From 525f8c18b0d67d58cee398d0074c25c8a2dd4fe6 Mon Sep 17 00:00:00 2001 From: Niklas Eicker Date: Sun, 5 Dec 2021 18:59:53 +0100 Subject: [PATCH 1/5] Rename fixed timestep state and add a test --- crates/bevy_core/src/time/fixed_timestep.rs | 93 +++++++++++++++++++-- 1 file changed, 85 insertions(+), 8 deletions(-) diff --git a/crates/bevy_core/src/time/fixed_timestep.rs b/crates/bevy_core/src/time/fixed_timestep.rs index a22c874f92930..1a10f38f4631c 100644 --- a/crates/bevy_core/src/time/fixed_timestep.rs +++ b/crates/bevy_core/src/time/fixed_timestep.rs @@ -10,6 +10,7 @@ use bevy_ecs::{ use bevy_utils::HashMap; use std::borrow::Cow; +#[derive(PartialEq, Debug)] pub struct FixedTimestepState { pub step: f64, pub accumulator: f64, @@ -49,14 +50,14 @@ impl FixedTimesteps { } pub struct FixedTimestep { - state: State, + state: LocalFixedTimestepState, internal_system: Box>, } impl Default for FixedTimestep { fn default() -> Self { Self { - state: State::default(), + state: LocalFixedTimestepState::default(), internal_system: Box::new(Self::prepare_system.system()), } } @@ -65,7 +66,7 @@ impl Default for FixedTimestep { impl FixedTimestep { pub fn step(step: f64) -> Self { Self { - state: State { + state: LocalFixedTimestepState { step, ..Default::default() }, @@ -75,7 +76,7 @@ impl FixedTimestep { pub fn steps_per_second(rate: f64) -> Self { Self { - state: State { + state: LocalFixedTimestepState { step: 1.0 / rate, ..Default::default() }, @@ -89,7 +90,7 @@ impl FixedTimestep { } fn prepare_system( - mut state: Local, + mut state: Local, time: Res