pub trait TickSim {
type Event;
// Required methods
fn step(&mut self, input: &TickInput) -> Vec<Self::Event>;
fn hash(&self) -> u64;
}Expand description
A game’s rules that step in time: 60 fixed steps a second
(STEPS_PER_SECOND), each given the players’
input for it.
§Contract
- Deterministic. The same state and input always give the same
events and the same new state, on every platform. Luck comes from a
seeded RNG kept in the state (
SimRng); there is no clock, no I/O and no float in the state or the step. So a run is rebuilt from its seed and its inputs (TickRecord,replay). - Time is steps. One call of
stepis one step. Timers advance by 1 in it (timer). - Events are the only way out. What a screen shows or plays (a
sound, say) comes from the events
stepreturns, so a step run again after a rewind plays nothing twice (shuyi_ui::tick::TickDriverhands each step’s events on once). hashchanges when the state does and is the same on every platform: most simplystate_hash(self)’s (state_hash).
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".