More pattern matching
This commit is contained in:
@@ -906,7 +906,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
tempTiles.clear();
|
||||
Geometry.circle(tileX(), tileY(), range, (x, y) -> {
|
||||
Building other = world.build(x, y);
|
||||
if(other != null && other.block instanceof PowerNode && ((PowerNode)other.block).linkValid(other, self()) && !PowerNode.insulated(other, self())
|
||||
if(other != null && other.block instanceof PowerNode node && node.linkValid(other, self()) && !PowerNode.insulated(other, self())
|
||||
&& !other.proximity().contains(this.<Building>self()) &&
|
||||
!(block.outputsPower && proximity.contains(p -> p.power != null && p.power.graph == other.power.graph))){
|
||||
tempTiles.add(other.tile);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ConstructBlock extends Block{
|
||||
if(tile == null) return;
|
||||
|
||||
float healthf = tile.build == null ? 1f : tile.build.healthf();
|
||||
Seq<Building> prev = tile.build instanceof ConstructBuild ? ((ConstructBuild)tile.build).prevBuild : null;
|
||||
Seq<Building> prev = tile.build instanceof ConstructBuild co ? co.prevBuild : null;
|
||||
|
||||
tile.setBlock(block, team, rotation);
|
||||
|
||||
|
||||
@@ -92,8 +92,8 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
@Override
|
||||
public boolean rotatedOutput(int x, int y){
|
||||
Building tile = world.build(x, y);
|
||||
if(tile instanceof StackConveyorBuild){
|
||||
return ((StackConveyorBuild)tile).state != stateUnload;
|
||||
if(tile instanceof StackConveyorBuild s){
|
||||
return s.state != stateUnload;
|
||||
}
|
||||
return super.rotatedOutput(x, y);
|
||||
}
|
||||
|
||||
@@ -246,9 +246,9 @@ public class PowerNode extends PowerBlock{
|
||||
public boolean linkValid(Building tile, Building link, boolean checkMaxNodes){
|
||||
if(tile == link || link == null || !link.block.hasPower || tile.team != link.team) return false;
|
||||
|
||||
if(overlaps(tile, link, laserRange * tilesize) || (link.block instanceof PowerNode && overlaps(link, tile, ((PowerNode)link.block).laserRange * tilesize))){
|
||||
if(checkMaxNodes && link.block instanceof PowerNode){
|
||||
return link.power.links.size < ((PowerNode)link.block).maxNodes || link.power.links.contains(tile.pos());
|
||||
if(overlaps(tile, link, laserRange * tilesize) || (link.block instanceof PowerNode node && overlaps(link, tile, node.laserRange * tilesize))){
|
||||
if(checkMaxNodes && link.block instanceof PowerNode node){
|
||||
return link.power.links.size < node.maxNodes || link.power.links.contains(tile.pos());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user