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(crate) 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(crate) elapsed: f64,
26    /// Whether the timer is currently paused.
27    #[get(type(copy))]
28    #[new(skip)]
29    #[get(pub(crate))]
30    #[get_mut(pub(crate))]
31    #[set(pub(crate))]
32    pub(crate) paused: bool,
33    /// Whether a one-shot timer has fired and stopped.
34    #[get(type(copy))]
35    #[new(skip)]
36    #[get(pub(crate))]
37    #[get_mut(pub(crate))]
38    #[set(pub(crate))]
39    pub(crate) finished: bool,
40}