Class to represent an entity in an ECS Context.
More...
#include <Entity.h>
|
using | ComponentMap = std::unordered_map<TypeIndex, std::unique_ptr<Internal::ComponentContainerBase>> |
| Maps component type indices to unique pointers to component containers.
|
|
|
| Entity (Context *context, U64 id) |
| Constructs a new entity in the given ECS Context with the given id.
|
|
| ~Entity () |
| Destroys the entity and all its components.
|
|
Context * | GetContext () const noexcept |
| Gets the ECS context associated with the entity.
|
|
U64 | GetId () const noexcept |
| Gets the ID of the entity.
|
|
bool | IsPendingDestroy () const noexcept |
| Whether the entity has pending destruction.
|
|
template<typename T > |
bool | Has () const |
| Whether the entity has a component of the given type.
|
|
template<typename T , typename U , typename... Types> |
bool | Has () const |
| Whether the entity has components of the given types.
|
|
template<typename T , typename... Args> |
ComponentHandle< T > | Add (Args &&... args) |
| Adds a component to the entity.
|
|
template<typename T > |
ComponentHandle< T > | Get () |
| Gets a component from the entity.
|
|
template<typename T > |
bool | Remove () |
| Gets a component from the entity.
|
|
void | RemoveAll () |
| Removes all components from the entity.
|
|
template<typename... Types> |
bool | With (typename std::common_type< std::function< void(ComponentHandle< Types >...)> >::type func) |
| Executes a function on a set of component handles if the entity has components of the specified types.
|
|
|
static constexpr U64 | InvalidId = 0 |
| Invalid entity ID.
|
|
Class to represent an entity in an ECS Context.
◆ Entity()
Nui::ECS::Entity::Entity |
( |
Context * | context, |
|
|
U64 | id ) |
|
inline |
Constructs a new entity in the given ECS Context with the given id.
- Parameters
-
context | Pointer to the ECS Context |
id | ID of the entity |
◆ Add()
template<typename T , typename ... Args>
Adds a component to the entity.
- Template Parameters
-
T | Type of the component |
...Args | Arguments to pass to the constructor |
- Parameters
-
...args | Arguments to pass to the constructor |
- Returns
- Handle to the added (or updated) component
◆ Get()
Gets a component from the entity.
- Template Parameters
-
- Returns
- Handle to the component
◆ GetContext()
Context * Nui::ECS::Entity::GetContext |
( |
| ) |
const |
|
inlinenoexcept |
Gets the ECS context associated with the entity.
- Returns
- Pointer to the ECS context
◆ GetId()
U64 Nui::ECS::Entity::GetId |
( |
| ) |
const |
|
inlinenoexcept |
Gets the ID of the entity.
- Returns
- ID of the entity
◆ Has() [1/2]
template<typename T >
bool Nui::ECS::Entity::Has |
( |
| ) |
const |
|
inline |
Whether the entity has a component of the given type.
- Template Parameters
-
- Returns
- True if the entity has the component
◆ Has() [2/2]
template<typename T , typename U , typename... Types>
bool Nui::ECS::Entity::Has |
( |
| ) |
const |
|
inline |
Whether the entity has components of the given types.
- Template Parameters
-
T | First Component |
V | Second Component |
...Types | Remaining Components |
- Returns
- True if the entity has all the specified components
◆ IsPendingDestroy()
bool Nui::ECS::Entity::IsPendingDestroy |
( |
| ) |
const |
|
inlinenoexcept |
Whether the entity has pending destruction.
- Returns
- True if the entity has pending destruction
◆ Remove()
template<typename T >
bool Nui::ECS::Entity::Remove |
( |
| ) |
|
|
inline |
Gets a component from the entity.
- Template Parameters
-
- Returns
- Handle to the component
◆ With()
template<typename... Types>
bool Nui::ECS::Entity::With |
( |
typename std::common_type< std::function< void(ComponentHandle< Types >...)> | , |
|
|
::type | func ) |
|
inline |
Executes a function on a set of component handles if the entity has components of the specified types.
- Template Parameters
-
...Types | Types of components |
- Parameters
-
- Returns
- True if the entity has all the specified components
The documentation for this class was generated from the following files:
- Engine/Core/Engine/ECS/Entity.h
- Engine/Core/Engine/ECS/ECS.h
- Engine/Core/Engine/ECS/Entity.cpp