wolfrpg_map_parser/command/set_variable_plus_command/
options.rs

1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3
4#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
5#[derive(PartialEq, Clone)]
6pub struct Options {
7    bind_result: bool,
8    use_variable_as_reference: bool,
9    precise_position: bool
10}
11
12impl Options {
13    pub fn new(options: u8) -> Self {
14        Options {
15            bind_result:                options & 0b00000001 != 0,
16            use_variable_as_reference:  options & 0b00010000 != 0,
17            precise_position:           options & 0b00100000 != 0,
18        }
19    }
20
21    pub fn bind_result(&self) -> bool {
22        self.bind_result
23    }
24
25    pub fn bind_result_mut(&mut self) -> &mut bool {
26        &mut self.bind_result
27    }
28
29    pub fn use_variable_as_reference(&self) -> bool {
30        self.use_variable_as_reference
31    }
32
33    pub fn use_variable_as_reference_mut(&mut self) -> &mut bool {
34        &mut self.use_variable_as_reference
35    }
36
37    pub fn precise_position(&self) -> bool {
38        self.precise_position
39    }
40
41    pub fn precise_position_mut(&mut self) -> &mut bool {
42        &mut self.precise_position
43    }
44}