Fix EntityCommands::despawn docs (#13774)

# Objective

The `EntityCommands::despawn` method was previously changed from
panicking behavior to a warning, but the docs continue to state that it
panics.

## Solution

- Removed panic section, copied warning blurb from `World::despawn`
- Adds a similar warning blurb to
`DespawnRecursiveExt::despawn_recursive` and
`DespawnRecursiveExt::despawn_descendants`
This commit is contained in:
thebluefish 2024-06-09 10:59:19 -07:00 committed by GitHub
parent b9e67bc3c3
commit 7c9c6ff27f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 3 additions and 4 deletions

View file

@ -1017,6 +1017,7 @@ impl EntityCommands<'_> {
} }
/// Despawns the entity. /// Despawns the entity.
/// This will emit a warning if the entity does not exist.
/// ///
/// See [`World::despawn`] for more details. /// See [`World::despawn`] for more details.
/// ///
@ -1025,10 +1026,6 @@ impl EntityCommands<'_> {
/// This won't clean up external references to the entity (such as parent-child relationships /// This won't clean up external references to the entity (such as parent-child relationships
/// if you're using `bevy_hierarchy`), which may leave the world in an invalid state. /// if you're using `bevy_hierarchy`), which may leave the world in an invalid state.
/// ///
/// # Panics
///
/// The command will panic when applied if the associated entity does not exist.
///
/// # Example /// # Example
/// ///
/// ``` /// ```

View file

@ -91,6 +91,7 @@ pub trait DespawnRecursiveExt {
impl DespawnRecursiveExt for EntityCommands<'_> { impl DespawnRecursiveExt for EntityCommands<'_> {
/// Despawns the provided entity and its children. /// Despawns the provided entity and its children.
/// This will emit warnings for any entity that does not exist.
fn despawn_recursive(mut self) { fn despawn_recursive(mut self) {
let entity = self.id(); let entity = self.id();
self.commands().add(DespawnRecursive { entity }); self.commands().add(DespawnRecursive { entity });
@ -105,6 +106,7 @@ impl DespawnRecursiveExt for EntityCommands<'_> {
impl<'w> DespawnRecursiveExt for EntityWorldMut<'w> { impl<'w> DespawnRecursiveExt for EntityWorldMut<'w> {
/// Despawns the provided entity and its children. /// Despawns the provided entity and its children.
/// This will emit warnings for any entity that does not exist.
fn despawn_recursive(self) { fn despawn_recursive(self) {
let entity = self.id(); let entity = self.id();