From f55e2e8436393c8da2ba850b01004bd7c9ccb43c Mon Sep 17 00:00:00 2001 From: ivan tkachenko Date: Wed, 1 Apr 2026 06:04:37 +0300 Subject: [PATCH] [v80] Use vanilla RefreshLightsList Vanilla v80 changed three things about this patch: - allPoweredLightsAnimators list became nullable, breaking the patch. - implemented looking up the List<> of children, rendering the patch obsolete. - added new logic for objects tagged with "IndirectLightSource", making the patch incomplete. All in all, the patch is not needed anymore. --- MuzikaGromche/PoweredLights.cs | 40 ++-------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/MuzikaGromche/PoweredLights.cs b/MuzikaGromche/PoweredLights.cs index 6010585..71fdbf6 100644 --- a/MuzikaGromche/PoweredLights.cs +++ b/MuzikaGromche/PoweredLights.cs @@ -14,47 +14,11 @@ namespace MuzikaGromche // - (maybe more?) // In order to fix that, replace singular GetComponentInChildren with plural GetComponentsInChildren version. [HarmonyPatch(nameof(RoundManager.RefreshLightsList))] - [HarmonyPrefix] - static bool OnRefreshLightsList(RoundManager __instance) + [HarmonyPostfix] + static void OnRefreshLightsList(RoundManager __instance) { - RefreshLightsListPatched(__instance); - var behaviour = __instance.gameObject.GetComponent() ?? __instance.gameObject.AddComponent(); behaviour.Refresh(); - - // Skip the original method - return false; - } - - static void RefreshLightsListPatched(RoundManager self) - { - // Reusable list to reduce allocations - List lights = []; - - self.allPoweredLights.Clear(); - self.allPoweredLightsAnimators.Clear(); - - GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("PoweredLight"); - if (gameObjects == null) - { - return; - } - - foreach (var gameObject in gameObjects) - { - Animator animator = gameObject.GetComponentInChildren(); - if (!(animator == null)) - { - self.allPoweredLightsAnimators.Add(animator); - // Patched section: Use list instead of singular GetComponentInChildren - gameObject.GetComponentsInChildren(includeInactive: true, lights); - self.allPoweredLights.AddRange(lights); - } - } - foreach (var animator in self.allPoweredLightsAnimators) - { - animator.SetFloat("flickerSpeed", UnityEngine.Random.Range(0.6f, 1.4f)); - } } }