mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix NullReferenceExceptions
This commit is contained in:
parent
5e1ddde773
commit
0e0766e870
@ -133,11 +133,11 @@ namespace NewHorizons.Builder.Body
|
|||||||
// It fucking insists on this existing and its really annoying
|
// It fucking insists on this existing and its really annoying
|
||||||
var supernovaVolume = new GameObject("SupernovaVolumePlaceholder");
|
var supernovaVolume = new GameObject("SupernovaVolumePlaceholder");
|
||||||
supernovaVolume.transform.SetParent(starGO.transform);
|
supernovaVolume.transform.SetParent(starGO.transform);
|
||||||
supernova._supernovaVolume = supernovaVolume.AddComponent<SupernovaDestructionVolume>();
|
|
||||||
var sphere = supernovaVolume.AddComponent<SphereCollider>();
|
var sphere = supernovaVolume.AddComponent<SphereCollider>();
|
||||||
sphere.radius = 0f;
|
sphere.radius = 0f;
|
||||||
sphere.isTrigger = true;
|
sphere.isTrigger = true;
|
||||||
supernovaVolume.AddComponent<OWCollider>();
|
supernovaVolume.AddComponent<OWCollider>();
|
||||||
|
supernova._supernovaVolume = supernovaVolume.AddComponent<SupernovaDestructionVolume>();
|
||||||
|
|
||||||
return starController;
|
return starController;
|
||||||
}
|
}
|
||||||
@ -148,6 +148,8 @@ namespace NewHorizons.Builder.Body
|
|||||||
|
|
||||||
var supernova = MakeSupernova(starGO, starModule);
|
var supernova = MakeSupernova(starGO, starModule);
|
||||||
|
|
||||||
|
supernova._belongsToProxySun = true;
|
||||||
|
|
||||||
starGO.SetActive(false);
|
starGO.SetActive(false);
|
||||||
var controller = starGO.AddComponent<StarEvolutionController>();
|
var controller = starGO.AddComponent<StarEvolutionController>();
|
||||||
if (starModule.curve != null) controller.scaleCurve = starModule.GetAnimationCurve();
|
if (starModule.curve != null) controller.scaleCurve = starModule.GetAnimationCurve();
|
||||||
|
|||||||
@ -18,8 +18,9 @@ namespace NewHorizons.Builder.General
|
|||||||
spawnGO.transform.localPosition = module.playerSpawnPoint;
|
spawnGO.transform.localPosition = module.playerSpawnPoint;
|
||||||
|
|
||||||
playerSpawn = spawnGO.AddComponent<SpawnPoint>();
|
playerSpawn = spawnGO.AddComponent<SpawnPoint>();
|
||||||
|
playerSpawn._triggerVolumes = new OWTriggerVolume[0];
|
||||||
|
|
||||||
if(module.playerSpawnRotation != null)
|
if (module.playerSpawnRotation != null)
|
||||||
{
|
{
|
||||||
spawnGO.transform.rotation = Quaternion.Euler(module.playerSpawnRotation);
|
spawnGO.transform.rotation = Quaternion.Euler(module.playerSpawnRotation);
|
||||||
}
|
}
|
||||||
@ -40,6 +41,7 @@ namespace NewHorizons.Builder.General
|
|||||||
|
|
||||||
var spawnPoint = spawnGO.AddComponent<SpawnPoint>();
|
var spawnPoint = spawnGO.AddComponent<SpawnPoint>();
|
||||||
spawnPoint._isShipSpawn = true;
|
spawnPoint._isShipSpawn = true;
|
||||||
|
spawnPoint._triggerVolumes = new OWTriggerVolume[0];
|
||||||
|
|
||||||
var ship = GameObject.Find("Ship_Body");
|
var ship = GameObject.Find("Ship_Body");
|
||||||
ship.transform.position = spawnPoint.transform.position;
|
ship.transform.position = spawnPoint.transform.position;
|
||||||
@ -67,6 +69,7 @@ namespace NewHorizons.Builder.General
|
|||||||
playerSpawnGO.transform.localPosition = new Vector3(0, 0, 0);
|
playerSpawnGO.transform.localPosition = new Vector3(0, 0, 0);
|
||||||
|
|
||||||
playerSpawn = playerSpawnGO.AddComponent<SpawnPoint>();
|
playerSpawn = playerSpawnGO.AddComponent<SpawnPoint>();
|
||||||
|
playerSpawn._triggerVolumes = new OWTriggerVolume[0];
|
||||||
playerSpawnGO.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
playerSpawnGO.transform.localRotation = Quaternion.Euler(0, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -169,6 +169,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (component == null) return;
|
||||||
if (component is Animator animator) animator.enabled = true;
|
if (component is Animator animator) animator.enabled = true;
|
||||||
else if (component is Collider collider) collider.enabled = true;
|
else if (component is Collider collider) collider.enabled = true;
|
||||||
else if (component is Renderer renderer) renderer.enabled = true;
|
else if (component is Renderer renderer) renderer.enabled = true;
|
||||||
|
|||||||
@ -199,8 +199,8 @@ namespace NewHorizons.Components.SizeControllers
|
|||||||
supernova.enabled = true;
|
supernova.enabled = true;
|
||||||
_isSupernova = true;
|
_isSupernova = true;
|
||||||
_supernovaStartTime = Time.time;
|
_supernovaStartTime = Time.time;
|
||||||
atmosphere.SetActive(false);
|
if (atmosphere != null) atmosphere.SetActive(false);
|
||||||
_destructionVolume._deathType = DeathType.Supernova;
|
if (_destructionVolume != null) _destructionVolume._deathType = DeathType.Supernova;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
namespace NewHorizons.Patches
|
namespace NewHorizons.Patches
|
||||||
@ -43,5 +43,12 @@ namespace NewHorizons.Patches
|
|||||||
|
|
||||||
return true;
|
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 != null && __instance._hasTarget && __instance._currentReferenceFrame != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Logger = NewHorizons.Utility.Logger;
|
using Logger = NewHorizons.Utility.Logger;
|
||||||
namespace NewHorizons.Patches
|
namespace NewHorizons.Patches
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
namespace NewHorizons.Patches
|
namespace NewHorizons.Patches
|
||||||
{
|
{
|
||||||
@ -40,5 +40,26 @@ namespace NewHorizons.Patches
|
|||||||
__instance._audioSource.SetLocalVolume(num * num * __instance._fade);
|
__instance._audioSource.SetLocalVolume(num * num * __instance._fade);
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user