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 GitHub
parent a312170749
commit 2ae1510f89
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -531,6 +531,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(&mut self) -> &mut World {
self.world
}
}
/// Uses commands to spawn related "source" entities with the given [`Relationship`], targeting