amethyst / amethyst/legion

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

未關閉
#247 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Rust
星號
1.7k
分支
140
PR 合併指標
30 天內沒有已合併 PR

描述

Consider this example

```rust
#[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.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。