bevy
bevy copied to clipboard
Add a variant of `spawn` that returns the spawned entity's ID
What problem does this solve or what need does it fill?
A very common pattern for spawning entities looks like this:
let id = commands
.spawn((
Transform::default(),
GlobalTransform::default(),
))
.id();
The .id() call makes rustfmt add an extra level of indentation, which makes the code worse.
What solution would you like?
Add a variant of spawn that returns the spawned entity's ID:
let id = commands.spawn_with_id((
Transform::default(),
GlobalTransform::default(),
));
What alternative(s) have you considered?
Instead of adding a new method, change spawn to return the entity's ID. I do not like this solution, since it would get in the way if you want to use EntityCommands.