mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 04:54:05 +09:00
fix: damaging terrain would not queue the modified chunk for the autosave
This commit is contained in:
@@ -644,7 +644,7 @@ open class GameWorld(
|
||||
/**
|
||||
* @return ItemID of the broken block AND ore if the block is broken, `null` otherwise
|
||||
*/
|
||||
fun inflictTerrainDamage(x: Int, y: Int, damage: Double): Pair<ItemID?, ItemID?> {
|
||||
fun inflictTerrainDamage(x: Int, y: Int, damage: Double, bypassEvent: Boolean): Pair<ItemID?, ItemID?> {
|
||||
if (damage.isNaN()) throw IllegalArgumentException("Cannot inflict NaN amount of damage at($x, $y)")
|
||||
|
||||
val damage = damage.toFloat()
|
||||
@@ -662,6 +662,10 @@ open class GameWorld(
|
||||
terrainDamages[addr] = terrainDamages[addr]!! + damage
|
||||
}
|
||||
|
||||
if (!bypassEvent) {
|
||||
Terrarum.ingame?.modified(LandUtil.LAYER_TERR, x, y)
|
||||
}
|
||||
|
||||
//println("[GameWorld] accumulated damage: ${terrainDamages[addr]}")
|
||||
|
||||
// remove tile from the world
|
||||
@@ -681,7 +685,7 @@ open class GameWorld(
|
||||
/**
|
||||
* @return true if block is broken
|
||||
*/
|
||||
fun inflictWallDamage(x: Int, y: Int, damage: Double): ItemID? {
|
||||
fun inflictWallDamage(x: Int, y: Int, damage: Double, bypassEvent: Boolean): ItemID? {
|
||||
if (damage.isNaN()) throw IllegalArgumentException("Cannot inflict NaN amount of damage at($x, $y)")
|
||||
|
||||
val damage = damage.toFloat()
|
||||
@@ -697,6 +701,10 @@ open class GameWorld(
|
||||
wallDamages[addr] = wallDamages[addr]!! + damage
|
||||
}
|
||||
|
||||
if (!bypassEvent) {
|
||||
Terrarum.ingame?.modified(LandUtil.LAYER_TERR, x, y)
|
||||
}
|
||||
|
||||
// remove tile from the world
|
||||
if (wallDamages[addr]!! >= BlockCodex[getTileFromWall(x, y)].strength) {
|
||||
val tileBroke = getTileFromWall(x, y)
|
||||
|
||||
Reference in New Issue
Block a user