mirror of
https://github.com/Outer-Wilds-New-Horizons/new-horizons.git
synced 2025-12-11 20:15:44 +01:00
Use bool to check if we should init prefabs (avoids excess null checks)
This commit is contained in:
parent
33323ddea5
commit
fb2de48d8f
@ -22,8 +22,14 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
private static GameObject _atmospherePrefab;
|
||||
private static GameObject _proxyAtmospherePrefab;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_atmospherePrefab == null) _atmospherePrefab = SearchUtilities.Find("TimberHearth_Body/Atmosphere_TH/AtmoSphere").InstantiateInactive().Rename("Atmosphere").DontDestroyOnLoad();
|
||||
if (_proxyAtmospherePrefab == null) _proxyAtmospherePrefab = GameObject.FindObjectOfType<DistantProxyManager>()._proxies.FirstOrDefault(apt => apt.astroName == AstroObject.Name.TimberHearth).proxyPrefab.FindChild("Atmosphere_TH/Atmosphere_LOD3").InstantiateInactive().Rename("ProxyAtmosphere").DontDestroyOnLoad();
|
||||
}
|
||||
|
||||
@ -27,8 +27,14 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
private static readonly int CapTex = Shader.PropertyToID("_CapTex");
|
||||
private static readonly int Smoothness = Shader.PropertyToID("_Glossiness");
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_lightningPrefab == null) _lightningPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Clouds_GD/LightningGenerator_GD").InstantiateInactive().Rename("LightningGenerator").DontDestroyOnLoad();
|
||||
if (_colorRamp == null) _colorRamp = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/Clouds_Bottom_ramp.png");
|
||||
if (_gdTopCloudMesh == null) _gdTopCloudMesh = SearchUtilities.Find("CloudsTopLayer_GD").GetComponent<MeshFilter>().mesh.DontDestroyOnLoad();
|
||||
|
||||
@ -9,8 +9,14 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
private static GameObject _rainEmitterPrefab;
|
||||
private static GameObject _snowEmitterPrefab;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_rainEmitterPrefab == null) _rainEmitterPrefab = SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Sector_GDInterior/Effects_GDInterior/Effects_GD_Rain").InstantiateInactive().Rename("Prefab_Effects_Rain").DontDestroyOnLoad();
|
||||
if (_snowEmitterPrefab == null) _snowEmitterPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Effects_BH/Effects_BH_Snowflakes").InstantiateInactive().Rename("Prefab_Effects_Snowflakes").DontDestroyOnLoad();
|
||||
}
|
||||
|
||||
@ -18,8 +18,14 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
private static Mesh _dbImpostorMesh;
|
||||
private static Material[] _dbImpostorMaterials;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_ramp == null) _ramp = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/FogColorRamp.png");
|
||||
|
||||
// Going to copy from dark bramble
|
||||
|
||||
@ -10,8 +10,14 @@ namespace NewHorizons.Builder.Atmosphere
|
||||
private static Material _gdMaterial;
|
||||
private static Material _gdCloudMaterial;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_gdMaterial == null) _gdMaterial = new Material(SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Volumes_GD/RulesetVolumes_GD").GetComponent<EffectRuleset>()._material).DontDestroyOnLoad();
|
||||
if (_gdCloudMaterial == null) _gdCloudMaterial = new Material(SearchUtilities.Find("GiantsDeep_Body/Sector_GD/Volumes_GD/RulesetVolumes_GD").GetComponent<EffectRuleset>()._cloudMaterial).DontDestroyOnLoad();
|
||||
}
|
||||
|
||||
@ -55,8 +55,14 @@ namespace NewHorizons.Builder.Body
|
||||
private static GameObject _repelVolume;
|
||||
private static Material _material;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_atmosphere == null) _atmosphere = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Atmosphere_HubDimension").InstantiateInactive().Rename("Prefab_Bramble_Atmosphere").DontDestroyOnLoad();
|
||||
if (_volumes == null) _volumes = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Volumes_HubDimension").InstantiateInactive().Rename("Prefab_Bramble_Volumes").DontDestroyOnLoad();
|
||||
if (_effects == null) _effects = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Effects_HubDimension").InstantiateInactive().Rename("Prefab_Bramble_Effects").DontDestroyOnLoad();
|
||||
|
||||
@ -19,8 +19,14 @@ namespace NewHorizons.Builder.Body
|
||||
private static Material[] _waterMaterials;
|
||||
private static Material _lavaMaterial;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_proxySandFunnel == null) _proxySandFunnel = SearchUtilities.Find("SandFunnel_Body/ScaleRoot/Proxy_SandFunnel").InstantiateInactive().Rename("Prefab_Funnel_Proxy").DontDestroyOnLoad();
|
||||
if (_geoSandFunnel == null) _geoSandFunnel = SearchUtilities.Find("SandFunnel_Body/ScaleRoot/Geo_SandFunnel").InstantiateInactive().Rename("Prefab_Funnel_Geo").DontDestroyOnLoad();
|
||||
if (_volumesSandFunnel == null) _volumesSandFunnel = SearchUtilities.Find("SandFunnel_Body/ScaleRoot/Volumes_SandFunnel").InstantiateInactive().Rename("Prefab_Funnel_Volumes").DontDestroyOnLoad();
|
||||
|
||||
@ -14,8 +14,14 @@ namespace NewHorizons.Builder.Body
|
||||
private static GameObject _moltenCoreProxy;
|
||||
private static GameObject _destructionVolume;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_lavaSphere == null) _lavaSphere = SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/LavaSphere").InstantiateInactive().Rename("Prefab_VM_LavaSphere").DontDestroyOnLoad();
|
||||
if (_moltenCoreProxy == null) _moltenCoreProxy = SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/MoltenCore_Proxy").InstantiateInactive().Rename("Prefab_VM_MoltenCore_Proxy").DontDestroyOnLoad();
|
||||
if (_destructionVolume == null) _destructionVolume = SearchUtilities.Find("VolcanicMoon_Body/MoltenCore_VM/DestructionVolume").InstantiateInactive().Rename("Prefab_VM_DestructionVolume").DontDestroyOnLoad();
|
||||
|
||||
@ -11,8 +11,14 @@ namespace NewHorizons.Builder.Body
|
||||
private static GameObject _sandOcclusion;
|
||||
private static GameObject _sandProxyShadowCaster;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_sandSphere == null) _sandSphere = SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/SandSphere").InstantiateInactive().Rename("Prefab_TT_SandSphere").DontDestroyOnLoad();
|
||||
if (_sandCollider == null) _sandCollider = SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/Collider").InstantiateInactive().Rename("Prefab_TT_SandCollider").DontDestroyOnLoad();
|
||||
if (_sandOcclusion == null) _sandOcclusion = SearchUtilities.Find("TowerTwin_Body/SandSphere_Draining/OcclusionSphere").InstantiateInactive().Rename("Prefab_TT_SandOcclusion").DontDestroyOnLoad();
|
||||
|
||||
@ -41,8 +41,14 @@ namespace NewHorizons.Builder.Body
|
||||
private static GameObject _whiteHoleRulesetVolume;
|
||||
private static GameObject _whiteHoleVolume;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_blackHoleProxyPrefab == null) _blackHoleProxyPrefab = SearchUtilities.Find(_blackHoleProxyPath).InstantiateInactive().Rename("BlackHoleSingularity").DontDestroyOnLoad();
|
||||
if (_whiteHoleProxyPrefab == null) _whiteHoleProxyPrefab = SearchUtilities.Find(_whiteHoleProxyPath).InstantiateInactive().Rename("WhiteHoleSingularity").DontDestroyOnLoad();
|
||||
|
||||
|
||||
@ -34,8 +34,14 @@ namespace NewHorizons.Builder.Body
|
||||
private static Material _mainSequenceMaterial;
|
||||
private static Material _giantMaterial;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_colorOverTime == null) _colorOverTime = ImageUtilities.GetTexture(Main.Instance, "Assets/textures/StarColorOverTime.png");
|
||||
if (_starAudio == null) _starAudio = SearchUtilities.Find("Sun_Body/Sector_SUN/Audio_SUN").InstantiateInactive().Rename("Prefab_Audio_Star").DontDestroyOnLoad();
|
||||
if (_starAtmosphere == null) _starAtmosphere = SearchUtilities.Find("Sun_Body/Atmosphere_SUN").InstantiateInactive().Rename("Prefab_Atmosphere_Star").DontDestroyOnLoad();
|
||||
|
||||
@ -13,8 +13,14 @@ namespace NewHorizons.Builder.Body
|
||||
private static Mesh _shockLayerMesh;
|
||||
private static Material _shockLayerMaterial;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_shockLayerMesh == null) _shockLayerMesh = SearchUtilities.Find("GiantsDeep_Body/Shocklayer_GD").GetComponent<MeshFilter>().sharedMesh.DontDestroyOnLoad();
|
||||
if (_shockLayerMaterial == null) _shockLayerMaterial = new Material(SearchUtilities.Find("GiantsDeep_Body/Shocklayer_GD").GetComponent<MeshRenderer>().sharedMaterial).Rename("ShockLayer_mat").DontDestroyOnLoad();
|
||||
}
|
||||
|
||||
@ -14,8 +14,14 @@ namespace NewHorizons.Builder.Body
|
||||
private static GameObject _oceanFog;
|
||||
private static GameObject _oceanAmbientLight;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_oceanMeshGroup == null)
|
||||
{
|
||||
_oceanMeshGroup = ScriptableObject.CreateInstance<MeshGroup>().Rename("Ocean").DontDestroyOnLoad();
|
||||
|
||||
@ -10,8 +10,14 @@ namespace NewHorizons.Builder.General
|
||||
{
|
||||
private static List<SplashEffect> _splashEffects;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_splashEffects == null)
|
||||
{
|
||||
_splashEffects = new List<SplashEffect>();
|
||||
|
||||
@ -41,8 +41,14 @@ namespace NewHorizons.Builder.Props
|
||||
PropagateSignals(dimensionConfigs);
|
||||
}
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_brambleSeedPrefab == null) _brambleSeedPrefab = SearchUtilities.Find("DB_PioneerDimension_Body/Sector_PioneerDimension/Interactables_PioneerDimension/SeedWarp_ToPioneer (1)").InstantiateInactive().Rename("Prefab_DB_Seed").DontDestroyOnLoad();
|
||||
if (_brambleNodePrefab == null) _brambleNodePrefab = SearchUtilities.Find("DB_HubDimension_Body/Sector_HubDimension/Interactables_HubDimension/InnerWarp_ToCluster").InstantiateInactive().Rename("Prefab_DB_Node").DontDestroyOnLoad();
|
||||
}
|
||||
|
||||
@ -45,8 +45,14 @@ namespace NewHorizons.Builder.Props
|
||||
public static List<GameObject> GetChildArcPrefabs() { return _childArcPrefabs; }
|
||||
public static List<GameObject> GetGhostArcPrefabs() { return _ghostArcPrefabs; }
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
// Just take every scroll and get the first arc
|
||||
if (_arcPrefabs == null || _childArcPrefabs == null)
|
||||
{
|
||||
|
||||
@ -20,8 +20,14 @@ namespace NewHorizons.Builder.Props
|
||||
private static GameObject _standingVisionTorchPrefab;
|
||||
private static readonly int EmissionMap = Shader.PropertyToID("_EmissionMap");
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_slideReelPrefab == null)
|
||||
{
|
||||
_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()?.Rename("Prefab_IP_Reel")?.DontDestroyOnLoad();
|
||||
|
||||
@ -17,8 +17,14 @@ namespace NewHorizons.Builder.Props
|
||||
private static GameObject _whiteboardPrefab;
|
||||
private static GameObject _shareStonePrefab;
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_decalMaterial == null)
|
||||
{
|
||||
_decalMaterial = new Material(Shader.Find("Standard (Decal)")).DontDestroyOnLoad();
|
||||
|
||||
@ -23,8 +23,14 @@ namespace NewHorizons.Builder.Props
|
||||
private static readonly int MainTex = Shader.PropertyToID("_MainTex");
|
||||
private static readonly int FresnelColor = Shader.PropertyToID("_FresnelColor");
|
||||
|
||||
private static bool _isInit;
|
||||
|
||||
internal static void InitPrefabs()
|
||||
{
|
||||
if (_isInit) return;
|
||||
|
||||
_isInit = true;
|
||||
|
||||
if (_upPrefab == null)
|
||||
{
|
||||
_upPrefab = SearchUtilities.Find("BrittleHollow_Body/Sector_BH/Sector_SouthHemisphere/Sector_SouthPole/Sector_Observatory/Interactables_Observatory/MockUpTornado").InstantiateInactive().Rename("Tornado_Up_Prefab").DontDestroyOnLoad();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user