mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Do not load bodies twice
This commit is contained in:
parent
c27e2ed665
commit
9cf94e601e
@ -87,6 +87,7 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
|
||||
// Load all planets
|
||||
_loadedBodies.Clear();
|
||||
var toLoad = bodies.ToList();
|
||||
var newPlanetGraph = new PlanetGraphHandler(toLoad);
|
||||
|
||||
@ -151,8 +152,18 @@ namespace NewHorizons.Handlers
|
||||
SingularityBuilder.PairAllSingularities();
|
||||
}
|
||||
|
||||
private static List<NewHorizonsBody> _loadedBodies = new();
|
||||
|
||||
/// <summary>
|
||||
/// Returns false if it failed
|
||||
/// </summary>
|
||||
/// <param name="body"></param>
|
||||
/// <param name="defaultPrimaryToSun"></param>
|
||||
/// <returns></returns>
|
||||
public static bool LoadBody(NewHorizonsBody body, bool defaultPrimaryToSun = false)
|
||||
{
|
||||
if (_loadedBodies.Contains(body)) return true;
|
||||
|
||||
body.LoadCache();
|
||||
|
||||
// I don't remember doing this why is it exceptions what am I doing
|
||||
@ -306,6 +317,7 @@ namespace NewHorizons.Handlers
|
||||
}
|
||||
|
||||
body.UnloadCache(true);
|
||||
_loadedBodies.Add(body);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user