diff options
Diffstat (limited to 'dungeon')
| -rw-r--r-- | dungeon/src/map.rs | 8 |
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 |