-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Cleanup entity reference types #17149
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
Conversation
1cc3ff7
to
43a6868
Compare
43a6868
to
5e7faa3
Compare
EntityRef::from(self) | ||
} | ||
|
||
/// Consumes `self` and returns non-structural mutable access to all of the |
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.
What does "non-structural" mean in this context?
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.
Structural access (&mut World
access) means you can insert/remove components, or despawn the entity. Non-structural access allows none of that; instead you have sliced access to the world which means you aren't allowed to perform changes that might affect other entities.
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 see, thanks for the clarification!
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.
This looks nice! This would all be good cleanup even if it weren't necessary for the EntityPtr
work. I especially like the reduction of unsafe
by doing self.as_mutable().thing()
and self.as_readonly().thing()
.
# Objective Cleanup `EntityRef`, `EntityMut`, and `EntityWorldMut` in preparation for my "Scoped Entity References" PR. ## Solution - Switched `EntityRef`/`EntityMut` from tuple structs to normal ones. - Ensured all conversion trait impls use the same `entity` argument name. - Replaced some `unsafe` with delegated calls from `EntityMut` to `EntityRef` - Added `EntityMut::into_readonly` to make the replacements clearer - Replaced some `unsafe` with delegated calls from `EntityWorldMut` to `EntityMut` and `EntityRef` - Added `EntityWorldMut::into_readonly`, `::as_readonly`, `::into_mutable`, `::as_mutable` to make the replacements clearer ## Testing Reusing current tests.
Objective
Cleanup
EntityRef
,EntityMut
, andEntityWorldMut
in preparation for my "Scoped Entity References" PR.Solution
EntityRef
/EntityMut
from tuple structs to normal ones.entity
argument name.unsafe
with delegated calls fromEntityMut
toEntityRef
EntityMut::into_readonly
to make the replacements clearerunsafe
with delegated calls fromEntityWorldMut
toEntityMut
andEntityRef
EntityWorldMut::into_readonly
,::as_readonly
,::into_mutable
,::as_mutable
to make the replacements clearerTesting
Reusing current tests.