connectedPower similar to conductivePower (#8306)
This commit is contained in:
@@ -1254,7 +1254,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
public void placed(){
|
public void placed(){
|
||||||
if(net.client()) return;
|
if(net.client()) return;
|
||||||
|
|
||||||
if((block.consumesPower || block.outputsPower) && block.hasPower){
|
if((block.consumesPower || block.outputsPower) && block.hasPower && block.connectedPower){
|
||||||
PowerNode.getNodeLinks(tile, block, team, 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());
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
public boolean consumesPower = true;
|
public boolean consumesPower = true;
|
||||||
/** If true, this block is a generator that can produce power. */
|
/** If true, this block is a generator that can produce power. */
|
||||||
public boolean outputsPower = false;
|
public boolean outputsPower = false;
|
||||||
|
/** If false, power nodes cannot connect to this block. */
|
||||||
|
public boolean connectedPower = true;
|
||||||
/** If true, this block can conduct power like a cable. */
|
/** If true, this block can conduct power like a cable. */
|
||||||
public boolean conductivePower = false;
|
public boolean conductivePower = false;
|
||||||
/** If true, this block can output payloads; affects blending. */
|
/** If true, this block can output payloads; affects blending. */
|
||||||
@@ -413,7 +415,7 @@ public class Block extends UnlockableContent implements Senseable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawPotentialLinks(int x, int y){
|
public void drawPotentialLinks(int x, int y){
|
||||||
if((consumesPower || outputsPower) && hasPower){
|
if((consumesPower || outputsPower) && hasPower && connectedPower){
|
||||||
Tile tile = world.tile(x, y);
|
Tile tile = world.tile(x, y);
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
PowerNode.getNodeLinks(tile, this, player.team(), other -> {
|
PowerNode.getNodeLinks(tile, this, player.team(), other -> {
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class BeamNode extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//power nodes do NOT play nice with beam nodes, do not touch them as that forcefully modifies their links
|
//power nodes do NOT play nice with beam nodes, do not touch them as that forcefully modifies their links
|
||||||
if(other != null && other.block.hasPower && other.team == team && !(other.block instanceof PowerNode)){
|
if(other != null && other.block.hasPower && other.block.connectedPower && other.team == team && !(other.block instanceof PowerNode)){
|
||||||
links[i] = other;
|
links[i] = other;
|
||||||
dests[i] = world.tile(tile.x + j * dir.x, tile.y + j * dir.y);
|
dests[i] = world.tile(tile.x + j * dir.x, tile.y + j * dir.y);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
protected void getPotentialLinks(Tile tile, Team team, Cons<Building> others){
|
protected void getPotentialLinks(Tile tile, Team team, Cons<Building> others){
|
||||||
if(!autolink) return;
|
if(!autolink) return;
|
||||||
|
|
||||||
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.power != null &&
|
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.block.connectedPower && other.power != null &&
|
||||||
(other.block.outputsPower || other.block.consumesPower || other.block instanceof PowerNode) &&
|
(other.block.outputsPower || other.block.consumesPower || other.block instanceof PowerNode) &&
|
||||||
overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team == team &&
|
overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team == team &&
|
||||||
!graphs.contains(other.power.graph) &&
|
!graphs.contains(other.power.graph) &&
|
||||||
@@ -342,7 +342,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean linkValid(Building tile, Building link, boolean checkMaxNodes){
|
public boolean linkValid(Building tile, Building link, boolean checkMaxNodes){
|
||||||
if(tile == link || link == null || !link.block.hasPower || tile.team != link.team) return false;
|
if(tile == link || link == null || !link.block.hasPower || !link.block.connectedPower || tile.team != link.team) return false;
|
||||||
|
|
||||||
if(overlaps(tile, link, laserRange * tilesize) || (link.block instanceof PowerNode node && overlaps(link, tile, node.laserRange * tilesize))){
|
if(overlaps(tile, link, laserRange * tilesize) || (link.block instanceof PowerNode node && overlaps(link, tile, node.laserRange * tilesize))){
|
||||||
if(checkMaxNodes && link.block instanceof PowerNode node){
|
if(checkMaxNodes && link.block instanceof PowerNode node){
|
||||||
|
|||||||
Reference in New Issue
Block a user