use crate::{extract::Extract, AgentId, Event, StateChange, TryExtract};
use num_enum::{FromPrimitive, IntoPrimitive};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "strum")]
use strum::{Display, EnumCount, EnumIter, IntoStaticStr, VariantNames};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct WeaponSwapEvent {
pub time: u64,
pub agent: AgentId,
pub weapon_set: WeaponSet,
}
impl Extract for WeaponSwapEvent {
#[inline]
unsafe fn extract(event: &Event) -> Self {
Self {
time: event.time,
agent: AgentId::from_src(event),
weapon_set: event.dst_agent.into(),
}
}
}
impl TryExtract for WeaponSwapEvent {
#[inline]
fn can_extract(event: &Event) -> bool {
event.get_statechange() == StateChange::WeaponSwap
}
}
#[derive(
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, IntoPrimitive, FromPrimitive,
)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(
feature = "strum",
derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
)]
#[repr(u64)]
pub enum WeaponSet {
Water1 = 0,
Water2 = 1,
Bundle = 2,
Transform = 3,
Land1 = 4,
Land2 = 5,
#[num_enum(catch_all)]
Unknown(u64),
}