More pattern matching

This commit is contained in:
Anuken
2021-01-15 16:04:26 -05:00
parent 650d47991e
commit 718a40d742
4 changed files with 7 additions and 7 deletions
@@ -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;
}