pub struct RollbackState {
pub max_rollback: usize,
pub current_frame: u64,
pub rollback_log: Vec<u64>,
pub player_count: usize,
/* private fields */
}Expand description
Rollback netcode state: stores a history of inputs for re-simulation.
Fields§
§max_rollback: usize§current_frame: u64§rollback_log: Vec<u64>Frame numbers where rollback was needed.
player_count: usizeImplementations§
Source§impl RollbackState
impl RollbackState
pub fn new(player_count: usize, max_rollback: usize) -> Self
Sourcepub fn add_remote_input(&mut self, input: NetInput)
pub fn add_remote_input(&mut self, input: NetInput)
Add a confirmed input from a remote player.
Sourcepub fn get_input(&self, frame: u64, player: u8) -> NetInput
pub fn get_input(&self, frame: u64, player: u8) -> NetInput
Get input for (frame, player): confirmed if available, else predicted.
Sourcepub fn predict_input(&mut self, frame: u64, player: u8)
pub fn predict_input(&mut self, frame: u64, player: u8)
Predict next frame’s input by repeating current frame’s input.
pub fn advance_frame(&mut self)
pub fn needs_rollback(&self) -> bool
pub fn consume_rollback(&mut self) -> Option<u64>
Auto Trait Implementations§
impl Freeze for RollbackState
impl RefUnwindSafe for RollbackState
impl Send for RollbackState
impl Sync for RollbackState
impl Unpin for RollbackState
impl UnsafeUnpin for RollbackState
impl UnwindSafe for RollbackState
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.