-
-
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.
# Objective Adjust bevy internals to utilize `Option<Res<State<S>>>` instead of `Res<State<S>>`, to allow for adding/removing states at runtime and avoid unexpected panics. As requested here: #10088 (comment) --- ## Changelog - Changed the use of `world.resource`/`world.resource_mut` to `world.get_resource`/`world.get_resource_mut` in the `run_enter_schedule` and `apply_state_transition` systems and handled the `None` option. - `in_state` now returns a ` FnMut(Option<Res<State<S>>>) -> bool + Clone`, returning `false` if the resource doesn't exist. - `state_exists_and_equals` was marked as deprecated, and now just runs and returns `in_state`, since their bevhaviour is now identical - `state_changed` now takes an `Option<Res<State<S>>>` and returns `false` if it does not exist. I would like to remove `state_exists_and_equals` fully, but wanted to ensure that is acceptable before doing so. --------- Co-authored-by: Mike <[email protected]>
- Loading branch information
Showing
2 changed files
with
59 additions
and
35 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