fix: bombs are making NaN amount of damage

This commit is contained in:
minjaesong
2024-02-15 17:35:56 +09:00
parent 2363a5c51f
commit 84dcc95fc0
4 changed files with 64 additions and 15 deletions

View File

@@ -446,6 +446,7 @@ internal object BlocksDrawer {
}
val breakage = if (mode == TERRAIN || mode == ORES) world.getTerrainDamage(x, y) else if (mode == WALL) world.getWallDamage(x, y) else 0f
if (breakage.isNaN()) throw IllegalStateException("Block breakage at ($x, $y) is NaN (mode=$mode)")
val maxHealth = if (mode == TERRAIN || mode == ORES) BlockCodex[world.getTileFromTerrain(x, y)].strength else if (mode == WALL) BlockCodex[world.getTileFromWall(x, y)].strength else 1
val breakingStage = if (mode == TERRAIN || mode == WALL || mode == ORES) (breakage / maxHealth).coerceIn(0f, 1f).times(BREAKAGE_STEPS).roundToInt() else 0