bevy/crates
Brezak 7cd729cf1a Add methods to bulk replace relationships on a entity (#18058)
# Objective

Add a way to efficiently replace a set of specifically related entities
with a new set.
Closes #18041 

## Solution

Add new `replace_(related/children)` to `EntityWorldMut` and friends.

## Testing

Added a new test to `hierarchy.rs` that specifically check if
`replace_children` actually correctly replaces the children on a entity
while keeping the original one.

---

## Showcase

`EntityWorldMut` and `EntityCommands` can now be used to efficiently
replace the entities a entity is related to.

```rust
/// `parent` has 2 children. `entity_a` and `entity_b`.
assert_eq!([entity_a, entity_b], world.entity(parent).get::<Children>());

/// Replace `parent`s children with `entity_a` and `entity_c`
world.entity_mut(parent).replace_related(&[entity_a, entity_c]);

/// `parent` now has 2 children. `entity_a` and `entity_c`.
///
/// `replace_children` has saved time by not removing and reading
/// the relationship between `entity_a` and `parent`
assert_eq!([entity_a, entity_c], world.entity(parent).get::<Children>());

---------

Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
2025-03-19 21:36:18 +01:00
..
bevy_a11y Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_animation Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_app Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_asset Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_audio Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_color Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_core_pipeline Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_derive Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_dev_tools Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_diagnostic Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_dylib enable std when building bevy_dylib (#18405) 2025-03-19 08:03:12 +01:00
bevy_ecs Add methods to bulk replace relationships on a entity (#18058) 2025-03-19 21:36:18 +01:00
bevy_encase_derive Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_gilrs Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_gizmos Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_gltf gate import on bevy_animation in bevy_gltf (#18403) 2025-03-19 00:51:59 +01:00
bevy_image Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_input Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_input_focus Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_internal Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_log Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_macro_utils Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_math Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_mesh Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_mikktspace Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_pbr Fix specialize_shadows system ordering (#18412) 2025-03-19 21:36:18 +01:00
bevy_picking Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_platform_support Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_ptr Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_reflect Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_remote Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_render Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_scene Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_sprite Fix unecessary specialization checks for apps with many materials (#18410) 2025-03-19 21:36:18 +01:00
bevy_state Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_tasks Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_text Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_time Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_transform Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_ui Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_utils Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_window Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00
bevy_winit Release 0.16.0-rc.1 2025-03-18 21:48:22 +01:00