evtc\buff/
remove.rs
1use crate::{
2 event::{impl_common, CommonEvent},
3 extract::Extract,
4 Event, EventCategory, TryExtract,
5};
6use num_enum::{FromPrimitive, IntoPrimitive};
7
8#[cfg(feature = "serde")]
9use serde::{Deserialize, Serialize};
10
11#[cfg(feature = "strum")]
12use strum::{Display, EnumCount, EnumIter, IntoStaticStr, VariantNames};
13
14#[derive(Debug, Clone)]
16#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
17pub struct BuffRemoveEvent {
18 #[cfg_attr(feature = "serde", serde(flatten))]
20 pub common: CommonEvent,
21
22 pub remove: BuffRemoveKind,
24
25 pub removed_duration: i32,
27
28 pub removed_intensity: i32,
32}
33
34impl_common!(BuffRemoveEvent);
35
36impl Extract for BuffRemoveEvent {
37 #[inline]
38 unsafe fn extract(event: &Event) -> Self {
39 Self {
40 common: event.into(),
41 remove: event.extract(),
42 removed_duration: event.value,
43 removed_intensity: event.buff_dmg,
44 }
45 }
46}
47
48impl TryExtract for BuffRemoveEvent {
49 #[inline]
50 fn can_extract(event: &Event) -> bool {
51 event.categorize() == EventCategory::BuffRemove
52 }
53}
54
55#[derive(
57 Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
58)]
59#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
60#[cfg_attr(
61 feature = "strum",
62 derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
63)]
64#[repr(u8)]
65pub enum BuffRemove {
66 None = 0,
68
69 All = 1,
73
74 Single = 2,
80
81 Manual = 3,
87
88 #[num_enum(catch_all)]
90 Unknown(u8),
91}
92
93#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
95#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
96#[cfg_attr(feature = "serde", serde(tag = "kind"))]
97#[cfg_attr(
98 feature = "strum",
99 derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
100)]
101pub enum BuffRemoveKind {
102 All {
106 stacks_removed: u8,
108 },
109
110 Single {
116 stack_id: u32,
118 },
119
120 Manual {
126 stack_id: u32,
128 },
129
130 Unknown(u8),
132}
133
134impl Extract for BuffRemoveKind {
135 #[inline]
136 unsafe fn extract(event: &Event) -> Self {
137 match event.get_buffremove() {
138 BuffRemove::None => unreachable!("extract buffremove on non-buffremove event"),
139 BuffRemove::All => Self::All {
140 stacks_removed: event.result,
141 },
142 BuffRemove::Single => Self::Single {
143 stack_id: event.get_pad_id(),
144 },
145 BuffRemove::Manual => Self::Manual {
146 stack_id: event.get_pad_id(),
147 },
148 BuffRemove::Unknown(value) => Self::Unknown(value),
149 }
150 }
151}