aboutsummaryrefslogtreecommitdiff
path: root/src/event.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/event.rs')
-rw-r--r--src/event.rs67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/event.rs b/src/event.rs
index 02f4686..f87688e 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -104,6 +104,73 @@ pub enum EventKind {
},
}
+impl EventKind {
+ /// Returns the source agent address for this event, if one exists.
+ pub fn source_agent_addr(&self) -> Option<u64> {
+ use EventKind::*;
+ match *self {
+ EnterCombat { agent_addr, .. } => return Some(agent_addr),
+ ExitCombat { agent_addr } => return Some(agent_addr),
+ ChangeUp { agent_addr } => return Some(agent_addr),
+ ChangeDown { agent_addr } => return Some(agent_addr),
+ ChangeDead { agent_addr } => return Some(agent_addr),
+ Spawn { agent_addr } => return Some(agent_addr),
+ Despawn { agent_addr } => return Some(agent_addr),
+ HealthUpdate { agent_addr, .. } => return Some(agent_addr),
+ WeaponSwap { agent_addr, .. } => return Some(agent_addr),
+ MaxHealthUpdate { agent_addr, .. } => return Some(agent_addr),
+ PointOfView { agent_addr } => return Some(agent_addr),
+ SkillUse {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ ConditionTick {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ InvulnTick {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ Physical {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ BuffApplication {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ BuffRemove {
+ source_agent_addr, ..
+ } => return Some(source_agent_addr),
+ _ => return None,
+ }
+ }
+
+ /// Returns the destination agent address for this event, if one exists.
+ pub fn destination_agent_addr(&self) -> Option<u64> {
+ use EventKind::*;
+ match *self {
+ ConditionTick {
+ destination_agent_addr,
+ ..
+ } => return Some(destination_agent_addr),
+ InvulnTick {
+ destination_agent_addr,
+ ..
+ } => return Some(destination_agent_addr),
+ Physical {
+ destination_agent_addr,
+ ..
+ } => return Some(destination_agent_addr),
+ BuffApplication {
+ destination_agent_addr,
+ ..
+ } => return Some(destination_agent_addr),
+ BuffRemove {
+ destination_agent_addr,
+ ..
+ } => return Some(destination_agent_addr),
+ _ => return None,
+ }
+ }
+}
+
/// A higher-level representation of a combat event.
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Event {