wolfrpg_map_parser/command/transfer_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
#[cfg(feature = "serde")]
use serde::Serialize;
use crate::command::transfer_command::transition::Transition;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Options {
    precise_coordinates: bool,
    transition: Transition,
}

impl Options {
    pub fn new(options: u32) -> Self {
        Self {
            precise_coordinates: options & 0b00000001 != 0,
            transition: Transition::new(((options >> 4) & 0x0f) as u8),
        }
    }

    pub fn precise_coordinates(&self) -> bool {
        self.precise_coordinates
    }
    
    pub fn precise_coordinates_mut(&mut self) -> &mut bool {
        &mut self.precise_coordinates
    }

    pub fn transition(&self) -> &Transition {
        &self.transition
    }
    
    pub fn transition_mut(&mut self) -> &mut Transition {
        &mut self.transition
    }
}