evtc\missile/
create.rs
1use crate::{
2 extract::{transmute_field, Extract},
3 AgentId, Event, Position, StateChange, TryExtract,
4};
5
6#[cfg(feature = "serde")]
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Clone)]
11#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
12pub struct MissileCreate {
13 pub time: u64,
15
16 pub source: AgentId,
18
19 pub location: Position,
21
22 pub skin_id: u32,
24
25 pub skill_id: u32,
27
28 pub tracking_id: u32,
30}
31
32impl Extract for MissileCreate {
33 #[inline]
34 unsafe fn extract(event: &Event) -> Self {
35 let [x, y, z] = transmute_field!(event.value as [i16; 3]);
36 let skin_id = event.overstack_value;
37 let skill_id = event.skill_id;
38
39 Self {
40 time: event.time,
41 source: AgentId::from_src(event),
42 location: Position::from_scaled_i16s(x, y, z, 10.0),
43 skill_id,
44 skin_id,
45 tracking_id: event.get_pad_id(),
46 }
47 }
48}
49
50impl TryExtract for MissileCreate {
51 #[inline]
52 fn can_extract(event: &Event) -> bool {
53 event.get_statechange() == StateChange::MissileCreate
54 }
55}