Struct bevy_ecs::system::EntityCommands [−][src]
pub struct EntityCommands<'w, 's, 'a> { /* fields omitted */ }
Expand description
A list of commands that will be run to modify an entity.
Implementations
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));
}
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>();
}
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>();
}
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();
}
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
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
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
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
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more