mindustry logic execution, map- and schematic- parsing and rendering
Diffstat (limited to 'src/block/simple.rs')
-rw-r--r--src/block/simple.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/block/simple.rs b/src/block/simple.rs
index 330ee7f..c363064 100644
--- a/src/block/simple.rs
+++ b/src/block/simple.rs
@@ -29,6 +29,31 @@ macro_rules!gen_state_empty
};
}
+macro_rules!state_impl
+{
+ ($vis:vis $type:ty) =>
+ {
+ $vis fn get_state<'l>(state: &'l dyn Any) -> &'l $type
+ where Self: Sized
+ {
+ state.downcast_ref::<$type>().unwrap()
+ }
+
+ $vis fn get_state_mut<'l>(state: &'l mut dyn Any) -> &'l mut $type
+ where Self: Sized
+ {
+ state.downcast_mut::<$type>().unwrap()
+ }
+
+ fn create_state(val: $type) -> Box<dyn Any>
+ where Self: Sized
+ {
+ Box::new(val)
+ }
+ };
+}
+pub(crate) use state_impl;
+
pub struct SimpleBlock
{
size: u8,