Struct bevy::ecs::system::EntityCommands [−]
pub struct EntityCommands<'w, 's, 'a> { /* fields omitted */ }
Expand description
A list of commands that will be run to modify an entity.
Implementations
impl<'w, 's, 'a> EntityCommands<'w, 's, 'a>
impl<'w, 's, 'a> EntityCommands<'w, 's, 'a>
pub fn insert_bundle(
&mut self,
bundle: impl Bundle
) -> &mut EntityCommands<'w, 's, 'a>
pub fn insert_bundle(
&mut self,
bundle: impl Bundle
) -> &mut EntityCommands<'w, 's, 'a>
pub fn insert(
&mut self,
component: impl Component
) -> &mut EntityCommands<'w, 's, 'a>
pub fn insert(
&mut self,
component: impl Component
) -> &mut EntityCommands<'w, 's, 'a>
Adds a single Component
to the entity.
See EntityMut::insert
for more
details.
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 Commands::spawn
.
fn example_system(mut commands: Commands) {
// Create a new entity with `Component1` and `Component2`
commands.spawn()
.insert(Component1)
.insert(Component2);
// The following statements are equivalent to above one.
commands.spawn().insert_bundle((Component1, Component2));
commands.spawn_bundle((Component1, Component2));
}
pub fn remove_bundle<T>(&mut self) -> &mut EntityCommands<'w, 's, 'a> where
T: Bundle,
pub fn remove_bundle<T>(&mut self) -> &mut EntityCommands<'w, 's, 'a> where
T: Bundle,
Removes a Bundle
of components from the entity.
See EntityMut::remove_bundle
for more
details.
Example
struct Dummy;
fn remove_combat_stats_system(mut commands: Commands, player: Res<PlayerEntity>) {
commands.entity(player.entity).remove_bundle::<CombatBundle>();
}
pub fn remove<T>(&mut self) -> &mut EntityCommands<'w, 's, 'a> where
T: Component,
pub fn remove<T>(&mut self) -> &mut EntityCommands<'w, 's, 'a> where
T: Component,
Removes a single component from the entity.
See EntityMut::remove
for more details.
Example
fn convert_enemy_system(mut commands: Commands, enemy: Res<TargetEnemy>) {
commands.entity(enemy.entity).remove::<Enemy>();
}
pub fn despawn(&mut self)
pub fn despawn(&mut self)
Despawns the entity.
See World::despawn
for more details.
Example
fn remove_character_system(
mut commands: Commands,
character_to_remove: Res<CharacterToRemove>
)
{
commands.entity(character_to_remove.entity).despawn();
}
Trait Implementations
impl<'w, 's, 'a> BuildChildren for EntityCommands<'w, 's, 'a>
impl<'w, 's, 'a> BuildChildren for EntityCommands<'w, 's, 'a>
pub fn with_children(
&mut self,
spawn_children: impl FnOnce(&mut ChildBuilder<'_, '_, '_>)
) -> &mut EntityCommands<'w, 's, 'a>
pub fn push_children(
&mut self,
children: &[Entity]
) -> &mut EntityCommands<'w, 's, 'a>
pub fn insert_children(
&mut self,
index: usize,
children: &[Entity]
) -> &mut EntityCommands<'w, 's, 'a>
pub fn remove_children(
&mut self,
children: &[Entity]
) -> &mut EntityCommands<'w, 's, 'a>
pub fn add_child(&mut self, child: Entity) -> &mut EntityCommands<'w, 's, 'a>
impl<'w, 's, 'a> DespawnRecursiveExt for EntityCommands<'w, 's, 'a>
impl<'w, 's, 'a> DespawnRecursiveExt for EntityCommands<'w, 's, 'a>
pub fn despawn_recursive(self)
pub fn despawn_recursive(self)
Despawns the provided entity and its children.
pub fn despawn_descendants(&mut self)
pub fn despawn_descendants(&mut self)
Despawns all descendants of the given entity.
Auto Trait Implementations
impl<'w, 's, 'a> RefUnwindSafe for EntityCommands<'w, 's, 'a>
impl<'w, 's, 'a> Send for EntityCommands<'w, 's, 'a>
impl<'w, 's, 'a> Sync for EntityCommands<'w, 's, 'a>
impl<'w, 's, 'a> Unpin for EntityCommands<'w, 's, 'a> where
's: 'a,
'w: 'a,
impl<'w, 's, 'a> !UnwindSafe for EntityCommands<'w, 's, 'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
pub fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
pub fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
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;
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;
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
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;
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;
impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
pub fn vzip(self) -> V
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more