use binrw::binrw;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use crate::hash::{HashCode, HashCode16};
#[binrw]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
#[derive(Debug)]
pub struct GameEventValue {
key: HashCode16,
value: u16,
}
impl GameEventValue {
pub fn new(key: impl Into<HashCode>, value: u16) -> Self {
let key = HashCode16::from(key.into());
Self { key, value }
}
const fn key(&self) -> HashCode16 {
self.key
}
pub const fn value(&self) -> &u16 {
&self.value
}
pub const fn value_mut(&mut self) -> &mut u16 {
&mut self.value
}
}
impl PartialEq<HashCode> for GameEventValue {
fn eq(&self, other: &HashCode) -> bool {
self.key() == *other
}
}