From fee2caa10522d2a473b5d78e6e735b25a6b9280a Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sun, 9 Nov 2025 20:14:31 -0500 Subject: dungeon: fix astar neighbor generation --- dungeon/src/map.rs | 8 ++++++-- 1 file 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 { - 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 -- cgit v1.2.3-freya