You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
Consider this example
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 typestruct Target(Entity)
, take that as the state typefn do_a_thing(#[state] target: &Target) { ... }
and then build it with that typedo_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.The text was updated successfully, but these errors were encountered: