Cleanup & bugfixes

This commit is contained in:
Anuken
2021-01-15 11:16:08 -05:00
parent 593a7b060c
commit a342a7d638
4 changed files with 20 additions and 32 deletions

View File

@@ -24,7 +24,7 @@ public class SectorDamage{
public static final int maxRetWave = 40, maxWavesSimulated = 50;
//direct damage is for testing only
private static final boolean direct = false, rubble = true;
private static final boolean rubble = true;
/** @return calculated capture progress of the enemy */
public static float getDamage(SectorInfo info){
@@ -225,7 +225,6 @@ public class SectorDamage{
//create sparse tile array for fast range query
int sparseSkip = 5, sparseSkip2 = 3;
//TODO if this is slow, use a quadtree
Seq<Tile> sparse = new Seq<>(path.size / sparseSkip + 1);
Seq<Tile> sparse2 = new Seq<>(path.size / sparseSkip2 + 1);
@@ -485,23 +484,21 @@ public class SectorDamage{
if(other.build != null && other.team() != state.rules.waveTeam){
resultDamage -= other.build.health();
if(direct){
other.build.damage(currDamage);
}else{ //indirect damage happens at game load time
other.build.health -= currDamage;
//don't kill the core!
if(other.block() instanceof CoreBlock) other.build.health = Math.max(other.build.health, 1f);
other.build.health -= currDamage;
//don't kill the core!
if(other.block() instanceof CoreBlock) other.build.health = Math.max(other.build.health, 1f);
//remove the block when destroyed
if(other.build.health < 0){
//rubble
if(rubble && !other.floor().solid && !other.floor().isLiquid && Mathf.chance(0.4)){
Effect.rubble(other.build.x, other.build.y, other.block().size);
}
other.build.addPlan(false);
other.remove();
//remove the block when destroyed
if(other.build.health < 0){
//rubble
if(rubble && !other.floor().solid && !other.floor().isLiquid && Mathf.chance(0.4)){
Effect.rubble(other.build.x, other.build.y, other.block().size);
}
other.build.addPlan(false);
other.remove();
}else{
indexer.notifyTileDamaged(other.build);
}
}else if(other.solid() && !other.synthetic()){ //skip damage propagation through solid blocks