-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update for arc event changes & improve doc
- Loading branch information
Showing
20 changed files
with
783 additions
and
394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::{extract::Extract, AgentId, Event, StateChange, TryExtract}; | ||
|
||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Agent is now an attack target. | ||
#[derive(Debug, Clone)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
pub struct AttackTargetEvent { | ||
/// Time of registering the attack target. | ||
pub time: u64, | ||
|
||
/// Agent that is an attack target. | ||
pub agent: AgentId, | ||
|
||
/// Parent gadget agent. | ||
pub parent: AgentId, | ||
|
||
/// Current targetable state. | ||
pub targetable: bool, | ||
} | ||
|
||
impl Extract for AttackTargetEvent { | ||
#[inline] | ||
unsafe fn extract(event: &Event) -> Self { | ||
Self { | ||
time: event.time, | ||
agent: AgentId::from_src(event), | ||
parent: AgentId::from_dst(event), | ||
targetable: event.value != 0, | ||
} | ||
} | ||
} | ||
|
||
impl TryExtract for AttackTargetEvent { | ||
#[inline] | ||
fn can_extract(event: &Event) -> bool { | ||
event.get_statechange() == StateChange::AttackTarget | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use crate::{ | ||
extract::Extract, AgentId, Event, Profession, Specialization, StateChange, TryExtract, | ||
}; | ||
use std::mem; | ||
|
||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Agent entered combat. | ||
#[derive(Debug, Clone)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
pub struct EnterCombatEvent { | ||
/// Time of registering the combat enter. | ||
pub time: u64, | ||
|
||
/// Agent that entered combat. | ||
pub agent: AgentId, | ||
|
||
/// Agent subgroup. | ||
pub subgroup: u64, | ||
|
||
/// Agent profession. | ||
pub profession: Profession, | ||
|
||
/// Agent elite specialization. | ||
pub elite: Specialization, | ||
} | ||
|
||
impl Extract for EnterCombatEvent { | ||
#[inline] | ||
unsafe fn extract(event: &Event) -> Self { | ||
Self { | ||
time: event.time, | ||
agent: AgentId::from_src(event), | ||
subgroup: event.dst_agent, | ||
profession: unsafe { mem::transmute::<i32, u32>(event.value) }.into(), | ||
elite: unsafe { mem::transmute::<i32, u32>(event.buff_dmg) }.into(), | ||
} | ||
} | ||
} | ||
|
||
impl TryExtract for EnterCombatEvent { | ||
#[inline] | ||
fn can_extract(event: &Event) -> bool { | ||
event.get_statechange() == StateChange::EnterCombat | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::{extract::Extract, AgentId, Event, StateChange, TryExtract}; | ||
|
||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Agent gliding state change. | ||
#[derive(Debug, Clone)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
pub struct GliderEvent { | ||
/// Time of registering the gliding state. | ||
pub time: u64, | ||
|
||
/// Agent that changed gliding state. | ||
pub agent: AgentId, | ||
|
||
pub deployed: bool, | ||
} | ||
|
||
impl Extract for GliderEvent { | ||
#[inline] | ||
unsafe fn extract(event: &Event) -> Self { | ||
Self { | ||
time: event.time, | ||
agent: AgentId::from_src(event), | ||
deployed: event.value != 0, | ||
} | ||
} | ||
} | ||
|
||
impl TryExtract for GliderEvent { | ||
#[inline] | ||
fn can_extract(event: &Event) -> bool { | ||
event.get_statechange() == StateChange::Glider | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
use crate::{extract::Extract, AgentId, Event, StateChange, TryExtract}; | ||
|
||
#[cfg(feature = "serde")] | ||
use serde::{Deserialize, Serialize}; | ||
|
||
/// Agent max health change. | ||
#[derive(Debug, Clone)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
pub struct MaxHealthEvent { | ||
/// Time of registering the max health change. | ||
pub time: u64, | ||
|
||
/// Agent that had their max health changed. | ||
pub agent: AgentId, | ||
|
||
/// New agent max health. | ||
pub max_health: u64, | ||
} | ||
|
||
impl Extract for MaxHealthEvent { | ||
#[inline] | ||
unsafe fn extract(event: &Event) -> Self { | ||
Self { | ||
time: event.time, | ||
agent: AgentId::from_src(event), | ||
max_health: event.dst_agent, | ||
} | ||
} | ||
} | ||
|
||
impl TryExtract for MaxHealthEvent { | ||
#[inline] | ||
fn can_extract(event: &Event) -> bool { | ||
event.get_statechange() == StateChange::MaxHealthUpdate | ||
} | ||
} | ||
|
||
/// Agent health percent change. | ||
#[derive(Debug, Clone)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
pub struct HealthUpdateEvent { | ||
/// Time of registering the health percent change. | ||
pub time: u64, | ||
|
||
/// Agent that had their health percent changed. | ||
pub agent: AgentId, | ||
|
||
/// Current health percent with `1.0` being max. | ||
pub health: f32, | ||
} | ||
|
||
impl HealthUpdateEvent { | ||
/// Conversion ratio. | ||
pub const CONVERT: f32 = 10_000.0; | ||
} | ||
|
||
impl Extract for HealthUpdateEvent { | ||
#[inline] | ||
unsafe fn extract(event: &Event) -> Self { | ||
Self { | ||
time: event.time, | ||
agent: AgentId::from_src(event), | ||
health: event.dst_agent as f32 / Self::CONVERT, | ||
} | ||
} | ||
} | ||
|
||
impl TryExtract for HealthUpdateEvent { | ||
#[inline] | ||
fn can_extract(event: &Event) -> bool { | ||
event.get_statechange() == StateChange::HealthUpdate | ||
} | ||
} | ||
|
||
/// Agent barrier percent change. | ||
#[derive(Debug, Clone)] | ||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] | ||
pub struct BarrierUpdateEvent { | ||
/// Time of registering the barrier change. | ||
pub time: u64, | ||
|
||
/// Agent that had their current barrier changed. | ||
pub agent: AgentId, | ||
|
||
/// Current barrier percent with `1.0` being max. | ||
pub barrier: f32, | ||
} | ||
|
||
impl BarrierUpdateEvent { | ||
/// Conversion ratio. | ||
pub const CONVERT: f32 = 10_000.0; | ||
} | ||
|
||
impl Extract for BarrierUpdateEvent { | ||
#[inline] | ||
unsafe fn extract(event: &Event) -> Self { | ||
Self { | ||
time: event.time, | ||
agent: AgentId::from_src(event), | ||
barrier: event.dst_agent as f32 / Self::CONVERT, | ||
} | ||
} | ||
} | ||
|
||
impl TryExtract for BarrierUpdateEvent { | ||
#[inline] | ||
fn can_extract(event: &Event) -> bool { | ||
event.get_statechange() == StateChange::BarrierUpdate | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.