All neccesary messages
This commit is contained in:
@@ -153,12 +153,51 @@ impl RegenerationHealthChanged {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct CharacterStats {
|
||||
pub source: usize,
|
||||
pub character_name: String,
|
||||
pub health: f32,
|
||||
pub max_health: f32,
|
||||
pub energy: f32,
|
||||
pub max_energy: f32,
|
||||
}
|
||||
|
||||
impl CharacterStats {
|
||||
fn encode(val: Parameters) -> Option<Message> {
|
||||
if val.len() < 40 {
|
||||
return None;
|
||||
}
|
||||
|
||||
let source = deserialize_number!(val, 0, "CharacterStats::source")?;
|
||||
|
||||
let character_name = deserialize_string!(val, 2, "CharacterStats::character_name")?;
|
||||
|
||||
let health = deserialize_float!(val, 11, "CharacterStats::health")?;
|
||||
let max_health = deserialize_float!(val, 12, "CharacterStats::max_health")?;
|
||||
|
||||
let energy = deserialize_float!(val, 15, "CharacterStats::energy")?;
|
||||
let max_energy = deserialize_float!(val, 16, "CharacterStats::max_energy")?;
|
||||
|
||||
|
||||
Some(Message::CharacterStats(Self {
|
||||
source,
|
||||
character_name,
|
||||
health,
|
||||
max_health,
|
||||
energy,
|
||||
max_energy,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Message {
|
||||
ChatSay(ChatSay),
|
||||
NewCharacter(NewCharacter),
|
||||
HealthUpdate(HealthUpdate),
|
||||
RegenerationHealthChanged(RegenerationHealthChanged),
|
||||
CharacterStats(CharacterStats)
|
||||
}
|
||||
|
||||
impl Packet {
|
||||
@@ -168,6 +207,7 @@ impl Packet {
|
||||
24 => NewCharacter::encode(self.parameters),
|
||||
63 => ChatSay::encode(self.parameters),
|
||||
79 => RegenerationHealthChanged::encode(self.parameters),
|
||||
1001 => CharacterStats::encode(self.parameters),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user