1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use std::io::Result as Res;
use endio::Serialize;
use endio_bit::BEBitWriter;
use lu_packets_derive::{BitVariantTests, ReplicaSerde};
use crate::common::{LVec, ObjId};
use crate::world::{LuNameValue, Lot, Quaternion, Vector3};
use crate::world::gm::InventoryType;
use super::{ComponentConstruction, ComponentProtocol, ComponentSerialization};
#[derive(Debug, PartialEq, ReplicaSerde)]
pub struct EquippedItemInfo {
pub id: ObjId,
pub lot: Lot,
pub subkey: Option<ObjId>,
pub count: Option<u32>,
pub slot: Option<u16>,
pub inventory_type: Option<InventoryType>,
pub extra_info: Option<LuNameValue>,
pub is_bound: bool,
}
#[derive(Debug, PartialEq, ReplicaSerde)]
pub struct EquippedModelTransform {
pub model_id: ObjId,
pub equip_position: Vector3,
pub equip_rotation: Quaternion,
}
#[derive(BitVariantTests, Debug, PartialEq, ReplicaSerde)]
pub struct InventoryConstruction {
pub equipped_items: Option<LVec<u32, EquippedItemInfo>>,
pub equipped_model_transforms: Option<LVec<u32, EquippedModelTransform>>,
}
impl ComponentConstruction for InventoryConstruction {
fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
self.serialize(writer)
}
}
pub type InventorySerialization = InventoryConstruction;
impl ComponentSerialization for InventorySerialization {
fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
self.serialize(writer)
}
}
pub struct InventoryProtocol;
impl ComponentProtocol for InventoryProtocol {
type Construction = InventoryConstruction;
type Serialization = InventorySerialization;
}