-
Notifications
You must be signed in to change notification settings - Fork 0
Entity Component System
This guide explains what is an ECS. But also how it is implemented in the Goat Engine.
An entity is the simplest unit of data in an ECS. It represents an object in a game. An entity could represent a character, a weapon, or a wall for example.
An entity is actually a container of components. Each component adds some functionality to an entity. For example, when a PhysicsComponent is added to an entity, the entity has a physical position in the 2D world. If a SpriteComponent is added to the same entity, we now have a visual entity with a position and physical boundaries. We say that an entity is composed of components. These components describe a certain aspect of an entity.
A system is a specialized unit of logic operating on components only. It does not really care about what kind of entity it interacts with only with it's specific subset of components. For example the PhysicsSystem, only operates on entities having a PhysicsComponent, it does not care whether or not the entity has a graphical representation as it does not concern its main task: calculating physics and collisions.
An entity in itself is not very important as a whole. What gives it a meaning is the combination of components it is composed of. Thus an entity could be seen as a simple link between components around a certain concept. For this reason in the goat engine, an entity is simply a unique ID.