pub trait BuildWorldChildren {
    // Required methods
    fn with_children(
        &mut self,
        spawn_children: impl FnOnce(&mut WorldChildBuilder<'_>)
    ) -> &mut Self;
    fn add_child(&mut self, child: Entity) -> &mut Self;
    fn push_children(&mut self, children: &[Entity]) -> &mut Self;
    fn insert_children(
        &mut self,
        index: usize,
        children: &[Entity]
    ) -> &mut Self;
    fn remove_children(&mut self, children: &[Entity]) -> &mut Self;
    fn set_parent(&mut self, parent: Entity) -> &mut Self;
    fn remove_parent(&mut self) -> &mut Self;
}
Expand description

Trait that defines adding, changing and children and parents of an entity directly through the World.

Required Methods§

source

fn with_children( &mut self, spawn_children: impl FnOnce(&mut WorldChildBuilder<'_>) ) -> &mut Self

Takes a clousre which builds children for this entity using WorldChildBuilder.

source

fn add_child(&mut self, child: Entity) -> &mut Self

Adds a single child.

If the children were previously children of another parent, that parent’s Children component will have those children removed from its list. Removing all children from a parent causes its Children component to be removed from the entity.

source

fn push_children(&mut self, children: &[Entity]) -> &mut Self

Pushes children to the back of the builder’s children. For any entities that are already a child of this one, this method does nothing.

If the children were previously children of another parent, that parent’s Children component will have those children removed from its list. Removing all children from a parent causes its Children component to be removed from the entity.

source

fn insert_children(&mut self, index: usize, children: &[Entity]) -> &mut Self

Inserts children at the given index.

If the children were previously children of another parent, that parent’s Children component will have those children removed from its list. Removing all children from a parent causes its Children component to be removed from the entity.

source

fn remove_children(&mut self, children: &[Entity]) -> &mut Self

Removes the given children

Removing all children from a parent causes its Children component to be removed from the entity.

source

fn set_parent(&mut self, parent: Entity) -> &mut Self

Sets the parent of this entity.

If this entity already had a parent, the parent’s Children component will have this child removed from its list. Removing all children from a parent causes its Children component to be removed from the entity.

source

fn remove_parent(&mut self) -> &mut Self

Removes the Parent of this entity.

Also removes this entity from its parent’s Children component. Removing all children from a parent causes its Children component to be removed from the entity.

Implementations on Foreign Types§

source§

impl<'w> BuildWorldChildren for EntityMut<'w>

source§

fn with_children( &mut self, spawn_children: impl FnOnce(&mut WorldChildBuilder<'_>) ) -> &mut Self

source§

fn add_child(&mut self, child: Entity) -> &mut Self

source§

fn push_children(&mut self, children: &[Entity]) -> &mut Self

source§

fn insert_children(&mut self, index: usize, children: &[Entity]) -> &mut Self

source§

fn remove_children(&mut self, children: &[Entity]) -> &mut Self

source§

fn set_parent(&mut self, parent: Entity) -> &mut Self

source§

fn remove_parent(&mut self) -> &mut Self

Implementors§