using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("coruscnium")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Cycles the game's UI color through pride flag stripes")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("PrideUIMod")]
[assembly: AssemblyTitle("PrideUIMod")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace PrideUIMod
{
[MycoMod(/*Could not decode attribute arguments.*/)]
[BepInPlugin("coruscnium.prideui", "PrideUI", "1.0.0.0")]
[BepInProcess("Mycopunk.exe")]
public class Plugin : BaseUnityPlugin
{
public const string PluginGUID = "coruscnium.prideui";
public const string PluginName = "PrideUI";
public const string PluginVersion = "1.0.0.0";
internal static ManualLogSource Logger;
private const float MinBrightness = 0.45f;
private const float RepaintInterval = 0.05f;
private const float FadeFraction = 0.5f;
private static ConfigEntry<string> _flagConfig;
private static ConfigEntry<string> _animateWhenConfig;
private static ConfigEntry<float> _secondsPerColorConfig;
private static bool _animateAlways;
private static float _secondsPerColor = 3f;
private static Color[] _sequence = PrideFlags.BuildSequence("Rainbow");
private const string WhenMenus = "Menus";
private const string WhenAlways = "Always";
private static FileSystemWatcher _configWatcher;
private static volatile bool _pendingConfigReload;
private static FieldInfo _uiColorField;
private static float _phase;
private static float _sinceTick;
private static bool _driving;
private static Color _vanillaColor;
private static Color _lastWritten;
private static bool _applyFailed;
private static bool _forceApply = true;
private void Awake()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"PrideUI loading...");
_flagConfig = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Flag", "Rainbow", new ConfigDescription("Which flag's colors the UI cycles through.\n All = run through every flag in order", (AcceptableValueBase)(object)new AcceptableValueList<string>(PrideFlags.OptionNames()), Array.Empty<object>()));
_animateWhenConfig = ((BaseUnityPlugin)this).Config.Bind<string>("General", "AnimateWhen", "Menus", new ConfigDescription("Menus = only animate while a menu is on screen (main menu, inventory,\n pause, popups, quip wheel). Frozen during play — the HUD keeps\n whatever color it stopped on and costs nothing.\nAlways = keep cycling during gameplay too.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Menus", "Always" }), Array.Empty<object>()));
_secondsPerColorConfig = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SecondsPerColor", 3f, new ConfigDescription("Seconds each color gets, including the crossfade into the next one.\nLower is faster.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 60f), Array.Empty<object>()));
CacheConfig();
_flagConfig.SettingChanged += delegate
{
CacheConfig();
};
_animateWhenConfig.SettingChanged += delegate
{
CacheConfig();
};
_secondsPerColorConfig.SettingChanged += delegate
{
CacheConfig();
};
PruneOrphanedEntries();
((BaseUnityPlugin)this).Config.Save();
try
{
_configWatcher = new FileSystemWatcher(Paths.ConfigPath, "coruscnium.prideui.cfg")
{
NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite),
EnableRaisingEvents = true
};
_configWatcher.Changed += OnConfigFileChanged;
_configWatcher.Created += OnConfigFileChanged;
_configWatcher.Renamed += OnConfigFileChanged;
}
catch (Exception ex)
{
Logger.LogWarning((object)("Could not start config file watcher: " + ex.Message));
}
_uiColorField = typeof(Global).GetField("_uiColor", BindingFlags.Static | BindingFlags.NonPublic);
if (_uiColorField == null)
{
Logger.LogWarning((object)"Global._uiColor not found — the vanilla UI color can't be restored on unload.");
}
Logger.LogInfo((object)("PrideUI loaded. Flag: " + _flagConfig.Value + ", animating: " + _animateWhenConfig.Value));
}
private void OnConfigFileChanged(object sender, FileSystemEventArgs e)
{
_pendingConfigReload = true;
}
private static void CacheConfig()
{
_animateAlways = _animateWhenConfig.Value == "Always";
_secondsPerColor = Mathf.Max(0.05f, _secondsPerColorConfig.Value);
_sequence = PrideFlags.BuildSequence(_flagConfig.Value);
_forceApply = true;
}
private void PruneOrphanedEntries()
{
try
{
if (typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(((BaseUnityPlugin)this).Config) is IDictionary { Count: >0 } dictionary)
{
Logger.LogInfo((object)$"Dropping {dictionary.Count} retired setting(s) from the config file.");
dictionary.Clear();
}
}
catch (Exception ex)
{
Logger.LogWarning((object)("Could not prune retired config entries: " + ex.Message));
}
}
private void Update()
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
if (_pendingConfigReload)
{
_pendingConfigReload = false;
((BaseUnityPlugin)this).Config.Reload();
}
if (_animateAlways || MenuVisible())
{
_phase += Time.unscaledDeltaTime;
_sinceTick += Time.unscaledDeltaTime;
}
else if (!_forceApply)
{
return;
}
if (_forceApply || !(_sinceTick < 0.05f))
{
_forceApply = false;
_sinceTick = 0f;
Apply(CurrentColor());
}
}
private static bool MenuVisible()
{
if (PlayerInput.IsMenuEnabled)
{
return true;
}
if ((Object)(object)StartMenu.Instance != (Object)null)
{
return true;
}
Menu instance = Menu.Instance;
return (Object)(object)instance != (Object)null && (instance.IsOpen || instance.IsClosing);
}
private static Color CurrentColor()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
int num = _sequence.Length;
if (num == 0)
{
return Color.white;
}
float secondsPerColor = _secondsPerColor;
float num2 = secondsPerColor * (float)num;
if (_phase >= num2)
{
_phase %= num2;
}
float num3 = _phase / secondsPerColor;
int num4 = Mathf.Min((int)num3, num - 1);
Color val = _sequence[num4];
if (num == 1)
{
return val;
}
float num5 = secondsPerColor * 0.5f;
float num6 = _phase - (float)num4 * secondsPerColor;
float num7 = secondsPerColor - num5;
if (num6 <= num7)
{
return val;
}
return Color.Lerp(val, _sequence[(num4 + 1) % num], (num6 - num7) / num5);
}
private static Color Readable(Color c)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
float num = default(float);
float num2 = default(float);
float num3 = default(float);
Color.RGBToHSV(c, ref num, ref num2, ref num3);
if (num3 >= 0.45f)
{
return c;
}
return Color.HSVToRGB(num, num2, 0.45f);
}
private static void Apply(Color color)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
Color val = ReadRawUiColor();
if (!_driving)
{
_vanillaColor = val;
_driving = true;
}
else if (val != _lastWritten)
{
_vanillaColor = val;
}
Color val2 = Readable(color);
val2.a = 1f;
SetUiColor(val2);
_lastWritten = val2;
}
private static void SetUiColor(Color color)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
try
{
Global.UIColor = color;
_applyFailed = false;
}
catch (Exception arg)
{
if (!_applyFailed)
{
_applyFailed = true;
Logger.LogError((object)$"Failed to set UI color: {arg}");
}
}
}
private static Color ReadRawUiColor()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (_uiColorField == null)
{
return _lastWritten;
}
return (Color)_uiColorField.GetValue(null);
}
private void OnDestroy()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (_driving)
{
_driving = false;
SetUiColor(_vanillaColor);
}
if (_configWatcher != null)
{
_configWatcher.EnableRaisingEvents = false;
_configWatcher.Changed -= OnConfigFileChanged;
_configWatcher.Created -= OnConfigFileChanged;
_configWatcher.Renamed -= OnConfigFileChanged;
_configWatcher.Dispose();
_configWatcher = null;
}
}
}
internal static class PrideFlags
{
internal sealed class Flag
{
public readonly string Name;
public readonly Color[] Stripes;
public Flag(string name, params string[] hex)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
Name = name;
Stripes = (Color[])(object)new Color[hex.Length];
for (int i = 0; i < hex.Length; i++)
{
Stripes[i] = FromHex(hex[i]);
}
}
}
public const string AllOption = "All";
public static readonly Flag[] All = new Flag[15]
{
new Flag("Rainbow", "E40303", "FF8C00", "FFED00", "008026", "004DFF", "750787"),
new Flag("Progress", "E40303", "FF8C00", "FFED00", "008026", "004DFF", "750787", "000000", "613915", "5BCEFA", "F5A9B8", "FFFFFF"),
new Flag("Transgender", "5BCEFA", "F5A9B8", "FFFFFF"),
new Flag("Bisexual", "D60270", "9B4F96", "0038A8"),
new Flag("Pansexual", "FF218C", "FFD800", "21B1FF"),
new Flag("Lesbian", "D52D00", "EF7627", "FF9A56", "FFFFFF", "D162A4", "B55690", "A30262"),
new Flag("Gay", "078D70", "26CEAA", "98E8C1", "FFFFFF", "7BADE2", "5049CC", "3D1A78"),
new Flag("Asexual", "000000", "A3A3A3", "FFFFFF", "800080"),
new Flag("Aromantic", "3BA740", "A8D47A", "FFFFFF", "ABABAB", "000000"),
new Flag("Aroace", "E28C00", "ECCD00", "FFFFFF", "62AEDC", "203856"),
new Flag("Nonbinary", "FCF434", "FFFFFF", "9C59D1", "2C2C2C"),
new Flag("Genderfluid", "FF75A2", "FFFFFF", "BE18D6", "000000", "333EBD"),
new Flag("Genderqueer", "B57EDC", "FFFFFF", "4A8123"),
new Flag("Agender", "000000", "BCC4C7", "FFFFFF", "B7F684"),
new Flag("Intersex", "FFD800", "7902AA")
};
public static string[] OptionNames()
{
string[] array = new string[All.Length + 1];
for (int i = 0; i < All.Length; i++)
{
array[i] = All[i].Name;
}
array[All.Length] = "All";
return array;
}
public static Color[] BuildSequence(string option)
{
if (option == "All")
{
List<Color> list = new List<Color>();
Flag[] all = All;
foreach (Flag flag in all)
{
list.AddRange(flag.Stripes);
}
return list.ToArray();
}
Flag[] all2 = All;
foreach (Flag flag2 in all2)
{
if (flag2.Name == option)
{
return flag2.Stripes;
}
}
return All[0].Stripes;
}
private static Color FromHex(string hex)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
int num = int.Parse(hex, NumberStyles.HexNumber);
return new Color((float)((num >> 16) & 0xFF) / 255f, (float)((num >> 8) & 0xFF) / 255f, (float)(num & 0xFF) / 255f, 1f);
}
}
}