bugs on fluid sim, Type is NULL but fill isn't 0/new temporary fluid draw

This commit is contained in:
Minjae Song
2018-12-16 02:10:04 +09:00
parent 4aa9ad6b14
commit 8e6fcf0b8a
20 changed files with 64 additions and 98 deletions

View File

@@ -359,6 +359,11 @@ open class GameWorld {
}*/
if (fluidType == Fluid.NULL && fill != 0f) {
throw Error("Illegal fluid at ($x,$y): ${FluidInfo(fluidType, fill)}")
}
val addr = LandUtil.getBlockAddr(this, x, y)
// fluid completely drained
if (fill <= WorldSimulator.FLUID_MIN_MASS) {
@@ -396,7 +401,9 @@ open class GameWorld {
return if (type == null) FluidInfo(Fluid.NULL, 0f) else FluidInfo(type, fill!!)
}
data class FluidInfo(val type: FluidType, val amount: Float)
data class FluidInfo(val type: FluidType, val amount: Float) {
override fun toString() = "Fluid type: ${type.value}, amount: $amount"
}
fun getTemperature(worldTileX: Int, worldTileY: Int): Float? {