![]() |
Entity Generator 4.2.3
Composable, deterministic entity generation for C++23
|
Adapter that bridges entity-generator with EnTT. More...
#include <entt_adapter.hpp>
Public Member Functions | |
| entt_adapter (entt::registry ®istry) | |
| Construct an adapter bound to an EnTT registry. | |
| template<typename Component > | |
| entt_adapter & | map (const std::wstring &key, std::function< Component(const entity &)> mapper) |
| Register a transform mapping from a generator key to an EnTT component. | |
| template<typename Component > | |
| entt_adapter & | map (const std::wstring &key) |
| Register a direct mapping (value type matches EnTT component type). | |
| entt::entity | spawn (const entity &src) |
| Create an EnTT entity from a generated entity. | |
| void | spawn_into (entt::entity target, const entity &src) |
| Emplace mapped components onto an existing EnTT entity. | |
| std::vector< entt::entity > | spawn_batch (const std::vector< entity > &sources) |
| Create EnTT entities for a batch of generated entities. | |
| entt_adapter & | clear_mappings () |
| Remove all registered mappings. | |
Adapter that bridges entity-generator with EnTT.
Users register mappings from generator component keys to EnTT component types, then spawn() converts generated entities into EnTT entities with typed components.
Definition at line 35 of file entt_adapter.hpp.
|
inlineexplicit |
Construct an adapter bound to an EnTT registry.
| registry | The EnTT registry to create entities in. |
Definition at line 40 of file entt_adapter.hpp.
|
inline |
Remove all registered mappings.
*this for chaining. Definition at line 131 of file entt_adapter.hpp.
|
inline |
Register a direct mapping (value type matches EnTT component type).
| Component | The EnTT component type. |
| key | Generator component key whose value type is Component. |
*this for chaining. Definition at line 70 of file entt_adapter.hpp.
|
inline |
Register a transform mapping from a generator key to an EnTT component.
The mapper receives the full generated entity so it can read any combination of keys. The component is only emplaced when the specified key is present in the generated entity.
| Component | The EnTT component type to emplace. |
| key | Generator component key to watch for. |
| mapper | Transform function producing the EnTT component. |
*this for chaining. Definition at line 53 of file entt_adapter.hpp.
|
inline |
Create an EnTT entity from a generated entity.
Emplaces 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 destroyed and the exception propagates, so the registry holds no half-built entity.
| src | The generated entity. |
Definition at line 89 of file entt_adapter.hpp.
|
inline |
Create EnTT entities for a batch of generated entities.
If a spawn throws, the entities spawned before it stay in the registry.
| sources | A vector of generated entities. |
Definition at line 117 of file entt_adapter.hpp.
|
inline |
Emplace mapped components onto an existing EnTT entity.
| target | The pre-existing EnTT entity. |
| src | The generated entity. |
Definition at line 107 of file entt_adapter.hpp.