mindustry logic execution, map- and schematic- parsing and rendering
Diffstat (limited to 'src/block/mod.rs')
| -rw-r--r-- | src/block/mod.rs | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/block/mod.rs b/src/block/mod.rs new file mode 100644 index 0000000..0c491ba --- /dev/null +++ b/src/block/mod.rs @@ -0,0 +1,30 @@ +use std::borrow::Cow; + +pub trait BlockLogic +{ + fn get_size(&self) -> u8; +} + +pub struct Block +{ + name: Cow<'static, str>, + logic: Box<dyn BlockLogic>, +} + +impl Block +{ + pub fn new(name: Cow<'static, str>, logic: Box<dyn BlockLogic>) -> Self + { + Self{name, logic} + } + + pub fn get_name(&self) -> &str + { + &self.name + } + + pub fn get_size(&self) -> u8 + { + self.logic.get_size() + } +} |