diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index 09459a5911..b766ed040d 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -535,28 +535,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ } }); } - - final int[] i = {0}; - lineRequests.each(req -> { - if(!(req.block instanceof PowerNode)) return; - - if(i[0]++ == 0 || i[0] == lineRequests.size){ - // beginning & end should always be placed - }else{ - // check with how many powernodes the *next* tile will overlap - int overlaps = 0; - for(int j = 0; j < i[0]; j++){ - if (((PowerNode) req.block).overlaps(lineRequests.get(i[0]).tile(), lineRequests.get(j).tile()) && lineRequests.get(j).block instanceof PowerNode){ - overlaps++; - } - } - - // if its more than two it can bridge the gap - if(overlaps > 1){ - req.block = Blocks.air; - } - } - }); } protected void updateLine(int x1, int y1){ @@ -830,21 +808,46 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ Array points; boolean diagonal = Core.input.keyDown(Binding.diagonal_placement); - // place powernodes diagonally by default - if((block != null && block.powernodePlacement)){ - diagonal = !diagonal; - } - if(Core.settings.getBool("swapdiagonal") && mobile){ diagonal = !diagonal; } if(diagonal){ - points = Placement.pathfindLine(block != null && block.conveyorPlacement, block != null && block.powernodePlacement, startX, startY, endX, endY); + points = Placement.pathfindLine(block != null && block.conveyorPlacement, startX, startY, endX, endY); }else{ points = Placement.normalizeLine(startX, startY, endX, endY); } + Array skip = new Array<>(); + if(block instanceof PowerNode){ + final int[] i = {0}; + points.each(req -> { + if(i[0]++ == 0 || i[0] == points.size){ + // beginning & end should always be placed + }else{ + // check with how many powernodes the *next* tile will overlap + int overlaps = 0; + for(int j = 0; j < i[0]; j++){ + // skip powernodes we have already crossed off as air + if(skip.contains(points.get(j))) continue; + + Tile next = world.ltile(points.get(i[0]).x, points.get(i[0]).y); + Tile loop = world.ltile(points.get(j).x, points.get(j).y); + + if (((PowerNode) block).overlaps(next, loop)){ + overlaps++; + } + } + + // if its more than one it can bridge the gap + if(overlaps > 1){ + skip.add(points.get(i[0]-1)); + } + } + }); + } + points.removeAll(skip); + float angle = Angles.angle(startX, startY, endX, endY); int baseRotation = rotation; if(!overrideLineRotation || diagonal){ diff --git a/core/src/io/anuke/mindustry/input/Placement.java b/core/src/io/anuke/mindustry/input/Placement.java index 6aac3c26aa..14d1b8b230 100644 --- a/core/src/io/anuke/mindustry/input/Placement.java +++ b/core/src/io/anuke/mindustry/input/Placement.java @@ -22,7 +22,7 @@ public class Placement{ private static IntSet closed = new IntSet(); /** Normalize a diagonal line into points. */ - public static Array pathfindLine(boolean conveyors, boolean powernodes, int startX, int startY, int endX, int endY){ + public static Array pathfindLine(boolean conveyors, int startX, int startY, int endX, int endY){ Pools.freeAll(points); points.clear(); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 37d62e8a9c..9710e1b8de 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -93,8 +93,6 @@ public class Block extends BlockStorage{ public boolean posConfig; /** Whether this block uses conveyor-type placement mode.*/ public boolean conveyorPlacement; - /** Whether this block uses powernode-type placement mode.*/ - public boolean powernodePlacement; /** * The color of this block when displayed on the minimap or map preview. * Do not set manually! This is overriden when loading for most blocks. diff --git a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java index 87f2ee68cb..7c0f947b65 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java @@ -32,7 +32,7 @@ public class PowerNode extends PowerBlock{ configurable = true; consumesPower = false; outputsPower = false; - powernodePlacement = true; + conveyorPlacement = true; } @Override