Fix things to happen after system config made

This commit is contained in:
Nick 2022-06-19 18:01:11 -04:00
parent 66201e63cc
commit fe5bda733e

View File

@ -454,18 +454,17 @@ namespace NewHorizons
var config = mod.ModHelper.Storage.Load<PlanetConfig>(relativeDirectory); var config = mod.ModHelper.Storage.Load<PlanetConfig>(relativeDirectory);
// var config = JsonConvert.DeserializeObject<PlanetConfig>(File.ReadAllText($"{mod.ModHelper.Manifest.ModFolderPath}/{relativeDirectory}")); // var config = JsonConvert.DeserializeObject<PlanetConfig>(File.ReadAllText($"{mod.ModHelper.Manifest.ModFolderPath}/{relativeDirectory}"));
config.MigrateAndValidate();
Logger.Log($"Loaded {config.name}"); Logger.Log($"Loaded {config.name}");
if (!SystemDict.ContainsKey(config.starSystem)) if (!SystemDict.ContainsKey(config.starSystem))
{ {
// Since we didn't load it earlier there shouldn't be a star system config // Since we didn't load it earlier there shouldn't be a star system config
var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>($"systems/{config.starSystem}.json"); var starSystemConfig = mod.ModHelper.Storage.Load<StarSystemConfig>($"systems/{config.starSystem}.json");
starSystemConfig.FixCoordinates();
if (starSystemConfig == null) starSystemConfig = new StarSystemConfig(); if (starSystemConfig == null) starSystemConfig = new StarSystemConfig();
else Logger.LogWarning($"Loaded system config for {config.starSystem}. Why wasn't this loaded earlier?"); else Logger.LogWarning($"Loaded system config for {config.starSystem}. Why wasn't this loaded earlier?");
starSystemConfig.FixCoordinates();
var system = new NewHorizonsSystem(config.starSystem, starSystemConfig, mod); var system = new NewHorizonsSystem(config.starSystem, starSystemConfig, mod);
SystemDict.Add(config.starSystem, system); SystemDict.Add(config.starSystem, system);
@ -473,6 +472,9 @@ namespace NewHorizons
BodyDict.Add(config.starSystem, new List<NewHorizonsBody>()); BodyDict.Add(config.starSystem, new List<NewHorizonsBody>());
} }
// Has to happen after we make sure theres a system config
config.MigrateAndValidate();
body = new NewHorizonsBody(config, mod, relativeDirectory); body = new NewHorizonsBody(config, mod, relativeDirectory);
} }
catch (Exception e) catch (Exception e)