My interpretation of this comment by Adam Martin, discussing how to model an airplane in an entity system --
Since an entity is formally just “a name”, a component can refer to other entities easily.
Personally, I’d be tempted to have a separate “plane” entity that had a “PlaneParts” component that was just a list of the names of the other entities on the plane.
-- is that components should never reference other components, but components can reference entities.
So I see two ways to do this:
- The player entity (not the player component) has a 'citizenOf' component, which has a reference to the city entity (not the city component).
- The city entity (not the city component) has a 'citizens' component, which (cf. the first part of Boreal's answer) contains a list of player entities (not player components)
Which way you want to model it probably depends on which way is going to make it more efficient to access the data.
Note that in neither case (contra the second part of Boreal's answer) does any component know about any other component, nor does any component care what other components the related entities have.
This, IMO, is the major advantage of an entity system for designers -- if you decide on the fly that potatoes can be citizens, or potatoes can have citizens, there's nothing in the entity-component system to stop you from doing that.
(And yes, you're probably not going to do make potatoes citizens, but you might make NPCs citizens; and yes, you're probably not going to make a player a citizen of a potato, but you might make a player a citizen of a village, or a guild, or a city-less nomadic tribe.)