From a955d65ffa6422d4d96583ca8e6f02ab4184ef7c Mon Sep 17 00:00:00 2001 From: Trashtalk217 Date: Sat, 27 Jan 2024 17:10:39 +0100 Subject: [PATCH] Exclusive systems can now be used for one-shot systems (#11560) Joy notified me that exclusive systems should now work (they may have always worked, I don't know), so here's a quick change to the documentation. --- crates/bevy_ecs/src/system/system_registry.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/bevy_ecs/src/system/system_registry.rs b/crates/bevy_ecs/src/system/system_registry.rs index c04ff35b7c..7057b6fcae 100644 --- a/crates/bevy_ecs/src/system/system_registry.rs +++ b/crates/bevy_ecs/src/system/system_registry.rs @@ -145,7 +145,6 @@ impl World { /// # Limitations /// /// - Stored systems cannot be recursive, they cannot call themselves through [`Commands::run_system`](crate::system::Commands). - /// - Exclusive systems cannot be used. /// /// # Examples /// @@ -239,7 +238,6 @@ impl World { /// # Limitations /// /// - Stored systems cannot be recursive, they cannot call themselves through [`Commands::run_system`](crate::system::Commands). - /// - Exclusive systems cannot be used. /// /// # Examples /// @@ -505,6 +503,17 @@ mod tests { assert_eq!(output, NonCopy(3)); } + #[test] + fn exclusive_system() { + let mut world = World::new(); + let exclusive_system_id = world.register_system(|world: &mut World| { + world.spawn_empty(); + }); + let entity_count = world.entities.len(); + let _ = world.run_system(exclusive_system_id); + assert_eq!(world.entities.len(), entity_count + 1); + } + #[test] fn nested_systems() { use crate::system::SystemId;