force clear cache flag for less duplication

This commit is contained in:
JohnCorby 2023-09-14 20:45:25 -07:00
parent d184a28ceb
commit 7beb66606c
2 changed files with 5 additions and 7 deletions

View File

@ -97,6 +97,7 @@ namespace NewHorizons
private bool _playerAwake; private bool _playerAwake;
public bool PlayerSpawned { get; set; } public bool PlayerSpawned { get; set; }
public bool ForceClearCaches { get; set; } // for reloading configs
public ShipWarpController ShipWarpController { get; private set; } public ShipWarpController ShipWarpController { get; private set; }
@ -196,7 +197,6 @@ namespace NewHorizons
} }
}; };
// why is this false when called in Start
if (resetTranslation) if (resetTranslation)
{ {
TranslationHandler.ClearTables(); TranslationHandler.ClearTables();
@ -289,8 +289,10 @@ namespace NewHorizons
EnumUtilities.ClearCache(); EnumUtilities.ClearCache();
// Caches of other assets only have to be cleared if we changed star systems // Caches of other assets only have to be cleared if we changed star systems
if (CurrentStarSystem != _previousStarSystem) if (ForceClearCaches || CurrentStarSystem != _previousStarSystem)
{ {
ForceClearCaches = false;
NHLogger.Log($"Changing star system from {_previousStarSystem} to {CurrentStarSystem} - Clearing system-specific caches!"); NHLogger.Log($"Changing star system from {_previousStarSystem} to {CurrentStarSystem} - Clearing system-specific caches!");
ImageUtilities.ClearCache(); ImageUtilities.ClearCache();
AudioUtilities.ClearCache(); AudioUtilities.ClearCache();

View File

@ -48,12 +48,8 @@ namespace NewHorizons.Utility.DebugTools
SearchUtilities.Find("/PauseMenu/PauseMenuManagers").GetComponent<PauseMenuManager>().OnSkipToNextTimeLoop(); SearchUtilities.Find("/PauseMenu/PauseMenuManagers").GetComponent<PauseMenuManager>().OnSkipToNextTimeLoop();
Main.Instance.ForceClearCaches = true;
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem); Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem);
NHLogger.Log($"Reloading configs for star system {Main.Instance.CurrentStarSystem} - Clearing system-specific caches!");
ImageUtilities.ClearCache();
AudioUtilities.ClearCache();
AssetBundleUtilities.ClearCache();
Main.SecondsElapsedInLoop = -1f; Main.SecondsElapsedInLoop = -1f;
} }