mindustry logic execution, map- and schematic- parsing and rendering
Diffstat (limited to 'src/block/logic.rs')
-rw-r--r--src/block/logic.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/block/logic.rs b/src/block/logic.rs
index 4946bdb..879c8b3 100644
--- a/src/block/logic.rs
+++ b/src/block/logic.rs
@@ -92,6 +92,14 @@ impl BlockLogic for MessageLogic
Box::new(Self::get_state(state).clone())
}
+ fn mirror_state(&self, _: &mut dyn Any, _: bool, _: bool)
+ {
+ }
+
+ fn rotate_state(&self, _: &mut dyn Any, _: bool)
+ {
+ }
+
fn serialize_state(&self, state: &dyn Any) -> Result<DynData, SerializeError>
{
Ok(DynData::String(Some(Self::get_state(state).clone())))
@@ -165,6 +173,14 @@ impl BlockLogic for SwitchLogic
Box::new(Self::get_state(state).clone())
}
+ fn mirror_state(&self, _: &mut dyn Any, _: bool, _: bool)
+ {
+ }
+
+ fn rotate_state(&self, _: &mut dyn Any, _: bool)
+ {
+ }
+
fn serialize_state(&self, state: &dyn Any) -> Result<DynData, SerializeError>
{
Ok(DynData::Boolean(*Self::get_state(state)))
@@ -299,6 +315,25 @@ impl BlockLogic for ProcessorLogic
Box::new(Self::get_state(state).clone())
}
+ fn mirror_state(&self, state: &mut dyn Any, horizontally: bool, vertically: bool)
+ {
+ for link in Self::get_state_mut(state).links.iter_mut()
+ {
+ if horizontally {link.x = -link.x;}
+ if vertically {link.y = -link.y;}
+ }
+ }
+
+ fn rotate_state(&self, state: &mut dyn Any, clockwise: bool)
+ {
+ for link in Self::get_state_mut(state).links.iter_mut()
+ {
+ let (cdx, cdy) = link.get_pos();
+ link.x = if clockwise {cdy} else {-cdy};
+ link.y = if clockwise {-cdx} else {cdx};
+ }
+ }
+
fn serialize_state(&self, state: &dyn Any) -> Result<DynData, SerializeError>
{
let state = Self::get_state(state);