Skip to content
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

Allow state.push with the same state that the app is in #4542

Closed
Seldom-SE opened this issue Apr 19, 2022 · 2 comments
Closed

Allow state.push with the same state that the app is in #4542

Seldom-SE opened this issue Apr 19, 2022 · 2 comments
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@Seldom-SE
Copy link

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.
@Seldom-SE Seldom-SE added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Apr 19, 2022
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Apr 19, 2022
@alice-i-cecile
Copy link
Member

@maniwani, this came up in #4391 :) Like we discussed there, this behavior should be changed.

@alice-i-cecile
Copy link
Member

The state stack has been removed by #7267.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
Archived in project
Development

No branches or pull requests

2 participants