Re:Show HN: A Clojure game library
by willismichael on Monday January 20, 2014 @01:35PM
(#7091035)
One way that I prototyped a component-entity system that worked well for quick lookups was more like this:
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.
[ Parent
| on HN ]
Yes, 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)