[Beginner] relationship between entities / collection handling


I’m trying to clearly understand the architecture of entity system, but I’m facing a design problem.

A concrete case, the fleet : A fleet of ship is an entity. It have a name component, a position, a global strength,… and is composed of ship, which are entities to. Must the fleet EntityId be referenced by the ships, by something like an OwnedBy component ?

If I use this pattern, almost every Entity is owned by something, up to the game itself which hold all the tree. Is it a bad design, or is it something normal?

Thank you.

Depends on if it is actually used. If no system uses the OwnedBy component then you don’t need it.

One part of ES thinking is to break out of this idea of including data because you think you will need it or because it fits some model in your head. If a system needs a component then you add it. Else don’t.

So within those bounds, I have no idea because I don’t know enough about everything else. For example, why does the fleet have a position? Why would you ever need to know about entities “owned by the game”… all entities are already owned by the game by their very nature.

Be careful falling down OOP traps of designing all kinds of magic attributes ahead of time.

1 Like