bevy icon indicating copy to clipboard operation
bevy copied to clipboard

Fix inaccurate docs for `Commands::spawn_empty`

Open benfrankel opened this issue 1 year ago • 3 comments

Objective

Commands::spawn_empty docs say that it queues a command to spawn an entity, but it doesn't. It immediately reserves an Entity to be spawned at the next flush point, which is possible because Entities::reserve_entity() takes &self and no components are added yet.

Solution

Fix docs.

benfrankel avatar Jul 09 '24 05:07 benfrankel

I'm not sure if "immediately spawns ..." is accurate to how the ECS works internally, but it's definitely not queueing a command. Open to better wording suggestions.

benfrankel avatar Jul 09 '24 05:07 benfrankel

It immediately reserves the entity id with Entities::reserve_entity() but the entity only gets "created" in the next call to World::flush_entities() which is usually the next time commands are applied as it requires &mut World.

There are no literal commands though.

james-j-obrien avatar Jul 09 '24 05:07 james-j-obrien

Adjusted wording to better reflect that.

benfrankel avatar Jul 09 '24 05:07 benfrankel