From 055635d1b43c6b7c061c8a243c947491f4f30346 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 19:16:08 +0200 Subject: [PATCH] feat(aswid): Eclipse runs the sky through dusk instead of cutting to night While EnvMan's debug time is on it copies the value straight onto the sky, so setting midnight in one go made night fall in a single frame. The clock now eases forward from the current hour to midnight over 3.5 seconds. The dawn already eased back on its own, because EnvMan smooths towards the real time once the switch is off. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Aswid/AswidRace.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index b3612bc..7a7543f 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -863,6 +863,9 @@ namespace RacesOfValheim StartCoroutine(EclipseRoutine()); } + /// How long the sky takes to run from the cast to midnight. + private const float EclipseDuskSeconds = 3.5f; + private System.Collections.IEnumerator EclipseRoutine() { IsEclipseActive = true; @@ -897,8 +900,22 @@ namespace RacesOfValheim { if (EnvMan.instance != null) { - EnvMan.instance.m_debugTime = 0f; + // Run the clock forward through dusk to midnight rather than cutting to it. + // While m_debugTimeOfDay is on, EnvMan copies m_debugTime straight onto the sky + // with no smoothing of its own, so the easing has to happen here. Forward means + // up to 1, which is midnight again; the Aswid's night buffs start at 0.75, + // partway through. The way back needs nothing: once the switch is off, EnvMan + // eases towards the real time by itself. + float from = EnvMan.instance.GetDayFraction(); + EnvMan.instance.m_debugTime = from; EnvMan.instance.m_debugTimeOfDay = true; + + for (float t = 0f; t < EclipseDuskSeconds && EnvMan.instance != null; t += Time.deltaTime) + { + EnvMan.instance.m_debugTime = Mathf.Lerp(from, 1f, Mathf.SmoothStep(0f, 1f, t / EclipseDuskSeconds)); + yield return null; + } + if (EnvMan.instance != null) EnvMan.instance.m_debugTime = 1f; } yield return new WaitForSeconds(AswidConfig.EclipseDuration.Value);