use crate::{extract::Extract, AgentId, Event, StateChange, TryExtract};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct AgentMarkerEvent {
pub time: u64,
pub agent: AgentId,
pub marker: i32,
pub commander: u8,
}
impl AgentMarkerEvent {
#[inline]
pub fn is_remove(&self) -> bool {
self.marker == 0
}
#[inline]
pub fn is_commander(&self) -> bool {
self.commander != 0
}
}
impl Extract for AgentMarkerEvent {
#[inline]
unsafe fn extract(event: &Event) -> Self {
Self {
time: event.time,
agent: AgentId::from_src(event),
marker: event.value,
commander: event.buff,
}
}
}
impl TryExtract for AgentMarkerEvent {
#[inline]
fn can_extract(event: &Event) -> bool {
event.get_statechange() == StateChange::Marker
}
}