mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Fix guys not being removed, maybe caches are good now
This commit is contained in:
parent
84654724a6
commit
5b2480c8fd
@ -158,8 +158,20 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (body?.Config?.name == null) NHLogger.LogError($"How is there no name for {body}");
|
||||
else existingPlanet = SearchUtilities.Find(body.Config.name.Replace(" ", "") + "_Body", false);
|
||||
if (body?.Config?.name == null)
|
||||
{
|
||||
NHLogger.LogError($"How is there no name for {body}");
|
||||
}
|
||||
else
|
||||
{
|
||||
existingPlanet = SearchUtilities.Find(body.Config.name.Replace(" ", "") + "_Body", false);
|
||||
}
|
||||
}
|
||||
|
||||
if (existingPlanet == null && body.Config.destroy)
|
||||
{
|
||||
NHLogger.LogError($"{body.Config.name} was meant to be destroyed, but was not found");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (existingPlanet != null)
|
||||
|
||||
@ -134,14 +134,14 @@ namespace NewHorizons.Handlers
|
||||
|
||||
public static void DisableAstroObject(AstroObject ao, List<AstroObject> toDisable = null)
|
||||
{
|
||||
NHLogger.LogVerbose($"Removing [{ao.name}]");
|
||||
|
||||
if (ao.gameObject == null || !ao.gameObject.activeInHierarchy)
|
||||
{
|
||||
NHLogger.LogVerbose($"[{ao.name}] was already removed");
|
||||
NHLogger.LogVerbose($"[{ao?.name}] was already removed");
|
||||
return;
|
||||
}
|
||||
|
||||
NHLogger.LogVerbose($"Removing [{ao.name}]");
|
||||
|
||||
toDisable ??= new List<AstroObject>();
|
||||
|
||||
if (toDisable.Contains(ao))
|
||||
@ -222,6 +222,7 @@ namespace NewHorizons.Handlers
|
||||
NHLogger.LogError($"Exception thrown when trying to delete bodies related to [{ao.name}]:\n{e}");
|
||||
}
|
||||
|
||||
DisableGameObject(ao.gameObject);
|
||||
RemoveProxy(ao);
|
||||
}
|
||||
|
||||
|
||||
@ -64,16 +64,21 @@ namespace NewHorizons
|
||||
{
|
||||
return _currentStarSystem;
|
||||
}
|
||||
internal set
|
||||
set
|
||||
{
|
||||
_previousStarSystem = _currentStarSystem;
|
||||
// Prevent invalid values
|
||||
if (value != "SolarSystem" && value != "EyeOfTheUniverse" && !SystemDict.ContainsKey(value) && !BodyDict.ContainsKey(value))
|
||||
{
|
||||
NHLogger.LogError($"System \"{value}\" does not exist!");
|
||||
_currentStarSystem = DefaultStarSystem;
|
||||
}
|
||||
_currentStarSystem = value;
|
||||
}
|
||||
}
|
||||
private string _currentStarSystem = "SolarSystem";
|
||||
private string _currentStarSystem;
|
||||
private string _previousStarSystem;
|
||||
|
||||
public bool TimeLoopEnabled => SystemDict[CurrentStarSystem]?.Config?.enableTimeLoop ?? true;
|
||||
public bool TimeLoopEnabled => CurrentStarSystem == null || (SystemDict[CurrentStarSystem]?.Config?.enableTimeLoop ?? true);
|
||||
public bool IsWarpingFromShip { get; private set; } = false;
|
||||
public bool IsWarpingFromVessel { get; private set; } = false;
|
||||
public bool IsWarpingBackToEye { get; internal set; } = false;
|
||||
@ -280,6 +285,7 @@ namespace NewHorizons
|
||||
// Caches of other assets only have to be cleared if we changed star systems
|
||||
if (CurrentStarSystem != _previousStarSystem)
|
||||
{
|
||||
NHLogger.Log($"Changing star system from {_previousStarSystem} to {CurrentStarSystem} - Clearing system-specific caches!");
|
||||
ImageUtilities.ClearCache();
|
||||
AudioUtilities.ClearCache();
|
||||
AssetBundleUtilities.ClearCache();
|
||||
@ -362,12 +368,6 @@ namespace NewHorizons
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SystemDict.ContainsKey(CurrentStarSystem) || !BodyDict.ContainsKey(CurrentStarSystem))
|
||||
{
|
||||
NHLogger.LogError($"System \"{CurrentStarSystem}\" does not exist!");
|
||||
CurrentStarSystem = DefaultStarSystem;
|
||||
}
|
||||
|
||||
// Set time loop stuff if its enabled and if we're warping to a new place
|
||||
if (IsChangingStarSystem && (SystemDict[CurrentStarSystem].Config.enableTimeLoop || CurrentStarSystem == "SolarSystem") && SecondsElapsedInLoop > 0f)
|
||||
{
|
||||
@ -576,6 +576,9 @@ namespace NewHorizons
|
||||
{
|
||||
ResetCurrentStarSystem();
|
||||
}
|
||||
|
||||
// We only check previous when the scene unloads, and at that point current should be updated to the new system
|
||||
_previousStarSystem = CurrentStarSystem;
|
||||
}
|
||||
|
||||
// Had a bunch of separate unity things firing stuff when the system is ready so I moved it all to here
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user