From f573480a5ddca1192a81d442879ca1adbc19915f Mon Sep 17 00:00:00 2001 From: urben1680 <55257931+urben1680@users.noreply.github.com> Date: Sat, 19 Apr 2025 11:52:17 +0200 Subject: [PATCH 1/2] Add `world` and `world_mut` methods to `RelatedSpawner` --- crates/bevy_ecs/src/relationship/related_methods.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/crates/bevy_ecs/src/relationship/related_methods.rs b/crates/bevy_ecs/src/relationship/related_methods.rs index 98ef8d08321ac..3ac927c6324cc 100644 --- a/crates/bevy_ecs/src/relationship/related_methods.rs +++ b/crates/bevy_ecs/src/relationship/related_methods.rs @@ -519,6 +519,16 @@ impl<'w, R: Relationship> RelatedSpawner<'w, R> { pub fn target_entity(&self) -> Entity { self.target } + + /// Returns a reference to the underlying [`World`]. + pub fn world(&self) -> &World { + self.world + } + + /// Returns a mutable reference to the underlying [`World`]. + pub fn world_mut(&self) -> &mut World { + self.world + } } /// Uses commands to spawn related "source" entities with the given [`Relationship`], targeting From 7a7b2a92ba85e469d507dd647d667a364d5b7d2b Mon Sep 17 00:00:00 2001 From: urben1680 <55257931+urben1680@users.noreply.github.com> Date: Sat, 19 Apr 2025 12:12:57 +0200 Subject: [PATCH 2/2] Update related_methods.rs --- crates/bevy_ecs/src/relationship/related_methods.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/relationship/related_methods.rs b/crates/bevy_ecs/src/relationship/related_methods.rs index 3ac927c6324cc..b53fd43943752 100644 --- a/crates/bevy_ecs/src/relationship/related_methods.rs +++ b/crates/bevy_ecs/src/relationship/related_methods.rs @@ -526,7 +526,7 @@ impl<'w, R: Relationship> RelatedSpawner<'w, R> { } /// Returns a mutable reference to the underlying [`World`]. - pub fn world_mut(&self) -> &mut World { + pub fn world_mut(&mut self) -> &mut World { self.world } }