summaryrefslogtreecommitdiff
path: root/src/systems/view.rs
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-02-23 23:58:55 +0100
committertroido <troido@protonmail.com>2020-02-23 23:58:55 +0100
commit4718cfdc7c2bf67d2389ca18ab035fe5a0887ff0 (patch)
tree83e645b930aa7434cb045ed58a5040bf3b16be93 /src/systems/view.rs
parent86cdc6c567d0ca429d69bebbb2fb02f1d3754c8d (diff)
don't draw removed entities
Diffstat (limited to 'src/systems/view.rs')
-rw-r--r--src/systems/view.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/systems/view.rs b/src/systems/view.rs
index 158a187..cff24fa 100644
--- a/src/systems/view.rs
+++ b/src/systems/view.rs
@@ -54,14 +54,14 @@ impl <'a> System<'a> for View {
let has_changed: bool = !changed.is_empty();
let mut changes: Vec<(Pos, Vec<Sprite>)> = Vec::new();
for pos in changed {
- changes.push((pos, cell_sprites(ground.components_on(pos, &visible))));
+ changes.push((pos, cell_sprites(ground.components_on(pos, &visible, &removed))));
}
output.output.clear();
for (ent, player, pos) in (&entities, &players, &positions).join() {
let mut updates = WorldMessage::default();
if new.get(ent).is_some() {
- let (values, mapping) = draw_room(&ground, (size.width, size.height), &visible);
+ let (values, mapping) = draw_room(&ground, (size.width, size.height), &visible, &removed);
let field = FieldMessage{
width: size.width,
height: size.height,
@@ -98,14 +98,14 @@ fn cell_sprites(mut visibles: Vec<&Visible>) -> Vec<Sprite> {
visibles.iter().map(|vis| vis.sprite.clone()).collect()
}
-fn draw_room(ground: &Read<Ground>, (width, height): (i64, i64), visible: &ReadStorage<Visible>) -> (Vec<usize>, Vec<Vec<Sprite>>){
+fn draw_room(ground: &Read<Ground>, (width, height): (i64, i64), visible: &ReadStorage<Visible>, removals: &ReadStorage<Removed>) -> (Vec<usize>, Vec<Vec<Sprite>>){
let size = width * height;
let mut values :Vec<usize> = Vec::with_capacity(size as usize);
let mut mapping: Vec<Vec<Sprite>> = Vec::new();
for y in 0..height {
for x in 0..width {
- let sprites: Vec<Sprite> = cell_sprites(ground.components_on(Pos{x, y}, visible));
+ let sprites: Vec<Sprite> = cell_sprites(ground.components_on(Pos{x, y}, visible, removals));
values.push(
match mapping.iter().position(|x| x == &sprites) {
Some(index) => {