working lava pool prototype

This commit is contained in:
minjaesong
2024-09-08 01:51:40 +09:00
parent 11cdcbe2fc
commit 56c12949f8
8 changed files with 276 additions and 21 deletions

View File

@@ -50,7 +50,6 @@ object WorldSimulator {
const val FLUID_MAX_COMP = 0.02f // How much excess water a cell can store, compared to the cell above it. A tile of fluid can contain more than MaxMass water.
// const val FLUID_MIN_MASS = net.torvald.terrarum.gameworld.FLUID_MIN_MASS //Ignore cells that are almost dry (smaller than epsilon of float16)
const val minFlow = 1f / 512f
const val maxSpeed = 1f // max units of water moved out of one block to another, per timestamp
// END OF FLUID-RELATED STUFFS
@@ -348,6 +347,8 @@ object WorldSimulator {
val worldY = y + updateYFrom
val remainingType = fluidTypeMap[y][x]
val maxSpeed = 1f / FluidCodex[remainingType].viscosity.sqr()
// check solidity
if (!isFlowable(remainingType, worldX, worldY)) continue
// check if the fluid is a same kind
@@ -386,7 +387,7 @@ object WorldSimulator {
if (flow > minFlow) {
flow *= 0.5f
}
flow = flow.coerceIn(0f, remainingMass)
flow = flow.coerceIn(0f, min(maxSpeed, remainingMass))
fluidNewMap[y][x] -= flow
fluidNewMap[y][x - 1] += flow
@@ -406,7 +407,7 @@ object WorldSimulator {
if (flow > minFlow) {
flow *= 0.5f
}
flow = flow.coerceIn(0f, remainingMass)
flow = flow.coerceIn(0f, min(maxSpeed, remainingMass))
fluidNewMap[y][x] -= flow
fluidNewMap[y][x + 1] += flow

View File

@@ -38,4 +38,34 @@ class ItemBottomlessWaterBucket(originalID: ItemID) : GameItem(originalID) {
return -1L
}
}
}
/**
* Created by minjaesong on 2024-09-07.
*/
class ItemBottomlessLavaBucket(originalID: ItemID) : GameItem(originalID) {
override var baseToolSize: Double? = PickaxeCore.BASE_MASS_AND_SIZE
override var inventoryCategory = Category.TOOL
override val canBeDynamic = false
override val materialId = "CUPR"
override var baseMass = 2.0
override var equipPosition = HAND_GRIP
override var originalName = "ITEM_BOTTOMLESS_LAVA_BUCKET"
init {
stackable = false
isUnique = true
}
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long {
val mx = Terrarum.mouseTileX; val my =Terrarum.mouseTileY
if (!BlockCodex[INGAME.world.getTileFromTerrain(mx, my)].isSolid) {
INGAME.world.setFluid(mx, my, Fluid.LAVA, 1f)
return 0L
}
else {
return -1L
}
}
}

View File

@@ -256,10 +256,11 @@ interface TerragenParams {
val caveBlockageFractalFreq: Double
val caveBlockageSelectThre: Double // adjust cave closing-up strength. Lower = more closing
val rockBandCutoffFreq: Double
}
val lavaShapeFreg: Double }
data class TerragenParamsAlpha1(
override val terragenTiers: List<Double> = listOf(.0, .5, 1.0, 2.5, 11.0),
override val terragenTiers: List<Double> = listOf(.0, .5, 1.0, 2.5, 11.0 * 9999),
override val featureSize: Double = 333.0,
override val lowlandScaleOffset: Double = -0.65, // linearly alters the height
@@ -277,10 +278,12 @@ data class TerragenParamsAlpha1(
override val caveBlockageSelectThre: Double = 1.40, // adjust cave closing-up strength. Lower = more closing
override val rockBandCutoffFreq: Double = 4.0,
override val lavaShapeFreg: Double = 0.03,
) : TerragenParams
data class TerragenParamsAlpha2(
override val terragenTiers: List<Double> = listOf(.0, .5, 1.5, 3.75, 11.0),
override val terragenTiers: List<Double> = listOf(.0, .5, 1.5, 3.75, 11.0 * 9999),
override val featureSize: Double = 333.0,
override val lowlandScaleOffset: Double = -0.65, // linearly alters the height
@@ -298,4 +301,7 @@ data class TerragenParamsAlpha2(
override val caveBlockageSelectThre: Double = 1.40, // adjust cave closing-up strength. Lower = more closing
override val rockBandCutoffFreq: Double = 4.0,
override val lavaShapeFreg: Double = 0.03,
) : TerragenParams