Allow for dynamic laser absorption and insulation (#5047)
* Allow for dynamic laser absorption * Might as well do insulated as well * null checks are important
This commit is contained in:
@@ -108,7 +108,7 @@ public class Damage{
|
||||
furthest = null;
|
||||
|
||||
boolean found = world.raycast(b.tileX(), b.tileY(), World.toTile(b.x + Tmp.v1.x), World.toTile(b.y + Tmp.v1.y),
|
||||
(x, y) -> (furthest = world.tile(x, y)) != null && furthest.team() != b.team && furthest.block().absorbLasers);
|
||||
(x, y) -> (furthest = world.tile(x, y)) != null && furthest.team() != b.team && (furthest.build != null && furthest.build.absorbLasers()));
|
||||
|
||||
return found && furthest != null ? Math.max(6f, b.dst(furthest.worldx(), furthest.worldy())) : length;
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class Lightning{
|
||||
world.raycastEach(World.toTile(from.getX()), World.toTile(from.getY()), World.toTile(to.getX()), World.toTile(to.getY()), (wx, wy) -> {
|
||||
|
||||
Tile tile = world.tile(wx, wy);
|
||||
if(tile != null && tile.block().insulated && tile.team() != team){
|
||||
if(tile != null && (tile.build != null && tile.build.isInsulated()) && tile.team() != team){
|
||||
bhit = true;
|
||||
//snap it instead of removing
|
||||
lines.get(lines.size - 1).set(wx * tilesize, wy * tilesize);
|
||||
|
||||
@@ -1241,6 +1241,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
||||
return amount;
|
||||
}
|
||||
|
||||
public boolean absorbLasers(){
|
||||
return block.absorbLasers;
|
||||
}
|
||||
|
||||
public boolean isInsulated(){
|
||||
return block.insulated;
|
||||
}
|
||||
|
||||
public boolean collide(Bullet other){
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ public class PowerNode extends PowerBlock{
|
||||
public static boolean insulated(int x, int y, int x2, int y2){
|
||||
return world.raycast(x, y, x2, y2, (wx, wy) -> {
|
||||
Building tile = world.build(wx, wy);
|
||||
return tile != null && tile.block.insulated;
|
||||
return tile != null && tile.isInsulated();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user