ParentCommands

Trait ParentCommands 

Source
pub trait ParentCommands<'w, 's, 'a> {
    // Required methods
    fn root_id(&self) -> Entity;
    fn id(&self) -> Entity;
    fn commands(&mut self) -> &mut Commands<'w, 's>;

    // Provided methods
    fn insert(&mut self, component: impl Component) -> &mut Self { ... }
    fn insert_bundle(&mut self, bundle: impl Bundle) -> &mut Self { ... }
    fn with_child<T>(&mut self, bundle: T) -> ChildCommands<'w, 's, '_>
       where T: Bundle { ... }
    fn with_empty_child<T>(&mut self) -> ChildCommands<'w, 's, '_> { ... }
    fn with_descendants(
        &mut self,
        local_root: impl FnOnce(&mut RootCommands<'_, '_, '_>),
    ) -> &mut Self { ... }
    fn add_child(&mut self, child: Entity) -> &mut Self { ... }
    fn with_child_batch<I>(&mut self, bundles_iter: I) -> &mut Self
       where I: IntoIterator + Send + Sync + 'static,
             I::Item: Bundle { ... }
}

Required Methods§

Source

fn root_id(&self) -> Entity

returns the id of the root entity of the current hierarchy

Source

fn id(&self) -> Entity

returns the id of the current entity

Source

fn commands(&mut self) -> &mut Commands<'w, 's>

returns Commands

Provided Methods§

Source

fn insert(&mut self, component: impl Component) -> &mut Self

add a component to the current entity

Source

fn insert_bundle(&mut self, bundle: impl Bundle) -> &mut Self

add a bundle of components to the current entity

Source

fn with_child<T>(&mut self, bundle: T) -> ChildCommands<'w, 's, '_>
where T: Bundle,

Create a child entity with components from bundle with the current entity as its parent. Then make it the current entity

Source

fn with_empty_child<T>(&mut self) -> ChildCommands<'w, 's, '_>

create a child entity and make it the current entity

Source

fn with_descendants( &mut self, local_root: impl FnOnce(&mut RootCommands<'_, '_, '_>), ) -> &mut Self

makes the current entity the root of a new local hierachy

Source

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

create a child entity but don’t advance to it.

Source

fn with_child_batch<I>(&mut self, bundles_iter: I) -> &mut Self
where I: IntoIterator + Send + Sync + 'static, I::Item: Bundle,

create multiple children each spawned with the same bundle of components.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'w, 's, 'a> ParentCommands<'w, 's, 'a> for EntityCommands<'w, 's, 'a>

Source§

fn root_id(&self) -> Entity

Source§

fn id(&self) -> Entity

Source§

fn commands(&mut self) -> &mut Commands<'w, 's>

Implementors§

Source§

impl<'w, 's, 'a> ParentCommands<'w, 's, 'a> for ChildCommands<'w, 's, 'a>

Source§

impl<'w, 's, 'a> ParentCommands<'w, 's, 'a> for RootCommands<'w, 's, 'a>