Game

ECS Public API

Using the Entity Component System to build game logic.

Core Concepts

Nevo Engine utilizes a high-performance Entity Component System (ECS) architecture. As a game developer, you interact with the ECS to define game objects (Entities), their data (Components), and their behavior (Systems).

1. Entities

An Entity is a unique ID that represents a game object. You create and destroy entities via the Coordinator.

2. Components

Components are simple structs containing data. They should not contain logic.

struct Transform {
    Public::ECS::Structs::Position position; // x, y, z
    Public::ECS::Structs::Rotation rotation; // x, y, z, w (Quaternion)
    Public::ECS::Structs::Scale scale;       // x, y, z
};

3. Systems

Systems contain the logic. They iterate over entities that match a specific signature (a set of required components).

class MovementSystem : public Public::ECS::System {
public:
    void Update(float dt) {
        for (auto const& entity : mEntities) {
            // ... update logic ...
        }
    }
};

The Coordinator

The Coordinator is your main interface to the ECS. You typically access it via the Engine instance.

Basic Usage

Registering a Component

Before using a component, it must be registered.

// In main.cpp
coordinator.registerComponent<Transform>();

Creating an Entity

EntityID entity = coordinator.createEntity();
coordinator.addComponent(entity, Transform{...});

Registering a System

auto movementSystem = coordinator.registerSystem<MovementSystem>();
// Define requirements
ComponentSignature signature;
signature.set(coordinator.getComponentType<Transform>());
coordinator.setSystemSignature<MovementSystem>(signature);