Allow all hooks on relationship components#24000
Merged
alice-i-cecile merged 3 commits intobevyengine:mainfrom Apr 28, 2026
Merged
Allow all hooks on relationship components#24000alice-i-cecile merged 3 commits intobevyengine:mainfrom
alice-i-cecile merged 3 commits intobevyengine:mainfrom
Conversation
SkiFire13
reviewed
Apr 27, 2026
| struct RelTarget(Entity); | ||
|
|
||
| fn on_add(world: DeferredWorld, context: HookContext) { | ||
| assert!(!world.entity(context.entity).contains::<RelTarget>()); |
Contributor
There was a problem hiding this comment.
I think this is a point of discussion: do we want the user defined hook to run before or after the relationship one?
Contributor
Author
There was a problem hiding this comment.
I think it doesn't matter a lot because structural changes are deferred. Currently the order in which hooks are called when inserting/removing multiple components at once isn't specified either (and they all run before the world is flushed).
I suppose this assert is misleading in this regard as it's independent of the order.
chescock
approved these changes
Apr 27, 2026
Contributor
chescock
left a comment
There was a problem hiding this comment.
Oh, nice, you managed to get this down to a pretty small change!
alice-i-cecile
approved these changes
Apr 28, 2026
Member
alice-i-cecile
left a comment
There was a problem hiding this comment.
Wow, that's incredibly nice. Love to see it!
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
Fixes #23990
Solution
If both the user and the relationship define a hook, call both.
Testing
Added a test checking hooks don't interfere with relationships.
Showcase