forked from nikita/muzika-gromche
Compare commits
No commits in common. "585ef604ffcdbcb23a39db6f57e3ca5dfb34bc87" and "63de62111f871cc6d55304b3c2d0c135b51975cc" have entirely different histories.
585ef604ff
...
63de62111f
|
@ -1,9 +1,5 @@
|
|||
# Changelog
|
||||
|
||||
## MuzikaGromche 1337.420.9003 - Lights Out Edition
|
||||
|
||||
- Fixed wrong colors during fade out transition, e.g. in Mineshaft tunnel tiles.
|
||||
|
||||
## MuzikaGromche 1337.420.9002 - Anime Edition
|
||||
|
||||
- Added a new track OnePartiyaUdar in Japanese language.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<AssemblyName>Ratijas.MuzikaGromche</AssemblyName>
|
||||
<Product>Muzika Gromche</Product>
|
||||
<Description>Add some content to your inverse teleporter experience on Titan!</Description>
|
||||
<Version>1337.420.9003</Version>
|
||||
<Version>1337.420.9002</Version>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<Nullable>enable</Nullable>
|
||||
|
|
|
@ -597,6 +597,22 @@ namespace MuzikaGromche
|
|||
return Tracks.SelectMany(track => track.GetTracks()).FirstOrDefault(track => track.Name == name);
|
||||
}
|
||||
|
||||
public static void SetLightColor(Color color)
|
||||
{
|
||||
foreach (var light in RoundManager.Instance.allPoweredLights)
|
||||
{
|
||||
light.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
public static void ResetLightColor()
|
||||
{
|
||||
foreach (var (light, color) in InitialLightsColors)
|
||||
{
|
||||
light.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
// Max audible distance for AudioSource and LyricsEvent
|
||||
public const float AudioMaxDistance = 150;
|
||||
|
||||
|
@ -1543,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(/* use initial light color */null, 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
|
||||
{
|
||||
|
@ -1592,9 +1610,9 @@ namespace MuzikaGromche
|
|||
}
|
||||
}
|
||||
// default
|
||||
return new SetLightsColorStaticEvent(ColorAtWholeBeat(timestamp));
|
||||
return new SetLightsColorEvent(ColorAtWholeBeat(timestamp));
|
||||
|
||||
SetLightsColorTransitionEvent ColorTransition(BeatTimestamp clipsBoundary)
|
||||
SetLightsColorEvent ColorTransition(BeatTimestamp clipsBoundary)
|
||||
{
|
||||
var transitionStart = clipsBoundary - track.ColorTransitionIn;
|
||||
var transitionEnd = clipsBoundary + track.ColorTransitionOut;
|
||||
|
@ -1607,7 +1625,7 @@ namespace MuzikaGromche
|
|||
return new SetLightsColorTransitionEvent(ColorAtWholeBeat(transitionStart), ColorAtWholeBeat(transitionEnd), track.ColorTransitionEasing, t);
|
||||
}
|
||||
|
||||
Color? ColorAtWholeBeat(BeatTimestamp timestamp)
|
||||
Color ColorAtWholeBeat(BeatTimestamp timestamp)
|
||||
{
|
||||
if (timestamp.Beat >= 0f)
|
||||
{
|
||||
|
@ -1616,7 +1634,9 @@ namespace MuzikaGromche
|
|||
}
|
||||
else
|
||||
{
|
||||
return float.IsNaN(track.FadeOutBeat) ? /* use initial light color */ null : Color.black;
|
||||
// TODO: assumes that default lights color is white
|
||||
var DefaultLightsColor = Color.white;
|
||||
return float.IsNaN(track.FadeOutBeat) ? DefaultLightsColor : Color.black;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1624,55 +1644,26 @@ namespace MuzikaGromche
|
|||
|
||||
abstract class BaseEvent;
|
||||
|
||||
abstract class SetLightsColorEvent : BaseEvent
|
||||
class SetLightsColorEvent(Color color) : BaseEvent
|
||||
{
|
||||
// Calculate final color, substituting null with initialColor if needed.
|
||||
public abstract Color GetColor(Color initialColor);
|
||||
|
||||
protected string NullableColorToString(Color? color)
|
||||
{
|
||||
return color is { } c ? ColorUtility.ToHtmlStringRGB(c) : "??????";
|
||||
}
|
||||
}
|
||||
|
||||
class SetLightsColorStaticEvent(Color? color) : SetLightsColorEvent
|
||||
{
|
||||
public readonly Color? Color = color;
|
||||
|
||||
public override Color GetColor(Color initialColor)
|
||||
{
|
||||
return Color ?? initialColor;
|
||||
}
|
||||
|
||||
public readonly Color Color = color;
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Color(#{NullableColorToString(Color)})";
|
||||
return $"Color(#{ColorUtility.ToHtmlStringRGB(Color)})";
|
||||
}
|
||||
}
|
||||
|
||||
class SetLightsColorTransitionEvent(Color? from, Color? to, Easing easing, float t) : SetLightsColorEvent
|
||||
class SetLightsColorTransitionEvent(Color from, Color to, Easing easing, float t)
|
||||
: SetLightsColorEvent(Color.Lerp(from, to, Mathf.Clamp(easing.Eval(t), 0f, 1f)))
|
||||
{
|
||||
// Additional context for debugging
|
||||
public readonly Color? From = from;
|
||||
public readonly Color? To = to;
|
||||
public readonly Color From = from;
|
||||
public readonly Color To = to;
|
||||
public readonly Easing Easing = easing;
|
||||
public readonly float T = t;
|
||||
|
||||
public override Color GetColor(Color initialColor)
|
||||
{
|
||||
var from = From ?? initialColor;
|
||||
var to = To ?? initialColor;
|
||||
return Color.Lerp(from, to, Mathf.Clamp(Easing.Eval(T), 0f, 1f));
|
||||
}
|
||||
|
||||
private Color? GetNullableColor()
|
||||
{
|
||||
return From is { } from && To is { } to ? Color.Lerp(from, to, Mathf.Clamp(Easing.Eval(T), 0f, 1f)) : null;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"Color(#{NullableColorToString(GetNullableColor())} = #{NullableColorToString(From)}..#{NullableColorToString(To)} {Easing} {T:N4})";
|
||||
return $"Color(#{ColorUtility.ToHtmlStringRGB(Color)} = #{ColorUtility.ToHtmlStringRGB(From)}..#{ColorUtility.ToHtmlStringRGB(To)} {Easing} {T:N4})";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2447,7 +2438,7 @@ namespace MuzikaGromche
|
|||
// transition away from state 2 ("poppedOut"), normally to state 0
|
||||
if (__state.previousState == 2 && __instance.previousState != 2)
|
||||
{
|
||||
PoweredLightsBehaviour.Instance.ResetLightColor();
|
||||
Plugin.ResetLightColor();
|
||||
DiscoBallManager.Disable();
|
||||
// Rotate track groups
|
||||
behaviour.ChooseTrackServerRpc();
|
||||
|
@ -2467,7 +2458,7 @@ namespace MuzikaGromche
|
|||
break;
|
||||
|
||||
case SetLightsColorEvent e:
|
||||
PoweredLightsBehaviour.Instance.SetLightColor(e);
|
||||
Plugin.SetLightColor(e.Color);
|
||||
break;
|
||||
|
||||
case FlickerLightsEvent:
|
||||
|
@ -2497,7 +2488,7 @@ namespace MuzikaGromche
|
|||
{
|
||||
if (__instance is JesterAI)
|
||||
{
|
||||
PoweredLightsBehaviour.Instance.ResetLightColor();
|
||||
Plugin.ResetLightColor();
|
||||
DiscoBallManager.Disable();
|
||||
// Just in case if players have spawned multiple Jesters,
|
||||
// Don't reset Plugin.CurrentTrack to null,
|
||||
|
|
|
@ -252,10 +252,7 @@ namespace MuzikaGromche
|
|||
static bool OnRefreshLightsList(RoundManager __instance)
|
||||
{
|
||||
RefreshLightsListPatched(__instance);
|
||||
|
||||
var behaviour = __instance.gameObject.GetComponent<PoweredLightsBehaviour>() ?? __instance.gameObject.AddComponent<PoweredLightsBehaviour>();
|
||||
behaviour.Refresh();
|
||||
|
||||
LoadInitialLightsColors(__instance);
|
||||
// Skip the original method
|
||||
return false;
|
||||
}
|
||||
|
@ -290,56 +287,15 @@ namespace MuzikaGromche
|
|||
animator.SetFloat("flickerSpeed", UnityEngine.Random.Range(0.6f, 1.4f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class PoweredLightsBehaviour : MonoBehaviour
|
||||
static void LoadInitialLightsColors(RoundManager self)
|
||||
{
|
||||
private struct LightData
|
||||
var originalColors = new Dictionary<Light, Color>();
|
||||
foreach (var light in self.allPoweredLights)
|
||||
{
|
||||
public Light Light;
|
||||
public Color InitialColor;
|
||||
}
|
||||
|
||||
private readonly List<LightData> AllPoweredLights = [];
|
||||
|
||||
public static PoweredLightsBehaviour Instance { get; private set; } = null!;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
AllPoweredLights.Clear();
|
||||
foreach (var light in RoundManager.Instance.allPoweredLights)
|
||||
{
|
||||
AllPoweredLights.Add(new LightData
|
||||
{
|
||||
Light = light,
|
||||
InitialColor = light.color,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void SetLightColor(SetLightsColorEvent e)
|
||||
{
|
||||
foreach (var data in AllPoweredLights)
|
||||
{
|
||||
var color = e.GetColor(data.InitialColor);
|
||||
data.Light.color = color;
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetLightColor()
|
||||
{
|
||||
foreach (var data in AllPoweredLights)
|
||||
{
|
||||
data.Light.color = data.InitialColor;
|
||||
originalColors[light] = light.color;
|
||||
}
|
||||
Plugin.InitialLightsColors = originalColors;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "MuzikaGromche",
|
||||
"version_number": "1337.420.9003",
|
||||
"version_number": "1337.420.9002",
|
||||
"author": "Ratijas",
|
||||
"description": "Add some content to your inverse teleporter experience on Titan!",
|
||||
"website_url": "https://git.vilunov.me/ratijas/muzika-gromche",
|
||||
|
|
Loading…
Reference in New Issue