Add more helper functions
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,3 +24,26 @@ pub struct Sticker {
|
||||
pub x: 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user