evtc\player/
tag.rs

1#![allow(deprecated)]
2
3use crate::{extract::Extract, AgentId, Event, StateChange, TryExtract};
4
5#[cfg(feature = "serde")]
6use serde::{Deserialize, Serialize};
7
8/// Agent has a tag.
9#[derive(Debug, Clone)]
10#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
11#[deprecated(since = "0.9.0", note = "replaced by agent marker event")]
12pub struct TagEvent {
13    /// Time of registering the event.
14    pub time: u64,
15
16    /// Agent that has the tag.
17    pub agent: AgentId,
18
19    /// Tag id.
20    ///
21    /// Id is volatile, depends on game build.
22    pub tag: i32,
23}
24
25impl Extract for TagEvent {
26    #[inline]
27    unsafe fn extract(event: &Event) -> Self {
28        Self {
29            time: event.time,
30            agent: AgentId::from_src(event),
31            tag: event.value,
32        }
33    }
34}
35
36impl TryExtract for TagEvent {
37    #[inline]
38    fn can_extract(event: &Event) -> bool {
39        event.get_statechange() == StateChange::Marker
40    }
41}