mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 06:13:36 +08:00
UXAssist: fix NightLight
This commit is contained in:
@@ -216,11 +216,35 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
|||||||
private static bool _mechaOnEarth;
|
private static bool _mechaOnEarth;
|
||||||
private static AnimationState _sail;
|
private static AnimationState _sail;
|
||||||
private static Light _sunlight;
|
private static Light _sunlight;
|
||||||
|
private static StarData _lastStar;
|
||||||
|
|
||||||
|
protected override void OnEnable()
|
||||||
|
{
|
||||||
|
GameLogic.OnGameEnd += GameMain_End_Postfix;
|
||||||
|
}
|
||||||
|
|
||||||
protected override void OnDisable()
|
protected override void OnDisable()
|
||||||
{
|
{
|
||||||
if (!_sunlight) return;
|
if (_sunlight)
|
||||||
|
{
|
||||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||||
|
_sunlight = null;
|
||||||
|
}
|
||||||
|
_lastStar = null;
|
||||||
|
_sail = null;
|
||||||
|
_nightlightInitialized = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void GameMain_End_Postfix()
|
||||||
|
{
|
||||||
|
if (_sunlight)
|
||||||
|
{
|
||||||
|
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||||
|
_sunlight = null;
|
||||||
|
}
|
||||||
|
_lastStar = null;
|
||||||
|
_sail = null;
|
||||||
|
_nightlightInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateSunlightAngle()
|
public static void UpdateSunlightAngle()
|
||||||
@@ -234,46 +258,38 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
|||||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.LateUpdate))]
|
[HarmonyPatch(typeof(GameMain), nameof(GameMain.LateUpdate))]
|
||||||
public static void GameMain_LateUpdate_Postfix(GameMain __instance)
|
public static void GameMain_LateUpdate_Postfix(GameMain __instance)
|
||||||
{
|
{
|
||||||
|
if (__instance.isMenuDemo || !__instance._running) return;
|
||||||
|
|
||||||
if (!_nightlightInitialized)
|
if (!_nightlightInitialized)
|
||||||
{
|
{
|
||||||
if (__instance.isMenuDemo || !__instance._running || !GameMain.mainPlayer.controller.model.gameObject.activeInHierarchy) return;
|
if (!GameMain.mainPlayer.controller.model.gameObject.activeInHierarchy) return;
|
||||||
if (_sail == null) _sail = GameMain.mainPlayer.animator.sails[GameMain.mainPlayer.animator.sailAnimIndex];
|
if (_sail == null) _sail = GameMain.mainPlayer.animator.sails[GameMain.mainPlayer.animator.sailAnimIndex];
|
||||||
_nightlightInitialized = true;
|
_nightlightInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sailing = _sail && _sail.enabled;
|
||||||
if (_mechaOnEarth)
|
if (_mechaOnEarth)
|
||||||
{
|
{
|
||||||
if (__instance.isMenuDemo || !GameMain.isRunning)
|
if (sailing)
|
||||||
{
|
{
|
||||||
_mechaOnEarth = false;
|
|
||||||
if (_sunlight != null)
|
|
||||||
{
|
|
||||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
|
||||||
_sunlight = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
_sail = null;
|
|
||||||
_nightlightInitialized = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_sail || !_sail.enabled) return;
|
|
||||||
_mechaOnEarth = false;
|
_mechaOnEarth = false;
|
||||||
if (!_sunlight) return;
|
if (!_sunlight) return;
|
||||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||||
_sunlight = null;
|
_sunlight = null;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (_sail && _sail.enabled) return;
|
else
|
||||||
if (!_sunlight)
|
|
||||||
{
|
{
|
||||||
var simu = GameMain.universeSimulator;
|
if (sailing) return;
|
||||||
if (simu) _sunlight = simu.LocalStarSimulator()?.sunLight;
|
var localStar = GameMain.localStar;
|
||||||
|
if (!_sunlight || _lastStar != localStar)
|
||||||
|
{
|
||||||
|
_sunlight = GameMain.universeSimulator?.LocalStarSimulator()?.sunLight;
|
||||||
if (!_sunlight) return;
|
if (!_sunlight) return;
|
||||||
|
_lastStar = localStar;
|
||||||
}
|
}
|
||||||
|
|
||||||
_mechaOnEarth = true;
|
_mechaOnEarth = true;
|
||||||
|
}
|
||||||
UpdateSunlightAngle();
|
UpdateSunlightAngle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user