-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]>
- Loading branch information
1 parent
c7eaedd
commit 0174d63
Showing
2 changed files
with
135 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters