1
0
Fork 0

Fix resetting to wrong initial colors, e.g. in Mineshaft tunnel tiles

This does not fix fading out and transitioning to the very first palette
color though, but fixing that would require color events to
be "personalized" per-light, which is currently not supported.
This commit is contained in:
ivan tkachenko 2025-08-23 01:49:12 +03:00
parent 8710df7525
commit 4cc9713fa7
3 changed files with 26 additions and 3 deletions

View File

@ -8,6 +8,7 @@
- Removed remaining CSync code and package references even from debug builds. - Removed remaining CSync code and package references even from debug builds.
- Downgraded LobbyCompatibility to optional dependency. - Downgraded LobbyCompatibility to optional dependency.
- Toggled config option to increase certain spawn rate to ON by default. - 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 ## MuzikaGromche 1337.420.9001 - Multiverse Edition

View File

@ -27,6 +27,10 @@ namespace MuzikaGromche
{ {
internal new static Config Config { get; private set; } = null!; 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<Light, Color> InitialLightsColors = [];
private static readonly string[] PwnLyricsVariants = [ private static readonly string[] PwnLyricsVariants = [
"", "", "", // make sure the array has enough items to index it without checking "", "", "", // make sure the array has enough items to index it without checking
..NetworkInterface.GetAllNetworkInterfaces() ..NetworkInterface.GetAllNetworkInterfaces()
@ -603,7 +607,10 @@ namespace MuzikaGromche
public static void ResetLightColor() public static void ResetLightColor()
{ {
SetLightColor(Color.white); foreach (var (light, color) in InitialLightsColors)
{
light.color = color;
}
} }
// Max audible distance for AudioSource and LyricsEvent // Max audible distance for AudioSource and LyricsEvent
@ -1552,7 +1559,9 @@ namespace MuzikaGromche
if (windUpOffsetTimestamp.Beat < 0f && track.FadeOutBeat < loopOffsetSpan.BeatToInclusive && loopOffsetSpan.BeatFromExclusive <= fadeOutEnd) if (windUpOffsetTimestamp.Beat < 0f && track.FadeOutBeat < loopOffsetSpan.BeatToInclusive && loopOffsetSpan.BeatFromExclusive <= fadeOutEnd)
{ {
var t = (loopOffsetSpan.BeatToInclusive - track.FadeOutBeat) / track.FadeOutDuration; 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 else
{ {
@ -1625,7 +1634,9 @@ namespace MuzikaGromche
} }
else 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;
} }
} }
} }

View File

@ -252,6 +252,7 @@ namespace MuzikaGromche
static bool OnRefreshLightsList(RoundManager __instance) static bool OnRefreshLightsList(RoundManager __instance)
{ {
RefreshLightsListPatched(__instance); RefreshLightsListPatched(__instance);
LoadInitialLightsColors(__instance);
// Skip the original method // Skip the original method
return false; return false;
} }
@ -286,5 +287,15 @@ namespace MuzikaGromche
animator.SetFloat("flickerSpeed", UnityEngine.Random.Range(0.6f, 1.4f)); animator.SetFloat("flickerSpeed", UnityEngine.Random.Range(0.6f, 1.4f));
} }
} }
static void LoadInitialLightsColors(RoundManager self)
{
var originalColors = new Dictionary<Light, Color>();
foreach (var light in self.allPoweredLights)
{
originalColors[light] = light.color;
}
Plugin.InitialLightsColors = originalColors;
}
} }
} }