-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Add ComponentId-taking functions to Entity{Ref,Mut}Except to mirror FilteredEntity{Ref,Mut} #17800
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 ComponentId-taking functions to Entity{Ref,Mut}Except to mirror FilteredEntity{Ref,Mut} #17800
Conversation
f49bfe3
to
b7a9d9c
Compare
…ilteredEntity{Ref,Mut}.
b7a9d9c
to
4d331dd
Compare
/// Unlike [`EntityRefExcept::get`], this returns a raw pointer to the component, | ||
/// which is only valid while the [`EntityRefExcept`] is alive. | ||
#[inline] | ||
pub fn get_by_id(&self, component_id: ComponentId) -> Option<Ptr<'w>> { |
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 think this could be generalized using DynamicComponentFetch
to match the other get_by_id()
methods. But that should happen anyway when these get merged by the "Pointing Fingers: Deduplicating Entity APIs with EntityPtr" working group, so this is fine for now!
…ilteredEntity{Ref,Mut}.
7adeefe
to
161ca26
Compare
@chescock I reverted the unsound lifetime change by an amend commit, apparently that removes the entire conversation from GitHub. Everything seems to be fine, so the issues I was having apparently were solved by some other change during development. |
…ilteredEntity{Ref,Mut} (bevyengine#17800) # Objective Related to bevyengine#17784. The ticket is actually about just getting rid of `Entity{Ref,Mut}Except` in favor of `FilteredEntity{Ref,Mut}`, but I got told the unification of Entity types is a bigger endeavor that has been going on for a while now (as the "Pointing Fingers" working group) and I should just add the functions I actually need in the meantime. ## Solution This PR adds all of the functions necessary to access components by TypeId or ComponentId instead of static types. ## Testing > Did you test these changes? If so, how? Haven't tested it yet, but the changes are mostly copy/paste from other implementations in the same file, since there is a lot of duplicated functionality there. ## Not a Migration Guide There shouldn't be any breaking changes, it's just a few new functions on existing types. I had to shuffle around the lifetimes in `From<&EntityMutExcept<'a, B>> for EntityRefExcept<'a, B>` (originally it was `From<&'a EntityMutExcept<'_, B>> for EntityRefExcept<'_, B>`) to make the borrow checker happy, but I don't think that this should have an impact on user code (correct me if I'm wrong).
Objective
Related to #17784. The ticket is actually about just getting rid of
Entity{Ref,Mut}Except
in favor ofFilteredEntity{Ref,Mut}
, but I got told the unification of Entity types is a bigger endeavor that has been going on for a while now (as the "Pointing Fingers" working group) and I should just add the functions I actually need in the meantime.Solution
This PR adds all of the functions necessary to access components by TypeId or ComponentId instead of static types.
Testing
Haven't tested it yet, but the changes are mostly copy/paste from other implementations in the same file, since there is a lot of duplicated functionality there.
Not a Migration Guide
There shouldn't be any breaking changes, it's just a few new functions on existing types.