wolfrpg_map_parser/command/chip_management_command/
map_chip_settings.rs

1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::byte_utils::as_u32_le;
4use crate::command::chip_management_command::options::Options;
5
6#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
7#[derive(PartialEq, Clone)]
8pub struct MapChipSettings {
9    chip: u32,
10    options: Options
11}
12
13impl MapChipSettings {
14    pub(crate) fn parse(bytes: &[u8]) -> (usize, Self) {
15        let mut offset: usize = 0;
16
17        let chip: u32 = as_u32_le(&bytes[offset..offset + 4]);
18        offset += 4;
19
20        let options: u32 = as_u32_le(&bytes[offset..offset + 4]);
21        let options: Options = Options::new(options);
22        offset += 4;
23
24        offset += 3; // Offset
25
26        (offset, Self {
27            chip,
28            options
29        })
30    }
31
32    pub fn chip(&self) -> u32 {
33        self.chip
34    }
35    
36    pub fn chip_mut(&mut self) -> &mut Options {
37        &mut self.options
38    }
39
40    pub fn options(&self) -> &Options {
41        &self.options
42    }
43    
44    pub fn options_mut(&mut self) -> &mut Options {
45        &mut self.options
46    }
47}