mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
do proper null checking on sectors
This commit is contained in:
parent
ce4072fed0
commit
177eea9e36
@ -24,6 +24,8 @@ namespace NewHorizons.Handlers
|
||||
{
|
||||
var group = GetStreamingGroup(name);
|
||||
|
||||
if (sector)
|
||||
{
|
||||
sector.OnOccupantEnterSector += _ =>
|
||||
{
|
||||
if (sector.ContainsAnyOccupants(DynamicOccupant.Player | DynamicOccupant.Probe))
|
||||
@ -35,6 +37,11 @@ namespace NewHorizons.Handlers
|
||||
group.ReleaseGeneralAssets();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
group.RequestGeneralAssets();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// makes it so that this object's streaming stuff will be connected to the given sector
|
||||
@ -87,8 +94,6 @@ namespace NewHorizons.Handlers
|
||||
|
||||
foreach (var assetBundle in assetBundles)
|
||||
{
|
||||
StreamingManager.LoadStreamingAssets(assetBundle);
|
||||
|
||||
// Track the sector even if its null. null means stay loaded forever
|
||||
if (!_sectorCache.TryGetValue(assetBundle, out var sectors))
|
||||
{
|
||||
@ -113,6 +118,11 @@ namespace NewHorizons.Handlers
|
||||
StreamingManager.UnloadStreamingAssets(assetBundle);
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var assetBundle in assetBundles)
|
||||
StreamingManager.LoadStreamingAssets(assetBundle);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsBundleInUse(string assetBundle)
|
||||
@ -133,7 +143,7 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
else
|
||||
{
|
||||
return Locator.GetAstroObject(name)?.GetComponentInChildren<StreamingGroup>();
|
||||
return Locator.GetAstroObject(name).GetComponentInChildren<StreamingGroup>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user