mirror of
https://github.com/lcdr/lu_packets.git
synced 2025-12-30 16:24:22 -06:00
Add support for destroyable serialization
This commit is contained in:
@@ -14,7 +14,7 @@ use lu_packets::{
|
||||
buff::BuffConstruction,
|
||||
character::CharacterConstruction,
|
||||
controllable_physics::{ControllablePhysicsConstruction, ControllablePhysicsSerialization},
|
||||
destroyable::DestroyableConstruction,
|
||||
destroyable::{DestroyableConstruction, DestroyableSerialization},
|
||||
fx::FxConstruction,
|
||||
inventory::InventoryConstruction,
|
||||
level_progression::LevelProgressionConstruction,
|
||||
@@ -75,6 +75,7 @@ impl ReplicaContext for PlayerContext<'_> {
|
||||
|
||||
vec![
|
||||
|x| Ok(Box::new(ControllablePhysicsSerialization::deserialize(x)?)),
|
||||
|x| Ok(Box::new(DestroyableSerialization::deserialize(x)?)),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use endio_bit::{BEBitReader, BEBitWriter};
|
||||
use lu_packets_derive::{BitVariantTests, ReplicaSerde};
|
||||
|
||||
use crate::common::LVec;
|
||||
use super::ComponentConstruction;
|
||||
use super::{ComponentConstruction, ComponentSerialization};
|
||||
|
||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
||||
pub struct StatusImmunityInfo {
|
||||
@@ -127,9 +127,39 @@ pub struct DestroyableConstruction {
|
||||
pub is_on_a_threat_list: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, ReplicaSerde)]
|
||||
pub struct SerializationStatsInfo {
|
||||
pub cur_health: u32,
|
||||
pub max_health: f32,
|
||||
pub cur_armor: u32,
|
||||
pub max_armor: f32,
|
||||
pub cur_imag: u32,
|
||||
pub max_imag: f32,
|
||||
pub damage_absorption_points: u32,
|
||||
pub immunity: bool,
|
||||
pub is_gm_immune: bool,
|
||||
pub is_shielded: bool,
|
||||
pub actual_max_health: f32,
|
||||
pub actual_max_armor: f32,
|
||||
pub actual_max_imag: f32,
|
||||
pub factions: LVec<u32, i32>,
|
||||
pub is_smashable: bool,
|
||||
}
|
||||
|
||||
#[derive(BitVariantTests, Debug, PartialEq, ReplicaSerde)]
|
||||
pub struct DestroyableSerialization {
|
||||
pub serialization_stats_info: Option<SerializationStatsInfo>,
|
||||
pub is_on_a_threat_list: Option<bool>,
|
||||
}
|
||||
|
||||
impl ComponentConstruction for DestroyableConstruction {
|
||||
fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
|
||||
self.serialize(writer)
|
||||
}
|
||||
}
|
||||
|
||||
impl ComponentSerialization for DestroyableSerialization {
|
||||
fn ser(&self, writer: &mut BEBitWriter<Vec<u8>>) -> Res<()> {
|
||||
self.serialize(writer)
|
||||
}
|
||||
}
|
||||
|
||||
BIN
src/raknet/client/replica/tests/DestroyableSerialization.bin
Normal file
BIN
src/raknet/client/replica/tests/DestroyableSerialization.bin
Normal file
Binary file not shown.
20
src/raknet/client/replica/tests/DestroyableSerialization.rs
Normal file
20
src/raknet/client/replica/tests/DestroyableSerialization.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
DestroyableSerialization {
|
||||
serialization_stats_info: Some(SerializationStatsInfo {
|
||||
cur_health: 9,
|
||||
max_health: 10.0,
|
||||
cur_armor: 11,
|
||||
max_armor: 12.0,
|
||||
cur_imag: 13,
|
||||
max_imag: 14.0,
|
||||
damage_absorption_points: 15,
|
||||
immunity: true,
|
||||
is_gm_immune: true,
|
||||
is_shielded: true,
|
||||
actual_max_health: 16.0,
|
||||
actual_max_armor: 17.0,
|
||||
actual_max_imag: 18.0,
|
||||
factions: vec![19].into(),
|
||||
is_smashable: true,
|
||||
}),
|
||||
is_on_a_threat_list: Some(true),
|
||||
}
|
||||
Reference in New Issue
Block a user