use core::time::Duration;
use bevy::{ecs::system::SystemParam, prelude::*};
#[derive(SystemParam, Deref)]
pub struct ContextTime<'w> {
#[deref]
pub virt: Res<'w, Time>,
pub real: Res<'w, Time<Real>>,
}
impl ContextTime<'_> {
#[must_use]
pub fn delta_kind(&self, kind: TimeKind) -> Duration {
match kind {
TimeKind::Virtual => self.virt.delta(),
TimeKind::Real => self.real.delta(),
}
}
}
#[derive(Debug, Default, Clone, Copy)]
#[cfg_attr(feature = "reflect", derive(Reflect), reflect(Clone, Debug, Default))]
pub enum TimeKind {
#[default]
Real,
Virtual,
}