diff --git a/core/src/mindustry/core/NetClient.java b/core/src/mindustry/core/NetClient.java index 8e6032c359..0594c3403a 100644 --- a/core/src/mindustry/core/NetClient.java +++ b/core/src/mindustry/core/NetClient.java @@ -633,7 +633,7 @@ public class NetClient implements ApplicationListener{ lastSent++, uid, player.dead(), - unit.x, unit.y, + player.dead() ? player.x : unit.x, player.dead() ? player.y : unit.y, player.unit().aimX(), player.unit().aimY(), unit.rotation, unit instanceof Mechc m ? m.baseRotation() : 0, diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index b7dd1af01b..3495255ded 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -911,7 +911,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, if(net.client()) return; if((block.consumesPower || block.outputsPower) && block.hasPower){ - PowerNode.getNodeLinks(tile, block, other -> { + PowerNode.getNodeLinks(tile, block, team, other -> { if(!other.power.links.contains(pos())){ other.configureAny(pos()); } diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 052e439594..69600c9f16 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -259,7 +259,7 @@ public class Block extends UnlockableContent{ if((consumesPower || outputsPower) && hasPower){ Tile tile = world.tile(x, y); if(tile != null){ - PowerNode.getNodeLinks(tile, this, other -> { + PowerNode.getNodeLinks(tile, this, player.team(), other -> { PowerNode node = (PowerNode)other.block; Draw.color(node.laserColor1, Renderer.laserOpacity * 0.5f); node.drawLaser(tile.team(), x * tilesize + offset, y * tilesize + offset, other.x, other.y, size, other.block.size); diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index dbf9d4b891..a48647b03f 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -175,6 +175,11 @@ public class PowerNode extends PowerBlock{ Drawf.laser(team, laser, laserEnd, x1 + vx*len1, y1 + vy*len1, x2 - vx*len2, y2 - vy*len2, 0.25f); } + protected boolean overlaps(float srcx, float srcy, Tile other, Block otherBlock, float range){ + return Intersector.overlaps(Tmp.cr1.set(srcx, srcy, range), Tmp.r1.setCentered(other.worldx() + otherBlock.offset, other.worldy() + otherBlock.offset, + otherBlock.size * tilesize, otherBlock.size * tilesize)); + } + protected boolean overlaps(float srcx, float srcy, Tile other, float range){ return Intersector.overlaps(Tmp.cr1.set(srcx, srcy, range), other.getHitbox(Tmp.r1)); } @@ -242,10 +247,10 @@ public class PowerNode extends PowerBlock{ //TODO code duplication w/ method above? /** Iterates through linked nodes of a block at a tile. All returned buildings are power nodes. */ - public static void getNodeLinks(Tile tile, Block block, Cons others){ + public static void getNodeLinks(Tile tile, Block block, Team team, Cons others){ Boolf valid = other -> other != null && other.tile() != tile && other.block instanceof PowerNode node && other.power.links.size < node.maxNodes && - node.overlaps(tile.x * tilesize + block.offset, tile.y * tilesize + block.offset, other.tile(), node.laserRange * tilesize) && other.team == player.team() + node.overlaps(other.x - block.offset, other.y - block.offset, tile, block, node.laserRange * tilesize) && other.team == team && !graphs.contains(other.power.graph) && !Structs.contains(Edges.getEdges(block.size), p -> { //do not link to adjacent buildings var t = world.tile(tile.x + p.x, tile.y + p.y); @@ -258,7 +263,7 @@ public class PowerNode extends PowerBlock{ //add conducting graphs to prevent double link for(var p : Edges.getEdges(block.size)){ Tile other = tile.nearby(p); - if(other != null && other.team() == player.team() && other.build != null && other.build.power != null){ + if(other != null && other.team() == team && other.build != null && other.build.power != null){ graphs.add(other.build.power.graph); } }