Entity Component Architecture

vladdeSV via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 26 12:30:43 PDT 2016


On Wednesday, 24 August 2016 at 22:26:00 UTC, Chris Wright wrote:
> It's like thirty lines of code and does almost nothing that I 
> need.
I've never done anything similar to this. I do not know what 
others might need.

> Why no `getOrAdd`?
Entity has getComponent and addComponent which do different 
things.

> Why no ID?
I simply found no use of them in the small test I did.

> Why is there nothing to help me find all components of a given 
> type?
An Entity must only have one (1) of a component type. I have not 
found a use of having two of the same components.

> Where's the reference back from Component to Entity?
In my implementation, via the `void update(Entity e)` method. 
Update is the only part of a component which interacts with the 
Entity.

> How do I get all components on an entity that implement a given 
> interface?
Never thought of this. That could come in handy, but I, 
personally, do not see any use of it.

> Why do all components need to have `update()` and `active`?
`update(Entity e)` is the core of ECA, `active` is something I 
added in which simply allows components to have an on/off state. 
Not necessary though.

> I really don't think the problem your library is addressing is 
> both complex enough and standardized enough to reasonably turn 
> it into a library.
I think you see this as ECS, which it is not. This system only 
uses the terms Entity and Component, but does not behave in the 
way ECS does. When it comes to this approach, it is definitely 
not the way traditional ECS should behave. But this is not ECS. 
It is ECA.


More information about the Digitalmars-d mailing list