From 8ec62e9dba6ef13a27bc04050c2838e4763a1a3c Mon Sep 17 00:00:00 2001 From: Anuken Date: Fri, 4 Jun 2021 11:08:53 -0400 Subject: [PATCH] Duct bridge polish --- .../world/blocks/distribution/DuctBridge.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/world/blocks/distribution/DuctBridge.java b/core/src/mindustry/world/blocks/distribution/DuctBridge.java index 10d3c287e6..f71d46514a 100644 --- a/core/src/mindustry/world/blocks/distribution/DuctBridge.java +++ b/core/src/mindustry/world/blocks/distribution/DuctBridge.java @@ -37,6 +37,7 @@ public class DuctBridge extends Block{ group = BlockGroup.transportation; noUpdateDisabled = true; envEnabled = Env.space | Env.terrestrial | Env.underwater; + drawArrow = false; } @Override @@ -55,6 +56,37 @@ public class DuctBridge extends Block{ Placement.calculateNodes(points, this, rotation, (point, other) -> Math.max(Math.abs(point.x - other.x), Math.abs(point.y - other.y)) <= range); } + @Override + public void drawPlace(int x, int y, int rotation, boolean valid){ + super.drawPlace(x, y, rotation, valid); + + int length = range; + Building found = null; + + //find the link + for(int i = 1; i <= range; i++){ + Tile other = world.tile(x + Geometry.d4x(rotation) * i, y + Geometry.d4y(rotation) * i); + + if(other != null && other.build instanceof DuctBridgeBuild build && build.team == player.team()){ + length = i; + found = other.build; + break; + } + } + + Drawf.dashLine(Pal.placing, + x * tilesize + Geometry.d4[rotation].x * (tilesize / 2f + 2), + y * tilesize + Geometry.d4[rotation].y * (tilesize / 2f + 2), + x * tilesize + Geometry.d4[rotation].x * (length) * tilesize, + y * tilesize + Geometry.d4[rotation].y * (length) * tilesize + ); + + if(found != null){ + Drawf.square(found.x, found.y, found.block.size * tilesize/2f + 2.5f, 0f); + } + + } + public boolean positionsValid(int x1, int y1, int x2, int y2){ if(x1 == x2){ return Math.abs(y1 - y2) <= range; @@ -88,7 +120,6 @@ public class DuctBridge extends Block{ Draw.rect(bridgeBotRegion, cx, cy, len, tilesize, angle); Draw.reset(); Draw.alpha(Renderer.bridgeOpacity); - //Draw.rect(bridgeTopRegion, cx, cy, len, tilesize, angle); for(float i = 6f; i <= len + size * tilesize - 5f; i += 5f){ Draw.rect(arrowRegion, x + Geometry.d4x(rotation) * i, y + Geometry.d4y(rotation) * i, angle);