wolfrpg_map_parser/command/set_variable_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    real_number_calculation: bool,
9    left_not_variable: bool,
10    right_not_variable: bool,
11    use_variable_as_reference: bool,
12    use_left_as_reference: bool,
13    use_right_as_reference: bool,
14}
15
16impl Options {
17    pub fn new(options: u8) -> Self {
18        Self {
19            bind_result:                options & 0b00000001 != 0,
20            real_number_calculation:    options & 0b00000010 != 0,
21            left_not_variable:          options & 0b00000100 != 0,
22            right_not_variable:         options & 0b00001000 != 0,
23            use_variable_as_reference:  options & 0b00010000 != 0,
24            use_left_as_reference:      options & 0b00100000 != 0,
25            use_right_as_reference:     options & 0b01000000 != 0,
26        }
27    }
28
29    pub fn bind_result(&self) -> bool {
30        self.bind_result
31    }
32
33    pub fn bind_result_mut(&mut self) -> &mut bool {
34        &mut self.bind_result
35    }
36
37    pub fn real_number_calculation(&self) -> bool {
38        self.real_number_calculation
39    }
40
41    pub fn real_number_calculation_mut(&mut self) -> &mut bool {
42        &mut self.real_number_calculation
43    }
44
45    pub fn left_not_variable(&self) -> bool {
46        self.left_not_variable
47    }
48
49    pub fn left_not_variable_mut(&mut self) -> &mut bool {
50        &mut self.left_not_variable
51    }
52
53    pub fn right_not_variable(&self) -> bool {
54        self.right_not_variable
55    }
56
57    pub fn right_not_variable_mut(&mut self) -> &mut bool {
58        &mut self.right_not_variable
59    }
60
61    pub fn use_variable_as_reference(&self) -> bool {
62        self.use_variable_as_reference
63    }
64
65    pub fn use_variable_as_reference_mut(&mut self) -> &mut bool {
66        &mut self.use_variable_as_reference
67    }
68
69    pub fn use_left_as_reference(&self) -> bool {
70        self.use_left_as_reference
71    }
72
73    pub fn use_left_as_reference_mut(&mut self) -> &mut bool {
74        &mut self.use_left_as_reference
75    }
76
77    pub fn use_right_as_reference(&self) -> bool {
78        self.use_right_as_reference
79    }
80
81    pub fn use_right_as_reference_mut(&mut self) -> &mut bool {
82        &mut self.use_right_as_reference
83    }
84}