use std::mem::transmute;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[cfg(feature = "strum")]
use strum::{Display, EnumCount, EnumIter, IntoStaticStr, VariantNames};
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[cfg_attr(
feature = "strum",
derive(Display, EnumCount, EnumIter, IntoStaticStr, VariantNames)
)]
pub enum AgentKind {
Player,
Npc(u16),
Gadget(u16),
}
impl AgentKind {
#[inline]
pub const fn new(prof: u32, elite: u32) -> Self {
if elite == u32::MAX {
let (lower, upper): (u16, u16) = unsafe { transmute(prof) };
if upper == u16::MAX {
AgentKind::Gadget(lower)
} else {
AgentKind::Npc(lower)
}
} else {
AgentKind::Player
}
}
}
impl From<(u32, u32)> for AgentKind {
#[inline]
fn from((prof, elite): (u32, u32)) -> Self {
Self::new(prof, elite)
}
}