summaryrefslogtreecommitdiff
path: root/src/systems/remove.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-02-09 00:38:00 +0100
committertroido <troido@protonmail.com>2020-02-09 00:38:00 +0100
commit624b3a94b498d7410049d2227568534c118a9f7d (patch)
treee8ef65c48e332a8f1c90d97c6aa346baffece394 /src/systems/remove.rs
parentb56add981c2f520789b97d1ee6f71dae41e8c900 (diff)
ground is now always up-to-date; view doesn't rebuild whole room
Diffstat (limited to 'src/systems/remove.rs')
-rw-r--r--src/systems/remove.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/systems/remove.rs b/src/systems/remove.rs
index 2c531e2..b73a2fb 100644
--- a/src/systems/remove.rs
+++ b/src/systems/remove.rs
@@ -3,25 +3,31 @@ use specs::{
ReadStorage,
System,
Join,
+ Write,
Entities
};
-use crate::components::{Removed};
-
+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, Removed>,
+ ReadStorage<'a, Position>,
+ Write<'a, Ground>
);
- fn run(&mut self, (entities, removals): Self::SystemData) {
- for (ent, _) in (&*entities, &removals).join() {
+ fn run(&mut self, (entities, removals, positions, mut ground): Self::SystemData) {
+ for (ent, _) in (&*entities, &removals, ).join() {
if let Err(msg) = entities.delete(ent){
println!("{:?}", msg);
}
+ if let Some(position) = positions.get(ent) {
+ ground.cells.get_mut(&position.pos).unwrap().remove(&ent);
+ }
}
}
}