Expand description
Client-side prediction primitives with server reconciliation.
Complements crate::netcode (checksum-based rollback for the
full simulation) with a lighter-weight input-buffer / snapshot-
reconciliation core that individual game systems (character
controllers, projectiles) can wire up without invoking the entire
world rewind.
§Usage pattern
1. Client records inputs into a `PredictionBuffer` each tick and
stores a matching `Snapshot` produced by applying that input.
2. Client sends inputs to the authoritative server.
3. Server replies with the authoritative `Snapshot` for the tick
it just simulated.
4. Client calls `reconcile` with the server snapshot + the list of
inputs it has retained since that tick. `reconcile` rewinds the
local snapshot to the authoritative one, replays each stored
input, and returns the corrected head snapshot.The trait interface is generic over the game’s input, state, and integration function so callers can plug in any deterministic step.
Structs§
- Predicted
Input - A single client-side input tagged with the tick it applies to.
- Prediction
Buffer - Rolling buffer of unacknowledged inputs + matching predicted snapshots, sized so the oldest entry is dropped when the ring is full.
- Snapshot
- A snapshot of the predicted state at a particular tick.
Enums§
- Reconcile
Error - Why
reconcile_checkedcould not replay the buffered inputs.
Functions§
- reconcile
- Rewind a prediction buffer to
authoritativeand replay every buffered input with a caller-supplied integration function, returning the corrected head snapshot. - reconcile_
checked reconcilethat refuses an incomplete history.