16 const entt::entity parent = hierarchy.m_Parent;
17 const entt::entity firstChild = hierarchy.m_FirstChild;
18 const entt::registry* registry = m_EntityHandle.registry();
19 if (registry->valid(parent)) {
24 if (registry->valid(firstChild)) {
44 const entt::entity firstChild = hierarchy.m_FirstChild;
45 const entt::registry* registry = m_EntityHandle.registry();
46 if (registry->valid(firstChild)) {
74 return "GetDebugData: Error: This Entity is no longer valid.";
115 static constexpr char empty[] =
"";
124 if (nameComponent.m_Name == name) {
130 entt::registry* registry = m_EntityHandle.registry();
131 if (registry->valid(hierarchy.m_Parent)) {
132 const entt::entity parent = hierarchy.m_Parent;
134 cache.m_Children.erase(nameComponent.m_Name);
135 cache.m_Children.emplace(name, m_EntityHandle.entity());
139 nameComponent.m_Name = name;
147 void Entity::DrawHierarchyRecursive(
const Entity& entity,
const std::string& prefix,
const bool isLast) {
153 entt::registry* registry = m_EntityHandle.registry();
157 if (finalEffectiveState) {
164 entt::entity currentChild = hierarchy.m_FirstChild;
165 while (registry->valid(currentChild)) {
#define CORI_CORE_CHECK(x,...)
#define CORI_PROFILE_FUNCTION()
Custom error class mainly used in std::expected.
Entities are the essential part of WorldSystem.
void SetActive(const bool state)
Changes the activity state of the entity.
std::expected< std::vector< Entity >, Core::CoriError<> > GetSiblings() const
Creates and returns a vector containing all entity siblings.
void UnlinkFromParent()
Unlinks the entity from its parent if it has one.
bool IsValid() const
Checks if the actual entity behind this handle is valid.
bool IsActiveGlobally() const
Checks if the entity is active locally (doesn't have InactiveGloballyFlag), just a convenience functi...
void PrintHierarchy() const
Prints the full entity hierarchy tree in the console.
std::string_view GetName() const
Retrieves the name of the entity.
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...
T & GetOrAddComponent(Args &&... args)
Retries or adds a component to the entity.
void DestroyChildren()
Destroys all children (and they grandchildren) that the entity has.
std::expected< Entity, Core::CoriError<> > GetParent() const
Retries the parent entity of the entity if any.
std::expected< void, Core::CoriError<> > SetParent(Entity parent)
Links the entity to a parent entity.
uint32_t GetVersion() const
Gets the entity version.
bool HasComponents() const
Checks if the entity has all the specified components.
void EraseComponents()
Erases components from the entity without checking if the entity actually have them.
T & AddComponent(Args &&... args)
Adds a component to the entity.
std::string GetDebugData(bool showUUID=false) const
Gets the debuting string for logging.
decltype(auto) GetComponents()
Retries the references to the requested components of the entity.
bool IsActiveLocally() const
Checks if the entity is active locally (doesn't have InactiveLocallyFlag), just a convenience functio...
uint32_t GetID() const
Gets the entity ID.
void SetName(const std::string &name)
Changes the entity name.
void UpdateInactivityFlagsRecursive(entt::entity parent, bool parentIsActive)
std::expected< Entity, Core::CoriError<> > FindChildByName(const char *name) const
Finds a children entity by name.
static std::expected< std::vector< Entity >, Core::CoriError<> > GetSiblings(Entity subject)
static void DrawHierarchyRecursive(const Entity &entity, const std::string &prefix, const bool isLast)
static std::expected< Entity, Core::CoriError<> > GetParent(Entity subject)
static std::expected< Entity, Core::CoriError<> > FindChildByName(Entity subject, const char *name)
static std::expected< void, Core::CoriError<> > SetParent(Entity subject, Entity parent)
static void UnlinkFromParent(Entity subject)
static void DestroyChildren(Entity subject)
static std::expected< std::vector< Entity >, Core::CoriError<> > GetChildren(Entity subject)
static void PrintHierarchy(Entity subject)
Anything connected to WorldSystem (ECS) is in this namespace.
Every Entity has a ChildCache component by default, it's essential for entity ChildCache system.
Every Entity has a hierarchy component by default, it's essential for entity hierarchy system.
Entity aquifers this flag when is disabled explicitly or its parent Entity is disabled.
Entity aquifers this flag when is disabled explicitly.