diff --git a/NewHorizons/Builder/General/AstroObjectBuilder.cs b/NewHorizons/Builder/General/AstroObjectBuilder.cs index 21be3536..89b5c041 100644 --- a/NewHorizons/Builder/General/AstroObjectBuilder.cs +++ b/NewHorizons/Builder/General/AstroObjectBuilder.cs @@ -8,6 +8,8 @@ namespace NewHorizons.Builder.General { public static class AstroObjectBuilder { + public static GameObject CenterOfUniverse { get; private set; } + public static NHAstroObject Make(GameObject body, AstroObject primaryBody, NewHorizonsBody nhBody, bool isVanilla) { NHAstroObject astroObject = body.AddComponent(); @@ -62,6 +64,8 @@ namespace NewHorizons.Builder.General if (config.Base.centerOfSolarSystem) { + CenterOfUniverse = body; + NHLogger.Log($"Setting center of universe to {config.name}"); Delay.RunWhen( diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index fda247e7..380e4673 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -421,8 +421,8 @@ namespace NewHorizons.Handlers if (defaultPrimaryToSun) { NHLogger.LogError($"Couldn't find {body.Config.Orbit.primaryBody}, defaulting to center of solar system"); - // TODO: Make this work in other systems. We tried using Locator.GetCenterOfUniverse before but that doesn't work since its too early now - primaryBody = SearchUtilities.Find("Sun_Body")?.GetComponent(); + // Fix #933 not defaulting primary body + primaryBody = (SearchUtilities.Find("Sun_Body") ?? AstroObjectBuilder.CenterOfUniverse)?.GetComponent(); } else {