mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 03:33:29 +08:00
UXAssist: fix Night Light again
This commit is contained in:
@@ -233,7 +233,6 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
private static bool _mechaOnEarth;
|
||||
private static AnimationState _sail;
|
||||
private static Light _sunlight;
|
||||
private static StarData _lastStar;
|
||||
|
||||
protected override void OnEnable()
|
||||
{
|
||||
@@ -247,8 +246,8 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||
_sunlight = null;
|
||||
}
|
||||
_lastStar = null;
|
||||
_sail = null;
|
||||
_mechaOnEarth = false;
|
||||
_nightlightInitialized = false;
|
||||
}
|
||||
|
||||
@@ -259,8 +258,8 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||
_sunlight = null;
|
||||
}
|
||||
_lastStar = null;
|
||||
_sail = null;
|
||||
_mechaOnEarth = false;
|
||||
_nightlightInitialized = false;
|
||||
}
|
||||
|
||||
@@ -271,6 +270,20 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
GameMain.mainPlayer.transform.right * NightLightAngleY.Value / 10f);
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameData), nameof(GameData.ArriveStar))]
|
||||
public static void GameData_ArriveStar_Postfix()
|
||||
{
|
||||
_sunlight = GameMain.universeSimulator?.LocalStarSimulator()?.sunLight;
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(GameData), nameof(GameData.LeaveStar))]
|
||||
public static void GameData_LeaveStar_Prefix()
|
||||
{
|
||||
_sunlight = null;
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(GameMain), nameof(GameMain.LateUpdate))]
|
||||
public static void GameMain_LateUpdate_Postfix(GameMain __instance)
|
||||
@@ -281,34 +294,28 @@ public class FactoryPatch : PatchImpl<FactoryPatch>
|
||||
{
|
||||
if (!GameMain.mainPlayer.controller.model.gameObject.activeInHierarchy) return;
|
||||
if (_sail == null) _sail = GameMain.mainPlayer.animator.sails[GameMain.mainPlayer.animator.sailAnimIndex];
|
||||
_sunlight = GameMain.universeSimulator?.LocalStarSimulator()?.sunLight;
|
||||
_nightlightInitialized = true;
|
||||
}
|
||||
|
||||
var sailing = _sail && _sail.enabled;
|
||||
if (_mechaOnEarth)
|
||||
{
|
||||
if (sailing)
|
||||
if (!sailing)
|
||||
{
|
||||
UpdateSunlightAngle();
|
||||
return;
|
||||
}
|
||||
_mechaOnEarth = false;
|
||||
if (!_sunlight) return;
|
||||
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
|
||||
_sunlight = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (sailing) return;
|
||||
var localStar = GameMain.localStar;
|
||||
if (!_sunlight || _lastStar != localStar)
|
||||
{
|
||||
_sunlight = GameMain.universeSimulator?.LocalStarSimulator()?.sunLight;
|
||||
if (!_sunlight) return;
|
||||
_lastStar = localStar;
|
||||
}
|
||||
_mechaOnEarth = true;
|
||||
}
|
||||
UpdateSunlightAngle();
|
||||
}
|
||||
|
||||
[HarmonyTranspiler]
|
||||
[HarmonyPatch(typeof(StarSimulator), "LateUpdate")]
|
||||
|
||||
Reference in New Issue
Block a user