Fix star system name

This commit is contained in:
Nick 2023-07-21 12:34:07 -04:00
parent ba30f13076
commit 6aef5c76f6
2 changed files with 22 additions and 19 deletions

View File

@ -600,7 +600,7 @@ namespace NewHorizons
#region Load
public void LoadStarSystemConfig(StarSystemConfig starSystemConfig, string relativePath, IModBehaviour mod)
public void LoadStarSystemConfig(string starSystemName, StarSystemConfig starSystemConfig, string relativePath, IModBehaviour mod)
{
starSystemConfig.Migrate();
starSystemConfig.FixCoordinates();
@ -608,22 +608,22 @@ namespace NewHorizons
if (starSystemConfig.startHere)
{
// We always want to allow mods to overwrite setting the main SolarSystem as default but not the other way around
if (name != "SolarSystem")
if (starSystemName != "SolarSystem")
{
SetDefaultSystem(name);
_currentStarSystem = name;
SetDefaultSystem(starSystemName);
_currentStarSystem = starSystemName;
}
}
if (SystemDict.ContainsKey(name))
if (SystemDict.ContainsKey(starSystemName))
{
if (string.IsNullOrEmpty(SystemDict[name].Config.travelAudio) && SystemDict[name].Config.Skybox == null)
SystemDict[name].Mod = mod;
SystemDict[name].Config.Merge(starSystemConfig);
if (string.IsNullOrEmpty(SystemDict[starSystemName].Config.travelAudio) && SystemDict[starSystemName].Config.Skybox == null)
SystemDict[starSystemName].Mod = mod;
SystemDict[starSystemName].Config.Merge(starSystemConfig);
}
else
{
SystemDict[name] = new NewHorizonsSystem(name, starSystemConfig, relativePath, mod);
SystemDict[starSystemName] = new NewHorizonsSystem(starSystemName, starSystemConfig, relativePath, mod);
}
}
@ -654,13 +654,13 @@ namespace NewHorizons
foreach (var file in systemFiles)
{
var name = Path.GetFileNameWithoutExtension(file);
var starSystemName = Path.GetFileNameWithoutExtension(file);
NHLogger.LogVerbose($"Loading system {name}");
NHLogger.LogVerbose($"Loading system {starSystemName}");
var relativePath = file.Replace(folder, "");
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>(relativePath, false);
LoadStarSystemConfig(starSystemConfig, relativePath, mod);
LoadStarSystemConfig(starSystemName, starSystemConfig, relativePath, mod);
}
}
if (Directory.Exists(planetsFolder))

View File

@ -69,24 +69,27 @@ namespace NewHorizons
public void AddShipLogXML(IModBehaviour mod, XElement xml, string planetName, string imageFolder, Dictionary<string, Vector2> entryPositions, Dictionary<string, (Color colour, Color highlight)> curiousityColours)
{
// This method has to be called each time the ship log manager is created, i.e. each time a system loads so it will only ever be relevant to the current one.
var starSystem = Main.Instance.CurrentStarSystem;
var body = new NewHorizonsBody(new PlanetConfig()
{
name = planetName,
starSystem = Main.Instance.CurrentStarSystem,
starSystem = starSystem,
ShipLog = new ShipLogModule()
{
spriteFolder = imageFolder
}
}, mod);
if (!Main.BodyDict.ContainsKey(Main.Instance.CurrentStarSystem))
if (!Main.BodyDict.ContainsKey(starSystem))
{
Main.BodyDict.Add(Main.Instance.CurrentStarSystem, new List<NewHorizonsBody>());
Main.BodyDict[Main.Instance.CurrentStarSystem].Add(body);
Main.BodyDict.Add(starSystem, new List<NewHorizonsBody>());
Main.BodyDict[starSystem].Add(body);
}
else
{
var existingBody = Main.BodyDict[Main.Instance.CurrentStarSystem]
var existingBody = Main.BodyDict[starSystem]
.FirstOrDefault(x => x.Config.name == planetName && x.Mod.ModHelper.Manifest.UniqueName == mod.ModHelper.Manifest.UniqueName);
if (existingBody != null)
{
@ -94,7 +97,7 @@ namespace NewHorizons
}
else
{
Main.BodyDict[Main.Instance.CurrentStarSystem].Add(body);
Main.BodyDict[starSystem].Add(body);
}
}
@ -108,7 +111,7 @@ namespace NewHorizons
.ToArray()
};
Main.Instance.LoadStarSystemConfig(system, null, mod);
Main.Instance.LoadStarSystemConfig(starSystem, system, null, mod);
RumorModeBuilder.AddShipLogXML(GameObject.FindObjectOfType<ShipLogManager>(), xml, body);
}