From 96af39ab4ab153311705beff7c61aae4ae57a5e9 Mon Sep 17 00:00:00 2001 From: minjaesong Date: Fri, 1 Sep 2023 00:50:24 +0900 Subject: [PATCH] changing the way weatherbox gets updated --- .../torvald/terrarum/ui/BasicDebugInfoWindow.kt | 11 ++++++++--- src/net/torvald/terrarum/weather/WeatherMixer.kt | 4 ++-- src/net/torvald/terrarum/weather/Weatherbox.kt | 14 +++++++++----- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt index 7e2d9d3eb..48e57847a 100644 --- a/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt +++ b/src/net/torvald/terrarum/ui/BasicDebugInfoWindow.kt @@ -348,6 +348,7 @@ class BasicDebugInfoWindow : UICanvas() { private val colHairline = Color(0xf22100ff.toInt()) private val colGraph = Toolkit.Theme.COL_SELECTED + private val colGrapi = Toolkit.Theme.COL_SELECTED.cpy().mul(0.5f, 0.5f, 0.5f, 1f) private val colGraphBack = Toolkit.Theme.COL_CELL_FILL private val colGraphFore = Color(1f, 1f, 1f, 0.5f) private val colGraphForf = Color(1f, 1f, 1f, 0.25f) @@ -424,19 +425,22 @@ class BasicDebugInfoWindow : UICanvas() { } val pys2 = (0 until xw).map { val px = it.toFloat() / xw - bh - (bh * WeatherStateBox.interpolate(px, box.p1, box.p2, box.p3, box.p4) / ymax).toFloat() + bh - (bh * WeatherStateBox.interpolate(px, box.p1, box.p2, box.p3, box.p3) / ymax).toFloat() } val pys3 = (0 until xw).map { val px = it.toFloat() / xw - bh - (bh * WeatherStateBox.interpolate(px, box.p2, box.p3, box.p4, box.p5) / ymax).toFloat() + bh - (bh * WeatherStateBox.interpolate(px, box.p2, box.p3, box.p3, box.p3) / ymax).toFloat() } - val pys = pysM1 + pys0 + pys1 + pys2 + pys3 + box.p4 + val pys = pysM1 + pys0 + pys1 + pys2 + pys3 + box.p3 // interpolated values it.color = colGraph val xis = xi + (xw / 2) for (index in xis until xis + bw - 1) { + + if (index == xw * 3) it.color = colGrapi // uncertain points will get darker + val px = x - xis + index + 1f it.rectLine( px, @@ -452,6 +456,7 @@ class BasicDebugInfoWindow : UICanvas() { if (box.x < 0.5) it.circle(x + (GRAPH_CW * 0.5f) - xi, App.scr.hf - 1 - (y + bh-(box.p0 * bh / ymax).toFloat()), 2.5f) it.circle(x + (GRAPH_CW * 1.5f) - xi, App.scr.hf - 1 - (y + bh-(box.p1 * bh / ymax).toFloat()), 2.5f) it.circle(x + (GRAPH_CW * 2.5f) - xi, App.scr.hf - 1 - (y + bh-(box.p2 * bh / ymax).toFloat()), 2.5f) + it.color = colGrapi if (box.x > 0.5) it.circle(x + (GRAPH_CW * 3.5f) - xi, App.scr.hf - 1 - (y + bh-(box.p3 * bh / ymax).toFloat()), 2.5f) } diff --git a/src/net/torvald/terrarum/weather/WeatherMixer.kt b/src/net/torvald/terrarum/weather/WeatherMixer.kt index 12e449c42..baf2a5fd0 100644 --- a/src/net/torvald/terrarum/weather/WeatherMixer.kt +++ b/src/net/torvald/terrarum/weather/WeatherMixer.kt @@ -139,7 +139,7 @@ internal object WeatherMixer : RNGConsumer { weatherbox.windDir.p1 = it[2] weatherbox.windDir.p2 = it[3] weatherbox.windDir.p3 = it[4] - weatherbox.windDir.p4 = it[5] +// weatherbox.windDir.p4 = it[5] } (0..5).map { takeUniformRand(-1f..1f) }.let { weatherbox.windSpeed.pM1 = currentWeather.getRandomWindSpeed(it[0]) @@ -147,7 +147,7 @@ internal object WeatherMixer : RNGConsumer { weatherbox.windSpeed.p1 = currentWeather.getRandomWindSpeed(it[2]) weatherbox.windSpeed.p2 = currentWeather.getRandomWindSpeed(it[3]) weatherbox.windSpeed.p3 = currentWeather.getRandomWindSpeed(it[4]) - weatherbox.windSpeed.p4 = currentWeather.getRandomWindSpeed(it[5]) +// weatherbox.windSpeed.p4 = currentWeather.getRandomWindSpeed(it[5]) } } diff --git a/src/net/torvald/terrarum/weather/Weatherbox.kt b/src/net/torvald/terrarum/weather/Weatherbox.kt index 94531228a..aeed4a1f3 100644 --- a/src/net/torvald/terrarum/weather/Weatherbox.kt +++ b/src/net/torvald/terrarum/weather/Weatherbox.kt @@ -17,9 +17,10 @@ data class WeatherStateBox( var p1: Float = 0f, var p2: Float = 0f, var p3: Float = 0f, - var p4: Float = 0f, - var p5: Float = 0f, +// var p4: Float = 0f, +// var p5: Float = 0f, // pM1 and p4 only exists for the sake of better weather forecasting + // - removing p4 and beyond: for faster response to the changing weather schedule and make the forecasting less accurate like irl ) { fun get() = interpolate(x, p0, p1, p2, p3) @@ -35,9 +36,12 @@ data class WeatherStateBox( p0 = p1 p1 = p2 p2 = p3 - p3 = p4 - p4 = p5 - p5 = next() + p3 = next() + + +// p3 = p4 +// p4 = p5 +// p5 = next() } return y }