Skip to content
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 various methods to get reflected components from EntityRef & friends #15199

Closed
wants to merge 10 commits into from

Conversation

SkiFire13
Copy link
Contributor

Objective

Solution

  • Add get_reflect, get_reflect_ref, get_reflect_mut and get_many_reflect_mut methods to the types UnsafeEntityCell, EntityRef, EntityMut, EntityWorldMut, FilteredEntityRef and FilteredEntityMut (the _mut variants are missing for types that don't provide mutable access);
    • With the exception of EntityWorldMut, all these methods take a &TypeRegistry argument, since they can't fetch it from the World. EntityWorldMut instead fetches the AppTypeRegistry resource from the World reference it has access to;
    • Differently from the methods on World these methods take a ComponentId, which I think is more general and slightly more efficient.
  • Add get_ref_by_id to those same types and a RefUntyped type to match MutUntyped.

TODO

  • Remove World::get_reflect and World::get_reflect_mut, since they can be replaced by the corresponding methods on EntityRef and EntityMut/EntityWorldMut
  • Documentation and safety comments
  • Proper errors instead of Options
  • Tests
  • Showcase

Showcase

TODO

@SkiFire13 SkiFire13 force-pushed the get-reflect-component branch from 232d476 to b4edd8b Compare September 14, 2024 12:27
@IQuick143 IQuick143 added C-Feature A new feature, making something new possible A-Reflection Runtime information about types D-Unsafe Touches with unsafe code in some way labels Sep 14, 2024
@alice-i-cecile alice-i-cecile added the S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged label Sep 16, 2024
@SkiFire13 SkiFire13 force-pushed the get-reflect-component branch from b4edd8b to 4ebcec1 Compare September 29, 2024 13:25
@SkiFire13 SkiFire13 force-pushed the get-reflect-component branch from 4ebcec1 to 44b70eb Compare September 29, 2024 13:43
@SkiFire13
Copy link
Contributor Author

Closing because I thought I had enough time to finish it but lately I've been too busy to do so. Might come back to it in the future, but for now this is open to adoption if anyone wants to.

@SkiFire13 SkiFire13 closed this Oct 2, 2024
@MrGVSV MrGVSV added S-Adopt-Me The original PR author has no intent to complete this work. Pick me up! and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types C-Feature A new feature, making something new possible D-Unsafe Touches with unsafe code in some way S-Adopt-Me The original PR author has no intent to complete this work. Pick me up!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants