Open benfrankel opened 2 months ago
I'm in favor.
Note that we went through many designs and this seems the cleanest by far imo. Bevy does not have the required answer to "How do I spawn an object composed of lots of stuff?" yet while still returning an EntityCommands
, so we need to introduce an abstraction here.
I'm also in favour of this.
Blocked on upstreaming https://github.com/bevyengine/bevy/issues/14278 and maybe https://github.com/bevyengine/bevy/issues/14231
An example of how the proposed API looks in practice: https://github.com/benfrankel/bevy_jam_template/blob/main/src/screen/title.rs.
Benefits:
EntityCommands
back immediately.SystemParam
s ergonomically by adding them as arguments.struct Projectile { lifetime, .. }
).struct Projectile
.EntityCommand
forProjectile
, and delegate to the spawning system withworld.run_system_once_with((id, self), projectile)
.In(id): In<Entity>
toIn((id, this)): In<(Entity, Projectile)>
.Drawbacks:
spawn_fn
andspawn_with
unfortunately couldn't be merged into one method.