bevy/crates
JaySpruce 5a94beb239
Extend cloning functionality and add convenience methods to EntityWorldMut and EntityCommands (#16826)
## Objective

Thanks to @eugineerd's work on entity cloning (#16132), we now have a
robust way to copy components between entities. We can extend this to
implement some useful functionality that would have been more
complicated before.

Closes #15350.

## Solution

`EntityCloneBuilder` now automatically includes required components
alongside any component added/removed from the component filter.

Added the following methods to `EntityCloneBuilder`:
- `move_components`
- `without_required_components`

Added the following methods to `EntityWorldMut` and `EntityCommands`:
- `clone_with`
- `clone_components`
- `move_components`

Also added `clone_and_spawn` and `clone_and_spawn_with` to
`EntityWorldMut` (`EntityCommands` already had them).

## Showcase

```
assert_eq!(world.entity(entity_a).get::<B>(), Some(&B));
assert_eq!(world.entity(entity_b).get::<B>(), None);
world.entity_mut(entity_a).clone_components::<B>(entity_b);
assert_eq!(world.entity(entity_a).get::<B>(), Some(&B));
assert_eq!(world.entity(entity_b).get::<B>(), Some(&B));

assert_eq!(world.entity(entity_a).get::<C>(), Some(&C(5)));
assert_eq!(world.entity(entity_b).get::<C>(), None);
world.entity_mut(entity_a).move_components::<C>(entity_b);
assert_eq!(world.entity(entity_a).get::<C>(), None);
assert_eq!(world.entity(entity_b).get::<C>(), Some(&C(5)));
```
2024-12-16 19:37:32 +00:00
..
bevy_a11y Remove accesskit re-export from bevy_a11y (#16257) 2024-11-08 21:01:16 +00:00
bevy_animation Support tuple structs in AnimatedField (#16747) 2024-12-11 17:06:08 +00:00
bevy_app Update hashbrown to 0.15 (#15801) 2024-12-10 19:45:50 +00:00
bevy_asset Fix stale comment on LoadContext::finish. (#16821) 2024-12-15 19:18:03 +00:00
bevy_audio Move Volume and GlobalVolume to own file (#16838) 2024-12-16 19:28:30 +00:00
bevy_color Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
bevy_core Update hashbrown to 0.15 (#15801) 2024-12-10 19:45:50 +00:00
bevy_core_pipeline Make indirect drawing opt-out instead of opt-in, enabling multidraw by default. (#16757) 2024-12-13 06:16:57 +00:00
bevy_derive Use one BevyManifest instance in proc macros (#16766) 2024-12-15 15:00:05 +00:00
bevy_dev_tools Draw the UI debug overlay using the UI renderer (#16693) 2024-12-11 00:49:47 +00:00
bevy_diagnostic Update hashbrown to 0.15 (#15801) 2024-12-10 19:45:50 +00:00
bevy_dylib
bevy_ecs Extend cloning functionality and add convenience methods to EntityWorldMut and EntityCommands (#16826) 2024-12-16 19:37:32 +00:00
bevy_encase_derive Use one BevyManifest instance in proc macros (#16766) 2024-12-15 15:00:05 +00:00
bevy_gilrs Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
bevy_gizmos Fix registering all reflection types that are components as reflection components (#16800) 2024-12-16 19:16:43 +00:00
bevy_gltf Remove the meta field from LoadedAsset and ErasedLoadedAsset. (#15487) 2024-12-13 20:40:02 +00:00
bevy_hierarchy rename enqueue_command to queue_command for consistency (#16753) 2024-12-11 00:53:54 +00:00
bevy_image ✏️ Fix typos across bevy (#16702) 2024-12-08 01:18:39 +00:00
bevy_input Fix registering all reflection types that are components as reflection components (#16800) 2024-12-16 19:16:43 +00:00
bevy_input_focus Improve bevy_input_focus (#16749) 2024-12-12 19:15:08 +00:00
bevy_internal Draw the UI debug overlay using the UI renderer (#16693) 2024-12-11 00:49:47 +00:00
bevy_log
bevy_macro_utils Use one BevyManifest instance in proc macros (#16766) 2024-12-15 15:00:05 +00:00
bevy_math Derivative access patterns for curves (#16503) 2024-12-10 20:27:37 +00:00
bevy_mesh Update hashbrown to 0.15 (#15801) 2024-12-10 19:45:50 +00:00
bevy_mikktspace Use en-us locale for typos (#16037) 2024-10-20 18:55:17 +00:00
bevy_pbr Make #[bindless] in ExtendedMaterial actually enable bindless mode. (#16818) 2024-12-15 19:18:58 +00:00
bevy_picking Reorder PickSet::Focus systems (#16791) 2024-12-13 18:55:22 +00:00
bevy_ptr Fix MSRVs for standalone crates (#16333) 2024-11-17 09:38:13 +00:00
bevy_reflect Use one BevyManifest instance in proc macros (#16766) 2024-12-15 15:00:05 +00:00
bevy_remote BRP strict field in query (#16725) 2024-12-14 05:22:19 +00:00
bevy_render Fix registering all reflection types that are components as reflection components (#16800) 2024-12-16 19:16:43 +00:00
bevy_scene Add missing #[reflect(Component, Default)] to SceneRoot and DynamicSceneRoot. (#16816) 2024-12-15 19:18:22 +00:00
bevy_sprite BorderRect maintenance (#16727) 2024-12-12 04:33:44 +00:00
bevy_state Use one BevyManifest instance in proc macros (#16766) 2024-12-15 15:00:05 +00:00
bevy_tasks Add no_std support to bevy_tasks (#15464) 2024-12-06 02:14:54 +00:00
bevy_text fix tiny copy-paste mistake in bevy_text::font_atlas_set (#16667) 2024-12-10 03:17:09 +00:00
bevy_time
bevy_transform Deny derive_more error feature and replace it with thiserror (#16684) 2024-12-06 17:03:55 +00:00
bevy_ui Fix registering all reflection types that are components as reflection components (#16800) 2024-12-16 19:16:43 +00:00
bevy_utils Update hashbrown to 0.15 (#15801) 2024-12-10 19:45:50 +00:00
bevy_window add missing type registration for Monitor (#16685) 2024-12-06 15:20:10 +00:00
bevy_winit Rename trigger.entity() to trigger.target() (#16716) 2024-12-08 21:55:09 +00:00