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§

source

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.

source

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.

source

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.

source

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<()>

source

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.

source

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§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl HierarchyMut for World

source§

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<()>

Detaches all children of parent.

source§

fn attach<T: Component>( &mut self, child: Entity, parent: Entity ) -> Result<Entity>

source§

fn attach_new<T: Component, C: DynamicBundle>( &mut self, parent: Entity, components: C ) -> Result<Entity>

source§

fn detach_all<T: Component>(&mut self, entity: Entity) -> Result<()>

source§

fn detach<T: Component>(&mut self, child: Entity) -> Result<()>

source§

fn despawn_all<T: Component>(&mut self, parent: Entity)

Implementors§