bevy/crates/bevy_time/src
NiseVoid 1d3ae677df
Add discard_overstep function to Time<Fixed> (#10453)
# Objective

There is no easy way to discard some amount for `Time<Fixed>`'s
overstep. This can be useful for online games when the client receives
information about a tick (which happens when you get a FPS drop or the
ping changes for example) it has not yet processed, it can discard
overstep equal to the number of ticks it can jump ahead.

Currently the workaround would be to create a new `Time<Fixed>` copy the
old timestep, advance it by the overstep amount that would remain after
subtracting the discarded amount, and using `.context_mut()` to
overwrite the old context with the new one. If you overwrite the whole
`Time<Fixed>` or forget to copy over the timestep you can introduce
undesirable side effects.

## Solution

Introduce a `discard_overstep` method, which discards the provided
amount of overstep. It uses satuarting_sub to avoid errors (negative
`Duration`s do not exist).

---

## Changelog

- Added `discard_overstep` function to `Time<Fixed>`

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2023-11-18 00:50:26 +00:00
..
common_conditions.rs add on_real_time_timer run condition (#10179) 2023-10-20 12:58:37 +00:00
fixed.rs Add discard_overstep function to Time<Fixed> (#10453) 2023-11-18 00:50:26 +00:00
lib.rs Unify FixedTime and Time while fixing several problems (#8964) 2023-10-16 01:57:55 +00:00
real.rs Unify FixedTime and Time while fixing several problems (#8964) 2023-10-16 01:57:55 +00:00
stopwatch.rs Unify FixedTime and Time while fixing several problems (#8964) 2023-10-16 01:57:55 +00:00
time.rs docs: use read instead of deprecated iter (#10376) 2023-11-05 02:03:42 +00:00
timer.rs Rename Timer::{percent,percent_left} to Timer::{fraction,fraction_remaining} (#10442) 2023-11-13 14:59:42 +00:00
virt.rs Time: demote delta time clamping warning to debug (#10145) 2023-10-16 19:18:39 +00:00