From f0153eefd580ec443b380504303620a61f24630b Mon Sep 17 00:00:00 2001 From: troido Date: Mon, 3 Feb 2020 16:13:58 +0100 Subject: refactored systems in their own file each --- src/systems/makefloor.rs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/systems/makefloor.rs (limited to 'src/systems/makefloor.rs') 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); + } + } +} -- cgit