diff --git a/src/parser/entities.rs b/src/parser/entities.rs index 2979791..b28f3f4 100644 --- a/src/parser/entities.rs +++ b/src/parser/entities.rs @@ -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) + } +} diff --git a/src/parser/variant.rs b/src/parser/variant.rs index ec4aba9..0d803ab 100644 --- a/src/parser/variant.rs +++ b/src/parser/variant.rs @@ -24,3 +24,26 @@ pub struct Sticker { pub x: f32, pub y: f32, } + +impl Variant { + pub fn as_f32(&self) -> Option { + match self { + Self::F32(v) => Some(*v), + _ => None, + } + } + + pub fn as_u32(&self) -> Option { + match self { + Self::U32(v) => Some(*v), + _ => None, + } + } + + pub fn as_i32(&self) -> Option { + match self { + Self::I32(v) => Some(*v), + _ => None, + } + } +}