Skip to main content

euv_engine/timer/
struct.rs

1use super::*;
2
3/// A countdown timer that fires after a fixed duration, optionally repeating.
4///
5/// Timers are updated with the frame delta time; [`Timer::update`] returns
6/// the number of times the timer fired during that update (0 or 1 for
7/// one-shot timers, possibly more for repeating timers after a long frame).
8#[derive(Clone, Copy, Data, Debug, New, PartialEq, PartialOrd)]
9pub struct Timer {
10    /// The countdown duration in seconds.
11    #[get(type(copy))]
12    #[set(pub(crate))]
13    #[get_mut(pub(crate))]
14    pub duration: f64,
15    /// Whether the timer restarts automatically after firing.
16    #[get(pub(crate), type(copy))]
17    #[set(pub(crate))]
18    #[get_mut(pub(crate))]
19    pub(crate) repeating: bool,
20    /// The time accumulated since the timer started or last fired.
21    #[get(type(copy))]
22    #[get_mut(pub(crate))]
23    #[set(pub(crate))]
24    #[new(skip)]
25    pub elapsed: f64,
26    /// Whether the timer is currently paused.
27    #[get(type(copy), pub(crate))]
28    #[new(skip)]
29    #[get_mut(pub(crate))]
30    #[set(pub(crate))]
31    pub(crate) paused: bool,
32    /// Whether a one-shot timer has fired and stopped.
33    #[get(type(copy), pub(crate))]
34    #[new(skip)]
35    #[get_mut(pub(crate))]
36    #[set(pub(crate))]
37    pub(crate) finished: bool,
38}