Decompiled source of CardBarCollapse v1.1.0

plugins/CardBarCollapse.dll

Decompiled 14 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnboundLib;
using UnboundLib.Extensions;
using UnboundLib.Utils;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[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 CardBarCollapse
{
	[BepInPlugin("com.mrnoa.rounds.cardbarcollapse", "CardBarCollapse", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("Rounds.exe")]
	public class CardBarCollapsePlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__11_0;

			public static UnityAction<bool> <>9__11_2;

			public static UnityAction<bool> <>9__11_3;

			public static UnityAction<float> <>9__11_4;

			public static UnityAction<float> <>9__11_5;

			public static UnityAction<float> <>9__11_6;

			public static Action<GameObject> <>9__11_1;

			internal void <Start>b__11_0()
			{
			}

			internal void <Start>b__11_1(GameObject menu)
			{
				TextMeshProUGUI val = default(TextMeshProUGUI);
				MenuHandler.CreateText("CardBarCollapse", menu, ref val, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				MenuHandler.CreateText(" ", menu, ref val, 20, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				MenuHandler.CreateToggle(Collapsed.Value, "Collapsed", menu, (UnityAction<bool>)delegate(bool v)
				{
					Collapsed.Value = v;
				}, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				MenuHandler.CreateToggle(ShowCount.Value, "Show Card Count On Boxes", menu, (UnityAction<bool>)delegate(bool v)
				{
					ShowCount.Value = v;
				}, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				Slider val2 = default(Slider);
				MenuHandler.CreateSlider("Toggle Button Size", menu, 30, 8f, 32f, ButtonSize.Value, (UnityAction<float>)delegate(float v)
				{
					ButtonSize.Value = v;
				}, ref val2, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				MenuHandler.CreateSlider("Animation Speed", menu, 30, 0.25f, 3f, AnimSpeed.Value, (UnityAction<float>)delegate(float v)
				{
					AnimSpeed.Value = v;
				}, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				MenuHandler.CreateSlider("Card Preview Size", menu, 30, 0.5f, 2f, PreviewSize.Value, (UnityAction<float>)delegate(float v)
				{
					PreviewSize.Value = v;
				}, ref val2, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			}

			internal void <Start>b__11_2(bool v)
			{
				Collapsed.Value = v;
			}

			internal void <Start>b__11_3(bool v)
			{
				ShowCount.Value = v;
			}

			internal void <Start>b__11_4(float v)
			{
				ButtonSize.Value = v;
			}

			internal void <Start>b__11_5(float v)
			{
				AnimSpeed.Value = v;
			}

			internal void <Start>b__11_6(float v)
			{
				PreviewSize.Value = v;
			}
		}

		public const string Guid = "com.mrnoa.rounds.cardbarcollapse";

		public const string Name = "CardBarCollapse";

		public const string Version = "1.1.0";

		internal static ConfigEntry<bool> Collapsed;

		internal static ConfigEntry<float> ButtonSize;

		internal static ConfigEntry<float> AnimSpeed;

		internal static ConfigEntry<bool> ShowCount;

		internal static ConfigEntry<float> PreviewSize;

		internal const string JeusticeGuid = "com.jeustice.rounds.chaos";

		private static bool LanguageButtonPrefix()
		{
			return false;
		}

		private void Awake()
		{
			//IL_00b1: 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_00bc: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Expected O, but got Unknown
			Collapsed = ((BaseUnityPlugin)this).Config.Bind<bool>("State", "CollapseRows", true, "Card rows are collapsed into player-colored boxes (toggled by the corner button).");
			ButtonSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ButtonSize", 14f, "Size of the toggle square in the top-right corner (pixels at 1080p).");
			AnimSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AnimationSpeed", 1f, "Open/close animation speed multiplier.");
			ShowCount = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowCardCount", true, "Show the number of cards on each collapsed box.");
			PreviewSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CardPreviewSize", 1f, "Size of the card that pops up when you hover a card square (1 = the game's normal size).");
			GameObject val = new GameObject("CardBarCollapse");
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<CollapseController>();
			Harmony val2 = new Harmony("com.mrnoa.rounds.cardbarcollapse");
			val2.PatchAll();
			if (Chainloader.PluginInfos.ContainsKey("com.jeustice.rounds.chaos"))
			{
				try
				{
					MethodInfo methodInfo = AccessTools.Method(AccessTools.TypeByName("JeusticeChaos.LanguageToggle"), "OnGUI", (Type[])null, (Type[])null);
					if (methodInfo != null)
					{
						val2.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(CardBarCollapsePlugin), "LanguageButtonPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						((BaseUnityPlugin)this).Logger.LogInfo((object)"Jeustice Chaos found: language button hook installed.");
					}
					else
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)"Jeustice Chaos found, but its language button code was not where expected.");
					}
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Jeustice Chaos language button hook failed: " + ex.Message));
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"CardBarCollapse 1.1.0 loaded.");
		}

		private void Start()
		{
			//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_0024: Expected O, but got Unknown
			object obj = <>c.<>9__11_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__11_0 = val;
				obj = (object)val;
			}
			Unbound.RegisterMenu("CardBarCollapse", (UnityAction)obj, (Action<GameObject>)delegate(GameObject menu)
			{
				TextMeshProUGUI val2 = default(TextMeshProUGUI);
				MenuHandler.CreateText("CardBarCollapse", menu, ref val2, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				MenuHandler.CreateText(" ", menu, ref val2, 20, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				MenuHandler.CreateToggle(Collapsed.Value, "Collapsed", menu, (UnityAction<bool>)delegate(bool v)
				{
					Collapsed.Value = v;
				}, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				MenuHandler.CreateToggle(ShowCount.Value, "Show Card Count On Boxes", menu, (UnityAction<bool>)delegate(bool v)
				{
					ShowCount.Value = v;
				}, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				Slider val3 = default(Slider);
				MenuHandler.CreateSlider("Toggle Button Size", menu, 30, 8f, 32f, ButtonSize.Value, (UnityAction<float>)delegate(float v)
				{
					ButtonSize.Value = v;
				}, ref val3, true, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				MenuHandler.CreateSlider("Animation Speed", menu, 30, 0.25f, 3f, AnimSpeed.Value, (UnityAction<float>)delegate(float v)
				{
					AnimSpeed.Value = v;
				}, ref val3, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				MenuHandler.CreateSlider("Card Preview Size", menu, 30, 0.5f, 2f, PreviewSize.Value, (UnityAction<float>)delegate(float v)
				{
					PreviewSize.Value = v;
				}, ref val3, false, (Color?)null, (Direction)0, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			}, (GameObject)null, true);
		}
	}
	[HarmonyPatch(typeof(CardBarButton), "OnPointerEnter")]
	internal static class SquareEnterPatch
	{
		private static bool Prefix(CardBarButton __instance, CardInfo ___card)
		{
			CardPreview.Enter(__instance, ___card);
			return false;
		}
	}
	[HarmonyPatch(typeof(CardBarButton), "OnPointerExit")]
	internal static class SquareExitPatch
	{
		private static bool Prefix(CardBarButton __instance)
		{
			CardPreview.Exit(__instance);
			return false;
		}
	}
	internal static class CardPreview
	{
		private static readonly FieldRef<CardBar, GameObject> CurrentCardRef = AccessTools.FieldRefAccess<CardBar, GameObject>("currentCard");

		private static readonly ManualLogSource Log = Logger.CreateLogSource("CardBarCollapse.Preview");

		private static int logs;

		private static readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];

		private static int layoutLogs;

		private static GameObject held;

		private static Vector3 heldPos;

		private static Vector3 heldScale;

		internal static void Enter(CardBarButton btn, CardInfo card)
		{
			//IL_0057: 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)
			try
			{
				CardBar componentInParent = ((Component)btn).GetComponentInParent<CardBar>();
				if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)card == (Object)null))
				{
					Exception ex = null;
					try
					{
						componentInParent.OnHover(card, ((Component)btn).transform.position);
					}
					catch (Exception ex2)
					{
						ex = ex2;
					}
					GameObject val = CurrentCardRef.Invoke(componentInParent);
					bool flag = false;
					if ((Object)(object)val == (Object)null)
					{
						val = Create(componentInParent, card, ((Component)btn).transform.position);
						CurrentCardRef.Invoke(componentInParent) = val;
						flag = true;
					}
					bool flag2 = (Object)(object)val != (Object)null && val.activeInHierarchy;
					if ((Object)(object)val != (Object)null && (ex != null || flag || !flag2))
					{
						Finish(val);
					}
					if (logs++ < 4)
					{
						Log.LogInfo((object)string.Format("preview '{0}': game code {1}, card object {2}, was active={3}, now active={4}", card.cardName, (ex == null) ? "ok" : ("threw " + ex.GetType().Name), ((Object)(object)val == (Object)null) ? "MISSING" : (flag ? "created by mod" : "from game"), flag2, (Object)(object)val != (Object)null && val.activeInHierarchy));
					}
					if ((Object)(object)val != (Object)null)
					{
						PlaceBeside(val, ((Component)btn).transform);
					}
					CollapseController.Instance?.SetHovered(((Component)btn).transform, componentInParent);
				}
			}
			catch (Exception ex3)
			{
				if (logs++ < 8)
				{
					Log.LogWarning((object)("preview failed: " + ex3));
				}
			}
		}

		internal static void Exit(CardBarButton btn)
		{
			try
			{
				CardBar componentInParent = ((Component)btn).GetComponentInParent<CardBar>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					componentInParent.StopHover();
				}
			}
			catch (Exception)
			{
			}
			CollapseController.Instance?.ClearHovered(((Component)btn).transform);
		}

		private static void PlaceBeside(GameObject cc, Transform square)
		{
			//IL_00a0: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: 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_0250: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: 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_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: 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)
			//IL_02e6: 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_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: 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_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0450: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Camera val = (((Object)(object)MainCam.instance != (Object)null) ? MainCam.instance.cam : Camera.main);
				CollapseController instance = CollapseController.Instance;
				if (!((Object)(object)val == (Object)null) && !((Object)(object)instance == (Object)null) && instance.TryGetRowsBox(((Component)square).GetComponentInParent<CardBar>(), out var box))
				{
					Canvas[] componentsInChildren = cc.GetComponentsInChildren<Canvas>(true);
					foreach (Canvas val2 in componentsInChildren)
					{
						val2.overrideSorting = true;
						val2.sortingLayerName = "MostFront";
						val2.sortingOrder = 30000 + val2.sortingOrder % 100;
					}
					float num = Mathf.Abs(((Component)val).transform.position.z - cc.transform.position.z);
					Vector3 val3 = val.ScreenToWorldPoint(new Vector3(0f, 0f, num));
					Vector3 val4 = val.ScreenToWorldPoint(new Vector3((float)Screen.width, (float)Screen.height, num));
					Vector3 val5 = val.ScreenToWorldPoint(new Vector3(((Rect)(ref box)).xMin, ((Rect)(ref box)).yMin, num));
					Vector3 val6 = val.ScreenToWorldPoint(new Vector3(((Rect)(ref box)).xMax, ((Rect)(ref box)).yMax, num));
					float num2 = (val4.y - val3.y) * 0.02f;
					Transform transform = cc.transform;
					Vector3 localScale = transform.localScale;
					float num3 = Mathf.Clamp(CardBarCollapsePlugin.PreviewSize.Value, 0.3f, 3f);
					transform.localScale = localScale * num3;
					Bounds val7 = Measure(cc);
					float num4 = val4.x - val6.x - num2 * 2f;
					float num5 = val5.x - val3.x - num2 * 2f;
					bool flag = num4 >= num5;
					float num6 = Mathf.Max(num4, num5);
					bool flag2 = num6 >= ((Bounds)(ref val7)).size.x * 0.45f;
					if (flag2 && ((Bounds)(ref val7)).size.x > num6)
					{
						transform.localScale *= num6 / ((Bounds)(ref val7)).size.x;
						val7 = Measure(cc);
					}
					float num7 = val4.y - val3.y - num2 * 2f;
					if (((Bounds)(ref val7)).size.y > num7)
					{
						transform.localScale *= num7 / ((Bounds)(ref val7)).size.y;
						val7 = Measure(cc);
					}
					float num8;
					float num9;
					if (flag2)
					{
						num8 = (flag ? (val6.x + num2 + ((Bounds)(ref val7)).extents.x) : (val5.x - num2 - ((Bounds)(ref val7)).extents.x));
						num9 = val6.y - ((Bounds)(ref val7)).extents.y;
					}
					else
					{
						num8 = Mathf.Clamp((val5.x + val6.x) * 0.5f, val3.x + ((Bounds)(ref val7)).extents.x + num2, val4.x - ((Bounds)(ref val7)).extents.x - num2);
						num9 = val5.y - num2 - ((Bounds)(ref val7)).extents.y;
					}
					num9 = Mathf.Clamp(num9, val3.y + num2 + ((Bounds)(ref val7)).extents.y, val4.y - num2 - ((Bounds)(ref val7)).extents.y);
					transform.position += new Vector3(num8 - ((Bounds)(ref val7)).center.x, num9 - ((Bounds)(ref val7)).center.y, 0f);
					held = cc;
					heldPos = transform.position;
					heldScale = transform.localScale;
					if (layoutLogs++ < 4)
					{
						Log.LogInfo((object)string.Format("preview spot: rows box x {0:F1}..{1:F1}, y {2:F1}..{3:F1}; screen x {4:F1}..{5:F1}; card {6:F1} x {7:F1} (size {8:F2}); {9} at ({10:F1}, {11:F1})", val5.x, val6.x, val5.y, val6.y, val3.x, val4.x, ((Bounds)(ref val7)).size.x, ((Bounds)(ref val7)).size.y, num3, (!flag2) ? "below rows" : (flag ? "right of rows" : "left of rows"), num8, num9));
					}
				}
			}
			catch (Exception ex)
			{
				if (layoutLogs++ < 8)
				{
					Log.LogWarning((object)("preview placement failed: " + ex.Message));
				}
			}
		}

		internal static void Hold()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)held == (Object)null))
			{
				Transform transform = held.transform;
				if (transform.position != heldPos)
				{
					transform.position = heldPos;
				}
				if (transform.localScale != heldScale)
				{
					transform.localScale = heldScale;
				}
			}
		}

		private static void Layout(GameObject cc, Transform square)
		{
			//IL_004f: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: 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_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: 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_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: 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_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Camera val = (((Object)(object)MainCam.instance != (Object)null) ? MainCam.instance.cam : Camera.main);
				if (!((Object)(object)val == (Object)null))
				{
					SetScaleToZero componentInChildren = cc.GetComponentInChildren<SetScaleToZero>(true);
					Transform val2 = (((Object)(object)componentInChildren != (Object)null) ? ((Component)componentInChildren).transform : cc.transform);
					val2.localScale *= Mathf.Clamp(CardBarCollapsePlugin.PreviewSize.Value, 0.3f, 3f);
					Canvas[] componentsInChildren = cc.GetComponentsInChildren<Canvas>(true);
					foreach (Canvas val3 in componentsInChildren)
					{
						val3.overrideSorting = true;
						val3.sortingLayerName = "MostFront";
						val3.sortingOrder = 30000 + val3.sortingOrder % 100;
					}
					float num = Mathf.Abs(((Component)val).transform.position.z - cc.transform.position.z);
					Vector3 val4 = val.ScreenToWorldPoint(new Vector3(0f, 0f, num));
					Vector3 val5 = val.ScreenToWorldPoint(new Vector3((float)Screen.width, (float)Screen.height, num));
					float num2 = (val5.y - val4.y) * 0.015f;
					float bottomPx = Screen.height;
					CollapseController instance = CollapseController.Instance;
					if ((Object)(object)instance == (Object)null || !instance.TryGetRowsBottom(out bottomPx))
					{
						bottomPx = RectTransformUtility.WorldToScreenPoint((Camera)null, square.position).y - 30f;
					}
					float y = val.ScreenToWorldPoint(new Vector3(0f, bottomPx, num)).y;
					float x = val.ScreenToWorldPoint(new Vector3(CollapseController.ScreenX(square), 0f, num)).x;
					Bounds val6 = Measure(cc);
					float num3 = y - val4.y - num2 * 2f;
					if (((Bounds)(ref val6)).size.y > num3 && num3 > 0f)
					{
						val2.localScale *= Mathf.Max(0.45f, num3 / ((Bounds)(ref val6)).size.y);
						val6 = Measure(cc);
					}
					float num4 = Mathf.Clamp(x, val4.x + ((Bounds)(ref val6)).extents.x + num2, val5.x - ((Bounds)(ref val6)).extents.x - num2);
					float num5 = y - num2 - ((Bounds)(ref val6)).extents.y;
					if (num5 - ((Bounds)(ref val6)).extents.y < val4.y + num2)
					{
						num5 = val4.y + num2 + ((Bounds)(ref val6)).extents.y;
					}
					Transform transform = cc.transform;
					transform.position += new Vector3(num4 - ((Bounds)(ref val6)).center.x, num5 - ((Bounds)(ref val6)).center.y, 0f);
					if (layoutLogs++ < 3)
					{
						Log.LogInfo((object)$"preview layout: card {((Bounds)(ref val6)).size.x:F1} x {((Bounds)(ref val6)).size.y:F1} world units, rows end at {y:F1}, screen {val4.y:F1}..{val5.y:F1}, placed at ({num4:F1}, {num5:F1})");
					}
				}
			}
			catch (Exception ex)
			{
				if (layoutLogs++ < 6)
				{
					Log.LogWarning((object)("preview layout failed: " + ex.Message));
				}
			}
		}

		private static Bounds Measure(GameObject cc)
		{
			//IL_00e4: 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_00b2: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = null;
			float num = -1f;
			Canvas[] componentsInChildren = cc.GetComponentsInChildren<Canvas>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Transform transform = ((Component)componentsInChildren[i]).transform;
				RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				if (!((Object)(object)val2 == (Object)null))
				{
					val2.GetWorldCorners(corners);
					float num2 = Mathf.Abs((corners[2].x - corners[0].x) * (corners[2].y - corners[0].y));
					if (num2 > num)
					{
						num = num2;
						val = val2;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return new Bounds(cc.transform.position, new Vector3(8f, 12f, 0f));
			}
			val.GetWorldCorners(corners);
			Bounds result = default(Bounds);
			((Bounds)(ref result))..ctor(corners[0], Vector3.zero);
			for (int j = 1; j < 4; j++)
			{
				((Bounds)(ref result)).Encapsulate(corners[j]);
			}
			return result;
		}

		private static GameObject Create(CardBar bar, CardInfo card, Vector3 fallbackPos)
		{
			//IL_001c: 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_0021: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (((Object)(object)bar.cardPos != (Object)null) ? bar.cardPos.transform.position : fallbackPos);
			GameObject obj = Object.Instantiate<GameObject>(((Component)card).gameObject, val, Quaternion.identity);
			CardVisuals componentInChildren = obj.GetComponentInChildren<CardVisuals>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.firstValueToSet = true;
			}
			return obj;
		}

		private static void Finish(GameObject cc)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (!cc.activeSelf)
			{
				cc.SetActive(true);
			}
			Collider2D[] componentsInChildren = ((Component)cc.transform.root).GetComponentsInChildren<Collider2D>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Behaviour)componentsInChildren[i]).enabled = false;
			}
			Canvas componentInChildren = cc.GetComponentInChildren<Canvas>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.sortingLayerName = "MostFront";
			}
			GraphicRaycaster componentInChildren2 = cc.GetComponentInChildren<GraphicRaycaster>(true);
			if ((Object)(object)componentInChildren2 != (Object)null)
			{
				((Behaviour)componentInChildren2).enabled = false;
			}
			SetScaleToZero componentInChildren3 = cc.GetComponentInChildren<SetScaleToZero>(true);
			if ((Object)(object)componentInChildren3 != (Object)null)
			{
				((Behaviour)componentInChildren3).enabled = false;
				float num = 1f;
				if ((Object)(object)MainCam.instance != (Object)null && (Object)(object)MainCam.instance.cam != (Object)null)
				{
					num = MainCam.instance.cam.orthographicSize / 20f;
				}
				((Component)componentInChildren3).transform.localScale = Vector3.one * 1.15f * num;
			}
		}
	}
	internal class CollapseController : MonoBehaviour
	{
		private class Row
		{
			public CardBar bar;

			public int index;

			public RectTransform chip;

			public Image chipImage;

			public TextMeshProUGUI chipText;

			public readonly List<Transform> cards = new List<Transform>();

			public int lastChildCount = -1;

			public float open = 1f;

			public float chipShown;

			public float hoverTimer;

			public bool dirty = true;

			public int layoutFrames;

			public Rect chipScreen;

			public int fitFrames;

			public Camera cam;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__26_0;

			internal void <BuildToggle>b__26_0()
			{
				CardBarCollapsePlugin.Collapsed.Value = !CardBarCollapsePlugin.Collapsed.Value;
			}
		}

		internal static CollapseController Instance;

		private static readonly FieldRef<CardBarHandler, CardBar[]> BarsRef = AccessTools.FieldRefAccess<CardBarHandler, CardBar[]>("cardBars");

		private static readonly FieldRef<CardBar, GameObject> SourceRef = AccessTools.FieldRefAccess<CardBar, GameObject>("source");

		private static readonly ManualLogSource Log = Logger.CreateLogSource("CardBarCollapse.State");

		private const float OpenDuration = 0.45f;

		private const float HoverGrace = 0.25f;

		private const float HoverScale = 1.1f;

		private readonly List<Row> rows = new List<Row>();

		private CardBarHandler handler;

		private CardBar[] lastBars;

		private int lastBarCount = -1;

		private GameObject toggleRoot;

		private RectTransform toggleRect;

		private Image toggleFill;

		private Transform hoveredSquare;

		private CardBar hoveredBar;

		private static readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];

		private readonly HashSet<int> fittedIcons = new HashSet<int>();

		private int fitLogs;

		private int dumpLogs;

		private void Awake()
		{
			Instance = this;
		}

		private void Start()
		{
			BuildToggle();
		}

		internal static float ScreenX(Transform square)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			Canvas componentInParent = ((Component)square).GetComponentInParent<Canvas>();
			return RectTransformUtility.WorldToScreenPoint(((Object)(object)componentInParent == (Object)null || (int)componentInParent.renderMode == 0) ? null : componentInParent.worldCamera, square.position).x;
		}

		private void LateUpdate()
		{
			CardPreview.Hold();
		}

		internal bool TryGetRowsBox(CardBar hovered, out Rect box)
		{
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_00f5: 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)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			float num = float.MaxValue;
			float num2 = float.MaxValue;
			float num3 = float.MinValue;
			float num4 = float.MinValue;
			bool value = CardBarCollapsePlugin.Collapsed.Value;
			Rect val3;
			foreach (Row row in rows)
			{
				int count = row.cards.Count;
				if ((Object)(object)row.bar == (Object)null || count == 0 || !((Component)row.bar).gameObject.activeInHierarchy)
				{
					continue;
				}
				bool flag = !value || (Object)(object)row.bar == (Object)(object)hovered;
				float num5 = PixelsPerWorld(row.cam);
				Vector3 lossyScale = ((Component)row.bar).transform.lossyScale;
				for (int i = ((!flag) ? (count - 1) : 0); i < count; i += ((!flag || count <= 1) ? 1 : (count - 1)))
				{
					Transform obj = row.cards[i];
					RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null);
					if (!((Object)(object)val == (Object)null))
					{
						Vector2 val2 = RectTransformUtility.WorldToScreenPoint(row.cam, ((Transform)val).position);
						val3 = val.rect;
						float num6 = ((Rect)(ref val3)).width * 0.5f * Mathf.Abs(lossyScale.x) * num5;
						val3 = val.rect;
						float num7 = ((Rect)(ref val3)).height * 0.5f * Mathf.Abs(lossyScale.y) * num5;
						num = Mathf.Min(num, val2.x - num6);
						num3 = Mathf.Max(num3, val2.x + num6);
						num2 = Mathf.Min(num2, val2.y - num7);
						num4 = Mathf.Max(num4, val2.y + num7);
					}
				}
			}
			Rect val4;
			if (num != float.MaxValue)
			{
				val4 = Rect.MinMaxRect(num, num2, num3, num4);
			}
			else
			{
				val3 = default(Rect);
				val4 = val3;
			}
			box = val4;
			return num != float.MaxValue;
		}

		internal bool TryGetRowsBottom(out float bottomPx)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_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)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			bottomPx = float.MaxValue;
			foreach (Row row in rows)
			{
				if ((Object)(object)row.bar == (Object)null || row.cards.Count == 0 || !((Component)row.bar).gameObject.activeInHierarchy)
				{
					continue;
				}
				foreach (Transform card in row.cards)
				{
					RectTransform val = (RectTransform)(object)((card is RectTransform) ? card : null);
					if (!((Object)(object)val == (Object)null))
					{
						Vector3 val2 = Vector2.op_Implicit(RectTransformUtility.WorldToScreenPoint(row.cam, ((Transform)val).position));
						Rect rect = val.rect;
						float num = ((Rect)(ref rect)).height * 0.5f * Mathf.Abs(((Component)row.bar).transform.lossyScale.y) * PixelsPerWorld(row.cam);
						bottomPx = Mathf.Min(bottomPx, val2.y - num);
						break;
					}
				}
			}
			return bottomPx != float.MaxValue;
		}

		private static float PixelsPerWorld(Camera cam)
		{
			//IL_0010: 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)
			//IL_001a: 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_0021: 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)
			if ((Object)(object)cam == (Object)null)
			{
				return 1f;
			}
			Vector2 val = RectTransformUtility.WorldToScreenPoint(cam, Vector3.zero);
			return Mathf.Abs(RectTransformUtility.WorldToScreenPoint(cam, Vector3.up).y - val.y);
		}

		internal void SetHovered(Transform square, CardBar bar)
		{
			hoveredSquare = square;
			hoveredBar = bar;
			foreach (Row row in rows)
			{
				row.dirty = true;
			}
		}

		internal void ClearHovered(Transform square)
		{
			if ((Object)(object)hoveredSquare == (Object)(object)square)
			{
				hoveredSquare = null;
				hoveredBar = null;
			}
			foreach (Row row in rows)
			{
				row.dirty = true;
			}
		}

		private void BuildToggle()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: 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_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Expected O, but got Unknown
			toggleRoot = new GameObject("CardBarCollapseCanvas", new Type[3]
			{
				typeof(Canvas),
				typeof(CanvasScaler),
				typeof(GraphicRaycaster)
			});
			toggleRoot.transform.SetParent(((Component)this).transform, false);
			Canvas component = toggleRoot.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.sortingOrder = 32000;
			CanvasScaler component2 = toggleRoot.GetComponent<CanvasScaler>();
			component2.uiScaleMode = (ScaleMode)1;
			component2.referenceResolution = new Vector2(1920f, 1080f);
			component2.matchWidthOrHeight = 1f;
			GameObject val = new GameObject("Toggle", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Button)
			});
			val.transform.SetParent(toggleRoot.transform, false);
			toggleRect = (RectTransform)val.transform;
			RectTransform obj = toggleRect;
			RectTransform obj2 = toggleRect;
			RectTransform obj3 = toggleRect;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(1f, 1f);
			obj3.pivot = val2;
			Vector2 anchorMin = (obj2.anchorMax = val2);
			obj.anchorMin = anchorMin;
			toggleRect.anchoredPosition = new Vector2(-6f, -6f);
			((Graphic)val.GetComponent<Image>()).color = new Color(0.08f, 0.08f, 0.1f, 0.85f);
			Button component3 = val.GetComponent<Button>();
			ColorBlock colors = ((Selectable)component3).colors;
			((ColorBlock)(ref colors)).highlightedColor = new Color(1.35f, 1.35f, 1.35f, 1f);
			((ColorBlock)(ref colors)).pressedColor = new Color(0.8f, 0.8f, 0.8f, 1f);
			((Selectable)component3).colors = colors;
			ButtonClickedEvent onClick = component3.onClick;
			object obj4 = <>c.<>9__26_0;
			if (obj4 == null)
			{
				UnityAction val4 = delegate
				{
					CardBarCollapsePlugin.Collapsed.Value = !CardBarCollapsePlugin.Collapsed.Value;
				};
				<>c.<>9__26_0 = val4;
				obj4 = (object)val4;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj4);
			GameObject val5 = new GameObject("Fill", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val5.transform.SetParent(val.transform, false);
			RectTransform val6 = (RectTransform)val5.transform;
			val6.anchorMin = new Vector2(0.25f, 0.25f);
			val6.anchorMax = new Vector2(0.75f, 0.75f);
			anchorMin = (val6.offsetMax = Vector2.zero);
			val6.offsetMin = anchorMin;
			toggleFill = val5.GetComponent<Image>();
			((Graphic)toggleFill).raycastTarget = false;
			toggleRoot.SetActive(false);
		}

		private void Update()
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			CardBarHandler instance = CardBarHandler.instance;
			if ((Object)(object)instance != (Object)(object)handler)
			{
				handler = instance;
				RebuildRows();
			}
			bool flag = (Object)(object)handler != (Object)null && ((Behaviour)handler).isActiveAndEnabled;
			if (toggleRoot.activeSelf != flag)
			{
				toggleRoot.SetActive(flag);
			}
			if ((Object)(object)hoveredBar != (Object)null && ((Object)(object)hoveredSquare == (Object)null || !((Component)hoveredSquare).gameObject.activeInHierarchy))
			{
				try
				{
					hoveredBar.StopHover();
				}
				catch (Exception)
				{
				}
				hoveredBar = null;
				hoveredSquare = null;
			}
			if (!flag)
			{
				return;
			}
			float value = CardBarCollapsePlugin.ButtonSize.Value;
			if (toggleRect.sizeDelta.x != value)
			{
				toggleRect.sizeDelta = new Vector2(value, value);
			}
			bool value2 = CardBarCollapsePlugin.Collapsed.Value;
			((Graphic)toggleFill).color = (value2 ? new Color(1f, 1f, 1f, 0.9f) : new Color(1f, 1f, 1f, 0.25f));
			CardBar[] array = BarsRef.Invoke(handler);
			if (array == null)
			{
				return;
			}
			if (array != lastBars || array.Length != lastBarCount)
			{
				RebuildRows();
			}
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			float num = CardBarCollapsePlugin.AnimSpeed.Value / 0.45f;
			Vector2 val = Vector2.op_Implicit(Input.mousePosition);
			foreach (Row row in rows)
			{
				if ((Object)(object)row.bar == (Object)null)
				{
					continue;
				}
				if ((Object)(object)row.chip == (Object)null)
				{
					BuildChip(row);
					row.lastChildCount = -1;
				}
				bool activeInHierarchy = ((Component)row.bar).gameObject.activeInHierarchy;
				if ((Object)(object)row.chip != (Object)null && ((Component)row.chip).gameObject.activeSelf != activeInHierarchy)
				{
					((Component)row.chip).gameObject.SetActive(activeInHierarchy);
				}
				RefreshCards(row);
				if (row.fitFrames > 0 && --row.fitFrames == 0)
				{
					FitIcons(row);
				}
				bool flag2 = row.cards.Count > 0;
				if (value2 && flag2)
				{
					if ((Object)(object)row.chip != (Object)null && row.open == 0f && row.chipShown == 1f)
					{
						row.chipScreen = ScreenRect(row.chip, row.cam);
					}
					bool flag3 = ((Rect)(ref row.chipScreen)).Contains(val);
					if (!flag3 && row.open > 0.5f)
					{
						foreach (Transform card in row.cards)
						{
							if ((Object)(object)card != (Object)null && Contains((RectTransform)(object)((card is RectTransform) ? card : null), val, row.cam))
							{
								flag3 = true;
								break;
							}
						}
					}
					row.hoverTimer = (flag3 ? 0.25f : Mathf.Max(0f, row.hoverTimer - unscaledDeltaTime));
				}
				else
				{
					row.hoverTimer = 0f;
				}
				float num2 = ((!value2 || row.hoverTimer > 0f) ? 1f : 0f);
				float num3 = ((value2 && flag2) ? 1f : 0f);
				if (row.open != num2 || row.chipShown != num3 || row.dirty)
				{
					row.open = Mathf.MoveTowards(row.open, num2, unscaledDeltaTime * num);
					row.chipShown = Mathf.MoveTowards(row.chipShown, num3, unscaledDeltaTime * num * 1.6f);
					ApplyRow(row);
					if (row.layoutFrames > 0)
					{
						row.layoutFrames--;
					}
					else
					{
						row.dirty = false;
					}
				}
			}
		}

		private static Rect ScreenRect(RectTransform rt, Camera cam)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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)
			rt.GetWorldCorners(corners);
			Vector2 val = RectTransformUtility.WorldToScreenPoint(cam, corners[0]);
			Vector2 val2 = RectTransformUtility.WorldToScreenPoint(cam, corners[2]);
			return Rect.MinMaxRect(Mathf.Min(val.x, val2.x), Mathf.Min(val.y, val2.y), Mathf.Max(val.x, val2.x), Mathf.Max(val.y, val2.y));
		}

		private static bool Contains(RectTransform rt, Vector2 p, Camera cam)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rt != (Object)null && ((Component)rt).gameObject.activeInHierarchy)
			{
				return RectTransformUtility.RectangleContainsScreenPoint(rt, p, cam);
			}
			return false;
		}

		private void RebuildRows()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			foreach (Row row2 in rows)
			{
				if ((Object)(object)row2.chip != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)row2.chip).gameObject);
				}
			}
			rows.Clear();
			lastBars = null;
			lastBarCount = -1;
			if ((Object)(object)handler == (Object)null)
			{
				return;
			}
			CardBar[] array = BarsRef.Invoke(handler);
			if (array == null)
			{
				return;
			}
			lastBars = array;
			lastBarCount = array.Length;
			for (int i = 0; i < array.Length; i++)
			{
				if (!((Object)(object)array[i] == (Object)null))
				{
					Row row = new Row
					{
						bar = array[i],
						index = i,
						open = (CardBarCollapsePlugin.Collapsed.Value ? 0f : 1f)
					};
					Canvas componentInParent = ((Component)array[i]).GetComponentInParent<Canvas>();
					row.cam = (((Object)(object)componentInParent == (Object)null || (int)componentInParent.renderMode == 0) ? null : componentInParent.worldCamera);
					BuildChip(row);
					rows.Add(row);
				}
			}
		}

		private void BuildChip(Row r)
		{
			//IL_0059: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = SourceRef.Invoke(r.bar);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform val2 = (((Object)(object)((Component)r.bar).transform.parent != (Object)null) ? ((Component)r.bar).transform.parent : ((Component)r.bar).transform);
			GameObject val3 = Object.Instantiate<GameObject>(val, val.transform.position, val.transform.rotation, val2);
			((Object)val3).name = "CollapseChip";
			CardBarButton[] componentsInChildren = val3.GetComponentsInChildren<CardBarButton>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			(val3.GetComponent<LayoutElement>() ?? val3.AddComponent<LayoutElement>()).ignoreLayout = true;
			val3.SetActive(true);
			r.chip = (RectTransform)val3.transform;
			((Transform)r.chip).SetAsLastSibling();
			r.chipText = val3.GetComponentInChildren<TextMeshProUGUI>(true);
			r.chipImage = null;
			float num = -1f;
			Image[] componentsInChildren2 = val3.GetComponentsInChildren<Image>(true);
			foreach (Image val4 in componentsInChildren2)
			{
				Rect rect = ((Graphic)val4).rectTransform.rect;
				float width = ((Rect)(ref rect)).width;
				rect = ((Graphic)val4).rectTransform.rect;
				float num2 = width * ((Rect)(ref rect)).height;
				if (num2 > num)
				{
					num = num2;
					r.chipImage = val4;
				}
			}
			if ((Object)(object)r.chipImage != (Object)null)
			{
				((Graphic)r.chipImage).color = PlayerColor(r.index);
			}
			((Transform)r.chip).localScale = Vector3.zero;
		}

		private static Color PlayerColor(int playerId)
		{
			//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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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)
			try
			{
				PlayerManager instance = PlayerManager.instance;
				if ((Object)(object)instance != (Object)null)
				{
					foreach (Player player in instance.players)
					{
						if ((Object)(object)player != (Object)null && player.playerID == playerId)
						{
							return ExtraPlayerSkins.GetPlayerSkinColors(PlayerExtensions.colorID(player)).color;
						}
					}
				}
				return ExtraPlayerSkins.GetPlayerSkinColors(playerId).color;
			}
			catch
			{
				return Color.gray;
			}
		}

		private void RefreshCards(Row r)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)r.bar).transform;
			if (transform.childCount == r.lastChildCount)
			{
				return;
			}
			r.lastChildCount = transform.childCount;
			GameObject val = SourceRef.Invoke(r.bar);
			r.cards.Clear();
			for (int i = 0; i < transform.childCount; i++)
			{
				Transform child = transform.GetChild(i);
				if ((!((Object)(object)val != (Object)null) || !((Object)(object)((Component)child).gameObject == (Object)(object)val)) && !((Object)(object)((Component)child).GetComponent<CardBarButton>() == (Object)null))
				{
					r.cards.Add(child);
				}
			}
			if ((Object)(object)r.chip != (Object)null)
			{
				if ((Object)(object)r.chipImage != (Object)null)
				{
					((Graphic)r.chipImage).color = PlayerColor(r.index);
				}
				if ((Object)(object)r.chipText != (Object)null)
				{
					((TMP_Text)r.chipText).text = (CardBarCollapsePlugin.ShowCount.Value ? r.cards.Count.ToString() : "");
				}
			}
			r.fitFrames = 3;
			r.dirty = true;
			r.layoutFrames = 2;
		}

		private void FitIcons(Row r)
		{
			//IL_005e: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: 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_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: 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_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: 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_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: 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_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform card in r.cards)
			{
				if ((Object)(object)card == (Object)null || !fittedIcons.Add(((Object)card).GetInstanceID()))
				{
					continue;
				}
				Transform val = null;
				Transform[] componentsInChildren = ((Component)card).GetComponentsInChildren<Transform>(true);
				foreach (Transform val2 in componentsInChildren)
				{
					if ((Object)(object)val2 != (Object)(object)card && Mathf.Abs(val2.localScale.x - 0.15f) < 0.001f && Mathf.Abs(val2.localScale.y - 0.15f) < 0.001f)
					{
						val = val2;
						break;
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Transform parent = val.parent;
				RectTransform val3 = (RectTransform)(object)((parent is RectTransform) ? parent : null);
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				try
				{
					Rect rect = val3.rect;
					Vector2 size = ((Rect)(ref rect)).size;
					Bounds val4 = MeasureArt(val3, val);
					if (((Bounds)(ref val4)).size.x < 0.01f || ((Bounds)(ref val4)).size.y < 0.01f || size.x < 1f)
					{
						if (fitLogs++ < 6)
						{
							Log.LogInfo((object)("icon '" + ((Object)val).name + "': could not measure the picture"));
						}
						if (dumpLogs++ < 2)
						{
							Dump(card, "", 0);
						}
						continue;
					}
					RectTransform val5 = (RectTransform)(object)((val is RectTransform) ? val : null);
					bool num = ((Bounds)(ref val4)).size.x <= size.x * 0.6f && ((Bounds)(ref val4)).size.y <= size.y * 0.6f;
					int num2;
					if ((Object)(object)val5 != (Object)null)
					{
						rect = val5.rect;
						if (Mathf.Abs(((Rect)(ref rect)).width - size.x) <= size.x * 0.02f)
						{
							rect = val5.rect;
							num2 = ((Mathf.Abs(((Rect)(ref rect)).height - size.y) <= size.y * 0.02f) ? 1 : 0);
							goto IL_0229;
						}
					}
					num2 = 0;
					goto IL_0229;
					IL_0229:
					bool flag = (byte)num2 != 0;
					string text;
					if (num && flag)
					{
						val.localScale = Vector3.one;
						rect = val3.rect;
						Vector2 center = ((Rect)(ref rect)).center;
						rect = val5.rect;
						Vector2 center2 = ((Rect)(ref rect)).center;
						val.localPosition = new Vector3(center.x - center2.x, center.y - center2.y, val.localPosition.z);
						text = "drawn at frame size, restored to full size";
					}
					else
					{
						float num3 = Mathf.Min(size.x / ((Bounds)(ref val4)).size.x, size.y / ((Bounds)(ref val4)).size.y);
						if (num3 <= 1.1f)
						{
							text = "already fills the frame, left as is";
						}
						else
						{
							num3 = Mathf.Min(num3, 10f);
							Vector3 localPosition = val.localPosition;
							Vector3 center3 = ((Bounds)(ref val4)).center;
							rect = val3.rect;
							Vector2 center4 = ((Rect)(ref rect)).center;
							Transform obj = val;
							obj.localScale *= num3;
							val.localPosition = new Vector3(center4.x - (center3.x - localPosition.x) * num3, center4.y - (center3.y - localPosition.y) * num3, localPosition.z);
							text = "enlarged x" + num3.ToString("F2");
						}
					}
					if (fitLogs++ < 8)
					{
						Log.LogInfo((object)$"icon '{((Object)val).name}': picture {((Bounds)(ref val4)).size.x:F1} x {((Bounds)(ref val4)).size.y:F1} in a {size.x:F0} x {size.y:F0} frame -> {text}");
					}
				}
				catch (Exception ex)
				{
					if (fitLogs++ < 8)
					{
						Log.LogWarning((object)("icon sizing failed: " + ex.Message));
					}
				}
			}
		}

		private static Bounds MeasureArt(RectTransform frame, Transform art)
		{
			//IL_0004: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			Bounds result = default(Bounds);
			Graphic[] componentsInChildren = ((Component)art).GetComponentsInChildren<Graphic>(true);
			Vector3 val2 = default(Vector3);
			foreach (Graphic val in componentsInChildren)
			{
				if (!((Behaviour)val).enabled || !((Component)val).gameObject.activeSelf || val.color.a < 0.02f)
				{
					continue;
				}
				Rect rect = val.rectTransform.rect;
				for (int j = 0; j < 4; j++)
				{
					((Vector3)(ref val2))..ctor((j < 2) ? ((Rect)(ref rect)).xMin : ((Rect)(ref rect)).xMax, (j % 2 == 0) ? ((Rect)(ref rect)).yMin : ((Rect)(ref rect)).yMax, 0f);
					Transform val3 = ((Component)val).transform;
					while ((Object)(object)val3 != (Object)null && (Object)(object)val3 != (Object)(object)frame)
					{
						val2 = val3.localRotation * Vector3.Scale(val2, val3.localScale) + val3.localPosition;
						val3 = val3.parent;
					}
					val2.z = 0f;
					if (!flag)
					{
						((Bounds)(ref result))..ctor(val2, Vector3.zero);
						flag = true;
					}
					else
					{
						((Bounds)(ref result)).Encapsulate(val2);
					}
				}
			}
			if (!flag)
			{
				return new Bounds(Vector3.zero, Vector3.zero);
			}
			return result;
		}

		private void Dump(Transform t, string indent, int depth)
		{
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_0105: Expected O, but got Unknown
			if (depth > 5)
			{
				return;
			}
			string text = "";
			Component[] components = ((Component)t).GetComponents<Component>();
			foreach (Component val in components)
			{
				if (!((Object)(object)val == (Object)null) && !(val is Transform) && !(val is CanvasRenderer))
				{
					text = text + ((object)val).GetType().Name + " ";
				}
			}
			RectTransform val2 = (RectTransform)(object)((t is RectTransform) ? t : null);
			ManualLogSource log = Log;
			object[] obj = new object[6]
			{
				indent,
				((Object)t).name,
				t.localScale.x,
				null,
				null,
				null
			};
			object obj2;
			if (!((Object)(object)val2 != (Object)null))
			{
				obj2 = "-";
			}
			else
			{
				Rect rect = val2.rect;
				Vector2 size = ((Rect)(ref rect)).size;
				obj2 = ((Vector2)(ref size)).ToString("F0");
			}
			obj[3] = obj2;
			obj[4] = ((Component)t).gameObject.activeSelf;
			obj[5] = text.Trim();
			log.LogInfo((object)string.Format("square> {0}{1} scale={2:F3} size={3} active={4} [{5}]", obj));
			int num = 0;
			foreach (Transform item in t)
			{
				Transform t2 = item;
				if (num++ >= 8)
				{
					break;
				}
				Dump(t2, indent + "  ", depth + 1);
			}
		}

		private void ApplyRow(Row r)
		{
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			int count = r.cards.Count;
			float num = 0.55f;
			for (int i = 0; i < count; i++)
			{
				Transform val = r.cards[i];
				if (!((Object)(object)val == (Object)null))
				{
					int num2 = count - 1 - i;
					float num3 = 0.15f + ((count > 1) ? (num * (float)num2 / (float)(count - 1)) : 0f);
					float num4 = Mathf.Clamp01((r.open - num3) / 0.3f);
					float num5 = ((num4 >= 1f) ? 1f : ((num4 <= 0f) ? 0f : EaseOutBack(num4)));
					if (num4 >= 1f && (Object)(object)val == (Object)(object)hoveredSquare)
					{
						num5 = 1.1f;
					}
					val.localScale = new Vector3(num5, num5, 1f);
				}
			}
			if (!((Object)(object)r.chip != (Object)null))
			{
				return;
			}
			GameObject val2 = SourceRef.Invoke(r.bar);
			Transform val3 = ((count > 0 && (Object)(object)r.cards[count - 1] != (Object)null) ? r.cards[count - 1] : (((Object)(object)val2 != (Object)null) ? val2.transform : null));
			if ((Object)(object)val3 != (Object)null)
			{
				((Transform)r.chip).position = val3.position;
				((Transform)r.chip).rotation = val3.rotation;
				RectTransform val4 = (RectTransform)(object)((val3 is RectTransform) ? val3 : null);
				if (val4 != null)
				{
					Rect rect = val4.rect;
					if (((Rect)(ref rect)).width > 1f)
					{
						RectTransform chip = r.chip;
						rect = val4.rect;
						chip.sizeDelta = ((Rect)(ref rect)).size;
					}
				}
			}
			Transform parent = ((Transform)r.chip).parent;
			Vector3 lossyScale = ((Component)r.bar).transform.lossyScale;
			Vector3 val5 = (((Object)(object)parent != (Object)null) ? parent.lossyScale : Vector3.one);
			float num6 = Safe(lossyScale.x, val5.x);
			float num7 = Safe(lossyScale.y, val5.y);
			float x = Mathf.Clamp01(r.open / 0.25f);
			float num8 = EaseOutBack(r.chipShown) * (1f - EaseInCubic(x));
			((Transform)r.chip).localScale = new Vector3(num6 * num8, num7 * num8, 1f);
		}

		private static float Safe(float a, float b)
		{
			if (!(Mathf.Abs(b) < 1E-06f))
			{
				return a / b;
			}
			return 1f;
		}

		private static float EaseInCubic(float x)
		{
			return x * x * x;
		}

		private static float EaseOutBack(float x)
		{
			float num = x - 1f;
			return 1f + 2.2f * num * num * num + 1.2f * num * num;
		}

		private void OnDestroy()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			foreach (Row row in rows)
			{
				if ((Object)(object)row.chip != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)row.chip).gameObject);
				}
				foreach (Transform card in row.cards)
				{
					if ((Object)(object)card != (Object)null)
					{
						card.localScale = Vector3.one;
					}
				}
			}
		}
	}
}