mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +09:00
water flow works
turns out, var.coerceIn() returns value and does not modify the var
This commit is contained in:
@@ -365,24 +365,20 @@ open class GameWorld {
|
||||
|
||||
|
||||
val addr = LandUtil.getBlockAddr(this, x, y)
|
||||
// fluid completely drained
|
||||
if (fill <= WorldSimulator.FLUID_MIN_MASS) {
|
||||
/**********/ fluidTypes.remove(addr)
|
||||
val oldMap = fluidFills.remove(addr)
|
||||
|
||||
// oldMap not being null means there actually was a fluid there, so we can put AIR onto it
|
||||
// otherwise, it means it was some solid and therefore we DON'T want to put AIR onto it
|
||||
if (oldMap != null) {
|
||||
setTileTerrain(x, y, 0)
|
||||
}
|
||||
}
|
||||
// update the fluid amount
|
||||
else {
|
||||
//printdbg(this, "> Setting nonzero ($fill) on ($x,$y)")
|
||||
|
||||
setTileTerrain(x, y, fluidTypeToBlock(fluidType)) // this function alters fluid list, must be called first // TODO fluidType aware
|
||||
fluidTypes[addr] = fluidType
|
||||
if (fill > WorldSimulator.FLUID_MIN_MASS) {
|
||||
setTileTerrain(x, y, fluidTypeToBlock(fluidType))
|
||||
fluidFills[addr] = fill
|
||||
fluidTypes[addr] = fluidType
|
||||
}
|
||||
else {
|
||||
fluidFills.remove(addr)
|
||||
fluidTypes.remove(addr)
|
||||
|
||||
// if old tile was fluid
|
||||
if (BlockCodex[getTileFromTerrain(x, y) ?: Block.STONE].isFluid) {
|
||||
setTileTerrain(x, y, Block.AIR)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -397,7 +393,6 @@ open class GameWorld {
|
||||
val addr = LandUtil.getBlockAddr(this, x, y)
|
||||
val fill = fluidFills[addr]
|
||||
val type = fluidTypes[addr]
|
||||
|
||||
return if (type == null) FluidInfo(Fluid.NULL, 0f) else FluidInfo(type, fill!!)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user