diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index ccaf5c89..13c903c3 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -245,12 +245,27 @@ namespace NewHorizons.Builder.Body cloak._sectors = new Sector[] { sector }; cloak.GetComponent().enabled = true; - // Cull stuff // Do next update so other nodes can be built first Delay.FireOnNextUpdate(() => { + // Cull stuff var cullController = go.AddComponent(); cullController.SetSector(sector); + + // Prevent recursion from causing hard crash + foreach (var senderWarp in outerFogWarpVolume._senderWarps.ToList()) + { + var currentWarp = senderWarp; + while (currentWarp.GetContainerWarpVolume() != null) + { + if (currentWarp.GetContainerWarpVolume() == outerFogWarpVolume && currentWarp != senderWarp) // game already fixes here to here recursion + { + outerFogWarpVolume._senderWarps.Remove(senderWarp); + break; + } + currentWarp = (InnerFogWarpVolume)currentWarp.GetContainerWarpVolume().GetLinkedFogWarpVolume(); + } + } }); // finalize diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index 83a657e8..56114146 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -250,12 +250,13 @@ namespace NewHorizons.Builder.Props brambleNode.FindChild("Prefab_SeedPunctureVolume (2)").GetComponent().enabled = true; fogLight._maxVisibleDistance = float.PositiveInfinity; // Prefab does have working foglight aside from this fogLight._minVisibleDistance *= config.scale / 15f; + fogLight._occlusionRange = 175f; } else { brambleNode.FindChild("Effects/PointLight_DB_FogLight").GetComponent().range *= config.scale; brambleNode.FindChild("Effects/FogOverrideVolume").GetComponent().blendDistance *= config.scale; - fogLight._minVisibleDistance *= config.scale; + //fogLight._minVisibleDistance *= config.scale; // Seed fog works differently, so it doesn't need to be fixed // (it's also located on a different child path, so the below FindChild calls wouldn't work) @@ -333,6 +334,24 @@ namespace NewHorizons.Builder.Props SetNodeColors(brambleNode, fogTint, farFogTint, fogLightTint, lightTint, lightShaftTint, glowTint, fogOverrideTint); } + + // Redo the foglight data after everything is colored + if (fogLight._linkedFogLights != null) + { + Delay.FireOnNextUpdate(() => + { + FogLightManager fogLightManager = Locator.GetFogLightManager(); + fogLight._linkedLightData.Clear(); + for (int i = 0; i < fogLight._linkedFogLights.Count; i++) + { + FogLight.LightData lightData = new FogLight.LightData(); + lightData.color = fogLight._linkedFogLights[i].GetTint(); + lightData.maxAlpha = fogLight._linkedFogLights[i]._maxAlpha; + fogLight._linkedLightData.Add(lightData); + fogLightManager.RegisterLightData(lightData); + } + }); + } }); // Set up warps