use bevy_ecs::{reflect::ReflectResource, system::Resource}; use bevy_reflect::{std_traits::ReflectDefault, Reflect}; use bevy_utils::Duration; /// A generic clock resource that tracks how much it has advanced since its /// previous update and since its creation. /// /// Multiple instances of this resource are inserted automatically by /// [`TimePlugin`](crate::TimePlugin): /// /// - [`Time`](crate::real::Real) tracks real wall-clock time elapsed. /// - [`Time`](crate::virt::Virtual) tracks virtual game time that may /// be paused or scaled. /// - [`Time`](crate::fixed::Fixed) tracks fixed timesteps based on /// virtual time. /// - [`Time`] is a generic clock that corresponds to "current" or "default" /// time for systems. It contains [`Time`](crate::virt::Virtual) /// except inside the [`FixedMain`](bevy_app::FixedMain) schedule when it /// contains [`Time`](crate::fixed::Fixed). /// /// The time elapsed since the previous time this clock was advanced is saved as /// [`delta()`](Time::delta) and the total amount of time the clock has advanced /// is saved as [`elapsed()`](Time::elapsed). Both are represented as exact /// [`Duration`] values with fixed nanosecond precision. The clock does not /// support time moving backwards, but it can be updated with [`Duration::ZERO`] /// which will set [`delta()`](Time::delta) to zero. /// /// These values are also available in seconds as `f32` via /// [`delta_seconds()`](Time::delta_seconds) and /// [`elapsed_seconds()`](Time::elapsed_seconds), and also in seconds as `f64` /// via [`delta_seconds_f64()`](Time::delta_seconds_f64) and /// [`elapsed_seconds_f64()`](Time::elapsed_seconds_f64). /// /// Since [`elapsed_seconds()`](Time::elapsed_seconds) will grow constantly and /// is `f32`, it will exhibit gradual precision loss. For applications that /// require an `f32` value but suffer from gradual precision loss there is /// [`elapsed_seconds_wrapped()`](Time::elapsed_seconds_wrapped) available. The /// same wrapped value is also available as [`Duration`] and `f64` for /// consistency. The wrap period is by default 1 hour, and can be set by /// [`set_wrap_period()`](Time::set_wrap_period). /// /// # Accessing clocks /// /// By default, any systems requiring current [`delta()`](Time::delta) or /// [`elapsed()`](Time::elapsed) should use `Res