Skip to main content

GameState

Trait GameState 

Source
pub trait GameState:
    Clone
    + Send
    + 'static {
    // Required methods
    fn advance(&mut self, inputs: &FrameInput);
    fn checksum(&self) -> u64;

    // Provided method
    fn snapshot_size_hint() -> usize { ... }
}
Expand description

Implement this on your game state to enable rollback.

Required Methods§

Source

fn advance(&mut self, inputs: &FrameInput)

Advance simulation by one frame using the given inputs.

Source

fn checksum(&self) -> u64

Compute a checksum of the game state (for desync detection).

Provided Methods§

Source

fn snapshot_size_hint() -> usize

Memory size hint for the snapshot (used for buffer sizing).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§