Composing Entities
Learn about entities and their properties.
We'll cover the following
How to form an entity
Entities are composed by combining descriptive components. Whenever we add a component type (and systems that use it), we’re offering that functionality to any entity. We can use it for everything, or we may restrict it to a small number of special creatures, but every time we add a component, we’re giving ourselves options. We can now add that functionality to anything we like. Some combinations may not make sense, but with a little thought, we can quickly add realism and fun to our game.
Advantage of using components
One advantage of using component composition is that it’s easier to translate from an English description of a monster to a set of components. We might write that a goblin is a small, green, angry humanoid. They roam the dungeon, preying upon unsuspecting adventurers. They prefer to attack from a distance and they are cowardly and quite weak. Reading a description like this gives us some valuable clues as to what components our goblin may require:
- It’s humanoid, so it requires the same
Render
components as other humanoids. - It has a
Position
on the map. - It’s angry, so we need an
AI
component denoting that it attacks on sight. - It prefers ranged attacks, so our AI components should indicate that.
- It’s cowardly. Maybe that needs a component when we implement running away?
- It’s quite weak, so it should have few hitpoints.
As we add components, entity design becomes a checklist. What components properly describe this new creature? For example:
Get hands-on with 1400+ tech skills courses.