summaryrefslogtreecommitdiff
path: root/src/systems/makefloor.rs
blob: 209d9651f07f23f78fd53d2cefc27ccff866d4ba (plain)
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


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.pos).or_insert(Vec::new()).push(ent);
		}
	}
}