mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
streaming unloading (#471)
## Improvements - leaving sectors now unloads streamed things
This commit is contained in:
commit
e4a68a3634
@ -385,6 +385,8 @@ namespace NewHorizons.Builder.Props
|
||||
}
|
||||
}
|
||||
|
||||
StreamingHandler.SetUpStreaming(brambleNode, sector);
|
||||
|
||||
// Done!
|
||||
brambleNode.SetActive(true);
|
||||
return brambleNode;
|
||||
|
||||
@ -614,7 +614,7 @@ namespace NewHorizons.Builder.Props
|
||||
nomaiWallText.SetTextAsset(text);
|
||||
|
||||
// #433 fuzzy stranger text
|
||||
if (info.arcInfo.Any(x => x.type == PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger))
|
||||
if (info.arcInfo != null && info.arcInfo.Any(x => x.type == PropModule.NomaiTextArcInfo.NomaiTextArcType.Stranger))
|
||||
{
|
||||
StreamingHandler.SetUpStreaming(AstroObject.Name.RingWorld, sector);
|
||||
}
|
||||
|
||||
@ -24,16 +24,23 @@ namespace NewHorizons.Handlers
|
||||
{
|
||||
var group = GetStreamingGroup(name);
|
||||
|
||||
sector.OnOccupantEnterSector += _ =>
|
||||
if (sector)
|
||||
{
|
||||
if (sector.ContainsAnyOccupants(DynamicOccupant.Player | DynamicOccupant.Probe))
|
||||
group.RequestGeneralAssets();
|
||||
};
|
||||
sector.OnOccupantExitSector += _ =>
|
||||
sector.OnOccupantEnterSector += _ =>
|
||||
{
|
||||
if (sector.ContainsAnyOccupants(DynamicOccupant.Player | DynamicOccupant.Probe))
|
||||
group.RequestGeneralAssets();
|
||||
};
|
||||
sector.OnOccupantExitSector += _ =>
|
||||
{
|
||||
if (!sector.ContainsAnyOccupants(DynamicOccupant.Player | DynamicOccupant.Probe))
|
||||
group.ReleaseGeneralAssets();
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!sector.ContainsAnyOccupants(DynamicOccupant.Player | DynamicOccupant.Probe))
|
||||
group.ReleaseGeneralAssets();
|
||||
};
|
||||
group.RequestGeneralAssets();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -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))
|
||||
{
|
||||
@ -106,15 +111,17 @@ namespace NewHorizons.Handlers
|
||||
foreach (var assetBundle in assetBundles)
|
||||
StreamingManager.LoadStreamingAssets(assetBundle);
|
||||
};
|
||||
/*
|
||||
sector.OnOccupantExitSector += _ =>
|
||||
{
|
||||
// UnloadStreamingAssets is patched to check IsBundleInUse first before unloading
|
||||
if (!sector.ContainsAnyOccupants(DynamicOccupant.Player | DynamicOccupant.Probe))
|
||||
foreach (var assetBundle in assetBundles)
|
||||
StreamingManager.UnloadStreamingAssets(assetBundle);
|
||||
};
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var assetBundle in assetBundles)
|
||||
StreamingManager.LoadStreamingAssets(assetBundle);
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +143,7 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
else
|
||||
{
|
||||
return Locator.GetAstroObject(name)?.GetComponentInChildren<StreamingGroup>();
|
||||
return Locator.GetAstroObject(name).GetComponentInChildren<StreamingGroup>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
using HarmonyLib;
|
||||
using NewHorizons.Handlers;
|
||||
using OWML.Logging;
|
||||
|
||||
namespace NewHorizons.Patches
|
||||
{
|
||||
[HarmonyPatch]
|
||||
public static class StreamingManagerPatches
|
||||
public static class StreamingPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(StreamingManager), nameof(StreamingManager.UnloadStreamingAssets))]
|
||||
@ -12,6 +13,14 @@ namespace NewHorizons.Patches
|
||||
{
|
||||
// Only let it unload stuff that isn't being used
|
||||
return !StreamingHandler.IsBundleInUse(assetBundleName);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(UnityLogger), "OnLogMessageReceived")]
|
||||
public static bool UnityLogger_OnLogMessageReceived(string message)
|
||||
{
|
||||
// Filter out goofy error that doesn't actually break anything
|
||||
return !message.EndsWith(") is out of bounds (size=0)");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user