Refactor hierarchy-related commands to remove structs#17029
Merged
alice-i-cecile merged 4 commits intobevyengine:mainfrom Dec 30, 2024
Merged
Refactor hierarchy-related commands to remove structs#17029alice-i-cecile merged 4 commits intobevyengine:mainfrom
alice-i-cecile merged 4 commits intobevyengine:mainfrom
Conversation
Contributor
|
It looks like your PR is a breaking change, but you didn't provide a migration guide. Could you add some context on what users should update when this change get released in a new version of Bevy? |
alice-i-cecile
approved these changes
Dec 29, 2024
Member
alice-i-cecile
left a comment
There was a problem hiding this comment.
Good changes and very clear. Many of these structs are pub though: can you add a quick migration guide to the PR description?
bushrat011899
approved these changes
Dec 30, 2024
Contributor
bushrat011899
left a comment
There was a problem hiding this comment.
Makes sense to streamline these commands, nice work!
BenjaminBrienen
approved these changes
Dec 30, 2024
ecoskey
pushed a commit
to ecoskey/bevy
that referenced
this pull request
Jan 6, 2025
## Objective Continuation of bevyengine#16999. This PR handles the following: - Many hierarchy-related commands are wrappers around `World` and `EntityWorldMut` methods and can be moved to closures: - `AddChild` - `InsertChildren` - `AddChildren` - `RemoveChildren` - `ClearChildren` - `ReplaceChildren` - `RemoveParent` - `DespawnRecursive` - `DespawnChildrenRecursive` - `AddChildInPlace` - `RemoveParentInPlace` - `SendEvent` is a wrapper around `World` methods and can be moved to a closure (and its file deleted). ## Migration Guide If you were queuing the structs of hierarchy-related commands or `SendEvent` directly, you will need to change them to the methods implemented on `EntityCommands` (or `Commands` for `SendEvent`): | Struct | Method | |--------------------------------------------------------------------|---------------------------------------------------------------------------------------------| | `commands.queue(AddChild { child, parent });` | `commands.entity(parent).add_child(child);` OR `commands.entity(child).set_parent(parent);` | | `commands.queue(AddChildren { children, parent });` | `commands.entity(parent).add_children(children);` | | `commands.queue(InsertChildren { children, parent });` | `commands.entity(parent).insert_children(children);` | | `commands.queue(RemoveChildren { children, parent });` | `commands.entity(parent).remove_children(children);` | | `commands.queue(ReplaceChildren { children, parent });` | `commands.entity(parent).replace_children(children);` | | `commands.queue(ClearChildren { parent });` | `commands.entity(parent).clear_children();` | | `commands.queue(RemoveParent { child });` | `commands.entity(child).remove_parent()` | | `commands.queue(DespawnRecursive { entity, warn: true });` | `commands.entity(entity).despawn_recursive();` | | `commands.queue(DespawnRecursive { entity, warn: false });` | `commands.entity(entity).try_despawn_recursive();` | | `commands.queue(DespawnChildrenRecursive { entity, warn: true });` | `commands.entity(entity).despawn_descendants();` | | `commands.queue(DespawnChildrenRecursive { entity, warn: false});` | `commands.entity(entity).try_despawn_descendants();` | | `commands.queue(SendEvent { event });` | `commands.send_event(event);` |
mrchantey
pushed a commit
to mrchantey/bevy
that referenced
this pull request
Feb 4, 2025
## Objective Continuation of bevyengine#16999. This PR handles the following: - Many hierarchy-related commands are wrappers around `World` and `EntityWorldMut` methods and can be moved to closures: - `AddChild` - `InsertChildren` - `AddChildren` - `RemoveChildren` - `ClearChildren` - `ReplaceChildren` - `RemoveParent` - `DespawnRecursive` - `DespawnChildrenRecursive` - `AddChildInPlace` - `RemoveParentInPlace` - `SendEvent` is a wrapper around `World` methods and can be moved to a closure (and its file deleted). ## Migration Guide If you were queuing the structs of hierarchy-related commands or `SendEvent` directly, you will need to change them to the methods implemented on `EntityCommands` (or `Commands` for `SendEvent`): | Struct | Method | |--------------------------------------------------------------------|---------------------------------------------------------------------------------------------| | `commands.queue(AddChild { child, parent });` | `commands.entity(parent).add_child(child);` OR `commands.entity(child).set_parent(parent);` | | `commands.queue(AddChildren { children, parent });` | `commands.entity(parent).add_children(children);` | | `commands.queue(InsertChildren { children, parent });` | `commands.entity(parent).insert_children(children);` | | `commands.queue(RemoveChildren { children, parent });` | `commands.entity(parent).remove_children(children);` | | `commands.queue(ReplaceChildren { children, parent });` | `commands.entity(parent).replace_children(children);` | | `commands.queue(ClearChildren { parent });` | `commands.entity(parent).clear_children();` | | `commands.queue(RemoveParent { child });` | `commands.entity(child).remove_parent()` | | `commands.queue(DespawnRecursive { entity, warn: true });` | `commands.entity(entity).despawn_recursive();` | | `commands.queue(DespawnRecursive { entity, warn: false });` | `commands.entity(entity).try_despawn_recursive();` | | `commands.queue(DespawnChildrenRecursive { entity, warn: true });` | `commands.entity(entity).despawn_descendants();` | | `commands.queue(DespawnChildrenRecursive { entity, warn: false});` | `commands.entity(entity).try_despawn_descendants();` | | `commands.queue(SendEvent { event });` | `commands.send_event(event);` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
Continuation of #16999.
This PR handles the following:
WorldandEntityWorldMutmethods and can be moved to closures:AddChildInsertChildrenAddChildrenRemoveChildrenClearChildrenReplaceChildrenRemoveParentDespawnRecursiveDespawnChildrenRecursiveAddChildInPlaceRemoveParentInPlaceSendEventis a wrapper aroundWorldmethods and can be moved to a closure (and its file deleted).Migration Guide
If you were queuing the structs of hierarchy-related commands or
SendEventdirectly, you will need to change them to the methods implemented onEntityCommands(orCommandsforSendEvent):commands.queue(AddChild { child, parent });commands.entity(parent).add_child(child);ORcommands.entity(child).set_parent(parent);commands.queue(AddChildren { children, parent });commands.entity(parent).add_children(children);commands.queue(InsertChildren { children, parent });commands.entity(parent).insert_children(children);commands.queue(RemoveChildren { children, parent });commands.entity(parent).remove_children(children);commands.queue(ReplaceChildren { children, parent });commands.entity(parent).replace_children(children);commands.queue(ClearChildren { parent });commands.entity(parent).clear_children();commands.queue(RemoveParent { child });commands.entity(child).remove_parent()commands.queue(DespawnRecursive { entity, warn: true });commands.entity(entity).despawn_recursive();commands.queue(DespawnRecursive { entity, warn: false });commands.entity(entity).try_despawn_recursive();commands.queue(DespawnChildrenRecursive { entity, warn: true });commands.entity(entity).despawn_descendants();commands.queue(DespawnChildrenRecursive { entity, warn: false});commands.entity(entity).try_despawn_descendants();commands.queue(SendEvent { event });commands.send_event(event);