![]() # 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: https://github.com/bevyengine/bevy/pull/10088#issuecomment-1869185413 --- ## 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 <mike.hsu@gmail.com> |
||
---|---|---|
.. | ||
entity | ||
identifier | ||
query | ||
reflect | ||
schedule | ||
storage | ||
system | ||
world | ||
archetype.rs | ||
bundle.rs | ||
change_detection.rs | ||
component.rs | ||
event.rs | ||
lib.rs | ||
removal_detection.rs |