wolfrpg_map_parser/db_parser/models/
tile.rs1#[cfg(feature = "serde")]
2use serde::{Deserialize, Serialize};
3
4#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6#[derive(PartialEq, Clone)]
7pub struct Tile {
8 tag_number: u8,
9 down_not_passable: bool,
10 left_not_passable: bool,
11 right_not_passable: bool,
12 up_not_passable: bool,
13 always_above_character: bool,
14 bottom_half_translucent: bool,
15 conceal_character_behind: bool,
16 match_passable_under: bool
17}
18
19impl Tile {
20 pub fn new(tag_number: u8, options: u32) -> Self {
21 Self {
22 tag_number,
23 down_not_passable: options & 0b00000001 != 0,
24 left_not_passable: options & 0b00000010 != 0,
25 right_not_passable: options & 0b00000100 != 0,
26 up_not_passable: options & 0b00001000 != 0,
27 always_above_character: options & 0b00010000 != 0,
28
29 bottom_half_translucent: options & 0b01000000 != 0,
30
31 conceal_character_behind: (options >> 8) & 0b00000001 != 0,
32 match_passable_under: (options >> 8) & 0b00000010 != 0
33 }
34 }
35
36 pub fn tag_number(&self) -> u8 {
40 self.tag_number
41 }
42
43 pub fn tag_number_mut(&mut self) -> &mut u8 {
45 &mut self.tag_number
46 }
47
48 pub fn down_not_passable(&self) -> bool {
50 self.down_not_passable
51 }
52
53 pub fn down_not_passable_mut(&mut self) -> &mut bool {
55 &mut self.down_not_passable
56 }
57
58 pub fn left_not_passable(&self) -> bool {
60 self.left_not_passable
61 }
62
63 pub fn left_not_passable_mut(&mut self) -> &mut bool {
65 &mut self.left_not_passable
66 }
67
68 pub fn right_not_passable(&self) -> bool {
70 self.right_not_passable
71 }
72
73 pub fn right_not_passable_mut(&mut self) -> &mut bool {
75 &mut self.right_not_passable
76 }
77
78 pub fn up_not_passable(&self) -> bool {
80 self.up_not_passable
81 }
82
83 pub fn up_not_passable_mut(&mut self) -> &mut bool {
85 &mut self.up_not_passable
86 }
87
88 pub fn always_above_character(&self) -> bool {
90 self.always_above_character
91 }
92
93 pub fn always_above_character_mut(&mut self) -> &mut bool {
95 &mut self.always_above_character
96 }
97
98 pub fn bottom_half_translucent(&self) -> bool {
100 self.bottom_half_translucent
101 }
102
103 pub fn bottom_half_translucent_mut(&mut self) -> &mut bool {
105 &mut self.bottom_half_translucent
106 }
107
108 pub fn conceal_character_behind(&self) -> bool {
110 self.conceal_character_behind
111 }
112
113 pub fn conceal_character_behind_mut(&mut self) -> &mut bool {
115 &mut self.conceal_character_behind
116 }
117
118 pub fn match_passable_under(&self) -> bool {
120 self.match_passable_under
121 }
122
123 pub fn match_passable_under_mut(&mut self) -> &mut bool {
125 &mut self.match_passable_under
126 }
127}