-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a scope
API for world schedules
#8387
Conversation
This reverts commit 0eed91d.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice: I was hoping we'd get these.
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
I'm not a big fan of the proliferation of the _ref functions, given the footgun with double boxing the label. Code quality looks good otherwise. |
I agree. I think we should merge the ref variants with the owned versions of these functions, but I'm including them for now for consistency with how |
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 asWorld::resource_scope
.Example
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.