diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d7edb0..1e2de78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Removed remaining CSync code and package references even from debug builds. - Downgraded LobbyCompatibility to optional dependency. - Toggled config option to increase certain spawn rate to ON by default. +- Fixed resetting to wrong initial colors, e.g. in Mineshaft tunnel tiles. ## MuzikaGromche 1337.420.9001 - Multiverse Edition diff --git a/MuzikaGromche/Plugin.cs b/MuzikaGromche/Plugin.cs index c2e1945..7cbd490 100644 --- a/MuzikaGromche/Plugin.cs +++ b/MuzikaGromche/Plugin.cs @@ -27,6 +27,10 @@ namespace MuzikaGromche { internal new static Config Config { get; private set; } = null!; + // Not all lights are white by default. For example, Mineshaft's neon light is green-ish. + // We don't have to care about Light objects lifetime, as Unity would internally destroy them on scene unload anyway. + internal static Dictionary InitialLightsColors = []; + private static readonly string[] PwnLyricsVariants = [ "", "", "", // make sure the array has enough items to index it without checking ..NetworkInterface.GetAllNetworkInterfaces() @@ -603,7 +607,10 @@ namespace MuzikaGromche public static void ResetLightColor() { - SetLightColor(Color.white); + foreach (var (light, color) in InitialLightsColors) + { + light.color = color; + } } // Max audible distance for AudioSource and LyricsEvent @@ -1552,7 +1559,9 @@ namespace MuzikaGromche if (windUpOffsetTimestamp.Beat < 0f && track.FadeOutBeat < loopOffsetSpan.BeatToInclusive && loopOffsetSpan.BeatFromExclusive <= fadeOutEnd) { var t = (loopOffsetSpan.BeatToInclusive - track.FadeOutBeat) / track.FadeOutDuration; - return new SetLightsColorTransitionEvent(Color.white, Color.black, Easing.Linear, t); + // TODO: assumes that default lights color is white + var DefaultLightsColor = Color.white; + return new SetLightsColorTransitionEvent(DefaultLightsColor, Color.black, Easing.Linear, t); } else { @@ -1625,7 +1634,9 @@ namespace MuzikaGromche } else { - return float.IsNaN(track.FadeOutBeat) ? Color.white : Color.black; + // TODO: assumes that default lights color is white + var DefaultLightsColor = Color.white; + return float.IsNaN(track.FadeOutBeat) ? DefaultLightsColor : Color.black; } } } diff --git a/MuzikaGromche/PoweredLightsAnimators.cs b/MuzikaGromche/PoweredLightsAnimators.cs index 7f5ea1d..b32e172 100644 --- a/MuzikaGromche/PoweredLightsAnimators.cs +++ b/MuzikaGromche/PoweredLightsAnimators.cs @@ -252,6 +252,7 @@ namespace MuzikaGromche static bool OnRefreshLightsList(RoundManager __instance) { RefreshLightsListPatched(__instance); + LoadInitialLightsColors(__instance); // Skip the original method return false; } @@ -286,5 +287,15 @@ namespace MuzikaGromche animator.SetFloat("flickerSpeed", UnityEngine.Random.Range(0.6f, 1.4f)); } } + + static void LoadInitialLightsColors(RoundManager self) + { + var originalColors = new Dictionary(); + foreach (var light in self.allPoweredLights) + { + originalColors[light] = light.color; + } + Plugin.InitialLightsColors = originalColors; + } } }