use FindChild as extension method

This commit is contained in:
JohnCorby 2022-07-01 12:46:40 -07:00
parent e4254ee6ec
commit 900d1e70b4
3 changed files with 650 additions and 650 deletions

View File

@ -50,14 +50,14 @@ namespace NewHorizons.Builder.Body
ao.transform.position = body.Config.Orbit.staticPosition; ao.transform.position = body.Config.Orbit.staticPosition;
// fix children's names and remove base game props (mostly just bramble nodes that are children to Interactibles) and set up the OuterWarp child // fix children's names and remove base game props (mostly just bramble nodes that are children to Interactibles) and set up the OuterWarp child
var dimensionSector = SearchUtilities.FindChild(dimension, "Sector_HubDimension"); var dimensionSector = dimension.FindChild("Sector_HubDimension");
dimensionSector.name = "Sector"; dimensionSector.name = "Sector";
var atmo = SearchUtilities.FindChild(dimensionSector, "Atmosphere_HubDimension"); var atmo = dimensionSector.FindChild("Atmosphere_HubDimension");
var geom = SearchUtilities.FindChild(dimensionSector, "Geometry_HubDimension"); var geom = dimensionSector.FindChild("Geometry_HubDimension");
var vols = SearchUtilities.FindChild(dimensionSector, "Volumes_HubDimension"); var vols = dimensionSector.FindChild("Volumes_HubDimension");
var efxs = SearchUtilities.FindChild(dimensionSector, "Effects_HubDimension"); var efxs = dimensionSector.FindChild("Effects_HubDimension");
var intr = SearchUtilities.FindChild(dimensionSector, "Interactables_HubDimension"); var intr = dimensionSector.FindChild("Interactables_HubDimension");
var exitWarps = SearchUtilities.FindChild(intr, "OuterWarp_Hub"); var exitWarps = intr.FindChild("OuterWarp_Hub");
exitWarps.name = "OuterWarp"; exitWarps.name = "OuterWarp";
exitWarps.transform.parent = dimensionSector.transform; exitWarps.transform.parent = dimensionSector.transform;
@ -79,7 +79,7 @@ namespace NewHorizons.Builder.Body
// change fog color // change fog color
if (body.Config.Bramble.dimension.fogTint != null) if (body.Config.Bramble.dimension.fogTint != null)
{ {
var fogGO = SearchUtilities.FindChild(atmo, "FogSphere_Hub"); var fogGO = atmo.FindChild("FogSphere_Hub");
var fog = fogGO.GetComponent<PlanetaryFogController>(); var fog = fogGO.GetComponent<PlanetaryFogController>();
fog.fogTint = body.Config.Bramble.dimension.fogTint.ToColor(); fog.fogTint = body.Config.Bramble.dimension.fogTint.ToColor();
} }

View File

@ -48,10 +48,10 @@ namespace NewHorizons.Builder.Props
private static OuterFogWarpVolume GetOuterFogWarpVolumeFromAstroObject(GameObject go) private static OuterFogWarpVolume GetOuterFogWarpVolumeFromAstroObject(GameObject go)
{ {
var sector = SearchUtilities.FindChild(go, "Sector"); var sector = go.FindChild("Sector");
if (sector == null) return null; if (sector == null) return null;
var outerWarpGO = SearchUtilities.FindChild(sector, "OuterWarp"); var outerWarpGO = sector.FindChild("OuterWarp");
if (outerWarpGO == null) return null; if (outerWarpGO == null) return null;
var outerFogWarpVolume = outerWarpGO.GetComponent<OuterFogWarpVolume>(); var outerFogWarpVolume = outerWarpGO.GetComponent<OuterFogWarpVolume>();
@ -117,7 +117,7 @@ namespace NewHorizons.Builder.Props
var warpController = brambleNode.GetComponent<InnerFogWarpVolume>(); var warpController = brambleNode.GetComponent<InnerFogWarpVolume>();
// this node comes with Feldspar's signal, we don't want that though // this node comes with Feldspar's signal, we don't want that though
GameObject.Destroy(SearchUtilities.FindChild(brambleNode, "Signal_Harmonica")); GameObject.Destroy(brambleNode.FindChild("Signal_Harmonica"));
// //
// change the colors // change the colors
@ -155,8 +155,8 @@ namespace NewHorizons.Builder.Props
public static void SetNodeColors(GameObject brambleNode, Color fogTint, Color lightTint) public static void SetNodeColors(GameObject brambleNode, Color fogTint, Color lightTint)
{ {
var fogRenderer = brambleNode.GetComponent<InnerFogWarpVolume>(); var fogRenderer = brambleNode.GetComponent<InnerFogWarpVolume>();
var effects = SearchUtilities.FindChild(brambleNode, "Effects"); var effects = brambleNode.FindChild("Effects");
var lightShafts = SearchUtilities.FindChild(effects, "DB_BrambleLightShafts"); var lightShafts = effects.FindChild("DB_BrambleLightShafts");
if (fogTint != null) if (fogTint != null)
{ {
@ -166,13 +166,13 @@ namespace NewHorizons.Builder.Props
if (lightTint != null) if (lightTint != null)
{ {
var lightShaft1 = SearchUtilities.FindChild(lightShafts, "BrambleLightShaft1"); var lightShaft1 = lightShafts.FindChild("BrambleLightShaft1");
var mat = lightShaft1.GetComponent<MeshRenderer>().material; var mat = lightShaft1.GetComponent<MeshRenderer>().material;
mat.color = lightTint; mat.color = lightTint;
for (int i = 1; i <= 6; i++) for (int i = 1; i <= 6; i++)
{ {
var lightShaft = SearchUtilities.FindChild(lightShafts, $"BrambleLightShaft{i}"); var lightShaft = lightShafts.FindChild($"BrambleLightShaft{i}");
lightShaft.GetComponent<MeshRenderer>().sharedMaterial = mat; lightShaft.GetComponent<MeshRenderer>().sharedMaterial = mat;
} }
} }
@ -180,9 +180,9 @@ namespace NewHorizons.Builder.Props
public static void SetSeedColors(GameObject brambleSeed, Color fogTint, Color lightTint) public static void SetSeedColors(GameObject brambleSeed, Color fogTint, Color lightTint)
{ {
var fogRenderer = SearchUtilities.FindChild(brambleSeed, "VolumetricFogSphere (2)"); var fogRenderer = brambleSeed.FindChild("VolumetricFogSphere (2)");
var effects = SearchUtilities.FindChild(brambleSeed, "Terrain_DB_BrambleSphere_Seed_V2 (2)"); var effects = brambleSeed.FindChild("Terrain_DB_BrambleSphere_Seed_V2 (2)");
var lightShafts = SearchUtilities.FindChild(effects, "DB_SeedLightShafts"); var lightShafts = effects.FindChild("DB_SeedLightShafts");
if (fogTint != null) if (fogTint != null)
{ {
@ -194,13 +194,13 @@ namespace NewHorizons.Builder.Props
if (lightTint != null) if (lightTint != null)
{ {
var lightShaft1 = SearchUtilities.FindChild(lightShafts, "DB_SeedLightShafts1"); var lightShaft1 = lightShafts.FindChild("DB_SeedLightShafts1");
var mat = lightShaft1.GetComponent<MeshRenderer>().material; var mat = lightShaft1.GetComponent<MeshRenderer>().material;
mat.color = lightTint; mat.color = lightTint;
for (int i = 1; i <= 6; i++) for (int i = 1; i <= 6; i++)
{ {
var lightShaft = SearchUtilities.FindChild(lightShafts, $"DB_SeedLightShafts{i}"); var lightShaft = lightShafts.FindChild($"DB_SeedLightShafts{i}");
lightShaft.GetComponent<MeshRenderer>().sharedMaterial = mat; lightShaft.GetComponent<MeshRenderer>().sharedMaterial = mat;
} }
} }

File diff suppressed because it is too large Load Diff