From 8535b0ce1344ad51dda1c16cf3cebe2175a9c256 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Wed, 23 Aug 2023 13:01:20 +0900 Subject: [PATCH] forgot to enable the initial clouds spawning --- .../mods/basegame/weathers/WeatherGeneric.json | 2 +- .../terrarum/weather/BaseModularWeather.kt | 2 +- .../torvald/terrarum/weather/WeatherMixer.kt | 18 +++++++----------- .../terrarum/weather/WeatherObjectCloud.kt | 2 +- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/assets/mods/basegame/weathers/WeatherGeneric.json b/assets/mods/basegame/weathers/WeatherGeneric.json index f13a66fd7..10c13b3ae 100644 --- a/assets/mods/basegame/weathers/WeatherGeneric.json +++ b/assets/mods/basegame/weathers/WeatherGeneric.json @@ -5,7 +5,7 @@ "cloudChance": 133, "cloudGamma": [0.48, 1.8], "cloudGammaVariance": [0.1, 0.1], - "cloudDriftSpeed": 20.16, + "windSpeed": 0.16, "clouds": { "cumulonimbus": { "filename": "cloud_large.png", "tw": 2048, "th": 1024, "probability": 0.25, diff --git a/src/net/torvald/terrarum/weather/BaseModularWeather.kt b/src/net/torvald/terrarum/weather/BaseModularWeather.kt index 104fd72fb..53357cc55 100644 --- a/src/net/torvald/terrarum/weather/BaseModularWeather.kt +++ b/src/net/torvald/terrarum/weather/BaseModularWeather.kt @@ -18,7 +18,7 @@ data class BaseModularWeather( val daylightClut: GdxColorMap, val classification: String, val cloudChance: Float, - val cloudDriftSpeed: Float, + val windSpeed: Float, val cloudGamma: Vector2, val cloudGammaVariance: Vector2, var clouds: List, // sorted by CloudProps.probability diff --git a/src/net/torvald/terrarum/weather/WeatherMixer.kt b/src/net/torvald/terrarum/weather/WeatherMixer.kt index a530922c7..f00a9a5f0 100644 --- a/src/net/torvald/terrarum/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/weather/WeatherMixer.kt @@ -18,10 +18,7 @@ import net.torvald.terrarum.gameworld.GameWorld import net.torvald.terrarum.gameworld.WorldTime import net.torvald.terrarum.gameworld.WorldTime.Companion.DAY_LENGTH import net.torvald.terrarum.RNGConsumer -import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED import net.torvald.terrarum.clut.Skybox -import net.torvald.terrarum.gameactors.Hitbox -import net.torvald.terrarum.spriteassembler.ADPropertyObject import net.torvald.terrarum.utils.JsonFetcher import net.torvald.terrarum.utils.forEachSiblings import net.torvald.terrarum.weather.WeatherObjectCloud.Companion.ALPHA_ROLLOFF_Z @@ -32,7 +29,6 @@ import java.io.File import java.io.FileFilter import java.lang.Double.doubleToLongBits import java.lang.Math.toDegrees -import java.util.* import kotlin.collections.ArrayList import kotlin.collections.HashMap import kotlin.math.absoluteValue @@ -155,7 +151,7 @@ internal object WeatherMixer : RNGConsumer { // initialise try { - weatherList["titlescreen"] = arrayListOf(weatherList[WEATHER_GENERIC]!![0].copy(cloudDriftSpeed = 1f)) + weatherList["titlescreen"] = arrayListOf(weatherList[WEATHER_GENERIC]!![0].copy(windSpeed = 1f)) currentWeather = weatherList[WEATHER_GENERIC]!![0] nextWeather = getRandomWeather(WEATHER_GENERIC) } @@ -223,7 +219,7 @@ internal object WeatherMixer : RNGConsumer { camDelta.set(testCamDelta) - val cloudChanceEveryMin = 60f / (currentWeather.cloudChance * currentWeather.cloudDriftSpeed) // if chance = 0, the result will be +inf + val cloudChanceEveryMin = 60f / (currentWeather.cloudChance * currentWeather.windSpeed) // if chance = 0, the result will be +inf while (cloudUpdateAkku >= cloudChanceEveryMin) { cloudUpdateAkku -= cloudChanceEveryMin @@ -238,7 +234,7 @@ internal object WeatherMixer : RNGConsumer { it.posY += camDelta.y * cloudParallaxMultY - it.update(cloudDriftVector, currentWeather.cloudDriftSpeed) + it.update(cloudDriftVector, currentWeather.windSpeed) if (it.life == 0) immDespawnCount += 1 } @@ -300,7 +296,7 @@ internal object WeatherMixer : RNGConsumer { val rl = (windVectorDir % 1f).let { if (it < 0.5f) -it else it - 1f } val rh = 1f + (windVectorDir % 1f).let { if (it < 0.5f) it else 1f - it } val rr = windVectorDir + takeUniformRand(rl..rh) - println("${windVectorDir + rl}..${windVectorDir + rh} / $rr") +// printdbg(this, "${windVectorDir + rl}..${windVectorDir + rh} / $rr") val Z_LIM = ALPHA_ROLLOFF_Z/2f return when (rr.toInt()) { 0, 4 -> { // right side of the screen @@ -388,7 +384,7 @@ internal object WeatherMixer : RNGConsumer { } private fun initClouds() { - /*val hCloudSize = 1024f + val hCloudSize = 1024f repeat((currentWeather.cloudChance * 3.3f).ceilToInt()) { // multiplier is an empirical value that depends on the 'rZ' val posXscr = FastMath.interpolateLinear(takeUniformRand(0f..1f), -hCloudSize, App.scr.width + hCloudSize) @@ -396,7 +392,7 @@ internal object WeatherMixer : RNGConsumer { val x = WeatherObjectCloud.screenXtoWorldX(posXscr, z) tryToSpawnCloud(currentWeather, Vector3(x, 0f, z)) - }*/ + } } internal fun titleScreenInitWeather() { @@ -690,7 +686,7 @@ internal object WeatherMixer : RNGConsumer { daylightClut = daylight, classification = classification, cloudChance = JSON.getFloat("cloudChance"), - cloudDriftSpeed = JSON.getFloat("cloudDriftSpeed"), + windSpeed = JSON.getFloat("windSpeed"), cloudGamma = JSON["cloudGamma"].asFloatArray().let { Vector2(it[0], it[1]) }, cloudGammaVariance = JSON["cloudGammaVariance"].asFloatArray().let { Vector2(it[0], it[1]) }, clouds = cloudsMap, diff --git a/src/net/torvald/terrarum/weather/WeatherObjectCloud.kt b/src/net/torvald/terrarum/weather/WeatherObjectCloud.kt index 0f24bcea6..576aaddcd 100644 --- a/src/net/torvald/terrarum/weather/WeatherObjectCloud.kt +++ b/src/net/torvald/terrarum/weather/WeatherObjectCloud.kt @@ -37,7 +37,7 @@ class WeatherObjectCloud(private val texture: TextureRegion, private val flipW: alpha = if (posZ < 1f) posZ.pow(0.5f) else -(posZ / ALPHA_ROLLOFF_Z) + 1f val lrCoord = screenCoordBottomLRforDespawnCalculation - if (lrCoord.x > WeatherMixer.oobMarginR || lrCoord.z < WeatherMixer.oobMarginL || posZ !in 0.05f..ALPHA_ROLLOFF_Z + 1f || alpha < 0f) { + if (lrCoord.x > WeatherMixer.oobMarginR || lrCoord.z < WeatherMixer.oobMarginL || posZ !in 0.0001f..ALPHA_ROLLOFF_Z + 1f || alpha < 0f) { flagToDespawn = true } else {