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
|
use specs::{
ReadStorage,
System,
Join,
Write,
Entities
};
use crate::components::{Removed, Position};
use crate::resources::Ground;
pub struct Remove;
impl <'a> System<'a> for Remove {
type SystemData = (
Entities<'a>,
ReadStorage<'a, Removed>,
ReadStorage<'a, Position>,
Write<'a, Ground>
);
fn run(&mut self, (entities, removals, positions, mut ground): Self::SystemData) {
for (ent, _) in (&*entities, &removals, ).join() {
if let Err(err) = entities.delete(ent){
println!("error deleting entity: {:?}", err);
}
if let Some(position) = positions.get(ent) {
ground.remove(&position.pos, ent);
}
}
}
}
|