/
is_tile_walkable_npc.rs
44 lines (40 loc) · 1.63 KB
/
is_tile_walkable_npc.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use eo::{protocol::Coords, pubs::EmfTileSpec};
use super::Map;
impl Map {
pub fn is_tile_walkable_npc(&self, coords: &Coords) -> bool {
if let Some(row) = self.file.warp_rows.iter().find(|row| row.y == coords.y) {
if row.tiles.iter().any(|warp| warp.x == coords.x) {
return false;
}
}
if let Some(row) = self.file.spec_rows.iter().find(|row| row.y == coords.y) {
if let Some(tile) = row.tiles.iter().find(|tile| tile.x == coords.x) {
return !matches!(
tile.spec,
EmfTileSpec::NPCBoundary
| EmfTileSpec::Wall
| EmfTileSpec::ChairDown
| EmfTileSpec::ChairLeft
| EmfTileSpec::ChairRight
| EmfTileSpec::ChairUp
| EmfTileSpec::ChairDownRight
| EmfTileSpec::ChairUpLeft
| EmfTileSpec::ChairAll
| EmfTileSpec::Chest
| EmfTileSpec::BankVault
| EmfTileSpec::MapEdge
| EmfTileSpec::Board1
| EmfTileSpec::Board2
| EmfTileSpec::Board3
| EmfTileSpec::Board4
| EmfTileSpec::Board5
| EmfTileSpec::Board6
| EmfTileSpec::Board7
| EmfTileSpec::Board8
| EmfTileSpec::Jukebox
);
}
}
!self.is_tile_occupied(coords)
}
}