From 8693ad351a934c99d413e1906ef67351765641dd Mon Sep 17 00:00:00 2001 From: Anuken Date: Thu, 24 Jul 2025 16:57:04 -0400 Subject: [PATCH] Erekir bridge link previews --- .../blocks/distribution/DirectionBridge.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/world/blocks/distribution/DirectionBridge.java b/core/src/mindustry/world/blocks/distribution/DirectionBridge.java index 2c0077cc99..89091e8faf 100644 --- a/core/src/mindustry/world/blocks/distribution/DirectionBridge.java +++ b/core/src/mindustry/world/blocks/distribution/DirectionBridge.java @@ -88,10 +88,41 @@ public class DirectionBridge extends Block{ public void drawPlace(int x, int y, int rotation, boolean valid, boolean line){ int length = range; + + if(line){ + //find input links + for(int d = 0; d < 4; d++){ + if(d == (rotation+2)%4) continue; + + int dx = Geometry.d4x(d), dy = Geometry.d4y(d); + + for(int i = 1; i <= range; i++){ + Tile other = world.tile(x - dx * i, y - dy * i); + + if(other != null && other.build instanceof DirectionBridgeBuild build && build.block == this && build.team == player.team()){ + if(build.rotation == d){ + var from = other.build; + + Drawf.dashLine(Pal.place, + from.x + dx * (tilesize / 2f + 2), + from.y + dy * (tilesize / 2f + 2), + from.x + dx * (i) * tilesize, + from.y + dy * (i) * tilesize + ); + + Drawf.square(from.x, from.y, from.block.size * tilesize/2f + 2.5f, 0f, Pal.place); + } + //always stop when a bridge is encountered, as it blocks incoming bridges from this side + break; + } + } + } + } + Building found = null; int dx = Geometry.d4x(rotation), dy = Geometry.d4y(rotation); - //find the link + //find the output link for(int i = 1; i <= range; i++){ Tile other = world.tile(x + dx * i, y + dy * i);