#![allow(deprecated)]
use crate::{
extract::{transmute_field, Extract},
guid::ContentLocal,
Event, StateChange, TryExtract,
};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[deprecated(since = "0.9.0", note = "replaced by content guid event")]
pub struct EffectGUID {
pub effect_id: u32,
#[cfg_attr(feature = "serde", serde(with = "crate::serde_hex"))]
pub guid: u128,
pub content_local: Option<ContentLocal>,
}
impl EffectGUID {
#[inline]
pub fn guid_string(&self) -> String {
format!("{:0>32X}", self.guid)
}
}
impl Extract for EffectGUID {
#[inline]
unsafe fn extract(event: &Event) -> Self {
Self {
effect_id: event.skill_id,
guid: u128::from_be(transmute_field!(event.src_agent as u128)),
content_local: event.overstack_value.try_into().ok(),
}
}
}
impl TryExtract for EffectGUID {
#[inline]
fn can_extract(event: &Event) -> bool {
event.get_statechange() == StateChange::IdToGUID
}
}