1use crate::{extract::Extract, AgentId, Event, EventCategory, Position, TryExtract};
2use num_enum::{FromPrimitive, IntoPrimitive};
3use std::mem::transmute;
4
5#[cfg(feature = "serde")]
6use serde::{Deserialize, Serialize};
7
8#[cfg(feature = "strum")]
9use strum::{Display, EnumCount, EnumIter, IntoStaticStr, VariantNames};
10
11#[derive(Debug, Clone)]
15#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
16pub struct ActivationEvent {
17 pub time: u64,
19
20 pub agent: AgentId,
22
23 pub skill_id: u32,
25
26 pub activation: Activation,
28
29 pub duration: i32,
31
32 pub scaled_duration: i32,
34
35 pub target: Position,
37}
38
39impl Extract for ActivationEvent {
40 #[inline]
41 unsafe fn extract(event: &Event) -> Self {
42 let [x, y]: [f32; 2] = transmute(event.dst_agent);
43 let z = f32::from_bits(event.overstack_value);
44 Self {
45 time: event.time,
46 agent: AgentId::from_src(event),
47 skill_id: event.skill_id,
48 activation: event.get_activation(),
49 duration: event.value,
50 scaled_duration: event.buff_dmg,
51 target: Position::new(x, y, z),
52 }
53 }
54}
55
56impl TryExtract for ActivationEvent {
57 #[inline]
58 fn can_extract(event: &Event) -> bool {
59 event.categorize() == EventCategory::Activation
60 }
61}
62
63#[derive(
67 Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
68)]
69#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
70#[cfg_attr(
71 feature = "strum",
72 derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
73)]
74#[repr(u8)]
75pub enum Activation {
76 None = 0,
78
79 Start = 1,
81
82 QuicknessUnused = 2,
84
85 CancelFire = 3,
87
88 CancelCancel = 4,
90
91 Reset = 5,
93
94 #[num_enum(catch_all)]
96 Unknown(u8),
97}
98
99#[derive(
103 Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
104)]
105#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
106#[cfg_attr(
107 feature = "strum",
108 derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
109)]
110#[repr(u8)]
111pub enum AnimationStop {
112 None = 0,
113 Instant = 1,
114 SecondUse = 2,
115 Transition = 3,
116 Partial = 4,
117 Ended = 5,
118 Cancel = 6,
119 StowedChange = 7,
120 Interrupt = 8,
121 Death = 9,
122 Downed = 10,
123 CrowdControl = 11,
124 MoveBehind = 12,
125 MoveSkill = 13,
126 MoveDodge = 14,
127 MoveStop = 15,
128
129 #[num_enum(catch_all)]
131 Unknown(u8),
132}