diff --git a/crates/bevy_ecs/src/relationship/related_methods.rs b/crates/bevy_ecs/src/relationship/related_methods.rs index 150bd02ebd..33e76b5874 100644 --- a/crates/bevy_ecs/src/relationship/related_methods.rs +++ b/crates/bevy_ecs/src/relationship/related_methods.rs @@ -21,7 +21,9 @@ impl<'w> EntityWorldMut<'w> { self } - /// Relates the given entities to this entity with the relation `R` + /// Relates the given entities to this entity with the relation `R`. + /// + /// See [`add_one_related`](Self::add_one_related) if you want relate only one entity. pub fn add_related(&mut self, related: &[Entity]) -> &mut Self { let id = self.id(); self.world_scope(|world| { @@ -32,6 +34,13 @@ impl<'w> EntityWorldMut<'w> { self } + /// Relates the given entity to this with the relation `R`. + /// + /// See [`add_related`](Self::add_related) if you want to relate more than one entity. + pub fn add_one_related(&mut self, entity: Entity) -> &mut Self { + self.add_related::(&[entity]) + } + /// Despawns entities that relate to this one via the given [`RelationshipTarget`]. /// This entity will not be despawned. pub fn despawn_related(&mut self) -> &mut Self { @@ -108,7 +117,9 @@ impl<'a> EntityCommands<'a> { self } - /// Relates the given entities to this entity with the relation `R` + /// Relates the given entities to this entity with the relation `R`. + /// + /// See [`add_one_related`](Self::add_one_related) if you want relate only one entity. pub fn add_related(&mut self, related: &[Entity]) -> &mut Self { let id = self.id(); let related = related.to_vec(); @@ -120,6 +131,13 @@ impl<'a> EntityCommands<'a> { self } + /// Relates the given entity to this with the relation `R`. + /// + /// See [`add_related`](Self::add_related) if you want to relate more than one entity. + pub fn add_one_related(&mut self, entity: Entity) -> &mut Self { + self.add_related::(&[entity]) + } + /// Despawns entities that relate to this one via the given [`RelationshipTarget`]. /// This entity will not be despawned. pub fn despawn_related(&mut self) -> &mut Self {