item module init, base weapon structs
This commit is contained in:
parent
93d98a3517
commit
e0e0ad8ec7
30
src/item/mod.rs
Normal file
30
src/item/mod.rs
Normal file
@ -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(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
138
src/item/weapon.rs
Normal file
138
src/item/weapon.rs
Normal file
@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}*/
|
@ -6,6 +6,7 @@ pub mod crypto;
|
|||||||
pub mod packet;
|
pub mod packet;
|
||||||
pub mod character;
|
pub mod character;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
pub mod item;
|
||||||
|
|
||||||
use std::io::{Read, Seek};
|
use std::io::{Read, Seek};
|
||||||
#[derive(Debug, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user