wolfrpg_map_parser/command/chip_management_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    no_down: bool,
8    no_left: bool,
9    no_right: bool,
10    no_up: bool,
11    above_hero: bool,
12    half_transparent: bool,
13    counter: bool,
14    match_lower_layer: bool,
15}
16
17impl Options {
18    pub fn new(options: u32) -> Self {
19        Self {
20            no_down:            options & 0b00000001 != 0,
21            no_left:            options & 0b00000010 != 0,
22            no_right:           options & 0b00000100 != 0,
23            no_up:              options & 0b00001000 != 0,
24            above_hero:         options & 0b00010000 != 0,
25            half_transparent:   options & 0b01000000 != 0,
26            counter:            options & 0b10000000 != 0,
27
28            match_lower_layer:  (options >> 8) & 0b00000010 != 0,
29        }
30    }
31
32    pub fn no_down(&self) -> bool {
33        self.no_down
34    }
35    
36    pub fn no_down_mut(&mut self) -> &mut bool {
37        &mut self.no_down
38    }
39
40    pub fn no_left(&self) -> bool {
41        self.no_left
42    }
43    
44    pub fn no_left_mut(&mut self) -> &mut bool {
45        &mut self.no_left
46    }
47
48    pub fn no_right(&self) -> bool {
49        self.no_right
50    }
51    
52    pub fn no_right_mut(&mut self) -> &mut bool {
53        &mut self.no_right
54    }
55
56    pub fn no_up(&self) -> bool {
57        self.no_up
58    }
59    
60    pub fn no_up_mut(&mut self) -> &mut bool {
61        &mut self.no_up
62    }
63
64    pub fn above_hero(&self) -> bool {
65        self.above_hero
66    }
67    
68    pub fn above_hero_mut(&mut self) -> &mut bool {
69        &mut self.above_hero
70    }
71
72    pub fn half_transparent(&self) -> bool {
73        self.half_transparent
74    }
75    
76    pub fn half_transparent_mut(&mut self) -> &mut bool {
77        &mut self.half_transparent
78    }
79
80    pub fn counter(&self) -> bool {
81        self.counter
82    }
83    
84    pub fn counter_mut(&mut self) -> &mut bool {
85        &mut self.counter
86    }
87
88    pub fn match_lower_layer(&self) -> bool {
89        self.match_lower_layer
90    }
91    
92    pub fn match_lower_layer_mut(&mut self) -> &mut bool {
93        &mut self.match_lower_layer
94    }
95}