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

State arguments cannot be Query-, CommandBuffer-, SubWorld, or Entity-typed #247

Open
tel opened this issue Mar 20, 2021 · 0 comments
Open

Comments

@tel
Copy link

tel commented Mar 20, 2021

Consider this example

#[system]
fn do_a_thing(#[state] target: &Entity) { ... }

this may be a system which is focused on working around a single entity; its starting entity is fed in during system init do_a_thing_system(ent). Today, this fails with the error "error: simple systems cannot contain component references, consider using #[system(for_each)]" which is somewhat confusing. I am not intending to reference a component.

Of course, Entity is a magic component as far as #[system] is concerned and ends up being referenced specially when it shows up in a type. The workaround is to produce a new, distinct type struct Target(Entity), take that as the state type fn do_a_thing(#[state] target: &Target) { ... } and then build it with that type do_a_thing_system(Target(ent)).

This workaround isn't too bad, and maybe is even the "ideal" way to handle this situation all together.

Expected behavior

Either (a) the #[state] attribute overrides type-based dispatch or (b) at the very least the error is more clear noting how &Entity refs are special-cased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant