wolfrpg_map_parser/command/set_variable_plus_command/
options.rs

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
#[cfg(feature = "serde")]
use serde::{Serialize, Deserialize};

#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(PartialEq)]
pub struct Options {
    bind_result: bool,
    use_variable_as_reference: bool,
    precise_position: bool
}

impl Options {
    pub fn new(options: u8) -> Self {
        Options {
            bind_result:                options & 0b00000001 != 0,
            use_variable_as_reference:  options & 0b00010000 != 0,
            precise_position:           options & 0b00100000 != 0,
        }
    }

    pub fn bind_result(&self) -> bool {
        self.bind_result
    }

    pub fn bind_result_mut(&mut self) -> &mut bool {
        &mut self.bind_result
    }

    pub fn use_variable_as_reference(&self) -> bool {
        self.use_variable_as_reference
    }

    pub fn use_variable_as_reference_mut(&mut self) -> &mut bool {
        &mut self.use_variable_as_reference
    }

    pub fn precise_position(&self) -> bool {
        self.precise_position
    }

    pub fn precise_position_mut(&mut self) -> &mut bool {
        &mut self.precise_position
    }
}