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 6916c3d..1ddd337 100644 --- a/src/block/mod.rs +++ b/src/block/mod.rs @@ -37,6 +37,10 @@ pub trait BlockLogic fn clone_state(&self, state: &dyn Any) -> Box<dyn Any>; + fn mirror_state(&self, state: &mut dyn Any, horizontally: bool, vertically: bool); + + fn rotate_state(&self, state: &mut dyn Any, clockwise: bool); + fn serialize_state(&self, state: &dyn Any) -> Result<DynData, SerializeError>; } @@ -207,6 +211,21 @@ impl Block self.logic.clone_state(state) } + pub fn mirror_state(&self, state: &mut dyn Any, horizontally: bool, vertically: bool) + { + self.logic.mirror_state(state, horizontally, vertically); + } + + pub fn rotate_state(&self, state: &mut dyn Any, clockwise: bool) + { + self.logic.rotate_state(state, clockwise); + } + + pub fn rotate_180(&mut self, state: &mut dyn Any) + { + self.logic.mirror_state(state, true, true); + } + pub fn serialize_state(&self, state: &dyn Any) -> Result<DynData, SerializeError> { self.logic.serialize_state(state) |