Trait hecs_hierarchy::HierarchyMut
source · [−]pub trait HierarchyMut {
fn attach<T: Component>(
&mut self,
child: Entity,
parent: Entity
) -> Result<Entity>;
fn attach_new<T: Component, C: DynamicBundle>(
&mut self,
parent: Entity,
components: C
) -> Result<Entity>;
fn detach_all<T: Component>(&mut self, entity: Entity) -> Result<()>;
fn detach_children<T: Component>(&mut self, parent: Entity) -> Result<()>;
fn detach<T: Component>(&mut self, child: Entity) -> Result<()>;
fn despawn_all<T: Component>(&mut self, parent: Entity);
}
Expand description
A trait for modifying the worlds hierarchy. Implemented for hecs::World
>
Required methods
Attach child
to parent
. Parent does not require an existing Parent component
. Returns
the passed child.
Note: The entity needs to be explicitly detached before being removed.
fn attach_new<T: Component, C: DynamicBundle>(
&mut self,
parent: Entity,
components: C
) -> Result<Entity>
fn attach_new<T: Component, C: DynamicBundle>(
&mut self,
parent: Entity,
components: C
) -> Result<Entity>
Attach a new entity with specified components to parent
. Parent does not require an existing Parent component
. Returns
the passed child.
fn detach_all<T: Component>(&mut self, entity: Entity) -> Result<()>
fn detach_all<T: Component>(&mut self, entity: Entity) -> Result<()>
Detaches all children from entity and detaches entity from parent. Use this before removing entities to ensure no loose entity ids.
fn detach_children<T: Component>(&mut self, parent: Entity) -> Result<()>
fn detach_children<T: Component>(&mut self, parent: Entity) -> Result<()>
Detaches all children of parent.
Detach the child from tree T
. The children of child
will not remain in hierachy, but will
remain attached to child
, which means a later attach also will attach the children of child
into the hierarchy. Essentially moving the subtree.
fn despawn_all<T: Component>(&mut self, parent: Entity)
fn despawn_all<T: Component>(&mut self, parent: Entity)
Despawn parent and all children recursively. Essentially despawns a whole subtree including root. Does not fail if there are invalid, dangling IDs in tree.
Implementations on Foreign Types
Detaches all children of parent.