|
CoriEngine
|
Entities are the essential part of WorldSystem. More...
#include <Entity.hpp>
Public Member Functions | |
| Entity ()=default | |
| Entity (entt::handle handle) | |
| template<typename T, typename... Args> | |
| T & | AddComponent (Args &&... args) |
| Adds a component to the entity. | |
| template<typename T, typename... Args> | |
| T & | ReplaceComponent (Args &&... args) |
| Replaces the component with a newly created one. | |
| template<typename T, typename... Args> | |
| T & | AddOrReplaceComponent (Args &&... args) |
| Adds a component to the entity, or replaces it if the entity already has this component. | |
| template<typename... T> | |
| decltype(auto) | GetComponents () |
| Retries the references to the requested components of the entity. | |
| template<typename... T> | |
| decltype(auto) | GetComponents () const |
| Retries the references to the requested components of the entity. Const variant. | |
| template<typename T, typename... Args> | |
| T & | GetOrAddComponent (Args &&... args) |
| Retries or adds a component to the entity. | |
| template<typename... T> | |
| bool | HasComponents () const |
| Checks if the entity has all the specified components. | |
| template<typename... T> | |
| entt::handle::size_type | RemoveComponents () |
| Removes components from the entity if entity has them. | |
| template<typename... T> | |
| void | EraseComponents () |
| Erases components from the entity without checking if the entity actually have them. | |
| operator bool () const | |
| bool | operator== (const Entity &other) const |
| bool | operator!= (const Entity &other) const |
| bool | IsValid () const |
| Checks if the actual entity behind this handle is valid. | |
| void | SetActive (const bool state) |
| Changes the activity state of the entity. | |
| bool | IsActiveLocally () const |
| Checks if the entity is active locally (doesn't have InactiveLocallyFlag), just a convenience function. | |
| bool | IsActiveGlobally () const |
| Checks if the entity is active locally (doesn't have InactiveGloballyFlag), just a convenience function. | |
| uint32_t | GetID () const |
| Gets the entity ID. | |
| uint32_t | GetVersion () const |
| Gets the entity version. | |
| uint64_t | GetEUID () const |
| Gets the EUID (entity unique ID). A combination of entity ID and version, it is unique for every entity. | |
| uint32_t | GetOwnerSceneID () const |
| Retries the ID of the owner scene. You can get the actual SceneHandle by providing SceneManager with this ID (method: GetHandle). | |
| std::string | GetDebugData (bool showUUID=false) const |
| Gets the debuting string for logging. | |
| std::expected< void, Core::CoriError<> > | SetParent (Entity parent) |
| Links the entity to a parent entity. | |
| std::expected< std::vector< Entity >, Core::CoriError<> > | GetSiblings () const |
| Creates and returns a vector containing all entity siblings. | |
| std::expected< Entity, Core::CoriError<> > | GetParent () const |
| Retries the parent entity of the entity if any. | |
| std::expected< std::vector< Entity >, Core::CoriError<> > | GetChildren () const |
| Creates and returns a vector containing all entity children (does not include grandchildren and so on, not recursive). | |
| std::expected< Entity, Core::CoriError<> > | FindChildByName (const char *name) const |
| Finds a children entity by name. | |
| std::expected< Entity, Core::CoriError<> > | FindChildByName (const std::string_view name) const |
| Finds a children entity by name. | |
| std::expected< Entity, Core::CoriError<> > | FindChildByName (const std::string &name) const |
| Finds a children entity by name. | |
| void | DestroyChildren () |
| Destroys all children (and they grandchildren) that the entity has. | |
| entt::entity | GetRawEntity () const |
| Gets a raw entt::entity if you need to interact with entt directly. | |
| entt::handle | GetRawHandle () const |
| Gets a raw entt::handle if you need to interact with entt directly. | |
| void | PrintHierarchy () const |
| Prints the full entity hierarchy tree in the console. | |
| std::string_view | GetName () const |
| Retrieves the name of the entity. | |
| void | SetName (const std::string &name) |
| Changes the entity name. | |
| void | UnlinkFromParent () |
| Unlinks the entity from its parent if it has one. | |
Protected Member Functions | |
| void | UpdateInactivityFlagsRecursive (entt::entity parent, bool parentIsActive) |
Friends | |
| class | Scene |
Entities are the essential part of WorldSystem.
Entities can have a parent-children hierarchy that is represented by a left-child right-sibling binary tree internally.
Instance of Entity class does not control a lifetime of an actual entity, it lifetime is controlled by the Scene. Through this class you interact with an actual entity, it is sort of a now-owning handle.
Definition at line 25 of file Entity.hpp.
|
default |
|
inline |
Definition at line 29 of file Entity.hpp.
|
inline |
Adds a component to the entity.
| T | Type of component to add. |
| Args | Deduced automatically, no need to specify. |
| args | Arguments passed to the component constructor. |
Definition at line 39 of file Entity.hpp.
|
inline |
Adds a component to the entity, or replaces it if the entity already has this component.
| T | Type of component to add or replace. |
| Args | Deduced automatically, no need to specify. |
| args | Arguments passed to the component constructor. |
Definition at line 63 of file Entity.hpp.
| void Cori::World::Entity::DestroyChildren | ( | ) |
Destroys all children (and they grandchildren) that the entity has.
Definition at line 106 of file Entity.cpp.

|
inline |
Erases components from the entity without checking if the entity actually have them.
| T | Components to erase. |
Definition at line 144 of file Entity.hpp.
|
nodiscard |
Finds a children entity by name.
| name | Name of the children to find. |
Definition at line 94 of file Entity.cpp.

|
nodiscard |
Finds a children entity by name.
| name | Name of the children to find. |
Definition at line 102 of file Entity.cpp.

|
nodiscard |
Finds a children entity by name.
| name | Name of the children to find. |
Definition at line 98 of file Entity.cpp.

|
nodiscard |
Creates and returns a vector containing all entity children (does not include grandchildren and so on, not recursive).
Definition at line 90 of file Entity.cpp.

|
inlinenodiscard |
Retries the references to the requested components of the entity.
| T | Types of components to retrieve. |
Definition at line 74 of file Entity.hpp.

|
inlinenodiscard |
Retries the references to the requested components of the entity. Const variant.
| T | Types of components to retrieve. |
Definition at line 92 of file Entity.hpp.

|
nodiscard |
Gets the debuting string for logging.
| showUUID | Whether to include UUID in the debugging string. |
Definition at line 65 of file Entity.cpp.

|
inlinenodiscard |
Gets the EUID (entity unique ID). A combination of entity ID and version, it is unique for every entity.
Definition at line 205 of file Entity.hpp.

|
inlinenodiscard |
Gets the entity ID.
Definition at line 189 of file Entity.hpp.
|
nodiscard |
Retrieves the name of the entity.
Definition at line 114 of file Entity.cpp.

|
inline |
Retries or adds a component to the entity.
| T | Type of component to retrieve or add if absent. |
| Args | Deduced automatically, no need to specify. |
| args | Arguments passed to the component constructor in case of addition of the component. |
Definition at line 112 of file Entity.hpp.
|
inlinenodiscard |
Retries the ID of the owner scene. You can get the actual SceneHandle by providing SceneManager with this ID (method: GetHandle).
Definition at line 213 of file Entity.hpp.

|
nodiscard |
Retries the parent entity of the entity if any.
Definition at line 82 of file Entity.cpp.

|
inlinenodiscard |
Gets a raw entt::entity if you need to interact with entt directly.
Definition at line 280 of file Entity.hpp.
|
inlinenodiscard |
Gets a raw entt::handle if you need to interact with entt directly.
Definition at line 287 of file Entity.hpp.
|
nodiscard |
Creates and returns a vector containing all entity siblings.
Definition at line 86 of file Entity.cpp.

|
inlinenodiscard |
|
inlinenodiscard |
Checks if the entity has all the specified components.
| T | Components to check the presence of. |
Definition at line 122 of file Entity.hpp.
|
nodiscard |
Checks if the entity is active locally (doesn't have InactiveGloballyFlag), just a convenience function.
Definition at line 61 of file Entity.cpp.

|
nodiscard |
Checks if the entity is active locally (doesn't have InactiveLocallyFlag), just a convenience function.
Definition at line 57 of file Entity.cpp.

|
inlinenodiscard |
Checks if the actual entity behind this handle is valid.
Definition at line 161 of file Entity.hpp.
|
inlineexplicit |
Definition at line 148 of file Entity.hpp.
|
inline |
|
inline |
| void Cori::World::Entity::PrintHierarchy | ( | ) | const |
Prints the full entity hierarchy tree in the console.
Definition at line 110 of file Entity.cpp.

|
inline |
Removes components from the entity if entity has them.
| T | Components to remove. |
Definition at line 133 of file Entity.hpp.
|
inline |
Replaces the component with a newly created one.
| T | Type of component to replace. |
| Args | Deduced automatically, no need to specify. |
| args | Arguments passed to the component constructor. |
Definition at line 51 of file Entity.hpp.
| void Cori::World::Entity::SetActive | ( | const bool | state | ) |
Changes the activity state of the entity.
| state | Activity state to set. |
When deactivating the entity a InactiveLocallyFlag and InactiveGloballyFlag are assigned to it, it this entity has any children a InactiveGloballyFlag will be added to the whole children tree recursively (to the grandchildren, grand-grandchildren and so on).
Definition at line 7 of file Entity.cpp.

| void Cori::World::Entity::SetName | ( | const std::string & | name | ) |
Changes the entity name.
| name | Name to change to. |
Definition at line 122 of file Entity.cpp.

| std::expected< void, Core::CoriError<> > Cori::World::Entity::SetParent | ( | Entity | parent | ) |
Links the entity to a parent entity.
| parent | Parent entity to link the entity to. |
Definition at line 78 of file Entity.cpp.

| void Cori::World::Entity::UnlinkFromParent | ( | ) |
Unlinks the entity from its parent if it has one.
Definition at line 143 of file Entity.cpp.

|
protected |
|
friend |
Definition at line 319 of file Entity.hpp.