summaryrefslogtreecommitdiff
path: root/src/systems/draw.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/systems/draw.rs')
-rw-r--r--src/systems/draw.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/systems/draw.rs b/src/systems/draw.rs
new file mode 100644
index 0000000..82400e3
--- /dev/null
+++ b/src/systems/draw.rs
@@ -0,0 +1,31 @@
+
+use specs::{
+ ReadStorage,
+ Write,
+ System,
+ Join
+};
+
+use super::super::components::{
+ Position,
+ Visible
+};
+
+use super::super::resources::{
+ TopView
+};
+
+
+pub struct Draw;
+impl <'a> System<'a> for Draw {
+
+ type SystemData = (ReadStorage<'a, Position>, ReadStorage<'a, Visible>, Write<'a, TopView>);
+
+ fn run(&mut self, (pos, vis, mut view): Self::SystemData) {
+ view.cells.clear();
+ for (pos, vis) in (&pos, &vis).join(){
+ view.cells.entry(*pos).or_insert(Vec::new()).push(vis.clone());
+ view.cells.get_mut(pos).unwrap().sort_by(|a, b| b.height.partial_cmp(&a.height).unwrap());
+ }
+ }
+}