-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Description
What problem does this solve or what need does it fill?
Currently, calling state.push on a state that the app is currently in yields an Err(StateError::AlreadyInState). This is a problem for devs who want to stack multiple states of the same variant. In my case, I have a GameState::Menu state that I want to stack directly on top of each other, since I have menus that lead to other menus. I have on_enter and on_exit systems that I want to run for each of my menus. My menus are determined at runtime, so I cannot add a new GameState variant for every menu in the game. My current workaround involves adding a GameState::Buffer between each GameState::Menu. My GameState::Buffer immediately pushes a given state in on_enter, and immediately pops in on_resume. Removing the error from state.push would let me remove this workaround and help to clean up my game's logic.
What solution would you like?
I would like the return Err(StateError::AlreadyInState); statement to be removed from state.push
What alternative(s) have you considered?
- I am currently adding a
GameState::Bufferbetween eachGameState::Menuto work around the issue, as described above - If duplicate states are not supposed to be allowed in the stack, then
state.pushshould check the entire stack to make sure that there are no duplicates. Then, I could run the logic that I have inon_enterandon_exitmanually instead, or use events.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status