From 881dfce05e07ac55d973988da08fc1670e1cd5ea Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Sat, 8 Nov 2025 17:25:14 -0500 Subject: dungeon: refactor astar to not be generic --- dungeon/src/map.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'dungeon/src/map.rs') 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 { + 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 { -- cgit v1.2.3-freya