mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 12:34:05 +09:00
fluid multiplies themselves ?!
This commit is contained in:
@@ -380,7 +380,7 @@ open class GameWorld {
|
||||
else {
|
||||
//printdbg(this, "> Setting nonzero ($fill) on ($x,$y)")
|
||||
|
||||
setTileTerrain(x, y, Block.WATER) // this function alters fluid list, must be called first // TODO fluidType aware
|
||||
setTileTerrain(x, y, fluidTypeToBlock(fluidType)) // this function alters fluid list, must be called first // TODO fluidType aware
|
||||
fluidTypes[addr] = fluidType
|
||||
fluidFills[addr] = fill
|
||||
}
|
||||
@@ -401,6 +401,12 @@ open class GameWorld {
|
||||
return if (type == null) FluidInfo(Fluid.NULL, 0f) else FluidInfo(type, fill!!)
|
||||
}
|
||||
|
||||
private fun fluidTypeToBlock(type: FluidType) = when (type.abs()) {
|
||||
Fluid.NULL.value -> Block.AIR
|
||||
in Fluid.fluidRange -> GameWorld.TILES_SUPPORTED - type.abs()
|
||||
else -> throw IllegalArgumentException("Unsupported fluid type: $type")
|
||||
}
|
||||
|
||||
data class FluidInfo(val type: FluidType, val amount: Float) {
|
||||
override fun toString() = "Fluid type: ${type.value}, amount: $amount"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user