@@ -182,6 +182,14 @@ impl Time<Fixed> {
182182 self . context ( ) . overstep
183183 }
184184
185+ /// Increase the overstep time accumulated towards new steps.
186+ ///
187+ /// This method is provided for use in tests. Ordinarily, the [`run_fixed_main_schedule`] system is responsible for calculating the overstep.
188+ #[ inline]
189+ pub fn accumulate_overstep ( & mut self , delta : Duration ) {
190+ self . context_mut ( ) . overstep += delta;
191+ }
192+
185193 /// Discard a part of the overstep amount.
186194 ///
187195 /// If `discard` is higher than overstep, the overstep becomes zero.
@@ -205,10 +213,6 @@ impl Time<Fixed> {
205213 self . context ( ) . overstep . as_secs_f64 ( ) / self . context ( ) . timestep . as_secs_f64 ( )
206214 }
207215
208- fn accumulate ( & mut self , delta : Duration ) {
209- self . context_mut ( ) . overstep += delta;
210- }
211-
212216 fn expend ( & mut self ) -> bool {
213217 let timestep = self . timestep ( ) ;
214218 if let Some ( new_value) = self . context_mut ( ) . overstep . checked_sub ( timestep) {
@@ -238,7 +242,9 @@ impl Default for Fixed {
238242/// [`RunFixedMainLoopSystems`](bevy_app::prelude::RunFixedMainLoopSystems).
239243pub fn run_fixed_main_schedule ( world : & mut World ) {
240244 let delta = world. resource :: < Time < Virtual > > ( ) . delta ( ) ;
241- world. resource_mut :: < Time < Fixed > > ( ) . accumulate ( delta) ;
245+ world
246+ . resource_mut :: < Time < Fixed > > ( )
247+ . accumulate_overstep ( delta) ;
242248
243249 // Run the schedule until we run out of accumulated time
244250 let _ = world. try_schedule_scope ( FixedMain , |world, schedule| {
@@ -278,7 +284,7 @@ mod test {
278284 assert_eq ! ( time. delta( ) , Duration :: ZERO ) ;
279285 assert_eq ! ( time. elapsed( ) , Duration :: ZERO ) ;
280286
281- time. accumulate ( Duration :: from_secs ( 1 ) ) ;
287+ time. accumulate_overstep ( Duration :: from_secs ( 1 ) ) ;
282288
283289 assert_eq ! ( time. delta( ) , Duration :: ZERO ) ;
284290 assert_eq ! ( time. elapsed( ) , Duration :: ZERO ) ;
@@ -294,7 +300,7 @@ mod test {
294300 assert_eq ! ( time. overstep_fraction( ) , 0.5 ) ;
295301 assert_eq ! ( time. overstep_fraction_f64( ) , 0.5 ) ;
296302
297- time. accumulate ( Duration :: from_secs ( 1 ) ) ;
303+ time. accumulate_overstep ( Duration :: from_secs ( 1 ) ) ;
298304
299305 assert_eq ! ( time. delta( ) , Duration :: ZERO ) ;
300306 assert_eq ! ( time. elapsed( ) , Duration :: ZERO ) ;
@@ -318,7 +324,7 @@ mod test {
318324 assert_eq ! ( time. overstep_fraction( ) , 0.0 ) ;
319325 assert_eq ! ( time. overstep_fraction_f64( ) , 0.0 ) ;
320326
321- time. accumulate ( Duration :: from_secs ( 1 ) ) ;
327+ time. accumulate_overstep ( Duration :: from_secs ( 1 ) ) ;
322328
323329 assert_eq ! ( time. delta( ) , Duration :: from_secs( 2 ) ) ;
324330 assert_eq ! ( time. elapsed( ) , Duration :: from_secs( 2 ) ) ;
@@ -339,7 +345,7 @@ mod test {
339345 fn test_expend_multiple ( ) {
340346 let mut time = Time :: < Fixed > :: from_seconds ( 2.0 ) ;
341347
342- time. accumulate ( Duration :: from_secs ( 7 ) ) ;
348+ time. accumulate_overstep ( Duration :: from_secs ( 7 ) ) ;
343349 assert_eq ! ( time. overstep( ) , Duration :: from_secs( 7 ) ) ;
344350
345351 assert ! ( time. expend( ) ) ; // true
0 commit comments