pub struct RollbackSession<S: GameState> {
pub current_frame: Frame,
pub confirmed_frame: Frame,
pub buffer: RollbackBuffer<S>,
pub predictor: InputPredictor,
pub desync_detector: DesyncDetector,
pub net_stats: NetworkStats,
pub player_count: u8,
pub local_player_id: PlayerId,
pub input_delay: usize,
/* private fields */
}Expand description
Orchestrates frame advance, rollback, and re-simulation.
Fields§
§current_frame: Frame§confirmed_frame: Frame§buffer: RollbackBuffer<S>§predictor: InputPredictor§desync_detector: DesyncDetector§net_stats: NetworkStats§player_count: u8§local_player_id: PlayerId§input_delay: usizeImplementations§
Source§impl<S: GameState> RollbackSession<S>
impl<S: GameState> RollbackSession<S>
pub fn new(player_count: u8, local_player_id: PlayerId) -> Self
Sourcepub fn queue_local_input(&mut self, input: PlayerInput)
pub fn queue_local_input(&mut self, input: PlayerInput)
Queue local player’s input for a future frame (after input delay).
Sourcepub fn receive_remote_input(
&mut self,
player: PlayerId,
frame: Frame,
input: PlayerInput,
)
pub fn receive_remote_input( &mut self, player: PlayerId, frame: Frame, input: PlayerInput, )
Receive a remote player’s confirmed input.
Sourcepub fn build_frame_input(&mut self, state: &S) -> FrameInput
pub fn build_frame_input(&mut self, state: &S) -> FrameInput
Build a FrameInput for the current frame, predicting any missing remotes.
Sourcepub fn advance(&mut self, state: &mut S) -> FrameInput
pub fn advance(&mut self, state: &mut S) -> FrameInput
Advance one frame.
Sourcepub fn check_rollback(&mut self) -> Option<Frame>
pub fn check_rollback(&mut self) -> Option<Frame>
Check if rollback is needed due to late-arriving remote inputs. Returns the frame to roll back to, if any.
Sourcepub fn rollback_to(&mut self, target_frame: Frame, state: &mut S) -> bool
pub fn rollback_to(&mut self, target_frame: Frame, state: &mut S) -> bool
Perform rollback and re-simulation to a specific frame. Returns the new current state after re-simulation.
pub fn rollback_count(&self) -> u64
pub fn frames_behind(&self) -> u64
Auto Trait Implementations§
impl<S> Freeze for RollbackSession<S>
impl<S> RefUnwindSafe for RollbackSession<S>where
S: RefUnwindSafe,
impl<S> Send for RollbackSession<S>
impl<S> Sync for RollbackSession<S>where
S: Sync,
impl<S> Unpin for RollbackSession<S>where
S: Unpin,
impl<S> UnsafeUnpin for RollbackSession<S>
impl<S> UnwindSafe for RollbackSession<S>where
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
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.