Decompiled source of CustomLocalColorsRedux v1.0.0

CustomLocalColors.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CustomLocalColors")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomLocalColors")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bfb06223-fd1a-4315-97e8-9924fb730a74")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public class ColorPickerController : MonoBehaviour
{
	public int size = 300;

	public RectTransform boxMarker;

	public RectTransform rangeMarker;

	private RectTransform hueBox;

	private RectTransform satVal;

	private RectTransform hueRange;

	private Color color;

	private bool inClick;

	private bool boxOrRange;

	public bool isEnabled;

	public Sprite grayscaleHueRange;

	private Sprite hueRangeSprite;

	public float step = 3f;

	private void Start()
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		isEnabled = true;
		hueBox = ((Component)((Component)this).transform.GetChild(0)).GetComponent<RectTransform>();
		satVal = ((Component)((Component)this).transform.GetChild(1)).GetComponent<RectTransform>();
		hueRange = ((Component)((Component)this).transform.GetChild(2)).GetComponent<RectTransform>();
		hueRangeSprite = ((Component)hueRange).GetComponent<Image>().sprite;
		hueBox.sizeDelta = Vector2.op_Implicit(Vector3.one * (float)size);
		satVal.sizeDelta = Vector2.op_Implicit(Vector3.one * (float)size);
		hueRange.sizeDelta = Vector2.op_Implicit(new Vector3((float)size, (float)(size / 10)));
		((Transform)hueRange).localPosition = new Vector3(0f, -0.55f * (float)size);
	}

	private void Update()
	{
		//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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0312: Unknown result type (might be due to invalid IL or missing references)
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0382: Unknown result type (might be due to invalid IL or missing references)
		//IL_0387: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		if (Mouse.current.leftButton.isPressed && isEnabled)
		{
			Vector2 val = ((InputControl<Vector2>)(object)((Pointer)Mouse.current).position).ReadValue();
			Vector2 val2 = default(Vector2);
			Rect rect;
			if (!inClick)
			{
				if (RectTransformUtility.RectangleContainsScreenPoint(hueBox, val, (Camera)null))
				{
					boxOrRange = true;
					inClick = true;
				}
				if (RectTransformUtility.RectangleContainsScreenPoint(hueRange, val, (Camera)null))
				{
					boxOrRange = false;
					inClick = true;
				}
			}
			else if (boxOrRange)
			{
				RectTransformUtility.ScreenPointToLocalPointInRectangle(hueBox, val, (Camera)null, ref val2);
				float x = val2.x;
				rect = hueBox.rect;
				float num = (0f - ((Rect)(ref rect)).width) / 2f;
				rect = hueBox.rect;
				val2.x = Mathf.Clamp(x, num, ((Rect)(ref rect)).width / 2f) + ((Transform)hueBox).localPosition.x;
				float y = val2.y;
				rect = hueBox.rect;
				float num2 = (0f - ((Rect)(ref rect)).height) / 2f;
				rect = hueBox.rect;
				val2.y = Mathf.Clamp(y, num2, ((Rect)(ref rect)).height / 2f) + ((Transform)hueBox).localPosition.y;
				((Transform)boxMarker).localPosition = Vector2.op_Implicit(val2);
			}
			else
			{
				RectTransformUtility.ScreenPointToLocalPointInRectangle(hueRange, val, (Camera)null, ref val2);
				float x2 = val2.x;
				rect = hueRange.rect;
				float num3 = (0f - ((Rect)(ref rect)).width) / 2f;
				rect = hueRange.rect;
				val2.x = Mathf.Clamp(x2, num3, ((Rect)(ref rect)).width / 2f) + ((Transform)hueRange).localPosition.x;
				float y2 = val2.y;
				rect = hueRange.rect;
				float num4 = (0f - ((Rect)(ref rect)).height) / 2f;
				rect = hueRange.rect;
				val2.y = Mathf.Clamp(y2, num4, ((Rect)(ref rect)).height / 2f) + ((Transform)hueRange).localPosition.y;
				((Transform)rangeMarker).localPosition = Vector2.op_Implicit(val2);
			}
		}
		else
		{
			inClick = false;
		}
		if ((Object)(object)((Component)hueRange).GetComponent<Image>().sprite == (Object)(object)hueRangeSprite && !isEnabled)
		{
			((Component)hueRange).GetComponent<Image>().sprite = grayscaleHueRange;
		}
		if ((Object)(object)((Component)hueRange).GetComponent<Image>().sprite == (Object)(object)grayscaleHueRange && isEnabled)
		{
			((Component)hueRange).GetComponent<Image>().sprite = hueRangeSprite;
		}
		Vector3 val3 = ((Transform)boxMarker).localPosition + Vector3.one * (float)size / 2f;
		val3 /= (float)size;
		Vector3 val4 = ((Transform)rangeMarker).localPosition + new Vector3((float)(size / 2), (float)(size / 20));
		val4 /= (float)size;
		color = Color.HSVToRGB(val4.x, val3.x, val3.y);
		if (!isEnabled)
		{
			color = new Color(((Color)(ref color)).grayscale, ((Color)(ref color)).grayscale, ((Color)(ref color)).grayscale);
		}
		Color val5 = Color.HSVToRGB(val4.x, 1f, 1f);
		if (!isEnabled)
		{
			((Color)(ref val5))..ctor(((Color)(ref val5)).grayscale, ((Color)(ref val5)).grayscale, ((Color)(ref val5)).grayscale);
		}
		((Graphic)((Component)hueBox).GetComponent<Image>()).color = val5;
	}

	public Color GetColor()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		return color;
	}

	public void SetMarkersToColor(Color targetColor)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: 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)
		if ((Object)(object)rangeMarker == (Object)null || (Object)(object)boxMarker == (Object)null)
		{
			Console.WriteLine("rangeMarker or boxMarker is null.");
			return;
		}
		float num = default(float);
		float num2 = default(float);
		float num3 = default(float);
		Color.RGBToHSV(targetColor, ref num, ref num2, ref num3);
		Vector3 localPosition = default(Vector3);
		((Vector3)(ref localPosition))..ctor(num * (float)size - (float)(size / 2), 0f, 0f);
		Vector3 localPosition2 = default(Vector3);
		((Vector3)(ref localPosition2))..ctor(num2 * (float)size - (float)(size / 2), num3 * (float)size - (float)(size / 2), 0f);
		if ((Object)(object)rangeMarker != (Object)null)
		{
			((Transform)rangeMarker).localPosition = localPosition;
		}
		if ((Object)(object)boxMarker != (Object)null)
		{
			((Transform)boxMarker).localPosition = localPosition2;
		}
	}

	public void MoveMarker(Vector2 direction, bool isBoxMarker)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: 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)
		//IL_004f: 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_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		RectTransform val = (isBoxMarker ? boxMarker : rangeMarker);
		RectTransform val2 = (isBoxMarker ? hueBox : hueRange);
		Vector3 val3 = ((Transform)val).localPosition + new Vector3(direction.x * step, direction.y * step);
		Rect rect = val.rect;
		float num = ((Rect)(ref rect)).width / 2f;
		rect = val.rect;
		float num2 = ((Rect)(ref rect)).height / 2f;
		rect = val2.rect;
		float num3 = ((Rect)(ref rect)).width / 2f;
		rect = val2.rect;
		float num4 = ((Rect)(ref rect)).height / 2f;
		float num5 = Mathf.Clamp(val3.x, ((Transform)val2).localPosition.x - num3 + num, ((Transform)val2).localPosition.x + num3 - num);
		float num6 = Mathf.Clamp(val3.y, ((Transform)val2).localPosition.y - num4 + num2, ((Transform)val2).localPosition.y + num4 - num2);
		((Transform)val).localPosition = new Vector3(num5, num6, ((Transform)val).localPosition.z);
	}
}
public class RandomButton : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerClickHandler
{
	public bool random;

	public Sprite on;

	public Sprite off;

	private Vector2 originalSize;

	private void Start()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		originalSize = ((Component)this).GetComponent<RectTransform>().sizeDelta;
	}

	public void OnPointerClick(PointerEventData eventData)
	{
		random = !random;
		((Component)this).GetComponent<Image>().sprite = (random ? on : off);
	}

	public void OnPointerEnter(PointerEventData eventData)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: 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_001b: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).GetComponent<RectTransform>().sizeDelta = originalSize + Vector2.one * 10f;
	}

	public void OnPointerExit(PointerEventData eventData)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		((Component)this).GetComponent<RectTransform>().sizeDelta = originalSize;
	}

	public void Press()
	{
		random = !random;
		((Component)this).GetComponent<Image>().sprite = (random ? on : off);
	}
}
namespace CustomLocalColors;

internal class Patches
{
	[HarmonyPatch(typeof(ReadyButton), "OnClick")]
	private class SummonColorPicker
	{
		private static void Postfix(ReadyButton __instance)
		{
			try
			{
				Transform parent = ((Component)__instance).transform.parent.parent;
				if ((Object)(object)parent != (Object)null && parent.childCount > 8)
				{
					((Component)parent.GetChild(8)).gameObject.SetActive(true);
				}
			}
			catch
			{
			}
		}
	}

	[HarmonyPatch(typeof(CharacterSelectBox), "OnEnterSelect")]
	public class DesummonColorPicker
	{
		private static void Prefix(CharacterSelectBox __instance)
		{
			if (((Component)__instance).transform.childCount > 8)
			{
				((Component)((Component)__instance).transform.GetChild(8)).gameObject.SetActive(false);
			}
		}
	}

	[HarmonyPatch(typeof(SelectColor), "Move")]
	public class DisableColorMove
	{
		private static bool Prefix()
		{
			return false;
		}
	}

	[HarmonyPatch(typeof(CharacterSelectBox), "Move")]
	public class SkipColor
	{
		private static void Prefix(CharacterSelectBox __instance, ref int movement)
		{
			try
			{
				if ((int.Parse(Traverse.Create((object)__instance).Field("selectedIndex").GetValue()
					.ToString()) + movement + __instance.selectables.Count) % __instance.selectables.Count == 5)
				{
					movement *= 2;
				}
			}
			catch
			{
			}
		}
	}

	[HarmonyPatch(typeof(CharacterSelectBox), "Update")]
	public class GamepadIntegration
	{
		private static void Prefix(CharacterSelectBox __instance)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.currentGamePad == null)
			{
				return;
			}
			Gamepad currentGamePad = __instance.currentGamePad;
			try
			{
				int num = int.Parse(((Object)__instance).name[((Object)__instance).name.Length - 1].ToString()) - 1;
				if (num < 0 || num >= Plugin.colorPickers.Length)
				{
					return;
				}
				ColorPickerController colorPickerController = Plugin.colorPickers[num];
				if (!((Object)(object)colorPickerController == (Object)null) && ((Behaviour)colorPickerController).isActiveAndEnabled)
				{
					Vector2 direction = ((InputControl<Vector2>)(object)currentGamePad.rightStick).ReadValue();
					direction.y = 0f;
					colorPickerController.MoveMarker(((InputControl<Vector2>)(object)currentGamePad.leftStick).ReadValue(), isBoxMarker: true);
					colorPickerController.MoveMarker(direction, isBoxMarker: false);
					if (currentGamePad.yButton.wasPressedThisFrame && (Object)(object)Plugin.randomButtons[num] != (Object)null)
					{
						Plugin.randomButtons[num].Press();
					}
				}
			}
			catch
			{
			}
		}
	}

	[HarmonyPatch(typeof(CharacterSelectBox), "SetSelected")]
	public class DisableColorArrows
	{
		private static void Postfix(CharacterSelectBox __instance, int index)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (index == 5 && (Object)(object)__instance.arrows != (Object)null)
			{
				__instance.arrows.anchoredPosition = new Vector2(0f, -1000f);
			}
		}
	}

	[HarmonyPatch(typeof(SlimeController), "Spawn")]
	public class ApplyColorOnSpawn
	{
		[HarmonyPostfix]
		public static void Postfix(SlimeController __instance)
		{
			ApplyCustomColor(__instance);
		}
	}

	[HarmonyPatch(typeof(PlayerCollision), "SpawnClone")]
	public class ApplyColorOnCloneSpawn
	{
		[HarmonyPostfix]
		public static void Postfix(SlimeController __result)
		{
			ApplyCustomColor(__result);
		}
	}

	[HarmonyPatch(typeof(PlayerCollision), "SpawnAbilityLessClone")]
	public class ApplyColorOnAbilitylessCloneSpawn
	{
		[HarmonyPostfix]
		public static void Postfix(SlimeController __result)
		{
			ApplyCustomColor(__result);
		}
	}

	[HarmonyPatch(typeof(Player), "set_Color")]
	public class InterceptPlayerColorAssignment
	{
		private static readonly Material[] _lastAppliedClone = (Material[])(object)new Material[4];

		[HarmonyPostfix]
		public static void Postfix(Player __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int num = __instance.Id - 1;
				if (num >= 0 && num < 4 && !(Plugin.playerColors[num] == Color.clear))
				{
					Material color = __instance.Color;
					if (!((Object)(object)color == (Object)null) && !((Object)(object)color == (Object)(object)_lastAppliedClone[num]))
					{
						Color val = (Plugin.playerRandoms[num] ? Random.ColorHSV() : Plugin.playerColors[num]);
						Material val2 = new Material(color);
						val2.SetColor("_ShadowColor", val);
						_lastAppliedClone[num] = val2;
						__instance.Color = val2;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.logger.LogError((object)("Player Color Intercept Exception: " + ex.Message));
			}
		}
	}

	private const string ShadowColorProperty = "_ShadowColor";

	private static void ApplyCustomColor(SlimeController slime)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: 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_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if ((Object)(object)slime == (Object)null)
			{
				return;
			}
			int num = slime.GetPlayerId() - 1;
			if (num >= 0 && num < 4 && !(Plugin.playerColors[num] == Color.clear))
			{
				SpriteRenderer playerSprite = slime.GetPlayerSprite();
				if (!((Object)(object)playerSprite == (Object)null) && !((Object)(object)((Renderer)playerSprite).material == (Object)null))
				{
					Color val = (Plugin.playerRandoms[num] ? Random.ColorHSV() : Plugin.playerColors[num]);
					((Renderer)playerSprite).material.SetColor("_ShadowColor", val);
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.logger.LogError((object)("Simulation Color Render Exception: " + ex.Message));
		}
	}
}
[BepInPlugin("com.thepro.CustomLocalColors", "Custom Local Colors", "1.1.0")]
[BepInProcess("BoplBattle.exe")]
public class Plugin : BaseUnityPlugin
{
	public static ColorPickerController[] colorPickers = new ColorPickerController[4];

	public static RandomButton[] randomButtons = new RandomButton[4];

	public static Image[] characterSelectOlds = (Image[])(object)new Image[4];

	public static Color[] playerColors = (Color[])(object)new Color[4]
	{
		Color.clear,
		Color.clear,
		Color.clear,
		Color.clear
	};

	public static bool[] playerRandoms = new bool[4];

	internal static Harmony harmony;

	internal static ManualLogSource logger;

	internal static ConfigFile config;

	internal static Sprite satVal;

	internal static Sprite huePicker;

	internal static Sprite marker;

	internal static Sprite characterSelectBody;

	internal static Sprite characterSelectFrame;

	internal static Sprite randomOn;

	internal static Sprite randomOff;

	internal static Sprite grayscaleHueRange;

	private void Awake()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
		logger = ((BaseUnityPlugin)this).Logger;
		config = ((BaseUnityPlugin)this).Config;
		harmony.PatchAll();
		SceneManager.sceneLoaded += SceneManager_sceneLoaded;
		satVal = Utils.LoadSprite("satval.png");
		huePicker = Utils.LoadSprite("huepicker.png");
		marker = Utils.LoadSprite("marker.png");
		characterSelectBody = Utils.LoadSprite("characterSelectBody.png");
		characterSelectFrame = Utils.LoadSprite("characterSelectFrame.png");
		randomOn = Utils.LoadSprite("randomOn.png");
		randomOff = Utils.LoadSprite("randomOff.png");
		grayscaleHueRange = Utils.LoadSprite("grayscaleHueRange.png");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin UI Assets fully initialized!");
	}

	private void Update()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < colorPickers.Length; i++)
		{
			ColorPickerController colorPickerController = colorPickers[i];
			if ((Object)(object)colorPickerController == (Object)null || !((Component)colorPickerController).gameObject.activeSelf)
			{
				continue;
			}
			playerColors[i] = colorPickerController.GetColor();
			if ((Object)(object)characterSelectOlds[i] != (Object)null)
			{
				((Graphic)characterSelectOlds[i]).color = playerColors[i];
				if ((Object)(object)((Graphic)characterSelectOlds[i]).material != (Object)null)
				{
					((Graphic)characterSelectOlds[i]).material = null;
				}
			}
			RandomButton randomButton = randomButtons[i];
			if ((Object)(object)randomButton != (Object)null)
			{
				playerRandoms[i] = randomButton.random;
				colorPickerController.isEnabled = !randomButton.random;
			}
		}
	}

	private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		if (((Scene)(ref arg0)).name != "CharacterSelect")
		{
			return;
		}
		for (int i = 0; i < colorPickers.Length; i++)
		{
			try
			{
				int num = 150;
				GameObject val = GameObject.Find("Rectangle" + (i + 1));
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				colorPickers[i] = Prefabs.ColorPicker("Color Picker" + (i + 1), Vector2.zero, num, val.transform).GetComponent<ColorPickerController>();
				if (playerColors[i] != Color.clear)
				{
					colorPickers[i].SetMarkersToColor(playerColors[i]);
				}
				((Component)colorPickers[i]).gameObject.SetActive(false);
				randomButtons[i] = Prefabs.RandomButton(Vector2.up * (float)num * 0.9f, ((Component)colorPickers[i]).transform, playerRandoms[i]);
				if (val.transform.childCount > 4)
				{
					Transform child = val.transform.GetChild(4);
					if (child.childCount > 0)
					{
						characterSelectOlds[i] = ((Component)child.GetChild(0)).GetComponent<Image>();
						characterSelectOlds[i].sprite = characterSelectBody;
						((Graphic)characterSelectOlds[i]).material = null;
						Image component = Object.Instantiate<GameObject>(((Component)characterSelectOlds[i]).gameObject, ((Component)characterSelectOlds[i]).transform.parent).GetComponent<Image>();
						component.sprite = characterSelectFrame;
						((Component)component).transform.localPosition = Vector2.op_Implicit(new Vector2(-47.1f, -96.4f));
					}
				}
			}
			catch (Exception ex)
			{
				logger.LogError((object)("UI Loading Exception: " + ex.Message));
			}
		}
	}
}
internal class Prefabs
{
	public static GameObject ColorPicker(string name, Vector2 position, int size = 300, Transform parent = null)
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Expected O, but got Unknown
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Expected O, but got Unknown
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		EnsureEventSystemExists();
		if ((Object)(object)parent == (Object)null)
		{
			Canvas val = Object.FindObjectOfType<Canvas>();
			if (!((Object)(object)val != (Object)null))
			{
				Debug.LogError((object)"No Canvas found in the scene.");
				return null;
			}
			parent = ((Component)val).transform;
		}
		GameObject val2 = new GameObject(name, new Type[2]
		{
			typeof(RectTransform),
			typeof(ColorPickerController)
		});
		val2.transform.SetParent(parent);
		val2.layer = LayerMask.NameToLayer("UI");
		((Transform)val2.GetComponent<RectTransform>()).localPosition = Vector2.op_Implicit(position);
		val2.GetComponent<ColorPickerController>().size = size;
		GameObject val3 = new GameObject("Hue Box", new Type[3]
		{
			typeof(RectTransform),
			typeof(CanvasRenderer),
			typeof(Image)
		});
		val3.transform.SetParent(val2.transform);
		((Transform)val3.GetComponent<RectTransform>()).localPosition = Vector2.op_Implicit(Vector2.zero);
		GameObject val4 = new GameObject("Saturation + Value", new Type[3]
		{
			typeof(RectTransform),
			typeof(CanvasRenderer),
			typeof(Image)
		});
		val4.transform.SetParent(val2.transform);
		((Transform)val4.GetComponent<RectTransform>()).localPosition = Vector2.op_Implicit(Vector2.zero);
		val4.GetComponent<Image>().sprite = Plugin.satVal;
		GameObject val5 = new GameObject("Hue Picker", new Type[3]
		{
			typeof(RectTransform),
			typeof(CanvasRenderer),
			typeof(Image)
		});
		val5.transform.SetParent(val2.transform);
		((Transform)val5.GetComponent<RectTransform>()).localPosition = Vector2.op_Implicit(Vector2.zero);
		val5.GetComponent<Image>().sprite = Plugin.huePicker;
		GameObject val6 = new GameObject("Box Marker", new Type[3]
		{
			typeof(RectTransform),
			typeof(CanvasRenderer),
			typeof(Image)
		});
		val6.transform.SetParent(val2.transform);
		val6.layer = LayerMask.NameToLayer("UI");
		val6.GetComponent<RectTransform>().sizeDelta = Vector2.one * 12f;
		((Transform)val6.GetComponent<RectTransform>()).localPosition = Vector2.op_Implicit(Vector2.zero);
		val6.GetComponent<Image>().sprite = Plugin.marker;
		GameObject val7 = new GameObject("Range Marker", new Type[3]
		{
			typeof(RectTransform),
			typeof(CanvasRenderer),
			typeof(Image)
		});
		val7.transform.SetParent(val2.transform);
		val7.layer = LayerMask.NameToLayer("UI");
		val7.GetComponent<RectTransform>().sizeDelta = Vector2.one * 6f;
		((Transform)val7.GetComponent<RectTransform>()).localPosition = Vector2.op_Implicit(Vector2.up * (float)(-size) * 0.55f);
		val7.GetComponent<Image>().sprite = Plugin.marker;
		val2.GetComponent<ColorPickerController>().boxMarker = val6.GetComponent<RectTransform>();
		val2.GetComponent<ColorPickerController>().rangeMarker = val7.GetComponent<RectTransform>();
		val2.GetComponent<ColorPickerController>().grayscaleHueRange = Plugin.grayscaleHueRange;
		return val2;
	}

	public static GameObject Sprite(string name, Vector2 position, Vector2 size, Sprite sprite, Transform parent = null)
	{
		//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_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Expected O, but got Unknown
		EnsureEventSystemExists();
		if ((Object)(object)parent == (Object)null)
		{
			Canvas val = Object.FindObjectOfType<Canvas>();
			if (!((Object)(object)val != (Object)null))
			{
				Debug.LogError((object)"No Canvas found in the scene.");
				return null;
			}
			parent = ((Component)val).transform;
		}
		GameObject val2 = new GameObject(name, new Type[3]
		{
			typeof(RectTransform),
			typeof(CanvasRenderer),
			typeof(Image)
		});
		val2.transform.SetParent(parent);
		val2.layer = LayerMask.NameToLayer("UI");
		((Transform)val2.GetComponent<RectTransform>()).localPosition = Vector2.op_Implicit(position);
		val2.GetComponent<RectTransform>().sizeDelta = size;
		val2.GetComponent<Image>().sprite = sprite;
		return val2;
	}

	public static RandomButton RandomButton(Vector2 position, Transform parent, bool random = false)
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		RandomButton component = new GameObject("Random Button", new Type[4]
		{
			typeof(RectTransform),
			typeof(CanvasRenderer),
			typeof(Image),
			typeof(RandomButton)
		}).GetComponent<RandomButton>();
		component.random = random;
		component.on = Plugin.randomOn;
		component.off = Plugin.randomOff;
		((Component)component).transform.parent = parent;
		((Component)component).transform.localPosition = Vector2.op_Implicit(position);
		((Component)component).transform.localScale = Vector2.op_Implicit(Vector2.one * 0.8f);
		((Component)component).GetComponent<Image>().sprite = (random ? Plugin.randomOn : Plugin.randomOff);
		return component;
	}

	private static void EnsureEventSystemExists()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Object.FindObjectOfType<EventSystem>() == (Object)null)
		{
			new GameObject("EventSystem", new Type[2]
			{
				typeof(EventSystem),
				typeof(StandaloneInputModule)
			});
		}
	}
}
public static class Utils
{
	public static Sprite LoadSprite(string filename)
	{
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string name) => name.EndsWith(filename, StringComparison.OrdinalIgnoreCase));
			if (string.IsNullOrEmpty(text))
			{
				Plugin.logger.LogError((object)("Could not locate embedded asset matching filename: '" + filename + "'"));
				return null;
			}
			using Stream stream = executingAssembly.GetManifestResourceStream(text);
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (ImageConversion.LoadImage(val, array))
			{
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
		}
		catch (Exception ex)
		{
			Plugin.logger.LogError((object)("Utils.LoadSprite Exception on '" + filename + "': " + ex.Message));
		}
		return null;
	}
}