Skip to content

Commit

Permalink
Clean up supernova NRE, fix no-DLC related issues
Browse files Browse the repository at this point in the history
  • Loading branch information
xen-42 committed Oct 18, 2023
1 parent 467876f commit 58fca35
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public void Update()
{
float collapseProgress = SunController.GetCollapseProgress();

if (_ambientLight != null)
if (_ambientLight != null && _ambientLightOrigIntensity != null)
{
for (int i = 0; i < _ambientLight.Length; i++)
{
Expand Down Expand Up @@ -221,11 +221,14 @@ public void Update()
{
if (_shockLayer != null) _shockLayer.enabled = false;

if (_ambientLight != null)
if (_ambientLight != null && _ambientLightOrigIntensity != null)
{
for (int i = 0; i < _ambientLight.Length; i++)
{
_ambientLight[i].intensity = _ambientLightOrigIntensity[i];
if (_ambientLight[i] != null)
{
_ambientLight[i].intensity = _ambientLightOrigIntensity[i];
}
}
}

Expand Down
19 changes: 15 additions & 4 deletions NewHorizons/Handlers/PlanetDestructionHandler.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using NewHorizons.Components;
using NewHorizons.Components.Stars;
using NewHorizons.Utility;
using NewHorizons.Utility.OWML;
using NewHorizons.Utility.OuterWilds;
using NewHorizons.Utility.OWML;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using NewHorizons.Components;

namespace NewHorizons.Handlers
{
Expand Down Expand Up @@ -40,7 +40,14 @@ public static void RemoveStockPlanets()
{
foreach (var gameObject in toDisable)
{
gameObject.SetActive(false);
// Somehow SetActive can NRE
// Seems to only happen if they don't have the DLC installed
// Even with the null check it's complaining so I don't understand at all
try
{
gameObject?.SetActive(false);
}
catch { }
}
// Kill all non nh proxies
foreach (var proxy in GameObject.FindObjectsOfType<ProxyBody>())
Expand All @@ -55,10 +62,14 @@ public static void RemoveStockPlanets()
if (Main.Instance.CurrentStarSystem != "EyeOfTheUniverse")
{
// Since we didn't call RemoveBody on the all planets there are some we have to call here
StrangerRemoved();
TimberHearthRemoved();
GiantsDeepRemoved();
SunRemoved();
if (Main.HasDLC)
{
StrangerRemoved();
}
}
}, 2); // Have to wait or shit goes wild
Expand Down
9 changes: 6 additions & 3 deletions NewHorizons/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,12 @@ private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
GravityCannonBuilder.InitPrefab();
ShuttleBuilder.InitPrefab();

ProjectionBuilder.InitPrefabs();
CloakBuilder.InitPrefab();
RaftBuilder.InitPrefab();
if (HasDLC)
{
ProjectionBuilder.InitPrefabs();
CloakBuilder.InitPrefab();
RaftBuilder.InitPrefab();
}

WarpPadBuilder.InitPrefabs();
}
Expand Down
2 changes: 1 addition & 1 deletion NewHorizons/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "xen, Bwc9876, clay, MegaPiggy, John, Trifid, Hawkbar, Book",
"name": "New Horizons",
"uniqueName": "xen.NewHorizons",
"version": "1.17.1",
"version": "1.17.2",
"owmlVersion": "2.9.8",
"dependencies": [ "JohnCorby.VanillaFix", "_nebula.MenuFramework", "xen.CommonCameraUtility", "dgarro.CustomShipLogModes" ],
"conflicts": [ "Raicuparta.QuantumSpaceBuddies", "PacificEngine.OW_CommonResources" ],
Expand Down

0 comments on commit 58fca35

Please sign in to comment.