From 3a490cee896b93d3dbfb0963c4a9ded2dfb0d007 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Fri, 14 Feb 2025 21:28:13 -0800 Subject: [PATCH] use FindAll --- NewHorizons/Builder/Props/DetailBuilder.cs | 31 ++++++++----------- NewHorizons/Handlers/PlanetCreationHandler.cs | 7 +---- 2 files changed, 14 insertions(+), 24 deletions(-) diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index d2064b68..a598f7ed 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -220,15 +220,10 @@ namespace NewHorizons.Builder.Props if (detail.removeChildren != null) { - var detailPath = prop.transform.GetPath(); - var transforms = prop.GetComponentsInChildren(true); foreach (var childPath in detail.removeChildren) { - // Multiple children can have the same path so we delete all that match - var path = $"{detailPath}/{childPath}"; - var flag = true; - foreach (var childObj in transforms.Where(x => x.GetPath() == path)) + foreach (var childObj in prop.transform.FindAll(childPath)) { flag = false; childObj.gameObject.SetActive(false); @@ -264,7 +259,7 @@ namespace NewHorizons.Builder.Props UnityEngine.Object.DestroyImmediate(prop); prop = newDetailGO; } - + if (isItem) { // Else when you put them down you can't pick them back up @@ -276,7 +271,7 @@ namespace NewHorizons.Builder.Props // For DLC related props // Make sure to do this before its set active - if (!string.IsNullOrEmpty(detail?.path) && + if (!string.IsNullOrEmpty(detail?.path) && (detail.path.ToLowerInvariant().StartsWith("ringworld") || detail.path.ToLowerInvariant().StartsWith("dreamworld"))) { prop.AddComponent()._destroyOnDLCNotOwned = true; @@ -295,7 +290,7 @@ namespace NewHorizons.Builder.Props if (!string.IsNullOrEmpty(detail.activationCondition)) { - ConditionalObjectActivation.SetUp(prop, detail.activationCondition, detail.blinkWhenActiveChanged, true); + ConditionalObjectActivation.SetUp(prop, detail.activationCondition, detail.blinkWhenActiveChanged, true); } if (!string.IsNullOrEmpty(detail.deactivationCondition)) { @@ -569,22 +564,22 @@ namespace NewHorizons.Builder.Props // Manually copied these values from a artifact lantern so that we don't have to find it (works in Eye) lantern._origLensFlareBrightness = 0f; - lantern._focuserPetalsBaseEulerAngles = new Vector3[] - { - new Vector3(0.7f, 270.0f, 357.5f), - new Vector3(288.7f, 270.1f, 357.4f), + lantern._focuserPetalsBaseEulerAngles = new Vector3[] + { + new Vector3(0.7f, 270.0f, 357.5f), + new Vector3(288.7f, 270.1f, 357.4f), new Vector3(323.3f, 90.0f, 177.5f), - new Vector3(35.3f, 90.0f, 177.5f), - new Vector3(72.7f, 270.1f, 357.5f) + new Vector3(35.3f, 90.0f, 177.5f), + new Vector3(72.7f, 270.1f, 357.5f) }; lantern._dirtyFlag_focus = true; - lantern._concealerRootsBaseScale = new Vector3[] + lantern._concealerRootsBaseScale = new Vector3[] { Vector3.one, Vector3.one, Vector3.one }; - lantern._concealerCoversStartPos = new Vector3[] + lantern._concealerCoversStartPos = new Vector3[] { new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, -0.1f, 0.0f), @@ -595,7 +590,7 @@ namespace NewHorizons.Builder.Props }; lantern._dirtyFlag_concealment = true; lantern.UpdateVisuals(); - + Destroy(this); } } diff --git a/NewHorizons/Handlers/PlanetCreationHandler.cs b/NewHorizons/Handlers/PlanetCreationHandler.cs index 42884d9d..b188fd2d 100644 --- a/NewHorizons/Handlers/PlanetCreationHandler.cs +++ b/NewHorizons/Handlers/PlanetCreationHandler.cs @@ -1000,15 +1000,10 @@ namespace NewHorizons.Handlers private static void RemoveChildren(GameObject go, NewHorizonsBody body) { - var goPath = go.transform.GetPath(); - var transforms = go.GetComponentsInChildren(true); foreach (var childPath in body.Config.removeChildren) { - // Multiple children can have the same path so we delete all that match - var path = $"{goPath}/{childPath}"; - var flag = true; - foreach (var childObj in transforms.Where(x => x.GetPath() == path)) + foreach (var childObj in go.transform.FindAll(childPath)) { flag = false; // idk why we wait here but we do