summaryrefslogtreecommitdiff
path: root/dungeon/src/map.rs
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-11-08 17:25:14 -0500
committerFreya Murphy <freya@freyacat.org>2025-11-08 17:25:45 -0500
commit881dfce05e07ac55d973988da08fc1670e1cd5ea (patch)
tree0f972d7e46c92f6496e90db27f231d4e3f3b18f1 /dungeon/src/map.rs
parentgraphics: refactor debug ui (diff)
downloadDungeonCrawl-881dfce05e07ac55d973988da08fc1670e1cd5ea.tar.gz
DungeonCrawl-881dfce05e07ac55d973988da08fc1670e1cd5ea.tar.bz2
DungeonCrawl-881dfce05e07ac55d973988da08fc1670e1cd5ea.zip
dungeon: refactor astar to not be generic
Diffstat (limited to 'dungeon/src/map.rs')
-rw-r--r--dungeon/src/map.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/dungeon/src/map.rs b/dungeon/src/map.rs
index 6daa3c7..eda467c 100644
--- a/dungeon/src/map.rs
+++ b/dungeon/src/map.rs
@@ -162,6 +162,13 @@ impl Floor {
&mut *self.tiles
}
+ /// 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)
+ }
+
/// Computes the hash of the tile map
#[must_use]
pub fn hash(&self) -> u64 {