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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
/// Settings for a specific tile in a given tileset.
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq, Clone)]
pub struct Tile {
tag_number: u8,
down_not_passable: bool,
left_not_passable: bool,
right_not_passable: bool,
up_not_passable: bool,
always_above_character: bool,
bottom_half_translucent: bool,
conceal_character_behind: bool,
match_passable_under: bool
}
impl Tile {
pub fn new(tag_number: u8, options: u32) -> Self {
Self {
tag_number,
down_not_passable: options & 0b00000001 != 0,
left_not_passable: options & 0b00000010 != 0,
right_not_passable: options & 0b00000100 != 0,
up_not_passable: options & 0b00001000 != 0,
always_above_character: options & 0b00010000 != 0,
bottom_half_translucent: options & 0b01000000 != 0,
conceal_character_behind: (options >> 8) & 0b00000001 != 0,
match_passable_under: (options >> 8) & 0b00000010 != 0
}
}
/// A value that can be assigned to tiles and retrieved via the [`SetVariablePlus`] command.
///
/// [`SetVariablePlus`]: crate::command::set_variable_plus_command::SetVariablePlusCommand
pub fn tag_number(&self) -> u8 {
self.tag_number
}
/// Mutable reference accessor for [`Tile::tag_number`].
pub fn tag_number_mut(&mut self) -> &mut u8 {
&mut self.tag_number
}
/// Whether the tile can be passed from its downside.
pub fn down_not_passable(&self) -> bool {
self.down_not_passable
}
/// Mutable reference accessor for [`Tile::down_not_passable`].
pub fn down_not_passable_mut(&mut self) -> &mut bool {
&mut self.down_not_passable
}
/// Whether the tile can be passed from its left side.
pub fn left_not_passable(&self) -> bool {
self.left_not_passable
}
/// Mutable reference accessor for [`Tile::left_not_passable`].
pub fn left_not_passable_mut(&mut self) -> &mut bool {
&mut self.left_not_passable
}
/// Whether the tile can be passed from its right side.
pub fn right_not_passable(&self) -> bool {
self.right_not_passable
}
/// Mutable reference accessor for [`Tile::right_not_passable`].
pub fn right_not_passable_mut(&mut self) -> &mut bool {
&mut self.right_not_passable
}
/// Whether the tile can be passed from its upside.
pub fn up_not_passable(&self) -> bool {
self.up_not_passable
}
/// Mutable reference accessor for [`Tile::up_not_passable`].
pub fn up_not_passable_mut(&mut self) -> &mut bool {
&mut self.up_not_passable
}
/// If true, this tile will always be displayed above a character.
pub fn always_above_character(&self) -> bool {
self.always_above_character
}
/// Mutable reference accessor for [`Tile::always_above_character`].
pub fn always_above_character_mut(&mut self) -> &mut bool {
&mut self.always_above_character
}
/// If true, the bottom half of this tile will be translucent.
pub fn bottom_half_translucent(&self) -> bool {
self.bottom_half_translucent
}
/// Mutable reference accessor for [`Tile::bottom_half_translucent`].
pub fn bottom_half_translucent_mut(&mut self) -> &mut bool {
&mut self.bottom_half_translucent
}
/// If true, this tile will be displayed above characters with a smaller or equal y position.
pub fn conceal_character_behind(&self) -> bool {
self.conceal_character_behind
}
/// Mutable reference accessor for [`Tile::conceal_character_behind`].
pub fn conceal_character_behind_mut(&mut self) -> &mut bool {
&mut self.conceal_character_behind
}
/// If true, whether this tile is passable or not depends on the tile on the lower layer.
pub fn match_passable_under(&self) -> bool {
self.match_passable_under
}
/// Mutable reference accessor for [`Tile::match_passable_under`].
pub fn match_passable_under_mut(&mut self) -> &mut bool {
&mut self.match_passable_under
}
}