use crate::prelude::*;
pub struct AhoyFixedUpdateUtilsPlugin;
impl Plugin for AhoyFixedUpdateUtilsPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<DidFixedTimestepRunThisFrame>()
.add_systems(PreUpdate, clear_fixed_timestep_flag)
.add_systems(FixedPreUpdate, set_fixed_time_step_flag);
}
}
#[derive(Resource, Debug, Deref, DerefMut, Default)]
pub(crate) struct DidFixedTimestepRunThisFrame(bool);
fn clear_fixed_timestep_flag(
mut did_fixed_timestep_run_this_frame: ResMut<DidFixedTimestepRunThisFrame>,
) {
did_fixed_timestep_run_this_frame.0 = false;
}
fn set_fixed_time_step_flag(
mut did_fixed_timestep_run_this_frame: ResMut<DidFixedTimestepRunThisFrame>,
) {
did_fixed_timestep_run_this_frame.0 = true;
}
pub(crate) fn did_fixed_timestep_run_this_frame(
did_fixed_timestep_run_this_frame: Res<DidFixedTimestepRunThisFrame>,
) -> bool {
did_fixed_timestep_run_this_frame.0
}