Easy to use template based C++ ECS library.
The ECS pattern, or Entity-Component-System pattern, is a design pattern commonly used in game development and simulation software. It is a way to organize and manage the behavior and data of objects within a system. The ECS pattern is particularly useful for systems with a large number of entities that can have varying and dynamic sets of attributes.
See the documentation
Features
- Straightforward template architecture
- Acceptable compilation time
- Custom event creation support
- Custom system groups creation
- Cache friendly linear pools
- Fast component iteration
- Fast entity component access
- Smart pool item views (zero-cost)
- Deferred components destruction
- Singleton class pattern
- Supports Windows, macOS and Linux
Usage example
using namespace ecsm;
struct RigidBodyComponent final :
public Component
{
float size = 0.0f;
};
class PhysicsSystem final :
public ComponentSystem<RigidBodyComponent, false>
{
PhysicsSystem()
{
}
void update()
{
for (auto& component : components)
{
if (!component.getEntity())
continue;
}
}
friend class ecsm::Manager;
};
void entryPoint()
{
manager->createSystem<PhysicsSystem>();
manager->createSystem<GraphicsSystem>(false, 123);
manager->initialize();
auto rigidBody = manager->createEntity();
auto rigidBodyView = manager->add<RigidBodyComponent>(rigidBody);
rigidBodyView->size = 1.0f;
manager->enterLoop();
manager->terminate();
delete manager;
}
Base system class with components.
Definition ecsm.hpp:1385
Systems and entities coordinator.
Definition ecsm.hpp:308
static Manager * getInstance()
Definition singleton.hpp:106
#define ECSM_SUBSCRIBE_TO_EVENT(name, func)
Subscribes System function to the event.
Definition ecsm.hpp:63
Base component structure.
Definition ecsm.hpp:87
Build requirements
Use building instructions to install all required tools and libraries.
CMake options
| Name | Description | Default value |
| ECSM_BUILD_SHARED | Build ECSM shared library | ON |
| ECSM_BUILD_TESTS | Build ECSM library tests | ON |
CMake targets
| Name | Description | Windows | macOS | Linux |
| ecsm-static | Static ECSM library | .lib | .a | .a |
| ecsm-shared | Dynamic ECSM library | .dll | .dylib | .so |
Cloning
git clone --recursive -j8 https://github.com/cfnptr/ecsm
Building 
- Windows: ./scripts/build-release.bat
- macOS / Linux: ./scripts/build-release.sh
Third-party
Special thanks to Sahak Grigoryan.