Skip to content

Support required components which have no sensible default #18717

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

Closed
teohhanhui opened this issue Apr 4, 2025 · 2 comments
Closed

Support required components which have no sensible default #18717

teohhanhui opened this issue Apr 4, 2025 · 2 comments
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled

Comments

@teohhanhui
Copy link

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

Required components spawns required components using the Default implementation, or a default specified in the #[require(...)] attribute.

I'd like to have a way to force the caller to provide some required components at spawn time.

What solution would you like?

Maybe something like:

#[require(Team)]
#[must_provide(Team)]
struct Player {
    // ...
}

What alternative(s) have you considered?

  1. Continue using bundles.

  2. Add the required component as a field on the "concept component".

    From the general design guidelines:

    1. Prefer using component fields directly on the "concept component" as the "public API" for the feature.

    2. Prefer simple APIs / don't over-componentize. By default, if you need to attach new properties to a concept, just add them as fields to that concept's component.

    However, there's unfortunately no way to query by component field from the ECS, AFAICT...

Additional context

N/A

@teohhanhui teohhanhui added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Apr 4, 2025
@hukasu
Copy link
Contributor

hukasu commented Apr 4, 2025

#16267 has some extra ideas for required components

@teohhanhui
Copy link
Author

Duplicate of #16194

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

2 participants