-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add insert and remove recursive methods on EntityWorldMut
and EntityCommands
#17463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add insert and remove recursive methods on EntityWorldMut
and EntityCommands
#17463
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. There's a ton of methods that could use this.
Co-authored-by: Zachary Harrold <[email protected]>
…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 <[email protected]>
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
EntityWorldMut
andEntityCommands
.These methods are generic over the
RelationshipTarget
, thanks to the freshly merged relations 🎉Testing
I've added a simple unit test for these methods.