-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Use traits to make ECS APIs for working with entities more consistent #14231
Comments
This takes the |
We should consider allowing methods, e.g. |
I'm not worried about migration, so I'd prefer to avoid duplicating the APIs. |
As part of this, I would also propose considering
|
Old related issue: #5647 (for |
I think this could use a working group once there's enough bandwidth, since it'll require design work and has cross-cutting impact. |
Agreed with that. Lots of changes that need to be made in concert, and high levels of controversy. |
Another family of traits is |
@alice-i-cecile I think now might be a good time to do this since a lot of work is focused outside of |
I'd really like to land the BSN work before tackling this, because of the large impact it will have on how users initialize entities. Fully agree on the design-first approach here; that'll need sign-off from SME-ECS and Cart. |
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:
Commands
ChildBuilder
EntityCommands
World
WorldChildBuilder
EntityWorldMut
For example, you cannot use
trigger
fromChildBuilder
, but if you spawn an entity and getEntityCommands
you can callEntityCommands::commands()
and thenCommands::trigger_targets()
.Proposed solution
This issue proposed the following traits:
a)
Spawn
withspawn_empty()
andspawn()
for [1, 2, 4, 5],b)
GetCommands
withcommands()
for [1, 2, 3],c)
GetEntity
withentity()
for [1, 2, 4, 5],d)
Trigger
traittrigger()
andtrigger_targeted()
for [1, 2, 4, 5],e)
TriggerEntity
withtrigger()
for [3, 6],f)
Observe
withobserve()
for [1, 3, 4, 6],g)
ModifyEntity
withinsert()
andremove()
for [3, 6],h)
WithChildren
withwith_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
Spawn
What alternative(s) have you considered?
The traits can theoretically be a 3rd part crate, but missing methods need to be added in
bevy_ecs
anyways.Additional context
This is mostly frustrations collected during development of Bevy Jam Template
Relevant discord discussion can be found here
The text was updated successfully, but these errors were encountered: