summaryrefslogtreecommitdiff
path: root/dungeon
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-11-09 20:14:31 -0500
committerFreya Murphy <freya@freyacat.org>2025-11-09 20:14:31 -0500
commitfee2caa10522d2a473b5d78e6e735b25a6b9280a (patch)
tree4907a67c67f2d1bd703a92d313ba7023942b7833 /dungeon
parentgraphics: refactor string formatting to use single common scratch buffer (diff)
downloadDungeonCrawl-fee2caa10522d2a473b5d78e6e735b25a6b9280a.tar.gz
DungeonCrawl-fee2caa10522d2a473b5d78e6e735b25a6b9280a.tar.bz2
DungeonCrawl-fee2caa10522d2a473b5d78e6e735b25a6b9280a.zip
dungeon: fix astar neighbor generation
Diffstat (limited to 'dungeon')
-rw-r--r--dungeon/src/map.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/dungeon/src/map.rs b/dungeon/src/map.rs
index eda467c..c204cac 100644
--- a/dungeon/src/map.rs
+++ b/dungeon/src/map.rs
@@ -43,6 +43,11 @@ impl Tile {
pub fn is_wall(self) -> bool {
self == Self::Wall
}
+
+ /// Returns if the tile is walkable
+ pub fn is_walkable(self) -> bool {
+ matches!(self, Self::Air)
+ }
}
impl Default for Tile {
fn default() -> Self {
@@ -165,8 +170,7 @@ impl Floor {
/// Returns the neighbors of a tile inside the floor, checking
/// that the neighbor positions are the same tile type as in `pos`.
pub fn neighbors(&self, pos: &Pos) -> impl Iterator<Item = Pos> {
- let tile = self.get(*pos);
- pos.neighbors().filter(move |p| self.get(*p) == tile)
+ pos.neighbors().filter(|p| self.get(*p).is_walkable())
}
/// Computes the hash of the tile map