Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information