summaryrefslogtreecommitdiff
path: root/src/systems/registernew.rs
blob: c6b18fa7a4bbc95e2cc7e1e992217a07811b4e2b (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
28
29
30
31
32
33
34
35
36
37

use std::collections::HashSet;

use specs::{
	ReadStorage,
	Write,
	Entities,
	System,
	Join
};

use crate::components::{
	Position,
	New
};

use crate::resources::{
	Ground
};


#[derive(Default)]
pub struct RegisterNew;
impl <'a> System<'a> for RegisterNew {
	type SystemData = (
		Entities<'a>,
		Write<'a, Ground>,
		ReadStorage<'a, Position>,
		ReadStorage<'a, New>,
	);
	fn run(&mut self, (entities, mut ground, positions, new): Self::SystemData) {
		for (ent, pos, _new) in (&entities, &positions, &new).join() {
			ground.cells.entry(pos.pos).or_insert(HashSet::new()).insert(ent);
		}
	}
}