Skip to content

Commit

Permalink
Add Commands::new_from_entities (bevyengine#4423)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
TheRawMeatball authored and exjam committed May 22, 2022
1 parent 42ed98a commit 6a03936
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/bevy_ecs/src/system/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6a03936

Please sign in to comment.