-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
API for traversing Relationship
s and RelationshipTarget
s in dynamic contexts
#21601
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
API for traversing Relationship
s and RelationshipTarget
s in dynamic contexts
#21601
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.
I really like this feature and already see me using this. 👍
This looks good! I see I'm too late to give an official approval, but I still wanted to leave a few thoughts: Will we want the Given how few components are relationships, would we want to do something like |
I've thought about adding that, but that'll require initializing this field after creating the
Yeah, that makes sense. Ideally we'd have components-as-entities so that @urben1680 also mentioned that a flag indicating whether there is any other data besides |
Oh, right, there are links in both directions, so you can't just register one component first and then pass it to the other. Yeah, that's harder than I thought!
The reason it's on my mind is that I'm trying to figure out how to safely allow mutable query access through |
Because we can't trust that |
…ic contexts (bevyengine#21601) # Objective Currently there is no way to traverse relationships in type-erased contexts or to define dynamic relationship components, which is a hole in the current relationships api. ## Solution Introduce `RelationshipAccessor` to describe a way to get `Entity` values from any registered relationships in dynamic contexts and store it on `ComponentDescriptor`. This allows to traverse relationships without knowing their type, which is useful for working with entity hierarchies using non-default components. ## Testing Added a simple test/example of how to use this api to traverse hierarchies in a type-erased context.
Objective
Currently there is no way to traverse relationships in type-erased contexts or to define dynamic relationship components, which is a hole in the current relationships api.
Solution
Introduce
RelationshipAccessor
to describe a way to getEntity
values from any registered relationships in dynamic contexts and store it onComponentDescriptor
. This allows to traverse relationships without knowing their type, which is useful for working with entity hierarchies using non-default components.Testing
Added a simple test/example of how to use this api to traverse hierarchies in a type-erased context.