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

WorldQuery::init_state signature is too generous #13358

Open
alice-i-cecile opened this issue May 13, 2024 · 3 comments · May be fixed by #13442
Open

WorldQuery::init_state signature is too generous #13358

alice-i-cecile opened this issue May 13, 2024 · 3 comments · May be fixed by #13442
Labels
A-ECS Entities, components, systems, and events D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Contentious There are nontrivial implications that should be thought through
Milestone

Comments

@alice-i-cecile
Copy link
Member

          I realized that because `Storages` and `Components` aren't public fields on `World`, and there are no mutable accessor functions, doing the same change likely doesn't work for `init_state`. 

Adding mutable accessor function does not make sense, because this would allow users to readily cause UB.
Instead we could have a function on &mut World that returns an opaque struct on which init_component, ... can be called.

Originally posted by @Victoronz in #13343 (comment)

@alice-i-cecile alice-i-cecile added this to the 0.14 milestone May 13, 2024
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events S-Needs-Design This issue requires design work to think about how it would best be accomplished X-Contentious There are nontrivial implications that should be thought through D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes labels May 13, 2024
@alice-i-cecile
Copy link
Member Author

@Victoronz do you want to tackle this?

@Victoronz
Copy link
Contributor

Sure, as I'm already familiar with this.

Currently I'd suggest a component_initializer method on &mut World. It would return a ComponentInitializer struct, which would be a wrapper around &mut Components and &mut Storages. This struct would re-expose all methods on Components, minus the &mut Storages parameter on init_component and init_component_with_descriptor respectively.

@alice-i-cecile
Copy link
Member Author

Sounds great: I look forward to reviewing it.

@alice-i-cecile alice-i-cecile added S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! and removed S-Needs-Design This issue requires design work to think about how it would best be accomplished labels May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Contentious There are nontrivial implications that should be thought through
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants