mindustry logic execution, map- and schematic- parsing and rendering
-rw-r--r--src/block/distribution.rs4
-rw-r--r--src/data/renderer.rs21
2 files changed, 10 insertions, 15 deletions
diff --git a/src/block/distribution.rs b/src/block/distribution.rs
index e185d3a..7186535 100644
--- a/src/block/distribution.rs
+++ b/src/block/distribution.rs
@@ -236,11 +236,11 @@ impl BlockLogic for ItemBlock {
}
match name {
"duct-router" => {
- unsafe { p.overlay(&load!("top", s).rotate(rot.rotated(false).count())) };
+ unsafe { p.overlay(load!("top", s).rotate(rot.rotated(false).count())) };
}
"duct-unloader" => {
unsafe {
- p.overlay(&load!("duct-unloader-top", s).rotate(rot.rotated(false).count()))
+ p.overlay(load!("duct-unloader-top", s).rotate(rot.rotated(false).count()))
};
}
_ => {}
diff --git a/src/data/renderer.rs b/src/data/renderer.rs
index 71aff18..ba578b1 100644
--- a/src/data/renderer.rs
+++ b/src/data/renderer.rs
@@ -115,19 +115,17 @@ impl Renderable for Schematic<'_> {
((self.height + 2) * 32) as u32,
);
for (GridPos(x, y), tile) in self.block_iter() {
- let ctx = if tile.block.wants_context() {
+ let ctx = tile.block.wants_context().then(|| {
let pctx = PositionContext {
position: GridPos(x, y),
width: self.width,
height: self.height,
};
- Some(RenderingContext {
+ RenderingContext {
cross: self.cross(&pctx),
position: pctx,
- })
- } else {
- None
- };
+ }
+ });
let x = x as u32 - ((tile.block.get_size() - 1) / 2) as u32;
let y = self.height as u32 - y as u32 - ((tile.block.get_size() / 2) + 1) as u32;
unsafe {
@@ -217,20 +215,17 @@ impl Renderable for Map<'_> {
// SAFETY: no block too big
_ => unsafe { std::hint::unreachable_unchecked() },
}) as usize;
- let ctx = if build.block.wants_context() {
+ let ctx = build.block.wants_context().then(|| {
let pctx = PositionContext {
position: GridPos(x, y),
width: self.width,
height: self.height,
};
- let rctx = RenderingContext {
+ RenderingContext {
cross: self.cross(j, &pctx),
position: pctx,
- };
- Some(rctx)
- } else {
- None
- };
+ }
+ });
unsafe {
top.as_mut().overlay_at(
&tile.build_image(ctx.as_ref(), scale).borrow(),