Required components cannot be registered just with ComponentIds
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
Registering required components is done through [try_register_required_components](https://docs.rs/bevy/latest/bevy/prelude/struct.World.html#method.try_register_required_components) (or equivalent functions in other types). This expects the components as static types in the generic parameters `T` and `R`. There's [get_required_components_by_id](https://docs.rs/bevy/latest/bevy/prelude/struct.World.html#method.get_required_components_by_id) that returns the list of required components as an immutable list.
However, I don't see a way to register required components just by passing component ids. This is necessary for runtime-defined components.
## What solution would you like?
Implement a function `try_register_required_components_by_id` that gets the base component and its required component by id. I don't know how to handle `try_register_required_components_with`, but there should also be a way to do that.
## What alternative(s) have you considered?
I've looked through the code. There's a `get_required_components_mut` in `Components`, but that one is `pub(crate)`. There's `register_required_components` that's also `pub(crate)`, but that one still needs some type `R` anyways.
So, I'm out of ideas how to get the current public API to do this.
## Additional context
All my research happened on the main branch of bevy (`82f6f704dad816e91a47cf72664db6289b179c26`).
Contributor guide
Assessment
This issue has not been assessed yet.