Struct bevy_ecs::system::EntityCommands[][src]

pub struct EntityCommands<'a, 'b> { /* fields omitted */ }

Implementations

impl<'a, 'b> EntityCommands<'a, 'b>[src]

pub fn id(&self) -> Entity[src]

Retrieves the current entity’s unique Entity id.

pub fn insert_bundle(&mut self, bundle: impl Bundle) -> &mut Self[src]

Adds a bundle of components to the current entity.

See [Self::with], [Self::current_entity].

pub fn insert(&mut self, component: impl Component) -> &mut Self[src]

Adds a single component to the current entity.

See Self::insert_bundle, Self::id.

Warning

It’s possible to call this with a bundle, but this is likely not intended and Self::insert_bundle should be used instead. If with is called with a bundle, the bundle itself will be added as a component instead of the bundles’ inner components each being added.

Example

Self::insert can be chained with [Self::spawn].

use bevy_ecs::prelude::*;

struct Component1;
struct Component2;

fn example_system(mut commands: Commands) {
    // Create a new entity with `Component1` and `Component2`
    commands.spawn()
        .insert(Component1)
        .insert(Component2);

    // Psst! These are also equivalent to the expression above!
    commands.spawn().insert_bundle((Component1, Component2));
    commands.spawn_bundle((Component1, Component2));
}

pub fn remove_bundle<T>(&mut self) -> &mut Self where
    T: Bundle
[src]

pub fn remove<T>(&mut self) -> &mut Self where
    T: Component
[src]

pub fn despawn(&mut self)[src]

Despawns only the specified entity, not including its children.

pub fn commands(&mut self) -> &mut Commands<'a>[src]

Auto Trait Implementations

impl<'a, 'b> !RefUnwindSafe for EntityCommands<'a, 'b>

impl<'a, 'b> Send for EntityCommands<'a, 'b>

impl<'a, 'b> Sync for EntityCommands<'a, 'b>

impl<'a, 'b> Unpin for EntityCommands<'a, 'b> where
    'a: 'b, 

impl<'a, 'b> !UnwindSafe for EntityCommands<'a, 'b>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Component for T where
    T: 'static + Send + Sync
[src]

impl<T> Downcast for T where
    T: Any
[src]

impl<T> DowncastSync for T where
    T: Any + Send + Sync
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,