bevy/examples/ecs
Lena Milizé 73605f43b6 Replace the bool argument of Timer with TimerMode (#6247)
As mentioned in #2926, it's better to have an explicit type that clearly communicates the intent of the timer mode rather than an opaque boolean, which can be only understood when knowing the signature or having to look up the documentation.

This also opens up a way to merge different timers, such as `Stopwatch`, and possibly future ones, such as `DiscreteStopwatch` and `DiscreteTimer` from #2683, into one struct.

Signed-off-by: Lena Milizé <me@lvmn.org>

# Objective

Fixes #2926.

## Solution

Introduce `TimerMode` which replaces the `bool` argument of `Timer` constructors. A `Default` value for `TimerMode` is `Once`.

---

## Changelog

### Added

- `TimerMode` enum, along with variants `TimerMode::Once` and `TimerMode::Repeating`

### Changed

- Replace `bool` argument of `Timer::new` and `Timer::from_seconds` with `TimerMode`
- Change `repeating: bool` field of `Timer` with `mode: TimerMode`

## Migration Guide

- Replace `Timer::new(duration, false)` with `Timer::new(duration, TimerMode::Once)`.
- Replace `Timer::new(duration, true)` with `Timer::new(duration, TimerMode::Repeating)`.
- Replace `Timer::from_seconds(seconds, false)` with `Timer::from_seconds(seconds, TimerMode::Once)`.
- Replace `Timer::from_seconds(seconds, true)` with `Timer::from_seconds(seconds, TimerMode::Repeating)`.
- Change `timer.repeating()` to `timer.mode() == TimerMode::Repeating`.
2022-10-17 13:47:01 +00:00
..
component_change_detection.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
custom_query_param.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
ecs_guide.rs Exclusive Systems Now Implement System. Flexible Exclusive System Params (#6083) 2022-09-26 23:57:07 +00:00
event.rs Replace the bool argument of Timer with TimerMode (#6247) 2022-10-17 13:47:01 +00:00
fixed_timestep.rs Split time functionality into bevy_time (#4187) 2022-05-26 00:27:18 +00:00
generic_system.rs Replace the bool argument of Timer with TimerMode (#6247) 2022-10-17 13:47:01 +00:00
hierarchy.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
iter_combinations.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
parallel_query.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
removal_detection.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
startup_system.rs Doc/module style doc blocks for examples (#4438) 2022-05-16 13:53:20 +00:00
state.rs Rename UiColor to BackgroundColor (#6087) 2022-09-25 00:39:17 +00:00
system_closure.rs Doc/module style doc blocks for examples (#4438) 2022-05-16 13:53:20 +00:00
system_param.rs Spawn now takes a Bundle (#6054) 2022-09-23 19:55:54 +00:00
system_piping.rs Rename system chaining to system piping (#6230) 2022-10-11 15:21:12 +00:00
system_sets.rs Remove last uses of string-labels (#5420) 2022-09-03 18:06:41 +00:00
timers.rs Replace the bool argument of Timer with TimerMode (#6247) 2022-10-17 13:47:01 +00:00