pub struct PredictionBuffer<I, S> { /* private fields */ }Expand description
Bounded client input/state history for server reconciliation.
Implementations§
Source§impl<I, S> PredictionBuffer<I, S>
impl<I, S> PredictionBuffer<I, S>
Sourcepub fn new(config: PredictionConfig) -> NetcodeResult<Self>
pub fn new(config: PredictionConfig) -> NetcodeResult<Self>
Creates an empty prediction history.
Sourcepub fn record(
&mut self,
tick: u64,
input: I,
predicted_state: S,
) -> NetcodeResult<()>
pub fn record( &mut self, tick: u64, input: I, predicted_state: S, ) -> NetcodeResult<()>
Records one successfully simulated local input and resulting state.
Sourcepub fn confirmed_tick(&self) -> u64
pub fn confirmed_tick(&self) -> u64
Returns the highest authoritative Tick already reconciled.
Sourcepub fn pending_len(&self) -> usize
pub fn pending_len(&self) -> usize
Returns the number of inputs awaiting authoritative confirmation.
Sourcepub fn frames(&self) -> impl Iterator<Item = &PredictionFrame<I, S>>
pub fn frames(&self) -> impl Iterator<Item = &PredictionFrame<I, S>>
Iterates retained prediction frames in Tick order.
Source§impl<I, S> PredictionBuffer<I, S>where
S: Clone,
impl<I, S> PredictionBuffer<I, S>where
S: Clone,
Sourcepub fn reconcile<Simulate>(
&mut self,
authoritative_tick: u64,
authoritative_state: S,
simulate: Simulate,
) -> NetcodeResult<ReconciliationReport<S>>
pub fn reconcile<Simulate>( &mut self, authoritative_tick: u64, authoritative_state: S, simulate: Simulate, ) -> NetcodeResult<ReconciliationReport<S>>
Restores an authoritative state and deterministically replays later local inputs.
simulate owns game rules and must advance state exactly once for the supplied Tick and
input. A replay-limit or ordering error leaves the buffer unchanged.
Trait Implementations§
Auto Trait Implementations§
impl<I, S> Freeze for PredictionBuffer<I, S>
impl<I, S> RefUnwindSafe for PredictionBuffer<I, S>where
I: RefUnwindSafe,
S: RefUnwindSafe,
impl<I, S> Send for PredictionBuffer<I, S>
impl<I, S> Sync for PredictionBuffer<I, S>
impl<I, S> Unpin for PredictionBuffer<I, S>
impl<I, S> UnsafeUnpin for PredictionBuffer<I, S>
impl<I, S> UnwindSafe for PredictionBuffer<I, S>where
I: UnwindSafe,
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more