diff --git a/crates/bevy_ecs/src/world/mod.rs b/crates/bevy_ecs/src/world/mod.rs index 81730be65d..6f1774e264 100644 --- a/crates/bevy_ecs/src/world/mod.rs +++ b/crates/bevy_ecs/src/world/mod.rs @@ -2474,19 +2474,13 @@ impl World { } } - /// Flushes queued entities and calls [`World::flush_commands`]. - #[inline] - pub fn flush(&mut self) { - self.flush_entities(); - self.flush_commands(); - } - /// Applies any commands in the world's internal [`CommandQueue`]. /// This does not apply commands from any systems, only those stored in the world. /// + /// # Panics /// This will panic if any of the queued commands are [`spawn`](Commands::spawn). /// If this is possible, you should instead use [`flush`](Self::flush). - pub fn flush_commands(&mut self) { + pub(crate) fn flush_commands(&mut self) { // SAFETY: `self.command_queue` is only de-allocated in `World`'s `Drop` if !unsafe { self.command_queue.is_empty() } { // SAFETY: `self.command_queue` is only de-allocated in `World`'s `Drop` @@ -2498,6 +2492,15 @@ impl World { } } + /// Flushes queued entities and commands. + /// + /// Queued entities will be spawned, and then commands will be applied. + #[inline] + pub fn flush(&mut self) { + self.flush_entities(); + self.flush_commands(); + } + /// Increments the world's current change tick and returns the old value. /// /// If you need to call this method, but do not have `&mut` access to the world,