bevy/crates
rudderbucky 2da8d17a44
Add try_despawn methods to World/Commands (#15480)
# Objective

Fixes #14511.

`despawn` allows you to remove entities from the world. However, if the
entity does not exist, it emits a warning. This may not be intended
behavior for many users who have use cases where they need to call
`despawn` regardless of if the entity actually exists (see the issue),
or don't care in general if the entity already doesn't exist.

(Also trying to gauge interest on if this feature makes sense, I'd
personally love to have it, but I could see arguments that this might be
a footgun. Just trying to help here 😄 If there's no contention I could
also implement this for `despawn_recursive` and `despawn_descendants` in
the same PR)

## Solution

Add `try_despawn`, `try_despawn_recursive` and
`try_despawn_descendants`.

Modify `World::despawn_with_caller` to also take in a `warn` boolean
argument, which is then considered when logging the warning. Set
`log_warning` to `true` in the case of `despawn`, and `false` in the
case of `try_despawn`.

## Testing

Ran `cargo run -p ci` on macOS, it seemed fine.
2024-10-03 16:21:05 +00:00
..
bevy_a11y Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_animation Impose a more sensible ordering for animation graph evaluation. (#15589) 2024-10-03 00:36:42 +00:00
bevy_app Documentation for variadics (#15387) 2024-10-02 12:48:36 +00:00
bevy_asset move ANDROID_APP to bevy_window (#15585) 2024-10-02 03:01:06 +00:00
bevy_audio Migrate audio to required components (#15573) 2024-10-01 22:43:29 +00:00
bevy_color Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_core Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_core_pipeline Migrate motion blur, TAA, SSAO, and SSR to required components (#15572) 2024-10-01 22:45:31 +00:00
bevy_derive move ANDROID_APP to bevy_window (#15585) 2024-10-02 03:01:06 +00:00
bevy_dev_tools Simplified ui_stack_system (#9889) 2024-09-30 18:43:57 +00:00
bevy_diagnostic Runtime required components (#15458) 2024-09-30 19:20:16 +00:00
bevy_dylib Generate links to definition in source code pages on docs.rs and dev-docs.bevyengine.org (#12965) 2024-07-29 23:10:16 +00:00
bevy_ecs Add try_despawn methods to World/Commands (#15480) 2024-10-03 16:21:05 +00:00
bevy_encase_derive Update `glam to 0.29, encase` to 0.10. (#15249) 2024-09-23 19:44:02 +00:00
bevy_gilrs Implement gamepads as entities (#12770) 2024-09-27 20:07:20 +00:00
bevy_gizmos Use circle gizmos for capsule (#15602) 2024-10-02 19:47:56 +00:00
bevy_gltf Migrate scenes to required components (#15579) 2024-10-01 22:42:11 +00:00
bevy_hierarchy Add try_despawn methods to World/Commands (#15480) 2024-10-03 16:21:05 +00:00
bevy_input Revert "Have EntityCommands methods consume self for easier chaining" (#15523) 2024-10-02 12:47:26 +00:00
bevy_internal Add features to switch NativeActivity and GameActivity usage (#12095) 2024-10-01 22:23:48 +00:00
bevy_log Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_macro_utils Modify derive_label to support no_std environments (#15465) 2024-09-27 20:23:26 +00:00
bevy_math add curve utilities to create curves interpolating/easing between two values (#14788) 2024-10-02 14:29:05 +00:00
bevy_mikktspace Add no_std support to bevy_mikktspace (#15528) 2024-09-30 18:17:03 +00:00
bevy_pbr Added visibility bitmask as an alternative SSAO method (#13454) 2024-10-02 13:43:35 +00:00
bevy_picking Revert "Have EntityCommands methods consume self for easier chaining" (#15523) 2024-10-02 12:47:26 +00:00
bevy_ptr Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_reflect Documentation for variadics (#15387) 2024-10-02 12:48:36 +00:00
bevy_remote Allow access a method handler (#15601) 2024-10-02 19:45:18 +00:00
bevy_render Better warnings about invalid parameters (#15500) 2024-10-03 13:16:55 +00:00
bevy_scene Migrate scenes to required components (#15579) 2024-10-01 22:42:11 +00:00
bevy_sprite Revert "Have EntityCommands methods consume self for easier chaining" (#15523) 2024-10-02 12:47:26 +00:00
bevy_state Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_tasks bump async-channel to 2.3.0 (#15497) 2024-09-28 19:21:59 +00:00
bevy_text Refactor TextPipeline::update_buffer to accept an interator (#15581) 2024-10-01 23:44:59 +00:00
bevy_time Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_transform Migrate visibility to required components (#15474) 2024-09-27 19:06:16 +00:00
bevy_ui Add try_despawn methods to World/Commands (#15480) 2024-10-03 16:21:05 +00:00
bevy_utils Add core and alloc over std Lints (#15281) 2024-09-27 00:59:59 +00:00
bevy_window move ANDROID_APP to bevy_window (#15585) 2024-10-02 03:01:06 +00:00
bevy_winit move ANDROID_APP to bevy_window (#15585) 2024-10-02 03:01:06 +00:00