wolfrpg_map_parser/command/event_control_command/move_route/
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 {
    repeat_actions: bool,
    skip_impossible_moves: bool,
    wait_until_done: bool,
}

impl Options {
    pub const fn new(options: u8) -> Self {
        Self {
            repeat_actions:         options & 0b00000001 != 0,
            skip_impossible_moves:  options & 0b00000010 != 0,
            wait_until_done:        options & 0b00000100 != 0,
        }
    }

    pub fn repeat_actions(&self) -> bool {
        self.repeat_actions
    }
    
    pub fn repeat_actions_mut(&mut self) -> &mut bool {
        &mut self.repeat_actions
    }

    pub fn skip_impossible_moves(&self) -> bool {
        self.skip_impossible_moves
    }
    
    pub fn skip_impossible_moves_mut(&mut self) -> &mut bool {
        &mut self.skip_impossible_moves
    }

    pub fn wait_until_done(&self) -> bool {
        self.wait_until_done
    }
    
    pub fn wait_until_done_mut(&mut self) -> &mut bool {
        &mut self.wait_until_done
    }
}