-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add in_any_state and in_all_states run conditions #11221
Copy link
Copy link
Closed
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useX-Needs-SMEThis type of work requires an SME to approve it.This type of work requires an SME to approve it.
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useX-Needs-SMEThis type of work requires an SME to approve it.This type of work requires an SME to approve it.
What problem does this solve or what need does it fill?
As games get more complex, users may find themselves wanting to setup a chain of systems to run in multiple separate states or on specific variant overlaps of multiple state types. While this is currently possible with combinator operations, it can be verbose and these patterns may be common enough to have dedicated run conditions. Searching for "or_else" on the discord yields quite a few instances of people asking (👀) how to do an OR with states.
What solution would you like?
Add two run conditions for handling multiple states: in_any_state for OR and in_all_states for AND. There's a good example to start from here for the OR version.
What alternative(s) have you considered?
Using or_else or and_then will suffice but again, it can get verbose
versus
Additional context
The "in_any_state" may be a bit more useful than the "in_all_states" as the latter is only useful if you're using multiple types of States. Additionally, depending on changes like #9942 this might get more complicated or be handled differently anyway?