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::Buffer between each GameState::Menu to work around the issue, as described above
- If duplicate states are not supposed to be allowed in the stack, then
state.push should check the entire stack to make sure that there are no duplicates. Then, I could run the logic that I have in on_enter and on_exit manually instead, or use events.
What problem does this solve or what need does it fill?
Currently, calling
state.pushon a state that the app is currently in yields anErr(StateError::AlreadyInState). This is a problem for devs who want to stack multiple states of the same variant. In my case, I have aGameState::Menustate that I want to stack directly on top of each other, since I have menus that lead to other menus. I haveon_enterandon_exitsystems that I want to run for each of my menus. My menus are determined at runtime, so I cannot add a newGameStatevariant for every menu in the game. My current workaround involves adding aGameState::Bufferbetween eachGameState::Menu. MyGameState::Bufferimmediately pushes a given state inon_enter, and immediately pops inon_resume. Removing the error fromstate.pushwould 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 fromstate.pushWhat alternative(s) have you considered?
GameState::Bufferbetween eachGameState::Menuto work around the issue, as described abovestate.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.