@@ -633,7 +633,7 @@ public class NetClient implements ApplicationListener{
|
|||||||
lastSent++,
|
lastSent++,
|
||||||
uid,
|
uid,
|
||||||
player.dead(),
|
player.dead(),
|
||||||
unit.x, unit.y,
|
player.dead() ? player.x : unit.x, player.dead() ? player.y : unit.y,
|
||||||
player.unit().aimX(), player.unit().aimY(),
|
player.unit().aimX(), player.unit().aimY(),
|
||||||
unit.rotation,
|
unit.rotation,
|
||||||
unit instanceof Mechc m ? m.baseRotation() : 0,
|
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(net.client()) return;
|
||||||
|
|
||||||
if((block.consumesPower || block.outputsPower) && block.hasPower){
|
if((block.consumesPower || block.outputsPower) && block.hasPower){
|
||||||
PowerNode.getNodeLinks(tile, block, other -> {
|
PowerNode.getNodeLinks(tile, block, team, other -> {
|
||||||
if(!other.power.links.contains(pos())){
|
if(!other.power.links.contains(pos())){
|
||||||
other.configureAny(pos());
|
other.configureAny(pos());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ public class Block extends UnlockableContent{
|
|||||||
if((consumesPower || outputsPower) && hasPower){
|
if((consumesPower || outputsPower) && hasPower){
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
PowerNode.getNodeLinks(tile, this, other -> {
|
PowerNode.getNodeLinks(tile, this, player.team(), other -> {
|
||||||
PowerNode node = (PowerNode)other.block;
|
PowerNode node = (PowerNode)other.block;
|
||||||
Draw.color(node.laserColor1, Renderer.laserOpacity * 0.5f);
|
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);
|
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);
|
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){
|
protected boolean overlaps(float srcx, float srcy, Tile other, float range){
|
||||||
return Intersector.overlaps(Tmp.cr1.set(srcx, srcy, range), other.getHitbox(Tmp.r1));
|
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?
|
//TODO code duplication w/ method above?
|
||||||
/** Iterates through linked nodes of a block at a tile. All returned buildings are power nodes. */
|
/** 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 &&
|
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.block instanceof PowerNode node &&
|
||||||
other.power.links.size < node.maxNodes &&
|
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) &&
|
&& !graphs.contains(other.power.graph) &&
|
||||||
!Structs.contains(Edges.getEdges(block.size), p -> { //do not link to adjacent buildings
|
!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);
|
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
|
//add conducting graphs to prevent double link
|
||||||
for(var p : Edges.getEdges(block.size)){
|
for(var p : Edges.getEdges(block.size)){
|
||||||
Tile other = tile.nearby(p);
|
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);
|
graphs.add(other.build.power.graph);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user