filterable power node connections

This commit is contained in:
Chawanya-c
2022-04-19 11:27:18 +07:00
parent a949e321ae
commit f56fa20cc7
2 changed files with 5 additions and 0 deletions

View File

@@ -670,6 +670,10 @@ public class Block extends UnlockableContent{
return isVisible() && (!state.rules.bannedBlocks.contains(this) || state.rules.editor) && supportsEnv(state.rules.environment); return isVisible() && (!state.rules.bannedBlocks.contains(this) || state.rules.editor) && supportsEnv(state.rules.environment);
} }
public boolean shouldConnect(Building build){
return true;
}
/** @return whether this block supports a specific environment. */ /** @return whether this block supports a specific environment. */
public boolean supportsEnv(int env){ public boolean supportsEnv(int env){
return (envEnabled & env) != 0 && (envDisabled & env) == 0 && (envRequired == 0 || (envRequired & env) == envRequired); return (envEnabled & env) != 0 && (envDisabled & env) == 0 && (envRequired == 0 || (envRequired & env) == envRequired);

View File

@@ -205,6 +205,7 @@ public class PowerNode extends PowerBlock{
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) &&
!PowerNode.insulated(tile, other.tile) && !PowerNode.insulated(tile, other.tile) &&
other.block.shouldConnect(other) &&
!(other instanceof PowerNodeBuild obuild && obuild.power.links.size >= ((PowerNode)obuild.block).maxNodes) && !(other instanceof PowerNodeBuild obuild && obuild.power.links.size >= ((PowerNode)obuild.block).maxNodes) &&
!Structs.contains(Edges.getEdges(size), p -> { //do not link to adjacent buildings !Structs.contains(Edges.getEdges(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);