asge::ecs::components
Classes & Structs
Functions
void AttachChild(ecs::Registry &inReg, ecs::Entity inParent, ecs::Entity inChild)Makes inChild a child of inParent, re-parenting it (detaching from any previous parent first) if it already had one.
A no-op if inParent equals inChild, or if inChild is already an ancestor of inParent — either would introduce a cycle. Lazily adds a Hierarchy to either entity that doesn't have one yet, and marks inChild's Transform (if any) dirty so the next TransformPropagationSystem pass recomposes its world transform under the new parent.
void DetachChild(ecs::Registry &inReg, ecs::Entity inChild)Unlinks inChild from its parent and siblings, leaving it a root.
A no-op if inChild has no Hierarchy component, or has one but is already a root. Marks inChild's Transform (if any) dirty, same as AttachChild(), since its world transform is no longer composed through the old parent.
bool IsAncestor(ecs::Registry &inReg, ecs::Entity inPotentialAncestor, ecs::Entity inEntity)True if inPotentialAncestor appears somewhere in inEntity's chain of parents (its parent, its parent's parent, ...).
False if inEntity has no Hierarchy component, or is a root.
template<typename Callable> void ForEachChild(ecs::Registry &inReg, ecs::Entity inParent, Callable &&inFn)Invokes inFn(child) once per direct child of inParent, in sibling order (m_FirstChild through m_LastChild).
A no-op if inParent has no Hierarchy component or currently has no children. inFn is captured by the caller's own iteration, so it may safely call AttachChild/DetachChild on the entity it's currently visiting that entity's own m_NextSibling is read before inFn runs.
Constrained via std::invocable rather than functools' function_trait, since inFn is allowed to be a generic lambda (e.g. [](auto child){...}) a generic call operator has no fixed argument type to extract until it's actually invoked, so invocability with ecs::Entity is the only thing that can honestly be checked here.
void SanitizeHierarchy(ecs::Registry &inReg, std::vector< ecs::Entity > const &inEntities)Rebuilds every Hierarchy link among inEntities from their m_Parent pointers, so data that was never validated (a loaded scene file) can't leave the tree inconsistent or cyclic.
A parent that is the entity itself, isn't in inEntities, or has no Hierarchy is dropped (the entity becomes a root), and a parent cycle is broken at the point it would close. Sibling order is kept from each parent's stored first-child chain wherever that chain is consistent; children it doesn't reach follow in inEntities order.
void DestroyEntityGraph(ecs::Registry &inReg, ecs::Entity inRoot)Destroys inRoot and its entire subtree (children, grandchildren, ...), depth-first via ForEachChild/recursion.
Unlike a plain DestroyEntity(inRoot), which detaches its children and leaves them alive as roots, this destroys them too.