wolfrpg_map_parser/command/chip_management_command/
overwrite_map_chips.rs1#[cfg(feature = "serde")]
2use serde::{Serialize, Deserialize};
3use crate::byte_utils::as_u32_le;
4
5#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
6#[derive(PartialEq, Clone)]
7pub struct OverwriteMapChips{
8 layer: u32,
9 position_x: u32,
10 position_y: u32,
11 width: u32,
12 height: u32,
13 chip: u32
14}
15
16impl OverwriteMapChips{
17 pub(crate) fn parse(bytes: &[u8]) -> (usize, Self) {
18 let mut offset: usize = 0;
19
20 let layer: u32 = as_u32_le(&bytes[offset..offset+4]);
21 offset += 4;
22
23 let position_x: u32 = as_u32_le(&bytes[offset..offset+4]);
24 offset += 4;
25
26 let position_y: u32 = as_u32_le(&bytes[offset..offset+4]);
27 offset += 4;
28
29 let width: u32 = as_u32_le(&bytes[offset..offset+4]);
30 offset += 4;
31
32 let height: u32 = as_u32_le(&bytes[offset..offset+4]);
33 offset += 4;
34
35 let chip: u32 = as_u32_le(&bytes[offset..offset+4]);
36 offset += 4;
37
38 offset += 3; (offset, Self {
41 layer,
42 position_x,
43 position_y,
44 width,
45 height,
46 chip
47 })
48 }
49
50 pub fn layer(&self) -> u32 {
51 self.layer
52 }
53
54 pub fn layer_mut(&mut self) -> &mut u32 {
55 &mut self.layer
56 }
57
58 pub fn position_x(&self) -> u32 {
59 self.position_x
60 }
61
62 pub fn position_x_mut(&mut self) -> &mut u32 {
63 &mut self.position_x
64 }
65
66 pub fn position_y(&self) -> u32 {
67 self.position_y
68 }
69
70 pub fn position_y_mut(&mut self) -> &mut u32 {
71 &mut self.position_y
72 }
73
74 pub fn width(&self) -> u32 {
75 self.width
76 }
77
78 pub fn width_mut(&mut self) -> &mut u32 {
79 &mut self.width
80 }
81
82 pub fn height(&self) -> u32 {
83 self.height
84 }
85
86 pub fn height_mut(&mut self) -> &mut u32 {
87 &mut self.height
88 }
89
90 pub fn chip(&self) -> u32 {
91 self.chip
92 }
93
94 pub fn chip_mut(&mut self) -> &mut u32 {
95 &mut self.chip
96 }
97}