I am sort of late to this discussion but I am looking on how to implement the pattern myself,
Ok thanks for your answers.
I have another trouble:
- My game has maps
- Maps are made of cells
- Cells have a position, an ID and a texture.
What should be the components, what should be the entities?
I'm pretty sure Map should be an entity, but then:
- Cell can't be an entity (otherwise I can't use it in my Map entity)
- Cell can't be a component since it uses other components (Position, ID and Texture).
And the same problem goes for a lot of things. Can one use component in other components or did I get it all wrong?
From what I've gathered I would say neither of those are entities, they all should be part of a map resource, referenced by a map component that is updated by a map system.
To elaborate, your map may be a XML document with cell or tile elements themselves with position (relative to the origin), id and texture (itself a reference to an image, shader and/or material) attributes.
You write some code to convert the XML into a runtime resource object, which is then referenced by a map component, the component is the "instantiation" of your resource, and it will then contain information specific for that instance of the resource, for example position if your map may coexist with multiple maps snapped together.
Later on, in your game loop you may have a map system which updates any variables in your map component, and a rendering system may render it later, or a collision system may query the component which itself would query the resource for collision information, etc.