14#include <unordered_map>
17#include "../ECS/Registry.hpp"
18#include "../ECS/Systems/ISystem.hpp"
125 std::unordered_map<std::string, std::unique_ptr<ISystem>>
_systems;
186 template <
typename... Components>
201 template <
typename... Components>
213 template <
typename T>
224 template <
typename T,
typename... Args>
235 template <
typename T,
typename... Args>
245 template <
typename T>
255 template <
typename T>
279 void update(
float deltaTime);
288 bool updateSystem(
const std::string &name,
float deltaTime);
339#include "ECSWorld.tpp"
Manages entities, their signatures and component type registrations.
Component for entities capable of shooting projectiles.
High-level ECS manager providing clean server-side API.
void createSystem(const std::string &name, Args &&...args)
Create and register a system.
std::vector< Entity > query()
Get all entities with specific components.
Entity createEntity()
Create a new entity.
void createSystem(SystemId id, Args &&...args)
Create and register a system using an enum identifier.
std::unordered_map< std::string, std::unique_ptr< ISystem > > _systems
Entity getEntity(Address address)
Get an entity wrapper from an address.
void update(float deltaTime)
Update all registered systems.
~ECSWorld()
Destroy the ECSWorld and cleanup resources.
std::unique_ptr< Registry > _registry
T * getSystem(SystemId id)
Get a registered system by enum identifier.
bool startingEvent
World state (for accessing from Lua scripts)d 0 = not running, 1 = starting event,...
std::vector< Entity > createEntities(size_t count)
Create multiple entities at once.
Registry & getRegistry()
Get direct access to the underlying registry.
void destroyEntity(const Entity &entity)
Destroy an entity and remove it from the world.
void clear()
Clear all entities from the world.
ECSWorld()
Construct a new ECSWorld.
std::vector< std::string > _systemsOrder
void registerSystem(const std::string &name, std::unique_ptr< T > system)
Register a system with the world.
bool updateSystem(const std::string &name, float deltaTime)
Update a specific system by name.
void removeSystem(const std::string &name)
Remove a system from the world.
T * getSystem(const std::string &name)
Get a registered system by name.
size_t getSystemCount() const
Get the number of systems registered.
void forEach(std::function< void(Entity, Components &...)> callback)
Iterate over entities with specific components.
High-level entity wrapper providing fluent interface.
Entity & with(const T &component)
Add/set a component to this entity.
bool has() const
Check if this entity has a specific component.
Entity & remove()
Remove a component from this entity.
const T & get() const
Get a component from this entity (const version).
T & get()
Get a component from this entity.
Address getAddress() const
Get the entity's address.
bool isValid() const
Check if this entity is valid.
std::string_view systemIdToName(SystemId id)
std::uint32_t Address
Type used to represent an entity address/ID.