From d5272aeeddd57b436c189de9ac384bada3b5339c Mon Sep 17 00:00:00 2001 From: NiseVoid Date: Wed, 8 Nov 2023 17:24:46 +0100 Subject: [PATCH] Add discard_overstep function to Time --- crates/bevy_time/src/fixed.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/bevy_time/src/fixed.rs b/crates/bevy_time/src/fixed.rs index 60270172aaa22..72e7fc648fee3 100644 --- a/crates/bevy_time/src/fixed.rs +++ b/crates/bevy_time/src/fixed.rs @@ -175,6 +175,14 @@ impl Time { self.context().overstep } + /// Discard a part of the overstep amount. If `discard` is higher than overstep, + /// overstep becomes zero. + #[inline] + pub fn discard_overstep(&mut self, discard: Duration) { + let context = self.context_mut(); + context.overstep = context.overstep.saturating_sub(discard); + } + /// Returns the amount of overstep time accumulated toward new steps, as an /// [`f32`] fraction of the timestep. #[inline]