diff options
| author | troido <troido@protonmail.com> | 2020-02-03 16:13:58 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-02-03 16:13:58 +0100 |
| commit | f0153eefd580ec443b380504303620a61f24630b (patch) | |
| tree | 98fe9cb6a9039d50b180ea774396e2d162a41656 /src/systems/makefloor.rs | |
| parent | 4bb710c6c6df8a24a2efa8033ad3c17663345dbd (diff) | |
refactored systems in their own file each
Diffstat (limited to 'src/systems/makefloor.rs')
| -rw-r--r-- | src/systems/makefloor.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/systems/makefloor.rs b/src/systems/makefloor.rs new file mode 100644 index 0000000..864f204 --- /dev/null +++ b/src/systems/makefloor.rs @@ -0,0 +1,29 @@ + + +use specs::{ + ReadStorage, + Write, + Entities, + System, + Join +}; + +use super::super::components::{ + Position +}; + +use super::super::resources::{ + Floor +}; + + +pub struct MakeFloor; +impl <'a> System<'a> for MakeFloor { + type SystemData = (Entities<'a>, Write<'a, Floor>, ReadStorage<'a, Position>); + fn run(&mut self, (entities, mut floor, positions): Self::SystemData) { + floor.cells.clear(); + for (ent, pos) in (&entities, &positions).join() { + floor.cells.entry(*pos).or_insert(Vec::new()).push(ent); + } + } +} |
