evtc\buff/
stack.rs

1use crate::{
2    extract::{transmute_field, Extract},
3    AgentId, Event, StateChange, TryExtract,
4};
5
6#[cfg(feature = "serde")]
7use serde::{Deserialize, Serialize};
8
9/// Active buff stack change.
10#[derive(Debug, Clone)]
11#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
12pub struct StackActiveEvent {
13    /// Time of registering the active buff stack change.
14    pub time: u64,
15
16    /// Agent that had their active buff stack changed.
17    pub agent: AgentId,
18
19    /// Stack id of new active stack.
20    pub stack_id: u64,
21
22    /// Current buff duration.
23    pub duration: i32,
24}
25
26impl Extract for StackActiveEvent {
27    #[inline]
28    unsafe fn extract(event: &Event) -> Self {
29        Self {
30            time: event.time,
31            agent: AgentId::from_src(event),
32            stack_id: event.dst_agent,
33            duration: event.value,
34        }
35    }
36}
37
38impl TryExtract for StackActiveEvent {
39    #[inline]
40    fn can_extract(event: &Event) -> bool {
41        event.get_statechange() == StateChange::StackActive
42    }
43}
44
45/// Buff stack reset.
46#[derive(Debug, Clone)]
47#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
48pub struct StackResetEvent {
49    /// Time of registering the stack reset.
50    pub time: u64,
51
52    /// Agent that the stack reset happened to.
53    pub agent: AgentId,
54
55    /// New duration to reset to.
56    pub duration: i32,
57
58    /// Stack id.
59    pub stack_id: u32,
60}
61
62impl Extract for StackResetEvent {
63    #[inline]
64    unsafe fn extract(event: &Event) -> Self {
65        Self {
66            time: event.time,
67            agent: AgentId::from_src(event),
68            duration: event.value,
69            stack_id: transmute_field!(event.pad61 as u32),
70        }
71    }
72}
73
74impl TryExtract for StackResetEvent {
75    #[inline]
76    fn can_extract(event: &Event) -> bool {
77        event.get_statechange() == StateChange::StackReset
78    }
79}