amethyst / amethyst/legion

It should be possible to have `#[read_component(Component)]` and `&Component` on the same `for_each` system.

Abierto
#199 2 comentarios 7 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Rust
Estrellas
1.7k
Forks
140
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I have (a more complex version of) the following system:

```rust
struct Name;
struct InCryoTube(pub Entity);

#[system(for_each)]
#[read_component(Name)]
fn help_me(
name: &Name,
in_cryo_tube: &InCryoTube,
world: &mut legion::world::SubWorld,
) {
println!("{}", name);

let entity: Entity = in_cryo_tube.0;
let entry = world.entry_ref(entity).unwrap();
let name = entry.get_component::().unwrap(); // panic here
println!("{}", name);

}
```

Unfortunately it panics with this:
```
thread '' panicked at 'called `Result::unwrap()` on an `Err` value: Denied {
component_type: ComponentTypeId { type_id: TypeId { t: 12223289268359141760 },
name: "game::components::Name" }, component_name: "game::components::Name" }', src/main.rs:408:46
```

I know that this is to do with the limitations of `SubWorld`s, but it really should be possible to do this, as this is a fairly common pattern.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.