From 08d0a7ada7a2b28f8829102cf35b3cf87c0f7bcc Mon Sep 17 00:00:00 2001 From: Anuken Date: Sun, 3 Nov 2019 21:27:58 -0500 Subject: [PATCH] Bugfixes / Better power link priority --- core/src/io/anuke/mindustry/input/MobileInput.java | 1 + .../mindustry/world/blocks/power/PowerNode.java | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/src/io/anuke/mindustry/input/MobileInput.java b/core/src/io/anuke/mindustry/input/MobileInput.java index 66a4c0a513..717fb68c95 100644 --- a/core/src/io/anuke/mindustry/input/MobileInput.java +++ b/core/src/io/anuke/mindustry/input/MobileInput.java @@ -434,6 +434,7 @@ public class MobileInput extends InputHandler implements GestureListener{ public void useSchematic(Schematic schem){ selectRequests.clear(); selectRequests.addAll(schematics.toRequests(schem, world.toTile(player.x), world.toTile(player.y))); + lastSchematic = schem; } @Override 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 03ed940b3d..e9d922ba1d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java @@ -114,7 +114,11 @@ public class PowerNode extends PowerBlock{ } }); - tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile))); + tempTiles.sort((a, b) -> { + int type = -Boolean.compare(a.block() instanceof PowerNode, b.block() instanceof PowerNode); + if(type != 0) return type; + return Float.compare(a.dst2(tile), b.dst2(tile)); + }); tempTiles.each(valid, other -> { if(!tile.entity.power.links.contains(other.pos())){ tile.configureAny(other.pos()); @@ -139,7 +143,11 @@ public class PowerNode extends PowerBlock{ } }); - tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile))); + tempTiles.sort((a, b) -> { + int type = -Boolean.compare(a.block() instanceof PowerNode, b.block() instanceof PowerNode); + if(type != 0) return type; + return Float.compare(a.dst2(tile), b.dst2(tile)); + }); tempTiles.each(valid, t -> { graphs.add(t.entity.power.graph); others.get(t);