Struct bevy::ecs::system::EntityCommands [−]
Implementations
impl<'a, 'b> EntityCommands<'a, 'b>
pub fn id(&self) -> Entity
Retrieves the current entity’s unique Entity id.
pub fn insert_bundle(
&mut self,
bundle: impl Bundle
) -> &mut EntityCommands<'a, 'b>
&mut self,
bundle: impl Bundle
) -> &mut EntityCommands<'a, 'b>
Adds a bundle of components to the current entity.
See [Self::with
], [Self::current_entity
].
pub fn insert(
&mut self,
component: impl Component
) -> &mut EntityCommands<'a, 'b>
&mut self,
component: impl Component
) -> &mut EntityCommands<'a, 'b>
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 EntityCommands<'a, 'b> where
T: Bundle,
T: Bundle,
pub fn remove<T>(&mut self) -> &mut EntityCommands<'a, 'b> where
T: Component,
T: Component,
pub fn despawn(&mut self)
Despawns only the specified entity, not including its children.
pub fn commands(&mut self) -> &mut Commands<'a>
Trait Implementations
impl<'a, 'b> BuildChildren for EntityCommands<'a, 'b>
pub fn with_children(
&mut self,
spawn_children: impl FnOnce(&mut ChildBuilder<'_, '_>)
) -> &mut EntityCommands<'a, 'b>
&mut self,
spawn_children: impl FnOnce(&mut ChildBuilder<'_, '_>)
) -> &mut EntityCommands<'a, 'b>
pub fn push_children(
&mut self,
children: &[Entity]
) -> &mut EntityCommands<'a, 'b>
&mut self,
children: &[Entity]
) -> &mut EntityCommands<'a, 'b>
pub fn insert_children(
&mut self,
index: usize,
children: &[Entity]
) -> &mut EntityCommands<'a, 'b>
&mut self,
index: usize,
children: &[Entity]
) -> &mut EntityCommands<'a, 'b>
impl<'a, 'b> DespawnRecursiveExt for EntityCommands<'a, 'b>
pub fn despawn_recursive(&mut self)
Despawns the provided entity and its children.
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,
'a: 'b,
impl<'a, 'b> !UnwindSafe for EntityCommands<'a, 'b>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any,
T: Any,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Component for T where
T: 'static + Send + Sync,
T: 'static + Send + Sync,
impl<T> Downcast for T where
T: Any,
T: Any,
pub fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn as_any(&self) -> &(dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
impl<T> Downcast<T> for T
impl<T> DowncastSync for T where
T: Any + Send + Sync,
T: Any + Send + Sync,
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
[src]
Notable traits for Instrumented<T>
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Upcast<T> for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,