libpso/src/item/mod.rs

57 lines
1.3 KiB
Rust
Raw Normal View History

2019-12-11 15:59:30 -08:00
pub mod weapon;
2023-11-19 17:30:03 -07:00
//pub mod tool;
//pub mod armor;
//pub mod shield;
2019-12-11 15:59:30 -08:00
2023-11-19 17:30:03 -07:00
//use std::io::{Read, Seek};
//use crate::{PacketParseError};
2019-12-11 15:59:30 -08:00
2023-11-19 17:30:03 -07:00
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];
}
2019-12-11 15:59:30 -08:00
#[derive(Debug, Copy, Clone)]
pub enum Item {
Weapon(weapon::Weapon),
2023-11-19 17:30:03 -07:00
//Armor(armor::Armor),
//Shield(shield::Shield),
2019-12-11 15:59:30 -08:00
//Unit(Unit),
//Mag(Mag),
2023-11-19 17:30:03 -07:00
//Tool(tool::Tool),
2019-12-11 15:59:30 -08:00
}
2023-11-19 17:30:03 -07:00
/*
2019-12-11 15:59:30 -08:00
impl Item {
fn from_bytes<R: Read + Seek>(_cursor: &mut R) -> Result<Self, PacketParseError> {
2019-12-11 15:59:30 -08:00
unimplemented!()
}
pub fn as_bytes(&self) -> [u8; 16] {
match self {
Item::Weapon(wep) => wep.as_bytes(),
2023-11-19 17:30:03 -07:00
//Item::Armor(armor) => armor.as_bytes(),
//Item::Shield(shield) => shield.as_bytes(),
//Item::Tool(tool) => tool.as_bytes(),
2019-12-11 15:59:30 -08:00
}
}
2020-01-18 21:38:51 -08:00
pub fn is_stackable(&self) -> bool {
match self {
Item::Tool(_) => true,
_ => false,
}
}
2019-12-11 15:59:30 -08:00
}
2023-11-19 17:30:03 -07:00
*/