Decompiled source of CustomLocalColors v1.0.0

CustomColors2.dll

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.IO;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("CustomColors2")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CustomColors2")]
[assembly: AssemblyTitle("CustomColors2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
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_0069: 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_007a: 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_0097: 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)
		//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_00e6: 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_002d: 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)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: 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_01ec: 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_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: 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_0121: 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_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Unknown result type (might be due to invalid IL or missing references)
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_0365: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0371: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: 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)
		//IL_0408: 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_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: 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_0026: 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)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: 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_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: 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_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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: 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)
		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 = false;

	public Sprite on;

	public Sprite off;

	private Vector2 originalSize;

	private void Start()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: 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_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: 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_0008: 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)
			{
				((Component)((Component)__instance).transform.parent.parent.GetChild(8)).gameObject.SetActive(true);
			}
		}

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

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

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

		[HarmonyPatch(typeof(CharacterSelectBox), "Update")]
		public class GamepadIntegration
		{
			private static void Prefix(CharacterSelectBox __instance)
			{
				//IL_0070: 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_0089: 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)
				if (__instance.currentGamePad == null)
				{
					return;
				}
				Gamepad currentGamePad = __instance.currentGamePad;
				int num = int.Parse(((Object)__instance).name[((Object)__instance).name.Length - 1].ToString()) - 1;
				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)
					{
						Plugin.randomButtons[num].Press();
					}
				}
			}
		}

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

		[HarmonyPatch(typeof(GameSessionHandler), "SpawnPlayers")]
		public class SpawnColors
		{
			private static void Prefix(GameSessionHandler __instance)
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				for (int i = 0; i < 4; i++)
				{
					Player player = PlayerHandler.Get().GetPlayer(i + 1);
					if (player != null)
					{
						Color val = (Plugin.playerRandoms[i] ? Random.ColorHSV() : Plugin.playerColors[i]);
						player.Color.SetColor("_ShadowColor", val);
					}
				}
			}
		}
	}
	[BepInPlugin("com.thepro.CustomLocalColors", "Custom Local Colors", "1.0.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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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("CustomLocalColors.satval.png");
			huePicker = Utils.LoadSprite("CustomLocalColors.huepicker.png");
			marker = Utils.LoadSprite("CustomLocalColors.marker.png");
			characterSelectBody = Utils.LoadSprite("CustomLocalColors.characterSelectBody.png");
			characterSelectFrame = Utils.LoadSprite("CustomLocalColors.characterSelectFrame.png");
			randomOn = Utils.LoadSprite("CustomLocalColors.randomOn.png");
			randomOff = Utils.LoadSprite("CustomLocalColors.randomOff.png");
			grayscaleHueRange = Utils.LoadSprite("CustomLocalColors.grayscaleHueRange.png");
		}

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

		private void SceneManager_sceneLoaded(Scene arg0, LoadSceneMode arg1)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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++)
			{
				int num = 150;
				GameObject val = GameObject.Find("Rectangle" + (i + 1));
				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]);
				characterSelectOlds[i] = ((Component)val.transform.GetChild(4).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));
			}
		}
	}
	internal class Prefabs
	{
		public static GameObject ColorPicker(string name, Vector2 position, int size = 300, Transform parent = null)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0097: 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)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01d0: 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_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected O, but got Unknown
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Expected O, but got Unknown
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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[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_0040: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_009c: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			EventSystem val = Object.FindObjectOfType<EventSystem>();
			if ((Object)(object)val == (Object)null)
			{
				GameObject val2 = new GameObject("EventSystem", new Type[2]
				{
					typeof(EventSystem),
					typeof(StandaloneInputModule)
				});
			}
		}
	}
	internal class Utils
	{
		public static Texture2D LoadDLLTexture(string path)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path);
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			Texture2D val = new Texture2D(256, 256);
			ImageConversion.LoadImage(val, array);
			return val;
		}

		public static Sprite LoadSprite(string path)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val2;
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path))
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				Texture2D val = new Texture2D(256, 256);
				ImageConversion.LoadImage(val, array);
				val2 = val;
			}
			return Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 45f);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CustomColors2";

		public const string PLUGIN_NAME = "CustomColors2";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}