summaryrefslogtreecommitdiff
path: root/src/systems/registernew.rs
blob: 0091296bf5c6f6f0b16f3e10458e5af150126aed (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
38
39
40
41
42


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

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

use crate::resources::{
	Ground,
	Players
};


pub struct RegisterNew;
impl <'a> System<'a> for RegisterNew {
	type SystemData = (
		Entities<'a>,
		ReadStorage<'a, New>,
		Write<'a, Ground>,
		ReadStorage<'a, Position>,
		Write<'a, Players>,
		ReadStorage<'a, Player>
	);
	fn run(&mut self, (entities, new, mut ground, positions, mut player_list, players): Self::SystemData) {
		for (ent, pos, _new) in (&entities, &positions, &new).join() {
			ground.insert(pos.pos, ent);
		}
		for (ent, player, _new) in (&entities, &players, &new).join(){
			player_list.entities.insert(player.id.clone(), ent);
		}
	}
}