Adapter that bridges entity-generator with EnTT.
More...
#include <entt_adapter.hpp>
|
| | 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.
- Example
entt::registry registry;
return Position{ e.get<float>(L"x"), e.get<float>(L"y") };
});
auto entt_entity = adapter.spawn(gen.generate());
A generated entity holding component values in registration order.
Adapter that bridges entity-generator with EnTT.
- See also
- flecs_adapter
Definition at line 32 of file entt_adapter.hpp.
◆ entt_adapter()
| dasmig::ext::entt_adapter::entt_adapter |
( |
entt::registry & |
registry | ) |
|
|
inlineexplicit |
Construct an adapter bound to an EnTT registry.
- Parameters
-
| registry | The EnTT registry to create entities in. |
Definition at line 37 of file entt_adapter.hpp.
◆ clear_mappings()
| entt_adapter & dasmig::ext::entt_adapter::clear_mappings |
( |
| ) |
|
|
inline |
Remove all registered mappings.
- Returns
*this for chaining.
Definition at line 115 of file entt_adapter.hpp.
◆ map() [1/2]
template<typename Component >
| entt_adapter & dasmig::ext::entt_adapter::map |
( |
const std::wstring & |
key | ) |
|
|
inline |
Register a direct mapping (value type matches EnTT component type).
- Template Parameters
-
| Component | The EnTT component type. |
- Parameters
-
| key | Generator component key whose value type is Component. |
- Returns
*this for chaining.
Definition at line 67 of file entt_adapter.hpp.
◆ map() [2/2]
template<typename Component >
| entt_adapter & dasmig::ext::entt_adapter::map |
( |
const std::wstring & |
key, |
|
|
std::function< Component(const entity &)> |
mapper |
|
) |
| |
|
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.
- Template Parameters
-
| Component | The EnTT component type to emplace. |
- Parameters
-
| key | Generator component key to watch for. |
| mapper | Transform function producing the EnTT component. |
- Returns
*this for chaining.
Definition at line 50 of file entt_adapter.hpp.
◆ spawn()
| entt::entity dasmig::ext::entt_adapter::spawn |
( |
const entity & |
src | ) |
|
|
inline |
Create an EnTT entity from a generated entity.
Emplaces all mapped components whose keys are present.
- Parameters
-
- Returns
- The new EnTT entity.
Definition at line 83 of file entt_adapter.hpp.
◆ spawn_batch()
| std::vector< entt::entity > dasmig::ext::entt_adapter::spawn_batch |
( |
const std::vector< entity > & |
sources | ) |
|
|
inline |
Create EnTT entities for a batch of generated entities.
- Parameters
-
| sources | A vector of generated entities. |
- Returns
- A vector of new EnTT entities.
Definition at line 101 of file entt_adapter.hpp.
◆ spawn_into()
| void dasmig::ext::entt_adapter::spawn_into |
( |
entt::entity |
target, |
|
|
const entity & |
src |
|
) |
| |
|
inline |
Emplace mapped components onto an existing EnTT entity.
- Parameters
-
| target | The pre-existing EnTT entity. |
| src | The generated entity. |
Definition at line 93 of file entt_adapter.hpp.
The documentation for this class was generated from the following file: