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
57
58
59
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 super::{ComponentConstruction, ComponentProtocol, ComponentSerialization};

#[derive(Debug, PartialEq, ReplicaSerde)]
pub struct BehaviorInfo {
	pub unknown_1: u32,
	pub action: u32, // todo: type
	pub wait_time_ms: u32,
	pub template_id: u32, // todo: type
	pub caster: ObjId,
	pub originator: ObjId,
	pub target: ObjId,
	pub used_mouse: bool,
	pub cooldown: f32,
	pub charge_time: f32,
	pub imagination_cost: u32,
}

#[derive(Debug, PartialEq, ReplicaSerde)]
pub struct SkillInfo {
	pub unknown_1: u32,
	pub skill_id: u32,    // todo: type
	pub cast_type: u32,   // todo: type
	pub cancel_type: u32, // todo: type
	pub behaviors: LVec<u32, BehaviorInfo>,
}

#[derive(BitVariantTests, Debug, PartialEq, ReplicaSerde)]
pub struct SkillConstruction {
	pub skills_in_progress: Option<LVec<u32, SkillInfo>>,
}

#[derive(BitVariantTests, Debug, PartialEq, ReplicaSerde)]
pub struct SkillSerialization {}

impl ComponentConstruction for SkillConstruction {
	fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
		self.serialize(writer)
	}
}

impl ComponentSerialization for SkillSerialization {
	fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
		self.serialize(writer)
	}
}

pub struct SkillProtocol;

impl ComponentProtocol for SkillProtocol {
	type Construction = SkillConstruction;
	type Serialization = SkillSerialization;
}