bevy/crates/bevy_diagnostic/src
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
..
diagnostic.rs Add suffixes to diagnostics and other cleanup (#1505) 2021-03-03 03:43:15 +00:00
entity_count_diagnostics_plugin.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
frame_time_diagnostics_plugin.rs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
lib.rs updates on diagnostics (log + new diagnostics) (#1085) 2020-12-24 13:28:31 -06:00
log_diagnostics_plugin.rs ♻️ Timer refactor to duration. Add Stopwatch struct. (#1151) 2021-03-05 19:59:14 +00:00