using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [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 CustomColors { [HarmonyPatch(typeof(SemiFunc))] internal static class ColorPatch { [HarmonyPostfix] [HarmonyPatch("PlayerGetColorMain")] private static void AfterPlayerGetColorMain(PlayerAvatar _player, ref Color __result) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Enabled.Value) { Color? val = ColorSync.Lookup(_player); if (val.HasValue) { __result = val.Value; } } } } internal class ColorPicker : MonoBehaviour { private bool _open; private int _row; private float[] _rgb = new float[3] { 0.31f, 0.76f, 0.97f }; private bool _loaded; private static readonly string[] Names = new string[3] { "Red", "Green", "Blue" }; private void Update() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled.Value) { return; } if (!_loaded) { Color? val = ColorSync.Parse(Plugin.MyColor.Value); if (val.HasValue) { _rgb[0] = val.Value.r; _rgb[1] = val.Value.g; _rgb[2] = val.Value.b; } _loaded = true; Publish(); } if (!SemiFunc.RunIsShop() && !SemiFunc.RunIsLobby() && !SemiFunc.RunIsLobbyMenu()) { _open = false; return; } if (Input.GetKeyDown(Plugin.ToggleKey.Value)) { _open = !_open; if (!_open) { Publish(); } } if (_open) { if (Input.GetKeyDown((KeyCode)274)) { _row = (_row + 1) % 3; } if (Input.GetKeyDown((KeyCode)273)) { _row = (_row + 2) % 3; } float num = (Input.GetKey((KeyCode)304) ? 0.02f : 0.08f); if (Input.GetKeyDown((KeyCode)275)) { Nudge(num); } if (Input.GetKeyDown((KeyCode)276)) { Nudge(0f - num); } } } private void Nudge(float delta) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) _rgb[_row] = Mathf.Clamp01(Mathf.Round((_rgb[_row] + delta) * 100f) / 100f); Plugin.MyColor.Value = "#" + ColorUtility.ToHtmlStringRGB(Current()); } private Color Current() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Color(_rgb[0], _rgb[1], _rgb[2]); } private void Publish() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ColorSync.Publish(Current()); } private void OnGUI() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_008b: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if (_open) { Rect val = default(Rect); ((Rect)(ref val))..ctor(24f, 24f, 320f, 190f); GUI.color = new Color(0f, 0f, 0f, 0.82f); GUI.Box(val, GUIContent.none); GUI.color = Color.white; GUILayout.BeginArea(new Rect(((Rect)(ref val)).x + 14f, ((Rect)(ref val)).y + 12f, ((Rect)(ref val)).width - 28f, ((Rect)(ref val)).height - 24f)); GUILayout.Label("Your colour", Rich(), Array.Empty()); GUI.color = Current(); GUILayout.Box(GUIContent.none, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(18f) }); GUI.color = Color.white; GUILayout.Space(4f); for (int i = 0; i < 3; i++) { string arg = ((_row == i) ? "> " : " "); int num = Mathf.RoundToInt(_rgb[i] * 100f); GUILayout.Label($"{arg}{Names[i],-6} {num,3}%", Rich(), Array.Empty()); } GUILayout.Space(6f); GUILayout.Label("" + Plugin.MyColor.Value + " · Up/Down select · Left/Right adjust\n" + $"Shift for fine · {Plugin.ToggleKey.Value} closes and applies", Rich(), Array.Empty()); GUILayout.EndArea(); } } private static GUIStyle Rich() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown return new GUIStyle(GUI.skin.label) { richText = true, wordWrap = true }; } } internal static class ColorSync { private const string Key = "bcol"; internal static void Publish(Color colour) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0032: Expected O, but got Unknown if (PhotonNetwork.IsConnected && PhotonNetwork.LocalPlayer != null) { string text = "#" + ColorUtility.ToHtmlStringRGB(colour); Hashtable val = new Hashtable(); ((Dictionary)val).Add((object)"bcol", (object)text); Hashtable val2 = val; PhotonNetwork.LocalPlayer.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null); Plugin.Trace("[CustomColors] Published " + text); } } internal static Color? Lookup(PlayerAvatar avatar) { if ((Object)(object)avatar == (Object)null) { return null; } if (avatar.isLocal || !PhotonNetwork.IsConnected) { return Parse(Plugin.MyColor.Value); } PhotonView photonView = avatar.photonView; Player val = (((Object)(object)photonView != (Object)null) ? photonView.Owner : null); if (val == null) { return null; } if (val.CustomProperties != null && ((Dictionary)(object)val.CustomProperties).TryGetValue((object)"bcol", out object value) && value is string hex) { return Parse(hex); } return null; } internal static Color? Parse(string hex) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(hex)) { return null; } if (!hex.StartsWith("#")) { hex = "#" + hex; } Color value = default(Color); if (!ColorUtility.TryParseHtmlString(hex, ref value)) { return null; } return value; } } [BepInPlugin("benjamin.customcolors", "CustomColors", "1.0.0")] [BepInProcess("REPO.exe")] public class Plugin : BaseUnityPlugin { public const string Guid = "benjamin.customcolors"; public const string Name = "CustomColors"; public const string Version = "1.0.0"; internal static ManualLogSource Log; private Harmony _harmony; internal static ConfigEntry Enabled; internal static ConfigEntry MyColor; internal static ConfigEntry ToggleKey; internal static ConfigEntry Verbose; private void Awake() { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Master switch. Turn off to fall back to the vanilla palette."); MyColor = ((BaseUnityPlugin)this).Config.Bind("Colour", "MyColor", "#4FC3F7", "Your colour as a hex string, e.g. #4FC3F7. Editable in-game with the picker; this is where it persists."); ToggleKey = ((BaseUnityPlugin)this).Config.Bind("General", "ToggleKey", (KeyCode)289, "Opens the colour picker. Works in the lobby and the shop, not mid-level."); Verbose = ((BaseUnityPlugin)this).Config.Bind("Debug", "Verbose", false, "Log colour broadcasts and lookups."); _harmony = new Harmony("benjamin.customcolors"); _harmony.PatchAll(typeof(ColorPatch)); ((Component)this).gameObject.AddComponent(); Log.LogInfo((object)string.Format("{0} v{1} loaded. Picker on {2}.", "CustomColors", "1.0.0", ToggleKey.Value)); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void Trace(string msg) { if (Verbose != null && Verbose.Value) { Log.LogInfo((object)msg); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "CustomColors"; public const string PLUGIN_NAME = "CustomColors"; public const string PLUGIN_VERSION = "1.0.0"; } }