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
use std::io::Result as Res;

use endio::Serialize;
use endio_bit::BEBitWriter;
use lu_packets_derive::{BitVariantTests, ReplicaSerde};

use crate::common::{LuVarString, LuVarWString, LVec, ObjId};
use super::{ComponentConstruction, ComponentProtocol, ComponentSerialization};

#[derive(Debug, PartialEq, ReplicaSerde)]
pub struct EffectInfo {
	pub effect_name: LuVarString<u8>,
	pub effect_id: u32, // todo: type
	pub effect_type: LuVarWString<u8>,
	pub priority: f32,
	pub secondary: ObjId,
}

#[derive(BitVariantTests, Debug, PartialEq, ReplicaSerde)]
pub struct FxConstruction {
	pub active_effects: LVec<u32, EffectInfo>,
}

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

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

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

pub struct FxProtocol;

impl ComponentProtocol for FxProtocol {
	type Construction = FxConstruction;
	type Serialization = FxSerialization;
}