mindustry logic execution, map- and schematic- parsing and rendering
Diffstat (limited to 'src/block/mod.rs')
| -rw-r--r-- | src/block/mod.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/block/mod.rs b/src/block/mod.rs index 1a32b6b..1967ba8 100644 --- a/src/block/mod.rs +++ b/src/block/mod.rs @@ -5,6 +5,8 @@ use std::collections::hash_map::Entry; use crate::access::BoxAccess; use crate::data::dynamic::DynData; +pub mod simple; + pub trait BlockLogic { fn get_size(&self) -> u8; @@ -173,3 +175,20 @@ impl<'l> AsRef<HashMap<&'l str, &'l Block>> for BlockRegistry<'l> &self.blocks } } + +macro_rules!make_register +{ + ($($field:ident: $name:literal => $logic:expr;)+) => + { + $( + pub static $field: $crate::block::Block = $crate::block::Block::new( + std::borrow::Cow::Borrowed($name), $crate::access::Access::Borrowed(&$logic)); + )+ + + pub fn register<'l>(reg: &mut $crate::block::BlockRegistry<'l>) + { + $(assert!(reg.register(&$field).is_ok(), "duplicate block {:?}", $name);)+ + } + }; +} +pub(crate) use make_register; |