-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Use traits to make ECS APIs for working with entities more consistent #14231
Copy link
Copy link
Open
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesX-ContentiousThere are nontrivial implications that should be thought throughThere are nontrivial implications that should be thought through
Metadata
Metadata
Assignees
Labels
A-ECSEntities, components, systems, and eventsEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to useD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesSimple bug fixes and API improvements, docs, test and examplesX-ContentiousThere are nontrivial implications that should be thought throughThere are nontrivial implications that should be thought through
What problem does this solve or what need does it fill?
Parts of ECS API are missing methods, which have no reason to not exist.
Types that this is most visible on are:
CommandsChildBuilderEntityCommandsWorldWorldChildBuilderEntityWorldMutFor example, you cannot use
triggerfromChildBuilder, but if you spawn an entity and getEntityCommandsyou can callEntityCommands::commands()and thenCommands::trigger_targets().Proposed solution
This issue proposed the following traits:
a)
Spawnwithspawn_empty()andspawn()for [1, 2, 4, 5],b)
GetCommandswithcommands()for [1, 2, 3],c)
GetEntitywithentity()for [1, 2, 4, 5],d)
Triggertraittrigger()andtrigger_targeted()for [1, 2, 4, 5],e)
TriggerEntitywithtrigger()for [3, 6],f)
Observewithobserve()for [1, 3, 4, 6],g)
ModifyEntitywithinsert()andremove()for [3, 6],h)
WithChildrenwithwith_children()for [3, 6].In general pairs of [1, 4], [2, 5], [3, 6] should share traits.
Now, this is just a proposal.
I want this issue to help decide the actual scope.
Ideally, key traits would make it to 0.14 without introducing breaking changes.
Example implementation for
SpawnWhat alternative(s) have you considered?
The traits can theoretically be a 3rd part crate, but missing methods need to be added in
bevy_ecsanyways.Additional context
This is mostly frustrations collected during development of Bevy Jam Template
Relevant discord discussion can be found here