ECSM v0.2.0
ECSM

Easy to use template based C++ Entity Component System Manager 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
  • Custom event creation support
  • Cache friendly linear pools
  • Acceptable compilation time
  • Fast component iteration
  • Fast entity component access
  • Singleton class pattern

Usage example

using namespace ecsm;
struct RigidBodyComponent final : public Component
{
float size = 0.0f;
};
class PhysicsSystem final : public ComponentSystem<RigidBodyComponent, false>
{
PhysicsSystem()
{
ECSM_SUBSCRIBE_TO_EVENT("Update", PhysicsSystem::update);
}
~PhysicsSystem() final
{
if (Manager::get()->isRunning)
ECSM_UNSUBSCRIBE_FROM_EVENT("Update", PhysicsSystem::update);
}
void copyComponent(View<Component> source, View<Component> destination) final
{
const auto sourceView = View<RigidBodyComponent>(source);
destinationView->size = sourceView->size;
}
void update()
{
// Process components...
}
friend class ecsm::Manager;
};
{
auto manager = new ecsm::Manager();
manager->createSystem<PhysicsSystem>();
manager->createSystem<GraphicsSystem>(false, 123); // System arguments
// ...
manager->initialize();
auto rigidBody = manager->createEntity();
rigidBodyView->size = 1.0f;
manager->start();
delete manager;
}
Base system class with components.
Definition ecsm.hpp:967
Systems and entities coordinator.
Definition ecsm.hpp:201
#define ECSM_UNSUBSCRIBE_FROM_EVENT(name, func)
Unsubscribes System function from the event.
Definition ecsm.hpp:50
#define ECSM_SUBSCRIBE_TO_EVENT(name, func)
Subscribes System function to the event.
Definition ecsm.hpp:45
Base component structure.
Definition ecsm.hpp:73
View of the item in the LinearPool.
Definition linear-pool.hpp:123

Supported operating systems

  • Windows
  • macOS
  • Ubuntu (Linux)

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 https://github.com/cfnptr/ecsm

Building CI

  • Windows: ./scripts/build-release.bat
  • macOS / Ubuntu: ./scripts/build-release.sh