1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use specs::{prelude::*, System};
use crate::{engine::components::UnitComponent, floor::Floor, unit::Unit};
pub struct UiSystem {
pub floor: Floor,
}
impl UiSystem {
pub fn new(floor: Floor) -> UiSystem {
UiSystem { floor }
}
}
impl<'a> System<'a> for UiSystem {
type SystemData = ReadStorage<'a, UnitComponent>;
fn run(&mut self, units: Self::SystemData) {
self.floor.units = (&units)
.join()
.map(|comp| Unit::new(comp.unit.unit_type, comp.unit.position))
.collect();
self.floor.draw();
}
}