mindustry logic execution, map- and schematic- parsing and rendering
update heat router render
| -rw-r--r-- | mindus/src/block/production.rs | 39 | ||||
| -rw-r--r-- | mindus/src/utils/image/mod.rs | 14 |
2 files changed, 43 insertions, 10 deletions
diff --git a/mindus/src/block/production.rs b/mindus/src/block/production.rs index b14efd5..e785805 100644 --- a/mindus/src/block/production.rs +++ b/mindus/src/block/production.rs @@ -65,15 +65,34 @@ make_simple!( make_simple!(HeatConduit, |_, n, _, _, r: Rotation, s| { let mut base = load!(from n which is ["heat-router" | "heat-redirector" | "small-heat-redirector"], s); - let mut top = match r { - Rotation::Up | Rotation::Right => { - load!(concat "top1" => n which is ["heat-router" | "heat-redirector" | "small-heat-redirector"], s) - } - Rotation::Down | Rotation::Left => { - load!(concat "top2" => n which is ["heat-router" | "heat-redirector" | "small-heat-redirector"], s) + if n == "heat-router" { + let t1 = load!("heat-router-top1", s); + let t2 = load!("heat-router-top2", s); + let x = |n| unsafe { + match n { + Rotation::Up => t1.clone().rotated(3), + Rotation::Right => t1.clone(), + Rotation::Down => t2.clone().rotated(1), + Rotation::Left => t2.clone().rotated(2), + } + }; + unsafe { + base.overlay(&x(r.rotated(false))); + base.overlay(&x(r)); + base.overlay(&x(r.rotated(true))); } - }; - unsafe { top.rotate(r.rotated(false).count()) }; - unsafe { base.overlay(&top) }; - base + base + } else { + let mut top = match r { + Rotation::Up | Rotation::Right => { + load!(concat "top1" => n which is ["heat-router" | "heat-redirector" | "small-heat-redirector"], s) + } + Rotation::Down | Rotation::Left => { + load!(concat "top2" => n which is ["heat-router" | "heat-redirector" | "small-heat-redirector"], s) + } + }; + unsafe { top.rotate(r.rotated(false).count()) }; + unsafe { base.overlay(&top) }; + base + } }); diff --git a/mindus/src/utils/image/mod.rs b/mindus/src/utils/image/mod.rs index 08aa13c..e9dcc10 100644 --- a/mindus/src/utils/image/mod.rs +++ b/mindus/src/utils/image/mod.rs @@ -11,6 +11,13 @@ pub trait ImageUtils { /// /// UB if image is not square unsafe fn rotate(&mut self, times: u8) -> &mut Self; + unsafe fn rotated(mut self, times: u8) -> Self + where + Self: Sized, + { + unsafe { self.rotate(times) }; + self + } /// shadow fn shadow(&mut self) -> &mut Self; } @@ -56,3 +63,10 @@ impl ImageUtils for Image<&mut [u8], 4> { self } } + +#[test] +fn x() { + let mut x = Image::<_, 4>::open("/home/os/pod.png"); + x.as_mut().shadow(); + x.save("/home/os/shadowpod.png"); +} |