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);