Use SearchUtilities.Find instead GameObject.Find

This commit is contained in:
Noah Pilarski 2022-05-30 00:56:12 -04:00
parent 4bcaef968d
commit 977c790ef5
39 changed files with 175 additions and 165 deletions

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Atmosphere namespace NewHorizons.Builder.Atmosphere
{ {
@ -16,7 +17,7 @@ namespace NewHorizons.Builder.Atmosphere
if (atmosphereModule.useAtmosphereShader) if (atmosphereModule.useAtmosphereShader)
{ {
GameObject atmo = GameObject.Instantiate(GameObject.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere"), atmoGO.transform, true); GameObject atmo = GameObject.Instantiate(SearchUtilities.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere"), atmoGO.transform, true);
atmo.transform.position = planetGO.transform.TransformPoint(Vector3.zero); atmo.transform.position = planetGO.transform.TransformPoint(Vector3.zero);
atmo.transform.localScale = Vector3.one * atmosphereModule.size * 1.2f; atmo.transform.localScale = Vector3.one * atmosphereModule.size * 1.2f;
foreach (var meshRenderer in atmo.GetComponentsInChildren<MeshRenderer>()) foreach (var meshRenderer in atmo.GetComponentsInChildren<MeshRenderer>())

View File

@ -21,7 +21,7 @@ namespace NewHorizons.Builder.Atmosphere
public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod) public static void Make(GameObject planetGO, Sector sector, AtmosphereModule atmo, IModBehaviour mod)
{ {
if (_lightningPrefab == null) _lightningPrefab = GameObject.Find("GiantsDeep_Body/Sector_GD/Clouds_GD/LightningGenerator_GD"); if (_lightningPrefab == null) _lightningPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Clouds_GD/LightningGenerator_GD");
if (_colorRamp == null) _colorRamp = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/textures/Clouds_Bottom_ramp.png"); if (_colorRamp == null) _colorRamp = ImageUtilities.GetTexture(Main.Instance, "AssetBundle/textures/Clouds_Bottom_ramp.png");
GameObject cloudsMainGO = new GameObject("Clouds"); GameObject cloudsMainGO = new GameObject("Clouds");
@ -36,8 +36,8 @@ namespace NewHorizons.Builder.Atmosphere
cloudsBottomGO.transform.localScale = Vector3.one * atmo.clouds.innerCloudRadius; cloudsBottomGO.transform.localScale = Vector3.one * atmo.clouds.innerCloudRadius;
TessellatedSphereRenderer bottomTSR = cloudsBottomGO.AddComponent<TessellatedSphereRenderer>(); TessellatedSphereRenderer bottomTSR = cloudsBottomGO.AddComponent<TessellatedSphereRenderer>();
bottomTSR.tessellationMeshGroup = GameObject.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup; bottomTSR.tessellationMeshGroup = SearchUtilities.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().tessellationMeshGroup;
var bottomTSRMaterials = GameObject.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().sharedMaterials; var bottomTSRMaterials = SearchUtilities.Find("CloudsBottomLayer_QM").GetComponent<TessellatedSphereRenderer>().sharedMaterials;
// If they set a colour apply it to all the materials else keep the default QM one // If they set a colour apply it to all the materials else keep the default QM one
if (atmo.clouds.tint != null) if (atmo.clouds.tint != null)
@ -165,12 +165,12 @@ namespace NewHorizons.Builder.Atmosphere
cloudsTopGO.transform.localScale = Vector3.one * atmo.clouds.outerCloudRadius; cloudsTopGO.transform.localScale = Vector3.one * atmo.clouds.outerCloudRadius;
MeshFilter topMF = cloudsTopGO.AddComponent<MeshFilter>(); MeshFilter topMF = cloudsTopGO.AddComponent<MeshFilter>();
topMF.mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh; topMF.mesh = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
MeshRenderer topMR = cloudsTopGO.AddComponent<MeshRenderer>(); MeshRenderer topMR = cloudsTopGO.AddComponent<MeshRenderer>();
if (_sphereShader == null) _sphereShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader"); if (_sphereShader == null) _sphereShader = Main.NHAssetBundle.LoadAsset<Shader>("Assets/Shaders/SphereTextureWrapper.shader");
if (_gdCloudMaterials == null) _gdCloudMaterials = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials; if (_gdCloudMaterials == null) _gdCloudMaterials = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshRenderer>().sharedMaterials;
var tempArray = new Material[2]; var tempArray = new Material[2];
if (atmo.clouds.useBasicCloudShader) if (atmo.clouds.useBasicCloudShader)

View File

@ -17,9 +17,9 @@ namespace NewHorizons.Builder.Atmosphere
fogGO.transform.localScale = Vector3.one; fogGO.transform.localScale = Vector3.one;
// Going to copy from dark bramble // Going to copy from dark bramble
var dbFog = GameObject.Find("DarkBramble_Body/Atmosphere_DB/FogLOD"); var dbFog = SearchUtilities.Find("DarkBramble_Body/Atmosphere_DB/FogLOD");
var dbPlanetaryFogController = GameObject.Find("DarkBramble_Body/Atmosphere_DB/FogSphere_DB").GetComponent<PlanetaryFogController>(); var dbPlanetaryFogController = SearchUtilities.Find("DarkBramble_Body/Atmosphere_DB/FogSphere_DB").GetComponent<PlanetaryFogController>();
var brambleLODFog = GameObject.Find("DarkBramble_Body/Sector_DB/Proxy_DB/LOD_DB_VolumeticFog"); var brambleLODFog = SearchUtilities.Find("DarkBramble_Body/Sector_DB/Proxy_DB/LOD_DB_VolumeticFog");
MeshFilter MF = fogGO.AddComponent<MeshFilter>(); MeshFilter MF = fogGO.AddComponent<MeshFilter>();
MF.mesh = dbFog.GetComponent<MeshFilter>().mesh; MF.mesh = dbFog.GetComponent<MeshFilter>().mesh;

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Atmosphere namespace NewHorizons.Builder.Atmosphere
{ {
@ -37,7 +38,7 @@ namespace NewHorizons.Builder.Atmosphere
EffectRuleset ER = rulesetGO.AddComponent<EffectRuleset>(); EffectRuleset ER = rulesetGO.AddComponent<EffectRuleset>();
ER._type = EffectRuleset.BubbleType.Underwater; ER._type = EffectRuleset.BubbleType.Underwater;
var gdRuleset = GameObject.Find("GiantsDeep_Body/Sector_GD/Volumes_GD/RulesetVolumes_GD").GetComponent<EffectRuleset>(); var gdRuleset = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Volumes_GD/RulesetVolumes_GD").GetComponent<EffectRuleset>();
ER._material = gdRuleset._material; ER._material = gdRuleset._material;

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
{ {
@ -6,7 +7,7 @@ namespace NewHorizons.Builder.Body
{ {
public static void Make(GameObject planetGO, Sector sector, PlanetConfig config) public static void Make(GameObject planetGO, Sector sector, PlanetConfig config)
{ {
var cometTail = GameObject.Instantiate(GameObject.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), sector?.transform ?? planetGO.transform); var cometTail = GameObject.Instantiate(SearchUtilities.Find("Comet_Body/Sector_CO/Effects_CO/Effects_CO_TailMeshes"), sector?.transform ?? planetGO.transform);
cometTail.transform.position = planetGO.transform.position; cometTail.transform.position = planetGO.transform.position;
cometTail.name = "CometTail"; cometTail.name = "CometTail";
cometTail.transform.localScale = Vector3.one * config.Base.surfaceSize / 110; cometTail.transform.localScale = Vector3.one * config.Base.surfaceSize / 110;

View File

@ -1,4 +1,4 @@
using System.Runtime.Serialization; using System.Runtime.Serialization;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
@ -43,13 +43,13 @@ namespace NewHorizons.Builder.Body
scaleRoot.transform.localPosition = Vector3.zero; scaleRoot.transform.localPosition = Vector3.zero;
scaleRoot.transform.localScale = new Vector3(1, 1, 1); scaleRoot.transform.localScale = new Vector3(1, 1, 1);
var proxyGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Proxy_SandFunnel"), scaleRoot.transform); var proxyGO = GameObject.Instantiate(SearchUtilities.Find("SandFunnel_Body/ScaleRoot/Proxy_SandFunnel"), scaleRoot.transform);
proxyGO.name = "Proxy_Funnel"; proxyGO.name = "Proxy_Funnel";
var geoGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Geo_SandFunnel"), scaleRoot.transform); var geoGO = GameObject.Instantiate(SearchUtilities.Find("SandFunnel_Body/ScaleRoot/Geo_SandFunnel"), scaleRoot.transform);
geoGO.name = "Geo_Funnel"; geoGO.name = "Geo_Funnel";
var volumesGO = GameObject.Instantiate(GameObject.Find("SandFunnel_Body/ScaleRoot/Volumes_SandFunnel"), scaleRoot.transform); var volumesGO = GameObject.Instantiate(SearchUtilities.Find("SandFunnel_Body/ScaleRoot/Volumes_SandFunnel"), scaleRoot.transform);
volumesGO.name = "Volumes_Funnel"; volumesGO.name = "Volumes_Funnel";
var sfv = volumesGO.GetComponentInChildren<SimpleFluidVolume>(); var sfv = volumesGO.GetComponentInChildren<SimpleFluidVolume>();
var fluidVolume = sfv.gameObject; var fluidVolume = sfv.gameObject;
@ -63,7 +63,7 @@ namespace NewHorizons.Builder.Body
GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);
var waterMaterials = GameObject.Find("TimberHearth_Body/Sector_TH/Geometry_TH/Terrain_TH_Water_v3/Village_Upper_Water/Village_Upper_Water_Geo").GetComponent<MeshRenderer>().materials; var waterMaterials = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Geometry_TH/Terrain_TH_Water_v3/Village_Upper_Water/Village_Upper_Water_Geo").GetComponent<MeshRenderer>().materials;
var materials = new Material[waterMaterials.Length]; var materials = new Material[waterMaterials.Length];
for (int i = 0; i < waterMaterials.Length; i++) for (int i = 0; i < waterMaterials.Length; i++)
{ {
@ -111,7 +111,7 @@ namespace NewHorizons.Builder.Body
GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject); GameObject.Destroy(geoGO.transform.Find("Effects_HT_SandColumn/SandColumn_Interior").gameObject);
var lavaMaterial = new Material(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").GetComponent<MeshRenderer>().material); var lavaMaterial = new Material(SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").GetComponent<MeshRenderer>().material);
lavaMaterial.mainTextureOffset = new Vector2(0.1f, 0.2f); lavaMaterial.mainTextureOffset = new Vector2(0.1f, 0.2f);
lavaMaterial.mainTextureScale = new Vector2(1f, 3f); lavaMaterial.mainTextureScale = new Vector2(1f, 3f);

View File

@ -1,4 +1,5 @@
using UnityEngine; using UnityEngine;
using NewHorizons.Utility;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
{ {
public static class GeometryBuilder public static class GeometryBuilder
@ -9,7 +10,7 @@ namespace NewHorizons.Builder.Body
groundGO.transform.parent = sector?.transform ?? planetGO.transform; groundGO.transform.parent = sector?.transform ?? planetGO.transform;
groundGO.transform.localScale = new Vector3(groundScale, groundScale, groundScale); groundGO.transform.localScale = new Vector3(groundScale, groundScale, groundScale);
groundGO.transform.position = planetGO.transform.position; groundGO.transform.position = planetGO.transform.position;
groundGO.GetComponent<MeshFilter>().mesh = GameObject.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh; groundGO.GetComponent<MeshFilter>().mesh = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh;
groundGO.GetComponent<SphereCollider>().radius = 1f; groundGO.GetComponent<SphereCollider>().radius = 1f;
groundGO.SetActive(true); groundGO.SetActive(true);
} }

View File

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using NewHorizons.Utility;
using NewHorizons.External.Modules.VariableSize; using NewHorizons.External.Modules.VariableSize;
namespace NewHorizons.Builder.Body namespace NewHorizons.Builder.Body
@ -28,7 +29,7 @@ namespace NewHorizons.Builder.Body
moltenCore.transform.position = planetGO.transform.position; moltenCore.transform.position = planetGO.transform.position;
moltenCore.transform.localScale = Vector3.one * module.size; moltenCore.transform.localScale = Vector3.one * module.size;
var lavaSphere = GameObject.Instantiate(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere"), moltenCore.transform); var lavaSphere = GameObject.Instantiate(SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere"), moltenCore.transform);
lavaSphere.transform.localScale = Vector3.one; lavaSphere.transform.localScale = Vector3.one;
lavaSphere.transform.name = "LavaSphere"; lavaSphere.transform.name = "LavaSphere";
lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale); lavaSphere.GetComponent<MeshRenderer>().material.SetFloat(HeightScale, heightScale);
@ -37,7 +38,7 @@ namespace NewHorizons.Builder.Body
var sectorCullGroup = lavaSphere.GetComponent<SectorCullGroup>(); var sectorCullGroup = lavaSphere.GetComponent<SectorCullGroup>();
sectorCullGroup.SetSector(sector); sectorCullGroup.SetSector(sector);
var moltenCoreProxy = GameObject.Instantiate(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/MoltenCore_Proxy"), moltenCore.transform); ; var moltenCoreProxy = GameObject.Instantiate(SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/MoltenCore_Proxy"), moltenCore.transform); ;
moltenCoreProxy.name = "MoltenCore_Proxy"; moltenCoreProxy.name = "MoltenCore_Proxy";
var proxyLavaSphere = moltenCoreProxy.transform.Find("LavaSphere (1)"); var proxyLavaSphere = moltenCoreProxy.transform.Find("LavaSphere (1)");
@ -50,7 +51,7 @@ namespace NewHorizons.Builder.Body
sectorProxy._renderers = new List<Renderer> { proxyLavaSphere.GetComponent<MeshRenderer>() }; sectorProxy._renderers = new List<Renderer> { proxyLavaSphere.GetComponent<MeshRenderer>() };
sectorProxy.SetSector(sector); sectorProxy.SetSector(sector);
var destructionVolume = GameObject.Instantiate(GameObject.Find("VolcanicMoon_Body/MoltenCore_VM/DestructionVolume"), moltenCore.transform); var destructionVolume = GameObject.Instantiate(SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/DestructionVolume"), moltenCore.transform);
destructionVolume.GetComponent<SphereCollider>().radius = 1; destructionVolume.GetComponent<SphereCollider>().radius = 1;
destructionVolume.SetActive(true); destructionVolume.SetActive(true);

View File

@ -1,4 +1,4 @@
using NewHorizons.Builder.Atmosphere; using NewHorizons.Builder.Atmosphere;
using NewHorizons.Builder.Props; using NewHorizons.Builder.Props;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Components.SizeControllers; using NewHorizons.Components.SizeControllers;
@ -176,7 +176,7 @@ namespace NewHorizons.Builder.Body
private static void MakeBlackHole(GameObject rootObject, float size) private static void MakeBlackHole(GameObject rootObject, float size)
{ {
if (_blackHolePrefab == null) _blackHolePrefab = GameObject.Find(_blackHolePath); if (_blackHolePrefab == null) _blackHolePrefab = SearchUtilities.Find(_blackHolePath);
var blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().material.shader; var blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().material.shader;
if (blackHoleShader == null) blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader; if (blackHoleShader == null) blackHoleShader = _blackHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader;
@ -201,7 +201,7 @@ namespace NewHorizons.Builder.Body
private static void MakeWhiteHole(GameObject rootObject, float size) private static void MakeWhiteHole(GameObject rootObject, float size)
{ {
if (_whiteHolePrefab == null) _whiteHolePrefab = GameObject.Find(_whiteHolePath); if (_whiteHolePrefab == null) _whiteHolePrefab = SearchUtilities.Find(_whiteHolePath);
var whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().material.shader; var whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().material.shader;
if (whiteHoleShader == null) whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader; if (whiteHoleShader == null) whiteHoleShader = _whiteHolePrefab.GetComponent<MeshRenderer>().sharedMaterial.shader;

View File

@ -1,4 +1,4 @@
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
using NewHorizons.External.Modules.VariableSize; using NewHorizons.External.Modules.VariableSize;
@ -11,7 +11,7 @@ namespace NewHorizons.Builder.Body
var sandGO = new GameObject("Sand"); var sandGO = new GameObject("Sand");
sandGO.SetActive(false); sandGO.SetActive(false);
var sandSphere = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/SandSphere"), sandGO.transform); var sandSphere = GameObject.Instantiate(SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/SandSphere"), sandGO.transform);
if (module.tint != null) if (module.tint != null)
{ {
var oldMR = sandSphere.GetComponent<TessellatedSphereRenderer>(); var oldMR = sandSphere.GetComponent<TessellatedSphereRenderer>();
@ -28,13 +28,13 @@ namespace NewHorizons.Builder.Body
sandMR.sharedMaterials[1].color = module.tint.ToColor(); sandMR.sharedMaterials[1].color = module.tint.ToColor();
} }
var collider = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/Collider"), sandGO.transform); var collider = GameObject.Instantiate(SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/Collider"), sandGO.transform);
var sphereCollider = collider.GetComponent<SphereCollider>(); var sphereCollider = collider.GetComponent<SphereCollider>();
collider.SetActive(true); collider.SetActive(true);
var occlusionSphere = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/OcclusionSphere"), sandGO.transform); var occlusionSphere = GameObject.Instantiate(SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/OcclusionSphere"), sandGO.transform);
var proxyShadowCasterGO = GameObject.Instantiate(GameObject.Find("TowerTwin_Body/SandSphere_Draining/ProxyShadowCaster"), sandGO.transform); var proxyShadowCasterGO = GameObject.Instantiate(SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/ProxyShadowCaster"), sandGO.transform);
var proxyShadowCaster = proxyShadowCasterGO.GetComponent<ProxyShadowCaster>(); var proxyShadowCaster = proxyShadowCasterGO.GetComponent<ProxyShadowCaster>();
proxyShadowCaster.SetSuperGroup(sandGO.GetComponent<ProxyShadowCasterSuperGroup>()); proxyShadowCaster.SetSuperGroup(sandGO.GetComponent<ProxyShadowCasterSuperGroup>());

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.Utility; using NewHorizons.Utility;
using System; using System;
@ -88,10 +88,10 @@ namespace NewHorizons.Builder.Body
blackHoleRender.transform.localScale = Vector3.one * size; blackHoleRender.transform.localScale = Vector3.one * size;
var meshFilter = blackHoleRender.AddComponent<MeshFilter>(); var meshFilter = blackHoleRender.AddComponent<MeshFilter>();
meshFilter.mesh = GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshFilter>().mesh; meshFilter.mesh = SearchUtilities.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshFilter>().mesh;
var meshRenderer = blackHoleRender.AddComponent<MeshRenderer>(); var meshRenderer = blackHoleRender.AddComponent<MeshRenderer>();
if (blackHoleShader == null) blackHoleShader = GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshRenderer>().sharedMaterial.shader; if (blackHoleShader == null) blackHoleShader = SearchUtilities.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleRenderer").GetComponent<MeshRenderer>().sharedMaterial.shader;
meshRenderer.material = new Material(blackHoleShader); meshRenderer.material = new Material(blackHoleShader);
meshRenderer.material.SetFloat(Radius, size * 0.4f); meshRenderer.material.SetFloat(Radius, size * 0.4f);
meshRenderer.material.SetFloat(MaxDistortRadius, size * 0.95f); meshRenderer.material.SetFloat(MaxDistortRadius, size * 0.95f);
@ -100,7 +100,7 @@ namespace NewHorizons.Builder.Body
if (makeAudio) if (makeAudio)
{ {
var blackHoleAmbience = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleAmbience"), blackHole.transform); var blackHoleAmbience = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleAmbience"), blackHole.transform);
blackHoleAmbience.name = "BlackHoleAmbience"; blackHoleAmbience.name = "BlackHoleAmbience";
blackHoleAmbience.GetComponent<SectorAudioGroup>().SetSector(sector); blackHoleAmbience.GetComponent<SectorAudioGroup>().SetSector(sector);
@ -109,7 +109,7 @@ namespace NewHorizons.Builder.Body
blackHoleAudioSource.minDistance = size * 0.4f; blackHoleAudioSource.minDistance = size * 0.4f;
blackHoleAmbience.transform.localPosition = Vector3.zero; blackHoleAmbience.transform.localPosition = Vector3.zero;
var blackHoleOneShot = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleEmissionOneShot"), blackHole.transform); var blackHoleOneShot = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleEmissionOneShot"), blackHole.transform);
var oneShotAudioSource = blackHoleOneShot.GetComponent<AudioSource>(); var oneShotAudioSource = blackHoleOneShot.GetComponent<AudioSource>();
oneShotAudioSource.maxDistance = size * 3f; oneShotAudioSource.maxDistance = size * 3f;
oneShotAudioSource.minDistance = size * 0.4f; oneShotAudioSource.minDistance = size * 0.4f;
@ -137,7 +137,7 @@ namespace NewHorizons.Builder.Body
} }
else else
{ {
var blackHoleVolume = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleVolume"), blackHole.transform); var blackHoleVolume = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/BlackHole_BH/BlackHoleVolume"), blackHole.transform);
blackHoleVolume.name = "BlackHoleVolume"; blackHoleVolume.name = "BlackHoleVolume";
blackHoleVolume.GetComponent<SphereCollider>().radius = size * 0.4f; blackHoleVolume.GetComponent<SphereCollider>().radius = size * 0.4f;
} }
@ -159,10 +159,10 @@ namespace NewHorizons.Builder.Body
whiteHoleRenderer.transform.localScale = Vector3.one * size * 2.8f; whiteHoleRenderer.transform.localScale = Vector3.one * size * 2.8f;
var meshFilter = whiteHoleRenderer.AddComponent<MeshFilter>(); var meshFilter = whiteHoleRenderer.AddComponent<MeshFilter>();
meshFilter.mesh = GameObject.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshFilter>().mesh; meshFilter.mesh = SearchUtilities.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshFilter>().mesh;
var meshRenderer = whiteHoleRenderer.AddComponent<MeshRenderer>(); var meshRenderer = whiteHoleRenderer.AddComponent<MeshRenderer>();
if (whiteHoleShader == null) whiteHoleShader = GameObject.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshRenderer>().sharedMaterial.shader; if (whiteHoleShader == null) whiteHoleShader = SearchUtilities.Find("WhiteHole_Body/WhiteHoleVisuals/Singularity").GetComponent<MeshRenderer>().sharedMaterial.shader;
meshRenderer.material = new Material(whiteHoleShader); meshRenderer.material = new Material(whiteHoleShader);
meshRenderer.sharedMaterial.SetFloat(Radius, size * 0.4f); meshRenderer.sharedMaterial.SetFloat(Radius, size * 0.4f);
meshRenderer.sharedMaterial.SetFloat(DistortFadeDist, size); meshRenderer.sharedMaterial.SetFloat(DistortFadeDist, size);
@ -170,14 +170,14 @@ namespace NewHorizons.Builder.Body
meshRenderer.sharedMaterial.SetFloat(MassScale, -1); meshRenderer.sharedMaterial.SetFloat(MassScale, -1);
meshRenderer.sharedMaterial.SetColor(Color1, new Color(1.88f, 1.88f, 1.88f, 1f)); meshRenderer.sharedMaterial.SetColor(Color1, new Color(1.88f, 1.88f, 1.88f, 1f));
var ambientLight = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/WhiteHoleVisuals/AmbientLight_WH")); var ambientLight = GameObject.Instantiate(SearchUtilities.Find("WhiteHole_Body/WhiteHoleVisuals/AmbientLight_WH"));
ambientLight.transform.parent = whiteHole.transform; ambientLight.transform.parent = whiteHole.transform;
ambientLight.transform.localScale = Vector3.one; ambientLight.transform.localScale = Vector3.one;
ambientLight.transform.localPosition = Vector3.zero; ambientLight.transform.localPosition = Vector3.zero;
ambientLight.name = "AmbientLight"; ambientLight.name = "AmbientLight";
ambientLight.GetComponent<Light>().range = size * 7f; ambientLight.GetComponent<Light>().range = size * 7f;
GameObject whiteHoleVolumeGO = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/WhiteHoleVolume")); GameObject whiteHoleVolumeGO = GameObject.Instantiate(SearchUtilities.Find("WhiteHole_Body/WhiteHoleVolume"));
whiteHoleVolumeGO.transform.parent = whiteHole.transform; whiteHoleVolumeGO.transform.parent = whiteHole.transform;
whiteHoleVolumeGO.transform.localPosition = Vector3.zero; whiteHoleVolumeGO.transform.localPosition = Vector3.zero;
whiteHoleVolumeGO.transform.localScale = Vector3.one; whiteHoleVolumeGO.transform.localScale = Vector3.one;
@ -205,13 +205,13 @@ namespace NewHorizons.Builder.Body
if (makeZeroGVolume) if (makeZeroGVolume)
{ {
var zeroGVolume = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/ZeroGVolume"), whiteHole.transform); var zeroGVolume = GameObject.Instantiate(SearchUtilities.Find("WhiteHole_Body/ZeroGVolume"), whiteHole.transform);
zeroGVolume.name = "ZeroGVolume"; zeroGVolume.name = "ZeroGVolume";
zeroGVolume.transform.localPosition = Vector3.zero; zeroGVolume.transform.localPosition = Vector3.zero;
zeroGVolume.GetComponent<SphereCollider>().radius = size * 10f; zeroGVolume.GetComponent<SphereCollider>().radius = size * 10f;
zeroGVolume.GetComponent<ZeroGVolume>()._attachedBody = OWRB; zeroGVolume.GetComponent<ZeroGVolume>()._attachedBody = OWRB;
var rulesetVolume = GameObject.Instantiate(GameObject.Find("WhiteHole_Body/Sector_WhiteHole/RulesetVolumes_WhiteHole"), planetGO.transform); var rulesetVolume = GameObject.Instantiate(SearchUtilities.Find("WhiteHole_Body/Sector_WhiteHole/RulesetVolumes_WhiteHole"), planetGO.transform);
rulesetVolume.name = "RulesetVolume"; rulesetVolume.name = "RulesetVolume";
rulesetVolume.transform.localPosition = Vector3.zero; rulesetVolume.transform.localPosition = Vector3.zero;
rulesetVolume.transform.localScale = Vector3.one * size / 100f; rulesetVolume.transform.localScale = Vector3.one * size / 100f;

View File

@ -23,7 +23,7 @@ namespace NewHorizons.Builder.Body
{ {
var starGO = MakeStarGraphics(planetGO, sector, starModule); var starGO = MakeStarGraphics(planetGO, sector, starModule);
var sunAudio = Object.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Audio_SUN"), starGO.transform); var sunAudio = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Audio_SUN"), starGO.transform);
sunAudio.transform.localPosition = Vector3.zero; sunAudio.transform.localPosition = Vector3.zero;
sunAudio.transform.localScale = Vector3.one; sunAudio.transform.localScale = Vector3.one;
sunAudio.transform.Find("SurfaceAudio_Sun").GetComponent<AudioSource>().maxDistance = starModule.size * 2f; sunAudio.transform.Find("SurfaceAudio_Sun").GetComponent<AudioSource>().maxDistance = starModule.size * 2f;
@ -36,7 +36,7 @@ namespace NewHorizons.Builder.Body
GameObject sunAtmosphere = null; GameObject sunAtmosphere = null;
if (starModule.hasAtmosphere) if (starModule.hasAtmosphere)
{ {
sunAtmosphere = Object.Instantiate(GameObject.Find("Sun_Body/Atmosphere_SUN"), starGO.transform); sunAtmosphere = Object.Instantiate(SearchUtilities.Find("Sun_Body/Atmosphere_SUN"), starGO.transform);
sunAtmosphere.transform.position = planetGO.transform.position; sunAtmosphere.transform.position = planetGO.transform.position;
sunAtmosphere.transform.localScale = Vector3.one * OuterRadiusRatio; sunAtmosphere.transform.localScale = Vector3.one * OuterRadiusRatio;
sunAtmosphere.name = "Atmosphere_Star"; sunAtmosphere.name = "Atmosphere_Star";
@ -59,17 +59,17 @@ namespace NewHorizons.Builder.Body
fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f); fog.lodFadeDistance = fog.fogRadius * (StarBuilder.OuterRadiusRatio - 1f);
} }
var ambientLightGO = Object.Instantiate(GameObject.Find("Sun_Body/AmbientLight_SUN"), starGO.transform); var ambientLightGO = Object.Instantiate(SearchUtilities.Find("Sun_Body/AmbientLight_SUN"), starGO.transform);
ambientLightGO.transform.localPosition = Vector3.zero; ambientLightGO.transform.localPosition = Vector3.zero;
ambientLightGO.name = "AmbientLight_Star"; ambientLightGO.name = "AmbientLight_Star";
var heatVolume = Object.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Volumes_SUN/HeatVolume"), starGO.transform); var heatVolume = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN/HeatVolume"), starGO.transform);
heatVolume.transform.localPosition = Vector3.zero; heatVolume.transform.localPosition = Vector3.zero;
heatVolume.transform.localScale = Vector3.one; heatVolume.transform.localScale = Vector3.one;
heatVolume.GetComponent<SphereShape>().radius = 1f; heatVolume.GetComponent<SphereShape>().radius = 1f;
heatVolume.name = "HeatVolume"; heatVolume.name = "HeatVolume";
var deathVolume = Object.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Volumes_SUN/ScaledVolumesRoot/DestructionFluidVolume"), starGO.transform); var deathVolume = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN/ScaledVolumesRoot/DestructionFluidVolume"), starGO.transform);
deathVolume.transform.localPosition = Vector3.zero; deathVolume.transform.localPosition = Vector3.zero;
deathVolume.transform.localScale = Vector3.one; deathVolume.transform.localScale = Vector3.one;
deathVolume.GetComponent<SphereCollider>().radius = 1f; deathVolume.GetComponent<SphereCollider>().radius = 1f;
@ -85,7 +85,7 @@ namespace NewHorizons.Builder.Body
sunLight.transform.localScale = Vector3.one; sunLight.transform.localScale = Vector3.one;
var light = sunLight.AddComponent<Light>(); var light = sunLight.AddComponent<Light>();
light.CopyPropertiesFrom(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>()); light.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>());
light.intensity *= starModule.solarLuminosity; light.intensity *= starModule.solarLuminosity;
light.range *= Mathf.Sqrt(starModule.solarLuminosity); light.range *= Mathf.Sqrt(starModule.solarLuminosity);
@ -96,12 +96,12 @@ namespace NewHorizons.Builder.Body
ambientLight.color = lightColour; ambientLight.color = lightColour;
var faceActiveCamera = sunLight.AddComponent<FaceActiveCamera>(); var faceActiveCamera = sunLight.AddComponent<FaceActiveCamera>();
faceActiveCamera.CopyPropertiesFrom(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<FaceActiveCamera>()); faceActiveCamera.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<FaceActiveCamera>());
var csmTextureCacher = sunLight.AddComponent<CSMTextureCacher>(); var csmTextureCacher = sunLight.AddComponent<CSMTextureCacher>();
csmTextureCacher.CopyPropertiesFrom(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<CSMTextureCacher>()); csmTextureCacher.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<CSMTextureCacher>());
csmTextureCacher._light = light; csmTextureCacher._light = light;
var proxyShadowLight = sunLight.AddComponent<ProxyShadowLight>(); var proxyShadowLight = sunLight.AddComponent<ProxyShadowLight>();
proxyShadowLight.CopyPropertiesFrom(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<ProxyShadowLight>()); proxyShadowLight.CopyPropertiesFrom(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<ProxyShadowLight>());
proxyShadowLight._light = light; proxyShadowLight._light = light;
StarController starController = null; StarController starController = null;
@ -172,12 +172,12 @@ namespace NewHorizons.Builder.Body
var starGO = new GameObject("Star"); var starGO = new GameObject("Star");
starGO.transform.parent = sector?.transform ?? rootObject.transform; starGO.transform.parent = sector?.transform ?? rootObject.transform;
var sunSurface = Object.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Geometry_SUN/Surface"), starGO.transform); var sunSurface = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Geometry_SUN/Surface"), starGO.transform);
sunSurface.transform.position = rootObject.transform.position; sunSurface.transform.position = rootObject.transform.position;
sunSurface.transform.localScale = Vector3.one; sunSurface.transform.localScale = Vector3.one;
sunSurface.name = "Surface"; sunSurface.name = "Surface";
var solarFlareEmitter = Object.Instantiate(GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SolarFlareEmitter"), starGO.transform); var solarFlareEmitter = Object.Instantiate(SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SolarFlareEmitter"), starGO.transform);
solarFlareEmitter.transform.localPosition = Vector3.zero; solarFlareEmitter.transform.localPosition = Vector3.zero;
solarFlareEmitter.transform.localScale = Vector3.one; solarFlareEmitter.transform.localScale = Vector3.one;
solarFlareEmitter.name = "SolarFlareEmitter"; solarFlareEmitter.name = "SolarFlareEmitter";
@ -204,7 +204,7 @@ namespace NewHorizons.Builder.Body
var colour = starModule.tint.ToColor(); var colour = starModule.tint.ToColor();
var sun = GameObject.Find("Sun_Body"); var sun = SearchUtilities.Find("Sun_Body");
var mainSequenceMaterial = sun.GetComponent<SunController>()._startSurfaceMaterial; var mainSequenceMaterial = sun.GetComponent<SunController>()._startSurfaceMaterial;
var giantMaterial = sun.GetComponent<SunController>()._endSurfaceMaterial; var giantMaterial = sun.GetComponent<SunController>()._endSurfaceMaterial;
@ -230,7 +230,7 @@ namespace NewHorizons.Builder.Body
private static SupernovaEffectController MakeSupernova(GameObject starGO, StarModule starModule) private static SupernovaEffectController MakeSupernova(GameObject starGO, StarModule starModule)
{ {
var supernovaGO = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/Supernova").InstantiateInactive(); var supernovaGO = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/Supernova").InstantiateInactive();
supernovaGO.transform.SetParent(starGO.transform); supernovaGO.transform.SetParent(starGO.transform);
supernovaGO.transform.localPosition = Vector3.zero; supernovaGO.transform.localPosition = Vector3.zero;

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Components.SizeControllers; using NewHorizons.Components.SizeControllers;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
@ -19,7 +19,7 @@ namespace NewHorizons.Builder.Body
waterGO.transform.parent = sector?.transform ?? planetGO.transform; waterGO.transform.parent = sector?.transform ?? planetGO.transform;
waterGO.transform.localScale = new Vector3(waterSize, waterSize, waterSize); waterGO.transform.localScale = new Vector3(waterSize, waterSize, waterSize);
var GDTSR = GameObject.Find("Ocean_GD").GetComponent<TessellatedSphereRenderer>(); var GDTSR = SearchUtilities.Find("Ocean_GD").GetComponent<TessellatedSphereRenderer>();
TessellatedSphereRenderer TSR = waterGO.AddComponent<TessellatedSphereRenderer>(); TessellatedSphereRenderer TSR = waterGO.AddComponent<TessellatedSphereRenderer>();
TSR.tessellationMeshGroup = ScriptableObject.CreateInstance<MeshGroup>(); TSR.tessellationMeshGroup = ScriptableObject.CreateInstance<MeshGroup>();
@ -30,7 +30,7 @@ namespace NewHorizons.Builder.Body
TSR.tessellationMeshGroup.variants[i] = mesh; TSR.tessellationMeshGroup.variants[i] = mesh;
} }
var GDSharedMaterials = GameObject.Find("Ocean_GD").GetComponent<TessellatedSphereLOD>()._lowAltitudeMaterials; var GDSharedMaterials = SearchUtilities.Find("Ocean_GD").GetComponent<TessellatedSphereLOD>()._lowAltitudeMaterials;
var tempArray = new Material[GDSharedMaterials.Length]; var tempArray = new Material[GDSharedMaterials.Length];
for (int i = 0; i < GDSharedMaterials.Length; i++) for (int i = 0; i < GDSharedMaterials.Length; i++)
{ {
@ -87,7 +87,7 @@ namespace NewHorizons.Builder.Body
fluidVolume._radius = waterSize; fluidVolume._radius = waterSize;
fluidVolume._layer = LayerMask.NameToLayer("BasicEffectVolume"); fluidVolume._layer = LayerMask.NameToLayer("BasicEffectVolume");
var fogGO = GameObject.Instantiate(GameObject.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/OceanFog"), waterGO.transform); var fogGO = GameObject.Instantiate(SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/OceanFog"), waterGO.transform);
fogGO.name = "OceanFog"; fogGO.name = "OceanFog";
fogGO.transform.localPosition = Vector3.zero; fogGO.transform.localPosition = Vector3.zero;
fogGO.transform.localScale = Vector3.one; fogGO.transform.localScale = Vector3.one;

View File

@ -1,11 +1,12 @@
using UnityEngine; using UnityEngine;
using NewHorizons.Utility;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
{ {
public static class AmbientLightBuilder public static class AmbientLightBuilder
{ {
public static void Make(GameObject planetGO, Sector sector, float scale, float intensity) public static void Make(GameObject planetGO, Sector sector, float scale, float intensity)
{ {
GameObject lightGO = GameObject.Instantiate(GameObject.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), sector?.transform ?? planetGO.transform); GameObject lightGO = GameObject.Instantiate(SearchUtilities.Find("BrittleHollow_Body/AmbientLight_BH_Surface"), sector?.transform ?? planetGO.transform);
lightGO.transform.position = planetGO.transform.position; lightGO.transform.position = planetGO.transform.position;
lightGO.name = "Light"; lightGO.name = "Light";

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
{ {
@ -27,7 +28,7 @@ namespace NewHorizons.Builder.General
owRigidBody._maintainOriginalCenterOfMass = true; owRigidBody._maintainOriginalCenterOfMass = true;
owRigidBody._rigidbody = rigidBody; owRigidBody._rigidbody = rigidBody;
owRigidBody._kinematicRigidbody = kinematicRigidBody; owRigidBody._kinematicRigidbody = kinematicRigidBody;
owRigidBody._origParent = GameObject.Find("SolarSystemRoot").transform; owRigidBody._origParent = SearchUtilities.Find("SolarSystemRoot").transform;
owRigidBody.EnableKinematicSimulation(); owRigidBody.EnableKinematicSimulation();
owRigidBody.MakeKinematic(); owRigidBody.MakeKinematic();

View File

@ -1,4 +1,5 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Builder.General namespace NewHorizons.Builder.General
@ -43,7 +44,7 @@ namespace NewHorizons.Builder.General
spawnPoint._isShipSpawn = true; spawnPoint._isShipSpawn = true;
spawnPoint._triggerVolumes = new OWTriggerVolume[0]; spawnPoint._triggerVolumes = new OWTriggerVolume[0];
var ship = GameObject.Find("Ship_Body"); var ship = SearchUtilities.Find("Ship_Body");
ship.transform.position = spawnPoint.transform.position; ship.transform.position = spawnPoint.transform.position;
if(module.shipSpawnRotation != null) if(module.shipSpawnRotation != null)
@ -92,7 +93,7 @@ namespace NewHorizons.Builder.General
Locator.GetPlayerTransform().GetComponent<PlayerSpacesuit>().SuitUp(false, true, true); Locator.GetPlayerTransform().GetComponent<PlayerSpacesuit>().SuitUp(false, true, true);
// Make the ship act as if the player took the suit // Make the ship act as if the player took the suit
var spv = GameObject.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear")?.GetComponent<SuitPickupVolume>(); var spv = SearchUtilities.Find("Ship_Body/Module_Supplies/Systems_Supplies/ExpeditionGear")?.GetComponent<SuitPickupVolume>();
if (spv == null) return; if (spv == null) return;

View File

@ -150,7 +150,7 @@ namespace NewHorizons.Builder.Props
{ {
torchItem.enabled = true; torchItem.enabled = true;
torchItem.mindProjectorTrigger.enabled = true; torchItem.mindProjectorTrigger.enabled = true;
torchItem.mindSlideProjector._mindProjectorImageEffect = GameObject.Find("Player_Body/PlayerCamera").GetComponent<MindProjectorImageEffect>(); torchItem.mindSlideProjector._mindProjectorImageEffect = SearchUtilities.Find("Player_Body/PlayerCamera").GetComponent<MindProjectorImageEffect>();
} }
} }
else else

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Props namespace NewHorizons.Builder.Props
@ -7,7 +7,7 @@ namespace NewHorizons.Builder.Props
{ {
public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInfo info) public static void Make(GameObject planetGO, Sector sector, PropModule.GeyserInfo info)
{ {
var original = GameObject.Find("TimberHearth_Body/Sector_TH/Interactables_TH/Geysers/Geyser_Village"); var original = SearchUtilities.Find("TimberHearth_Body/Sector_TH/Interactables_TH/Geysers/Geyser_Village");
GameObject geyserGO = original.InstantiateInactive(); GameObject geyserGO = original.InstantiateInactive();
geyserGO.transform.parent = sector?.transform ?? planetGO.transform; geyserGO.transform.parent = sector?.transform ?? planetGO.transform;
geyserGO.name = "Geyser"; geyserGO.name = "Geyser";

View File

@ -51,18 +51,18 @@ namespace NewHorizons.Builder.Props
_ghostArcPrefabs.Add(arc); _ghostArcPrefabs.Add(arc);
} }
_scrollPrefab = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Scroll").InstantiateInactive(); _scrollPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_NorthHemisphere/Sector_NorthPole/Sector_HangingCity/Sector_HangingCity_District2/Interactables_HangingCity_District2/Prefab_NOM_Scroll").InstantiateInactive();
_scrollPrefab.name = "Prefab_NOM_Scroll"; _scrollPrefab.name = "Prefab_NOM_Scroll";
_computerPrefab = GameObject.Find("VolcanicMoon_Body/Sector_VM/Interactables_VM/Prefab_NOM_Computer").InstantiateInactive(); _computerPrefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Interactables_VM/Prefab_NOM_Computer").InstantiateInactive();
_computerPrefab.name = "Prefab_NOM_Computer"; _computerPrefab.name = "Prefab_NOM_Computer";
_computerPrefab.transform.rotation = Quaternion.identity; _computerPrefab.transform.rotation = Quaternion.identity;
_cairnPrefab = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_Crossroads/Interactables_Crossroads/Trailmarkers/Prefab_NOM_BH_Cairn_Arc (1)").InstantiateInactive(); _cairnPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_Crossroads/Interactables_Crossroads/Trailmarkers/Prefab_NOM_BH_Cairn_Arc (1)").InstantiateInactive();
_cairnPrefab.name = "Prefab_NOM_Cairn"; _cairnPrefab.name = "Prefab_NOM_Cairn";
_cairnPrefab.transform.rotation = Quaternion.identity; _cairnPrefab.transform.rotation = Quaternion.identity;
_recorderPrefab = GameObject.Find("Comet_Body/Prefab_NOM_Shuttle/Sector_NomaiShuttleInterior/Interactibles_NomaiShuttleInterior/Prefab_NOM_Recorder").InstantiateInactive(); _recorderPrefab = SearchUtilities.Find("Comet_Body/Prefab_NOM_Shuttle/Sector_NomaiShuttleInterior/Interactibles_NomaiShuttleInterior/Prefab_NOM_Recorder").InstantiateInactive();
_recorderPrefab.name = "Prefab_NOM_Recorder"; _recorderPrefab.name = "Prefab_NOM_Recorder";
_recorderPrefab.transform.rotation = Quaternion.identity; _recorderPrefab.transform.rotation = Quaternion.identity;
} }

View File

@ -41,7 +41,7 @@ namespace NewHorizons.Builder.Props
{ {
if (_slideReelPrefab == null) if (_slideReelPrefab == null)
{ {
_slideReelPrefab = GameObject.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone1/Sector_SlideBurningRoom_Zone1/Interactables_SlideBurningRoom_Zone1/Prefab_IP_SecretAlcove/RotationPivot/SlideReelSocket/Prefab_IP_Reel_1_LibraryPath")?.gameObject?.InstantiateInactive(); _slideReelPrefab = SearchUtilities.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone1/Sector_SlideBurningRoom_Zone1/Interactables_SlideBurningRoom_Zone1/Prefab_IP_SecretAlcove/RotationPivot/SlideReelSocket/Prefab_IP_Reel_1_LibraryPath")?.gameObject?.InstantiateInactive();
if (_slideReelPrefab == null) if (_slideReelPrefab == null)
{ {
Logger.LogWarning($"Tried to make a slide reel but couldn't. Do you have the DLC installed?"); Logger.LogWarning($"Tried to make a slide reel but couldn't. Do you have the DLC installed?");
@ -139,7 +139,7 @@ namespace NewHorizons.Builder.Props
{ {
if (_autoPrefab == null) if (_autoPrefab == null)
{ {
_autoPrefab = GameObject.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone4/Sector_BlightedShore/Sector_JammingControlRoom_Zone4/Interactables_JammingControlRoom_Zone4/AutoProjector_SignalJammer/Prefab_IP_AutoProjector_SignalJammer")?.gameObject?.InstantiateInactive(); _autoPrefab = SearchUtilities.Find("RingWorld_Body/Sector_RingInterior/Sector_Zone4/Sector_BlightedShore/Sector_JammingControlRoom_Zone4/Interactables_JammingControlRoom_Zone4/AutoProjector_SignalJammer/Prefab_IP_AutoProjector_SignalJammer")?.gameObject?.InstantiateInactive();
if (_autoPrefab == null) if (_autoPrefab == null)
{ {
Logger.LogWarning($"Tried to make a auto projector but couldn't. Do you have the DLC installed?"); Logger.LogWarning($"Tried to make a auto projector but couldn't. Do you have the DLC installed?");
@ -261,7 +261,7 @@ namespace NewHorizons.Builder.Props
// //
var mindSlideProjector = standingTorch.GetComponent<MindSlideProjector>(); var mindSlideProjector = standingTorch.GetComponent<MindSlideProjector>();
mindSlideProjector._mindProjectorImageEffect = GameObject.Find("Player_Body/PlayerCamera").GetComponent<MindProjectorImageEffect>(); mindSlideProjector._mindProjectorImageEffect = SearchUtilities.Find("Player_Body/PlayerCamera").GetComponent<MindProjectorImageEffect>();
// setup for visually supporting async texture loading // setup for visually supporting async texture loading
mindSlideProjector.enabled = false; mindSlideProjector.enabled = false;

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Configs; using NewHorizons.External.Configs;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Common; using OWML.Common;
@ -44,7 +44,7 @@ namespace NewHorizons.Builder.Props
GameObject prefab; GameObject prefab;
if (propInfo.assetBundle != null) prefab = AssetBundleUtilities.LoadPrefab(propInfo.assetBundle, propInfo.path, mod); if (propInfo.assetBundle != null) prefab = AssetBundleUtilities.LoadPrefab(propInfo.assetBundle, propInfo.path, mod);
else prefab = GameObject.Find(propInfo.path); else prefab = SearchUtilities.Find(propInfo.path);
for (int i = 0; i < propInfo.count; i++) for (int i = 0; i < propInfo.count; i++)
{ {
var randomInd = (int)Random.Range(0, points.Count - 1); var randomInd = (int)Random.Range(0, points.Count - 1);

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Common; using OWML.Common;
@ -192,7 +192,7 @@ namespace NewHorizons.Builder.Props
source.rolloffMode = AudioRolloffMode.Custom; source.rolloffMode = AudioRolloffMode.Custom;
if (_customCurve == null) if (_customCurve == null)
_customCurve = GameObject.Find("Moon_Body/Sector_THM/Characters_THM/Villager_HEA_Esker/Signal_Whistling").GetComponent<AudioSource>().GetCustomCurve(AudioSourceCurveType.CustomRolloff); _customCurve = SearchUtilities.Find("Moon_Body/Sector_THM/Characters_THM/Villager_HEA_Esker/Signal_Whistling").GetComponent<AudioSource>().GetCustomCurve(AudioSourceCurveType.CustomRolloff);
source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, _customCurve); source.SetCustomCurve(AudioSourceCurveType.CustomRolloff, _customCurve);
// If it can be heard regularly then we play it immediately // If it can be heard regularly then we play it immediately

View File

@ -26,17 +26,17 @@ namespace NewHorizons.Builder.Props
{ {
if (_upPrefab == null) if (_upPrefab == null)
{ {
_upPrefab = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/MockUpTornado").InstantiateInactive(); _upPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/MockUpTornado").InstantiateInactive();
_upPrefab.name = "Tornado_Up_Prefab"; _upPrefab.name = "Tornado_Up_Prefab";
} }
if (_downPrefab == null) if (_downPrefab == null)
{ {
_downPrefab = GameObject.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/MockDownTornado").InstantiateInactive(); _downPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/MockDownTornado").InstantiateInactive();
_downPrefab.name = "Tornado_Down_Prefab"; _downPrefab.name = "Tornado_Down_Prefab";
} }
if (_hurricanePrefab == null) if (_hurricanePrefab == null)
{ {
_hurricanePrefab = GameObject.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/Hurricane/").InstantiateInactive(); _hurricanePrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/Hurricane/").InstantiateInactive();
// For some reason they put the hurricane at the origin and offset all its children (450) // For some reason they put the hurricane at the origin and offset all its children (450)
// Increasing by 40 will keep the bottom above the ground // Increasing by 40 will keep the bottom above the ground
foreach (Transform child in _hurricanePrefab.transform) foreach (Transform child in _hurricanePrefab.transform)
@ -50,7 +50,7 @@ namespace NewHorizons.Builder.Props
} }
if (_soundPrefab == null) if (_soundPrefab == null)
{ {
_soundPrefab = GameObject.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/SouthernTornadoes/DownTornado_Pivot/DownTornado/AudioRail").InstantiateInactive(); _soundPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Tornadoes_GDInterior/SouthernTornadoes/DownTornado_Pivot/DownTornado/AudioRail").InstantiateInactive();
_soundPrefab.name = "AudioRail_Prefab"; _soundPrefab.name = "AudioRail_Prefab";
} }
if (_mainTexture == null) if (_mainTexture == null)

View File

@ -1,4 +1,4 @@
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Builder.Props namespace NewHorizons.Builder.Props
@ -12,7 +12,7 @@ namespace NewHorizons.Builder.Props
public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoInfo info) public static void Make(GameObject planetGO, Sector sector, PropModule.VolcanoInfo info)
{ {
var prefab = GameObject.Find("VolcanicMoon_Body/Sector_VM/Effects_VM/VolcanoPivot (2)/MeteorLauncher"); var prefab = SearchUtilities.Find("VolcanicMoon_Body/Sector_VM/Effects_VM/VolcanoPivot (2)/MeteorLauncher");
var launcherGO = prefab.InstantiateInactive(); var launcherGO = prefab.InstantiateInactive();
launcherGO.transform.parent = sector.transform; launcherGO.transform.parent = sector.transform;

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.External.Modules; using NewHorizons.External.Modules;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
@ -16,7 +16,7 @@ namespace NewHorizons.Builder.ShipLog
#region General #region General
public static ShipLogAstroObject[][] ConstructMapMode(string systemName, GameObject transformParent, ShipLogAstroObject[][] currentNav, int layer) public static ShipLogAstroObject[][] ConstructMapMode(string systemName, GameObject transformParent, ShipLogAstroObject[][] currentNav, int layer)
{ {
Material greyScaleMaterial = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/Sprite").GetComponent<Image>().material; Material greyScaleMaterial = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/TimberHearth/Sprite").GetComponent<Image>().material;
List<NewHorizonsBody> bodies = Main.BodyDict[systemName].Where( List<NewHorizonsBody> bodies = Main.BodyDict[systemName].Where(
b => !(b.Config.ShipLog?.mapMode?.remove ?? false) && !b.Config.isQuantumState b => !(b.Config.ShipLog?.mapMode?.remove ?? false) && !b.Config.isQuantumState
).ToList(); ).ToList();
@ -251,12 +251,12 @@ namespace NewHorizons.Builder.ShipLog
navMatrix[navIndex[0]][navIndex[1]] = null; navMatrix[navIndex[0]][navIndex[1]] = null;
if (astroObject.GetID() == "CAVE_TWIN" || astroObject.GetID() == "TOWER_TWIN") if (astroObject.GetID() == "CAVE_TWIN" || astroObject.GetID() == "TOWER_TWIN")
{ {
GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false); SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false);
} }
} }
else if (name == "SandFunnel") else if (name == "SandFunnel")
{ {
GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false); SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel").SetActive(false);
} }
gameObject.SetActive(false); gameObject.SetActive(false);
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility; using NewHorizons.Utility;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -136,7 +136,7 @@ namespace NewHorizons.Components
{ {
if (_cardTemplate == null) if (_cardTemplate == null)
{ {
var panRoot = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot"); var panRoot = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ScaleRoot/PanRoot");
_cardTemplate = GameObject.Instantiate(panRoot.GetComponentInChildren<ShipLogEntryCard>().gameObject); _cardTemplate = GameObject.Instantiate(panRoot.GetComponentInChildren<ShipLogEntryCard>().gameObject);
_cardTemplate.SetActive(false); _cardTemplate.SetActive(false);
} }

View File

@ -1,4 +1,5 @@
using NewHorizons.Builder.General; using NewHorizons.Builder.General;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
using Logger = NewHorizons.Utility.Logger; using Logger = NewHorizons.Utility.Logger;
namespace NewHorizons.Components namespace NewHorizons.Components
@ -26,8 +27,8 @@ namespace NewHorizons.Components
public void Init() public void Init()
{ {
_blackHolePrefab = GameObject.Find(_blackHolePath); _blackHolePrefab = SearchUtilities.Find(_blackHolePath);
_whiteHolePrefab = GameObject.Find(_whiteHolePath); _whiteHolePrefab = SearchUtilities.Find(_whiteHolePath);
} }
public void Start() public void Start()
@ -183,7 +184,7 @@ namespace NewHorizons.Components
// For some reason warping into the ship makes you suffocate while in the ship // For some reason warping into the ship makes you suffocate while in the ship
if (_wearingSuit) resources.OnSuitUp(); if (_wearingSuit) resources.OnSuitUp();
var o2Volume = Locator.GetShipBody().GetComponent<OxygenVolume>(); var o2Volume = Locator.GetShipBody().GetComponent<OxygenVolume>();
var atmoVolume = GameObject.Find("Ship_Body/Volumes/ShipAtmosphereVolume").GetComponent<SimpleFluidVolume>(); var atmoVolume = SearchUtilities.Find("Ship_Body/Volumes/ShipAtmosphereVolume").GetComponent<SimpleFluidVolume>();
resources._cameraFluidDetector.AddVolume(atmoVolume); resources._cameraFluidDetector.AddVolume(atmoVolume);
resources._cameraFluidDetector.OnVolumeAdded(atmoVolume); resources._cameraFluidDetector.OnVolumeAdded(atmoVolume);

View File

@ -33,13 +33,13 @@ namespace NewHorizons.Handlers
// Set up stars // Set up stars
// Need to manage this when there are multiple stars // Need to manage this when there are multiple stars
var sun = GameObject.Find("Sun_Body"); var sun = SearchUtilities.Find("Sun_Body");
var starController = sun.AddComponent<StarController>(); var starController = sun.AddComponent<StarController>();
starController.Light = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>(); starController.Light = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<Light>();
starController.AmbientLight = GameObject.Find("Sun_Body/AmbientLight_SUN").GetComponent<Light>(); starController.AmbientLight = SearchUtilities.Find("Sun_Body/AmbientLight_SUN").GetComponent<Light>();
starController.FaceActiveCamera = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<FaceActiveCamera>(); starController.FaceActiveCamera = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<FaceActiveCamera>();
starController.CSMTextureCacher = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<CSMTextureCacher>(); starController.CSMTextureCacher = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<CSMTextureCacher>();
starController.ProxyShadowLight = GameObject.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<ProxyShadowLight>(); starController.ProxyShadowLight = SearchUtilities.Find("Sun_Body/Sector_SUN/Effects_SUN/SunLight").GetComponent<ProxyShadowLight>();
starController.Intensity = 0.9859f; starController.Intensity = 0.9859f;
starController.SunColor = new Color(1f, 0.8845f, 0.6677f, 1f); starController.SunColor = new Color(1f, 0.8845f, 0.6677f, 1f);
@ -137,7 +137,7 @@ namespace NewHorizons.Handlers
catch (Exception) catch (Exception)
{ {
if (body?.Config?.name == null) Logger.LogError($"How is there no name for {body}"); if (body?.Config?.name == null) Logger.LogError($"How is there no name for {body}");
else existingPlanet = GameObject.Find(body.Config.name.Replace(" ", "") + "_Body"); else existingPlanet = SearchUtilities.Find(body.Config.name.Replace(" ", "") + "_Body", false);
} }
if (existingPlanet != null) if (existingPlanet != null)
@ -252,7 +252,7 @@ namespace NewHorizons.Handlers
{ {
foreach (var child in body.Config.removeChildren) foreach (var child in body.Config.removeChildren)
{ {
Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => GameObject.Find(go.name + "/" + child)?.SetActive(false), 2); Main.Instance.ModHelper.Events.Unity.FireInNUpdates(() => SearchUtilities.Find(go.name + "/" + child)?.SetActive(false), 2);
} }
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Utility; using NewHorizons.Utility;
using OWML.Utils; using OWML.Utils;
using System; using System;
@ -33,7 +33,7 @@ namespace NewHorizons.Handlers
public static void RemoveSolarSystem() public static void RemoveSolarSystem()
{ {
// Stop the sun from killing the player // Stop the sun from killing the player
var sunVolumes = GameObject.Find("Sun_Body/Sector_SUN/Volumes_SUN"); var sunVolumes = SearchUtilities.Find("Sun_Body/Sector_SUN/Volumes_SUN");
sunVolumes.SetActive(false); sunVolumes.SetActive(false);
foreach (var name in _solarSystemBodies) foreach (var name in _solarSystemBodies)
@ -82,11 +82,11 @@ namespace NewHorizons.Handlers
break; break;
case AstroObject.Name.CaveTwin: case AstroObject.Name.CaveTwin:
case AstroObject.Name.TowerTwin: case AstroObject.Name.TowerTwin:
DisableBody(GameObject.Find("FocalBody"), delete); DisableBody(SearchUtilities.Find("FocalBody"), delete);
DisableBody(GameObject.Find("SandFunnel_Body"), delete); DisableBody(SearchUtilities.Find("SandFunnel_Body"), delete);
break; break;
case AstroObject.Name.MapSatellite: case AstroObject.Name.MapSatellite:
DisableBody(GameObject.Find("MapSatellite_Body"), delete); DisableBody(SearchUtilities.Find("MapSatellite_Body"), delete);
break; break;
case AstroObject.Name.GiantsDeep: case AstroObject.Name.GiantsDeep:
// Might prevent leftover jellyfish from existing // Might prevent leftover jellyfish from existing
@ -100,7 +100,7 @@ namespace NewHorizons.Handlers
break; break;
case AstroObject.Name.TimberHearth: case AstroObject.Name.TimberHearth:
// Always just fucking kill this one to stop THE WARP BUG!!! // Always just fucking kill this one to stop THE WARP BUG!!!
DisableBody(GameObject.Find("StreamingGroup_TH"), true); DisableBody(SearchUtilities.Find("StreamingGroup_TH"), true);
foreach (var obj in GameObject.FindObjectsOfType<DayNightTracker>()) foreach (var obj in GameObject.FindObjectsOfType<DayNightTracker>())
{ {
@ -229,8 +229,8 @@ namespace NewHorizons.Handlers
{ {
if (name.Equals("TowerTwin")) name = "AshTwin"; if (name.Equals("TowerTwin")) name = "AshTwin";
if (name.Equals("CaveTwin")) name = "EmberTwin"; if (name.Equals("CaveTwin")) name = "EmberTwin";
var distantProxy = GameObject.Find(name + "_DistantProxy"); var distantProxy = SearchUtilities.Find(name + "_DistantProxy", false);
var distantProxyClone = GameObject.Find(name + "_DistantProxy(Clone)"); var distantProxyClone = SearchUtilities.Find(name + "_DistantProxy(Clone)", false);
if (distantProxy != null) GameObject.Destroy(distantProxy.gameObject); if (distantProxy != null) GameObject.Destroy(distantProxy.gameObject);
if (distantProxyClone != null) GameObject.Destroy(distantProxyClone.gameObject); if (distantProxyClone != null) GameObject.Destroy(distantProxyClone.gameObject);

View File

@ -1,4 +1,4 @@
using NewHorizons.Utility; using NewHorizons.Utility;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@ -26,7 +26,7 @@ namespace NewHorizons.Handlers
_entryIDsToNHBody = new Dictionary<string, NewHorizonsBody>(); _entryIDsToNHBody = new Dictionary<string, NewHorizonsBody>();
_nhBodyToAstroIDs = new Dictionary<NewHorizonsBody, string>(); _nhBodyToAstroIDs = new Dictionary<NewHorizonsBody, string>();
List<GameObject> gameObjects = SearchUtilities.GetAllChildren(GameObject.Find(PAN_ROOT_PATH)); List<GameObject> gameObjects = SearchUtilities.GetAllChildren(SearchUtilities.Find(PAN_ROOT_PATH));
_vanillaBodies = gameObjects.ConvertAll(g => g.name).ToArray(); _vanillaBodies = gameObjects.ConvertAll(g => g.name).ToArray();
_vanillaBodyIDs = gameObjects.ConvertAll(g => g.GetComponent<ShipLogAstroObject>()?.GetID()).ToArray(); _vanillaBodyIDs = gameObjects.ConvertAll(g => g.GetComponent<ShipLogAstroObject>()?.GetID()).ToArray();
} }

View File

@ -1,4 +1,4 @@
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Utility; using NewHorizons.Utility;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -18,7 +18,7 @@ namespace NewHorizons.Handlers
{ {
_systems = systems; _systems = systems;
var shipLogRoot = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas"); var shipLogRoot = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas");
var starChartLog = new GameObject("StarChartMode"); var starChartLog = new GameObject("StarChartMode");
starChartLog.SetActive(false); starChartLog.SetActive(false);
@ -29,7 +29,7 @@ namespace NewHorizons.Handlers
ShipLogStarChartMode = starChartLog.AddComponent<ShipLogStarChartMode>(); ShipLogStarChartMode = starChartLog.AddComponent<ShipLogStarChartMode>();
var reticleImage = GameObject.Instantiate(GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ReticleImage (1)/"), starChartLog.transform); var reticleImage = GameObject.Instantiate(SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/DetectiveMode/ReticleImage (1)/"), starChartLog.transform);
var scaleRoot = new GameObject("ScaleRoot"); var scaleRoot = new GameObject("ScaleRoot");
scaleRoot.transform.parent = starChartLog.transform; scaleRoot.transform.parent = starChartLog.transform;
@ -45,7 +45,7 @@ namespace NewHorizons.Handlers
var centerPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_Center")?.GetComponent<ScreenPromptList>(); var centerPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_Center")?.GetComponent<ScreenPromptList>();
var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.GetComponent<ScreenPromptList>(); var upperRightPromptList = shipLogRoot.transform.Find("ScreenPromptListScaleRoot/ScreenPromptList_UpperRight")?.GetComponent<ScreenPromptList>();
var oneShotSource = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent<OWAudioSource>(); var oneShotSource = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/OneShotAudio_ShipLog")?.GetComponent<OWAudioSource>();
_starSystemToFactID = new Dictionary<string, string>(); _starSystemToFactID = new Dictionary<string, string>();
_factIDToStarSystem = new Dictionary<string, string>(); _factIDToStarSystem = new Dictionary<string, string>();

View File

@ -1,4 +1,4 @@
using NewHorizons.Builder.StarSystem; using NewHorizons.Builder.StarSystem;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Utility; using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
@ -9,7 +9,7 @@ namespace NewHorizons.Handlers
{ {
public static void LoadSystem(NewHorizonsSystem system) public static void LoadSystem(NewHorizonsSystem system)
{ {
var skybox = GameObject.Find("Skybox/Starfield"); var skybox = SearchUtilities.Find("Skybox/Starfield");
if (system.Config.skybox?.destroyStarField ?? false) if (system.Config.skybox?.destroyStarField ?? false)
{ {

View File

@ -13,7 +13,7 @@ namespace NewHorizons.Handlers
{ {
public static void InitSubtitles() public static void InitSubtitles()
{ {
GameObject subtitleContainer = GameObject.Find("TitleMenu/TitleCanvas/TitleLayoutGroup/Logo_EchoesOfTheEye"); GameObject subtitleContainer = SearchUtilities.Find("TitleMenu/TitleCanvas/TitleLayoutGroup/Logo_EchoesOfTheEye");
if (subtitleContainer == null) if (subtitleContainer == null)
{ {
@ -60,11 +60,11 @@ namespace NewHorizons.Handlers
body3.transform.localRotation = Quaternion.Euler(10f, 0f, 0f); body3.transform.localRotation = Quaternion.Euler(10f, 0f, 0f);
} }
GameObject.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire").SetActive(false); SearchUtilities.Find("Scene/Background/PlanetPivot/Prefab_HEA_Campfire").SetActive(false);
GameObject.Find("Scene/Background/PlanetPivot/PlanetRoot").SetActive(false); SearchUtilities.Find("Scene/Background/PlanetPivot/PlanetRoot").SetActive(false);
var lightGO = new GameObject("Light"); var lightGO = new GameObject("Light");
lightGO.transform.parent = GameObject.Find("Scene/Background").transform; lightGO.transform.parent = SearchUtilities.Find("Scene/Background").transform;
lightGO.transform.localPosition = new Vector3(-47.9203f, 145.7596f, 43.1802f); lightGO.transform.localPosition = new Vector3(-47.9203f, 145.7596f, 43.1802f);
var light = lightGO.AddComponent<Light>(); var light = lightGO.AddComponent<Light>();
light.color = new Color(1f, 1f, 1f, 1f); light.color = new Color(1f, 1f, 1f, 1f);
@ -98,7 +98,7 @@ namespace NewHorizons.Handlers
HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod); HeightMapBuilder.Make(titleScreenGO, null, heightMap, body.Mod);
GameObject pivot = GameObject.Instantiate(GameObject.Find("Scene/Background/PlanetPivot"), GameObject.Find("Scene/Background").transform); GameObject pivot = GameObject.Instantiate(SearchUtilities.Find("Scene/Background/PlanetPivot"), SearchUtilities.Find("Scene/Background").transform);
pivot.GetComponent<RotateTransform>()._degreesPerSecond = 10f; pivot.GetComponent<RotateTransform>()._degreesPerSecond = 10f;
foreach (Transform child in pivot.transform) foreach (Transform child in pivot.transform)
{ {

View File

@ -189,7 +189,7 @@ namespace NewHorizons
} }
launchController.enabled = false; launchController.enabled = false;
} }
var nomaiProbe = GameObject.Find("NomaiProbe_Body"); var nomaiProbe = SearchUtilities.Find("NomaiProbe_Body");
if (nomaiProbe != null) nomaiProbe.gameObject.SetActive(false); if (nomaiProbe != null) nomaiProbe.gameObject.SetActive(false);
} }
@ -220,7 +220,7 @@ namespace NewHorizons
if (_ship != null) if (_ship != null)
{ {
_ship = GameObject.Find("Ship_Body").InstantiateInactive(); _ship = SearchUtilities.Find("Ship_Body").InstantiateInactive();
DontDestroyOnLoad(_ship); DontDestroyOnLoad(_ship);
} }
@ -237,7 +237,7 @@ namespace NewHorizons
// Warp drive // Warp drive
StarChartHandler.Init(SystemDict.Values.ToArray()); StarChartHandler.Init(SystemDict.Values.ToArray());
HasWarpDrive = StarChartHandler.CanWarp(); HasWarpDrive = StarChartHandler.CanWarp();
_shipWarpController = GameObject.Find("Ship_Body").AddComponent<ShipWarpController>(); _shipWarpController = SearchUtilities.Find("Ship_Body").AddComponent<ShipWarpController>();
_shipWarpController.Init(); _shipWarpController.Init();
if (HasWarpDrive == true) EnableWarpDrive(); if (HasWarpDrive == true) EnableWarpDrive();
@ -250,7 +250,7 @@ namespace NewHorizons
if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f; if (map != null) map._maxPanDistance = FurthestOrbit * 1.5f;
// Fix the map satellite // Fix the map satellite
GameObject.Find("HearthianMapSatellite_Body").AddComponent<MapSatelliteOrbitFix>(); SearchUtilities.Find("HearthianMapSatellite_Body", false).AddComponent<MapSatelliteOrbitFix>();
} }
else else
{ {

View File

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Builder.ShipLog; using NewHorizons.Builder.ShipLog;
using NewHorizons.Components; using NewHorizons.Components;
using NewHorizons.Handlers; using NewHorizons.Handlers;
@ -135,8 +135,8 @@ namespace NewHorizons.Patches
[HarmonyPatch(typeof(ShipLogMapMode), nameof(ShipLogMapMode.Initialize))] [HarmonyPatch(typeof(ShipLogMapMode), nameof(ShipLogMapMode.Initialize))]
public static void ShipLogMapMode_Initialize(ShipLogMapMode __instance) public static void ShipLogMapMode_Initialize(ShipLogMapMode __instance)
{ {
GameObject panRoot = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH); GameObject panRoot = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH);
GameObject sunObject = GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun"); GameObject sunObject = SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/Sun");
ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, __instance._astroObjects, sunObject.layer); ShipLogAstroObject[][] navMatrix = MapModeBuilder.ConstructMapMode(Main.Instance.CurrentStarSystem, panRoot, __instance._astroObjects, sunObject.layer);
if (navMatrix == null || navMatrix.Length <= 1) if (navMatrix == null || navMatrix.Length <= 1)
{ {
@ -151,9 +151,9 @@ namespace NewHorizons.Patches
List<GameObject> delete = SearchUtilities.GetAllChildren(panRoot).Where(g => g.name.Contains("_ShipLog") == false).ToList(); List<GameObject> delete = SearchUtilities.GetAllChildren(panRoot).Where(g => g.name.Contains("_ShipLog") == false).ToList();
foreach (GameObject gameObject in delete) foreach (GameObject gameObject in delete)
{ {
Object.Destroy(GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name)); Object.Destroy(SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + gameObject.name));
} }
if (GameObject.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel") == null) if (SearchUtilities.Find(ShipLogHandler.PAN_ROOT_PATH + "/" + "SandFunnel") == null)
{ {
__instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>(); __instance._sandFunnel = __instance.gameObject.AddComponent<ShipLogSandFunnel>();
} }

View File

@ -1,5 +1,6 @@
using HarmonyLib; using HarmonyLib;
using NewHorizons.Handlers; using NewHorizons.Handlers;
using NewHorizons.Utility;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Patches namespace NewHorizons.Patches
{ {
@ -14,7 +15,7 @@ namespace NewHorizons.Patches
var newPrompt = TranslationHandler.GetTranslation("INTERSTELLAR_MODE", TranslationHandler.TextType.UI); var newPrompt = TranslationHandler.GetTranslation("INTERSTELLAR_MODE", TranslationHandler.TextType.UI);
__instance._detectiveModePrompt.SetText(newPrompt); __instance._detectiveModePrompt.SetText(newPrompt);
var text = GameObject.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/ScreenPromptListScaleRoot/ScreenPromptList_UpperRight/ScreenPrompt/Text").GetComponent<UnityEngine.UI.Text>(); var text = SearchUtilities.Find("Ship_Body/Module_Cabin/Systems_Cabin/ShipLogPivot/ShipLog/ShipLogPivot/ShipLogCanvas/ScreenPromptListScaleRoot/ScreenPromptList_UpperRight/ScreenPrompt/Text").GetComponent<UnityEngine.UI.Text>();
text.text = newPrompt; text.text = newPrompt;
} }

View File

@ -1,4 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
namespace NewHorizons.Utility namespace NewHorizons.Utility
@ -97,35 +97,35 @@ namespace NewHorizons.Utility
switch (primary._name) switch (primary._name)
{ {
case AstroObject.Name.TowerTwin: case AstroObject.Name.TowerTwin:
otherChildren.Add(GameObject.Find("TimeLoopRing_Body")); otherChildren.Add(SearchUtilities.Find("TimeLoopRing_Body"));
break; break;
case AstroObject.Name.ProbeCannon: case AstroObject.Name.ProbeCannon:
otherChildren.Add(GameObject.Find("NomaiProbe_Body")); otherChildren.Add(SearchUtilities.Find("NomaiProbe_Body"));
otherChildren.Add(GameObject.Find("CannonMuzzle_Body")); otherChildren.Add(SearchUtilities.Find("CannonMuzzle_Body"));
otherChildren.Add(GameObject.Find("FakeCannonMuzzle_Body (1)")); otherChildren.Add(SearchUtilities.Find("FakeCannonMuzzle_Body (1)"));
otherChildren.Add(GameObject.Find("CannonBarrel_Body")); otherChildren.Add(SearchUtilities.Find("CannonBarrel_Body"));
otherChildren.Add(GameObject.Find("FakeCannonBarrel_Body (1)")); otherChildren.Add(SearchUtilities.Find("FakeCannonBarrel_Body (1)"));
otherChildren.Add(GameObject.Find("Debris_Body (1)")); otherChildren.Add(SearchUtilities.Find("Debris_Body (1)"));
break; break;
case AstroObject.Name.GiantsDeep: case AstroObject.Name.GiantsDeep:
otherChildren.Add(GameObject.Find("BrambleIsland_Body")); otherChildren.Add(SearchUtilities.Find("BrambleIsland_Body"));
otherChildren.Add(GameObject.Find("GabbroIsland_Body")); otherChildren.Add(SearchUtilities.Find("GabbroIsland_Body"));
otherChildren.Add(GameObject.Find("QuantumIsland_Body")); otherChildren.Add(SearchUtilities.Find("QuantumIsland_Body"));
otherChildren.Add(GameObject.Find("StatueIsland_Body")); otherChildren.Add(SearchUtilities.Find("StatueIsland_Body"));
otherChildren.Add(GameObject.Find("ConstructionYardIsland_Body")); otherChildren.Add(SearchUtilities.Find("ConstructionYardIsland_Body"));
otherChildren.Add(GameObject.Find("GabbroShip_Body")); otherChildren.Add(SearchUtilities.Find("GabbroShip_Body"));
break; break;
case AstroObject.Name.WhiteHole: case AstroObject.Name.WhiteHole:
otherChildren.Add(GameObject.Find("WhiteholeStation_Body")); otherChildren.Add(SearchUtilities.Find("WhiteholeStation_Body"));
otherChildren.Add(GameObject.Find("WhiteholeStationSuperstructure_Body")); otherChildren.Add(SearchUtilities.Find("WhiteholeStationSuperstructure_Body"));
break; break;
case AstroObject.Name.TimberHearth: case AstroObject.Name.TimberHearth:
otherChildren.Add(GameObject.Find("MiningRig_Body")); otherChildren.Add(SearchUtilities.Find("MiningRig_Body"));
otherChildren.Add(GameObject.Find("Ship_Body")); otherChildren.Add(SearchUtilities.Find("Ship_Body"));
break; break;
case AstroObject.Name.DreamWorld: case AstroObject.Name.DreamWorld:
otherChildren.Add(GameObject.Find("BackRaft_Body")); otherChildren.Add(SearchUtilities.Find("BackRaft_Body"));
otherChildren.Add(GameObject.Find("SealRaft_Body")); otherChildren.Add(SearchUtilities.Find("SealRaft_Body"));
break; break;
// For some dumb reason the sun station doesn't use AstroObject.Name.SunStation // For some dumb reason the sun station doesn't use AstroObject.Name.SunStation
case AstroObject.Name.CustomString: case AstroObject.Name.CustomString:

View File

@ -1,4 +1,4 @@
using NewHorizons.Handlers; using NewHorizons.Handlers;
using OWML.Common; using OWML.Common;
using OWML.Common.Menus; using OWML.Common.Menus;
using System; using System;
@ -45,7 +45,7 @@ namespace NewHorizons.Utility.DebugUtilities
Logger.LogWarning("Error While Reloading"); Logger.LogWarning("Error While Reloading");
} }
GameObject.Find("/PauseMenu/PauseMenuManagers").GetComponent<PauseMenuManager>().OnSkipToNextTimeLoop(); SearchUtilities.Find("/PauseMenu/PauseMenuManagers").GetComponent<PauseMenuManager>().OnSkipToNextTimeLoop();
Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem); Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem);

View File

@ -129,7 +129,7 @@ namespace NewHorizons.Utility
return null; return null;
} }
public static GameObject Find(string path) public static GameObject Find(string path, bool warn = true)
{ {
if (CachedGameObjects.ContainsKey(path)) if (CachedGameObjects.ContainsKey(path))
{ {
@ -150,7 +150,7 @@ namespace NewHorizons.Utility
var t = root?.transform; var t = root?.transform;
if (t == null) if (t == null)
{ {
Logger.LogWarning($"Couldn't find root object in path ({names[0]})"); if (warn) Logger.LogWarning($"Couldn't find root object in path ({names[0]})");
} }
else else
{ {
@ -172,7 +172,7 @@ namespace NewHorizons.Utility
if (child == null) if (child == null)
{ {
Logger.LogWarning($"Couldn't find object in path ({names[i]})"); if (warn) Logger.LogWarning($"Couldn't find object in path ({names[i]})");
t = null; t = null;
break; break;
} }
@ -187,7 +187,7 @@ namespace NewHorizons.Utility
if (go == null) if (go == null)
{ {
var name = names.Last(); var name = names.Last();
Logger.LogWarning($"Couldn't find object {path}, will look for potential matches for name {name}"); if (warn) Logger.LogWarning($"Couldn't find object {path}, will look for potential matches for name {name}");
go = FindObjectOfTypeAndName<GameObject>(name); go = FindObjectOfTypeAndName<GameObject>(name);
} }