Add insert and remove recursive methods on EntityWorldMut and EntityCommands#17463
Merged
alice-i-cecile merged 3 commits intobevyengine:mainfrom Jan 21, 2025
Merged
Conversation
bushrat011899
approved these changes
Jan 21, 2025
Contributor
bushrat011899
left a comment
There was a problem hiding this comment.
Makes sense! just a missing new-line in the documentation.
| /// # Warning | ||
| /// | ||
| /// This method should only be called on relationships that form a tree-like structure. | ||
| /// Any cycles will cause this method to loop infinitely. |
Contributor
There was a problem hiding this comment.
Follow-up: I reckon a detect_cyclic_traversal debug feature could be nice. Internally just keep an EntityHashSet and panic! when a cycle is detected.
Member
Author
There was a problem hiding this comment.
Agreed. There's a ton of methods that could use this.
Co-authored-by: Zachary Harrold <zac@harrold.com.au>
AlephCubed
approved these changes
Jan 21, 2025
mrchantey
pushed a commit
to mrchantey/bevy
that referenced
this pull request
Feb 4, 2025
…tyCommands` (bevyengine#17463) # Objective While being able to quickly add / remove components down a tree is broadly useful (material changing!), it's particularly necessary when combined with the newly added bevyengine#13120. ## Solution Write four methods: covering both adding and removal on both `EntityWorldMut` and `EntityCommands`. These methods are generic over the `RelationshipTarget`, thanks to the freshly merged relations 🎉 ## Testing I've added a simple unit test for these methods. --------- Co-authored-by: Zachary Harrold <zac@harrold.com.au>
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
While being able to quickly add / remove components down a tree is broadly useful (material changing!), it's particularly necessary when combined with the newly added #13120.
Solution
Write four methods: covering both adding and removal on both
EntityWorldMutandEntityCommands.These methods are generic over the
RelationshipTarget, thanks to the freshly merged relations 🎉Testing
I've added a simple unit test for these methods.