Vixen
02b45cc4
csharp
public sealed class PredictionHistory

What this client thought the world looked like on each of the last few ticks.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Recorded through the replication codecs, which is the whole trick. A predicted entity's state is written with the same IComponentReplicator the server would have used, so a frame of history and a snapshot are the same bytes describing the same thing — and comparing them is a span comparison rather than a per-component equality nobody wrote.

It also settles what "predicted state" means: exactly what is replicated. That is not a limitation to be lifted later; it is the definition. A field the server never sends is a field no snapshot can contradict, so there is nothing to reconcile it against and nothing that could tell you the prediction was wrong.

Comparing in the encoded domain gets the tolerance right for free. A prediction that differs from the server in the last bit of a float is a difference below what the wire can express — the server's own value arrived quantized — so the two encode identically and no rollback happens. A naive float comparison would roll back on almost every snapshot and the cost would look like the feature working.

Fields and properties (2)

  • public int Depth

    How many ticks of history are kept.

  • public int Count

    How many frames are filled.

Methods (6)

  • public PredictionHistory(ReplicationRegistry registry, int depth = 32)

    Creates a history.

  • public void Record(World world, Tick tick)

    Records what the world looks like now, as this tick's prediction.

  • public bool Has(Tick tick)

    Whether a tick's prediction is still held.

  • public bool Matches(World world, Tick tick)

    Whether the world now matches what was predicted for a tick.

  • public bool TryRestore(World world, Tick tick)

    Puts a recorded prediction back into the world.

  • public void Clear()

    Forgets everything, for a client that has been put somewhere.

Used by (1)

  • ClientPredictionVixen.Net