![]() |
Entity Generator 4.2.3
Composable, deterministic entity generation for C++23
|
Adapter that bridges entity-generator with Flecs. More...
#include <flecs_adapter.hpp>
Public Member Functions | |
| flecs_adapter (flecs::world &world) | |
| Construct an adapter bound to a Flecs world. | |
| template<typename Component > | |
| flecs_adapter & | map (const std::wstring &key, std::function< Component(const entity &)> mapper) |
| Register a transform mapping from a generator key to a Flecs component. | |
| template<typename Component > | |
| flecs_adapter & | map (const std::wstring &key) |
| Register a direct mapping (value type matches Flecs component type). | |
| flecs::entity | spawn (const entity &src) |
| Create a Flecs entity from a generated entity. | |
| void | spawn_into (flecs::entity target, const entity &src) |
| Set mapped components onto an existing Flecs entity. | |
| std::vector< flecs::entity > | spawn_batch (const std::vector< entity > &sources) |
| Create Flecs entities for a batch of generated entities. | |
| flecs_adapter & | clear_mappings () |
| Remove all registered mappings. | |
Adapter that bridges entity-generator with Flecs.
Users register mappings from generator component keys to Flecs component types, then spawn() converts generated entities into Flecs entities with typed components.
Definition at line 35 of file flecs_adapter.hpp.
|
inlineexplicit |
Construct an adapter bound to a Flecs world.
| world | The Flecs world to create entities in. |
Definition at line 40 of file flecs_adapter.hpp.
|
inline |
Remove all registered mappings.
*this for chaining. Definition at line 128 of file flecs_adapter.hpp.
|
inline |
Register a direct mapping (value type matches Flecs component type).
| Component | The Flecs component type. |
| key | Generator component key whose value type is Component. |
*this for chaining. Definition at line 69 of file flecs_adapter.hpp.
|
inline |
Register a transform mapping from a generator key to a Flecs component.
The mapper receives the full generated entity so it can read any combination of keys. The component is only set when the specified key is present in the generated entity.
| Component | The Flecs component type. |
| key | Generator component key to watch for. |
| mapper | Transform function producing the Flecs component. |
*this for chaining. Definition at line 53 of file flecs_adapter.hpp.
|
inline |
Create a Flecs entity from a generated entity.
Sets all mapped components whose keys are present. If a mapping throws (a direct map of the wrong type, a mapper reading a missing key), the new entity is destructed and the exception propagates, so the world holds no half-built entity.
| src | The generated entity. |
Definition at line 86 of file flecs_adapter.hpp.
|
inline |
Create Flecs entities for a batch of generated entities.
If a spawn throws, the entities spawned before it stay in the world.
| sources | A vector of generated entities. |
Definition at line 114 of file flecs_adapter.hpp.
|
inline |
Set mapped components onto an existing Flecs entity.
| target | The pre-existing Flecs entity. |
| src | The generated entity. |
Definition at line 104 of file flecs_adapter.hpp.