Merge branch 'fix/aswid-eclipse'

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

View file

@ -887,23 +887,34 @@ 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
if (EnvMan.instance != null) // 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
{ {
HarmonyLib.Traverse.Create(EnvMan.instance).Field("m_debugTime").SetValue(true); if (EnvMan.instance != null)
HarmonyLib.Traverse.Create(EnvMan.instance).Field("m_debugTimeOfDay").SetValue(0.5f); // Midnight {
EnvMan.instance.m_debugTime = 0f;
EnvMan.instance.m_debugTimeOfDay = true;
}
yield return new WaitForSeconds(AswidConfig.EclipseDuration.Value);
}
finally
{
// 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;
} }
yield return new WaitForSeconds(AswidConfig.EclipseDuration.Value); if (Player.m_localPlayer != null)
// Revert to server time
if (EnvMan.instance != null)
{ {
HarmonyLib.Traverse.Create(EnvMan.instance).Field("m_debugTime").SetValue(false); Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The Eclipse has ended.");
} }
IsEclipseActive = false;
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The Eclipse has ended.");
} }
private float damageTickTimer = 0f; private float damageTickTimer = 0f;