Bevy: How about replace `Commands` with `WorldBuilder`?

Created on 21 Aug 2020  路  6Comments  路  Source: bevyengine/bevy

// this system spawns entities with the Position and Velocity components
fn setup(mut world: WorldBuilder) {
    world
        .spawn((Position(0.0), Velocity(1.0),))
        .spawn((Position(1.0), Velocity(2.0),));
}

When reading code, this feels more natural in concept.

I think the commands queue is an implementation detail, it should be contained in the world builder, and also insert resources by the world builder.

ecs enhancement

Most helpful comment

After thinking more, I convinced myself to against these options:

  1. Commands and Commander make not so much difference.
  2. With Res and Query we are decomposing App for ease of access.
  3. Bevy supports both games and tools, so App is more appropriate.

All 6 comments

This could be a nice step towards good type-safe commands too. You could also have EntityBuilder, ChildBuilder (already exists), etc. which would remove the need for panics in some of the functions.

So we do already have a WorldBuilder type that performs build operations directly on the real World type. Its basically a mirror of the current Commands interface. We would be stomping on it with a rename, but given that Commands is used everywhere, I'd be willing to give it priority for the "better" name.

I do agree that Commands isn't exactly self-documenting. Most of the time its just used to queue up world changes, so something like WorldBuilder makes sense in that context. But I think its important to note that it isn't just for queuing up World changes. Its also for queuing up Resource changes. And in the future we might use it to queue up system/app changes too.

That being said, lets leave issue open for a bit because I think its definitely useful to discuss the names (and apis) we should use here. I'd love to hear your thoughts!

Then I can think of the following options:

  1. Rename Commands to Commander.
  2. Replace Commands with AppBuilder, which can access all the entities, systems, resources and app itself.
  3. Rename current World to EntityStorage, current App to World.

Just for discussing, maybe either of the options not worth the effert.

After thinking more, I convinced myself to against these options:

  1. Commands and Commander make not so much difference.
  2. With Res and Query we are decomposing App for ease of access.
  3. Bevy supports both games and tools, so App is more appropriate.

So "Commands' controls the World and everything surrounding it? Sounds like a Universe :stuck_out_tongue_winking_eye:

Yeah I _think_ I'm happy with the names as they are. I'll close this issue for now, but feel free to create new issues if you have new name ideas.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fopsdev picture fopsdev  路  14Comments

cart picture cart  路  18Comments

cart picture cart  路  28Comments

hollg picture hollg  路  13Comments

cart picture cart  路  80Comments