Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Relationship::Utils Namespace Reference

Functions

auto SetChildOf (Engine::Entity child, Engine::Entity parent) -> void
auto IsChildOf (Engine::Entity child, Engine::Entity parent) -> bool
auto RemoveParent (Engine::Entity child) -> void
auto GetParent (Engine::Entity child) -> std::optional< Engine::Entity >
template<typename TFunc>
auto ForEachChild (Engine::Entity parent, TFunc func) -> void
template<typename TComponent>
auto GetChildComponents (Engine::Entity parent) -> std::vector< std::reference_wrapper< TComponent > >
template<typename TComponent>
auto TryGetParentComponent (Engine::Entity child) -> TComponent *

Function Documentation

◆ ForEachChild()

template<typename TFunc>
auto Relationship::Utils::ForEachChild ( Engine::Entity parent,
TFunc func ) -> void

Apply a function to each child of an entity.

Parameters
parentparent entity
Returns
no return value

◆ GetChildComponents()

template<typename TComponent>
auto Relationship::Utils::GetChildComponents ( Engine::Entity parent) -> std::vector< std::reference_wrapper< TComponent > >

Get a specific pointer list of a component for each child of an entity.

Parameters
parentparent entity
Returns
a vector containing pointers to the specified component for each child of the parent entity

◆ GetParent()

auto Relationship::Utils::GetParent ( Engine::Entity child) -> std::optional< Engine::Entity >

Get the parent of an entity.

Parameters
childchild entity
Returns
the parent entity, or nullopt if the entity has no parent

◆ IsChildOf()

auto Relationship::Utils::IsChildOf ( Engine::Entity child,
Engine::Entity parent ) -> bool

Check if an entity is a child of another entity.

Parameters
parentparent entity
childchild entity
Returns
true if the child is a child of the parent

◆ RemoveParent()

auto Relationship::Utils::RemoveParent ( Engine::Entity child) -> void

Remove the parent of an entity.

Parameters
childchild entity

◆ SetChildOf()

auto Relationship::Utils::SetChildOf ( Engine::Entity child,
Engine::Entity parent ) -> void

Set the child of an entity to another entity.

Parameters
parentparent entity
childchild entity

◆ TryGetParentComponent()

template<typename TComponent>
auto Relationship::Utils::TryGetParentComponent ( Engine::Entity child) -> TComponent *

Get the pointer to a component of a parent of an Entity.

Parameters
childchild entity
Returns
the pointer to the component if the parent entity has it, or nullptr if the entity has no parent or the parent has no such component