diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-11-08 17:25:14 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-11-08 17:25:45 -0500 |
| commit | 881dfce05e07ac55d973988da08fc1670e1cd5ea (patch) | |
| tree | 0f972d7e46c92f6496e90db27f231d4e3f3b18f1 /dungeon/src/map.rs | |
| parent | graphics: refactor debug ui (diff) | |
| download | DungeonCrawl-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.rs | 7 |
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 { |