|
Acheron
|
Central context for the ECS. More...
#include <world.hpp>
Public Member Functions | |
| World () | |
| Constructs a new World, initializing managers. | |
| Entity | Spawn () |
| Spawns a new entity. | |
| void | AddStageBefore (std::string name, std::string after) |
| Creates a stage before another. | |
| void | AddStageAfter (std::string name, std::string before) |
| Creates a stage before another. | |
| template<typename... Cs, typename... Overrides> | |
| Entity | SpawnWith (Overrides &&... overrides) |
| Spawns an entity with components. | |
| void | Despawn (Entity entity) |
| Despawns(destroys) an entity. | |
| template<typename T> | |
| void | RegisterComponent () |
| Registers a new component type with the ECS. | |
| template<typename T> | |
| bool | HasComponent (Entity entity) |
| Checks if en entity has a component. | |
| template<typename... Components, typename Func> | |
| void | View (Func &&func) |
| template<typename T, typename... Args> | |
| void | AddComponent (Entity entity, Args &&... args) |
| Adds a component to an entity. | |
| template<typename T> | |
| void | RemoveComponent (Entity entity) |
| Removes a component from an entity. | |
| template<typename T> | |
| T & | GetComponent (Entity entity) |
| Retrieves a reference to a component on an entity. | |
| template<typename T> | |
| ComponentID | GetComponentID () |
| Retrieves the unique ID associated with a component type. | |
| template<typename... Components> | |
| Signature | MakeSignature () |
| Creates a signature that includes all specified component types. | |
| template<typename T> | |
| std::shared_ptr< T > | RegisterSystem (Signature signature={}, std::string stage="Update") |
| Registers a system of type T. | |
| template<typename Func> | |
| std::shared_ptr< System > | RegisterSystemExplicit (Func &&func, Signature signature={}, std::string stage="Update") |
| Registers a system explicitly from a function object or lambda. | |
| template<typename... Components, typename Func> | |
| std::shared_ptr< System > | RegisterSystem (Func &&func, std::string stage="Update") |
| Registers a system from a lambda or callable with component type deduction. | |
| template<typename T> | |
| void | SetSystemSignature (Signature signature) |
| Sets the component signature for a system. | |
| template<typename T> | |
| void | SetSingleton (T value) |
| Stores a singleton instance in the world. | |
| template<typename T> | |
| T & | GetSingleton () |
| Retrieves a singleton instance from the world. | |
| template<typename T> | |
| bool | IsSingletonSet () |
| Checks if singleton is set. | |
| template<typename T> | |
| void | Import () |
| Imports a module into the world. | |
| template<typename T> | |
| void | SubscribeEvent (EventManager::Callback< T > cb) |
| Subscribes a callback to an event. | |
| template<typename T> | |
| void | EmitEvent (const T &event) |
| Emit an event to the event queue. | |
| void | DispatchEvents () |
| Dispatch events. | |
| void | Update (double dt=0.0) |
| Runs system updates in the world. | |
Central context for the ECS.
This class manages EVERYTHING to do with the ECS
|
inline |
Adds a component to an entity.
Also updates the entity's signature and notifies systems
| T | Component type |
| entity | The entity receiving the component |
| component | Optional instance of the component (default constructed if omitted) |
| void World::AddStageAfter | ( | std::string | name, |
| std::string | before ) |
Creates a stage before another.
| name | The name of the system to register after |
| after | The system that will be before the registered stage |
| void World::AddStageBefore | ( | std::string | name, |
| std::string | after ) |
Creates a stage before another.
| name | The name of the system to register before |
| after | The system that will be after the registered stage |
| void World::Despawn | ( | Entity | entity | ) |
Despawns(destroys) an entity.
Cleans up all associated components and notifies systems
| entity | The entity to remove |
|
inline |
Emit an event to the event queue.
| T | Event type to emit |
| event | Event and its data |
|
inline |
Retrieves a reference to a component on an entity.
| T | Component type |
| entity | The entity to query |
|
inline |
Retrieves the unique ID associated with a component type.
| T | Component type |
|
inline |
Retrieves a singleton instance from the world.
| T | Singleton type |
| Assert | failure if the singleton has not been set |
|
inline |
Checks if en entity has a component.
| entity | The entity to check |
|
inline |
|
inline |
Checks if singleton is set.
| T | The singleton to check |
|
inline |
Creates a signature that includes all specified component types.
| Components... | Variadic list of component types |
|
inline |
Registers a new component type with the ECS.
| T | The component type to register |
|
inline |
Registers a system from a lambda or callable with component type deduction.
Example:
| Components... | The component types the system operates on |
| Func | Callable type |
| func | The system function/lambda |
| stage | The update stage (default Update) |
|
inline |
|
inline |
Registers a system explicitly from a function object or lambda.
Allows flexible system definition without requiring a class
| Func | Callable type. |
| func | The system function/lambda |
| signature | Component signature this system cares about (default empty) |
| stage | Update stage to run the system in (default Update) |
|
inline |
Removes a component from an entity.
Updates the entity's signature and notifies systems
| T | Component type to remove |
| entity | The entity to modify |
|
inline |
Stores a singleton instance in the world.
| T | Singleton type |
| value | The instance to store |
|
inline |
Sets the component signature for a system.
| T | System type |
| signature | The signature to associate with the system |
| Entity World::Spawn | ( | ) |
Spawns a new entity.
|
inline |
Spawns an entity with components.
Example:
| Cs | Components that are to be added to the entity |
| Overrides | The actual component data passed to the function |
| overrides | Same as the template parameter Overrides |
| Static | Assert Fail if Overrides has a type Cs doesnt contain |
|
inline |
Subscribes a callback to an event.
| T | Event type |
| cb | Callback to subscribe to the event |
| void World::Update | ( | double | dt = 0.0 | ) |
Runs system updates in the world.
Systems are executed in stage order:
| dt | Delta time passed to systems (default 0.0) |