wolfrpg_map_parser/command/set_variable_plus_command/
position.rs#[cfg(feature = "serde")]
use serde::Serialize;
use crate::byte_utils::as_u32_le;
#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct Position {
target: u8,
position_x: u32,
position_y: u32
}
impl Position {
pub fn parse(bytes: &[u8]) -> (usize, Self) {
let mut offset: usize = 0;
let target: u8 = bytes[offset];
offset += 1;
offset += 1; let position_x: u32 = as_u32_le(&bytes[offset..offset+4]);
offset += 4;
let position_y: u32 = as_u32_le(&bytes[offset..offset+4]);
offset += 4;
(offset, Self {
target,
position_x,
position_y,
})
}
pub fn target(&self) -> u8 {
self.target
}
pub fn target_mut(&mut self) -> &mut u8 {
&mut self.target
}
pub fn position_x(&self) -> u32 {
self.position_x
}
pub fn position_x_mut(&mut self) -> &mut u32 {
&mut self.position_x
}
pub fn position_y(&self) -> u32 {
self.position_y
}
pub fn position_y_mut(&mut self) -> &mut u32 {
&mut self.position_y
}
}