Merge branch 'fix/aswid-eclipse'

This commit is contained in:
kanym 2026-09-26 19:14:14 +02:00
commit 0403b6a9df

View file

@ -887,24 +887,35 @@ namespace RacesOfValheim
yield return null; yield return null;
} }
// Force night client-side // Force night client-side. EnvMan's switch is the bool m_debugTimeOfDay and the time it
// pins is the float m_debugTime, a day fraction where 0 is midnight and 0.5 is noon.
// These two used to be written the other way round: handing a bool to the float threw,
// the coroutine died right after "An Eclipse descends...", and IsEclipseActive stayed
// true for the rest of the session, so every later press returned without a word.
// Public fields both, so no Traverse to get the names wrong through.
try
{
if (EnvMan.instance != null) if (EnvMan.instance != null)
{ {
HarmonyLib.Traverse.Create(EnvMan.instance).Field("m_debugTime").SetValue(true); EnvMan.instance.m_debugTime = 0f;
HarmonyLib.Traverse.Create(EnvMan.instance).Field("m_debugTimeOfDay").SetValue(0.5f); // Midnight EnvMan.instance.m_debugTimeOfDay = true;
} }
yield return new WaitForSeconds(AswidConfig.EclipseDuration.Value); yield return new WaitForSeconds(AswidConfig.EclipseDuration.Value);
}
// Revert to server time finally
if (EnvMan.instance != null)
{ {
HarmonyLib.Traverse.Create(EnvMan.instance).Field("m_debugTime").SetValue(false); // In a finally so that a throw in here can never again leave the ability locked.
// Unity does not dispose a coroutine it stops, so this does not cover that case.
if (EnvMan.instance != null) EnvMan.instance.m_debugTimeOfDay = false;
IsEclipseActive = false;
} }
IsEclipseActive = false; if (Player.m_localPlayer != null)
{
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The Eclipse has ended."); Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The Eclipse has ended.");
} }
}
private float damageTickTimer = 0f; private float damageTickTimer = 0f;