mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Cache details used on the eye (#910)
## Improvements - When making changes to the Eye of the Universe you can now use any path from the base solar system. Note some objects might not behave as expected since many things aren't made to exist at the eye.
This commit is contained in:
commit
103e041129
@ -438,7 +438,7 @@ namespace NewHorizons.Builder.Props
|
|||||||
|
|
||||||
NHLogger.LogVerbose("Fixing anglerfish animation");
|
NHLogger.LogVerbose("Fixing anglerfish animation");
|
||||||
|
|
||||||
// Remove any event reference to its angler
|
// Remove any event reference to its angler so that they dont change its state
|
||||||
if (angler._anglerfishController)
|
if (angler._anglerfishController)
|
||||||
{
|
{
|
||||||
angler._anglerfishController.OnChangeAnglerState -= angler.OnChangeAnglerState;
|
angler._anglerfishController.OnChangeAnglerState -= angler.OnChangeAnglerState;
|
||||||
@ -446,7 +446,8 @@ namespace NewHorizons.Builder.Props
|
|||||||
angler._anglerfishController.OnAnglerSuspended -= angler.OnAnglerSuspended;
|
angler._anglerfishController.OnAnglerSuspended -= angler.OnAnglerSuspended;
|
||||||
angler._anglerfishController.OnAnglerUnsuspended -= angler.OnAnglerUnsuspended;
|
angler._anglerfishController.OnAnglerUnsuspended -= angler.OnAnglerUnsuspended;
|
||||||
}
|
}
|
||||||
angler.enabled = true;
|
// Disable the angler anim controller because we don't want Update or LateUpdate to run, just need it to set the initial Animator state
|
||||||
|
angler.enabled = false;
|
||||||
angler.OnChangeAnglerState(AnglerfishController.AnglerState.Lurking);
|
angler.OnChangeAnglerState(AnglerfishController.AnglerState.Lurking);
|
||||||
|
|
||||||
Destroy(this);
|
Destroy(this);
|
||||||
|
|||||||
63
NewHorizons/Handlers/EyeDetailCacher.cs
Normal file
63
NewHorizons/Handlers/EyeDetailCacher.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
using NewHorizons.Utility;
|
||||||
|
using NewHorizons.Utility.OWML;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace NewHorizons.Handlers;
|
||||||
|
|
||||||
|
public static class EyeDetailCacher
|
||||||
|
{
|
||||||
|
public static bool IsInitialized;
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
if (IsInitialized) return;
|
||||||
|
|
||||||
|
SearchUtilities.ClearDontDestroyOnLoadCache();
|
||||||
|
|
||||||
|
IsInitialized = true;
|
||||||
|
|
||||||
|
foreach (var body in Main.BodyDict["EyeOfTheUniverse"])
|
||||||
|
{
|
||||||
|
NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {body.Config.name}");
|
||||||
|
if (body.Config?.Props?.details != null)
|
||||||
|
{
|
||||||
|
foreach (var detail in body.Config.Props.details)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(detail.assetBundle)) continue;
|
||||||
|
|
||||||
|
AddPathToCache(detail.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body.Config?.Props?.scatter != null)
|
||||||
|
{
|
||||||
|
foreach (var scatter in body.Config.Props.scatter)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(scatter.assetBundle)) continue;
|
||||||
|
|
||||||
|
AddPathToCache(scatter.path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AddPathToCache(string path)
|
||||||
|
{
|
||||||
|
NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: {path}");
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(path)) return;
|
||||||
|
|
||||||
|
var planet = path.Contains('/') ? path.Split('/').First() : string.Empty;
|
||||||
|
|
||||||
|
if (planet != "EyeOfTheUniverse_Body" && planet != "Vessel_Body")
|
||||||
|
{
|
||||||
|
NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Looking for {path}");
|
||||||
|
var obj = SearchUtilities.Find(path);
|
||||||
|
if (obj != null)
|
||||||
|
{
|
||||||
|
NHLogger.LogVerbose($"{nameof(EyeDetailCacher)}: Added solar system asset to dont destroy on load cache for eye: {path}");
|
||||||
|
SearchUtilities.AddToDontDestroyOnLoadCache(path, obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -341,6 +341,8 @@ namespace NewHorizons
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
EyeDetailCacher.Init();
|
||||||
|
|
||||||
AtmosphereBuilder.InitPrefabs();
|
AtmosphereBuilder.InitPrefabs();
|
||||||
BrambleDimensionBuilder.InitPrefabs();
|
BrambleDimensionBuilder.InitPrefabs();
|
||||||
BrambleNodeBuilder.InitPrefabs();
|
BrambleNodeBuilder.InitPrefabs();
|
||||||
@ -967,7 +969,8 @@ namespace NewHorizons
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlayerData.SaveEyeCompletion(); // So that the title screen doesn't keep warping you back to eye
|
if (!IsWarpingBackToEye)
|
||||||
|
PlayerData.SaveEyeCompletion(); // So that the title screen doesn't keep warping you back to eye
|
||||||
|
|
||||||
if (SystemDict[CurrentStarSystem].Config.enableTimeLoop) SecondsElapsedInLoop = TimeLoop.GetSecondsElapsed();
|
if (SystemDict[CurrentStarSystem].Config.enableTimeLoop) SecondsElapsedInLoop = TimeLoop.GetSecondsElapsed();
|
||||||
else SecondsElapsedInLoop = -1;
|
else SecondsElapsedInLoop = -1;
|
||||||
|
|||||||
@ -43,10 +43,21 @@ namespace NewHorizons.Utility.DebugTools
|
|||||||
NHLogger.LogWarning("Error While Reloading");
|
NHLogger.LogWarning("Error While Reloading");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Main.Instance.ForceClearCaches = true;
|
||||||
|
|
||||||
|
|
||||||
SearchUtilities.Find("/PauseMenu/PauseMenuManagers").GetComponent<PauseMenuManager>().OnSkipToNextTimeLoop();
|
SearchUtilities.Find("/PauseMenu/PauseMenuManagers").GetComponent<PauseMenuManager>().OnSkipToNextTimeLoop();
|
||||||
|
|
||||||
Main.Instance.ForceClearCaches = true;
|
if (Main.Instance.CurrentStarSystem == "EyeOfTheUniverse")
|
||||||
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem, Main.Instance.DidWarpFromShip, Main.Instance.DidWarpFromVessel);
|
{
|
||||||
|
Main.Instance.IsWarpingBackToEye = true;
|
||||||
|
EyeDetailCacher.IsInitialized = false;
|
||||||
|
Main.Instance.ChangeCurrentStarSystem("SolarSystem");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem, Main.Instance.DidWarpFromShip, Main.Instance.DidWarpFromVessel);
|
||||||
|
}
|
||||||
|
|
||||||
Main.SecondsElapsedInLoop = -1f;
|
Main.SecondsElapsedInLoop = -1f;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -164,6 +164,9 @@ namespace NewHorizons.Utility.OuterWilds
|
|||||||
.Select(x => x.gameObject)
|
.Select(x => x.gameObject)
|
||||||
.Where(x => x.name == "SS_Debris_Body"));
|
.Where(x => x.name == "SS_Debris_Body"));
|
||||||
break;
|
break;
|
||||||
|
case AstroObject.Name.Eye:
|
||||||
|
otherChildren.Add(SearchUtilities.Find("Vessel_Body"));
|
||||||
|
break;
|
||||||
// Just in case GetChildren runs before sun station's name is changed
|
// Just in case GetChildren runs before sun station's name is changed
|
||||||
case AstroObject.Name.CustomString:
|
case AstroObject.Name.CustomString:
|
||||||
if (primary._customName.Equals("Sun Station"))
|
if (primary._customName.Equals("Sun Station"))
|
||||||
|
|||||||
@ -9,9 +9,24 @@ namespace NewHorizons.Utility
|
|||||||
{
|
{
|
||||||
public static class SearchUtilities
|
public static class SearchUtilities
|
||||||
{
|
{
|
||||||
|
private static readonly Dictionary<string, GameObject> DontDestroyOnLoadCachedGameObjects = new Dictionary<string, GameObject>();
|
||||||
private static readonly Dictionary<string, GameObject> CachedGameObjects = new Dictionary<string, GameObject>();
|
private static readonly Dictionary<string, GameObject> CachedGameObjects = new Dictionary<string, GameObject>();
|
||||||
private static readonly Dictionary<string, GameObject> CachedRootGameObjects = new Dictionary<string, GameObject>();
|
private static readonly Dictionary<string, GameObject> CachedRootGameObjects = new Dictionary<string, GameObject>();
|
||||||
|
|
||||||
|
public static void AddToDontDestroyOnLoadCache(string path, GameObject go)
|
||||||
|
{
|
||||||
|
DontDestroyOnLoadCachedGameObjects[path] = go.InstantiateInactive().DontDestroyOnLoad();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ClearDontDestroyOnLoadCache()
|
||||||
|
{
|
||||||
|
foreach (var go in DontDestroyOnLoadCachedGameObjects.Values)
|
||||||
|
{
|
||||||
|
GameObject.Destroy(go);
|
||||||
|
}
|
||||||
|
DontDestroyOnLoadCachedGameObjects.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
public static void ClearCache()
|
public static void ClearCache()
|
||||||
{
|
{
|
||||||
NHLogger.LogVerbose("Clearing search cache");
|
NHLogger.LogVerbose("Clearing search cache");
|
||||||
@ -96,6 +111,8 @@ namespace NewHorizons.Utility
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static GameObject Find(string path, bool warn = true)
|
public static GameObject Find(string path, bool warn = true)
|
||||||
{
|
{
|
||||||
|
if (DontDestroyOnLoadCachedGameObjects.TryGetValue(path, out var gameObject)) return gameObject;
|
||||||
|
|
||||||
if (CachedGameObjects.TryGetValue(path, out var go)) return go;
|
if (CachedGameObjects.TryGetValue(path, out var go)) return go;
|
||||||
|
|
||||||
// 1: normal find
|
// 1: normal find
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user