Document repeating timer tick behavior (#20137)

# Objective

Closes #20132 

## Solution

I found docs describing the behavior elsewhere in Bevy, which I pulled
in to the main `Timer` docs:
b01de70bdd/crates/bevy_time/src/common_conditions.rs (L27-L35)

I also restructured the docs a little bit.
This commit is contained in:
onbjerg 2025-07-15 00:31:31 +02:00 committed by GitHub
parent 2cb8450fa4
commit 554bc7b0d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,13 +5,25 @@ use core::time::Duration;
/// Tracks elapsed time. Enters the finished state once `duration` is reached.
///
/// Non repeating timers will stop tracking and stay in the finished state until reset.
/// Repeating timers will only be in the finished state on each tick `duration` is reached or
/// exceeded, and can still be reset at any given point.
///
/// Paused timers will not have elapsed time increased.
///
/// Note that in order to advance the timer [`tick`](Timer::tick) **MUST** be called.
///
/// # Timer modes
///
/// There are two timer modes ([`TimerMode`]):
///
/// - Non repeating timers will stop tracking and stay in the finished state until reset.
/// - Repeating timers will only be in the finished state on each tick `duration` is reached or
/// exceeded, and can still be reset at any given point.
///
/// # Pausing timers
///
/// You can pause a timer using [`Timer::pause`]. Paused timers will not have elapsed time increased.
///
/// # Elapsing multiple times a frame
///
/// Repeating timers might elapse multiple times per frame if the time is advanced by more than the timer duration.
/// You can check how many times a timer elapsed each tick with [`Timer::times_finished_this_tick`].
/// For non-repeating timers, this will always be 0 or 1.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serialize", derive(serde::Deserialize, serde::Serialize))]
#[cfg_attr(