diff options
author | Guillaume Pasquet <dev@etenil.net> | 2020-01-02 17:28:15 +0000 |
---|---|---|
committer | Guillaume Pasquet <dev@etenil.net> | 2020-03-14 16:52:06 +0000 |
commit | 219e32ad793e66a3111465ef02f3eb677f70277d (patch) | |
tree | ffbfc495906fdb447074c1c1e3e4996432f83a14 /src/entities.rs | |
parent | 9848a92fde2891177cc352064ae9e4ec1098277f (diff) |
Fix for invisible enemies
- Don't double-count visibility
- Set enemies visibility with LOS
- Set dirty flag when enemies are revealed
Diffstat (limited to 'src/entities.rs')
-rw-r--r-- | src/entities.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/entities.rs b/src/entities.rs index 78e5ab9..98c8443 100644 --- a/src/entities.rs +++ b/src/entities.rs @@ -41,7 +41,6 @@ pub struct Character { luck: i32,
xp: i32,
tile: Tile,
- visible: bool,
}
pub trait Enemy {
@@ -114,11 +113,14 @@ impl Entity for Character { }
fn visibility(&mut self, visible: bool) {
- self.visible = visible;
+ if visible != self.is_visible() {
+ self.dirty = true;
+ }
+ self.tile.visibility(visible)
}
fn is_visible(&self) -> bool {
- self.visible
+ self.tile.is_visible()
}
}
@@ -146,7 +148,6 @@ impl Enemy for Character { previous_location: location,
tile: Tile::from(TileType::Character(tile_str)),
dirty: false,
- visible: false,
}
}
@@ -182,7 +183,6 @@ impl Player for Character { false,
),
dirty: false,
- visible: true,
}
}
|