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 <noreply@anthropic.com>
This commit is contained in:
parent
0403b6a9df
commit
055635d1b4
1 changed files with 18 additions and 1 deletions
|
|
@ -863,6 +863,9 @@ namespace RacesOfValheim
|
|||
StartCoroutine(EclipseRoutine());
|
||||
}
|
||||
|
||||
/// <summary>How long the sky takes to run from the cast to midnight.</summary>
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue