From f30320e758062d649288e0f5e4593218e2fe8061 Mon Sep 17 00:00:00 2001 From: FreezeDriedMangoes Date: Sat, 25 Jun 2022 22:53:38 -0400 Subject: [PATCH 1/3] made AstroObjectLocator also register astro objects under the name of their game object, eg MyPlanet_Body --- NewHorizons/Utility/AstroObjectLocator.cs | 3 ++- NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs | 5 +---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/NewHorizons/Utility/AstroObjectLocator.cs b/NewHorizons/Utility/AstroObjectLocator.cs index 8c48e1bf..6287a3a2 100644 --- a/NewHorizons/Utility/AstroObjectLocator.cs +++ b/NewHorizons/Utility/AstroObjectLocator.cs @@ -69,7 +69,8 @@ namespace NewHorizons.Utility else { Logger.Log($"Registering [{ao.name}] as [{key}]"); - _customAstroObjectDictionary.Add(key, ao); + _customAstroObjectDictionary.Add(key, ao); + _customAstroObjectDictionary.Add(ao.name, ao); } } diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index b2d71191..f818490c 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs @@ -144,13 +144,10 @@ namespace NewHorizons.Utility.DebugUtilities public static string GetAstroObjectName(string bodyName) { - if (bodyName.EndsWith("_Body")) bodyName = bodyName.Substring(0, bodyName.Length-"_Body".Length); - var astroObject = AstroObjectLocator.GetAstroObject(bodyName); if (astroObject == null) return null; var astroObjectName = astroObject.name; - if (astroObjectName.EndsWith("_Body")) astroObjectName = astroObjectName.Substring(0, astroObjectName.Length-"_Body".Length); return astroObjectName; } @@ -202,7 +199,7 @@ namespace NewHorizons.Utility.DebugUtilities string bodyName = GetAstroObjectName(bodyGameObjectName); - Logger.Log("Adding prop to " + Main.Instance.CurrentStarSystem + "::" + bodyName); + Logger.Log("Adding prop to " + Main.Instance.CurrentStarSystem + "::" + bodyName + " (passed name: "+bodyGameObjectName+")"); detailInfo = detailInfo == null ? new DetailInfo() : detailInfo; From bfcee12e648a7970accfbd1dc1638fa71ce040ab Mon Sep 17 00:00:00 2001 From: FreezeDriedMangoes Date: Sun, 26 Jun 2022 22:12:45 -0400 Subject: [PATCH 2/3] updated the rest of AstroObjectLocator to account for there now being multiple keys per astro object --- NewHorizons/Utility/AstroObjectLocator.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/NewHorizons/Utility/AstroObjectLocator.cs b/NewHorizons/Utility/AstroObjectLocator.cs index 6287a3a2..5c54394f 100644 --- a/NewHorizons/Utility/AstroObjectLocator.cs +++ b/NewHorizons/Utility/AstroObjectLocator.cs @@ -77,17 +77,18 @@ namespace NewHorizons.Utility public static void DeregisterCustomAstroObject(AstroObject ao) { var key = ao._name == AstroObject.Name.CustomString ? ao.GetCustomName() : ao._name.ToString(); - _customAstroObjectDictionary.Remove(key); + _customAstroObjectDictionary.Remove(key); + _customAstroObjectDictionary.Remove(ao.name); } public static AstroObject[] GetAllAstroObjects() { - return _customAstroObjectDictionary.Values.ToArray(); + return _customAstroObjectDictionary.Values.Distinct().ToArray(); } public static GameObject[] GetMoons(AstroObject primary) { - return _customAstroObjectDictionary.Values.Where(x => x._primaryBody == primary).Select(x => x.gameObject).ToArray(); + return _customAstroObjectDictionary.Values.Distinct().Where(x => x._primaryBody == primary).Select(x => x.gameObject).ToArray(); } public static GameObject[] GetChildren(AstroObject primary) From 60d7d01bbf881503b4a6e0c729f5b1d448753524 Mon Sep 17 00:00:00 2001 From: FreezeDriedMangoes Date: Sun, 26 Jun 2022 22:23:34 -0400 Subject: [PATCH 3/3] replaced concat string with interp string --- NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs index f818490c..228aa9da 100644 --- a/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs +++ b/NewHorizons/Utility/DebugUtilities/DebugPropPlacer.cs @@ -199,7 +199,7 @@ namespace NewHorizons.Utility.DebugUtilities string bodyName = GetAstroObjectName(bodyGameObjectName); - Logger.Log("Adding prop to " + Main.Instance.CurrentStarSystem + "::" + bodyName + " (passed name: "+bodyGameObjectName+")"); + Logger.Log($"Adding prop to {Main.Instance.CurrentStarSystem}::{bodyName} (passed name: {bodyGameObjectName})"); detailInfo = detailInfo == null ? new DetailInfo() : detailInfo;