jake
5 years ago
3 changed files with 169 additions and 0 deletions
-
30src/item/mod.rs
-
138src/item/weapon.rs
-
1src/lib.rs
@ -0,0 +1,30 @@ |
|||
pub mod weapon;
|
|||
|
|||
use std::io::{Read, Seek};
|
|||
use crate::{PSOPacketData, PacketParseError};
|
|||
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone)]
|
|||
pub enum Item {
|
|||
Weapon(weapon::Weapon),
|
|||
//Armor(Armor),
|
|||
//Shield(Shield),
|
|||
//Unit(Unit),
|
|||
//Mag(Mag),
|
|||
//Tool(Tool),
|
|||
}
|
|||
|
|||
|
|||
impl Item {
|
|||
fn from_bytes<R: Read + Seek>(cursor: &mut R) -> Result<Self, PacketParseError> {
|
|||
unimplemented!()
|
|||
}
|
|||
pub fn as_bytes(&self) -> [u8; 16] {
|
|||
match self {
|
|||
Item::Weapon(wep) => wep.as_bytes(),
|
|||
}
|
|||
}
|
|||
|
|||
|
|||
}
|
@ -0,0 +1,138 @@ |
|||
|
|||
use std::io::{Read, Seek};
|
|||
use crate::{PSOPacketData, PacketParseError};
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone)]
|
|||
pub enum Attribute {
|
|||
Native,
|
|||
ABeast,
|
|||
Machine,
|
|||
Dark,
|
|||
Hit
|
|||
}
|
|||
|
|||
#[derive(Debug, Copy, Clone)]
|
|||
pub struct WeaponAttribute {
|
|||
attr: Attribute,
|
|||
value: u8,
|
|||
}
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone)]
|
|||
pub enum WeaponSpecial {
|
|||
Draw,
|
|||
Drain,
|
|||
Fill,
|
|||
Gush,
|
|||
Heart,
|
|||
Mind,
|
|||
Soul,
|
|||
Geist,
|
|||
Masters,
|
|||
Lords,
|
|||
Kings,
|
|||
Charge,
|
|||
Spirit,
|
|||
Berserk,
|
|||
Ice,
|
|||
Frost,
|
|||
Freeze,
|
|||
Blizzard,
|
|||
Bind,
|
|||
Hold,
|
|||
Seize,
|
|||
Arrest,
|
|||
Heat,
|
|||
Fire,
|
|||
Flame,
|
|||
Burning,
|
|||
Shock,
|
|||
Thunder,
|
|||
Storm,
|
|||
Tempest,
|
|||
Dim,
|
|||
Shadow,
|
|||
Dark,
|
|||
Hell,
|
|||
Panic,
|
|||
Riot,
|
|||
Havoc,
|
|||
Chaos,
|
|||
Devils,
|
|||
Demons,
|
|||
}
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone)]
|
|||
pub enum WeaponType {
|
|||
Saber,
|
|||
Handgun,
|
|||
Cane,
|
|||
}
|
|||
|
|||
impl WeaponType {
|
|||
fn value(&self) -> [u8; 3] {
|
|||
match self {
|
|||
WeaponType::Saber => [0x00, 0x01, 0x00],
|
|||
WeaponType::Handgun => [0x00, 0x06, 0x00],
|
|||
WeaponType::Cane => [0x00, 0x0A, 0x00],
|
|||
}
|
|||
}
|
|||
}
|
|||
|
|||
|
|||
|
|||
#[derive(Debug, Copy, Clone)]
|
|||
pub struct Weapon {
|
|||
pub weapon: WeaponType,
|
|||
pub special: Option<WeaponSpecial>,
|
|||
pub grind: u8,
|
|||
pub attrs: [Option<WeaponAttribute>; 3],
|
|||
}
|
|||
|
|||
|
|||
impl Weapon {
|
|||
pub fn new(&self, wep: WeaponType) -> Weapon {
|
|||
Weapon {
|
|||
weapon: wep,
|
|||
special: None,
|
|||
grind: 0,
|
|||
attrs: [None; 3]
|
|||
}
|
|||
}
|
|||
|
|||
pub fn as_bytes(&self) -> [u8; 16] {
|
|||
let mut result = [0u8; 16];
|
|||
result[0..3].copy_from_slice(&self.weapon.value());
|
|||
result[3] = self.grind;
|
|||
//result.extend_from_slice(&self.weapon.value());
|
|||
//result.push(self.grind);
|
|||
|
|||
//result.extend_from_slice(&[0,0,0,0]);
|
|||
//result.extend_from_slice(&[0,0,0,0]);
|
|||
//result.extend_from_slice(&[0,0,0,0]);
|
|||
|
|||
result
|
|||
}
|
|||
}
|
|||
|
|||
|
|||
/*impl PSOPacketData for Weapon{
|
|||
fn from_bytes<R: Read + Seek>(cursor: &mut R) -> Result<Self, PacketParseError> {
|
|||
unimplemented!()
|
|||
}
|
|||
fn as_bytes(&self) -> Vec<u8> {
|
|||
let mut result = Vec::new();
|
|||
result.extend_from_slice(&self.weapon.value());
|
|||
result.push(self.grind);
|
|||
|
|||
result.extend_from_slice(&[0,0,0,0]);
|
|||
result.extend_from_slice(&[0,0,0,0]);
|
|||
result.extend_from_slice(&[0,0,0,0]);
|
|||
|
|||
result
|
|||
}
|
|||
|
|||
|
|||
}*/
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue