3 ms·
One way that I prototyped a component-entity system that worked well for quick lookups was more like this: {:health {entity-id-1 32 entity-id
by willismichael 13y ago
One way that I prototyped a component-entity system that worked well for quick lookups was more like this:
{:health {entity-id-1 32
entity-id-2 23}
:location {entity-id-1 [32 16 7]
entity-id-2 [33 13 7]}
... more stuff ...}
So the entity data structure is organized first by component tag, then by entity id. I've heard this referred to as "inside-out objects". That way functions can quickly query things like "find all entities that have a location" or "find all entities that are poisoned". The downside is that there isn't a convenient way to atomically update multiple components of a single entity.
- Morgawr 13y agoYes, that's exactly how my ClojureScript prototype worked, the problem is that it wouldn't allow me to use concurrent entities. (Although you could use refs for tag-types instead of individual entitites... an interesting approach nonetheless)