|
R-Type
Distributed multiplayer game engine in C++
|
High-level ECS manager providing clean server-side API. More...
#include <ECSWorld.hpp>

Public Member Functions | |
| ECSWorld () | |
| Construct a new ECSWorld. | |
| ~ECSWorld () | |
| Destroy the ECSWorld and cleanup resources. | |
| Entity | createEntity () |
| Create a new entity. | |
| std::vector< Entity > | createEntities (size_t count) |
| Create multiple entities at once. | |
| Entity | getEntity (Address address) |
| Get an entity wrapper from an address. | |
| void | destroyEntity (const Entity &entity) |
| Destroy an entity and remove it from the world. | |
| void | destroyEntity (Address address) |
| Destroy an entity by its address. | |
| template<typename... Components> | |
| std::vector< Entity > | query () |
| Get all entities with specific components. | |
| template<typename... Components> | |
| void | forEach (std::function< void(Entity, Components &...)> callback) |
| Iterate over entities with specific components. | |
| template<typename T > | |
| void | registerSystem (const std::string &name, std::unique_ptr< T > system) |
| Register a system with the world. | |
| template<typename T , typename... Args> | |
| void | createSystem (const std::string &name, Args &&...args) |
| Create and register a system. | |
| template<typename T , typename... Args> | |
| void | createSystem (SystemId id, Args &&...args) |
| Create and register a system using an enum identifier. | |
| template<typename T > | |
| T * | getSystem (const std::string &name) |
| Get a registered system by name. | |
| template<typename T > | |
| T * | getSystem (SystemId id) |
| Get a registered system by enum identifier. | |
| void | removeSystem (const std::string &name) |
| Remove a system from the world. | |
| void | removeSystem (SystemId id) |
| Remove a system using its enum identifier. | |
| void | update (float deltaTime) |
| Update all registered systems. | |
| bool | updateSystem (const std::string &name, float deltaTime) |
| Update a specific system by name. | |
| bool | updateSystem (SystemId id, float deltaTime) |
| Update a specific system by enum identifier. | |
| Registry & | getRegistry () |
| Get direct access to the underlying registry. | |
| const Registry & | getRegistry () const |
| Get const access to the underlying registry. | |
| void | clear () |
| Clear all entities from the world. | |
| size_t | getSystemCount () const |
| Get the number of systems registered. | |
Public Attributes | |
| bool | startingEvent = false |
| World state (for accessing from Lua scripts)d 0 = not running, 1 = starting event, 2 = running. | |
Private Attributes | |
| std::unique_ptr< Registry > | _registry |
| std::unordered_map< std::string, std::unique_ptr< ISystem > > | _systems |
| std::vector< std::string > | _systemsOrder |
High-level ECS manager providing clean server-side API.
Manages the ECS registry, entities, and systems with a clean interface. Designed for server-side game logic with emphasis on code clarity.
Definition at line 122 of file ECSWorld.hpp.
| ecs::wrapper::ECSWorld::ECSWorld | ( | ) |
Construct a new ECSWorld.
Definition at line 63 of file ECSWorld.cpp.
|
default |
Destroy the ECSWorld and cleanup resources.
| void ecs::wrapper::ECSWorld::clear | ( | ) |
Clear all entities from the world.
Systems are preserved.
Definition at line 154 of file ECSWorld.cpp.
References _registry, and ecs::Registry::view().

| std::vector< Entity > ecs::wrapper::ECSWorld::createEntities | ( | size_t | count | ) |
Create multiple entities at once.
| count | Number of entities to create |
Definition at line 72 of file ECSWorld.cpp.
References createEntity().

| Entity ecs::wrapper::ECSWorld::createEntity | ( | ) |
Create a new entity.
Definition at line 67 of file ECSWorld.cpp.
References _registry.
Referenced by scripting::bindings::bindServerGame(), scripting::bindings::bindWorld(), and createEntities().
| void ecs::wrapper::ECSWorld::createSystem | ( | const std::string & | name, |
| Args &&... | args | ||
| ) |
Create and register a system.
| T | System type (must inherit from ISystem) |
| Args | Constructor argument types |
| name | Unique name for the system |
| args | Constructor arguments |
| void ecs::wrapper::ECSWorld::createSystem | ( | SystemId | id, |
| Args &&... | args | ||
| ) |
Create and register a system using an enum identifier.
| T | System type (must inherit from ISystem) |
| Args | Constructor argument types |
| id | Enum identifier for the system |
| args | Constructor arguments |
| void ecs::wrapper::ECSWorld::destroyEntity | ( | Address | address | ) |
Destroy an entity by its address.
| address | The entity's address |
Definition at line 93 of file ECSWorld.cpp.
References _registry.
| void ecs::wrapper::ECSWorld::destroyEntity | ( | const Entity & | entity | ) |
Destroy an entity and remove it from the world.
| entity | The entity to destroy |
Definition at line 87 of file ECSWorld.cpp.
References _registry, ecs::wrapper::Entity::getAddress(), and ecs::wrapper::Entity::isValid().
Referenced by scripting::bindings::bindEntity(), and scripting::bindings::bindWorld().

| void ecs::wrapper::ECSWorld::forEach | ( | std::function< void(Entity, Components &...)> | callback | ) |
Iterate over entities with specific components.
| Components | Component types required |
| callback | Function to call for each matching entity |
Get an entity wrapper from an address.
| address | The entity's address |
Definition at line 83 of file ECSWorld.cpp.
References _registry.
Referenced by scripting::bindings::bindWorld(), server::GameStateSerializer::serializeEntity(), and scripting::LuaSystemAdapter::update().
| Registry & ecs::wrapper::ECSWorld::getRegistry | ( | ) |
Get direct access to the underlying registry.
Definition at line 146 of file ECSWorld.cpp.
References _registry.
| const Registry & ecs::wrapper::ECSWorld::getRegistry | ( | ) | const |
Get const access to the underlying registry.
Definition at line 150 of file ECSWorld.cpp.
References _registry.
| T * ecs::wrapper::ECSWorld::getSystem | ( | const std::string & | name | ) |
Get a registered system by name.
| T | System type |
| name | The system's name |
| T * ecs::wrapper::ECSWorld::getSystem | ( | SystemId | id | ) |
Get a registered system by enum identifier.
| T | System type |
| id | Enum identifier for the system |
| size_t ecs::wrapper::ECSWorld::getSystemCount | ( | ) | const |
Get the number of systems registered.
Definition at line 162 of file ECSWorld.cpp.
References _systems.
| std::vector< Entity > ecs::wrapper::ECSWorld::query | ( | ) |
Get all entities with specific components.
| Components | Component types to query |
Referenced by server::GameStateSerializer::createFullSnapshot().
| void ecs::wrapper::ECSWorld::registerSystem | ( | const std::string & | name, |
| std::unique_ptr< T > | system | ||
| ) |
Register a system with the world.
| T | System type (must inherit from ISystem) |
| name | Unique name for the system |
| system | Unique pointer to the system |
| void ecs::wrapper::ECSWorld::removeSystem | ( | const std::string & | name | ) |
Remove a system from the world.
| name | The system's name |
Definition at line 97 of file ECSWorld.cpp.
References _systems, and _systemsOrder.
Referenced by removeSystem().
| void ecs::wrapper::ECSWorld::removeSystem | ( | SystemId | id | ) |
Remove a system using its enum identifier.
| id | Enum identifier for the system |
Definition at line 110 of file ECSWorld.cpp.
References removeSystem(), and ecs::wrapper::systemIdToName().

| void ecs::wrapper::ECSWorld::update | ( | float | deltaTime | ) |
Update all registered systems.
Systems are updated in registration order.
| deltaTime | Time elapsed since last update (in seconds) |
Definition at line 114 of file ECSWorld.cpp.
References _registry, _systems, _systemsOrder, and LOG_ERROR.
| bool ecs::wrapper::ECSWorld::updateSystem | ( | const std::string & | name, |
| float | deltaTime | ||
| ) |
Update a specific system by name.
| name | The system's name |
| deltaTime | Time elapsed since last update (in seconds) |
Definition at line 127 of file ECSWorld.cpp.
References _registry, _systems, and LOG_ERROR.
Referenced by ecs::wrapper::SystemScheduler::update(), and updateSystem().
| bool ecs::wrapper::ECSWorld::updateSystem | ( | SystemId | id, |
| float | deltaTime | ||
| ) |
Update a specific system by enum identifier.
| id | Enum identifier for the system |
| deltaTime | Time elapsed since last update (in seconds) |
Definition at line 142 of file ECSWorld.cpp.
References ecs::wrapper::systemIdToName(), and updateSystem().

|
private |
Definition at line 124 of file ECSWorld.hpp.
Referenced by clear(), createEntity(), destroyEntity(), destroyEntity(), getEntity(), getRegistry(), getRegistry(), update(), and updateSystem().
|
private |
Definition at line 125 of file ECSWorld.hpp.
Referenced by getSystemCount(), removeSystem(), update(), and updateSystem().
|
private |
Definition at line 126 of file ECSWorld.hpp.
Referenced by removeSystem(), and update().
| bool ecs::wrapper::ECSWorld::startingEvent = false |
World state (for accessing from Lua scripts)d 0 = not running, 1 = starting event, 2 = running.
Definition at line 320 of file ECSWorld.hpp.