Add world and world_mut methods to RelatedSpawner (#18880)

# Objective

`RelatedSpawnerCommands` offers methods to get the underlying
`Commands`.
`RelatedSpawner` does not expose the inner `World` reference so far.

I currently want to write extension traits for both of them but I need
to duplicate the whole API for the latter because I cannot get it's
`&mut World`.

## Solution

Add methods for immutable and mutable `World` access
This commit is contained in:
urben1680 2025-05-06 07:18:56 +02:00 committed by François Mockers
parent 79cbe845db
commit f39320d0c7

View File

@ -519,6 +519,16 @@ impl<'w, R: Relationship> RelatedSpawner<'w, R> {
pub fn target_entity(&self) -> Entity { pub fn target_entity(&self) -> Entity {
self.target 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(&mut self) -> &mut World {
self.world
}
} }
/// Uses commands to spawn related "source" entities with the given [`Relationship`], targeting /// Uses commands to spawn related "source" entities with the given [`Relationship`], targeting