Trait hecs_hierarchy::HierarchyMut
source · pub trait HierarchyMut {
// Required methods
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<Vec<Entity>>;
fn despawn_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§
sourcefn attach<T: Component>(
&mut self,
child: Entity,
parent: Entity
) -> Result<Entity>
fn attach<T: Component>( &mut self, child: Entity, parent: Entity ) -> Result<Entity>
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.
sourcefn 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.
sourcefn 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.
sourcefn detach_children<T: Component>(
&mut self,
parent: Entity
) -> Result<Vec<Entity>>
fn detach_children<T: Component>( &mut self, parent: Entity ) -> Result<Vec<Entity>>
Detaches all children of parent.
fn despawn_children<T: Component>(&mut self, parent: Entity) -> Result<()>
sourcefn detach<T: Component>(&mut self, child: Entity) -> Result<()>
fn detach<T: Component>(&mut self, child: Entity) -> Result<()>
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.
sourcefn 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.
Object Safety§
Implementations on Foreign Types§
source§impl HierarchyMut for World
impl HierarchyMut for World
source§fn detach_children<T: Component>(
&mut self,
parent: Entity
) -> Result<Vec<Entity>>
fn detach_children<T: Component>( &mut self, parent: Entity ) -> Result<Vec<Entity>>
Detaches all children of parent.
source§fn despawn_children<T: Component>(&mut self, parent: Entity) -> Result<()>
fn despawn_children<T: Component>(&mut self, parent: Entity) -> Result<()>
Detaches all children of parent.