diff --git a/NewHorizons/Builder/Body/StarBuilder.cs b/NewHorizons/Builder/Body/StarBuilder.cs index e51341ef..ba5d303a 100644 --- a/NewHorizons/Builder/Body/StarBuilder.cs +++ b/NewHorizons/Builder/Body/StarBuilder.cs @@ -133,11 +133,11 @@ namespace NewHorizons.Builder.Body // It fucking insists on this existing and its really annoying var supernovaVolume = new GameObject("SupernovaVolumePlaceholder"); supernovaVolume.transform.SetParent(starGO.transform); - supernova._supernovaVolume = supernovaVolume.AddComponent(); var sphere = supernovaVolume.AddComponent(); sphere.radius = 0f; sphere.isTrigger = true; supernovaVolume.AddComponent(); + supernova._supernovaVolume = supernovaVolume.AddComponent(); return starController; } @@ -148,6 +148,8 @@ namespace NewHorizons.Builder.Body var supernova = MakeSupernova(starGO, starModule); + supernova._belongsToProxySun = true; + starGO.SetActive(false); var controller = starGO.AddComponent(); if (starModule.curve != null) controller.scaleCurve = starModule.GetAnimationCurve(); diff --git a/NewHorizons/Builder/General/SpawnPointBuilder.cs b/NewHorizons/Builder/General/SpawnPointBuilder.cs index 05f6d7a4..f74767bd 100644 --- a/NewHorizons/Builder/General/SpawnPointBuilder.cs +++ b/NewHorizons/Builder/General/SpawnPointBuilder.cs @@ -18,8 +18,9 @@ namespace NewHorizons.Builder.General spawnGO.transform.localPosition = module.playerSpawnPoint; playerSpawn = spawnGO.AddComponent(); - - if(module.playerSpawnRotation != null) + playerSpawn._triggerVolumes = new OWTriggerVolume[0]; + + if (module.playerSpawnRotation != null) { spawnGO.transform.rotation = Quaternion.Euler(module.playerSpawnRotation); } @@ -40,6 +41,7 @@ namespace NewHorizons.Builder.General var spawnPoint = spawnGO.AddComponent(); spawnPoint._isShipSpawn = true; + spawnPoint._triggerVolumes = new OWTriggerVolume[0]; var ship = GameObject.Find("Ship_Body"); ship.transform.position = spawnPoint.transform.position; @@ -67,6 +69,7 @@ namespace NewHorizons.Builder.General playerSpawnGO.transform.localPosition = new Vector3(0, 0, 0); playerSpawn = playerSpawnGO.AddComponent(); + playerSpawn._triggerVolumes = new OWTriggerVolume[0]; playerSpawnGO.transform.localRotation = Quaternion.Euler(0, 0, 0); } } diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index bfa69d09..54469e24 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -169,6 +169,7 @@ namespace NewHorizons.Builder.Props { try { + if (component == null) return; if (component is Animator animator) animator.enabled = true; else if (component is Collider collider) collider.enabled = true; else if (component is Renderer renderer) renderer.enabled = true; diff --git a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs index c862f7fc..d27486fb 100644 --- a/NewHorizons/Components/SizeControllers/StarEvolutionController.cs +++ b/NewHorizons/Components/SizeControllers/StarEvolutionController.cs @@ -199,8 +199,8 @@ namespace NewHorizons.Components.SizeControllers supernova.enabled = true; _isSupernova = true; _supernovaStartTime = Time.time; - atmosphere.SetActive(false); - _destructionVolume._deathType = DeathType.Supernova; + if (atmosphere != null) atmosphere.SetActive(false); + if (_destructionVolume != null) _destructionVolume._deathType = DeathType.Supernova; return; } } diff --git a/NewHorizons/Patches/MapControllerPatches.cs b/NewHorizons/Patches/MapControllerPatches.cs index b3c25e29..5c6e626a 100644 --- a/NewHorizons/Patches/MapControllerPatches.cs +++ b/NewHorizons/Patches/MapControllerPatches.cs @@ -1,4 +1,4 @@ -using HarmonyLib; +using HarmonyLib; using UnityEngine.SceneManagement; namespace NewHorizons.Patches @@ -43,5 +43,12 @@ namespace NewHorizons.Patches return true; } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ReferenceFrameTracker), nameof(ReferenceFrameTracker.UntargetReferenceFrame), new System.Type[] { typeof(bool) })] + public static bool ReferenceFrameTracker_UntargetReferenceFrame(ReferenceFrameTracker __instance, bool playAudio) + { + return __instance._hasTarget && __instance._currentReferenceFrame != null; + } } } diff --git a/NewHorizons/Patches/PlayerSpawnerPatches.cs b/NewHorizons/Patches/PlayerSpawnerPatches.cs index e6dec94d..09e9ff0a 100644 --- a/NewHorizons/Patches/PlayerSpawnerPatches.cs +++ b/NewHorizons/Patches/PlayerSpawnerPatches.cs @@ -1,4 +1,4 @@ -using HarmonyLib; +using HarmonyLib; using Logger = NewHorizons.Utility.Logger; namespace NewHorizons.Patches { diff --git a/NewHorizons/Patches/SunPatches.cs b/NewHorizons/Patches/SunPatches.cs index ba57ffee..447028bd 100644 --- a/NewHorizons/Patches/SunPatches.cs +++ b/NewHorizons/Patches/SunPatches.cs @@ -1,4 +1,4 @@ -using HarmonyLib; +using HarmonyLib; using UnityEngine; namespace NewHorizons.Patches { @@ -40,5 +40,26 @@ namespace NewHorizons.Patches __instance._audioSource.SetLocalVolume(num * num * __instance._fade); return false; } + + [HarmonyPrefix] + [HarmonyPatch(typeof(SunProxyEffectController), nameof(SunProxyEffectController.UpdateScales))] + public static bool SunProxyEffectController_UpdateScales(SunProxyEffectController __instance) + { + return __instance != null && __instance._surface != null && __instance._fog != null && __instance._fogMaterial != null && __instance._solarFlareEmitter != null && __instance._atmosphere != null; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(SunProxyEffectController), nameof(SunProxyEffectController.UpdateAtmosphereRadii))] + public static bool SunProxyEffectController_UpdateAtmosphereRadii(SunProxyEffectController __instance) + { + return __instance != null && __instance.transform != null && __instance.transform.parent != null && __instance._atmosphereMaterial != null; + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(VanishVolume), nameof(VanishVolume.Shrink))] + public static bool VanishVolume_Shrink(VanishVolume __instance, OWRigidbody bodyToShrink) + { + return __instance != null && __instance.transform != null && __instance._shrinkingBodies != null && __instance._shrinkingBodyLocationData != null && bodyToShrink != null; + } } }