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

Reflection - Add a way to register or modify RequiredComponents for a component whose type you don't know #18420

Open
makspll opened this issue Mar 19, 2025 · 0 comments
Labels
A-ECS Entities, components, systems, and events A-Reflection Runtime information about types C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Uncontroversial This work is generally agreed upon

Comments

@makspll
Copy link
Contributor

makspll commented Mar 19, 2025

What problem does this solve or what need does it fill?

Currently you can:

  • register a dynamic component with World::register_component_with_descriptor
  • register required components for a component whose type you know at compile time via: World::register_required_components()
  • retrieve a &RequiredComponents for any component
  • Create a new component implementing type which initializes its RequiredComponents BUT PURELY with compile time information i.e. no &self

But there is no way to either (as far I can see):

  • initialize your dynamic component with a specific RequiredComponents
  • retrieve a &mut for the components RequiredComponents after the fact

What solution would you like?

  • Add ability to get to &mut RequiredComponents for any component
  • Add &self to Component::register_required_components
  • Add RequiredComponents argument to register_component_with_descriptor or an alternative function with that argument

What alternative(s) have you considered?

  • Perhaps there is a horribly cursed way to do this if you pass the required components via World through a resource or something, but even that seems difficult as there's no way to call register_required_components yourself.
  • An ability to create a component with a custom ComponentInfo yourself
@makspll makspll added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Mar 19, 2025
@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events A-Reflection Runtime information about types S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Uncontroversial This work is generally agreed upon D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed S-Needs-Triage This issue needs to be labelled labels Mar 19, 2025
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 A-Reflection Runtime information about types C-Feature A new feature, making something new possible D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Ready-For-Implementation This issue is ready for an implementation PR. Go for it! X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

No branches or pull requests

2 participants