diff --git a/crates/bevy_ecs/src/world/entity_access/world_mut.rs b/crates/bevy_ecs/src/world/entity_access/world_mut.rs index d77a26315b30f..8f4d9010ba9f7 100644 --- a/crates/bevy_ecs/src/world/entity_access/world_mut.rs +++ b/crates/bevy_ecs/src/world/entity_access/world_mut.rs @@ -16,6 +16,7 @@ use crate::{ relationship::RelationshipHookMode, resource::Resource, storage::{SparseSets, Table}, + system::EntityCommands, template::{EntityScopes, ScopedEntities, Template, TemplateContext}, world::{ error::EntityComponentError, unsafe_world_cell::UnsafeEntityCell, ComponentEntry, @@ -1877,6 +1878,17 @@ impl<'w> EntityWorldMut<'w> { f(guard.entity_mut.world) } + /// Creates a new [`EntityCommands`] instance that writes to the world's command queue + /// Use [`World::flush`] to apply all queued commands + #[inline] + pub fn entity_commands(&mut self) -> EntityCommands<'_> { + let id = self.id(); + EntityCommands { + entity: id, + commands: self.world.commands(), + } + } + /// Updates the internal entity location to match the current location in the internal /// [`World`]. ///