|
Engine²
Open-source game engine written in C++.
|
Represents a unique identifier for an entity in the Engine's entity-component system. An EntityId is just Id with utility methods to manage components associated with the entity but not the core. More...
#include <EntityId.hpp>
Public Types | |
| using | ValueType = Id::ValueType |
| The underlying value type of the EntityId, which is the same as Engine::Id::ValueType. | |
| Public Types inherited from Engine::Id | |
| using | ValueType = entt::id_type |
Public Member Functions | |
| constexpr | EntityId (ValueType v=NullValue()) |
| Constructs an EntityId with the given value. By default, it constructs a null EntityId. | |
| constexpr | EntityId (Id id) |
| Constructs an EntityId from an Engine::Id. This allows for implicit conversion from Engine::Id to EntityId. | |
| constexpr | operator ValueType () const |
| Implicit conversion operator to the underlying ValueType. This allows for seamless use of EntityId where a ValueType is expected. | |
| bool | IsValid (const Engine::Core &core) const |
| Checks if the EntityId is valid. An EntityId is considered valid if it corresponds to an existing entity in the Core's registry. | |
| template<typename TComponent> | |
| decltype(auto) | AddComponent (Engine::Core &core, TComponent &&component) |
| Add a component to an entity. | |
| template<typename TComponent, typename... TArgs> | |
| decltype(auto) | AddComponent (Engine::Core &core, TArgs &&...args) |
| Add a component to an entity. | |
| template<typename TComponent, typename... TArgs> | |
| decltype(auto) | AddComponentIfNotExists (Engine::Core &core, TArgs &&...args) |
| Add a component to an entity if it does not already exist. | |
| template<typename... TComponent> | |
| bool | HasComponents (const Engine::Core &core) const |
| Check if entity have one or multiple component's type. | |
| template<typename TTempComponent, typename... TArgs> | |
| decltype(auto) | AddTemporaryComponent (Engine::Core &core, TArgs &&...args) |
| Add a temporary component to an entity. Temporary component are removed when calling RemoveTemporaryComponents system. | |
| template<typename... TComponent> | |
| decltype(auto) | GetComponents (Engine::Core &core) |
| Get components of type TComponent from an entity. | |
| template<typename... TComponent> | |
| decltype(auto) | GetComponents (Engine::Core &core) const |
| Get components of type TComponent from the entity. | |
| template<typename TComponent> | |
| decltype(auto) | TryGetComponent (Engine::Core &core) |
| Try to get a component of type TComponent from the entity. It returns a pointer to the component if it exists, or nullptr if it does not exist. | |
| template<typename TComponent> | |
| void | RemoveComponent (Engine::Core &core) |
| Remove a component from an entity. | |
| Public Member Functions inherited from Engine::Id | |
| constexpr | Id (ValueType v=NullValue()) |
| Constructor for Id. | |
| constexpr | operator ValueType () const |
| Implicit conversion operator to the underlying entt::id_type, allowing seamless use of Id instances where entt::id_type is expected. | |
Static Public Member Functions | |
| static constexpr EntityId | Null () |
| Returns a null EntityId. A null EntityId is an EntityId that does not correspond to any valid entity in the registry. | |
| static void | RemoveTemporaryComponents (Core &core) |
| Remove all temporary components from the registry. This system should be called at the end of each loop to ensure that temporary components are removed after they have been used. | |
| Static Public Member Functions inherited from Engine::Id | |
| static constexpr ValueType | NullValue () |
| Get the null value for this ID type. This returns the null value defined by EnTT's id_type, which is typically. | |
| static constexpr Id | Null () |
| Get a null instance of Id, which has its value set to the null value defined by NullValue(). | |
Static Private Attributes | |
| static std::unordered_map< std::type_index, std::function< void(Core &)> > | temporaryComponent = {} |
Additional Inherited Members | |
| Public Attributes inherited from Engine::BasicId< Id, entt::id_type > | |
| entt::id_type | value |
| The underlying value of the ID. | |
Represents a unique identifier for an entity in the Engine's entity-component system. An EntityId is just Id with utility methods to manage components associated with the entity but not the core.
The underlying value type of the EntityId, which is the same as Engine::Id::ValueType.
Constructs an EntityId with the given value. By default, it constructs a null EntityId.
| v | The value to initialize the EntityId with. If not provided, it defaults to the null value defined by Engine::Id. |
rename v to value
put the implementation in the cpp file
|
inlineconstexpr |
Constructs an EntityId from an Engine::Id. This allows for implicit conversion from Engine::Id to EntityId.
| id | The Engine::Id to convert. |
|
inline |
Add a component to an entity.
| TComponent | The type of the component to add to the registry. |
| TArgs | The types of the arguments to construct the component in-place in the registry. |
| core | The Core instance whose registry is used to store the component. |
| args | The arguments to construct the component in-place in the registry. |
|
inline |
Add a component to an entity.
| TComponent | The type of the component to add to the registry. |
| core | The Core instance whose registry is used to store the component. |
| component | The rvalue of the component to add to the registry. |
|
inline |
Add a component to an entity if it does not already exist.
| TComponent | type to add to registry. |
| TArgs | type used to create the component. |
| core | registry used to store the component. |
| args | parameters used to instanciate component directly in registry memory. |
|
inline |
Add a temporary component to an entity. Temporary component are removed when calling RemoveTemporaryComponents system.
| TTempComponent | type to add to registry |
| TArgs | type used to create the component |
| core | registry used to store the component |
| args | parameters used to instanciate component directly in registry memory |
|
inline |
Get components of type TComponent from an entity.
| TComponent | The type of the component to get from the registry. |
| core | The Core instance whose registry is used to store the component. |
|
inline |
Get components of type TComponent from the entity.
| TComponent | The type of the component to get from the registry. |
| core | The Core instance whose registry is used to store the component. |
|
inline |
Check if entity have one or multiple component's type.
| TComponent | components to check. |
| core | context used to check if the entity have the component in the core's registry. |
|
inline |
Checks if the EntityId is valid. An EntityId is considered valid if it corresponds to an existing entity in the Core's registry.
| core | The Core instance to check the validity against. |
|
inlinestaticconstexpr |
|
inlineconstexpr |
|
inline |
|
inlinestatic |
Remove all temporary components from the registry. This system should be called at the end of each loop to ensure that temporary components are removed after they have been used.
| core | The Core instance whose registry is used to store the components. |
|
inline |
Try to get a component of type TComponent from the entity. It returns a pointer to the component if it exists, or nullptr if it does not exist.
| TComponent | The type of the component to get from the registry. |
| core | The Core instance whose registry is used to store the component. |
|
inlinestaticprivate |