Add more helper functions

This commit is contained in:
Lol3rrr
2024-09-27 22:48:02 +02:00
parent 3fabe9f493
commit fa57cacae0
2 changed files with 29 additions and 0 deletions

View File

@@ -109,3 +109,9 @@ impl EntityContext {
))) )))
} }
} }
impl EntityState {
pub fn get_prop(&self, name: &str) -> Option<&EntityProp> {
self.props.iter().find(|p| p.prop_info.prop_name.as_ref() == name)
}
}

View File

@@ -24,3 +24,26 @@ pub struct Sticker {
pub x: f32, pub x: f32,
pub y: f32, pub y: f32,
} }
impl Variant {
pub fn as_f32(&self) -> Option<f32> {
match self {
Self::F32(v) => Some(*v),
_ => None,
}
}
pub fn as_u32(&self) -> Option<u32> {
match self {
Self::U32(v) => Some(*v),
_ => None,
}
}
pub fn as_i32(&self) -> Option<i32> {
match self {
Self::I32(v) => Some(*v),
_ => None,
}
}
}