Skip to content

Required components cannot be registered just with ComponentIds #17910

@anlumo

Description

@anlumo

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

Registering required components is done through 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 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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions