evtc\agent/
attack_target.rs
1use crate::{extract::Extract, AgentId, Event, StateChange, TryExtract};
2
3#[cfg(feature = "serde")]
4use serde::{Deserialize, Serialize};
5
6#[derive(Debug, Clone)]
8#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
9pub struct AttackTargetEvent {
10 pub time: u64,
12
13 pub agent: AgentId,
15
16 pub parent: AgentId,
18
19 pub targetable: bool,
21}
22
23impl Extract for AttackTargetEvent {
24 #[inline]
25 unsafe fn extract(event: &Event) -> Self {
26 Self {
27 time: event.time,
28 agent: AgentId::from_src(event),
29 parent: AgentId::from_dst(event),
30 targetable: event.value != 0,
31 }
32 }
33}
34
35impl TryExtract for AttackTargetEvent {
36 #[inline]
37 fn can_extract(event: &Event) -> bool {
38 event.get_statechange() == StateChange::AttackTarget
39 }
40}