Parent/Child
Parent is a relation like any other, not a special case wired into the engine. It just happens to be the one Wyrd ships for you:
public readonly struct Parent : IRelation, IExclusiveRelation, IDependent { }Exclusive because a child has one parent at a time. Dependent because destroying a parent should take its subtree with it.
Setting and clearing
Section titled “Setting and clearing”child.SetParent(parent);child.ClearParent();SetParent/ClearParent are EntityView mutators, chainable like any other. To reparent, call SetParent alone, a preceding ClearParent costs an extra archetype move for nothing.
From the parent’s side, the same edge, called from whichever entity you have in hand:
parent.AddChild(child);parent.RemoveChild(child);Walking the tree
Section titled “Walking the tree”world.Children(parent); // direct childrenworld.Ancestors(entity); // parent chain, closest firstworld.Descendants(entity); // every descendant, depth-firstworld.TryGetParent(child, out var parent);Cascading destruction
Section titled “Cascading destruction”Destroying a parent destroys its whole subtree, not just the parent. This comes from Parent implementing IDependent, the same mechanism Relations covers for any relation, not a hierarchy-specific special case.
Relations link existing entities together. For starting several entities from one reusable definition, see Templates.