mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 22:01:52 +09:00
removed FLUID prop from the blocks
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
package net.torvald.terrarum.blockproperties
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.utils.CSVFetcher
|
||||
import net.torvald.terrarum.gameworld.MapLayer
|
||||
import net.torvald.terrarum.gameworld.PairedMapLayer
|
||||
import net.torvald.terrarum.utils.CSVFetcher
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import org.apache.commons.csv.CSVRecord
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
/**
|
||||
@@ -108,7 +107,7 @@ object BlockCodex {
|
||||
prop.friction = intVal(record, "friction")
|
||||
prop.viscosity = intVal(record, "vscs")
|
||||
|
||||
prop.isFluid = boolVal(record, "fluid")
|
||||
//prop.isFluid = boolVal(record, "fluid")
|
||||
prop.isSolid = boolVal(record, "solid")
|
||||
prop.isClear = boolVal(record, "clear")
|
||||
prop.isWallable = boolVal(record, "wall")
|
||||
|
||||
@@ -27,7 +27,6 @@ class BlockProp {
|
||||
var density: Int = 0
|
||||
var viscosity: Int = 0
|
||||
|
||||
var isFluid: Boolean = false
|
||||
var isSolid: Boolean = false
|
||||
var isClear: Boolean = false
|
||||
var isWallable: Boolean = false
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.blockproperties
|
||||
|
||||
import net.torvald.terrarum.gameworld.FluidType
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-08-06.
|
||||
@@ -16,13 +15,6 @@ object Fluid {
|
||||
val LAVA = FluidType(2)
|
||||
val STATIC_LAVA = FluidType(-2)
|
||||
|
||||
val fluidTilesRange = 4094..4095 // MANUAL UPDATE
|
||||
val fluidRange = 1..2 // MANUAL UPDATE
|
||||
|
||||
|
||||
/**
|
||||
* Returns tile number in the main tile atlas. Water being 4095.
|
||||
*/
|
||||
fun getFluidTileFrom(type: FluidType) = GameWorld.TILES_SUPPORTED - type.abs()
|
||||
fun isThisTileFluid(tileid: Int) = tileid in fluidTilesRange
|
||||
val fluidRange = 1..2 // TODO MANUAL UPDATE
|
||||
}
|
||||
@@ -988,7 +988,7 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
|
||||
}
|
||||
|
||||
// evaluate
|
||||
if (BlockCodex[world!!.getTileFromTerrain(tileX, tileY)].isFluid) {
|
||||
if (world!!.getFluid(tileX, tileY).isFluid()) {
|
||||
contactAreaCounter += 1
|
||||
}
|
||||
}
|
||||
@@ -1177,10 +1177,10 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
|
||||
private inline val tileDensityFluid: Int
|
||||
get() {
|
||||
var density = 0
|
||||
forEachOccupyingTile {
|
||||
forEachOccupyingFluid {
|
||||
// get max density for each tile
|
||||
if (it?.isFluid ?: false && it?.density ?: 0 > density) {
|
||||
density = it?.density ?: 0
|
||||
if (it?.isFluid() ?: false && it?.getProp()?.density ?: 0 > density) {
|
||||
density = it?.getProp()?.density ?: 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1426,6 +1426,21 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
|
||||
return tileProps.forEach(consumer)
|
||||
}
|
||||
|
||||
private fun forEachOccupyingFluid(consumer: (GameWorld.FluidInfo?) -> Unit) {
|
||||
if (world == null) return
|
||||
|
||||
|
||||
val fluids = ArrayList<GameWorld.FluidInfo?>()
|
||||
|
||||
for (y in hIntTilewiseHitbox.startY.toInt()..hIntTilewiseHitbox.endY.toInt()) {
|
||||
for (x in hIntTilewiseHitbox.startX.toInt()..hIntTilewiseHitbox.endX.toInt()) {
|
||||
fluids.add(world!!.getFluid(x, y))
|
||||
}
|
||||
}
|
||||
|
||||
return fluids.forEach(consumer)
|
||||
}
|
||||
|
||||
private fun forEachOccupyingTilePos(hitbox: Hitbox, consumer: (BlockAddress) -> Unit) {
|
||||
if (world == null) return
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
48
src/net/torvald/terrarum/gameworld/FluidProp.kt
Normal file
48
src/net/torvald/terrarum/gameworld/FluidProp.kt
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.faction.FactionFactory
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.gameactors.faction.FactionFactory
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
@@ -82,7 +79,8 @@ object PlayerBuilderSigrid {
|
||||
Block.DAYLIGHT_CAPACITOR, Block.ICE_FRAGILE,
|
||||
Block.ILLUMINATOR_WHITE, Block.ILLUMINATOR_BLACK, Block.ILLUMINATOR_ORANGE,
|
||||
Block.ILLUMINATOR_GREEN, Block.ILLUMINATOR_CYAN, Block.SUNSTONE,
|
||||
Block.ORE_COPPER
|
||||
Block.ORE_COPPER,
|
||||
Block.PLATFORM_WOODEN
|
||||
)
|
||||
val walls = arrayOf(
|
||||
Block.AIR, Block.DIRT, Block.GLASS_CRUDE,
|
||||
|
||||
@@ -491,11 +491,8 @@ internal object BlocksDrawer {
|
||||
if (mode == FLUID) {
|
||||
writeToBuffer(mode, bufferX, bufferY, thisTileX, thisTileY, 0)
|
||||
}
|
||||
else if (!BlockCodex[thisTile].isFluid) {
|
||||
writeToBuffer(mode, bufferX, bufferY, thisTileX, thisTileY, breakingStage)
|
||||
}
|
||||
else {
|
||||
writeToBuffer(mode, bufferX, bufferY, 0, 0, 0)
|
||||
writeToBuffer(mode, bufferX, bufferY, thisTileX, thisTileY, breakingStage)
|
||||
}
|
||||
} catch (e: NullPointerException) {
|
||||
// do nothing. WARNING: This exception handling may hide erratic behaviour completely.
|
||||
@@ -580,10 +577,9 @@ internal object BlocksDrawer {
|
||||
|
||||
//return ret
|
||||
|
||||
val upTile = world.getTileFromTerrain(x , y - 1) ?: Block.NULL
|
||||
return if (ret == 15 || ret == 10)
|
||||
ret
|
||||
else if (world.getFluid(x, y-1).isFluid())
|
||||
else if (world.getFluid(x, y-1).isFluid()) // if tile above is a fluid
|
||||
0
|
||||
else
|
||||
1
|
||||
|
||||
@@ -5,12 +5,11 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.gameworld.PairedMapLayer
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.roundInt
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.gameworld.PairedMapLayer
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_TILES
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import java.io.BufferedOutputStream
|
||||
@@ -573,8 +572,8 @@ object BlocksDrawerOLD {
|
||||
var ret = 0
|
||||
for (i in 0..3) {
|
||||
try {
|
||||
if (!BlockCodex[nearbyTiles[i]].isSolid &&
|
||||
!BlockCodex[nearbyTiles[i]].isFluid) {
|
||||
if (!BlockCodex[nearbyTiles[i]].isSolid) {
|
||||
//&& !BlockCodex[nearbyTiles[i]].isFluid) {
|
||||
ret += (1 shl i) // add 1, 2, 4, 8 for i = 0, 1, 2, 3
|
||||
}
|
||||
} catch (e: ArrayIndexOutOfBoundsException) {
|
||||
|
||||
Reference in New Issue
Block a user