Skip to content

Comment on Representing Heterogeneous Dataparent

Comments

ECS is popular in games because each of your “things” can freely and dynamically change into anything. In a static type hierarchy this is not possible.

Each of your things that you want to identify and tell apart from other has an ID. Nothing else like a type is required.

Your ID can be registered in the melee fighter “system” (ECS lingo), inserted into the melee fighter table (relational db lingo). But it can also be registered in the table for ghosts, resulting in little girls reacting by crying, running away and shouting for a guard.

Once the ghost melee fighter finishes a quest to regain his body he’s removed from the ghost table. The advantage here is that this scales really well due the melee fighter and ghost systems not being tied to each other. In OOP you get combinatorial explosions of types resulting in a “god object” with many booleans to turn behavior off, or switching from type hierarchies to composition.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.