-
-
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-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_statescrate. - Move all core state logic out of
bevy_ecs. - Move
App::add_stateout ofbevy_apponto an extension trait. - Add
.on_update,.on_enterand.on_exitsystem modifiers via an extension trait. - Depend on
bevy_statesinbevy_coreas 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-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