extension

This commit is contained in:
JohnCorby 2022-06-30 20:34:06 -07:00
parent 9aa6bf540c
commit 06dab3fa5b
3 changed files with 4 additions and 4 deletions

View File

@ -29,7 +29,7 @@ namespace NewHorizons.Handlers
GameObject panRoot = SearchUtilities.Find(PAN_ROOT_PATH);
if (panRoot != null)
{
List<GameObject> gameObjects = SearchUtilities.GetAllChildren(panRoot);
List<GameObject> gameObjects = panRoot.GetAllChildren();
_vanillaBodies = gameObjects.ConvertAll(g => g.name).ToArray();
_vanillaBodyIDs = gameObjects.ConvertAll(g => g.GetComponent<ShipLogAstroObject>()?.GetID()).ToArray();
}

View File

@ -145,7 +145,7 @@ namespace NewHorizons.Patches
__instance._startingAstroObjectID = navMatrix[1][0].GetID();
if (Main.Instance.CurrentStarSystem != "SolarSystem")
{
List<GameObject> delete = SearchUtilities.GetAllChildren(panRoot).Where(g => g.name.Contains("_ShipLog") == false).ToList();
List<GameObject> delete = panRoot.GetAllChildren().Where(g => g.name.Contains("_ShipLog") == false).ToList();
foreach (GameObject gameObject in delete)
{
Object.Destroy(SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name));
@ -182,7 +182,7 @@ namespace NewHorizons.Patches
Transform detailsParent = __instance.transform.Find("Details");
if (detailsParent != null)
{
foreach (GameObject child in SearchUtilities.GetAllChildren(detailsParent.gameObject))
foreach (GameObject child in detailsParent.gameObject.GetAllChildren())
{
if (child.TryGetComponent(typeof(ShipLogDetail), out Component detail))
{

View File

@ -160,7 +160,7 @@ namespace NewHorizons.Utility
}
}
public static List<GameObject> GetAllChildren(GameObject parent)
public static List<GameObject> GetAllChildren(this GameObject parent)
{
List<GameObject> children = new List<GameObject>();
foreach (Transform child in parent.transform)