-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
A-AppBevy apps and pluginsBevy apps and pluginsA-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useM-Needs-Migration-GuideA breaking change to Bevy's public API that needs to be noted in a migration guideA breaking change to Bevy's public API that needs to be noted in a migration guideX-ControversialThere is active debate or serious implications around merging this PRThere is active debate or serious implications around merging this PR
Description
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?
- Create a new
bevy_states
crate. - Move all core state logic out of
bevy_ecs
. - Move
App::add_state
out ofbevy_app
onto an extension trait. - Add
.on_update
,.on_enter
and.on_exit
system modifiers via an extension trait. - Depend on
bevy_states
inbevy_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.
honungsburk and Stumblinbear
Metadata
Metadata
Assignees
Labels
A-AppBevy apps and pluginsBevy apps and pluginsA-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or changeC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useM-Needs-Migration-GuideA breaking change to Bevy's public API that needs to be noted in a migration guideA breaking change to Bevy's public API that needs to be noted in a migration guideX-ControversialThere is active debate or serious implications around merging this PRThere is active debate or serious implications around merging this PR