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;
// 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";
var atmo = SearchUtilities.FindChild(dimensionSector, "Atmosphere_HubDimension");
var geom = SearchUtilities.FindChild(dimensionSector, "Geometry_HubDimension");
var vols = SearchUtilities.FindChild(dimensionSector, "Volumes_HubDimension");
var efxs = SearchUtilities.FindChild(dimensionSector, "Effects_HubDimension");
var intr = SearchUtilities.FindChild(dimensionSector, "Interactables_HubDimension");
var exitWarps = SearchUtilities.FindChild(intr, "OuterWarp_Hub");
var atmo = dimensionSector.FindChild("Atmosphere_HubDimension");
var geom = dimensionSector.FindChild("Geometry_HubDimension");
var vols = dimensionSector.FindChild("Volumes_HubDimension");
var efxs = dimensionSector.FindChild("Effects_HubDimension");
var intr = dimensionSector.FindChild("Interactables_HubDimension");
var exitWarps = intr.FindChild("OuterWarp_Hub");
exitWarps.name = "OuterWarp";
exitWarps.transform.parent = dimensionSector.transform;
@ -79,7 +79,7 @@ namespace NewHorizons.Builder.Body
// change fog color
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>();
fog.fogTint = body.Config.Bramble.dimension.fogTint.ToColor();
}

View File

@ -48,10 +48,10 @@ namespace NewHorizons.Builder.Props
private static OuterFogWarpVolume GetOuterFogWarpVolumeFromAstroObject(GameObject go)
{
var sector = SearchUtilities.FindChild(go, "Sector");
var sector = go.FindChild("Sector");
if (sector == null) return null;
var outerWarpGO = SearchUtilities.FindChild(sector, "OuterWarp");
var outerWarpGO = sector.FindChild("OuterWarp");
if (outerWarpGO == null) return null;
var outerFogWarpVolume = outerWarpGO.GetComponent<OuterFogWarpVolume>();
@ -117,7 +117,7 @@ namespace NewHorizons.Builder.Props
var warpController = brambleNode.GetComponent<InnerFogWarpVolume>();
// 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
@ -155,8 +155,8 @@ namespace NewHorizons.Builder.Props
public static void SetNodeColors(GameObject brambleNode, Color fogTint, Color lightTint)
{
var fogRenderer = brambleNode.GetComponent<InnerFogWarpVolume>();
var effects = SearchUtilities.FindChild(brambleNode, "Effects");
var lightShafts = SearchUtilities.FindChild(effects, "DB_BrambleLightShafts");
var effects = brambleNode.FindChild("Effects");
var lightShafts = effects.FindChild("DB_BrambleLightShafts");
if (fogTint != null)
{
@ -166,13 +166,13 @@ namespace NewHorizons.Builder.Props
if (lightTint != null)
{
var lightShaft1 = SearchUtilities.FindChild(lightShafts, "BrambleLightShaft1");
var lightShaft1 = lightShafts.FindChild("BrambleLightShaft1");
var mat = lightShaft1.GetComponent<MeshRenderer>().material;
mat.color = lightTint;
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;
}
}
@ -180,9 +180,9 @@ namespace NewHorizons.Builder.Props
public static void SetSeedColors(GameObject brambleSeed, Color fogTint, Color lightTint)
{
var fogRenderer = SearchUtilities.FindChild(brambleSeed, "VolumetricFogSphere (2)");
var effects = SearchUtilities.FindChild(brambleSeed, "Terrain_DB_BrambleSphere_Seed_V2 (2)");
var lightShafts = SearchUtilities.FindChild(effects, "DB_SeedLightShafts");
var fogRenderer = brambleSeed.FindChild("VolumetricFogSphere (2)");
var effects = brambleSeed.FindChild("Terrain_DB_BrambleSphere_Seed_V2 (2)");
var lightShafts = effects.FindChild("DB_SeedLightShafts");
if (fogTint != null)
{
@ -194,13 +194,13 @@ namespace NewHorizons.Builder.Props
if (lightTint != null)
{
var lightShaft1 = SearchUtilities.FindChild(lightShafts, "DB_SeedLightShafts1");
var lightShaft1 = lightShafts.FindChild("DB_SeedLightShafts1");
var mat = lightShaft1.GetComponent<MeshRenderer>().material;
mat.color = lightTint;
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;
}
}

View File

@ -304,7 +304,7 @@ namespace NewHorizons.Handlers
{
var go = BrambleDimensionBuilder.Make(body);
var ao = go.GetComponent<AstroObject>();
var sector = SearchUtilities.FindChild(go, "Sector").GetComponent<Sector>();
var sector = go.FindChild("Sector").GetComponent<Sector>();
var owRigidBody = go.GetComponent<OWRigidbody>();
go = SharedGenerateBody(body, go, sector, owRigidBody);