Expand description
Deterministic gameplay timers driven explicitly by simulation deltas.
Timers never read wall-clock time and own no host resources, so they may be stored directly in script structs. Hot reload resets unexposed script state.
use kvas_engine::timer::{Timer, TimerMode};
use std::time::Duration;
let mut timer = Timer::new(Duration::from_millis(100), TimerMode::Repeating);
timer.tick(Duration::from_millis(250));
assert_eq!(timer.times_finished(), 2);
assert_eq!(timer.elapsed(), Duration::from_millis(50));
assert!((timer.fraction() - 0.5).abs() < 1e-6);Structs§
- Timer
- Explicitly ticked timer with pause, reset and exact duration accounting. A zero-duration timer completes once per non-paused tick, including a zero tick.
Enums§
- Timer
Mode - What happens when a timer reaches its duration.