1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-09 06:53:31 +08:00

crash fix

This commit is contained in:
2024-03-02 14:50:28 +08:00
parent 4a0ab4494a
commit 3ddd20845a

View File

@@ -167,11 +167,11 @@ public static class FactoryPatch
return;
}
if (_sail.enabled)
if (_sail && _sail.enabled)
{
_mechaOnEarth = false;
Enabled = false;
if (_sunlight == null) return;
if (!_sunlight || !_sunlight.transform) return;
_sunlight.transform.localEulerAngles = new Vector3(0f, 180f);
_sunlight = null;
return;
@@ -179,19 +179,19 @@ public static class FactoryPatch
if (!_mechaOnEarth)
{
if (_sunlight == null)
if (!_sunlight)
{
var simu = GameMain.universeSimulator;
if (simu)
_sunlight = simu.LocalStarSimulator()?.sunLight;
if (_sunlight == null) return;
if (!_sunlight) return;
}
_mechaOnEarth = true;
Enabled = NightLightEnabled.Value;
}
if (Enabled)
if (Enabled && _sunlight)
{
_sunlight.transform.rotation =
Quaternion.LookRotation(-GameMain.mainPlayer.transform.up + GameMain.mainPlayer.transform.forward * NightLightAngleX / 10f +