From da199bf90ce64c7719dad359019034887931dfe2 Mon Sep 17 00:00:00 2001 From: TerrificTrifid <99054745+TerrificTrifid@users.noreply.github.com> Date: Mon, 12 Dec 2022 18:20:49 -0600 Subject: [PATCH 1/6] Prevent recursion from causing hard crash --- .../Builder/Body/BrambleDimensionBuilder.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index ccaf5c89..26bd51ad 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -245,12 +245,26 @@ 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) + { + var currentWarp = senderWarp; + while (currentWarp.GetContainerWarpVolume() != null) + { + if (currentWarp.GetContainerWarpVolume() == outerFogWarpVolume && currentWarp != senderWarp) // game already fixes here to here recursion + { + outerFogWarpVolume._senderWarps.Remove(senderWarp); + } + else currentWarp = (InnerFogWarpVolume)currentWarp.GetContainerWarpVolume().GetLinkedFogWarpVolume(); + } + } }); // finalize From 0fbe807589378afb828aa8b1cbb8719c0e9a2318 Mon Sep 17 00:00:00 2001 From: TerrificTrifid <99054745+TerrificTrifid@users.noreply.github.com> Date: Mon, 12 Dec 2022 19:51:57 -0600 Subject: [PATCH 2/6] Break --- NewHorizons/Builder/Body/BrambleDimensionBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 26bd51ad..7779cb14 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -260,7 +260,7 @@ namespace NewHorizons.Builder.Body { if (currentWarp.GetContainerWarpVolume() == outerFogWarpVolume && currentWarp != senderWarp) // game already fixes here to here recursion { - outerFogWarpVolume._senderWarps.Remove(senderWarp); + outerFogWarpVolume._senderWarps.Remove(senderWarp); break; } else currentWarp = (InnerFogWarpVolume)currentWarp.GetContainerWarpVolume().GetLinkedFogWarpVolume(); } From 32923cea520e044afc481f636af07e8c381597ac Mon Sep 17 00:00:00 2001 From: TerrificTrifid <99054745+TerrificTrifid@users.noreply.github.com> Date: Mon, 12 Dec 2022 20:11:26 -0600 Subject: [PATCH 3/6] Remove outside foreach --- NewHorizons/Builder/Body/BrambleDimensionBuilder.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index 7779cb14..ec2a184f 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -253,6 +253,7 @@ namespace NewHorizons.Builder.Body cullController.SetSector(sector); // Prevent recursion from causing hard crash + List removeList = new List(); foreach (var senderWarp in outerFogWarpVolume._senderWarps) { var currentWarp = senderWarp; @@ -260,10 +261,15 @@ namespace NewHorizons.Builder.Body { if (currentWarp.GetContainerWarpVolume() == outerFogWarpVolume && currentWarp != senderWarp) // game already fixes here to here recursion { - outerFogWarpVolume._senderWarps.Remove(senderWarp); break; + removeList.Add(senderWarp); break; } else currentWarp = (InnerFogWarpVolume)currentWarp.GetContainerWarpVolume().GetLinkedFogWarpVolume(); } + + } + foreach (var recursiveWarp in removeList) + { + outerFogWarpVolume._senderWarps.Remove(recursiveWarp); } }); From 7e8071551251ee1463dd2b7c3dff54d19bc53772 Mon Sep 17 00:00:00 2001 From: JohnCorby Date: Mon, 12 Dec 2022 18:28:59 -0800 Subject: [PATCH 4/6] just copy list before doing foreach --- NewHorizons/Builder/Body/BrambleDimensionBuilder.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs index ec2a184f..13c903c3 100644 --- a/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs +++ b/NewHorizons/Builder/Body/BrambleDimensionBuilder.cs @@ -253,23 +253,18 @@ namespace NewHorizons.Builder.Body cullController.SetSector(sector); // Prevent recursion from causing hard crash - List removeList = new List(); - foreach (var senderWarp in outerFogWarpVolume._senderWarps) + 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 { - removeList.Add(senderWarp); break; + outerFogWarpVolume._senderWarps.Remove(senderWarp); + break; } - else currentWarp = (InnerFogWarpVolume)currentWarp.GetContainerWarpVolume().GetLinkedFogWarpVolume(); + currentWarp = (InnerFogWarpVolume)currentWarp.GetContainerWarpVolume().GetLinkedFogWarpVolume(); } - - } - foreach (var recursiveWarp in removeList) - { - outerFogWarpVolume._senderWarps.Remove(recursiveWarp); } }); From e2f7d8a05b060f2cffc458c5660750a193a27fab Mon Sep 17 00:00:00 2001 From: TerrificTrifid <99054745+TerrificTrifid@users.noreply.github.com> Date: Mon, 12 Dec 2022 21:53:35 -0600 Subject: [PATCH 5/6] Foglight tweaks --- NewHorizons/Builder/Props/BrambleNodeBuilder.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index 83a657e8..e227cb02 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) From 3ca471fa93d592289eecd8a0080a5f9e421c888b Mon Sep 17 00:00:00 2001 From: TerrificTrifid <99054745+TerrificTrifid@users.noreply.github.com> Date: Mon, 12 Dec 2022 23:06:19 -0600 Subject: [PATCH 6/6] Fix foglight data --- .../Builder/Props/BrambleNodeBuilder.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs index e227cb02..56114146 100644 --- a/NewHorizons/Builder/Props/BrambleNodeBuilder.cs +++ b/NewHorizons/Builder/Props/BrambleNodeBuilder.cs @@ -334,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