Decompiled source of SkinColorSliders v1.5.0

SkinColorSliders/SkinColorSliders.dll

Decompiled a month ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using HSVPicker;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Photon.Pun;
using Photon.Realtime;
using PhotonCustomPropsUtils;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SkinColorSliders")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyInformationalVersion("1.5.0+b2d0e7e1863e404a8ec899a9086ff36892a54c90")]
[assembly: AssemblyProduct("SkinColorSliders")]
[assembly: AssemblyTitle("SkinColorSliders")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
[Serializable]
public class ColorChangedEvent : UnityEvent<Color>
{
}
public enum ColorValues
{
	R,
	G,
	B,
	A,
	Hue,
	Saturation,
	Value
}
public class HSVChangedEvent : UnityEvent<float, float, float>
{
}
public class SliderOnChangeEndEvent : UnityEvent<float>
{
}
namespace HSVPicker
{
	[AddComponentMenu("UI/BoxSlider", 35)]
	[RequireComponent(typeof(RectTransform))]
	public class BoxSlider : Selectable, IDragHandler, IEventSystemHandler, IInitializePotentialDragHandler, ICanvasElement
	{
		public enum Direction
		{
			LeftToRight,
			RightToLeft,
			BottomToTop,
			TopToBottom
		}

		[Serializable]
		public class BoxSliderEvent : UnityEvent<float, float>
		{
		}

		private enum Axis
		{
			Horizontal,
			Vertical
		}

		[SerializeField]
		private RectTransform m_HandleRect;

		[Space(6f)]
		[SerializeField]
		private float m_MinValue = 0f;

		[SerializeField]
		private float m_MaxValue = 1f;

		[SerializeField]
		private bool m_WholeNumbers = false;

		[SerializeField]
		private float m_Value = 1f;

		[SerializeField]
		private float m_ValueY = 1f;

		[Space(6f)]
		[SerializeField]
		private BoxSliderEvent m_OnValueChanged = new BoxSliderEvent();

		private Transform m_HandleTransform;

		private RectTransform m_HandleContainerRect;

		private Vector2 m_Offset = Vector2.zero;

		private DrivenRectTransformTracker m_Tracker;

		public RectTransform handleRect
		{
			get
			{
				return m_HandleRect;
			}
			set
			{
				if (SetClass(ref m_HandleRect, value))
				{
					UpdateCachedReferences();
					UpdateVisuals();
				}
			}
		}

		public float minValue
		{
			get
			{
				return m_MinValue;
			}
			set
			{
				if (SetStruct(ref m_MinValue, value))
				{
					Set(m_Value);
					SetY(m_ValueY);
					UpdateVisuals();
				}
			}
		}

		public float maxValue
		{
			get
			{
				return m_MaxValue;
			}
			set
			{
				if (SetStruct(ref m_MaxValue, value))
				{
					Set(m_Value);
					SetY(m_ValueY);
					UpdateVisuals();
				}
			}
		}

		public bool wholeNumbers
		{
			get
			{
				return m_WholeNumbers;
			}
			set
			{
				if (SetStruct(ref m_WholeNumbers, value))
				{
					Set(m_Value);
					SetY(m_ValueY);
					UpdateVisuals();
				}
			}
		}

		public float value
		{
			get
			{
				if (wholeNumbers)
				{
					return Mathf.Round(m_Value);
				}
				return m_Value;
			}
			set
			{
				Set(value);
			}
		}

		public float normalizedValue
		{
			get
			{
				if (Mathf.Approximately(minValue, maxValue))
				{
					return 0f;
				}
				return Mathf.InverseLerp(minValue, maxValue, value);
			}
			set
			{
				this.value = Mathf.Lerp(minValue, maxValue, value);
			}
		}

		public float valueY
		{
			get
			{
				if (wholeNumbers)
				{
					return Mathf.Round(m_ValueY);
				}
				return m_ValueY;
			}
			set
			{
				SetY(value);
			}
		}

		public float normalizedValueY
		{
			get
			{
				if (Mathf.Approximately(minValue, maxValue))
				{
					return 0f;
				}
				return Mathf.InverseLerp(minValue, maxValue, valueY);
			}
			set
			{
				valueY = Mathf.Lerp(minValue, maxValue, value);
			}
		}

		public BoxSliderEvent onValueChanged
		{
			get
			{
				return m_OnValueChanged;
			}
			set
			{
				m_OnValueChanged = value;
			}
		}

		private float stepSize => wholeNumbers ? 1f : ((maxValue - minValue) * 0.1f);

		protected BoxSlider()
		{
		}//IL_003f: 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)


		public virtual void Rebuild(CanvasUpdate executing)
		{
		}

		public void LayoutComplete()
		{
		}

		public void GraphicUpdateComplete()
		{
		}

		public static bool SetClass<T>(ref T currentValue, T newValue) where T : class
		{
			if ((currentValue == null && newValue == null) || (currentValue != null && currentValue.Equals(newValue)))
			{
				return false;
			}
			currentValue = newValue;
			return true;
		}

		public static bool SetStruct<T>(ref T currentValue, T newValue) where T : struct
		{
			if (currentValue.Equals(newValue))
			{
				return false;
			}
			currentValue = newValue;
			return true;
		}

		protected override void OnEnable()
		{
			((Selectable)this).OnEnable();
			UpdateCachedReferences();
			Set(m_Value, sendCallback: false);
			SetY(m_ValueY, sendCallback: false);
			UpdateVisuals();
		}

		protected override void OnDisable()
		{
			((DrivenRectTransformTracker)(ref m_Tracker)).Clear();
			((Selectable)this).OnDisable();
		}

		private void UpdateCachedReferences()
		{
			if (Object.op_Implicit((Object)(object)m_HandleRect))
			{
				m_HandleTransform = ((Component)m_HandleRect).transform;
				if ((Object)(object)m_HandleTransform.parent != (Object)null)
				{
					m_HandleContainerRect = ((Component)m_HandleTransform.parent).GetComponent<RectTransform>();
				}
			}
			else
			{
				m_HandleContainerRect = null;
			}
		}

		private void Set(float input)
		{
			Set(input, sendCallback: true);
		}

		private void Set(float input, bool sendCallback)
		{
			float num = Mathf.Clamp(input, minValue, maxValue);
			if (wholeNumbers)
			{
				num = Mathf.Round(num);
			}
			if (!m_Value.Equals(num))
			{
				m_Value = num;
				UpdateVisuals();
				if (sendCallback)
				{
					((UnityEvent<float, float>)m_OnValueChanged).Invoke(num, valueY);
				}
			}
		}

		private void SetY(float input)
		{
			SetY(input, sendCallback: true);
		}

		private void SetY(float input, bool sendCallback)
		{
			float num = Mathf.Clamp(input, minValue, maxValue);
			if (wholeNumbers)
			{
				num = Mathf.Round(num);
			}
			if (!m_ValueY.Equals(num))
			{
				m_ValueY = num;
				UpdateVisuals();
				if (sendCallback)
				{
					((UnityEvent<float, float>)m_OnValueChanged).Invoke(value, num);
				}
			}
		}

		protected override void OnRectTransformDimensionsChange()
		{
			((UIBehaviour)this).OnRectTransformDimensionsChange();
			UpdateVisuals();
		}

		private void UpdateVisuals()
		{
			//IL_0036: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			((DrivenRectTransformTracker)(ref m_Tracker)).Clear();
			if ((Object)(object)m_HandleContainerRect != (Object)null)
			{
				((DrivenRectTransformTracker)(ref m_Tracker)).Add((Object)(object)this, m_HandleRect, (DrivenTransformProperties)3840);
				Vector2 zero = Vector2.zero;
				Vector2 one = Vector2.one;
				float num2 = (((Vector2)(ref one))[0] = normalizedValue);
				((Vector2)(ref zero))[0] = num2;
				num2 = (((Vector2)(ref one))[1] = normalizedValueY);
				((Vector2)(ref zero))[1] = num2;
				m_HandleRect.anchorMin = zero;
				m_HandleRect.anchorMax = one;
			}
		}

		private void UpdateDrag(PointerEventData eventData, Camera cam)
		{
			//IL_0012: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_005f: 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_006c: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_0085: 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_008d: 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_00ac: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			RectTransform handleContainerRect = m_HandleContainerRect;
			if ((Object)(object)handleContainerRect != (Object)null)
			{
				Rect rect = handleContainerRect.rect;
				Vector2 val = ((Rect)(ref rect)).size;
				Vector2 val2 = default(Vector2);
				if (((Vector2)(ref val))[0] > 0f && RectTransformUtility.ScreenPointToLocalPointInRectangle(handleContainerRect, eventData.position, cam, ref val2))
				{
					Vector2 val3 = val2;
					rect = handleContainerRect.rect;
					val2 = val3 - ((Rect)(ref rect)).position;
					val = val2 - m_Offset;
					float num = ((Vector2)(ref val))[0];
					rect = handleContainerRect.rect;
					val = ((Rect)(ref rect)).size;
					float num2 = Mathf.Clamp01(num / ((Vector2)(ref val))[0]);
					normalizedValue = num2;
					val = val2 - m_Offset;
					float num3 = ((Vector2)(ref val))[1];
					rect = handleContainerRect.rect;
					val = ((Rect)(ref rect)).size;
					float num4 = Mathf.Clamp01(num3 / ((Vector2)(ref val))[1]);
					normalizedValueY = num4;
				}
			}
		}

		private bool MayDrag(PointerEventData eventData)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			return ((UIBehaviour)this).IsActive() && ((Selectable)this).IsInteractable() && (int)eventData.button == 0;
		}

		public override void OnPointerDown(PointerEventData eventData)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			if (!MayDrag(eventData))
			{
				return;
			}
			((Selectable)this).OnPointerDown(eventData);
			m_Offset = Vector2.zero;
			if ((Object)(object)m_HandleContainerRect != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(m_HandleRect, eventData.position, eventData.enterEventCamera))
			{
				Vector2 offset = default(Vector2);
				if (RectTransformUtility.ScreenPointToLocalPointInRectangle(m_HandleRect, eventData.position, eventData.pressEventCamera, ref offset))
				{
					m_Offset = offset;
				}
				m_Offset.y = 0f - m_Offset.y;
			}
			else
			{
				UpdateDrag(eventData, eventData.pressEventCamera);
			}
		}

		public virtual void OnDrag(PointerEventData eventData)
		{
			if (MayDrag(eventData))
			{
				UpdateDrag(eventData, eventData.pressEventCamera);
			}
		}

		public virtual void OnInitializePotentialDrag(PointerEventData eventData)
		{
			eventData.useDragThreshold = false;
		}

		Transform ICanvasElement.get_transform()
		{
			return ((Component)this).transform;
		}
	}
	[RequireComponent(typeof(Image))]
	public class ColorImage : MonoBehaviour
	{
		public ColorPicker picker;

		private Image image;

		private void Awake()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			image = ((Component)this).GetComponent<Image>();
			((UnityEvent<Color>)picker.onValueChanged).AddListener((UnityAction<Color>)ColorChanged);
			ColorChanged(picker.CurrentColor);
		}

		private void OnDestroy()
		{
			((UnityEvent<Color>)picker.onValueChanged).RemoveListener((UnityAction<Color>)ColorChanged);
		}

		private void ColorChanged(Color newColor)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)image).color = newColor;
		}
	}
	[RequireComponent(typeof(TMP_Text))]
	public class ColorLabel : MonoBehaviour
	{
		public ColorPicker picker;

		public ColorValues type;

		public string prefix = "R: ";

		public float minValue = 0f;

		public float maxValue = 255f;

		public int precision = 0;

		[SerializeField]
		[HideInInspector]
		private TMP_Text label;

		private void Awake()
		{
			label = ((Component)this).GetComponent<TMP_Text>();
		}

		private void OnEnable()
		{
			if (Application.isPlaying && (Object)(object)picker != (Object)null)
			{
				((UnityEvent<Color>)picker.onValueChanged).AddListener((UnityAction<Color>)ColorChanged);
				((UnityEvent<float, float, float>)picker.onHSVChanged).AddListener((UnityAction<float, float, float>)HSVChanged);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)picker != (Object)null)
			{
				((UnityEvent<Color>)picker.onValueChanged).RemoveListener((UnityAction<Color>)ColorChanged);
				((UnityEvent<float, float, float>)picker.onHSVChanged).RemoveListener((UnityAction<float, float, float>)HSVChanged);
			}
		}

		private void ColorChanged(Color color)
		{
			UpdateValue();
		}

		private void HSVChanged(float hue, float sateration, float value)
		{
			UpdateValue();
		}

		private void UpdateValue()
		{
			if (!((Object)(object)label == (Object)null))
			{
				if ((Object)(object)picker == (Object)null)
				{
					label.text = prefix + "-";
					return;
				}
				float value = minValue + picker.GetValue(type) * (maxValue - minValue);
				label.text = prefix + ConvertToDisplayString(value);
			}
		}

		private string ConvertToDisplayString(float value)
		{
			if (precision > 0)
			{
				return value.ToString("f " + precision);
			}
			return Mathf.FloorToInt(value).ToString();
		}
	}
	[DefaultExecutionOrder(0)]
	public class ColorPicker : MonoBehaviour
	{
		private float _hue = 0f;

		private float _saturation = 0f;

		private float _brightness = 0f;

		[SerializeField]
		private Color _color = Color.red;

		[Header("Setup")]
		public ColorPickerSetup Setup;

		[Header("Event")]
		public ColorChangedEvent onValueChanged = new ColorChangedEvent();

		public HSVChangedEvent onHSVChanged = new HSVChangedEvent();

		public Color CurrentColor
		{
			get
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				return _color;
			}
			set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: 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)
				if (!(CurrentColor == value))
				{
					_color = value;
					RGBChanged();
					SendChangedEvent();
				}
			}
		}

		public float H
		{
			get
			{
				return _hue;
			}
			set
			{
				if (_hue != value)
				{
					_hue = value;
					HSVChanged();
					SendChangedEvent();
				}
			}
		}

		public float S
		{
			get
			{
				return _saturation;
			}
			set
			{
				if (_saturation != value)
				{
					_saturation = value;
					HSVChanged();
					SendChangedEvent();
				}
			}
		}

		public float V
		{
			get
			{
				return _brightness;
			}
			set
			{
				if (_brightness != value)
				{
					_brightness = value;
					HSVChanged();
					SendChangedEvent();
				}
			}
		}

		public float R
		{
			get
			{
				return _color.r;
			}
			set
			{
				if (_color.r != value)
				{
					_color.r = value;
					RGBChanged();
					SendChangedEvent();
				}
			}
		}

		public float G
		{
			get
			{
				return _color.g;
			}
			set
			{
				if (_color.g != value)
				{
					_color.g = value;
					RGBChanged();
					SendChangedEvent();
				}
			}
		}

		public float B
		{
			get
			{
				return _color.b;
			}
			set
			{
				if (_color.b != value)
				{
					_color.b = value;
					RGBChanged();
					SendChangedEvent();
				}
			}
		}

		private float A
		{
			get
			{
				return _color.a;
			}
			set
			{
				if (_color.a != value)
				{
					_color.a = value;
					SendChangedEvent();
				}
			}
		}

		private void Awake()
		{
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"[ColorPicker] Awake start");
			Transform val = ((Component)this).transform.Find("Sliders/R");
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: Sliders/R");
			}
			Transform val2 = ((Component)this).transform.Find("Sliders/G");
			if ((Object)(object)val2 == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: Sliders/G");
			}
			Transform val3 = ((Component)this).transform.Find("Sliders/B");
			if ((Object)(object)val3 == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: Sliders/B");
			}
			RectTransform[] elements = (RectTransform[])(object)new RectTransform[3]
			{
				(RectTransform)/*isinst with value type is only supported in some contexts*/,
				(RectTransform)/*isinst with value type is only supported in some contexts*/,
				(RectTransform)/*isinst with value type is only supported in some contexts*/
			};
			ColorPickerSetup.UiElements rgbSliders = new ColorPickerSetup.UiElements
			{
				Elements = elements
			};
			Transform val4 = ((Component)this).transform.Find("Sliders/H");
			if ((Object)(object)val4 == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: Sliders/H");
			}
			Transform val5 = ((Component)this).transform.Find("Sliders/S");
			if ((Object)(object)val5 == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: Sliders/S");
			}
			Transform val6 = ((Component)this).transform.Find("Sliders/V");
			if ((Object)(object)val6 == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: Sliders/V");
			}
			RectTransform[] elements2 = (RectTransform[])(object)new RectTransform[3]
			{
				(RectTransform)/*isinst with value type is only supported in some contexts*/,
				(RectTransform)/*isinst with value type is only supported in some contexts*/,
				(RectTransform)/*isinst with value type is only supported in some contexts*/
			};
			ColorPickerSetup.UiElements hsvSliders = new ColorPickerSetup.UiElements
			{
				Elements = elements2
			};
			Transform val7 = ((Component)this).transform.Find("Sliders/Toggle");
			if ((Object)(object)val7 == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: Sliders/Toggle");
			}
			RectTransform[] elements3 = (RectTransform[])(object)new RectTransform[1] { (RectTransform)/*isinst with value type is only supported in some contexts*/ };
			ColorPickerSetup.UiElements uiElements = new ColorPickerSetup.UiElements
			{
				Elements = elements3
			};
			Transform val8 = ((Component)this).transform.Find("ColorField");
			if ((Object)(object)val8 == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: ColorField");
			}
			RectTransform[] elements4 = (RectTransform[])(object)new RectTransform[1] { (RectTransform)/*isinst with value type is only supported in some contexts*/ };
			ColorPickerSetup.UiElements uiElements2 = new ColorPickerSetup.UiElements
			{
				Elements = elements4
			};
			Transform val9 = ((Component)this).transform.Find("ColorField/InputField (TMP)");
			if ((Object)(object)val9 == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: ColorField/InputField (TMP)");
			}
			RectTransform[] elements5 = (RectTransform[])(object)new RectTransform[1] { (RectTransform)/*isinst with value type is only supported in some contexts*/ };
			ColorPickerSetup.UiElements colorCode = new ColorPickerSetup.UiElements
			{
				Elements = elements5
			};
			Transform val10 = ((Component)this).transform.Find("HSVField");
			if ((Object)(object)val10 == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: HSVField");
			}
			RectTransform[] elements6 = (RectTransform[])(object)new RectTransform[1] { (RectTransform)/*isinst with value type is only supported in some contexts*/ };
			ColorPickerSetup.UiElements colorBox = new ColorPickerSetup.UiElements
			{
				Elements = elements6
			};
			Transform val11 = ((Component)this).transform.Find("Sliders/A");
			if ((Object)(object)val11 == (Object)null)
			{
				Debug.LogError((object)"[ColorPicker] Missing transform: Sliders/A");
			}
			RectTransform[] elements7 = (RectTransform[])(object)new RectTransform[1] { (RectTransform)/*isinst with value type is only supported in some contexts*/ };
			ColorPickerSetup.UiElements alphaSlidiers = new ColorPickerSetup.UiElements
			{
				Elements = elements7
			};
			Color[] defaultPresetColors = (Color[])(object)new Color[3]
			{
				Color.red,
				Color.green,
				Color.blue
			};
			Debug.Log((object)"[ColorPicker] Assigning Setup object");
			ColorPickerSetup obj = new ColorPickerSetup
			{
				ShowRgb = true,
				ShowHsv = false,
				ShowAlpha = false,
				ShowColorBox = true,
				ShowColorSliderToggle = true,
				AlphaSlidiers = alphaSlidiers,
				DefaultPresetColors = defaultPresetColors,
				RegenerateOnOpen = false,
				UserCanAddPresets = true,
				ShowHeader = ColorPickerSetup.ColorHeaderShowing.ShowAll,
				RgbSliders = rgbSliders,
				HsvSliders = hsvSliders,
				ColorToggleElement = uiElements
			};
			object sliderToggleButtonText;
			if (uiElements == null)
			{
				sliderToggleButtonText = null;
			}
			else
			{
				RectTransform obj2 = uiElements.Elements[0];
				sliderToggleButtonText = ((obj2 != null) ? ((Component)obj2).GetComponent<TextMeshProUGUI>() : null);
			}
			obj.SliderToggleButtonText = (TMP_Text)sliderToggleButtonText;
			obj.ColorHeader = uiElements2;
			obj.ColorPreview = uiElements2;
			obj.ColorCode = colorCode;
			obj.ColorBox = colorBox;
			obj.PresetColorsId = "default";
			Setup = obj;
			Debug.Log((object)"[ColorPicker] Setup assigned, calling Regenerate");
			Regenerate();
			Debug.Log((object)"[ColorPicker] Awake finished");
		}

		private void OnEnable()
		{
			if (Setup.RegenerateOnOpen)
			{
				Regenerate();
			}
		}

		private void Regenerate()
		{
			Setup.AlphaSlidiers.Toggle(Setup.ShowAlpha);
			Setup.ColorToggleElement.Toggle(Setup.ShowColorSliderToggle);
			Setup.RgbSliders.Toggle(Setup.ShowRgb);
			Setup.HsvSliders.Toggle(Setup.ShowHsv);
			Setup.ColorBox.Toggle(Setup.ShowColorBox);
			HandleHeaderSetting(Setup.ShowHeader);
			UpdateColorToggleText();
			RGBChanged();
		}

		private void RGBChanged()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			HsvColor hsvColor = HSVUtil.ConvertRgbToHsv(CurrentColor);
			_hue = hsvColor.normalizedH;
			_saturation = hsvColor.normalizedS;
			_brightness = hsvColor.normalizedV;
		}

		private void HSVChanged()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			Color color = HSVUtil.ConvertHsvToRgb(_hue * 360f, _saturation, _brightness, _color.a);
			_color = color;
		}

		private void SendChangedEvent()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			((UnityEvent<Color>)onValueChanged).Invoke(CurrentColor);
			((UnityEvent<float, float, float>)onHSVChanged).Invoke(_hue, _saturation, _brightness);
		}

		public void AssignColor(ColorValues type, float value)
		{
			switch (type)
			{
			case ColorValues.R:
				R = value;
				break;
			case ColorValues.G:
				G = value;
				break;
			case ColorValues.B:
				B = value;
				break;
			case ColorValues.A:
				A = value;
				break;
			case ColorValues.Hue:
				H = value;
				break;
			case ColorValues.Saturation:
				S = value;
				break;
			case ColorValues.Value:
				V = value;
				break;
			}
		}

		public void AssignColor(Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			CurrentColor = color;
		}

		public float GetValue(ColorValues type)
		{
			return type switch
			{
				ColorValues.R => R, 
				ColorValues.G => G, 
				ColorValues.B => B, 
				ColorValues.A => A, 
				ColorValues.Hue => H, 
				ColorValues.Saturation => S, 
				ColorValues.Value => V, 
				_ => throw new NotImplementedException(""), 
			};
		}

		public void ToggleColorSliders()
		{
			Setup.ShowHsv = !Setup.ShowHsv;
			Setup.ShowRgb = !Setup.ShowRgb;
			Setup.HsvSliders.Toggle(Setup.ShowHsv);
			Setup.RgbSliders.Toggle(Setup.ShowRgb);
			((UnityEvent<float, float, float>)onHSVChanged).Invoke(_hue, _saturation, _brightness);
			UpdateColorToggleText();
		}

		private void UpdateColorToggleText()
		{
			if (!((Object)(object)Setup.SliderToggleButtonText == (Object)null))
			{
				if (Setup.ShowRgb)
				{
					Setup.SliderToggleButtonText.text = "RGB";
				}
				if (Setup.ShowHsv)
				{
					Setup.SliderToggleButtonText.text = "HSV";
				}
			}
		}

		private void HandleHeaderSetting(ColorPickerSetup.ColorHeaderShowing setupShowHeader)
		{
			if (setupShowHeader == ColorPickerSetup.ColorHeaderShowing.Hide)
			{
				Setup.ColorHeader.Toggle(active: false);
				return;
			}
			Setup.ColorHeader.Toggle(active: true);
			Setup.ColorPreview.Toggle(setupShowHeader != ColorPickerSetup.ColorHeaderShowing.ShowColorCode);
			Setup.ColorCode.Toggle(setupShowHeader != ColorPickerSetup.ColorHeaderShowing.ShowColor);
		}
	}
	[Serializable]
	public class ColorPickerSetup
	{
		public enum ColorHeaderShowing
		{
			Hide,
			ShowColor,
			ShowColorCode,
			ShowAll
		}

		[Serializable]
		public class UiElements
		{
			public RectTransform[] Elements;

			public void Toggle(bool active)
			{
				for (int i = 0; i < Elements.Length; i++)
				{
					((Component)Elements[i]).gameObject.SetActive(active);
				}
			}
		}

		public bool ShowRgb = true;

		public bool ShowHsv;

		public bool ShowAlpha = true;

		public bool ShowColorBox = true;

		public bool ShowColorSliderToggle = true;

		[Tooltip("Re-initialise the colour picker settings every time the picker is made active.")]
		public bool RegenerateOnOpen = false;

		[Tooltip("Enable the user to add presets, up to the maximum preset limit.")]
		public bool UserCanAddPresets = true;

		public ColorHeaderShowing ShowHeader = ColorHeaderShowing.ShowAll;

		public UiElements RgbSliders;

		public UiElements HsvSliders;

		public UiElements ColorToggleElement;

		public UiElements AlphaSlidiers;

		public UiElements ColorHeader;

		public UiElements ColorCode;

		public UiElements ColorPreview;

		public UiElements ColorBox;

		public TMP_Text SliderToggleButtonText;

		public string PresetColorsId = "default";

		public Color[] DefaultPresetColors;
	}
	public static class ColorPresetManager
	{
		private static Dictionary<string, ColorPresetList> _presets = new Dictionary<string, ColorPresetList>();

		public static ColorPresetList Get(string listId = "default")
		{
			if (!_presets.TryGetValue(listId, out ColorPresetList value))
			{
				value = new ColorPresetList(listId);
				_presets.Add(listId, value);
			}
			return value;
		}
	}
	public class ColorPresetList
	{
		[CompilerGenerated]
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private UnityAction<List<Color>> m_OnColorsUpdated;

		public string ListId { get; private set; }

		public List<Color> Colors { get; private set; }

		public event UnityAction<List<Color>> OnColorsUpdated
		{
			[CompilerGenerated]
			add
			{
				UnityAction<List<Color>> val = this.m_OnColorsUpdated;
				UnityAction<List<Color>> val2;
				do
				{
					val2 = val;
					UnityAction<List<Color>> value2 = (UnityAction<List<Color>>)(object)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref this.m_OnColorsUpdated, value2, val2);
				}
				while (val != val2);
			}
			[CompilerGenerated]
			remove
			{
				UnityAction<List<Color>> val = this.m_OnColorsUpdated;
				UnityAction<List<Color>> val2;
				do
				{
					val2 = val;
					UnityAction<List<Color>> value2 = (UnityAction<List<Color>>)(object)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref this.m_OnColorsUpdated, value2, val2);
				}
				while (val != val2);
			}
		}

		public ColorPresetList(string listId, List<Color> colors = null)
		{
			if (colors == null)
			{
				colors = new List<Color>();
			}
			Colors = colors;
			ListId = listId;
		}

		public void AddColor(Color color)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			Colors.Add(color);
			if (this.OnColorsUpdated != null)
			{
				this.OnColorsUpdated.Invoke(Colors);
			}
		}

		public void UpdateList(IEnumerable<Color> colors)
		{
			Colors.Clear();
			Colors.AddRange(colors);
			if (this.OnColorsUpdated != null)
			{
				this.OnColorsUpdated.Invoke(Colors);
			}
		}
	}
	public class ColorPresets : MonoBehaviour
	{
		public ColorPicker picker;

		public GameObject[] presets;

		public Image createPresetImage;

		private ColorPresetList _colors;

		private void Awake()
		{
			((UnityEvent<Color>)picker.onValueChanged).AddListener((UnityAction<Color>)ColorChanged);
		}

		private void Start()
		{
			GenerateDefaultPresetColours();
		}

		private void OnEnable()
		{
			if (picker.Setup.RegenerateOnOpen)
			{
				GenerateDefaultPresetColours();
			}
		}

		private void GenerateDefaultPresetColours()
		{
			List<Color> colors = new List<Color>();
			_colors = ColorPresetManager.Get(picker.Setup.PresetColorsId);
			_colors.UpdateList(colors);
			if (_colors.Colors.Count < picker.Setup.DefaultPresetColors.Length)
			{
				_colors.UpdateList(picker.Setup.DefaultPresetColors);
			}
			_colors.OnColorsUpdated += OnColorsUpdate;
			OnColorsUpdate(_colors.Colors);
		}

		private void OnColorsUpdate(List<Color> colors)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < presets.Length; i++)
			{
				if (colors.Count <= i)
				{
					presets[i].SetActive(false);
					continue;
				}
				presets[i].SetActive(true);
				((Graphic)presets[i].GetComponent<Image>()).color = colors[i];
			}
			((Component)createPresetImage).gameObject.SetActive(colors.Count < presets.Length && picker.Setup.UserCanAddPresets);
		}

		public void CreatePresetButton()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			_colors.AddColor(picker.CurrentColor);
		}

		public void PresetSelect(Image sender)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			picker.CurrentColor = ((Graphic)sender).color;
		}

		private void ColorChanged(Color color)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)createPresetImage).color = color;
		}

		private void OnDestroy()
		{
			((UnityEvent<Color>)picker.onValueChanged).RemoveListener((UnityAction<Color>)ColorChanged);
			_colors.OnColorsUpdated -= OnColorsUpdate;
		}
	}
	[RequireComponent(typeof(Slider))]
	[DefaultExecutionOrder(10)]
	public class ColorSlider : MonoBehaviour, IEndDragHandler, IEventSystemHandler
	{
		public ColorPicker hsvpicker;

		public ColorValues type;

		private Slider slider;

		private bool listen = true;

		[Header("Event")]
		public SliderOnChangeEndEvent onSliderChangeEndEvent = new SliderOnChangeEndEvent();

		private void Awake()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			slider = ((Component)this).GetComponent<Slider>();
			((UnityEvent<Color>)hsvpicker.onValueChanged).AddListener((UnityAction<Color>)ColorChanged);
			((UnityEvent<float, float, float>)hsvpicker.onHSVChanged).AddListener((UnityAction<float, float, float>)HSVChanged);
			((UnityEvent<float>)(object)slider.onValueChanged).AddListener((UnityAction<float>)SliderChanged);
			ColorChanged(hsvpicker.CurrentColor);
			HSVChanged(hsvpicker.H, hsvpicker.S, hsvpicker.V);
		}

		private void OnDestroy()
		{
			((UnityEvent<Color>)hsvpicker.onValueChanged).RemoveListener((UnityAction<Color>)ColorChanged);
			((UnityEvent<float, float, float>)hsvpicker.onHSVChanged).RemoveListener((UnityAction<float, float, float>)HSVChanged);
			((UnityEvent<float>)(object)slider.onValueChanged).RemoveListener((UnityAction<float>)SliderChanged);
		}

		private void ColorChanged(Color newColor)
		{
			//IL_002f: 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_0057: 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)
			listen = false;
			switch (type)
			{
			case ColorValues.R:
				slider.normalizedValue = newColor.r;
				break;
			case ColorValues.G:
				slider.normalizedValue = newColor.g;
				break;
			case ColorValues.B:
				slider.normalizedValue = newColor.b;
				break;
			case ColorValues.A:
				slider.normalizedValue = newColor.a;
				break;
			}
		}

		private void HSVChanged(float hue, float saturation, float value)
		{
			listen = false;
			switch (type)
			{
			case ColorValues.Hue:
				slider.normalizedValue = hue;
				break;
			case ColorValues.Saturation:
				slider.normalizedValue = saturation;
				break;
			case ColorValues.Value:
				slider.normalizedValue = value;
				break;
			}
		}

		private void SliderChanged(float newValue)
		{
			if (listen)
			{
				newValue = slider.normalizedValue;
				hsvpicker.AssignColor(type, newValue);
			}
			listen = true;
		}

		public virtual void OnEndDrag(PointerEventData eventData)
		{
			((UnityEvent<float>)onSliderChangeEndEvent).Invoke(slider.normalizedValue);
		}

		public void SliderClicked(BaseEventData data)
		{
			SliderChanged(slider.value);
		}
	}
	[RequireComponent(typeof(RawImage))]
	[ExecuteInEditMode]
	public class ColorSliderImage : MonoBehaviour
	{
		public ColorPicker picker;

		public ColorValues type;

		public Direction direction;

		private RawImage image;

		private RectTransform rectTransform
		{
			get
			{
				Transform transform = ((Component)this).transform;
				return (RectTransform)(object)((transform is RectTransform) ? transform : null);
			}
		}

		private void Awake()
		{
			image = ((Component)this).GetComponent<RawImage>();
			if (Application.isPlaying)
			{
				RegenerateTexture();
			}
		}

		private void OnEnable()
		{
			if ((Object)(object)picker != (Object)null && Application.isPlaying)
			{
				((UnityEvent<Color>)picker.onValueChanged).AddListener((UnityAction<Color>)ColorChanged);
				((UnityEvent<float, float, float>)picker.onHSVChanged).AddListener((UnityAction<float, float, float>)HSVChanged);
			}
		}

		private void OnDisable()
		{
			if ((Object)(object)picker != (Object)null)
			{
				((UnityEvent<Color>)picker.onValueChanged).RemoveListener((UnityAction<Color>)ColorChanged);
				((UnityEvent<float, float, float>)picker.onHSVChanged).RemoveListener((UnityAction<float, float, float>)HSVChanged);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)image.texture != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)image.texture);
			}
		}

		private void ColorChanged(Color newColor)
		{
			switch (type)
			{
			case ColorValues.R:
			case ColorValues.G:
			case ColorValues.B:
			case ColorValues.Saturation:
			case ColorValues.Value:
				RegenerateTexture();
				break;
			case ColorValues.A:
			case ColorValues.Hue:
				break;
			}
		}

		private void HSVChanged(float hue, float saturation, float value)
		{
			switch (type)
			{
			case ColorValues.R:
			case ColorValues.G:
			case ColorValues.B:
			case ColorValues.Saturation:
			case ColorValues.Value:
				RegenerateTexture();
				break;
			case ColorValues.A:
			case ColorValues.Hue:
				break;
			}
		}

		private void RegenerateTexture()
		{
			//IL_001c: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0091: Invalid comparison between Unknown and I4
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Invalid comparison between Unknown and I4
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Invalid comparison between Unknown and I4
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Invalid comparison between Unknown and I4
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Invalid comparison between Unknown and I4
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: 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_0323: 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_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: 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)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Invalid comparison between Unknown and I4
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			Color32 val = Color32.op_Implicit(((Object)(object)picker != (Object)null) ? picker.CurrentColor : Color.black);
			float num = (((Object)(object)picker != (Object)null) ? picker.H : 0f);
			float num2 = (((Object)(object)picker != (Object)null) ? picker.S : 0f);
			float num3 = (((Object)(object)picker != (Object)null) ? picker.V : 0f);
			bool flag = (int)direction == 2 || (int)direction == 3;
			bool flag2 = (int)direction == 3 || (int)direction == 1;
			int num4;
			switch (type)
			{
			case ColorValues.R:
			case ColorValues.G:
			case ColorValues.B:
			case ColorValues.A:
				num4 = 255;
				break;
			case ColorValues.Hue:
				num4 = 360;
				break;
			case ColorValues.Saturation:
			case ColorValues.Value:
				num4 = 100;
				break;
			default:
				throw new NotImplementedException("");
			}
			Texture2D val2 = ((!flag) ? new Texture2D(num4, 1) : new Texture2D(1, num4));
			((Object)val2).hideFlags = (HideFlags)52;
			Color32[] array = (Color32[])(object)new Color32[num4];
			switch (type)
			{
			case ColorValues.R:
			{
				for (byte b3 = 0; b3 < num4; b3++)
				{
					array[flag2 ? (num4 - 1 - b3) : b3] = new Color32(b3, val.g, val.b, byte.MaxValue);
				}
				break;
			}
			case ColorValues.G:
			{
				for (byte b = 0; b < num4; b++)
				{
					array[flag2 ? (num4 - 1 - b) : b] = new Color32(val.r, b, val.b, byte.MaxValue);
				}
				break;
			}
			case ColorValues.B:
			{
				for (byte b2 = 0; b2 < num4; b2++)
				{
					array[flag2 ? (num4 - 1 - b2) : b2] = new Color32(val.r, val.g, b2, byte.MaxValue);
				}
				break;
			}
			case ColorValues.A:
			{
				for (byte b4 = 0; b4 < num4; b4++)
				{
					array[flag2 ? (num4 - 1 - b4) : b4] = new Color32(b4, b4, b4, byte.MaxValue);
				}
				break;
			}
			case ColorValues.Hue:
			{
				for (int k = 0; k < num4; k++)
				{
					array[flag2 ? (num4 - 1 - k) : k] = Color32.op_Implicit(HSVUtil.ConvertHsvToRgb(k, 1.0, 1.0, 1f));
				}
				break;
			}
			case ColorValues.Saturation:
			{
				for (int j = 0; j < num4; j++)
				{
					array[flag2 ? (num4 - 1 - j) : j] = Color32.op_Implicit(HSVUtil.ConvertHsvToRgb(num * 360f, (float)j / (float)num4, num3, 1f));
				}
				break;
			}
			case ColorValues.Value:
			{
				for (int i = 0; i < num4; i++)
				{
					array[flag2 ? (num4 - 1 - i) : i] = Color32.op_Implicit(HSVUtil.ConvertHsvToRgb(num * 360f, num2, (float)i / (float)num4, 1f));
				}
				break;
			}
			default:
				throw new NotImplementedException("");
			}
			((Texture)val2).wrapMode = (TextureWrapMode)1;
			val2.SetPixels32(array);
			val2.Apply();
			if ((Object)(object)image.texture != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)image.texture);
			}
			image.texture = (Texture)(object)val2;
			Direction val3 = direction;
			Direction val4 = val3;
			if ((int)val4 > 1)
			{
				if (val4 - 2 <= 1)
				{
					image.uvRect = new Rect(0f, 0f, 2f, 1f);
				}
			}
			else
			{
				image.uvRect = new Rect(0f, 0f, 1f, 2f);
			}
		}
	}
	[RequireComponent(typeof(TMP_InputField))]
	[DefaultExecutionOrder(10)]
	public class HexColorField : MonoBehaviour
	{
		public ColorPicker hsvpicker;

		public bool displayAlpha;

		private TMP_InputField hexInputField;

		private void Start()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			hexInputField = ((Component)this).GetComponent<TMP_InputField>();
			((UnityEvent<string>)(object)hexInputField.onEndEdit).AddListener((UnityAction<string>)UpdateColor);
			((UnityEvent<Color>)hsvpicker.onValueChanged).AddListener((UnityAction<Color>)UpdateHex);
			UpdateHex(hsvpicker.CurrentColor);
		}

		private void OnDestroy()
		{
			((UnityEvent<string>)(object)hexInputField.onValueChanged).RemoveListener((UnityAction<string>)UpdateColor);
			((UnityEvent<Color>)hsvpicker.onValueChanged).RemoveListener((UnityAction<Color>)UpdateHex);
		}

		private void UpdateHex(Color newColor)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			hexInputField.text = ColorToHex(Color32.op_Implicit(newColor));
		}

		private void UpdateColor(string newHex)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (!newHex.StartsWith("#"))
			{
				newHex = "#" + newHex;
			}
			Color currentColor = default(Color);
			if (ColorUtility.TryParseHtmlString(newHex, ref currentColor))
			{
				hsvpicker.CurrentColor = currentColor;
			}
			else
			{
				Debug.Log((object)"hex value is in the wrong format, valid formats are: #RGB, #RGBA, #RRGGBB and #RRGGBBAA (# is optional)");
			}
		}

		private string ColorToHex(Color32 color)
		{
			//IL_0043: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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)
			return displayAlpha ? $"#{color.r:X2}{color.g:X2}{color.b:X2}{color.a:X2}" : $"#{color.r:X2}{color.g:X2}{color.b:X2}";
		}
	}
	public static class HSVUtil
	{
		public static HsvColor ConvertRgbToHsv(Color color)
		{
			//IL_0001: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			return ConvertRgbToHsv((int)(color.r * 255f), (int)(color.g * 255f), (int)(color.b * 255f));
		}

		public static HsvColor ConvertRgbToHsv(double r, double b, double g)
		{
			double num = 0.0;
			double num2 = Math.Min(Math.Min(r, g), b);
			double num3 = Math.Max(Math.Max(r, g), b);
			double num4 = num3 - num2;
			double s = ((!num3.Equals(0.0)) ? (num4 / num3) : 0.0);
			if (s.Equals(0.0))
			{
				num = 360.0;
			}
			else
			{
				if (r.Equals(num3))
				{
					num = (g - b) / num4;
				}
				else if (g.Equals(num3))
				{
					num = 2.0 + (b - r) / num4;
				}
				else if (b.Equals(num3))
				{
					num = 4.0 + (r - g) / num4;
				}
				num *= 60.0;
				if (num <= 0.0)
				{
					num += 360.0;
				}
			}
			HsvColor result = default(HsvColor);
			result.H = 360.0 - num;
			result.S = s;
			result.V = num3 / 255.0;
			return result;
		}

		public static Color ConvertHsvToRgb(double h, double s, double v, float alpha)
		{
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			double num = 0.0;
			double num2 = 0.0;
			double num3 = 0.0;
			if (s.Equals(0.0))
			{
				num = v;
				num2 = v;
				num3 = v;
			}
			else
			{
				h = ((!h.Equals(360.0)) ? (h / 60.0) : 0.0);
				int num4 = (int)h;
				double num5 = h - (double)num4;
				double num6 = v * (1.0 - s);
				double num7 = v * (1.0 - s * num5);
				double num8 = v * (1.0 - s * (1.0 - num5));
				switch (num4)
				{
				case 0:
					num = v;
					num2 = num8;
					num3 = num6;
					break;
				case 1:
					num = num7;
					num2 = v;
					num3 = num6;
					break;
				case 2:
					num = num6;
					num2 = v;
					num3 = num8;
					break;
				case 3:
					num = num6;
					num2 = num7;
					num3 = v;
					break;
				case 4:
					num = num8;
					num2 = num6;
					num3 = v;
					break;
				default:
					num = v;
					num2 = num6;
					num3 = num7;
					break;
				}
			}
			return new Color((float)num, (float)num2, (float)num3, alpha);
		}
	}
	public struct HsvColor
	{
		public double H;

		public double S;

		public double V;

		public float normalizedH
		{
			get
			{
				return (float)H / 360f;
			}
			set
			{
				H = (double)value * 360.0;
			}
		}

		public float normalizedS
		{
			get
			{
				return (float)S;
			}
			set
			{
				S = value;
			}
		}

		public float normalizedV
		{
			get
			{
				return (float)V;
			}
			set
			{
				V = value;
			}
		}

		public HsvColor(double h, double s, double v)
		{
			H = h;
			S = s;
			V = v;
		}

		public override string ToString()
		{
			return "{" + H.ToString("f2") + "," + S.ToString("f2") + "," + V.ToString("f2") + "}";
		}
	}
	[RequireComponent(typeof(BoxSlider), typeof(RawImage))]
	[ExecuteInEditMode]
	[DefaultExecutionOrder(10)]
	public class SVBoxSlider : MonoBehaviour, IEndDragHandler, IEventSystemHandler
	{
		public ColorPicker picker;

		private BoxSlider slider;

		private RawImage image;

		private int textureWidth = 128;

		private int textureHeight = 128;

		private float lastH = -1f;

		private bool listen = true;

		[Header("Event")]
		public SliderOnChangeEndEvent onSliderChangeEndEvent = new SliderOnChangeEndEvent();

		public RectTransform rectTransform
		{
			get
			{
				Transform transform = ((Component)this).transform;
				return (RectTransform)(object)((transform is RectTransform) ? transform : null);
			}
		}

		private void Awake()
		{
			slider = ((Component)this).GetComponent<BoxSlider>();
			image = ((Component)this).GetComponent<RawImage>();
		}

		private void OnEnable()
		{
			if (Application.isPlaying && (Object)(object)picker != (Object)null)
			{
				((UnityEvent<float, float>)slider.onValueChanged).AddListener((UnityAction<float, float>)SliderChanged);
				((UnityEvent<float, float, float>)picker.onHSVChanged).AddListener((UnityAction<float, float, float>)HSVChanged);
				HSVChanged(picker.H, picker.S, picker.V);
			}
			if (Application.isPlaying)
			{
				RegenerateSVTexture();
			}
		}

		private void OnDisable()
		{
			if ((Object)(object)picker != (Object)null)
			{
				((UnityEvent<float, float>)slider.onValueChanged).RemoveListener((UnityAction<float, float>)SliderChanged);
				((UnityEvent<float, float, float>)picker.onHSVChanged).RemoveListener((UnityAction<float, float, float>)HSVChanged);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)image.texture != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)image.texture);
			}
		}

		private void SliderChanged(float saturation, float value)
		{
			if (listen)
			{
				picker.AssignColor(ColorValues.Saturation, saturation);
				picker.AssignColor(ColorValues.Value, value);
			}
			listen = true;
		}

		private void HSVChanged(float h, float s, float v)
		{
			if (!lastH.Equals(h))
			{
				lastH = h;
				RegenerateSVTexture();
			}
			if (!s.Equals(slider.normalizedValue))
			{
				listen = false;
				slider.normalizedValue = s;
			}
			if (!v.Equals(slider.normalizedValueY))
			{
				listen = false;
				slider.normalizedValueY = v;
			}
		}

		private void RegenerateSVTexture()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			double h = (((Object)(object)picker != (Object)null) ? (picker.H * 360f) : 0f);
			if ((Object)(object)image.texture != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)image.texture);
			}
			Texture2D val = new Texture2D(textureWidth, textureHeight);
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Object)val).hideFlags = (HideFlags)52;
			for (int i = 0; i < textureWidth; i++)
			{
				Color[] array = (Color[])(object)new Color[textureHeight];
				for (int j = 0; j < textureHeight; j++)
				{
					array[j] = HSVUtil.ConvertHsvToRgb(h, (float)i / (float)textureWidth, (float)j / (float)textureHeight, 1f);
				}
				val.SetPixels(i, 0, 1, textureHeight, array);
			}
			val.Apply();
			image.texture = (Texture)(object)val;
		}

		public virtual void OnEndDrag(PointerEventData eventData)
		{
			((UnityEvent<float>)onSliderChangeEndEvent).Invoke(slider.normalizedValue);
		}
	}
}
namespace SkinColorSliders
{
	public class ColorWheelUI : MonoBehaviour
	{
		public SkinColorManager.SkinPart currentSkinPart = SkinColorManager.SkinPart.Face;

		public Button currentButton;

		public Button currentPresetButton;

		public Button[] presetButtons;

		public Toggle faceBodyMatchToggle;

		public Toggle blushMatchToggle;

		public Toggle wholeBodyMatchToggle;

		public TextMeshProUGUI nameText;

		private void Start()
		{
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			BindSkinPartButtons();
			BindToggles();
			BindApplyButton();
			presetButtons = ((Component)((Component)this).transform.Find("PresetsPanel")).GetComponentsInChildren<Button>();
			nameText = ((Component)((Component)this).transform.Find("NamePanel/NameDisplay")).GetComponentInChildren<TextMeshProUGUI>();
			TextMeshProUGUI text = GUIManager.instance.playerNames.playerNameText[0].text;
			((TMP_Text)nameText).font = ((TMP_Text)text).font;
			((TMP_Text)nameText).fontMaterial = Object.Instantiate<Material>(((TMP_Text)text).fontMaterial);
			((Graphic)nameText).color = SkinColorManager.dummyColors.Get(SkinColorManager.SkinPart.NameFill);
			((TMP_Text)nameText).fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, SkinColorManager.dummyColors.Get(SkinColorManager.SkinPart.NameOutline));
			((TMP_Text)nameText).ForceMeshUpdate(false, false);
			((TMP_Text)nameText).text = Character.localCharacter.characterName;
			InitializePresets();
			((UnityEvent<Color>)SkinColorSliders.Instance.colorPicker.onValueChanged).AddListener((UnityAction<Color>)delegate
			{
				UpdatePreview(useAppliedLocal: false);
			});
		}

		private void BindSkinPartButtons()
		{
			BindButton("TabPanel/FaceButton", delegate(Button btn)
			{
				BindSkinPart(btn, SkinColorManager.SkinPart.Face);
			});
			BindButton("TabPanel/BodyButton", delegate(Button btn)
			{
				BindSkinPart(btn, SkinColorManager.SkinPart.Body);
			});
			BindButton("TabPanel/BlushLButton", delegate(Button btn)
			{
				BindSkinPart(btn, SkinColorManager.SkinPart.Blush_L);
			});
			BindButton("TabPanel/BlushRButton", delegate(Button btn)
			{
				BindSkinPart(btn, SkinColorManager.SkinPart.Blush_R);
			});
			BindButton("TabPanel/SashButton", delegate(Button btn)
			{
				BindSkinPart(btn, SkinColorManager.SkinPart.Sash);
			});
			BindButton("NamePanel/NameButtons/FillButton", delegate(Button btn)
			{
				BindSkinPart(btn, SkinColorManager.SkinPart.NameFill);
			});
			BindButton("NamePanel/NameButtons/OutlineButton", delegate(Button btn)
			{
				BindSkinPart(btn, SkinColorManager.SkinPart.NameOutline);
			});
		}

		private void BindToggles()
		{
			BindToggle("SettingsPanel/LeftPanel/FaceBodyMatchPanel/Toggle", delegate(Toggle t)
			{
				faceBodyMatchToggle = t;
				((UnityEvent<bool>)(object)t.onValueChanged).AddListener((UnityAction<bool>)OnFaceBodyMatchChanged);
			});
			BindToggle("SettingsPanel/LeftPanel/BlushMatchPanel/Toggle", delegate(Toggle t)
			{
				blushMatchToggle = t;
				((UnityEvent<bool>)(object)t.onValueChanged).AddListener((UnityAction<bool>)OnBlushMatchChanged);
			});
			BindToggle("SettingsPanel/LeftPanel/WholeBodyMatchPanel/Toggle", delegate(Toggle t)
			{
				wholeBodyMatchToggle = t;
				((UnityEvent<bool>)(object)t.onValueChanged).AddListener((UnityAction<bool>)OnMatchEverythingChanged);
			});
		}

		private void BindApplyButton()
		{
			BindButton("SettingsPanel/RightPanel/ApplyButtonContainer/ApplyButton", delegate(Button btn)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Expected O, but got Unknown
				((UnityEvent)btn.onClick).AddListener(new UnityAction(OnApplyButtonClicked));
			});
		}

		private void BindSkinPart(Button button, SkinColorManager.SkinPart part)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			Button button2 = button;
			((UnityEvent)button2.onClick).AddListener((UnityAction)delegate
			{
				OnSkinPartSelected(button2, part);
			});
		}

		private void BindButton(string path, Action<Button> action)
		{
			Transform obj = ((Component)this).transform.Find(path);
			Button val = ((obj != null) ? ((Component)obj).GetComponent<Button>() : null);
			if ((Object)(object)val != (Object)null)
			{
				action(val);
			}
		}

		private void BindToggle(string path, Action<Toggle> action)
		{
			Transform obj = ((Component)this).transform.Find(path);
			Toggle val = ((obj != null) ? ((Component)obj).GetComponent<Toggle>() : null);
			if ((Object)(object)val != (Object)null)
			{
				action(val);
			}
		}

		private void InitializePresets()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			SetActivePresetButton(SkinColorSliders.Instance.configPresetIndex.Value);
			for (int i = 0; i < presetButtons.Length; i++)
			{
				int index = i;
				((UnityEvent)presetButtons[i].onClick).AddListener((UnityAction)delegate
				{
					SetActivePresetButton(index);
				});
				UpdatePresetButtonPreview(index);
			}
		}

		public void SetActivePresetButton(int index)
		{
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)currentPresetButton != (Object)null)
			{
				((Behaviour)((Component)currentPresetButton).GetComponent<Outline>()).enabled = false;
			}
			currentPresetButton = presetButtons[index];
			((Behaviour)((Component)currentPresetButton).GetComponent<Outline>()).enabled = true;
			SkinColorManager.SetCurrentPreset(index);
			SkinColorSliders.Instance.configPresetIndex.Value = index;
			SkinColorManager.SkinPartColorSet orCreatePreset = SkinColorManager.GetOrCreatePreset(index);
			faceBodyMatchToggle.isOn = orCreatePreset.faceBodyMatch;
			blushMatchToggle.isOn = orCreatePreset.blushMatch;
			wholeBodyMatchToggle.isOn = orCreatePreset.matchEverything;
			SkinColorManager.SetLocalColors(orCreatePreset);
			SkinColorSliders.Instance.colorPicker.CurrentColor = orCreatePreset.Get(currentSkinPart);
			UpdatePresetButtonPreview(index);
			UpdatePreview(useAppliedLocal: false);
		}

		public void UpdatePresetButtonPreview(int index)
		{
			//IL_003d: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if (SkinColorManager.localPresets.TryGetValue(index, out SkinColorManager.SkinPartColorSet value))
			{
				((Graphic)((Component)((Component)presetButtons[index]).transform.Find("PresetColors/PresetFacePreview")).GetComponent<Image>()).color = value.colors[SkinColorManager.SkinPart.Face];
				((Graphic)((Component)((Component)presetButtons[index]).transform.Find("PresetColors/PresetBodyPreview")).GetComponent<Image>()).color = value.colors[SkinColorManager.SkinPart.Body];
				((Graphic)((Component)((Component)presetButtons[index]).transform.Find("PresetColors/PresetBlushLPreview")).GetComponent<Image>()).color = value.colors[SkinColorManager.SkinPart.Blush_L];
				((Graphic)((Component)((Component)presetButtons[index]).transform.Find("PresetColors/PresetBlushRPreview")).GetComponent<Image>()).color = value.colors[SkinColorManager.SkinPart.Blush_R];
			}
		}

		private void OnSkinPartSelected(Button button, SkinColorManager.SkinPart part)
		{
			//IL_003b: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			currentSkinPart = part;
			if ((Object)(object)currentButton != (Object)null)
			{
				((Graphic)((Component)currentButton).GetComponent<Image>()).color = Color.white;
			}
			currentButton = button;
			((Graphic)((Component)button).GetComponent<Image>()).color = Color.clear;
			SkinColorSliders.Instance.colorPicker.CurrentColor = SkinColorManager.GetColors(PhotonNetwork.LocalPlayer.ActorNumber)?.Get(currentSkinPart) ?? Color.white;
			UpdatePreview(useAppliedLocal: false);
		}

		private void OnFaceBodyMatchChanged(bool value)
		{
			SkinColorManager.SetMatchFlag(SkinColorManager.currentPresetIndex, value);
		}

		private void OnBlushMatchChanged(bool value)
		{
			int currentPresetIndex = SkinColorManager.currentPresetIndex;
			bool? matchBlush = value;
			SkinColorManager.SetMatchFlag(currentPresetIndex, null, matchBlush);
		}

		private void OnMatchEverythingChanged(bool value)
		{
			int currentPresetIndex = SkinColorManager.currentPresetIndex;
			bool? matchEverything = value;
			SkinColorManager.SetMatchFlag(currentPresetIndex, null, null, matchEverything);
		}

		private void OnApplyButtonClicked()
		{
			//IL_000b: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			Color currentColor = SkinColorSliders.Instance.colorPicker.CurrentColor;
			SkinColorManager.ApplyColor(currentSkinPart, currentColor, SkinColorManager.currentPresetIndex, faceBodyMatchToggle.isOn, blushMatchToggle.isOn, wholeBodyMatchToggle.isOn);
			UpdatePresetButtonPreview(SkinColorManager.currentPresetIndex);
			UpdatePreview(useAppliedLocal: false);
		}

		private void UpdatePreview(bool useAppliedLocal)
		{
			//IL_0011: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: 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_0091: 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)
			SkinColorManager.UpdateDummyColors(currentSkinPart, SkinColorSliders.Instance.colorPicker.CurrentColor, useAppliedLocal);
			if (currentSkinPart == SkinColorManager.SkinPart.NameFill)
			{
				((Graphic)nameText).color = SkinColorSliders.Instance.colorPicker.CurrentColor;
				((TMP_Text)nameText).fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, SkinColorManager.GetOrCreatePreset(SkinColorManager.currentPresetIndex).Get(SkinColorManager.SkinPart.NameOutline));
			}
			else if (currentSkinPart == SkinColorManager.SkinPart.NameOutline)
			{
				((Graphic)nameText).color = SkinColorManager.GetOrCreatePreset(SkinColorManager.currentPresetIndex).Get(SkinColorManager.SkinPart.NameFill);
				((TMP_Text)nameText).fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, SkinColorSliders.Instance.colorPicker.CurrentColor);
			}
			else
			{
				((Graphic)nameText).color = SkinColorManager.GetOrCreatePreset(SkinColorManager.currentPresetIndex).Get(SkinColorManager.SkinPart.NameFill);
				((TMP_Text)nameText).fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, SkinColorManager.GetOrCreatePreset(SkinColorManager.currentPresetIndex).Get(SkinColorManager.SkinPart.NameOutline));
			}
			((TMP_Text)nameText).ForceMeshUpdate(false, false);
		}
	}
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resource1
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("SkinColorSliders.Resource1", typeof(Resource1).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal static byte[] colorsliders
		{
			get
			{
				object @object = ResourceManager.GetObject("colorsliders", resourceCulture);
				return (byte[])@object;
			}
		}

		internal Resource1()
		{
		}
	}
	public static class SkinColorManager
	{
		public enum SkinPart
		{
			Face,
			Body,
			Blush_L,
			Blush_R,
			Sash,
			NameFill,
			NameOutline
		}

		[Serializable]
		public class SkinPartColorSet
		{
			public Dictionary<SkinPart, Color> colors = new Dictionary<SkinPart, Color>();

			public bool matchEverything;

			public bool blushMatch;

			public bool faceBodyMatch;

			public SkinPartColorSet()
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				foreach (SkinPart value in Enum.GetValues(typeof(SkinPart)))
				{
					colors[value] = Color.white;
				}
			}

			public Color Get(SkinPart part)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				return colors[part];
			}

			public void Set(SkinPart part, Color color)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				colors[part] = color;
			}
		}

		public static SkinPartColorSet dummyColors = new SkinPartColorSet();

		public static int currentIndex;

		public static int currentSashIndex;

		public static int currentPresetIndex = 0;

		public static bool currentFaceBodyMatch = false;

		public static bool currentBlushMatch = false;

		public static bool currentWholeBodyMatch = false;

		public static Dictionary<int, SkinPartColorSet> colorTable = new Dictionary<int, SkinPartColorSet>();

		public static Dictionary<int, SkinPartColorSet> localPresets = new Dictionary<int, SkinPartColorSet>();

		private static readonly string OldSavePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "presets.json");

		private static readonly string SavePath = Path.Combine(Application.persistentDataPath, "SkinColorSliders", "presets.json");

		public static SkinPartColorSet GetOrCreatePreset(int index)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!localPresets.TryGetValue(index, out SkinPartColorSet value))
			{
				value = new SkinPartColorSet();
				value.Set(SkinPart.NameOutline, Color.black);
				localPresets[index] = value;
				SavePresets();
			}
			return value;
		}

		public static SkinPartColorSet GetCurrentPreset()
		{
			return GetOrCreatePreset(currentPresetIndex);
		}

		public static void SetMatchFlag(int presetIndex, bool? matchFaceBody = null, bool? matchBlush = null, bool? matchEverything = null)
		{
			SkinPartColorSet orCreatePreset = GetOrCreatePreset(presetIndex);
			if (matchFaceBody.HasValue)
			{
				orCreatePreset.faceBodyMatch = matchFaceBody.Value;
			}
			if (matchBlush.HasValue)
			{
				orCreatePreset.blushMatch = matchBlush.Value;
			}
			if (matchEverything.HasValue)
			{
				orCreatePreset.matchEverything = matchEverything.Value;
			}
			SavePresets();
			if (presetIndex == currentPresetIndex)
			{
				if (matchFaceBody.HasValue)
				{
					currentFaceBodyMatch = matchFaceBody.Value;
				}
				if (matchBlush.HasValue)
				{
					currentBlushMatch = matchBlush.Value;
				}
				if (matchEverything.HasValue)
				{
					currentWholeBodyMatch = matchEverything.Value;
				}
			}
		}

		public static void SetCurrentPresetMatchFlags(bool? matchFaceBody = null, bool? matchBlush = null, bool? matchEverything = null)
		{
			SetMatchFlag(currentPresetIndex, matchFaceBody, matchBlush, matchEverything);
		}

		public static void SetCurrentPreset(int presetIndex)
		{
			currentPresetIndex = presetIndex;
			SkinPartColorSet orCreatePreset = GetOrCreatePreset(presetIndex);
			currentFaceBodyMatch = orCreatePreset.faceBodyMatch;
			currentBlushMatch = orCreatePreset.blushMatch;
			currentWholeBodyMatch = orCreatePreset.matchEverything;
		}

		public static void ApplyColor(SkinPart part, Color color, int presetIndex, bool faceBodyMatch, bool blushMatch, bool matchEverything)
		{
			//IL_0086: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_00b9: 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_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber;
			SkinPartColorSet skinPartColorSet = GetColors(actorNumber) ?? new SkinPartColorSet();
			if (matchEverything)
			{
				foreach (SkinPart value in Enum.GetValues(typeof(SkinPart)))
				{
					Color val = skinPartColorSet.Get(value);
					skinPartColorSet.Set(value, color);
				}
			}
			else
			{
				Color val2 = skinPartColorSet.Get(part);
				skinPartColorSet.Set(part, color);
				if (faceBodyMatch && (part == SkinPart.Face || part == SkinPart.Body))
				{
					SkinPart part3 = ((part == SkinPart.Face) ? SkinPart.Body : SkinPart.Face);
					Color val3 = skinPartColorSet.Get(part3);
					skinPartColorSet.Set(part3, color);
				}
				if (blushMatch && (part == SkinPart.Blush_L || part == SkinPart.Blush_R))
				{
					SkinPart part4 = ((part == SkinPart.Blush_L) ? SkinPart.Blush_R : SkinPart.Blush_L);
					Color val4 = skinPartColorSet.Get(part4);
					skinPartColorSet.Set(part4, color);
				}
			}
			SetLocalColors(skinPartColorSet);
			localPresets[presetIndex].colors = skinPartColorSet.colors;
			SavePresets();
		}

		public static void ApplyColor(SkinPart part, Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			ApplyColor(part, color, currentPresetIndex, currentFaceBodyMatch, currentBlushMatch, currentWholeBodyMatch);
		}

		public static void UpdateDummyColors(SkinPart currentPart, Color currentColor, bool faceBodyMatch, bool blushMatch, bool matchEverything, bool useAppliedLocal)
		{
			//IL_00aa: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			SkinPartColorSet skinPartColorSet = GetColors(PhotonNetwork.LocalPlayer.ActorNumber) ?? new SkinPartColorSet();
			SkinPartColorSet skinPartColorSet2 = new SkinPartColorSet();
			if (useAppliedLocal || matchEverything)
			{
				foreach (SkinPart value in Enum.GetValues(typeof(SkinPart)))
				{
					skinPartColorSet2.Set(value, currentColor);
				}
			}
			else
			{
				foreach (SkinPart value2 in Enum.GetValues(typeof(SkinPart)))
				{
					Color color = skinPartColorSet.Get(value2);
					if (value2 == currentPart)
					{
						color = currentColor;
					}
					if (faceBodyMatch && (value2 == SkinPart.Face || value2 == SkinPart.Body) && (currentPart == SkinPart.Face || currentPart == SkinPart.Body))
					{
						color = currentColor;
					}
					if (blushMatch && (value2 == SkinPart.Blush_L || value2 == SkinPart.Blush_R) && (currentPart == SkinPart.Blush_L || currentPart == SkinPart.Blush_R))
					{
						color = currentColor;
					}
					skinPartColorSet2.Set(value2, color);
				}
			}
			SetDummyColors(skinPartColorSet2);
		}

		public static void UpdateDummyColors(SkinPart currentPart, Color currentColor, bool useAppliedLocal = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			UpdateDummyColors(currentPart, currentColor, currentFaceBodyMatch, currentBlushMatch, currentWholeBodyMatch, useAppliedLocal);
		}

		public static void SetDummyColors(SkinPartColorSet colors)
		{
			dummyColors = colors;
			PassportManager.instance.dummy.SetPlayerColor(0);
		}

		public static void SetLocalColors(SkinPartColorSet colorSet)
		{
			int actorNumber = PhotonNetwork.LocalPlayer.ActorNumber;
			bool isMasterClient = PhotonNetwork.IsMasterClient;
			foreach (KeyValuePair<SkinPart, Color> color in colorSet.colors)
			{
			}
			if (!colorTable.ContainsKey(actorNumber))
			{
				colorTable[actorNumber] = new SkinPartColorSet();
			}
			colorTable[actorNumber] = colorSet;
			SyncColorsToPhoton(actorNumber);
			CharacterCustomization.SetCharacterSkinColor(currentIndex);
			CharacterCustomization.SetCharacterSash(currentSashIndex);
		}

		private static void SyncColorsToPhoton(int actor)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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)
			//IL_00b4: 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)
			if (!colorTable.TryGetValue(actor, out SkinPartColorSet value))
			{
				return;
			}
			foreach (KeyValuePair<SkinPart, Color> color in value.colors)
			{
			}
			float[] array = new float[Enum.GetValues(typeof(SkinPart)).Length * 3];
			int num = 0;
			foreach (SkinPart value2 in Enum.GetValues(typeof(SkinPart)))
			{
				Color val = value.Get(value2);
				array[num++] = val.r;
				array[num++] = val.g;
				array[num++] = val.b;
			}
			SkinColorSliders.Instance.manager.SetPlayerProperty("customSkinColors", (object)array);
		}

		public static Color? GetColor(int actorNumber, SkinPart part)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (colorTable.TryGetValue(actorNumber, out SkinPartColorSet value))
			{
				return value.Get(part);
			}
			return null;
		}

		public static Color GetCurrentPresetColor(SkinPart part)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			SkinPartColorSet currentPreset = GetCurrentPreset();
			return currentPreset.Get(part);
		}

		public static SkinPartColorSet GetColors(int actorNumber)
		{
			if (colorTable.TryGetValue(actorNumber, out SkinPartColorSet value))
			{
			}
			return value;
		}

		public static void SavePresets()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			string contents = JsonConvert.SerializeObject((object)localPresets, new JsonSerializerSettings
			{
				Formatting = (Formatting)1,
				Converters = new List<JsonConverter> { (JsonConverter)(object)new ColorHexConverter() }
			});
			File.WriteAllText(SavePath, contents);
		}

		public static void LoadPresets()
		{
			//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_00b9: Expected O, but got Unknown
			string directoryName = Path.GetDirectoryName(SavePath);
			if (!Directory.Exists(directoryName))
			{
				Directory.CreateDirectory(directoryName);
			}
			if (!File.Exists(SavePath) && File.Exists(OldSavePath))
			{
				try
				{
					File.Move(OldSavePath, SavePath);
				}
				catch (IOException)
				{
					File.Copy(OldSavePath, SavePath, overwrite: true);
				}
			}
			if (!File.Exists(SavePath))
			{
				localPresets = new Dictionary<int, SkinPartColorSet>();
				return;
			}
			string text = File.ReadAllText(SavePath);
			localPresets = JsonConvert.DeserializeObject<Dictionary<int, SkinPartColorSet>>(text, new JsonSerializerSettings
			{
				Converters = new List<JsonConverter> { (JsonConverter)(object)new ColorHexConverter() }
			}) ?? new Dictionary<int, SkinPartColorSet>();
			if (localPresets.Count > 0)
			{
				SetCurrentPreset(0);
			}
		}
	}
	public class ColorHexConverter : JsonConverter<Color>
	{
		public override void WriteJson(JsonWriter writer, Color value, JsonSerializer serializer)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			writer.WriteValue("#" + ColorUtility.ToHtmlStringRGBA(value));
		}

		public override Color ReadJson(JsonReader reader, Type objectType, Color existingValue, bool hasExistingValue, JsonSerializer serializer)
		{
			//IL_0028: 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_0024: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			if (ColorUtility.TryParseHtmlString((string)reader.Value, ref result))
			{
				result.a = 1f;
				return result;
			}
			return Color.white;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.snosz.skincolorsliders", "SkinColorSliders", "1.5.0")]
	public class SkinColorSliders : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Character), "Awake")]
		private class CharacterAwakePatch
		{
			private static void Postfix(Character __instance)
			{
				if (__instance.IsLocal)
				{
					InitializeLocalCharacterColors();
				}
			}
		}

		public static SkinColorSliders Instance;

		private static Harmony _harmony;

		public ConfigEntry<Color> configFaceColor;

		public ConfigEntry<Color> configBodyColor;

		public ConfigEntry<Color> configBlushLeftColor;

		public ConfigEntry<Color> configBlushRightColor;

		public ConfigEntry<int> configPresetIndex;

		public AssetBundle colorWheelUIBundle;

		public PhotonScopedManager manager;

		public GameObject colorWheelUI;

		public ColorWheelUI colorWheel;

		public ColorPicker colorPicker;

		private void Awake()
		{
			Instance = this;
			byte[] colorsliders = Resource1.colorsliders;
			colorWheelUIBundle = AssetBundle.LoadFromMemory(colorsliders);
			InitializeConfig();
			AddPhotonManager();
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.snosz.skincolorsliders");
		}

		private void InitializeConfig()
		{
			//IL_0033: 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)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			configPresetIndex = ((BaseUnityPlugin)this).Config.Bind<int>("General", "ChosenPresetIndex", 0, "Index of preset to load first (0-6)");
			configFaceColor = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "SkinColor", Color.white, "Face color to apply.");
			configBodyColor = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "BodyColor", Color.white, "Body color to apply.");
			configBlushLeftColor = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "BlushLeftColor", Color.white, "BlushLeft color to apply.");
			configBlushRightColor = ((BaseUnityPlugin)this).Config.Bind<Color>("General", "BlushRightColor", Color.white, "BlushRight color to apply.");
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void AddPhotonManager()
		{
			manager = PhotonCustomPropsUtilsPlugin.GetManager("com.snosz.skincolorsliders");
			manager.RegisterPlayerProperty<float[]>("customSkinColors", (PlayerEventType)1, (Action<Player, float[]>)delegate(Player targetPlayer, float[] val)
			{
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				int actorNumber2 = targetPlayer.ActorNumber;
				bool isLocal = targetPlayer.IsLocal;
				bool isMasterClient = PhotonNetwork.IsMasterClient;
				if (val != null)
				{
					SkinColorManager.SkinPartColorSet skinPartColorSet2 = new SkinColorManager.SkinPartColorSet();
					int num5 = 0;
					Color color2 = default(Color);
					foreach (SkinColorManager.SkinPart value2 in Enum.GetValues(typeof(SkinColorManager.SkinPart)))
					{
						if (num5 + 2 >= val.Length)
						{
							break;
						}
						float num6 = val[num5++];
						float num7 = val[num5++];
						float num8 = val[num5++];
						((Color)(ref color2))..ctor(num6, num7, num8, 1f);
						skinPartColorSet2.Set(value2, color2);
					}
					SkinColorManager.colorTable[actorNumber2] = skinPartColorSet2;
				}
			});
			manager.RegisterOnJoinedRoom((Action<Player>)delegate
			{
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				Dictionary<Player, float[]> allPlayerProperties = Instance.manager.GetAllPlayerProperties<float[]>("customSkinColors");
				Color color = default(Color);
				foreach (KeyValuePair<Player, float[]> item in allPlayerProperties)
				{
					int actorNumber = item.Key.ActorNumber;
					float[] value = item.Value;
					if (value != null)
					{
						SkinColorManager.SkinPartColorSet skinPartColorSet = new SkinColorManager.SkinPartColorSet();
						int num = 0;
						foreach (SkinColorManager.SkinPart value3 in Enum.GetValues(typeof(SkinColorManager.SkinPart)))
						{
							if (num + 2 >= value.Length)
							{
								break;
							}
							float num2 = value[num++];
							float num3 = value[num++];
							float num4 = value[num++];
							((Color)(ref color))..ctor(num2, num3, num4, 1f);
							skinPartColorSet.Set(value3, color);
						}
						SkinColorManager.colorTable[actorNumber] = skinPartColorSet;
					}
				}
			});
		}

		public void CreateAndInitializeColorWheel(PassportManager passportManager)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_0115: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			AssetBundle val = Instance.colorWheelUIBundle;
			GameObject val2 = val.LoadAsset<GameObject>("SkinColorSlidersUIThemed");
			GameObject val3 = val.LoadAsset<GameObject>("SkinColorSlidersUIToggle");
			GameObject wheelUI = Object.Instantiate<GameObject>(val2, ((Component)passportManager).transform.Find("PassportUI/Canvas/Panel"));
			wheelUI.transform.localScale = new Vector3(0.75f, 0.75f, 1f);
			wheelUI.transform.localPosition = new Vector3(-543.8375f, -8.1966f, 0f);
			wheelUI.SetActive(false);
			Instance.colorWheelUI = wheelUI;
			Instance.colorWheel = wheelUI.AddComponent<ColorWheelUI>();
			Instance.colorPicker = wheelUI.GetComponentInChildren<ColorPicker>();
			Instance.colorPicker.CurrentColor = Instance.configFaceColor.Value;
			GameObject val4 = Object.Instantiate<GameObject>(val3, ((Component)passportManager).transform.Find("PassportUI/Canvas/Panel/Panel/BG"));
			val4.transform.localScale = Vector3.one;
			val4.transform.localPosition = new Vector3(-317.2037f, -101.0918f, 0f);
			Button componentInChildren = val4.GetComponentInChildren<Button>();
			((UnityEvent)componentInChildren.onClick).AddListener((UnityAction)delegate
			{
				wheelUI.SetActive(!wheelUI.activeSelf);
			});
		}

		public static void InitializeLocalCharacterColors()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0096: 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)
			SkinColorManager.LoadPresets();
			Dictionary<int, SkinColorManager.SkinPartColorSet> localPresets = SkinColorManager.localPresets;
			SkinColorManager.SkinPartColorSet value;
			if (localPresets.Count == 0)
			{
				value = new SkinColorManager.SkinPartColorSet();
				value.Set(SkinColorManager.SkinPart.Face, Instance.configFaceColor.Value);
				value.Set(SkinColorManager.SkinPart.Body, Instance.configBodyColor.Value);
				value.Set(SkinColorManager.SkinPart.Blush_L, Instance.configBlushLeftColor.Value);
				value.Set(SkinColorManager.SkinPart.Blush_R, Instance.configBlushRightColor.Value);
				value.Set(SkinColorManager.SkinPart.NameFill, new Color(1f, 1f, 1f, 1f));
				value.Set(SkinColorManager.SkinPart.NameOutline, new Color(0f, 0f, 0f, 1f));
				localPresets[0] = value;
				SkinColorManager.SetCurrentPreset(0);
			}
			else
			{
				int num = Instance.configPresetIndex.Value;
				if (!localPresets.TryGetValue(num, out value))
				{
					num = 0;
					value = localPresets[0];
				}
				Instance.configPresetIndex.Value = num;
				SkinColorManager.SetCurrentPreset(num);
			}
			SkinColorManager.SetDummyColors(value);
			SkinColorManager.SetLocalColors(value);
		}

		public static void ApplyColorsToPartRenderers(Renderer[] playerRenderers, SkinColorManager.SkinPartColorSet colorSet, int shaderID)
		{
			//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_0032: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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)
			//IL_0062: 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_0070: 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)
			if (playerRenderers != null && colorSet != null && playerRenderers.Length >= 4)
			{
				Color val = colorSet.Get(SkinColorManager.SkinPart.Face);
				playerRenderers[0].material.SetColor(shaderID, val);
				Color val2 = colorSet.Get(SkinColorManager.SkinPart.Body);
				playerRenderers[1].material.SetColor(shaderID, val2);
				Color val3 = colorSet.Get(SkinColorManager.SkinPart.Blush_L);
				playerRenderers[2].material.SetColor(shaderID, val3);
				Color val4 = colorSet.Get(SkinColorManager.SkinPart.Blush_R);
				playerRenderers[3].material.SetColor(shaderID, val4);
			}
		}

		public static void ApplyColorToSashRenderer(Renderer sashRenderer, SkinColorManager.SkinPartColorSet colorSet, int shaderID)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			sashRenderer.materials[1].SetColor(shaderID, colorSet.Get(SkinColorManager.SkinPart.Sash));
		}

		public static void ApplyColorsToPlayerNameText(CharacterCustomization characterCustomization)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			CharacterInteractible component = ((Component)characterCustomization).GetComponent<CharacterInteractible>();
			int actorNumber = characterCustomization._character.view.Owner.ActorNumber;
			bool isMine = characterCustomization._character.view.IsMine;
			PlayerName[] componentsInChildren = ((Component)GUIManager.instance.playerNames).GetComponentsInChildren<PlayerName>(true);
			PlayerName[] array = componentsInChildren;
			foreach (PlayerName val in array)
			{
				if (!((Object)(object)val.characterInteractable == (Object)(object)component))
				{
					continue;
				}
				TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
				if (!((Object)(object)componentInChildren != (Object)null))
				{
					break;
				}
				SkinColorManager.SkinPartColorSet colors = SkinColorManager.GetColors(actorNumber);
				if (colors != null)
				{
					foreach (KeyValuePair<SkinColorManager.SkinPart, Color> color4 in colors.colors)
					{
					}
				}
				Color color = ((Graphic)componentInChildren).color;
				Color color2 = ((TMP_Text)componentInChildren).fontMaterial.GetColor(ShaderUtilities.ID_OutlineColor);
				Color color3 = colors?.Get(SkinColorManager.SkinPart.NameFill) ?? Color.white;
				Color val2 = colors?.Get(SkinColorManager.SkinPart.NameOutline) ?? Color.black;
				((Graphic)componentInChildren).color = color3;
				((TMP_Text)componentInChildren).fontMaterial.SetColor(ShaderUtilities.ID_OutlineColor, val2);
				((TMP_Text)componentInChildren).ForceMeshUpdate(false, false);
				break;
			}
		}

		public static void ApplyColorsToGhostPartRenderers(Renderer[] playerRenderers, Renderer[] eyeRenderers, SkinColorManager.SkinPartColorSet colorSet, int playerShaderID, int eyeShaderID)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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)
			//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_0035: Unknown result type (might be due to invalid IL or missing references)
			//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_004e: Unknown result type (might be due to invalid IL or missing references)
			if (playerRenderers != null)
			{
				Color val = colorSet.Get(SkinColorManager.SkinPart.Face);
				playerRenderers[0].material.SetColor(playerShaderID, val);
				Color val2 = colorSet.Get(SkinColorManager.SkinPart.Blush_L);
				eyeRenderers[0].material.SetColor(eyeShaderID, val2);
				Color val3 = colorSet.Get(SkinColorManager.SkinPart.Blush_R);
				eyeRenderers[1].material.SetColor(eyeShaderID, val3);
			}
		}
	}
}
namespace SkinColorSliders.Patches
{
	public static class CustomizationPatches
	{
		[HarmonyPatch(typeof(CharacterCustomization), "OnPlayerDataChange")]
		public static class CharacterCustomization_OnPlayerDataChange_Patch
		{
			private static void Postfix(CharacterCustomization __instance, PersistentPlayerData playerData)
			{
				if (!((Object)(object)__instance.refs.PlayerRenderers[0] == (Object)null) && !__instance._character.isBot)
				{
					PhotonView component = ((Component)__instance).gameObject.GetComponent<PhotonView>();
					int actorNumber = component.Owner.ActorNumber;
					SkinColorManager.SkinPartColorSet colors = SkinColorManager.GetColors(actorNumber);
					if (colors != null)
					{
						int shaderID = Shader.PropertyToID("_SkinColor");
						SkinColorSliders.ApplyColorsToPartRenderers(__instance.refs.PlayerRenderers, colors, shaderID);
						int shaderID2 = Shader.PropertyToID("_Tint");
						SkinColorSliders.ApplyColorToSashRenderer(__instance.refs.sashRenderer, colors, shaderID2);
						SkinColorSliders.ApplyColorsToPlayerNameText(__instance);
					}
				}
			}
		}

		[HarmonyPatch(typeof(PersistentPlayerDataService))]
		[HarmonyPatch("OnSyncReceived")]
		private class PersistentPlayerDataService_OnSyncReceived_Patch
		{
			private static bool Prefix(SyncPersistentPlayerDataPackage package, PersistentPlayerDataService __instance)
			{
				if (package == null)
				{
					return false;
				}
				if (__instance.PersistentPlayerDatas == null)
				{
					return false;
				}
				__instance.PersistentPlayerDatas[package.ActorNumber] = package.Data;
				if (__instance.OnChangeActions != null && __instance.OnChangeActions.ContainsKey(package.ActorNumber))
				{
					try
					{
						__instance.OnChangeActions[package.ActorNumber]?.Invoke(package.Data);
					}
					catch (Exception)
					{
					}
				}
				return false;
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public class PlayerColorPatch
		{
			private static bool Prefix(CharacterCustomization __instance, ref Color __result)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				Color? color = SkinColorManager.GetColor(((MonoBehaviourPun)__instance._character).photonView.Owner.ActorNumber, SkinColorManager.SkinPart.Face);
				if (color.HasValue)
				{
					__result = color.Value;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(PlayerGhost), "CustomizeGhost")]
		private static class CustomizeGhostPatch
		{
			private static void Postfix(PlayerGhost __instance, CharacterCustomizationData data)
			{
				SkinColorManager.SkinPartColorSet colors = SkinColorManager.GetColors(((MonoBehaviourPun)__instance.m_owner).photonView.Owner.ActorNumber);
				if (colors != null)
				{
					SkinColorSliders.ApplyColorsToGhostPartRenderers(__instance.PlayerRenderers, __instance.EyeRenderers, colors, Shader.PropertyToID("_PlayerColor"), Shader.PropertyToID("_SkinColor"));
				}
			}
		}

		[HarmonyPatch(typeof(PlayerCustomizationDummy), "SetPlayerColor")]
		private static class SetPlayerDummyColorPatch
		{
			private static void Postfix(PlayerCustomizationDummy __instance, int index)
			{
				SkinColorManager.SkinPartColorSet dummyColors = SkinColorManager.dummyColors;
				SkinColorSliders.ApplyColorsToPartRenderers(__instance.refs.PlayerRenderers, dummyColors, Shader.PropertyToID("_SkinColor"));
				SkinColorSliders.ApplyColorToSashRenderer(__instance.refs.sashRenderer, dummyColors, Shader.PropertyToID("_Tint"));
			}
		}

		[HarmonyPatch(typeof(PlayerCustomizationDummy), "UpdateDummy")]
		private static class UpdateDummyPatch
		{
			private static void Postfix(PlayerCustomizationDummy __instance)
			{
				SkinColorManager.SkinPartColorSet dummyColors = SkinColorManager.dummyColors;
				SkinColorSliders.ApplyColorToSashRenderer(__instance.refs.sashRenderer, dummyColors, Shader.PropertyToID("_Tint"));
			}
		}
	}
	public static class UIPatches
	{
		[HarmonyPatch(typeof(UIPlayerNames), "Init")]
		public static class InitPatch
		{
			private static void Postfix(UIPlayerNames __instance, CharacterInteractible characterInteractable)
			{
				//IL_008a: 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)
				//IL_009c: 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_00af: Unknown result type (might be due to invalid IL or missing ref