Book Image

SFML Blueprints

Book Image

SFML Blueprints

Overview of this book

Table of Contents (15 chapters)
SFML Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Building an entity system


First of all, what is an entity system?

An entity system is a design pattern that focuses on data. Instead of creating a complex hierarchical tree of all possible entities, the idea is to build a system that allows us to add components to an entity at runtime. These components could be anything such as health points, artificial intelligence, skin, weapon, and everything but data.

However, if none of the entities and components hold functionalities, where are they stored? The answer is in the systems. Each system manages at least one component, and all the logic is inside these systems. Moreover, it is not possible to build an entity directly. You have to create or update it using an entity manager. It will be in charge of a set of entities, managing their components, creation, and destruction.

The structure is represented by the following chart:

There are many ways to implement such a structure. My choice was to use template and polymorphism.

Use of the entity system...