|
@ -1,25 +1,37 @@ |
|
|
#![allow(dead_code)]
|
|
|
|
|
|
pub mod weapon;
|
|
|
pub mod weapon;
|
|
|
pub mod tool;
|
|
|
|
|
|
pub mod armor;
|
|
|
|
|
|
pub mod shield;
|
|
|
|
|
|
|
|
|
|
|
|
use std::io::{Read, Seek};
|
|
|
|
|
|
use crate::{PacketParseError};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//pub mod tool;
|
|
|
|
|
|
//pub mod armor;
|
|
|
|
|
|
//pub mod shield;
|
|
|
|
|
|
|
|
|
|
|
|
//use std::io::{Read, Seek};
|
|
|
|
|
|
//use crate::{PacketParseError};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub trait ItemBytes {
|
|
|
|
|
|
fn as_bytes(&self) -> [u8; 16] {
|
|
|
|
|
|
// this is one of those things that should be easier than it is
|
|
|
|
|
|
let mut result = [0; 16];
|
|
|
|
|
|
let (left, right) = result.split_at_mut(12);
|
|
|
|
|
|
left.copy_from_slice(&self.as_bytes_upper());
|
|
|
|
|
|
right.copy_from_slice(&self.as_bytes_lower());
|
|
|
|
|
|
result
|
|
|
|
|
|
}
|
|
|
|
|
|
fn as_bytes_upper(&self) -> [u8; 12];
|
|
|
|
|
|
fn as_bytes_lower(&self) -> [u8; 4];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
pub enum Item {
|
|
|
pub enum Item {
|
|
|
Weapon(weapon::Weapon),
|
|
|
Weapon(weapon::Weapon),
|
|
|
Armor(armor::Armor),
|
|
|
|
|
|
Shield(shield::Shield),
|
|
|
|
|
|
|
|
|
//Armor(armor::Armor),
|
|
|
|
|
|
//Shield(shield::Shield),
|
|
|
//Unit(Unit),
|
|
|
//Unit(Unit),
|
|
|
//Mag(Mag),
|
|
|
//Mag(Mag),
|
|
|
Tool(tool::Tool),
|
|
|
|
|
|
|
|
|
//Tool(tool::Tool),
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
impl Item {
|
|
|
impl Item {
|
|
|
fn from_bytes<R: Read + Seek>(_cursor: &mut R) -> Result<Self, PacketParseError> {
|
|
|
fn from_bytes<R: Read + Seek>(_cursor: &mut R) -> Result<Self, PacketParseError> {
|
|
|
unimplemented!()
|
|
|
unimplemented!()
|
|
@ -27,9 +39,9 @@ impl Item { |
|
|
pub fn as_bytes(&self) -> [u8; 16] {
|
|
|
pub fn as_bytes(&self) -> [u8; 16] {
|
|
|
match self {
|
|
|
match self {
|
|
|
Item::Weapon(wep) => wep.as_bytes(),
|
|
|
Item::Weapon(wep) => wep.as_bytes(),
|
|
|
Item::Armor(armor) => armor.as_bytes(),
|
|
|
|
|
|
Item::Shield(shield) => shield.as_bytes(),
|
|
|
|
|
|
Item::Tool(tool) => tool.as_bytes(),
|
|
|
|
|
|
|
|
|
//Item::Armor(armor) => armor.as_bytes(),
|
|
|
|
|
|
//Item::Shield(shield) => shield.as_bytes(),
|
|
|
|
|
|
//Item::Tool(tool) => tool.as_bytes(),
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
@ -41,3 +53,4 @@ impl Item { |
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
*/
|