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    pub(crate) duration: f64,
14    /// Whether the timer restarts automatically after firing.
15    #[get(type(copy))]
16    #[set(pub(crate))]
17    pub(crate) repeating: bool,
18    /// The time accumulated since the timer started or last fired.
19    #[get(pub(crate), type(copy))]
20    #[get_mut(pub(crate))]
21    #[set(pub(crate))]
22    #[new(skip)]
23    pub(crate) elapsed: f64,
24    /// Whether the timer is currently paused.
25    #[get(type(copy))]
26    #[new(skip)]
27    pub(crate) paused: bool,
28    /// Whether a one-shot timer has fired and stopped.
29    #[get(type(copy))]
30    #[new(skip)]
31    pub(crate) finished: bool,
32}