-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 in_any_state
and in_all_states
run conditions
#11221
Comments
There are a number of proposed state changes in flight right now; I think we should land some of them, but we should do so with both eyes open and take a holistic view :) |
@ramirezmike - Do you think #11426 would end up resolving this use case? If that PR is merged, you'd approach this by creating a |
@lee-orr - That looks like it'd work well for this use case; I would say if that gets merged then this can be closed. |
This is also fixed in pyri_state without the need for defining a second state: add_systems(Update, MyState::with(|x| matches!(x, MyState::X | MyState::Y | ...)).on_update(my_systems)); Or if you want to look at states of different types (or anything in the ECS world), you can write your own run condition. |
I think that between the new computed states and a solid easy-to-swap-out third party solution the core need here is resolved. |
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?
The text was updated successfully, but these errors were encountered: