Decompiled source of Customizations v1.0.0

plugins/Customizations.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using SoundImplementation;
using TMPro;
using UnboundLib;
using UnboundLib.Networking;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.UI.ProceduralImage;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Customizations
{
	[HarmonyPatch(typeof(GunAmmo), "Start")]
	internal static class GunAmmoStartPatch
	{
		private static void Postfix(GunAmmo __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<AmmoNumberDisplay>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<AmmoNumberDisplay>();
			}
		}
	}
	internal class AmmoNumberDisplay : MonoBehaviour
	{
		private static readonly FieldRef<GunAmmo, int> CurrentAmmo = AccessTools.FieldRefAccess<GunAmmo, int>("currentAmmo");

		private static readonly FieldRef<GunAmmo, Image> ReloadRingRef = AccessTools.FieldRefAccess<GunAmmo, Image>("reloadRing");

		private static readonly ManualLogSource Log = Logger.CreateLogSource("Customizations.Ammo");

		private static readonly Color FallbackYellow = new Color(1f, 0.85f, 0.1f);

		internal const float RingPerFont = 1.35f;

		private static Transform holder;

		private static int placeLogs;

		private GunAmmo ammo;

		private Gun gun;

		private Transform blocks;

		private Canvas gunCanvas;

		private Transform gunRoot;

		private CanvasGroup blocksGroup;

		private GameObject rootGo;

		private Transform rootT;

		private RectTransform textRt;

		private TextMeshProUGUI text;

		private float blockHeight = 80f;

		private float unit = 0.001842f;

		private Image gameRing;

		private RectTransform gameRingRt;

		private Image ring;

		private RectTransform ringRt;

		private float maxPop;

		private float outTimer;

		private bool sword;

		private float nextSwordCheck;

		private float along = 0.4f;

		private float perp = 0.41f;

		private float alongTarget = 0.4f;

		private float perpTarget = 0.41f;

		private bool measured;

		private int lastChildCount = -1;

		private int skipFrames;

		private int measureFrames;

		private float candPerp = -1f;

		private float candAlong;

		private int lastCur = -1;

		private int lastMax = -1;

		private int shown;

		private int seenVersion;

		private bool lastShowMax;

		private float tickTimer;

		private float punch;

		private float colorT;

		private bool animating = true;

		private Color gameColor;

		private bool hasGameColor;

		internal const float ShotPunch = 0.25f;

		internal const float ReloadPunch = 0.45f;

		internal const float PunchDecay = 14f;

		internal const float ColorSpeed = 10f;

		private float sideSmooth = 1f;

		private float sideTarget = 1f;

		private Player Owner
		{
			get
			{
				if (!((Object)(object)gun != (Object)null))
				{
					return null;
				}
				return gun.player;
			}
		}

		private void Start()
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Expected O, but got Unknown
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Expected O, but got Unknown
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Expected O, but got Unknown
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Expected O, but got Unknown
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			ammo = ((Component)this).GetComponent<GunAmmo>();
			if ((Object)(object)ammo == (Object)null || (Object)(object)ammo.populate == (Object)null)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			gun = ((Component)this).GetComponentInParent<Gun>();
			blocks = ((Component)ammo.populate).transform;
			gunCanvas = ((Component)blocks).GetComponentInParent<Canvas>();
			gunRoot = ((Component)ammo).transform.root;
			blocksGroup = ((Component)blocks).GetComponent<CanvasGroup>() ?? ((Component)blocks).gameObject.AddComponent<CanvasGroup>();
			if (blocks.childCount > 0)
			{
				Transform child = blocks.GetChild(0);
				RectTransform val = (RectTransform)(object)((child is RectTransform) ? child : null);
				if (val != null)
				{
					Rect rect = val.rect;
					if (((Rect)(ref rect)).height > 1f)
					{
						rect = val.rect;
						blockHeight = ((Rect)(ref rect)).height;
					}
				}
			}
			if ((Object)(object)gunCanvas != (Object)null)
			{
				Vector3 lossyScale = ((Component)gunCanvas).transform.lossyScale;
				float num = Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.y));
				if (num > 1E-06f)
				{
					unit = num;
				}
			}
			if ((Object)(object)holder == (Object)null)
			{
				GameObject val2 = new GameObject("Customizations.AmmoNumbers");
				Object.DontDestroyOnLoad((Object)val2);
				holder = val2.transform;
			}
			rootGo = new GameObject("AmmoNumber", new Type[2]
			{
				typeof(RectTransform),
				typeof(Canvas)
			});
			rootGo.layer = (((Object)(object)gunCanvas != (Object)null) ? ((Component)gunCanvas).gameObject.layer : ((Component)this).gameObject.layer);
			rootT = rootGo.transform;
			rootT.SetParent(holder, false);
			Canvas component = rootGo.GetComponent<Canvas>();
			component.renderMode = (RenderMode)2;
			if ((Object)(object)gunCanvas != (Object)null)
			{
				component.worldCamera = gunCanvas.worldCamera;
				component.sortingLayerID = gunCanvas.sortingLayerID;
				component.sortingOrder = gunCanvas.sortingOrder + 1;
			}
			((RectTransform)rootT).sizeDelta = new Vector2(blockHeight * 8f, blockHeight * 3f);
			rootT.rotation = Quaternion.identity;
			rootT.localScale = new Vector3(unit, unit, unit);
			gameRing = ReloadRingRef.Invoke(ammo);
			Vector2 val4 = default(Vector2);
			Vector2 anchorMin;
			if ((Object)(object)gameRing != (Object)null)
			{
				gameRingRt = ((Graphic)gameRing).rectTransform;
				GameObject val3 = new GameObject("ReloadRing", new Type[1] { typeof(RectTransform) });
				val3.layer = rootGo.layer;
				ringRt = (RectTransform)val3.transform;
				((Transform)ringRt).SetParent(rootT, false);
				RectTransform obj = ringRt;
				RectTransform obj2 = ringRt;
				RectTransform obj3 = ringRt;
				((Vector2)(ref val4))..ctor(0.5f, 0.5f);
				obj3.pivot = val4;
				anchorMin = (obj2.anchorMax = val4);
				obj.anchorMin = anchorMin;
				ringRt.anchoredPosition = Vector2.zero;
				ring = val3.AddComponent<Image>();
				((Graphic)ring).raycastTarget = false;
				ring.sprite = gameRing.sprite;
				ring.type = gameRing.type;
				ring.fillMethod = gameRing.fillMethod;
				ring.fillOrigin = gameRing.fillOrigin;
				ring.fillClockwise = gameRing.fillClockwise;
				ring.preserveAspect = true;
				((Behaviour)ring).enabled = false;
			}
			GameObject val6 = new GameObject("Text", new Type[1] { typeof(RectTransform) });
			val6.layer = rootGo.layer;
			textRt = (RectTransform)val6.transform;
			((Transform)textRt).SetParent(rootT, false);
			RectTransform obj4 = textRt;
			RectTransform obj5 = textRt;
			RectTransform obj6 = textRt;
			((Vector2)(ref val4))..ctor(0.5f, 0.5f);
			obj6.pivot = val4;
			anchorMin = (obj5.anchorMax = val4);
			obj4.anchorMin = anchorMin;
			textRt.anchoredPosition = Vector2.zero;
			textRt.sizeDelta = new Vector2(blockHeight * 8f, blockHeight * 3f);
			text = val6.AddComponent<TextMeshProUGUI>();
			((TMP_Text)text).alignment = (TextAlignmentOptions)514;
			((TMP_Text)text).enableWordWrapping = false;
			((TMP_Text)text).overflowMode = (TextOverflowModes)0;
			((Graphic)text).raycastTarget = false;
			((TMP_Text)text).fontStyle = (FontStyles)1;
			((TMP_Text)text).outlineWidth = 0.2f;
			((TMP_Text)text).outlineColor = new Color32((byte)0, (byte)0, (byte)0, (byte)200);
			SampleGameColor();
		}

		private void LateUpdate()
		{
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ammo == (Object)null || (Object)(object)text == (Object)null)
			{
				return;
			}
			int num = CurrentAmmo.Invoke(ammo);
			int maxAmmo = ammo.maxAmmo;
			bool value = CustomizationsPlugin.ShowMax.Value;
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			if (Time.unscaledTime >= nextSwordCheck)
			{
				nextSwordCheck = Time.unscaledTime + 0.5f;
				bool flag = CustomizationsPlugin.HideForSwords.Value && HoldingSword();
				if (flag != sword)
				{
					sword = flag;
					animating = true;
				}
			}
			bool num2 = lastCur < 0;
			bool flag2 = maxAmmo != lastMax || value != lastShowMax || seenVersion != CustomizationsPlugin.SettingsVersion;
			seenVersion = CustomizationsPlugin.SettingsVersion;
			lastCur = num;
			lastMax = maxAmmo;
			lastShowMax = value;
			if (num2)
			{
				shown = num;
			}
			if (num2 || flag2)
			{
				ApplyLayout();
				SetText(maxAmmo);
			}
			if (shown != num)
			{
				if (!CustomizationsPlugin.Animate.Value)
				{
					shown = num;
					SetText(maxAmmo);
				}
				else
				{
					int num3 = Mathf.Abs(num - shown);
					float value2 = CustomizationsPlugin.CountDownStep.Value;
					float num4 = ((num < shown) ? value2 : (value2 * 0.35f)) / Mathf.Max(1f, (float)num3 / 8f);
					tickTimer += unscaledDeltaTime;
					while (tickTimer >= num4 && shown != num)
					{
						tickTimer -= num4;
						bool flag3 = num < shown;
						shown += ((!flag3) ? 1 : (-1));
						punch = Mathf.Max(punch, flag3 ? 0.25f : 0.225f);
						SetText(maxAmmo);
					}
				}
				animating = true;
			}
			else
			{
				tickTimer = 0f;
			}
			Measure(unscaledDeltaTime);
			Place(unscaledDeltaTime);
			UpdateRing(unscaledDeltaTime);
			if (animating)
			{
				float num5 = ((shown <= 0) ? 1f : 0f);
				colorT = Mathf.MoveTowards(colorT, num5, unscaledDeltaTime * 10f);
				punch *= Mathf.Exp(-14f * unscaledDeltaTime);
				if (punch < 0.002f)
				{
					punch = 0f;
				}
				float num6 = 1f + punch;
				((Transform)textRt).localScale = new Vector3(num6, num6, 1f);
				Color val = BaseColor();
				if (CustomizationsPlugin.HideWhenEmpty.Value)
				{
					val.a *= 1f - colorT;
					((Graphic)text).color = val;
				}
				else
				{
					((Graphic)text).color = Color.Lerp(val, CustomizationsPlugin.EmptyColor.Value, colorT);
				}
				animating = punch > 0f || colorT != num5 || shown != num;
			}
		}

		private bool HoldingSword()
		{
			if ((Object)(object)gun != (Object)null && (Has(((Component)gun).gameObject, "SwordLength_Mono") || Has(((Component)gun).gameObject, "SwordNoAmmo_Mono")))
			{
				return true;
			}
			if ((Object)(object)ammo != (Object)null && Has(((Component)ammo).gameObject, "SwordNoAmmo_Mono"))
			{
				return true;
			}
			Player owner = Owner;
			if ((Object)(object)owner != (Object)null)
			{
				return Has(((Component)owner).gameObject, "NinjaMono");
			}
			return false;
		}

		private static bool Has(GameObject go, string typeName)
		{
			MonoBehaviour[] components = go.GetComponents<MonoBehaviour>();
			foreach (MonoBehaviour val in components)
			{
				if ((Object)(object)val != (Object)null && ((object)val).GetType().Name == typeName)
				{
					return true;
				}
			}
			return false;
		}

		private Color BaseColor()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			Color? val = Styles.For(Owner).Ammo;
			if (!val.HasValue)
			{
				if (!hasGameColor)
				{
					return FallbackYellow;
				}
				return gameColor;
			}
			return val.GetValueOrDefault();
		}

		private void UpdateRing(float dt)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Invalid comparison between Unknown and I4
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)gameRing == (Object)null || (Object)(object)ring == (Object)null)
			{
				return;
			}
			bool value = CustomizationsPlugin.MoveRing.Value;
			bool flag = value || sword;
			if (((Behaviour)gameRing).enabled == flag)
			{
				((Behaviour)gameRing).enabled = !flag;
			}
			if (!value)
			{
				if (((Behaviour)ring).enabled)
				{
					((Behaviour)ring).enabled = false;
				}
				return;
			}
			CurveAnimation reloadAnim = ammo.reloadAnim;
			bool flag2 = (Object)(object)reloadAnim != (Object)null && (int)reloadAnim.currentState == 0;
			float num = (((Object)(object)gameRingRt != (Object)null) ? Mathf.Abs(((Transform)gameRingRt).localScale.x) : 1f);
			if (flag2)
			{
				maxPop = Mathf.Max(maxPop, num);
				outTimer = 0.4f;
			}
			else
			{
				outTimer -= dt;
			}
			float num2 = ((maxPop > 0.0001f) ? Mathf.Clamp01(num / maxPop) : 1f);
			if (!rootGo.activeSelf || !((Component)gameRing).gameObject.activeInHierarchy || (!flag2 && !(outTimer > 0f)) || num2 < 0.001f)
			{
				if (((Behaviour)ring).enabled)
				{
					((Behaviour)ring).enabled = false;
				}
				return;
			}
			if (!((Behaviour)ring).enabled)
			{
				((Behaviour)ring).enabled = true;
			}
			if ((Object)(object)ring.sprite != (Object)(object)gameRing.sprite)
			{
				ring.sprite = gameRing.sprite;
			}
			ring.fillAmount = gameRing.fillAmount;
			float num3 = blockHeight * 2f * CustomizationsPlugin.FontSize.Value * 1.35f * CustomizationsPlugin.RingSize.Value;
			if (ringRt.sizeDelta.x != num3)
			{
				ringRt.sizeDelta = new Vector2(num3, num3);
			}
			((Transform)ringRt).localScale = new Vector3(num2, num2, 1f);
			Color color = (Color)(((??)Styles.For(Owner).Ring) ?? BaseColor());
			color.a = ((Graphic)gameRing).color.a;
			((Graphic)ring).color = color;
		}

		private void SetText(int max)
		{
			if (shown > 0 || !CustomizationsPlugin.HideWhenEmpty.Value)
			{
				((TMP_Text)text).text = (lastShowMax ? $"{shown} / {max}" : shown.ToString());
			}
		}

		private void ApplyLayout()
		{
			blocksGroup.alpha = (CustomizationsPlugin.HideBlocks.Value ? 0f : 1f);
			((TMP_Text)text).fontSize = blockHeight * 2f * CustomizationsPlugin.FontSize.Value;
			animating = true;
		}

		private void Measure(float dt)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			int childCount = blocks.childCount;
			if (childCount != lastChildCount)
			{
				lastChildCount = childCount;
				skipFrames = 3;
				measureFrames = 45;
				candPerp = -1f;
			}
			if (skipFrames > 0)
			{
				skipFrames--;
			}
			else if (measureFrames > 0)
			{
				measureFrames--;
				Vector3 position = gunRoot.position;
				Vector3 up = gunRoot.up;
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(0f - up.y, up.x, 0f);
				float num = float.MaxValue;
				float num2 = float.MinValue;
				float num3 = float.MaxValue;
				int num4 = 0;
				for (int i = 0; i < childCount; i++)
				{
					Transform child = blocks.GetChild(i);
					if (((Component)child).gameObject.activeSelf)
					{
						Vector3 val2 = child.position - position;
						float num5 = val2.x * up.x + val2.y * up.y;
						float num6 = Mathf.Abs(val2.x * val.x + val2.y * val.y);
						if (num5 < num)
						{
							num = num5;
						}
						if (num5 > num2)
						{
							num2 = num5;
						}
						if (num6 < num3)
						{
							num3 = num6;
						}
						num4++;
					}
				}
				if (num4 > 0)
				{
					float num7 = (num + num2) * 0.5f;
					if (num3 > candPerp && num3 < 2f && Mathf.Abs(num7) < 2f)
					{
						candPerp = num3;
						candAlong = num7;
					}
					if (candPerp >= 0f)
					{
						alongTarget = candAlong;
						perpTarget = candPerp;
						if (!measured)
						{
							measured = true;
							along = alongTarget;
							perp = perpTarget;
						}
					}
				}
				if (measureFrames == 0 && placeLogs++ < 3)
				{
					ManualLogSource log = Log;
					string obj = $"gun '{((Object)gunRoot).name}': blocks {alongTarget:F3} along the barrel, {perpTarget:F3} off it; unit={unit:G4}, block={blockHeight}";
					object obj2;
					if (!((Object)(object)gameRingRt != (Object)null))
					{
						obj2 = "";
					}
					else
					{
						Rect rect = gameRingRt.rect;
						obj2 = $", game ring {((Rect)(ref rect)).width:F0} wide";
					}
					log.LogInfo((object)(obj + (string?)obj2));
				}
			}
			if (along != alongTarget)
			{
				along = Mathf.MoveTowards(along, alongTarget, dt * 3f);
			}
			if (perp != perpTarget)
			{
				perp = Mathf.MoveTowards(perp, perpTarget, dt * 3f);
			}
		}

		private void Place(float dt)
		{
			//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_0079: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			bool flag = ((Object)(object)gunCanvas == (Object)null || ((Behaviour)gunCanvas).isActiveAndEnabled) && !sword;
			if (rootGo.activeSelf != flag)
			{
				rootGo.SetActive(flag);
			}
			if (flag)
			{
				Vector3 up = gunRoot.up;
				float num = blockHeight * unit;
				float num2 = Mathf.Max(perp, num * 1.2f);
				Vector3 position = gunRoot.position;
				float num3 = position.x + up.x * along;
				float num4 = position.y + up.y * along;
				if (up.x > 0.2f)
				{
					sideTarget = 1f;
				}
				else if (up.x < -0.2f)
				{
					sideTarget = -1f;
				}
				sideSmooth = Mathf.MoveTowards(sideSmooth, sideTarget, dt * 8f);
				Vector3 position2 = default(Vector3);
				if (up.y >= 0f)
				{
					position2.x = num3;
					position2.y = num4 + num2 + up.y * Mathf.Abs(along);
				}
				else
				{
					position2.x = num3 + (0f - up.y) * sideSmooth * num2;
					position2.y = num4 + Mathf.Abs(up.x) * num2;
				}
				position2.x += CustomizationsPlugin.OffsetX.Value * num;
				position2.y += CustomizationsPlugin.OffsetY.Value * num;
				position2.z = (((Object)(object)gunCanvas != (Object)null) ? ((Component)gunCanvas).transform.position.z : position.z);
				rootT.position = position2;
			}
		}

		private void SampleGameColor()
		{
			//IL_003e: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			Image val = null;
			for (int i = 0; i < blocks.childCount; i++)
			{
				if (!((Object)(object)val == (Object)null))
				{
					break;
				}
				val = ((Component)blocks.GetChild(i)).GetComponentInChildren<Image>(true);
			}
			if ((Object)(object)val != (Object)null && IsColored(((Graphic)val).color))
			{
				Use(((Graphic)val).color);
			}
			else if ((Object)(object)gameRing != (Object)null && IsColored(((Graphic)gameRing).color))
			{
				Use(((Graphic)gameRing).color);
			}
			else if ((Object)(object)ammo.cooldownRing != (Object)null && IsColored(((Graphic)ammo.cooldownRing).color))
			{
				Use(((Graphic)ammo.cooldownRing).color);
			}
		}

		private static bool IsColored(Color c)
		{
			//IL_0000: 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)
			float num = default(float);
			float num2 = default(float);
			float num3 = default(float);
			Color.RGBToHSV(c, ref num, ref num2, ref num3);
			if (num2 > 0.2f && num3 > 0.2f)
			{
				return c.a > 0.05f;
			}
			return false;
		}

		private void Use(Color c)
		{
			//IL_000d: 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)
			c.a = 1f;
			gameColor = c;
			hasGameColor = true;
		}

		private void OnEnable()
		{
			animating = true;
			if ((Object)(object)rootGo != (Object)null)
			{
				rootGo.SetActive(true);
			}
		}

		private void OnDisable()
		{
			if ((Object)(object)rootGo != (Object)null)
			{
				rootGo.SetActive(false);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)rootGo != (Object)null)
			{
				Object.Destroy((Object)(object)rootGo);
			}
			if ((Object)(object)blocksGroup != (Object)null)
			{
				blocksGroup.alpha = 1f;
			}
			if ((Object)(object)gameRing != (Object)null)
			{
				((Behaviour)gameRing).enabled = true;
			}
		}
	}
	internal enum HudPart
	{
		Ammo,
		Ring,
		Bar,
		BarBack,
		BarDeplete,
		Health,
		Damage,
		Heal
	}
	internal static class HudColors
	{
		public const int Count = 8;

		public const string Game = "GAME";

		public const string Same = "SAME";

		private const string DefaultName = "Default";

		private static readonly (string name, string token)[] Basic = new(string, string)[9]
		{
			("Red", "#FF3B30"),
			("Orange", "#FF9500"),
			("Yellow", "#FFCC00"),
			("Green", "#34C759"),
			("Cyan", "#32D7FF"),
			("Blue", "#3B82F6"),
			("Purple", "#AF52DE"),
			("Pink", "#FF5FA2"),
			("White", "#FFFFFF")
		};

		private static readonly (string name, string token) Black = (name: "Black", token: "#1A1A1A");

		private static readonly (string name, string token)[][] Lists = new(string, string)[8][]
		{
			new(string, string)[10]
			{
				Basic[0],
				Basic[1],
				("Default", "GAME"),
				Basic[2],
				Basic[3],
				Basic[4],
				Basic[5],
				Basic[6],
				Basic[7],
				Basic[8]
			},
			new(string, string)[1] { ("Default", "SAME") }.Concat<(string, string)>(Basic).ToArray(),
			new(string, string)[1] { ("Default", "GAME") }.Concat<(string, string)>(Basic).ToArray(),
			new(string, string)[2]
			{
				("Default", "GAME"),
				Black
			}.Concat<(string, string)>(Basic).ToArray(),
			new(string, string)[1] { ("Default", "GAME") }.Concat<(string, string)>(Basic).Concat(new(string, string)[1] { Black }).ToArray(),
			new(string, string)[1] { ("Default", "GAME") }.Concat<(string, string)>(Basic).ToArray(),
			new(string, string)[1] { ("Default", Basic[0].token) }.Concat(Basic.Skip(1)).ToArray(),
			new(string, string)[1] { ("Default", "GAME") }.Concat<(string, string)>(Basic).ToArray()
		};

		public static readonly string[] Names = new string[8] { "AMMO", "RING", "BAR", "BAR BACK", "BAR DEPLETE", "HEALTH", "DAMAGE", "HEALING" };

		private static bool Offers((string name, string token)[] list, string token)
		{
			for (int i = 0; i < list.Length; i++)
			{
				if (list[i].token == token)
				{
					return true;
				}
			}
			return false;
		}

		private static int Home((string name, string token)[] list)
		{
			for (int i = 0; i < list.Length; i++)
			{
				if (list[i].name == "Default")
				{
					return i;
				}
			}
			return 0;
		}

		private static int IndexOf(HudPart part, string token)
		{
			//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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			(string, string)[] array = Lists[(int)part];
			int result = Home(array);
			if (token == null)
			{
				return result;
			}
			if (token == "GAME" || token == "SAME")
			{
				for (int i = 0; i < array.Length; i++)
				{
					if (array[i].Item2 == token)
					{
						return i;
					}
				}
				return result;
			}
			Color? val = Parse(token);
			if (!val.HasValue)
			{
				return result;
			}
			for (int j = 0; j < array.Length; j++)
			{
				Color? val2 = Parse(array[j].Item2);
				if (val2.HasValue && Color.op_Implicit(val2.Value) == Color.op_Implicit(val.Value))
				{
					return j;
				}
			}
			return -1;
		}

		public static string Next(HudPart part, string token)
		{
			(string, string)[] array = Lists[(int)part];
			int num = Home(array);
			int num2 = IndexOf(part, token);
			int num3 = ((num2 < 0) ? num : ((num2 + 1) % array.Length));
			if (num3 != num)
			{
				return array[num3].Item2;
			}
			return null;
		}

		public static string Label(HudPart part, string token)
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			(string, string)[] array = Lists[(int)part];
			int num = IndexOf(part, token);
			Color? val = ((num < 0) ? Parse(token) : ((Color?)null));
			if (num < 0 && !val.HasValue)
			{
				num = Home(array);
			}
			string text;
			string text2;
			if (num >= 0)
			{
				text = array[num].Item1.ToUpperInvariant();
				text2 = ((array[num].Item1 == "Default" || array[num].Item2 == "GAME" || array[num].Item2 == "SAME") ? null : array[num].Item2);
			}
			else
			{
				text2 = "#" + ColorUtility.ToHtmlStringRGB(val.Value);
				text = text2;
			}
			string text3 = Names[(int)part];
			if (text2 != null)
			{
				return text3 + ": <color=" + text2 + ">" + text + "</color>";
			}
			return text3 + ": " + text;
		}

		public static IEnumerable<string> AllLabels(HudPart part)
		{
			(string name, string token)[] list = Lists[(int)part];
			int home = Home(list);
			for (int i = 0; i < list.Length; i++)
			{
				yield return Label(part, (i == home) ? null : list[i].token);
			}
		}

		public static Color? Resolve(HudPart part, string token)
		{
			(string, string)[] array = Lists[(int)part];
			string item = array[Home(array)].Item2;
			string text = token ?? item;
			if ((text == "GAME" || text == "SAME") && !Offers(array, text))
			{
				text = item;
			}
			if (text == "GAME" || text == "SAME")
			{
				return null;
			}
			return Parse(text);
		}

		public static string Clean(string token)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(token))
			{
				switch (token)
				{
				case "~":
					break;
				case "GAME":
				case "SAME":
					return token;
				default:
				{
					Color? val = Parse(token);
					if (!val.HasValue)
					{
						return null;
					}
					return "#" + ColorUtility.ToHtmlStringRGB(val.Value);
				}
				}
			}
			return null;
		}

		public static Color? Parse(string value)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(value))
			{
				return null;
			}
			value = value.Trim();
			if (value.Equals("Default", StringComparison.OrdinalIgnoreCase) || value == "GAME" || value == "SAME")
			{
				return null;
			}
			(string, string)[] basic = Basic;
			for (int i = 0; i < basic.Length; i++)
			{
				(string, string) tuple = basic[i];
				if (tuple.Item1.Equals(value, StringComparison.OrdinalIgnoreCase))
				{
					value = tuple.Item2;
					break;
				}
			}
			if (!value.StartsWith("#"))
			{
				value = "#" + value;
			}
			Color value2 = default(Color);
			if (!ColorUtility.TryParseHtmlString(value, ref value2))
			{
				return null;
			}
			value2.a = 1f;
			return value2;
		}
	}
	internal class HudStyle
	{
		public readonly Color?[] C = new Color?[8];

		public static readonly HudStyle Defaults = FromTokens(null);

		public Color? Ammo => C[0];

		public Color? Ring => C[1];

		public Color? Bar => C[2];

		public Color? BarBack => C[3];

		public Color? BarDeplete => C[4];

		public Color? Health => C[5];

		public Color? Damage => C[6];

		public Color? Heal => C[7];

		public static HudStyle FromTokens(string[] tokens)
		{
			HudStyle hudStyle = new HudStyle();
			for (int i = 0; i < 8; i++)
			{
				hudStyle.C[i] = HudColors.Resolve((HudPart)i, (tokens != null && i < tokens.Length) ? tokens[i] : null);
			}
			return hudStyle;
		}

		public string Serialize()
		{
			return "3|" + string.Join("|", C.Select((Color? c) => (!c.HasValue) ? "-" : ColorUtility.ToHtmlStringRGB(c.Value)));
		}

		public static HudStyle Parse(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return null;
			}
			string[] array = s.Split(new char[1] { '|' });
			HudStyle hudStyle = new HudStyle();
			if (array[0] == "3" && array.Length >= 9)
			{
				for (int i = 0; i < 8; i++)
				{
					hudStyle.C[i] = C(array[i + 1]);
				}
				return hudStyle;
			}
			if ((array[0] == "1" || array[0] == "2") && array.Length >= 6)
			{
				hudStyle.C[0] = C(array[1]);
				hudStyle.C[2] = C(array[2]);
				hudStyle.C[5] = C(array[3]);
				hudStyle.C[6] = C(array[4]);
				hudStyle.C[7] = C(array[5]);
				if (array[0] == "2" && array.Length >= 7)
				{
					hudStyle.C[1] = C(array[6]);
				}
				return hudStyle;
			}
			return null;
			static Color? C(string v)
			{
				if (!(v == "-"))
				{
					return HudColors.Parse("#" + v);
				}
				return null;
			}
		}
	}
	internal static class Styles
	{
		private const int LocalSlots = 4;

		private static readonly HudStyle[] local = Enumerable.Repeat(HudStyle.Defaults, 4).ToArray();

		private static readonly string[] localKey = new string[4];

		private static readonly Dictionary<int, HudStyle> remote = new Dictionary<int, HudStyle>();

		public static int Version;

		public static HudStyle Mine => local[0];

		public static void Tick()
		{
			CharacterCreatorHandler instance = CharacterCreatorHandler.instance;
			bool flag = false;
			bool flag2 = false;
			for (int i = 0; i < 4; i++)
			{
				FaceExtras faceExtras = FaceStore.Get(((Object)(object)instance != (Object)null && instance.selectedPlayerFaces != null && i < instance.selectedPlayerFaces.Length) ? instance.selectedPlayerFaces[i] : null);
				string text = ((faceExtras != null) ? faceExtras.ColorKey() : "");
				if (!(text == localKey[i]))
				{
					localKey[i] = text;
					local[i] = ((faceExtras != null) ? HudStyle.FromTokens(faceExtras.Colors) : HudStyle.Defaults);
					flag = true;
					if (i == 0)
					{
						flag2 = true;
					}
				}
			}
			if (flag)
			{
				Changed();
			}
			if (flag2)
			{
				StyleNet.SendLocalSoon();
			}
		}

		public static void SetRemote(int actor, HudStyle s)
		{
			remote[actor] = s;
			Changed();
		}

		private static void Changed()
		{
			Version++;
			CustomizationsPlugin.SettingsVersion++;
			TooMuchHudHooks.RefreshHealthTexts();
		}

		public static HudStyle For(Player p)
		{
			if ((Object)(object)p == (Object)null)
			{
				return HudStyle.Defaults;
			}
			PhotonView val = (((Object)(object)p.data != (Object)null) ? p.data.view : null);
			if (!PhotonNetwork.OfflineMode && PhotonNetwork.CurrentRoom != null)
			{
				if ((Object)(object)val != (Object)null && !val.IsMine)
				{
					if (!remote.TryGetValue(val.OwnerActorNr, out var value))
					{
						return HudStyle.Defaults;
					}
					return value;
				}
				return local[0];
			}
			int playerID = p.playerID;
			if (playerID < 0 || playerID >= 4)
			{
				return HudStyle.Defaults;
			}
			return local[playerID];
		}
	}
	internal static class StyleNet
	{
		private static float sendAt = -1f;

		public static void SendLocalSoon()
		{
			sendAt = Time.unscaledTime + 0.5f;
		}

		public static void Tick()
		{
			if (sendAt >= 0f && Time.unscaledTime >= sendAt)
			{
				sendAt = -1f;
				SendLocal();
			}
		}

		public static void SendLocal()
		{
			if (!PhotonNetwork.OfflineMode && PhotonNetwork.CurrentRoom != null && PhotonNetwork.LocalPlayer != null)
			{
				NetworkingManager.RPC_Others(typeof(StyleNet), "RPCA_Style", new object[2]
				{
					PhotonNetwork.LocalPlayer.ActorNumber,
					Styles.Mine.Serialize()
				});
			}
		}

		[UnboundRPC]
		private static void RPCA_Style(int actor, string data)
		{
			HudStyle hudStyle = HudStyle.Parse(data);
			if (hudStyle != null)
			{
				Styles.SetRemote(actor, hudStyle);
			}
		}
	}
	[HarmonyPatch(typeof(Player), "Start")]
	internal static class Player_Start_Share
	{
		private static float lastShare = -10f;

		private static void Postfix(Player __instance)
		{
			try
			{
				if (!PhotonNetwork.OfflineMode && PhotonNetwork.CurrentRoom != null && (((Object)(object)__instance.data != (Object)null && (Object)(object)__instance.data.view != (Object)null && __instance.data.view.IsMine) || !(Time.unscaledTime - lastShare < 1f)))
				{
					lastShare = Time.unscaledTime;
					Styles.Tick();
					StyleNet.SendLocal();
					CharacterCreatorHandler instance = CharacterCreatorHandler.instance;
					object face;
					if (instance == null)
					{
						face = null;
					}
					else
					{
						PlayerFace[] selectedPlayerFaces = instance.selectedPlayerFaces;
						face = ((selectedPlayerFaces != null) ? selectedPlayerFaces[0] : null);
					}
					FaceNet.Send((PlayerFace)face);
				}
			}
			catch (Exception ex)
			{
				CustomizationsPlugin.Log.LogWarning((object)("Could not share colors/face: " + ex.Message));
			}
		}
	}
	[HarmonyPatch(typeof(HealthHandler), "DoDamage")]
	internal static class HealthHandler_DoDamage
	{
		internal static readonly Dictionary<Player, Player> LastAttacker = new Dictionary<Player, Player>();

		private static void Postfix(HealthHandler __instance, Player damagingPlayer)
		{
			if (!((Object)(object)damagingPlayer == (Object)null) && !((Object)(object)__instance == (Object)null))
			{
				Player component = ((Component)__instance).GetComponent<Player>();
				if ((Object)(object)component != (Object)null)
				{
					LastAttacker[component] = damagingPlayer;
				}
			}
		}
	}
	internal class HudColorApplier : MonoBehaviour
	{
		private class Bar
		{
			public Image hp;

			public Image white;

			public Color hpC;

			public Color whiteC;

			public Image[] back;

			public Color[] backC;
		}

		private readonly Dictionary<HealthBar, Bar> bars = new Dictionary<HealthBar, Bar>();

		private float next;

		private bool logged;

		private void Update()
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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)
			StyleNet.Tick();
			if (Time.unscaledTime < next)
			{
				return;
			}
			next = Time.unscaledTime + 0.25f;
			Styles.Tick();
			PlayerManager instance = PlayerManager.instance;
			if ((Object)(object)instance == (Object)null || instance.players == null)
			{
				return;
			}
			foreach (Player player in instance.players)
			{
				if ((Object)(object)player == (Object)null)
				{
					continue;
				}
				HealthBar componentInChildren = ((Component)player).GetComponentInChildren<HealthBar>(true);
				if (!((Object)(object)componentInChildren == (Object)null) && !((Object)(object)componentInChildren.hp == (Object)null))
				{
					Bar bar = GetBar(componentInChildren);
					HudStyle hudStyle = Styles.For(player);
					Set(bar.hp, hudStyle.Bar, bar.hpC);
					Set(bar.white, hudStyle.BarDeplete, bar.whiteC);
					for (int i = 0; i < bar.back.Length; i++)
					{
						Set(bar.back[i], hudStyle.BarBack, bar.backC[i]);
					}
				}
			}
			if (bars.Count <= 64)
			{
				return;
			}
			foreach (HealthBar item in bars.Keys.Where((HealthBar k) => (Object)(object)k == (Object)null).ToList())
			{
				bars.Remove(item);
			}
		}

		private static void Set(Image img, Color? want, Color original)
		{
			//IL_000a: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)img == (Object)null))
			{
				Color val = original;
				if (want.HasValue)
				{
					val = want.Value;
					val.a = original.a;
				}
				if (((Graphic)img).color != val)
				{
					((Graphic)img).color = val;
				}
			}
		}

		private Bar GetBar(HealthBar hb)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			if (bars.TryGetValue(hb, out var value))
			{
				return value;
			}
			value = new Bar
			{
				hp = hb.hp,
				white = hb.white
			};
			value.hpC = ((Graphic)hb.hp).color;
			value.whiteC = (((Object)(object)hb.white != (Object)null) ? ((Graphic)hb.white).color : Color.white);
			value.back = (from i in ((Component)hb).GetComponentsInChildren<Image>(true)
				where (Object)(object)i != (Object)(object)hb.hp && (Object)(object)i != (Object)(object)hb.white && !Under(((Component)i).transform, (Component)(object)hb.hp) && !Under(((Component)i).transform, (Component)(object)hb.white)
				select i).ToArray();
			value.backC = value.back.Select((Image i) => ((Graphic)i).color).ToArray();
			bars[hb] = value;
			if (!logged)
			{
				logged = true;
				StringBuilder stringBuilder = new StringBuilder("Health bar parts: fill '").Append(((Object)hb.hp).name).Append("' #").Append(ColorUtility.ToHtmlStringRGBA(value.hpC));
				if ((Object)(object)hb.white != (Object)null)
				{
					stringBuilder.Append(", deplete '").Append(((Object)hb.white).name).Append("' #")
						.Append(ColorUtility.ToHtmlStringRGBA(value.whiteC));
				}
				for (int num = 0; num < value.back.Length; num++)
				{
					stringBuilder.Append(", background '").Append(((Object)value.back[num]).name).Append("' #")
						.Append(ColorUtility.ToHtmlStringRGBA(value.backC[num]));
				}
				CustomizationsPlugin.Log.LogInfo((object)stringBuilder.ToString());
			}
			return value;
		}

		private static bool Under(Transform t, Component root)
		{
			if ((Object)(object)root != (Object)null && (Object)(object)t != (Object)(object)root.transform)
			{
				return t.IsChildOf(root.transform);
			}
			return false;
		}
	}
	internal static class TooMuchHudHooks
	{
		private struct CanvasOrder
		{
			public Canvas canvas;

			public bool overrideSorting;

			public int order;

			public int layer;
		}

		internal static bool Hooked;

		private static Type healthType;

		private static FieldInfo lastHealthField;

		private static FieldInfo playerField;

		private static FieldInfo tmField;

		private static int errors;

		internal static bool MenuShared;

		internal static void Apply(Harmony harmony, ManualLogSource log)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_016d: Expected O, but got Unknown
			bool flag = false;
			bool flag2 = false;
			try
			{
				MethodInfo methodInfo = AccessTools.Method(AccessTools.TypeByName("TooMuchHUD.StatusHUDMod"), "SpawnText", (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(TooMuchHudHooks), "SpawnTextPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					flag = true;
				}
			}
			catch (Exception ex)
			{
				log.LogWarning((object)("TooMuchHUD damage/heal color hook failed: " + ex.Message));
			}
			try
			{
				healthType = AccessTools.TypeByName("TooMuchHUD.HealthBarText");
				MethodInfo methodInfo2 = AccessTools.Method(healthType, "Update", (Type[])null, (Type[])null);
				if (methodInfo2 != null)
				{
					lastHealthField = AccessTools.Field(healthType, "lastHealth");
					playerField = AccessTools.Field(healthType, "player");
					tmField = AccessTools.Field(healthType, "tm");
					harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(TooMuchHudHooks), "HealthPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					flag2 = true;
				}
			}
			catch (Exception ex2)
			{
				log.LogWarning((object)("TooMuchHUD health color hook failed: " + ex2.Message));
			}
			try
			{
				MethodInfo methodInfo3 = AccessTools.Method(healthType ?? AccessTools.TypeByName("TooMuchHUD.HealthBarText"), "Start", (Type[])null, (Type[])null);
				if (methodInfo3 != null)
				{
					harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(typeof(TooMuchHudHooks), "TextStartPrefix", (Type[])null), new HarmonyMethod(typeof(TooMuchHudHooks), "TextStartPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			catch (Exception ex3)
			{
				log.LogWarning((object)("TooMuchHUD health bar draw-order fix failed: " + ex3.Message));
			}
			try
			{
				MethodInfo methodInfo4 = AccessTools.Method(AccessTools.TypeByName("TooMuchHUD.StatusHUDMod"), "CreateSettingsMenu", (Type[])null, (Type[])null);
				if (methodInfo4 != null)
				{
					harmony.Patch((MethodBase)methodInfo4, (HarmonyMethod)null, new HarmonyMethod(typeof(TooMuchHudHooks), "MenuPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					MenuShared = true;
				}
			}
			catch (Exception ex4)
			{
				log.LogWarning((object)("TooMuchHUD menu hook failed: " + ex4.Message));
			}
			Hooked = flag || flag2;
			log.LogInfo((object)("TooMuchHUD found: damage/heal colors " + (flag ? "hooked" : "NOT hooked") + ", health colors " + (flag2 ? "hooked" : "NOT hooked") + ", settings " + (MenuShared ? "on TooMuchHUD's page" : "on their own page") + "."));
		}

		private static void TextStartPrefix(MonoBehaviour __instance, out CanvasOrder __state)
		{
			__state = default(CanvasOrder);
			try
			{
				HealthBar val = (((Object)(object)__instance != (Object)null) ? ((Component)__instance).GetComponentInChildren<HealthBar>() : null);
				Canvas val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInChildren<Canvas>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					__state = new CanvasOrder
					{
						canvas = val2,
						overrideSorting = val2.overrideSorting,
						order = val2.sortingOrder,
						layer = val2.sortingLayerID
					};
				}
			}
			catch (Exception ex)
			{
				if (errors++ < 3)
				{
					CustomizationsPlugin.Log.LogWarning((object)("Health bar draw order: " + ex.Message));
				}
			}
		}

		private static void TextStartPostfix(CanvasOrder __state)
		{
			Canvas canvas = __state.canvas;
			if (!((Object)(object)canvas == (Object)null))
			{
				canvas.overrideSorting = __state.overrideSorting;
				canvas.sortingOrder = __state.order;
				canvas.sortingLayerID = __state.layer;
			}
		}

		private static void MenuPostfix(GameObject menu)
		{
			try
			{
				CustomizationsPlugin.BuildMenu(menu, nested: true);
			}
			catch (Exception ex)
			{
				CustomizationsPlugin.Log.LogWarning((object)("Could not add settings to the TooMuchHUD page: " + ex));
			}
		}

		private static void SpawnTextPrefix(Vector3 pos, ref Color c, bool isHealing)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Player val = Nearest(pos);
				if (!((Object)(object)val == (Object)null))
				{
					Color? val2;
					if (isHealing)
					{
						val2 = Styles.For(val).Heal;
					}
					else
					{
						HealthHandler_DoDamage.LastAttacker.TryGetValue(val, out var value);
						val2 = (((Object)(object)value != (Object)null) ? Styles.For(value).Damage : ((Color?)null));
					}
					if (val2.HasValue)
					{
						c = val2.Value;
					}
				}
			}
			catch (Exception ex)
			{
				if (errors++ < 3)
				{
					CustomizationsPlugin.Log.LogWarning((object)("Damage number color failed: " + ex.Message));
				}
			}
		}

		private static Player Nearest(Vector3 pos)
		{
			//IL_0049: 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)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			PlayerManager instance = PlayerManager.instance;
			if ((Object)(object)instance == (Object)null || instance.players == null)
			{
				return null;
			}
			Player result = null;
			float num = 6f;
			foreach (Player player in instance.players)
			{
				if (!((Object)(object)player == (Object)null))
				{
					float num2 = Vector2.Distance(Vector2.op_Implicit(((Component)player).transform.position), Vector2.op_Implicit(pos));
					if (num2 < num)
					{
						num = num2;
						result = player;
					}
				}
			}
			return result;
		}

		private static void HealthPostfix(object __instance)
		{
			//IL_005a: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				object? obj = playerField?.GetValue(__instance);
				Player val = (Player)((obj is Player) ? obj : null);
				object? obj2 = tmField?.GetValue(__instance);
				TextMeshProUGUI val2 = (TextMeshProUGUI)((obj2 is TextMeshProUGUI) ? obj2 : null);
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null))
				{
					Color? health = Styles.For(val).Health;
					if (health.HasValue && ((Graphic)val2).color != health.Value)
					{
						((Graphic)val2).color = health.Value;
					}
				}
			}
			catch (Exception ex)
			{
				if (errors++ < 3)
				{
					CustomizationsPlugin.Log.LogWarning((object)("Health number color failed: " + ex.Message));
				}
			}
		}

		internal static void RefreshHealthTexts()
		{
			if (healthType == null || lastHealthField == null)
			{
				return;
			}
			try
			{
				Object[] array = Object.FindObjectsOfType(healthType);
				foreach (Object obj in array)
				{
					lastHealthField.SetValue(obj, -99999f);
				}
			}
			catch (Exception)
			{
			}
		}
	}
	internal static class EditorStyle
	{
		private class State
		{
			public CharacterCreator c;

			public CharacterCreatorButtonSpawner spawner;

			public RectTransform canvas;

			public RectTransform items;

			public RectTransform categories;

			public RectTransform toggler;

			public RectTransform done;

			public RectTransform hint;

			public GridLayoutGroup grid;

			public Transform faces;

			public RectTransform backdrop;

			public RectTransform leftPanel;

			public RectTransform gridPanel;

			public RectTransform highlight;

			public bool ok;

			public bool open;

			public bool styledTools;

			public int activeTab;

			public int cols = 16;

			public bool cascade;

			public float top;

			public float gridX;

			public float gridTop;

			public float gridW;

			public float tile;

			public Vector2 hlFrom;

			public Vector2 hlTo;

			public Vector2 hlCur;

			public Vector2 hlSize;

			public float hlP = 1f;

			public bool hlSet;

			public float gpFrom;

			public float gpTo;

			public float gpCur;

			public float gpP = 1f;

			public bool gpSet;

			public Color accent;

			public float openedAt;

			public float clock;

			public int revealNext;

			public float left;

			public int measureWait;

			public RectTransform slotsRoot;

			public readonly List<FaceSlot> slots = new List<FaceSlot>();

			public float nextSlotsCheck;

			public int slotPress = -1;

			public RectTransform demo;

			public RectTransform scrollTrack;

			public RectTransform scrollThumb;

			public int rowOffset;

			public int visibleRows = 99;

			public int totalRows;

			public TextMeshProUGUI credit;

			public int pagedPart = -1;

			public int lastNav = -1;
		}

		private class FaceSlot
		{
			public RectTransform tile;

			public GameObject dot;

			public ProceduralImage bg;

			public float hover;

			public CharacterCreatorItemEquipper eq;

			public string shows;

			public float k = 1f;
		}

		private static readonly Color PanelColor = new Color(0.07f, 0.08f, 0.105f, 0.84f);

		private static readonly Color EdgeColor = new Color(1f, 1f, 1f, 0.07f);

		private static readonly Color TabColor = new Color(0.15f, 0.16f, 0.2f, 0.96f);

		private static readonly Color TabText = new Color(0.7f, 0.72f, 0.77f, 1f);

		private static readonly Color TileColor = new Color(0.16f, 0.17f, 0.21f, 1f);

		private static readonly Color ToolColor = new Color(0.14f, 0.15f, 0.19f, 0.96f);

		private const float PanelRadius = 12f;

		private const float TileRadius = 7f;

		private const float Pad = 12f;

		private const float LeftW = 280f;

		private const float ColumnGap = 40f;

		private const float TabH = 26f;

		private const float TabGap = 8f;

		private const float CellGap = 4f;

		private const float CardH = 215f;

		private const float DemoH = 168f;

		private const float DemoGap = 12f;

		private const string Credit = "Dialed by: <b>ImmobileNoah</b>";

		private const float CardDelay = 0.08f;

		private const float RevealStart = 0.16f;

		private const float RevealStep = 0.022f;

		private const float RevealTime = 0.26f;

		private static readonly Dictionary<CharacterCreator, State> states = new Dictionary<CharacterCreator, State>();

		private static CharacterCreator current;

		private static int errors;

		private static readonly Dictionary<CharacterCreator, int> shownParts = new Dictionary<CharacterCreator, int>();

		private static readonly List<Transform> sectionTiles = new List<Transform>();

		private static readonly HashSet<int> styledTiles = new HashSet<int>();

		private const float SlotMax = 26f;

		private const float SlotGap = 4f;

		private static Transform staging;

		internal static float Dt => Mathf.Min(Time.unscaledDeltaTime, 1f / 30f);

		internal static void Opening(CharacterCreator c)
		{
			if ((Object)(object)c != (Object)null && states.TryGetValue(c, out var value))
			{
				value.open = false;
			}
			current = null;
			Tick(c);
		}

		internal static void Tick(CharacterCreator c)
		{
			try
			{
				if ((Object)(object)c != (Object)(object)current)
				{
					if ((Object)(object)current != (Object)null && states.TryGetValue(current, out var value))
					{
						value.open = false;
					}
					current = c;
				}
				if ((Object)(object)c == (Object)null)
				{
					return;
				}
				if (!states.TryGetValue(c, out var value2))
				{
					Dictionary<CharacterCreator, State> dictionary = states;
					State obj = new State
					{
						c = c
					};
					value2 = obj;
					dictionary[c] = obj;
				}
				if (!value2.open)
				{
					value2.open = true;
					Open(value2);
				}
				else
				{
					value2.clock += Dt;
				}
				if (value2.ok)
				{
					if (!value2.styledTools)
					{
						StyleTools(value2);
					}
					HideExtras(value2);
					if (value2.cascade)
					{
						value2.cascade = false;
						Cascade(value2, 0.05f);
					}
					ScrollInput(value2);
					SlotInput(value2);
					UpdateHighlight(value2);
					UpdateGridPanel(value2);
					if (Time.unscaledTime >= value2.nextSlotsCheck)
					{
						value2.nextSlotsCheck = Time.unscaledTime + 0.5f;
						UpdateSlots(value2);
					}
				}
			}
			catch (Exception ex)
			{
				if (errors++ < 5)
				{
					CustomizationsPlugin.Log.LogWarning((object)("Editor restyle failed: " + ex));
				}
			}
		}

		internal static void TabOpened(CharacterCreatorButtonSpawner sp, int id)
		{
			CharacterCreator val = (((Object)(object)sp != (Object)null) ? ((Component)sp).GetComponent<CharacterCreator>() : null);
			if ((Object)(object)val != (Object)null && states.TryGetValue(val, out var value))
			{
				value.activeTab = Mathf.Clamp(id, 0, 3);
			}
		}

		internal static void SectionShown(CharacterCreatorButtonSpawner sp, CharacterItemType target, int slotNr)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			CharacterCreator val = (((Object)(object)sp != (Object)null) ? ((Component)sp).GetComponent<CharacterCreator>() : null);
			if (!((Object)(object)val == (Object)null))
			{
				int num = FaceExtras.PartIndex(target, slotNr);
				shownParts[val] = num;
				if ((Object)(object)FacePanel.Instance != (Object)null)
				{
					FacePanel.Instance.SectionOpened(val, num);
				}
			}
		}

		internal static int ShownPart(CharacterCreator c)
		{
			if (!((Object)(object)c != (Object)null) || !shownParts.TryGetValue(c, out var value))
			{
				return -1;
			}
			return value;
		}

		internal static void ItemsRebuilt(CharacterCreatorButtonSpawner sp, int part)
		{
			try
			{
				CharacterCreator val = (((Object)(object)sp != (Object)null) ? ((Component)sp).GetComponent<CharacterCreator>() : null);
				if ((Object)(object)val != (Object)null && states.TryGetValue(val, out var value) && value.ok && value.open)
				{
					value.measureWait = 2;
					if (part != value.pagedPart)
					{
						value.pagedPart = part;
						value.rowOffset = 0;
					}
					ApplyPaging(value);
					Cascade(value, 0.03f);
				}
			}
			catch (Exception ex)
			{
				if (errors++ < 5)
				{
					CustomizationsPlugin.Log.LogWarning((object)("Item cascade failed: " + ex.Message));
				}
			}
		}

		internal static void FaceSwitched(CharacterCreator c)
		{
			if ((Object)(object)c != (Object)null && states.TryGetValue(c, out var value) && value.ok)
			{
				UpdateSlots(value);
			}
		}

		internal static void ToolsBuilt(CharacterCreator c)
		{
			try
			{
				if ((Object)(object)c != (Object)null && states.TryGetValue(c, out var value) && value.ok && value.open && !value.styledTools)
				{
					StyleTools(value);
				}
			}
			catch (Exception ex)
			{
				if (errors++ < 5)
				{
					CustomizationsPlugin.Log.LogWarning((object)("Face button style failed: " + ex));
				}
			}
		}

		private static void Open(State s)
		{
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			if (!Find(s))
			{
				return;
			}
			Layout(s);
			Style(s);
			try
			{
				MakeSlots(s);
			}
			catch (Exception ex)
			{
				if (errors++ < 5)
				{
					CustomizationsPlugin.Log.LogWarning((object)("Saved-face squares failed: " + ex));
				}
			}
			s.styledTools = false;
			s.openedAt = Time.unscaledTime;
			s.clock = 0f;
			s.measureWait = 2;
			Pop.Run(((Component)s.leftPanel).gameObject, 0.08f);
			Pop.Run(((Component)s.faces).gameObject, 0.08f);
			Pop.Run(((Component)s.gridPanel).gameObject, 0.08f);
			if ((Object)(object)s.demo != (Object)null)
			{
				Pop.Run(((Component)s.demo).gameObject, 0.08f);
			}
			if ((Object)(object)s.credit != (Object)null)
			{
				Pop.Run(((Component)s.credit).gameObject, 0.08f);
			}
			List<(GameObject, Vector3?)> list = new List<(GameObject, Vector3?)>();
			foreach (FaceSlot slot in s.slots)
			{
				if ((Object)(object)slot.tile != (Object)null)
				{
					list.Add((((Component)slot.tile).gameObject, (Vector3?)new Vector3(slot.k, slot.k, 1f)));
				}
			}
			for (int i = 0; i < ((Transform)s.categories).childCount; i++)
			{
				list.Add((((Component)((Transform)s.categories).GetChild(i)).gameObject, null));
			}
			list.Add((((Component)s.done).gameObject, null));
			for (int j = 0; j < list.Count; j++)
			{
				Pop.Run(list[j].Item1, 0.16f + (float)j * 0.022f, 0.26f, list[j].Item2 ?? RestOf(list[j].Item1));
			}
			int count = s.slots.Count;
			Pop.Run(((Component)s.highlight).gameObject, 0.16f + (float)(count + Mathf.Clamp(s.activeTab, 0, 3)) * 0.022f, 0.26f);
			s.revealNext = list.Count;
			Cascade(s, 0.2f);
		}

		private static void RevealTools(State s, Transform root)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			float num = Mathf.Max(0f, 0.16f + (float)s.revealNext * 0.022f - s.clock);
			int num2 = 0;
			foreach (Transform item in root)
			{
				Transform val = item;
				if (((Component)val).gameObject.activeSelf)
				{
					Pop.Run(((Component)val).gameObject, num + (float)num2 * 0.022f, 0.26f, RestOf(((Component)val).gameObject));
					num2++;
				}
			}
		}

		private static Vector3? RestOf(GameObject go)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			ToolFx component = go.GetComponent<ToolFx>();
			if ((Object)(object)component != (Object)null && component.Inited)
			{
				return Vector3.one * component.BaseScale;
			}
			if ((Object)(object)go.GetComponent<ScaleShake>() != (Object)null)
			{
				return null;
			}
			return Pop.RestScale(go);
		}

		private static bool Find(State s)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			CharacterCreator c = s.c;
			ref RectTransform canvas = ref s.canvas;
			Transform obj = ((Component)c).transform.Find("Canvas");
			canvas = (RectTransform)(object)((obj is RectTransform) ? obj : null);
			s.spawner = ((Component)c).GetComponent<CharacterCreatorButtonSpawner>();
			s.faces = ((Component)c).transform.Find("Faces");
			if ((Object)(object)s.canvas != (Object)null)
			{
				ref RectTransform items = ref s.items;
				Transform obj2 = ((Transform)s.canvas).Find("Items");
				items = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null);
				ref RectTransform categories = ref s.categories;
				Transform obj3 = ((Transform)s.canvas).Find("Categories");
				categories = (RectTransform)(object)((obj3 is RectTransform) ? obj3 : null);
				ref RectTransform toggler = ref s.toggler;
				Transform obj4 = ((Transform)s.canvas).Find("Toggler");
				toggler = (RectTransform)(object)((obj4 is RectTransform) ? obj4 : null);
			}
			Button val = FacePanel.FindDone(c);
			s.done = ((!((Object)(object)val != (Object)null)) ? ((RectTransform)null) : ((RectTransform)((Component)val).transform));
			s.hint = (RectTransform)(((Object)(object)s.toggler != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
			s.grid = (((Object)(object)s.items != (Object)null) ? ((Component)s.items).GetComponent<GridLayoutGroup>() : null);
			s.ok = (Object)(object)s.canvas != (Object)null && (Object)(object)s.items != (Object)null && (Object)(object)s.categories != (Object)null && (Object)(object)s.done != (Object)null && (Object)(object)s.grid != (Object)null && (Object)(object)s.faces != (Object)null && (Object)(object)s.spawner != (Object)null;
			if (!s.ok && errors++ < 3)
			{
				CustomizationsPlugin.Log.LogWarning((object)"Edit Character screen isn't laid out as expected; keeping the game's own look.");
			}
			return s.ok;
		}

		private static Camera Cam(State s)
		{
			Canvas component = ((Component)s.canvas).GetComponent<Canvas>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.worldCamera != (Object)null)
			{
				return component.worldCamera;
			}
			if (!((Object)(object)MainCam.instance != (Object)null))
			{
				return Camera.main;
			}
			return MainCam.instance.cam;
		}

		private static Vector2 Local(State s, Vector2 screen)
		{
			//IL_0006: 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)
			Vector2 result = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(s.canvas, screen, Cam(s), ref result);
			return result;
		}

		private static void Place(RectTransform rt, RectTransform canvas, float left, float top, float w, float h, bool pivotCentre = false)
		{
			//IL_0013: 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_003f: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			rt.anchorMax = val;
			rt.anchorMin = val;
			rt.pivot = (pivotCentre ? new Vector2(0.5f, 0.5f) : new Vector2(0f, 1f));
			rt.sizeDelta = new Vector2(w, h);
			Vector3 val2 = (pivotCentre ? new Vector3(left + w * 0.5f, top - h * 0.5f, 0f) : new Vector3(left, top, 0f));
			((Transform)rt).position = ((Transform)canvas).TransformPoint(val2);
			Vector3 localPosition = ((Transform)rt).localPosition;
			localPosition.z = 0f;
			((Transform)rt).localPosition = localPosition;
		}

		private static void PlaceCentre(RectTransform rt, RectTransform canvas, float x, float y)
		{
			//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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Transform)canvas).TransformPoint(new Vector3(x, y, 0f));
			Vector3 position = ((Transform)rt).position;
			Rect rect = rt.rect;
			((Transform)rt).position = val + (position - ((Transform)rt).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)));
		}

		private static int ItemCount(State s)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			int num = 0;
			GameObject sourceButton = s.spawner.sourceButton;
			foreach (Transform item in (Transform)s.items)
			{
				Transform val = item;
				if (((Component)val).gameObject.activeSelf && ((Object)(object)sourceButton == (Object)null || (Object)(object)((Component)val).gameObject != (Object)(object)sourceButton))
				{
					num++;
				}
			}
			return num;
		}

		private static void Layout(State s)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: 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_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0625: Unknown result type (might be due to invalid IL or missing references)
			//IL_062a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0638: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Expected O, but got Unknown
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06de: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = Local(s, Vector2.zero);
			Vector2 val2 = Local(s, new Vector2((float)Screen.width, (float)Screen.height));
			float num = val2.x - val.x;
			float num2 = val2.y - val.y;
			float num3 = ((s.grid.cellSize.x > 1f) ? s.grid.cellSize.x : 43f);
			s.tile = num3 + 4f;
			float num4 = 40f;
			s.top = val.y + num2 * 0.9f;
			float num5 = s.top - 26f - 16f;
			float num6 = val.y + num2 * 0.15f;
			float num7 = num5 - (num6 + 168f + 12f + 12f);
			int num8 = (s.visibleRows = Mathf.Max(3, Mathf.FloorToInt((num7 + 4f) / s.tile)));
			int num9 = Mathf.Clamp(Mathf.FloorToInt((num - num4 * 2f - 280f - 40f + 4f) / s.tile), 8, 20);
			s.cols = Mathf.Clamp(Mathf.Max(14, Mathf.CeilToInt((float)MaxItems() / (float)num8)), 8, num9);
			s.gridW = (float)s.cols * s.tile - 4f;
			float num10 = 320f + s.gridW;
			float num11 = (s.left = (val.x + val2.x) * 0.5f - num10 * 0.5f);
			s.gridX = num11 + 280f + 40f;
			GridLayoutGroup component = ((Component)s.categories).GetComponent<GridLayoutGroup>();
			float num12 = Mathf.Min(130f, (s.gridW - 24f) / 4f);
			if ((Object)(object)component != (Object)null)
			{
				component.cellSize = new Vector2(num12, 26f);
				component.spacing = new Vector2(8f, 0f);
				component.constraint = (Constraint)1;
				component.constraintCount = 4;
				((LayoutGroup)component).childAlignment = (TextAnchor)0;
			}
			Place(s.categories, s.canvas, s.gridX, s.top, num12 * 4f + 24f, 26f);
			s.gridTop = s.top - 26f - 16f;
			s.grid.spacing = new Vector2(4f, 4f);
			s.grid.constraint = (Constraint)1;
			s.grid.constraintCount = s.cols;
			((LayoutGroup)s.grid).childAlignment = (TextAnchor)0;
			Place(s.items, s.canvas, s.gridX, s.gridTop, s.gridW, GridHeight(s));
			float num13 = num11 + 140f;
			float num14 = s.top - 107.5f + 6f;
			Vector3 val3 = ((Transform)s.canvas).TransformPoint(new Vector3(num13, num14, 0f));
			s.faces.position = new Vector3(val3.x, val3.y, s.faces.position.z);
			float num15 = s.top - 215f;
			s.done.sizeDelta = new Vector2(216f, 34f);
			PlaceCentre(s.done, s.canvas, num13, num15 - 12f - 17f);
			HideExtras(s);
			if ((Object)(object)s.backdrop == (Object)null)
			{
				s.backdrop = Backdrop(s.canvas);
			}
			if ((Object)(object)s.leftPanel == (Object)null)
			{
				s.leftPanel = Panel(s.backdrop, "Customizations.LeftCard");
			}
			if ((Object)(object)s.gridPanel == (Object)null)
			{
				s.gridPanel = Panel(s.backdrop, "Customizations.ItemsCard");
			}
			if ((Object)(object)s.demo == (Object)null)
			{
				s.demo = Panel(s.backdrop, "Customizations.HudDemo");
				HudDemo hudDemo = ((Component)s.demo).gameObject.AddComponent<HudDemo>();
				CharacterCreatorItemEquipper componentInChildren = ((Component)s.c).GetComponentInChildren<CharacterCreatorItemEquipper>();
				hudDemo.Init(s.c, ((Object)(object)s.faces != (Object)null) ? s.faces.Find("PlayerScaler") : null, ((Object)(object)componentInChildren != (Object)null) ? componentInChildren.scaleM : 1f);
			}
			if ((Object)(object)s.credit == (Object)null)
			{
				GameObject val4 = new GameObject("Customizations.Credit", new Type[1] { typeof(RectTransform) });
				val4.layer = ((Component)s.backdrop).gameObject.layer;
				val4.transform.SetParent((Transform)(object)s.backdrop, false);
				s.credit = val4.AddComponent<TextMeshProUGUI>();
				TMP_Text componentInChildren2 = ((Component)s.done).GetComponentInChildren<TMP_Text>(true);
				if ((Object)(object)componentInChildren2 != (Object)null)
				{
					((TMP_Text)s.credit).font = componentInChildren2.font;
				}
				((TMP_Text)s.credit).richText = true;
				((TMP_Text)s.credit).text = CreditText(((TMP_Text)s.credit).font);
				((TMP_Text)s.credit).fontSize = 15f;
				((Graphic)s.credit).color = Color.white;
				((TMP_Text)s.credit).alignment = (TextAlignmentOptions)1028;
				((TMP_Text)s.credit).enableWordWrapping = false;
				((TMP_Text)s.credit).overflowMode = (TextOverflowModes)0;
				((Graphic)s.credit).raycastTarget = false;
			}
			RectTransform rectTransform = ((TMP_Text)s.credit).rectTransform;
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor(0.5f, 0.5f);
			rectTransform.anchorMax = val5;
			rectTransform.anchorMin = val5;
			rectTransform.pivot = new Vector2(1f, 0f);
			rectTransform.sizeDelta = new Vector2(320f, 22f);
			((Transform)rectTransform).position = ((Transform)s.canvas).TransformPoint(new Vector3(s.gridX + s.gridW + 12f - 4f, s.top + 12f + 6f, 0f));
			Vector3 localPosition = ((Transform)rectTransform).localPosition;
			localPosition.z = 0f;
			((Transform)rectTransform).localPosition = localPosition;
			ApplyPaging(s);
			Place(s.leftPanel, s.canvas, num11, s.top + 12f, 280f, 227f, pivotCentre: true);
			s.gpSet = false;
			UpdateGridPanel(s);
			if ((Object)(object)s.highlight == (Object)null)
			{
				s.highlight = Rounded(s.backdrop, "Customizations.TabHighlight", 13f, Color.white);
				RectTransform highlight = s.highlight;
				RectTransform highlight2 = s.highlight;
				RectTransform highlight3 = s.highlight;
				Vector2 val6 = default(Vector2);
				((Vector2)(ref val6))..ctor(0.5f, 0.5f);
				highlight3.pivot = val6;
				val5 = (highlight.anchorMin = (highlight2.anchorMax = val6));
			}
			((Transform)s.highlight).SetAsLastSibling();
			s.hlSet = false;
			CustomizationsPlugin.Log.LogInfo((object)$"Edit Character restyled: screen {num:F0} x {num2:F0} units, {s.cols} columns, left card at {num11:F0}, items at {s.gridX:F0}, top {s.top:F0}.");
		}

		private static int MaxItems()
		{
			CharacterCreatorItemLoader instance = CharacterCreatorItemLoader.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return 120;
			}
			CharacterItem[] eyes = instance.eyes;
			int num = ((eyes != null) ? eyes.Length : 0);
			CharacterItem[] mouths = instance.mouths;
			int num2 = ((mouths != null) ? mouths.Length : 0);
			CharacterItem[] accessories = instance.accessories;
			return Mathf.Max(num, Mathf.Max(num2, (accessories != null) ? accessories.Length : 0));
		}

		private static float GridHeight(State s)
		{
			return (float)Mathf.CeilToInt((float)Mathf.Max(1, ItemCount(s)) / (float)s.cols) * s.tile - 4f;
		}

		private static void Style(State s)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				s.accent = PlayerSkinBank.GetPlayerSkinColors(Mathf.Max(0, s.c.playerID)).color;
			}
			catch
			{
				s.accent = new Color(1f, 0.55f, 0.15f);
			}
			s.accent.a = 1f;
			((Graphic)((Component)s.highlight).GetComponent<Image>()).color = s.accent;
			Image component = ((Component)s.items).GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = false;
			}
			component = ((Component)s.categories).GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = false;
			}
			TMP_Text[] componentsInChildren;
			foreach (Transform item in (Transform)s.categories)
			{
				MakeRounded(((Component)item).GetComponent<ProceduralImage>(), 13f, TabColor);
				componentsInChildren = ((Component)item).GetComponentsInChildren<TMP_Text>(true);
				foreach (TMP_Text obj2 in componentsInChildren)
				{
					((Graphic)obj2).color = TabText;
					obj2.fontSize = 13f;
				}
			}
			if ((Object)(object)s.spawner.sourceButton != (Object)null)
			{
				StyleTile(s, s.spawner.sourceButton.transform);
			}
			foreach (Transform item2 in (Transform)s.items)
			{
				Transform tile = item2;
				StyleTile(s, tile);
			}
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(s.accent.r, s.accent.g, s.accent.b, 0.92f);
			MakeRounded(((Component)s.done).GetComponent<ProceduralImage>(), 17f, val2);
			componentsInChildren = ((Component)s.done).GetComponentsInChildren<TMP_Text>(true);
			foreach (TMP_Text obj3 in componentsInChildren)
			{
				((Graphic)obj3).color = Color.white;
				obj3.text = "SAVE";
			}
			Interactive(((Component)s.done).gameObject, val2, Color.Lerp(val2, Color.white, 0.22f));
		}

		private static void Interactive(GameObject go, Color normal, Color hover)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			Transform val = go.transform.Find("Image");
			Image val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Image>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				((Behaviour)val2).enabled = false;
				((Graphic)val2).raycastTarget = false;
			}
			HoverEvent[] components = go.GetComponents<HoverEvent>();
			foreach (HoverEvent obj in components)
			{
				obj.enterEvent = new UnityEvent();
				obj.exitEvent = new UnityEvent();
			}
			Button component = go.GetComponent<Button>();
			if ((Object)(object)component != (Object)null)
			{
				((Selectable)component).transition = (Transition)0;
			}
			(go.GetComponent<ToolFx>() ?? go.AddComponent<ToolFx>()).Init((Graphic)(object)go.GetComponent<ProceduralImage>(), normal, hover);
		}

		private static void StyleTile(State s, Transform tile)
		{
			//IL_0017: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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)
			ProceduralImage component = ((Component)tile).GetComponent<ProceduralImage>();
			if (!((Object)(object)component == (Object)null))
			{
				MakeRounded(component, 7f, TileColor);
				HoverEventColor component2 = ((Component)tile).GetComponent<HoverEventColor>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.hoverColor = Color.Lerp(TileColor, s.accent, 0.35f);
				}
				Transform val = tile.Find("SelectedDot");
				ProceduralImage val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<ProceduralImage>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					MakeRounded(val2, 7f, s.accent);
					val2.BorderWidth = 3f;
				}
			}
		}

		private static void StyleTools(State s)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			Transform val = (((Object)(object)s.toggler != (Object)null) ? ((Transform)s.toggler).Find("Customizations.FaceButtons") : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			s.styledTools = true;
			Button[] componentsInChildren = ((Component)val).GetComponentsInChildren<Button>(true);
			foreach (Button val2 in componentsInChildren)
			{
				RectTransform val3 = (RectTransform)((Component)val2).transform;
				ProceduralImage component = ((Component)val2).GetComponent<ProceduralImage>();
				Rect rect = val3.rect;
				MakeRounded(component, ((Rect)(ref rect)).height * 0.5f, ToolColor);
				TMP_Text[] componentsInChildren2 = ((Component)val2).GetComponentsInChildren<TMP_Text>(true);
				for (int j = 0; j < componentsInChildren2.Length; j++)
				{
					((Graphic)componentsInChildren2[j]).color = Color.white;
				}
				Interactive(((Component)val2).gameObject, ToolColor, Color.Lerp(ToolColor, s.accent, 0.45f));
			}
			TextMeshProUGUI[] componentsInChildren3 = ((Component)val).GetComponentsInChildren<TextMeshProUGUI>(true);
			foreach (TextMeshProUGUI val4 in componentsInChildren3)
			{
				if ((Object)(object)((Component)val4).GetComponentInParent<Button>() == (Object)null)
				{
					((Graphic)val4).color = Color.white;
				}
			}
			RevealTools(s, val);
		}

		private static void MakeRounded(ProceduralImage pi, float radius, Color color)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)pi == (Object)null))
			{
				if (pi.ModifierType != typeof(UniformModifier))
				{
					pi.ModifierType = typeof(UniformModifier);
				}
				UniformModifier component = ((Component)pi).GetComponent<UniformModifier>();
				if ((Object)(object)component != (Object)null)
				{
					component.Radius = radius;
				}
				pi.BorderWidth = 0f;
				((Graphic)pi).color = color;
			}
		}

		private static RectTransform Rounded(RectTransform parent, string name, float radius, Color color)
		{
			//IL_0014: 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_002a: 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)
			//IL_0036: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) })
			{
				layer = ((Component)parent).gameObject.layer
			};
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent((Transform)(object)parent, false);
			ProceduralImage obj = val.AddComponent<ProceduralImage>();
			((Graphic)obj).raycastTarget = false;
			MakeRounded(obj, radius, color);
			return val2;
		}

		private static RectTransform Backdrop(RectTransform canvas)
		{
			//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_003b: 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_0047: Expected O, but got Unknown
			//IL_0050: 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_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_006d: 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)
			GameObject val = new GameObject("Customizations.Backdrop", new Type[2]
			{
				typeof(RectTransform),
				typeof(Canvas)
			})
			{
				layer = ((Component)canvas).gameObject.layer
			};
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent((Transform)(object)canvas, false);
			val2.anchorMin = Vector2.zero;
			val2.anchorMax = Vector2.one;
			Vector2 offsetMin = (val2.offsetMax = Vector2.zero);
			val2.offsetMin = offsetMin;
			((Transform)val2).SetAsLastSibling();
			Canvas component = ((Component)canvas).GetComponent<Canvas>();
			Canvas component2 = val.GetComponent<Canvas>();
			component2.overrideSorting = true;
			if ((Object)(object)component != (Object)null)
			{
				component2.sortingLayerID = component.sortingLayerID;
				component2.sortingOrder = component.sortingOrder - 1;
			}
			else
			{
				component2.sortingOrder = -1;
			}
			return val2;
		}

		private static RectTransform Panel(RectTransform canvas, string name)
		{
			//IL_0007: 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_0027: 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_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_0044: 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)
			RectTransform obj = Rounded(canvas, name, 12f, PanelColor);
			RectTransform obj2 = Rounded(obj, "Edge", 12f, EdgeColor);
			obj2.anchorMin = Vector2.zero;
			obj2.anchorMax = Vector2.one;
			Vector2 offsetMin = (obj2.offsetMax = Vector2.zero);
			obj2.offsetMin = offsetMin;
			((Component)obj2).GetComponent<ProceduralImage>().BorderWidth = 1.5f;
			return obj;
		}

		private static void UpdateHighlight(State s)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)s.highlight == (Object)null || ((Transform)s.categories).childCount == 0)
			{
				return;
			}
			Transform child = ((Transform)s.categories).GetChild(Mathf.Clamp(s.activeTab, 0, ((Transform)s.categories).childCount - 1));
			RectTransform val = (RectTransform)(object)((child is RectTransform) ? child : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			RectTransform canvas = s.canvas;
			Rect rect = val.rect;
			Vector2 val2 = Vector2.op_Implicit(((Transform)canvas).InverseTransformPoint(((Transform)val).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center))));
			rect = val.rect;
			s.hlSize = ((Rect)(ref rect)).size + new Vector2(6f, 6f);
			Vector2 hlTo;
			if (!s.hlSet)
			{
				hlTo = (s.hlCur = val2);
				hlTo = (s.hlFrom = (s.hlTo = hlTo));
				s.hlP = 1f;
				s.hlSet = true;
			}
			else
			{
				hlTo = val2 - s.hlTo;
				if (((Vector2)(ref hlTo)).sqrMagnitude > 0.25f)
				{
					s.hlFrom = s.hlCur;
					s.hlTo = val2;
					s.hlP = 0f;
				}
			}
			if (s.hlP < 1f)
			{
				s.hlP = Mathf.MoveTowards(s.hlP, 1f, Dt / 0.35f);
				s.hlCur = Vector2.LerpUnclamped(s.hlFrom, s.hlTo, Pop.EaseOutBack(s.hlP));
			}
			s.highlight.sizeDelta = s.hlSize;
			((Transform)s.highlight).position = ((Transform)s.canvas).TransformPoint(new Vector3(s.hlCur.x, s.hlCur.y, 0f));
			for (int i = 0; i < ((Transform)s.categories).childCount; i++)
			{
				TMP_Text[] componentsInChildren = ((Component)((Transform)s.categories).GetChild(i)).GetComponentsInChildren<TMP_Text>(true);
				foreach (TMP_Text val3 in componentsInChildren)
				{
					Color val4 = ((i == s.activeTab) ? Color.white : TabText);
					if (((Graphic)val3).color != val4)
					{
						((Graphic)val3).color = val4;
					}
				}
			}
		}

		private static void UpdateGridPanel(State s)
		{
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)s.gridPanel == (Object)null))
			{
				float num = GridHeight(s);
				float num2 = 42f + num + 24f;
				float lowest;
				if (s.measureWait > 0)
				{
					s.measureWait--;
				}
				else if (LowestTile(s, out lowest))
				{
					num2 = Mathf.Max(num2, s.top + 12f - lowest + 12f);
				}
				if (!s.gpSet)
				{
					s.gpFrom = (s.gpTo = (s.gpCur = num2));
					s.gpP = 1f;
					s.gpSet = true;
				}
				else if (Mathf.Abs(num2 - s.gpTo) > 0.5f)
				{
					s.gpFrom = s.gpCur;
					s.gpTo = num2;
					s.gpP = 0f;
				}
				if (s.gpP < 1f)
				{
					s.gpP = Mathf.MoveTowards(s.gpP, 1f, Dt / 0.4f);
					s.gpCur = Mathf.LerpUnclamped(s.gpFrom, s.gpTo, Pop.EaseOutBack(s.gpP));
				}
				Place(s.gridPanel, s.canvas, s.gridX - 12f, s.top + 12f, s.gridW + 24f, s.gpCur, pivotCentre: true);
				if (Mathf.Abs(s.items.sizeDelta.y - num) > 0.5f)
				{
					s.items.sizeDelta = new Vector2(s.gridW, num);
				}
				if ((Object)(object)s.demo != (Object)null)
				{
					Place(s.demo, s.canvas, s.gridX - 12f, s.top + 12f - s.gpCur - 12f, s.gridW + 24f, 168f, pivotCentre: true);
				}
				UpdateScrollbar(s, num);
			}
		}

		private static void UpdateScrollbar(State s, float gridH)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			bool flag = s.totalRows > s.visibleRows && ((Transform)s.gridPanel).localScale.x > 0.98f;
			if ((Object)(object)s.scrollTrack == (Object)null)
			{
				if (!flag)
				{
					return;
				}
				s.scrollTrack = Rounded(s.backdrop, "Customizations.ScrollTrack", 2f, new Color(1f, 1f, 1f, 0.06f));
				s.scrollThumb = Rounded(s.scrollTrack, "Thumb", 2f, new Color(1f, 1f, 1f, 0.3f));
			}
			if (((