From e8b0bf4a6b51b4701a4d155c607110e91dcdc4f8 Mon Sep 17 00:00:00 2001 From: Nick Date: Mon, 11 Mar 2024 11:46:14 -0400 Subject: [PATCH] Check for null refs inside streaming warp volume then destroy it --- .../Components/Volumes/StreamingWarpVolume.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/NewHorizons/Components/Volumes/StreamingWarpVolume.cs b/NewHorizons/Components/Volumes/StreamingWarpVolume.cs index 25616c487..cfce0c083 100644 --- a/NewHorizons/Components/Volumes/StreamingWarpVolume.cs +++ b/NewHorizons/Components/Volumes/StreamingWarpVolume.cs @@ -1,3 +1,4 @@ +using NewHorizons.Utility.OWML; using UnityEngine; namespace NewHorizons.Components.Volumes @@ -23,6 +24,23 @@ public void Start() public void FixedUpdate() { + // Bug report on Astral Codec mod page - Huge lag inside streaming warp volume, possible NRE? + if (_probe == null) + { + _probe = Locator.GetProbe(); + if (_probe == null) + { + NHLogger.LogError($"How is your scout probe null? Destroying {nameof(StreamingWarpVolume)}"); + Component.DestroyImmediate(this); + } + } + + if (streamingGroup == null) + { + NHLogger.LogError($"{nameof(StreamingWarpVolume)} has no streaming group. Destroying {nameof(StreamingWarpVolume)}"); + Component.DestroyImmediate(this); + } + bool probeActive = _probe.IsLaunched() && !_probe.IsAnchored(); bool shouldBeLoadingRequiredAssets = _playerInVolume || (_probeInVolume && probeActive);