test both remove children methods

This commit is contained in:
JohnCorby 2025-02-14 21:15:53 -08:00
parent 2543d8b94d
commit 0fa7cfe2c5
2 changed files with 24 additions and 14 deletions

View File

@ -1,3 +1,4 @@
using HarmonyLib;
using NewHorizons.Builder.General; using NewHorizons.Builder.General;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Components.Orbital; using NewHorizons.Components.Orbital;
@ -228,12 +229,16 @@ namespace NewHorizons.Builder.Props
var path = $"{detailPath}/{childPath}"; var path = $"{detailPath}/{childPath}";
var flag = true; var flag = true;
foreach (var childObj in transforms.Where(x => x.GetPath() == path)) var childObjs = transforms.Where(x => x.GetPath() == path).ToList();
var childObjs2 = go.transform.FindAll(childPath);
foreach (var childObj in childObjs)
{ {
flag = false; flag = false;
childObj.gameObject.SetActive(false); childObj.gameObject.SetActive(false);
} }
Main.Instance.ModHelper.Console.WriteLine($"remove children detail\n{prop.transform.GetPath()}\n{childPath}\n\n{childObjs.Join()}\n{childObjs2.Join()}");
if (flag) NHLogger.LogWarning($"Couldn't find \"{childPath}\"."); if (flag) NHLogger.LogWarning($"Couldn't find \"{childPath}\".");
} }
} }
@ -264,7 +269,7 @@ namespace NewHorizons.Builder.Props
UnityEngine.Object.DestroyImmediate(prop); UnityEngine.Object.DestroyImmediate(prop);
prop = newDetailGO; prop = newDetailGO;
} }
if (isItem) if (isItem)
{ {
// Else when you put them down you can't pick them back up // Else when you put them down you can't pick them back up
@ -276,7 +281,7 @@ namespace NewHorizons.Builder.Props
// For DLC related props // For DLC related props
// Make sure to do this before its set active // 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"))) (detail.path.ToLowerInvariant().StartsWith("ringworld") || detail.path.ToLowerInvariant().StartsWith("dreamworld")))
{ {
prop.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true; prop.AddComponent<DestroyOnDLC>()._destroyOnDLCNotOwned = true;
@ -295,7 +300,7 @@ namespace NewHorizons.Builder.Props
if (!string.IsNullOrEmpty(detail.activationCondition)) 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)) if (!string.IsNullOrEmpty(detail.deactivationCondition))
{ {
@ -569,22 +574,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) // Manually copied these values from a artifact lantern so that we don't have to find it (works in Eye)
lantern._origLensFlareBrightness = 0f; lantern._origLensFlareBrightness = 0f;
lantern._focuserPetalsBaseEulerAngles = new Vector3[] lantern._focuserPetalsBaseEulerAngles = new Vector3[]
{ {
new Vector3(0.7f, 270.0f, 357.5f), new Vector3(0.7f, 270.0f, 357.5f),
new Vector3(288.7f, 270.1f, 357.4f), new Vector3(288.7f, 270.1f, 357.4f),
new Vector3(323.3f, 90.0f, 177.5f), new Vector3(323.3f, 90.0f, 177.5f),
new Vector3(35.3f, 90.0f, 177.5f), new Vector3(35.3f, 90.0f, 177.5f),
new Vector3(72.7f, 270.1f, 357.5f) new Vector3(72.7f, 270.1f, 357.5f)
}; };
lantern._dirtyFlag_focus = true; lantern._dirtyFlag_focus = true;
lantern._concealerRootsBaseScale = new Vector3[] lantern._concealerRootsBaseScale = new Vector3[]
{ {
Vector3.one, Vector3.one,
Vector3.one, 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.0f, 0.0f),
new Vector3(0.0f, -0.1f, 0.0f), new Vector3(0.0f, -0.1f, 0.0f),
@ -595,7 +600,7 @@ namespace NewHorizons.Builder.Props
}; };
lantern._dirtyFlag_concealment = true; lantern._dirtyFlag_concealment = true;
lantern.UpdateVisuals(); lantern.UpdateVisuals();
Destroy(this); Destroy(this);
} }
} }

View File

@ -1,3 +1,4 @@
using HarmonyLib;
using NewHorizons.Builder.Atmosphere; using NewHorizons.Builder.Atmosphere;
using NewHorizons.Builder.Body; using NewHorizons.Builder.Body;
using NewHorizons.Builder.General; using NewHorizons.Builder.General;
@ -1008,7 +1009,9 @@ namespace NewHorizons.Handlers
var path = $"{goPath}/{childPath}"; var path = $"{goPath}/{childPath}";
var flag = true; var flag = true;
foreach (var childObj in transforms.Where(x => x.GetPath() == path)) var childObjs = transforms.Where(x => x.GetPath() == path).ToList();
var childObjs2 = go.transform.FindAll(childPath);
foreach (var childObj in childObjs)
{ {
flag = false; flag = false;
// idk why we wait here but we do // idk why we wait here but we do
@ -1021,6 +1024,8 @@ namespace NewHorizons.Handlers
}, 2); }, 2);
} }
Main.Instance.ModHelper.Console.WriteLine($"remove children planet\n{go.transform.GetPath()}\n{childPath}\n\n{childObjs.Join()}\n{childObjs2.Join()}");
if (flag) NHLogger.LogWarning($"Couldn't find \"{childPath}\"."); if (flag) NHLogger.LogWarning($"Couldn't find \"{childPath}\".");
} }
} }