mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-09-21 21:38:29 +03:00
parent
4c9cda7e40
commit
5f83c92829
@ -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,
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<Building> others){
|
||||
public static void getNodeLinks(Tile tile, Block block, Team team, Cons<Building> others){
|
||||
Boolf<Building> 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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user