From 8d12dbbe7075f7f7a9387ef55eff3bb250453e2f Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 6 Jun 2021 10:06:33 -0400 Subject: [PATCH] Minor duct preview optimizations --- core/src/mindustry/ctype/UnlockableContent.java | 2 +- .../world/blocks/distribution/DuctBridge.java | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/core/src/mindustry/ctype/UnlockableContent.java b/core/src/mindustry/ctype/UnlockableContent.java index c28496bb81..749477f330 100644 --- a/core/src/mindustry/ctype/UnlockableContent.java +++ b/core/src/mindustry/ctype/UnlockableContent.java @@ -50,8 +50,8 @@ public abstract class UnlockableContent extends MappableContent{ fullIcon = Core.atlas.find(getContentType().name() + "-" + name + "-full", Core.atlas.find(name + "-full", - Core.atlas.find(name, Core.atlas.find(getContentType().name() + "-" + name, + Core.atlas.find(name, Core.atlas.find(name + "1"))))); uiIcon = Core.atlas.find(getContentType().name() + "-" + name + "-ui", fullIcon); diff --git a/core/src/mindustry/world/blocks/distribution/DuctBridge.java b/core/src/mindustry/world/blocks/distribution/DuctBridge.java index 87cec19af9..b2965ddee7 100644 --- a/core/src/mindustry/world/blocks/distribution/DuctBridge.java +++ b/core/src/mindustry/world/blocks/distribution/DuctBridge.java @@ -53,13 +53,13 @@ public class DuctBridge extends Block{ public void drawRequestConfigTop(BuildPlan req, Eachable list){ otherReq = null; otherDst = range; + Point2 d = Geometry.d4(req.rotation); list.each(other -> { - if(other.block == this && req != other){ - for(int i = 1; i <= range; i++){ - if(req.x + (Geometry.d4x(req.rotation) * i) == other.x && req.y + (Geometry.d4y(req.rotation) * i) == other.y && i <= otherDst){ - otherReq = other; - otherDst = i; - } + if(other.block == this && req != other && Mathf.clamp(other.x - req.x, -1, 1) == d.x && Mathf.clamp(other.y - req.y, -1, 1) == d.y){ + int dst = Math.max(Math.abs(other.x - req.x), Math.abs(other.y - req.y)); + if(dst <= otherDst){ + otherReq = other; + otherDst = dst; } } });