removed FLUID prop from the blocks

This commit is contained in:
Minjae Song
2018-12-29 21:04:27 +09:00
parent 59531ea1ba
commit 3765678735
11 changed files with 210 additions and 145 deletions

View File

@@ -1,9 +1,29 @@
package net.torvald.terrarum.gameworld
import net.torvald.terrarum.blockproperties.Fluid
/**
* Created by minjaesong on 2016-08-06.
*/
object FluidCodex {
const val FLUID_LAVA = 0xFE.toByte()
const val FLUID_WATER = 0xFF.toByte()
}
operator fun get(type: FluidType): FluidProp {
return if (type sameAs Fluid.NULL)
nullProp
else
waterProp
}
// TODO temporary, should read from CSV
val nullProp = FluidProp.getNullProp()
val waterProp = FluidProp()
init {
waterProp.shadeColR = 0.1016f
waterProp.shadeColG = 0.0744f
waterProp.shadeColB = 0.0508f
waterProp.shadeColA = 0.0508f
waterProp.density = 1000
}
}

View File

@@ -0,0 +1,48 @@
package net.torvald.terrarum.gameworld
import com.badlogic.gdx.graphics.Color
import net.torvald.terrarum.blockproperties.Block
import net.torvald.terrarum.blockproperties.BlockCodex
import net.torvald.terrarum.blockproperties.BlockPropUtil
/**
* Created by minjaesong on 2018-12-29.
*/
class FluidProp {
var density: Int = 0
var dynamicLuminosityFunction: Int = 0
/** 1.0f for 1023, 0.25f for 255 */
var shadeColR = 0f
var shadeColG = 0f
var shadeColB = 0f
var shadeColA = 0f
/** 1.0f for 1023, 0.25f for 255 */
var lumColR = 0f
var lumColG = 0f
var lumColB = 0f
var lumColA = 0f
inline val opacity: Color
get() = Color(shadeColR, shadeColG, shadeColB, shadeColA)
inline val luminosity: Color
get() = BlockPropUtil.getDynamicLumFunc(Color(lumColR, lumColG, lumColB, lumColA), dynamicLuminosityFunction)
companion object {
fun getNullProp(): FluidProp {
val p = FluidProp()
p.shadeColR = BlockCodex[Block.AIR].shadeColR
p.shadeColG = BlockCodex[Block.AIR].shadeColG
p.shadeColB = BlockCodex[Block.AIR].shadeColB
p.shadeColA = BlockCodex[Block.AIR].shadeColA
return p
}
}
}

View File

@@ -224,7 +224,7 @@ open class GameWorld {
val blockAddr = LandUtil.getBlockAddr(this, x, y)
terrainDamages.remove(blockAddr)
if (!BlockCodex[tile * PairedMapLayer.RANGE + damage].isFluid) {
if (BlockCodex[tile * PairedMapLayer.RANGE + damage].isSolid) {
fluidFills.remove(blockAddr)
fluidTypes.remove(blockAddr)
}
@@ -374,10 +374,6 @@ open class GameWorld {
fluidFills.remove(addr)
fluidTypes.remove(addr)
// if old tile was fluid
if (BlockCodex[getTileFromTerrain(x, y) ?: Block.STONE].isFluid) {
//setTileTerrain(x, y, Block.AIR)
}
}
@@ -404,6 +400,7 @@ open class GameWorld {
data class FluidInfo(val type: FluidType, val amount: Float) {
/** test if this fluid should be considered as one */
fun isFluid() = type != Fluid.NULL && amount >= WorldSimulator.FLUID_MIN_MASS
fun getProp() = FluidCodex[type]
override fun toString() = "Fluid type: ${type.value}, amount: $amount"
}