bevy/crates
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
..
bevy_app Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_asset Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_audio Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_core ♻️ Timer refactor to duration. Add Stopwatch struct. (#1151) 2021-03-05 19:59:14 +00:00
bevy_derive Modify Derive to allow unit structs for RenderResources. (#1089) 2020-12-23 17:21:10 -06:00
bevy_diagnostic ♻️ Timer refactor to duration. Add Stopwatch struct. (#1151) 2021-03-05 19:59:14 +00:00
bevy_dylib release 0.4.0 (#1093) 2020-12-19 13:28:00 -06:00
bevy_dynamic_plugin update libloading (#1543) 2021-03-03 03:11:12 +00:00
bevy_ecs add Or back to prelude (#1564) 2021-03-05 18:33:20 +00:00
bevy_gilrs Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_gltf Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_input Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_internal Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_log Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_math More types (#1267) 2021-01-21 16:05:23 -08:00
bevy_pbr Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_reflect ♻️ Timer refactor to duration. Add Stopwatch struct. (#1151) 2021-03-05 19:59:14 +00:00
bevy_render Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_scene Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_sprite Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_tasks Xtask CI (#1387) 2021-02-22 08:42:19 +00:00
bevy_text Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_transform Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_ui Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_utils Update ahash requirement from 0.6.1 to 0.7.0 (#1370) 2021-02-01 13:29:54 -08:00
bevy_wgpu Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_window Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00
bevy_winit Bevy ECS V2 (#1525) 2021-03-05 07:54:35 +00:00