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

Split States into their own crate, and add convenience app extension methods #7906

Closed
alice-i-cecile opened this issue Mar 5, 2023 · 2 comments
Labels
A-App Bevy apps and plugins A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide X-Controversial There is active debate or serious implications around merging this PR

Comments

@alice-i-cecile
Copy link
Member

What problem does this solve or what need does it fill?

Bevy states are well-isolated from other app or ECS logic, and not all users will want to use our exact implementation (e.g. some users may want a state stack).

Adding dedicated methods to manage and work with states to both bevy_app and bevy_ecs feels "wrong" as a result: it ends up polluting APIs with what could reasonably be an add-on.

What solution would you like?

  1. Create a new bevy_states crate.
  2. Move all core state logic out of bevy_ecs.
  3. Move App::add_state out of bevy_app onto an extension trait.
  4. Add .on_update, .on_enter and .on_exit system modifiers via an extension trait.
  5. Depend on bevy_states in bevy_core as an optional dependency and add the extension traits and structs back to the prelude.

What alternative(s) have you considered?

If we want to replace startup systems with states as in #5437, we should be able to retain this design, and simply import bevy_states in bevy_core.

Additional context

This was proposed by @maniwani in #7790 here, which attempted to add sugar for on_update.

#7634 is also something to be mindful of during the implementation.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use A-App Bevy apps and plugins M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide X-Controversial There is active debate or serious implications around merging this PR labels Mar 5, 2023
@swfsql
Copy link

swfsql commented Mar 8, 2023

Hi, I've started learning Bevy a couple of days ago, and the state update was very welcome!
Just today I've been trying out some ergonomics builder, link to an example.

I'll be looking forward to the development, and thanks for your work!

@alice-i-cecile
Copy link
Member Author

Fixed by #13216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-App Bevy apps and plugins A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

No branches or pull requests

2 participants