mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
newborn clouds will fade-in
This commit is contained in:
@@ -22,6 +22,7 @@ import net.torvald.terrarum.clut.Skybox
|
||||
import net.torvald.terrarum.utils.JsonFetcher
|
||||
import net.torvald.terrarum.utils.forEachSiblings
|
||||
import net.torvald.terrarum.weather.WeatherObjectCloud.Companion.ALPHA_ROLLOFF_Z
|
||||
import net.torvald.terrarum.weather.WeatherObjectCloud.Companion.NEWBORN_GROWTH_TIME
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import net.torvald.util.SortedArrayList
|
||||
@@ -391,7 +392,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
}
|
||||
|
||||
private fun tryToSpawnCloud(currentWeather: BaseModularWeather, precalculatedPos: Vector3? = null) {
|
||||
private fun tryToSpawnCloud(currentWeather: BaseModularWeather, precalculatedPos: Vector3? = null, ageOverride: Int = 0) {
|
||||
// printdbg(this, "Trying to spawn a cloud... (${cloudsSpawned} / ${cloudSpawnMax})")
|
||||
|
||||
if (cloudsSpawned < cloudSpawnMax) {
|
||||
@@ -444,6 +445,8 @@ internal object WeatherMixer : RNGConsumer {
|
||||
it.pos.y = takeUniformRand(-cloud.altHigh..-cloud.altLow) * scrHscaler
|
||||
}
|
||||
|
||||
it.life = ageOverride
|
||||
|
||||
clouds.add(it)
|
||||
cloudsSpawned += 1
|
||||
|
||||
@@ -468,7 +471,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
val x = WeatherObjectCloud.screenXtoWorldX(takeUniformRand(0f..App.scr.wf), zz)
|
||||
|
||||
|
||||
tryToSpawnCloud(currentWeather, Vector3(x, 0f, z))
|
||||
tryToSpawnCloud(currentWeather, Vector3(x, 0f, z), NEWBORN_GROWTH_TIME.toInt())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -753,23 +756,6 @@ internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var mixFrom: String?
|
||||
try { mixFrom = JSON.getString("mixFrom") }
|
||||
catch (e: IllegalArgumentException) { mixFrom = null }
|
||||
|
||||
|
||||
|
||||
var mixPercentage: Double?
|
||||
try { mixPercentage = JSON.getDouble("mixPercentage") }
|
||||
catch (e: IllegalArgumentException) { mixPercentage = null }
|
||||
|
||||
|
||||
|
||||
return BaseModularWeather(
|
||||
identifier = identifier,
|
||||
json = JSON,
|
||||
|
||||
@@ -26,7 +26,7 @@ class WeatherObjectCloud(
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
var life = 0; private set
|
||||
var life = 0
|
||||
var despawnCode = ""; private set
|
||||
|
||||
private val lifespan = 40000 + ((Math.random() + Math.random()) * 20000).roundToInt() // triangular distibution of 40000..80000
|
||||
@@ -49,7 +49,14 @@ class WeatherObjectCloud(
|
||||
|
||||
eigenAlpha = if (posZ < 1f) posZ.pow(0.5f) else -((posZ - 1f) / ALPHA_ROLLOFF_Z) + 1f
|
||||
|
||||
alpha = eigenAlpha * if (life < lifespan) 1f else 1f - (life - lifespan) / OLD_AGE_DECAY
|
||||
val alphaMult = if (life < NEWBORN_GROWTH_TIME)
|
||||
life / NEWBORN_GROWTH_TIME
|
||||
else if (life < lifespan)
|
||||
1f
|
||||
else
|
||||
1f - (life - lifespan) / OLD_AGE_DECAY
|
||||
|
||||
alpha = eigenAlpha * alphaMult
|
||||
|
||||
|
||||
val lrCoord = screenCoordBottomLRforDespawnCalculation
|
||||
@@ -173,7 +180,8 @@ class WeatherObjectCloud(
|
||||
fun worldYtoWorldZforScreenYof0(y: Float) = 1f - (y / H) // rearrange screenCoord equations to derive this eq :p
|
||||
|
||||
const val ALPHA_ROLLOFF_Z = 64f
|
||||
const val OLD_AGE_DECAY = 4000f
|
||||
const val OLD_AGE_DECAY = 5000f
|
||||
const val NEWBORN_GROWTH_TIME = 1000f
|
||||
|
||||
val RGB_GAMMA_TABLE = floatArrayOf(
|
||||
0.2f,
|
||||
|
||||
Reference in New Issue
Block a user