rj00a / evenio

An event-driven Entity Component System
MIT License
129 stars 13 forks source link

Make `World` interface more convenient. #57

Open rj00a opened 4 months ago

rj00a commented 4 months ago

The iter methods should not construct a cached query on every invocation.

andrewgazelka commented 4 months ago

What are your thoughts on having an alternative spawn method?

let entity_id = world.spawn();
world.insert(entity_id, ComponentA);
world.insert(entity_id, ComponentB);

could potentially be cleaner if written like

let entity_id = world.spawn_entity((ComponentA, ComponentB));

I'm not set on the spawn_entity name. There may be a better name. This should clean up the code, though. Perhaps this could also help O(n^2) problem mentioned in #5 in certain situations (although not good perm solution)

rj00a commented 4 months ago

That seems reasonable. We could just change spawn to behave like spawn_entity and require writing .spawn(()) if the old behavior is needed. We will want to do the same for Sender too.

I don't think it would immediately help with #5 though since we want it to be semantically equivalent to inserting the components individually. We still need command batching to make that efficient.

andrewgazelka commented 4 months ago

That seems reasonable. We could just change spawn to behave like spawn_entity and require writing .spawn(()) if the old behavior is needed. We will want to do the same for Sender too.

I don't think it would immediately help with #5 though since we want it to be semantically equivalent to inserting the components individually. We still need command batching to make that efficient.

ok cool. I think bevy by default (I might be very wrong) lets one spawn an entity with multiple components in one call so I am for a new spawn impl

andrewgazelka commented 3 months ago

Hey @rj00a have you been working on this? I'm very interested in the new spawn impl but I do not want to work on it if you are working on this :) and it would really benefit me.

rj00a commented 3 months ago

Hey @rj00a have you been working on this? I'm very interested in the new spawn impl but I do not want to work on it if you are working on this :) and it would really benefit me.

Going to try to get this and #59 done today :)