Commission: Mad Scientist by Culpeo-Fox on DeviantArt
In this article I will roughly describe the ECS pattern and my implementation in the Flame Steel Engine Game Toolkit. The Entity Component System pattern is used in games, including the Unity engine. Each object in the game is an Entity, which is filled with Components. Why is this necessary if there is OOP?
Then to change the properties, behavior, display of objects directly during the game execution. Such things are not found in real-world applications, the dynamics of changing parameters, properties of objects, display, sound, are more inherent in games than in accounting software.
We didn’t go through bananas
Let’s say we have a banana class in our game. And the game designer wanted bananas to be used as weapons. Let’s say in the current architecture bananas are not related to weapons. Make a banana a weapon? Make all objects weapons?
ECS offers a solution to this pressing problem – all objects in the game must consist of components. Previously, a banana was a Banana class, now we will make it, and all other objects, an Entity class, and add components to them. Let’s say a banana now consists of components:
- Position component (coordinates in the game world – x, y, z)
- Rotation component (x, y, z coordinates)
- The calorie content of a banana (the main character can’t get too fat)
- Banana picture component
We are now adding a new component to all bananas, which is a flag that it can be used as a weapon – Weapon Component. Now when the game system sees that a player has approached a banana, it checks whether the banana has a weapon component, and if it does, it arms the player with a banana.
In my game Flame Steel Call Of The Death Mask, the ECS pattern is used everywhere. Objects consist of components, components themselves can contain components. In general, the separation of object < – > component is absent in my implementation, but this is even a plus.

The shotgun in this screenshot is a player component, while the second shotgun is just hanging on the game map like a normal object.
In this screenshot, there are two Systems running – the scene renderer and the interface renderer. The scene renderer is working with the shotgun image component on the map, the interface renderer is working with the shotgun image component in the player’s hands.
Related links:
https://habrahabr.ru/post/197920/
https://www.youtube.com/watch?v=NTWSeQtHZ9M