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
This commit is contained in:
TheRawMeatball 2022-05-14 14:40:09 +00:00
parent 947d3f9627
commit 516e4aaa10

View file

@ -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