summaryrefslogtreecommitdiff
path: root/src/systems/makefloor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/systems/makefloor.rs')
-rw-r--r--src/systems/makefloor.rs29
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);
+ }
+ }
+}