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

Adapt Commands apis for consistency with new World apis #1562

Closed
alice-i-cecile opened this issue Mar 5, 2021 · 5 comments
Closed

Adapt Commands apis for consistency with new World apis #1562

alice-i-cecile opened this issue Mar 5, 2021 · 5 comments
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use
Milestone

Comments

@alice-i-cecile
Copy link
Member

From Future Work of #1525.

@alice-i-cecile
Copy link
Member Author

@cart there's quite a few of us who are enthusiastic about this change, and I think the API consistency is very valuable. Can we add this to the 0.5 milestone?

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Mar 5, 2021
@cart cart added this to the Bevy 0.5 milestone Mar 6, 2021
@cart
Copy link
Member

cart commented Mar 6, 2021

Yup I dig it!

@cart
Copy link
Member

cart commented Mar 19, 2021

Theres only one mismatch between Commands and World:

world.spawn().insert_bundle(SomeBundle { .. });

commands.spawn(SomeBundle { .. });

I'm thinking that moving to commands.spawn().insert_bundle(SomeBundle {..}) would largely just result in more boilerplate. Ex: we don't have a single Bevy example that needs to spawn an empty entity.

I think that consistency is a good idea, but maybe we should pursue alternatives, such as making world.spawn() take a Bundle again, then add something like world.spawn_empty() and commands.spawn_empty().

However there is the matter of spawn(SomeBundle) not explicitly calling out that the parameter is a bundle (which confuses newbies). We could consider adding a new commands.spawn_bundle(SomeBundle) command, then commands.spawn() could just create a new empty entity.

@cart
Copy link
Member

cart commented Mar 20, 2021

Currently investigating how disruptive moving to an api that completely mirrors the relevant World functions (including the "type state" pattern). I don't want to rush that in, but its also pretty surface level. I largely want to see how painful it is to adapt the examples.

bors bot pushed a commit that referenced this issue Mar 23, 2021
Resolves #1253 #1562

This makes the Commands apis consistent with World apis. This moves to a "type state" pattern (like World) where the "current entity" is stored in an `EntityCommands` builder.

In general this tends to cuts down on indentation and line count. It comes at the cost of needing to type `commands` more and adding more semicolons to terminate expressions.

I also added `spawn_bundle` to Commands because this is a common enough operation that I think its worth providing a shorthand.
@cart
Copy link
Member

cart commented Mar 23, 2021

Closed by #1703

@cart cart closed this as completed Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

No branches or pull requests

2 participants