Struct Commands

Source
pub struct Commands<'a> { /* private fields */ }
Available on crate feature ecs only.
Expand description

A SystemParameter that allows you to create/destroy Entitys, add/remove Components, etc

Implementations§

Source§

impl Commands<'_>

Source

pub fn create_entity<B>(&mut self, bundle: B)
where B: ComponentBundle,

Creates an Entity

Source

pub fn destroy_entity(&mut self, entity: Entity)

Schedules an Entity to be destroyed along with all its attached components This does not error if the Entity is already destroyed

Source

pub fn add_components<B>(&mut self, entity: Entity, bundle: B)
where B: ComponentBundle,

Adds a bundle of Components to an Entity, any Components that are already attached will be replaced This does not error if the Entity is invalid/destroyed

Source

pub fn remove_components<B>(&mut self, entity: Entity)
where B: ComponentBundle,

Removes a bundle of Components from an Entity This does not error if the Entity is invalid/destroyed or any of the Components are not attached to this Entity

Source

pub fn schedule(&mut self, f: impl FnOnce(&mut App) + Send + 'static)

Schedules an arbitrary closure to be run after the current SystemSet has finished

Trait Implementations§

Source§

impl<'a> SystemParameter for Commands<'a>

Source§

type This<'this> = Commands<'this>

The type that this trait is implemented on, but with a different lifetime
Source§

type Lock<'state> = &'state Sender<Box<dyn FnOnce(&mut App) + Send>>

The lock returned by SystemParameter::lock
Source§

fn lock<'state>( state: &SystemRunState<'state>, ) -> <Commands<'a> as SystemParameter>::Lock<'state>

Locks any state required for this SystemParameter
Source§

fn construct<'this>( state: &'this mut <Commands<'a> as SystemParameter>::Lock<'_>, last_run_tick: u64, ) -> <Commands<'a> as SystemParameter>::This<'this>

Constructs the SystemParameter from a lock
Source§

fn get_resource_types() -> impl Iterator<Item = Borrow>

Returns an iterator over all Resource types that this system parameter will lock
Source§

fn get_component_types() -> impl Iterator<Item = Borrow>

Returns an iterator over all Component types that this system parameter will lock

Auto Trait Implementations§

§

impl<'a> Freeze for Commands<'a>

§

impl<'a> RefUnwindSafe for Commands<'a>

§

impl<'a> Send for Commands<'a>

§

impl<'a> Sync for Commands<'a>

§

impl<'a> Unpin for Commands<'a>

§

impl<'a> UnwindSafe for Commands<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.