use bevy_ecs::resource::Resource; use core::time::Duration; #[cfg(feature = "bevy_reflect")] use { bevy_ecs::reflect::ReflectResource, bevy_reflect::{std_traits::ReflectDefault, Reflect}, }; /// 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_secs()`](Time::delta_secs) and /// [`elapsed_secs()`](Time::elapsed_secs), and also in seconds as `f64` /// via [`delta_secs_f64()`](Time::delta_secs_f64) and /// [`elapsed_secs_f64()`](Time::elapsed_secs_f64). /// /// Since [`elapsed_secs()`](Time::elapsed_secs) 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_secs_wrapped()`](Time::elapsed_secs_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