evtc\marker/
squad.rs
1use crate::{
2 extract::{transmute_field, Extract},
3 Event, Position, StateChange, TryExtract,
4};
5use num_enum::{FromPrimitive, IntoPrimitive};
6
7#[cfg(feature = "serde")]
8use serde::{Deserialize, Serialize};
9
10#[cfg(feature = "strum")]
11use strum::{Display, EnumCount, EnumIter, IntoStaticStr, VariantNames};
12
13#[derive(Debug, Clone)]
15#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
16pub struct SquadMarkerEvent {
17 pub time: u64,
19
20 pub marker: SquadMarker,
22
23 pub position: Position,
25}
26
27impl SquadMarkerEvent {
28 #[inline]
30 pub fn is_remove(&self) -> bool {
31 self.position == Position::new(f32::INFINITY, f32::INFINITY, f32::INFINITY)
32 }
33}
34
35impl Extract for SquadMarkerEvent {
36 #[inline]
37 unsafe fn extract(event: &Event) -> Self {
38 let pos = transmute_field!(event.src_agent as [f32; 3]);
39 Self {
40 time: event.time,
41 marker: event.skill_id.into(),
42 position: pos.into(),
43 }
44 }
45}
46
47impl TryExtract for SquadMarkerEvent {
48 #[inline]
49 fn can_extract(event: &Event) -> bool {
50 event.get_statechange() == StateChange::SquadMarker
51 }
52}
53
54#[derive(
56 Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
57)]
58#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
59#[cfg_attr(
60 feature = "strum",
61 derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
62)]
63#[repr(u32)]
64pub enum SquadMarker {
65 Arrow = 0,
66
67 Circle = 1,
68
69 Heart = 2,
70
71 Square = 3,
72
73 Star = 4,
74
75 Swirl = 5,
76
77 Triangle = 6,
78
79 X = 7,
80
81 #[num_enum(catch_all)]
82 Unknown(u32),
83}