From 6a0393642826722244cfc7275ef3556c4fb0d2bc Mon Sep 17 00:00:00 2001 From: TheRawMeatball Date: Sat, 14 May 2022 14:40:09 +0000 Subject: [PATCH] Add Commands::new_from_entities (#4423) This change allows for creating `Commands` objects from just an entities reference, which allows for creating multiple dynamically in a normal system. Context: https://discord.com/channels/691052431525675048/774027865020039209/960857605943726142 --- crates/bevy_ecs/src/system/commands/mod.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/bevy_ecs/src/system/commands/mod.rs b/crates/bevy_ecs/src/system/commands/mod.rs index d9495f80c48d1..564f1ab3ebe5f 100644 --- a/crates/bevy_ecs/src/system/commands/mod.rs +++ b/crates/bevy_ecs/src/system/commands/mod.rs @@ -55,6 +55,11 @@ impl<'w, 's> Commands<'w, 's> { } } + /// Create a new `Commands` from a queue and an [`Entities`] reference. + pub fn new_from_entities(queue: &'s mut CommandQueue, entities: &'w Entities) -> Self { + Self { queue, entities } + } + /// Creates a new empty [`Entity`] and returns an [`EntityCommands`] builder for it. /// /// To directly spawn an entity with a [`Bundle`] included, you can use