wolfrpg_map_parser/command/set_variable_plus_command/
other.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
use crate::byte_utils::as_u32_le;
use crate::command::set_variable_plus_command::target::Target;
#[cfg(feature = "serde")]
use serde::Serialize;

#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Other {
    target: Target
}

impl Other {
    pub fn parse(bytes: &[u8]) -> (usize, Self) {
        let mut offset: usize = 0;

        offset += 2;

        let target: u32 = as_u32_le(&bytes[offset..offset + 4]);
        let target: Target = Target::new(target);
        offset += 4;

        (offset, Self {
            target
        })
    }

    pub fn target(&self) -> &Target {
        &self.target
    }

    pub fn target_mut(&mut self) -> &mut Target {
        &mut self.target
    }
}