Check for null refs inside streaming warp volume then destroy it

This commit is contained in:
Nick 2024-03-11 11:46:14 -04:00
parent 0036028404
commit e8b0bf4a6b

View File

@ -1,3 +1,4 @@
using NewHorizons.Utility.OWML;
using UnityEngine;
namespace NewHorizons.Components.Volumes
@ -23,6 +24,23 @@ namespace NewHorizons.Components.Volumes
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);