diff --git a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs index e06c1800..b4c74b78 100644 --- a/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs +++ b/NewHorizons/Builder/Atmosphere/EffectsBuilder.cs @@ -2,6 +2,7 @@ using NewHorizons.External.Configs; using NewHorizons.External.Modules; using NewHorizons.Utility; using UnityEngine; + namespace NewHorizons.Builder.Atmosphere { public static class EffectsBuilder @@ -55,29 +56,19 @@ namespace NewHorizons.Builder.Atmosphere { InitPrefabs(); - GameObject effectsGO = new GameObject("Effects"); + var effectsGO = new GameObject("Effects"); effectsGO.SetActive(false); effectsGO.transform.parent = sector?.transform ?? planetGO.transform; effectsGO.transform.position = planetGO.transform.position; - SectorCullGroup SCG = effectsGO.AddComponent(); - SCG._sector = sector; - SCG._particleSystemSuspendMode = CullGroup.ParticleSystemSuspendMode.Stop; - SCG._occlusionCulling = false; - SCG._dynamicCullingBounds = false; - SCG._waitForStreaming = false; + var sectorCullGroup = effectsGO.AddComponent(); + sectorCullGroup._sector = sector; + sectorCullGroup._particleSystemSuspendMode = CullGroup.ParticleSystemSuspendMode.Stop; + sectorCullGroup._occlusionCulling = false; + sectorCullGroup._dynamicCullingBounds = false; + sectorCullGroup._waitForStreaming = false; - var minHeight = config.Base.surfaceSize; - if (config.HeightMap?.minHeight != null) - { - if (config.Water?.size >= config.HeightMap.minHeight) minHeight = config.Water.size; // use sea level if its higher - else minHeight = config.HeightMap.minHeight; - } - else if (config.Water?.size != null) minHeight = config.Water.size; - else if (config.Lava?.size != null) minHeight = config.Lava.size; - - var maxHeight = config.Atmosphere.size; - if (config.Atmosphere.clouds?.outerCloudRadius != null) maxHeight = config.Atmosphere.clouds.outerCloudRadius; + var (minHeight, maxHeight) = GetDefaultHeightRange(config); foreach (var particleField in config.ParticleFields) { @@ -130,5 +121,48 @@ namespace NewHorizons.Builder.Atmosphere _ => null, }; } + + private static (float, float) GetDefaultHeightRange(PlanetConfig config) + { + var minHeight = 0f; + + if (config.HeightMap?.minHeight != null) + { + if (config.Water?.size >= config.HeightMap.minHeight) minHeight = config.Water.size; // use sea level if its higher + else minHeight = config.HeightMap.minHeight; + } + else if (config.Water?.size != null) + { + minHeight = config.Water.size; + } + else if (config.Lava?.size != null) + { + minHeight = config.Lava.size; + } + else if (config.Base != null) + { + minHeight = config.Base.surfaceSize; + } + + var maxHeight = 100f; + + if (config.Atmosphere != null) + { + if (config.Atmosphere.clouds?.outerCloudRadius != null) + { + maxHeight = config.Atmosphere.clouds.outerCloudRadius; + } + else + { + maxHeight = config.Atmosphere.size; + } + } + else if (minHeight != 0f) + { + maxHeight = minHeight * 2f; + } + + return (minHeight, maxHeight); + } } } diff --git a/NewHorizons/Builder/Props/DetailBuilder.cs b/NewHorizons/Builder/Props/DetailBuilder.cs index 66c16a95..245ba6c1 100644 --- a/NewHorizons/Builder/Props/DetailBuilder.cs +++ b/NewHorizons/Builder/Props/DetailBuilder.cs @@ -339,12 +339,6 @@ namespace NewHorizons.Builder.Props component.gameObject.layer = Layer.IgnoreSun; } } - // I forget why this is here - else if (component is GhostIK or GhostEffects) - { - UnityEngine.Object.DestroyImmediate(component); - return; - } else if (component is DarkMatterVolume) { var probeVisuals = component.gameObject.transform.Find("ProbeVisuals"); @@ -400,8 +394,15 @@ namespace NewHorizons.Builder.Props else if (component is Renderer renderer && component.gameObject.GetComponent() == null) renderer.enabled = true; else if(component is Shape shape) shape.enabled = true; - // If it's not a moving anglerfish make sure the anim controller is regular - else if(component is AnglerfishAnimController && component.transform.parent.GetComponent() == null) //Manual parent chain so we can find inactive + // If it's not a moving ghostbird (ie Prefab_IP_GhostBird/Ghostbird_IP_ANIM) make sure it doesnt spam NREs + // Manual parent chain so we can find inactive + else if (component is GhostIK or GhostEffects && component.transform.parent.GetComponent() == null) + { + UnityEngine.Object.DestroyImmediate(component); + } + // If it's not a moving anglerfish (ie Anglerfish_Body/Beast_Anglerfish) make sure the anim controller is regular + // Manual parent chain so we can find inactive + else if(component is AnglerfishAnimController && component.transform.parent.GetComponent() == null) { component.gameObject.AddComponent(); } diff --git a/NewHorizons/Main.cs b/NewHorizons/Main.cs index b1b05a1d..b6c5dc5d 100644 --- a/NewHorizons/Main.cs +++ b/NewHorizons/Main.cs @@ -97,6 +97,7 @@ namespace NewHorizons private bool _playerAwake; public bool PlayerSpawned { get; set; } + public bool ForceClearCaches { get; set; } // for reloading configs public ShipWarpController ShipWarpController { get; private set; } @@ -288,8 +289,10 @@ namespace NewHorizons EnumUtilities.ClearCache(); // Caches of other assets only have to be cleared if we changed star systems - if (CurrentStarSystem != _previousStarSystem) + if (ForceClearCaches || CurrentStarSystem != _previousStarSystem) { + ForceClearCaches = false; + NHLogger.Log($"Changing star system from {_previousStarSystem} to {CurrentStarSystem} - Clearing system-specific caches!"); ImageUtilities.ClearCache(); AudioUtilities.ClearCache(); diff --git a/NewHorizons/Utility/DebugTools/DebugReload.cs b/NewHorizons/Utility/DebugTools/DebugReload.cs index af3bd938..87dc99cf 100644 --- a/NewHorizons/Utility/DebugTools/DebugReload.cs +++ b/NewHorizons/Utility/DebugTools/DebugReload.cs @@ -1,4 +1,5 @@ using NewHorizons.Handlers; +using NewHorizons.Utility.Files; using NewHorizons.Utility.OWML; using OWML.Common; using OWML.Common.Menus; @@ -47,6 +48,7 @@ namespace NewHorizons.Utility.DebugTools SearchUtilities.Find("/PauseMenu/PauseMenuManagers").GetComponent().OnSkipToNextTimeLoop(); + Main.Instance.ForceClearCaches = true; Main.Instance.ChangeCurrentStarSystem(Main.Instance.CurrentStarSystem); Main.SecondsElapsedInLoop = -1f;