aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2020-04-28 15:47:31 +0200
committerDaniel Schadt <kingdread@gmx.de>2020-04-28 15:47:31 +0200
commit2847dae9014fcc59be5b45f78d1b000dc92aa7bc (patch)
tree3e94dc5e731a208dbe4b56932997764fa17957c2
parentdb8e74092776d499ba1590389411735b6276af78 (diff)
downloadevtclib-2847dae9014fcc59be5b45f78d1b000dc92aa7bc.tar.gz
evtclib-2847dae9014fcc59be5b45f78d1b000dc92aa7bc.tar.bz2
evtclib-2847dae9014fcc59be5b45f78d1b000dc92aa7bc.zip
implement Position/Velocity/Facing/MapId events
-rw-r--r--src/event.rs66
1 files changed, 60 insertions, 6 deletions
diff --git a/src/event.rs b/src/event.rs
index 71effba..867276c 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -2,13 +2,13 @@ use super::raw;
use std::io;
-use num_traits::FromPrimitive;
use byteorder::{BigEndian, WriteBytesExt};
+use num_traits::FromPrimitive;
/// A rusty enum for all possible combat events.
///
/// This makes dealing with `CbtEvent` a bit saner (and safer).
-#[derive(Clone, Debug, PartialEq, Eq)]
+#[derive(Clone, Debug, PartialEq)]
pub enum EventKind {
// State change events
/// The agent has entered combat.
@@ -106,6 +106,32 @@ pub enum EventKind {
removal: raw::CbtBuffRemove,
},
+ /// Position of the agent has changed.
+ Position {
+ source_agent_addr: u64,
+ x: f32,
+ y: f32,
+ z: f32,
+ },
+
+ /// Velocity of the agent has changed.
+ Velocity {
+ source_agent_addr: u64,
+ x: f32,
+ y: f32,
+ z: f32,
+ },
+
+ /// The agent is facing in the given direction.
+ Facing {
+ source_agent_addr: u64,
+ x: f32,
+ y: f32,
+ },
+
+ /// Information about the map id.
+ MapId { map_id: u64 },
+
/// Guild identification
Guild {
source_agent_addr: u64,
@@ -115,7 +141,7 @@ pub enum EventKind {
}
/// A higher-level representation of a combat event.
-#[derive(Clone, Debug, PartialEq, Eq)]
+#[derive(Clone, Debug, PartialEq)]
pub struct Event {
/// The time when the event happened.
///
@@ -214,10 +240,38 @@ impl Event {
raw_bytes: get_guild_id_bytes(raw_event),
api_guild_id: get_api_guild_string(&get_guild_id_bytes(raw_event)),
},
+ CbtStateChange::Position => EventKind::Position {
+ source_agent_addr: raw_event.src_agent,
+ x: f32::from_bits((raw_event.dst_agent >> 32) as u32),
+ y: f32::from_bits((raw_event.dst_agent & 0xffffffff) as u32),
+ z: f32::from_bits(raw_event.value as u32),
+ },
+ CbtStateChange::Velocity => EventKind::Velocity {
+ source_agent_addr: raw_event.src_agent,
+ x: f32::from_bits((raw_event.dst_agent >> 32) as u32),
+ y: f32::from_bits((raw_event.dst_agent & 0xffffffff) as u32),
+ z: f32::from_bits(raw_event.value as u32),
+ },
+ CbtStateChange::Facing => EventKind::Facing {
+ source_agent_addr: raw_event.src_agent,
+ x: f32::from_bits((raw_event.dst_agent >> 32) as u32),
+ y: f32::from_bits((raw_event.dst_agent & 0xffffffff) as u32),
+ },
+ CbtStateChange::MapId => EventKind::MapId {
+ map_id: raw_event.src_agent,
+ },
// XXX: implement proper handling of those events!
- CbtStateChange::BuffInitial | CbtStateChange::Position | CbtStateChange::Velocity | CbtStateChange::Facing | CbtStateChange::TeamChange | CbtStateChange::AttackTarget | CbtStateChange::Targetable | CbtStateChange::MapId | CbtStateChange::ReplInfo | CbtStateChange::StackActive | CbtStateChange::StackReset | CbtStateChange::BuffInfo | CbtStateChange::BuffFormula | CbtStateChange::SkillInfo | CbtStateChange::SkillTiming => {
- return None
- }
+ CbtStateChange::BuffInitial
+ | CbtStateChange::TeamChange
+ | CbtStateChange::AttackTarget
+ | CbtStateChange::Targetable
+ | CbtStateChange::ReplInfo
+ | CbtStateChange::StackActive
+ | CbtStateChange::StackReset
+ | CbtStateChange::BuffInfo
+ | CbtStateChange::BuffFormula
+ | CbtStateChange::SkillInfo
+ | CbtStateChange::SkillTiming => return None,
CbtStateChange::None => check_activation(raw_event)?,
};