bevy/examples/ecs
Chris Janaqi ab407aa697 ♻️ Timer refactor to duration. Add Stopwatch struct. (#1151)
This pull request is following the discussion on the issue #1127. Additionally, it integrates the change proposed by #1112.

The list of change of this pull request:

*  Add `Timer::times_finished` method that counts the number of wraps for repeating timers.
* ♻️ Refactored `Timer`
* 🐛 Fix a bug where 2 successive calls to `Timer::tick` which makes a repeating timer to finish makes `Timer::just_finished` to return `false` where it should return `true`. Minimal failing example:
```rust
use bevy::prelude::*;
let mut timer: Timer<()> = Timer::from_seconds(1.0, true);
timer.tick(1.5);
assert!(timer.finished());
assert!(timer.just_finished());
timer.tick(1.5);
assert!(timer.finished());
assert!(timer.just_finished()); // <- This fails where it should not
```
* 📚 Add extensive documentation for Timer with doc examples.
*  Add a `Stopwatch` struct similar to `Timer` with extensive doc and tests.

Even if the type specialization is not retained for bevy, the doc, bugfix and added method are worth salvaging 😅.
This is my first PR for bevy, please be kind to me ❤️ .

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2021-03-05 19:59:14 +00:00
..
change_detection.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
ecs_guide.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
event.rs ♻️ Timer refactor to duration. Add Stopwatch struct. (#1151) 2021-03-05 19:59:14 +00:00
fixed_timestep.rs Non-string labels (#1423 continued) (#1473) 2021-02-18 13:20:37 -08:00
hierarchy.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
parallel_query.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
removal_detection.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
startup_system.rs Adopt a Fetch pattern for SystemParams (#1074) 2020-12-15 21:57:16 -08:00
state.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
system_chaining.rs Rename add_resource to insert_resource (#1356) 2021-01-30 12:55:13 -08:00
system_param.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
timers.rs ♻️ Timer refactor to duration. Add Stopwatch struct. (#1151) 2021-03-05 19:59:14 +00:00