Api

ECS API

Coordinator, System, signatures, component storage, and entity lifetime.

Public Types

#include <ECS/ECSCommon.hpp>
#include <ECS/Coordinator.hpp>
#include <ECS/SystemManager.hpp>
TypeDefinition
EntityIDuint32_t
INVALID_ENTITYstatic_cast<EntityID>(-1)
MAX_ENTITIES5000000
MAX_COMPONENTS32
ComponentSignaturestd::bitset<MAX_COMPONENTS>
COMPONENTPublic export macro for component structs.

Coordinator

The coordinator owns entity, component, and system managers:

auto& coord = Public::Engine::getInstance().GetCoordinator();

Entity API

APINotes
createEntity()Allocates an entity ID.
createEntity(EntityID)Used by scene loading to preserve scene IDs.
destroyEntity(EntityID)Removes components and system membership.
clearAllEntities()Destroys every active entity and clears manager state.
getEntityCount()Active entity count.

Component API

APINotes
registerComponent<T>()Creates storage and assigns a component type index.
addComponent<T>(entity, component)Adds component data and updates system membership.
removeComponent<T>(entity)Removes component data and updates system membership.
getComponent<T>(entity)Returns std::optional<std::reference_wrapper<T>>.
hasComponent<T>(entity)Returns bool.
getComponentType<T>()Returns the bit index for signatures.
getEntitiesWithComponent<T>()Returns a vector of entity IDs.
getEntitiesWithComponentView<T>()Returns a read-only span of entity IDs.
getComponentView<T>()Returns a dense span of components.
getComponentCount<T>()Returns number of components of type T.

System API

APINotes
registerSystem<T>()Creates and returns std::shared_ptr<T>.
setSystemSignature<T>(signature)Defines required component bits.
getSystem<T>()Returns registered system.
tryGetSystem<T>()Returns nullptr if absent.
update(dt)Runs systems in registration order.

System Base Class

class MySystem : public Public::ECS::System {
public:
    void update(float dt) override;
    void entityAdded(Public::ECS::EntityID entity) override;
    void entityRemoved(Public::ECS::EntityID entity) override;
};

The base class exposes:

MemberUse
entitiesstd::unordered_set<EntityID> of matching entities.
entityList()Vector-style list maintained alongside the set.

Prefer entityList() for iteration.

Signature Example

using namespace Public::ECS;
using namespace Public::ECS::Components;

coord.registerComponent<PlayerController>();
auto controller = coord.registerSystem<PlayerControllerSystem>();

ComponentSignature signature;
signature.set(coord.getComponentType<Transform>());
signature.set(coord.getComponentType<Rigidbody>());
signature.set(coord.getComponentType<PlayerController>());
coord.setSystemSignature<PlayerControllerSystem>(signature);

An entity joins the system only when it has all three components.

Component Mutation

auto transformOpt = coord.getComponent<Transform>(entity);
if (!transformOpt) {
    return;
}

auto& transform = transformOpt->get();
transform.position.y += 1.0f;

getComponent<T> intentionally returns a reference wrapper so systems can edit component data in place.

Built-In System Timing

The engine registers built-in render, lighting, shadow, camera, animation, post-processing settings, and physics systems during initialization. Custom gameplay systems are registered by the game and run in the order they are registered with the coordinator.

If your system needs physics results, register it with update order in mind and prefer public PhysicsSystem APIs for forces, impulses, raycasts, and velocity changes.