bevy/crates/bevy_time/src
JoJoJet 0174d632a5
Add a scope API for world schedules (#8387)
# Objective

If you want to execute a schedule on the world using arbitrarily complex
behavior, you currently need to use "hokey-pokey strats": remove the
schedule from the world, do your thing, and add it back to the world.
Not only is this cumbersome, it's potentially error-prone as one might
forget to re-insert the schedule.

## Solution

Add the `World::{try}schedule_scope{ref}` family of functions, which is
a convenient abstraction over hokey pokey strats. This method
essentially works the same way as `World::resource_scope`.

### Example

```rust
// Run the schedule five times.
world.schedule_scope(MySchedule, |world, schedule| {
    for _ in 0..5 {
        schedule.run(world);
    }
});
```

---

## Changelog

Added the `World::schedule_scope` family of methods, which provide a way
to get mutable access to a world and one of its schedules at the same
time.

---------

Co-authored-by: James Liu <contact@jamessliu.com>
2023-04-16 05:09:33 +00:00
..
common_conditions.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
fixed_timestep.rs Add a scope API for world schedules (#8387) 2023-04-16 05:09:33 +00:00
lib.rs Suppress the clippy::type_complexity lint (#8313) 2023-04-06 21:27:36 +00:00
stopwatch.rs Fix various typos (#7096) 2023-01-06 00:43:30 +00:00
time.rs Schedule-First: the new and improved add_systems (#8079) 2023-03-18 01:45:34 +00:00
timer.rs Update old docs from Timer (#6646) 2022-11-18 20:42:33 +00:00