Decompiled source of LeanAndMeanCards v1.2.4

LeanAndMeanCards.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CardChoiceSpawnUniqueCardPatch.CustomCategories;
using HarmonyLib;
using LeanAndMeanCards.Cards;
using LeanAndMeanCards.Patches;
using LeanAndMeanCards.Utils;
using Microsoft.CodeAnalysis;
using ModdingUtils.Extensions;
using ModdingUtils.Utils;
using Photon.Pun;
using Photon.Realtime;
using Sonigon;
using SoundImplementation;
using TMPro;
using UnboundLib;
using UnboundLib.Cards;
using UnboundLib.GameModes;
using UnboundLib.Networking;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LeanAndMeanCards")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.2.4+65ac76020c6e67ccf46e55f26574d762424dab98")]
[assembly: AssemblyProduct("LeanAndMeanCards")]
[assembly: AssemblyTitle("LeanAndMeanCards")]
[assembly: AssemblyVersion("1.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 LeanAndMeanCards
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.ljindustries.rounds.leanandmeancards", "Lean and Mean Cards", "1.2.4")]
	[BepInProcess("Rounds.exe")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModId = "com.ljindustries.rounds.leanandmeancards";

		public const string ModName = "Lean and Mean Cards";

		public const string Version = "1.2.4";

		public const string ModInitials = "LMC";

		public const string CardsMenuName = "LeanAndMeanCards";

		internal static Configs Configs;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Instance = this;
			Configs = new Configs(((BaseUnityPlugin)this).Config);
			try
			{
				Harmony val = new Harmony("com.ljindustries.rounds.leanandmeancards");
				Type[] types;
				try
				{
					types = typeof(Plugin).Assembly.GetTypes();
				}
				catch (ReflectionTypeLoadException ex)
				{
					types = ex.Types;
					ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
					Exception?[] loaderExceptions = ex.LoaderExceptions;
					logger.LogWarning((object)$"GetTypes partial load: {((loaderExceptions != null) ? loaderExceptions.Length : 0)} loader error(s)");
				}
				Type[] array = types;
				foreach (Type type in array)
				{
					if (!(type == null))
					{
						try
						{
							val.CreateClassProcessor(type).Patch();
						}
						catch (Exception ex2)
						{
							((BaseUnityPlugin)this).Logger.LogWarning((object)("Harmony skip " + type.FullName + ": " + ex2.GetType().Name + ": " + ex2.Message));
						}
					}
				}
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Harmony patching failed: {arg}");
			}
		}

		private void Start()
		{
			CardRegistration.RegisterAll();
			CardArtFactory.BindLoadedCardInfos();
			BozoShoesRuntime.RegisterHooks();
			DynamiteBlast.RegisterHooks();
			SilverEggManager.RegisterHooks();
			CardStatus.Register();
			ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)Instance, 0.8f, (Action)DynamiteBlast.Warmup);
			ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)Instance, 2.5f, (Action)DynamiteBlast.Warmup);
			ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)Instance, 0.5f, (Action)CardArtFactory.BindLoadedCardInfos);
			ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)Instance, 2.5f, (Action)CardArtFactory.BindLoadedCardInfos);
			ExtensionMethods.GetOrAddComponent<DraftSniperTicker>(((Component)this).gameObject, false);
			GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)OnGameStart);
			GameModeManager.AddHook("PlayerPickStart", (Func<IGameModeHandler, IEnumerator>)OnPlayerPickStart);
			GameModeManager.AddHook("PlayerPickEnd", (Func<IGameModeHandler, IEnumerator>)OnPlayerPickEnd);
			GameModeManager.AddHook("PickEnd", (Func<IGameModeHandler, IEnumerator>)OnPickEnd);
		}

		private static IEnumerator OnGameStart(IGameModeHandler gm)
		{
			StealLedger.ResetForNewGame();
			SandbagManager.ResetForNewGame();
			PickUiHold.Reset();
			CurseOnlyPlayers.InvalidateTargets();
			CurseOnlyPlayers.ResetCache();
			DraftSniperManager.ResetForNewGame();
			BozoShoesRuntime.Clear();
			SilverEggManager.ResetForNewGame();
			SafetyNetEscape.Reset();
			yield break;
		}

		private static IEnumerator OnPlayerPickStart(IGameModeHandler gm)
		{
			DraftSniperManager.ResetForPick();
			CurseOnlyPlayers.ResetCache();
			StealLedger.TryOpenDeferredThiefPrompt();
			CardBarMiniIcons.RestampAll();
			ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)Instance, 0.25f, (Action)CardBarMiniIcons.RestampAll);
			ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)Instance, 1f, (Action)CardBarMiniIcons.RestampAll);
			yield break;
		}

		private static IEnumerator OnPlayerPickEnd(IGameModeHandler gm)
		{
			while (PickUiHold.ShouldWait)
			{
				yield return null;
			}
			DraftSniperManager.ResetForPick();
		}

		private static IEnumerator OnPickEnd(IGameModeHandler gm)
		{
			while (PickUiHold.ShouldWait)
			{
				yield return null;
			}
			DraftSniperManager.ResetForPick();
			PickPhase.ClearActingPicker();
		}

		internal void Log(string message)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[Lean and Mean Cards] " + message));
		}

		internal void LogWarn(string message)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[Lean and Mean Cards] " + message));
		}
	}
	internal class Configs
	{
		public ConfigEntry<bool> SandbagOncePerGame { get; }

		public ConfigEntry<bool> SoftenCardGlow { get; }

		public ConfigEntry<string> CurseOnlySteamIds { get; }

		public Configs(ConfigFile config)
		{
			SandbagOncePerGame = config.Bind<bool>("Cards", "SandbagOncePerGame", true, "Sandbag Simulator can only be used once per game. Set by the host.");
			SoftenCardGlow = config.Bind<bool>("Visuals", "SoftenCardGlow", true, "Kill the particle glow on this pack's pick cards and mini icons. Sticker outlines stay.");
			CurseOnlySteamIds = config.Bind<string>("Curse Only", "SteamIds", "76561198284769933", "Comma-separated Steam64 IDs that are only ever offered curses. Empty disables it.");
		}
	}
	[HarmonyPatch(typeof(CardChoice), "StartPick")]
	internal static class StartPickTrackerPatch
	{
		private static void Postfix(int pickerIDToSet)
		{
			PickPhase.NoteActingPicker(pickerIDToSet);
		}
	}
	internal sealed class DraftSniperTicker : MonoBehaviour
	{
		private void Update()
		{
			DraftSniperManager.Tick();
		}
	}
}
namespace LeanAndMeanCards.Utils
{
	internal static class BozoShoesRuntime
	{
		private const string VisualName = "MM_BozoMark";

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

		private static Sprite _shoeSprite;

		private static Sprite _labelSprite;

		internal static void RegisterHooks()
		{
			GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)OnClear);
			GameModeManager.AddHook("RoundEnd", (Func<IGameModeHandler, IEnumerator>)OnClear);
			GameModeManager.AddHook("PointStart", (Func<IGameModeHandler, IEnumerator>)OnPointStart);
		}

		internal static void Clear()
		{
			Marked.Clear();
			StripAllVisuals();
		}

		internal static bool IsMarked(Player player)
		{
			if ((Object)(object)player != (Object)null)
			{
				return Marked.Contains(player.playerID);
			}
			return false;
		}

		internal static void Mark(Player victim)
		{
			if (!((Object)(object)victim == (Object)null))
			{
				Marked.Add(victim.playerID);
				AttachVisual(victim);
				EnsureTicker(victim);
			}
		}

		private static IEnumerator OnClear(IGameModeHandler gm)
		{
			Clear();
			yield break;
		}

		private static IEnumerator OnPointStart(IGameModeHandler gm)
		{
			yield return null;
			ReapplyVisuals();
		}

		private static void ReapplyVisuals()
		{
			List<Player> list = PlayerManager.instance?.players;
			if (list == null)
			{
				return;
			}
			foreach (Player item in list)
			{
				if (IsMarked(item))
				{
					AttachVisual(item);
					EnsureTicker(item);
				}
			}
		}

		private static void StripAllVisuals()
		{
			List<Player> list = PlayerManager.instance?.players;
			if (list == null)
			{
				return;
			}
			foreach (Player item in list)
			{
				StripVisual(item);
				BozoShoesTicker bozoShoesTicker = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponent<BozoShoesTicker>() : null);
				if ((Object)(object)bozoShoesTicker != (Object)null)
				{
					Object.Destroy((Object)(object)bozoShoesTicker);
				}
			}
		}

		private static void StripVisual(Player player)
		{
			if (!((Object)(object)player == (Object)null))
			{
				GameObject val = FindVisual(player);
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
		}

		private static GameObject FindVisual(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			Transform val = ((Component)player).transform.Find("MM_BozoMark");
			if (!((Object)(object)val != (Object)null))
			{
				return null;
			}
			return ((Component)val).gameObject;
		}

		private static void EnsureTicker(Player player)
		{
			if (!((Object)(object)player == (Object)null) && (Object)(object)((Component)player).GetComponent<BozoShoesTicker>() == (Object)null)
			{
				((Component)player).gameObject.AddComponent<BozoShoesTicker>();
			}
		}

		internal static void AttachVisual(Player player)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_003c: 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_005c: 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_00c9: 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_00f1: 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_0126: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || (Object)(object)FindVisual(player) != (Object)null)
			{
				return;
			}
			GameObject val = new GameObject("MM_BozoMark");
			val.transform.SetParent(((Component)player).transform, false);
			val.transform.localPosition = Vector3.zero;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one;
			val.layer = ((Component)player).gameObject.layer;
			int num = 80;
			string layer = "Default";
			SpriteRenderer componentInChildren = ((Component)player).GetComponentInChildren<SpriteRenderer>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				num = ((Renderer)componentInChildren).sortingOrder + 40;
				if (!string.IsNullOrEmpty(((Renderer)componentInChildren).sortingLayerName))
				{
					layer = ((Renderer)componentInChildren).sortingLayerName;
				}
			}
			AddSprite(val.transform, "Label", LabelSprite(), Vector3.zero, 0f, Vector3.one, num + 2, layer);
			AddSprite(val.transform, "ShoeL", ShoeSprite(), Vector3.zero, 22f, Vector3.one, num, layer);
			AddSprite(val.transform, "ShoeR", ShoeSprite(), Vector3.zero, -22f, new Vector3(-1f, 1f, 1f), num, layer);
			Pose(player, val);
		}

		internal static void Pose(Player player)
		{
			GameObject val = FindVisual(player);
			if (!((Object)(object)val == (Object)null))
			{
				Pose(player, val);
			}
		}

		private static void Pose(Player player, GameObject root)
		{
			//IL_0037: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//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_010b: 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_0121: 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_00ce: 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_00ea: 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_0101: 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_012f: 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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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_0189: 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_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (((Object)(object)player.data?.playerVel != (Object)null) ? ((Component)player.data.playerVel).transform.position : ((Component)player).transform.position);
			float num = 1f;
			if ((Object)(object)player.data?.stats != (Object)null)
			{
				num = Mathf.Max(0.45f, player.data.stats.sizeMultiplier);
			}
			Vector3 val2 = val + Vector3.up * (0.85f * num);
			Transform val3 = root.transform.Find("Label");
			Transform val4 = root.transform.Find("ShoeL");
			Transform val5 = root.transform.Find("ShoeR");
			if ((Object)(object)val3 != (Object)null)
			{
				val3.position = val2 + Vector3.up * (0.58f * num);
				val3.rotation = Quaternion.identity;
				val3.localScale = Vector3.one * (0.95f * num);
			}
			Vector3 val6 = val + Vector3.down * (0.92f * num);
			if ((Object)(object)val4 != (Object)null)
			{
				val4.position = val6 + Vector3.left * (0.28f * num);
				val4.rotation = Quaternion.Euler(0f, 0f, 18f);
				val4.localScale = Vector3.one * (0.55f * num);
			}
			if ((Object)(object)val5 != (Object)null)
			{
				val5.position = val6 + Vector3.right * (0.28f * num);
				val5.rotation = Quaternion.Euler(0f, 0f, -18f);
				val5.localScale = new Vector3(-0.55f * num, 0.55f * num, 1f);
			}
		}

		private static void AddSprite(Transform parent, string name, Sprite sprite, Vector3 localPos, float zRot, Vector3 localScale, int sort, string layer)
		{
			//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_0026: 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_0032: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			GameObject val = new GameObject(name, new Type[1] { typeof(SpriteRenderer) });
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localRotation = Quaternion.Euler(0f, 0f, zRot);
			val.transform.localScale = localScale;
			val.layer = ((Component)parent).gameObject.layer;
			SpriteRenderer component = val.GetComponent<SpriteRenderer>();
			component.sprite = sprite;
			((Renderer)component).sortingOrder = sort;
			((Renderer)component).sortingLayerName = layer;
			component.color = Color.white;
		}

		private static Sprite ShoeSprite()
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_014f: 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_00d3: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if ((Object)(object)_shoeSprite != (Object)null)
			{
				return _shoeSprite;
			}
			Texture2D val = new Texture2D(80, 48, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1
			};
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(1f, 0.93f, 0.82f, 1f);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.95f, 0.12f, 0.18f, 1f);
			Color val4 = default(Color);
			((Color)(ref val4))..ctor(1f, 0.86f, 0.12f, 1f);
			float num = 39.5f;
			float num2 = 21.62f;
			float num3 = 36.8f;
			float num4 = 19.2f;
			for (int i = 0; i < 48; i++)
			{
				for (int j = 0; j < 80; j++)
				{
					float num5 = ((float)j - num) / num3;
					float num6 = ((float)i - num2) / num4;
					float num7 = num5 * num5 + num6 * num6;
					if (num7 > 1f)
					{
						val.SetPixel(j, i, Color.clear);
						continue;
					}
					Color val5 = ((num7 > 0.78f) ? val2 : ((!(num6 > -0.12f) || !(num6 < 0.28f)) ? val3 : val4));
					val.SetPixel(j, i, val5);
				}
			}
			val.Apply();
			Object.DontDestroyOnLoad((Object)(object)val);
			_shoeSprite = Sprite.Create(val, new Rect(0f, 0f, 80f, 48f), new Vector2(0.5f, 0.5f), 48f);
			return _shoeSprite;
		}

		private static Sprite LabelSprite()
		{
			//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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_035f: 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_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_labelSprite != (Object)null)
			{
				return _labelSprite;
			}
			Texture2D tex = new Texture2D(132, 36, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)1
			};
			Color clear = Color.clear;
			for (int i = 0; i < 36; i++)
			{
				for (int j = 0; j < 132; j++)
				{
					tex.SetPixel(j, i, clear);
				}
			}
			Color c = default(Color);
			((Color)(ref c))..ctor(1f, 0.88f, 0.12f, 1f);
			Color c2 = default(Color);
			((Color)(ref c2))..ctor(0.05f, 0.04f, 0.04f, 1f);
			Color c3 = default(Color);
			((Color)(ref c3))..ctor(1f, 0.94f, 0.84f, 1f);
			int[][] array = new int[4][]
			{
				new int[7] { 30, 17, 30, 17, 17, 17, 30 },
				new int[7] { 14, 17, 17, 17, 17, 17, 14 },
				new int[7] { 31, 1, 2, 4, 8, 16, 31 },
				new int[7] { 14, 17, 17, 17, 17, 17, 14 }
			};
			int num = array.Length * 5 * 3 + (array.Length - 1) * 4;
			int num2 = (132 - num) / 2;
			int num3 = 7;
			for (int k = 0; k < array.Length; k++)
			{
				int[] array2 = array[k];
				int num4 = num2 + k * 19;
				for (int l = 0; l < 7; l++)
				{
					int num5 = array2[l];
					for (int m = 0; m < 5; m++)
					{
						if ((num5 & (1 << 4 - m)) == 0)
						{
							continue;
						}
						for (int n = 0; n < 3; n++)
						{
							for (int num6 = 0; num6 < 3; num6++)
							{
								int gx = num4 + m * 3 + num6;
								int gy = num3 + (6 - l) * 3 + n;
								Stamp(gx, gy, c3);
							}
						}
					}
				}
			}
			for (int num7 = 0; num7 < array.Length; num7++)
			{
				int[] array3 = array[num7];
				int num8 = num2 + num7 * 19;
				for (int num9 = 0; num9 < 7; num9++)
				{
					int num10 = array3[num9];
					for (int num11 = 0; num11 < 5; num11++)
					{
						if ((num10 & (1 << 4 - num11)) == 0)
						{
							continue;
						}
						for (int num12 = 0; num12 < 3; num12++)
						{
							for (int num13 = 0; num13 < 3; num13++)
							{
								int px = num8 + num11 * 3 + num13;
								int py = num3 + (6 - num9) * 3 + num12;
								Plot(px, py, c2);
							}
						}
					}
				}
			}
			for (int num14 = 0; num14 < array.Length; num14++)
			{
				int[] array4 = array[num14];
				int num15 = num2 + num14 * 19;
				for (int num16 = 0; num16 < 7; num16++)
				{
					int num17 = array4[num16];
					for (int num18 = 0; num18 < 5; num18++)
					{
						if ((num17 & (1 << 4 - num18)) == 0)
						{
							continue;
						}
						for (int num19 = 1; num19 < 2; num19++)
						{
							for (int num20 = 1; num20 < 2; num20++)
							{
								int px2 = num15 + num18 * 3 + num20;
								int py2 = num3 + (6 - num16) * 3 + num19;
								Plot(px2, py2, c);
							}
						}
					}
				}
			}
			tex.Apply();
			Object.DontDestroyOnLoad((Object)(object)tex);
			_labelSprite = Sprite.Create(tex, new Rect(0f, 0f, 132f, 36f), new Vector2(0.5f, 0.5f), 32f);
			return _labelSprite;
			void Plot(int num21, int num22, Color val)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				if (num21 >= 0 && num22 >= 0 && num21 < 132 && num22 < 36)
				{
					tex.SetPixel(num21, num22, val);
				}
			}
			void Stamp(int num23, int num24, Color c4)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				for (int num21 = -1; num21 <= 1; num21++)
				{
					for (int num22 = -1; num22 <= 1; num22++)
					{
						Plot(num23 + num22, num24 + num21, c4);
					}
				}
			}
		}
	}
	internal sealed class BozoShoesTicker : MonoBehaviour
	{
		private Player _player;

		private void Awake()
		{
			_player = ((Component)this).GetComponent<Player>();
		}

		private void LateUpdate()
		{
			if (!((Object)(object)_player == (Object)null))
			{
				if (!BozoShoesRuntime.IsMarked(_player))
				{
					Object.Destroy((Object)(object)this);
					return;
				}
				BozoShoesRuntime.AttachVisual(_player);
				BozoShoesRuntime.Pose(_player);
			}
		}
	}
	internal sealed class MmCardArtTag : MonoBehaviour
	{
		public string ArtName;
	}
	internal static class CardArtFactory
	{
		private static readonly HashSet<string> RegisteredCardNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, string> CardNameToArt = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

		private static readonly HashSet<string> MissingMiniLogged = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static readonly HashSet<string> ArtNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static string _artFolder;

		private static bool _artFolderResolved;

		private static bool _artIndexBuilt;

		private static bool _folderLogged;

		private static Sprite _vanillaTemplateSprite;

		private static Type _nullCardInfoType;

		private static bool _nullCardInfoResolved;

		private static readonly Dictionary<string, Sprite> FullSprites = new Dictionary<string, Sprite>();

		private static readonly Dictionary<string, Sprite> MiniSprites = new Dictionary<string, Sprite>();

		private static readonly Dictionary<string, GameObject> Templates = new Dictionary<string, GameObject>();

		private static string DllDir => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "";

		private static string ArtFolder
		{
			get
			{
				if (_artFolderResolved)
				{
					return _artFolder;
				}
				_artFolderResolved = true;
				string dllDir = DllDir;
				string text = Path.Combine(dllDir, "Art");
				if (DirHasPng(text))
				{
					_artFolder = text;
				}
				else if (DirHasPng(dllDir))
				{
					_artFolder = dllDir;
				}
				else
				{
					string text2 = Path.Combine(Directory.GetParent(dllDir)?.FullName ?? dllDir, "Art");
					_artFolder = (DirHasPng(text2) ? text2 : text);
				}
				if (!_folderLogged)
				{
					_folderLogged = true;
					Plugin.Instance?.Log("Card art folder: " + _artFolder);
				}
				return _artFolder;
			}
		}

		internal static GameObject Create(string artName)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			//IL_0087: 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_00a3: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(artName))
			{
				return null;
			}
			if (Templates.TryGetValue(artName, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Sprite fullSprite = GetFullSprite(artName);
			if ((Object)(object)fullSprite == (Object)null)
			{
				return null;
			}
			GameObject val = new GameObject("MM_CardArt_" + artName, new Type[1] { typeof(RectTransform) });
			Object.DontDestroyOnLoad((Object)(object)val);
			val.AddComponent<MmCardArtTag>().ArtName = artName;
			Image obj = val.AddComponent<Image>();
			obj.sprite = fullSprite;
			obj.preserveAspect = true;
			((Graphic)obj).raycastTarget = false;
			((Graphic)obj).color = Color.white;
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.pivot = new Vector2(0.5f, 0.5f);
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			component.anchoredPosition = Vector2.zero;
			((Transform)component).localScale = Vector3.one;
			((Transform)component).localRotation = Quaternion.identity;
			CardArtFx.AttachToTemplate(val, artName);
			Templates[artName] = val;
			return val;
		}

		internal static Sprite GetMiniSprite(string artName)
		{
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(artName))
			{
				return null;
			}
			if (MiniSprites.TryGetValue(artName, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			string text = ResolvePng(artName + "_mini.png") ?? ResolvePng(artName + ".png");
			if (text == null)
			{
				if (MissingMiniLogged.Add(artName))
				{
					Plugin.Instance?.LogWarn("No mini PNG for '" + artName + "' in " + ArtFolder + " or next to the DLL");
				}
				return null;
			}
			try
			{
				Texture2D val = LoadTexture(text);
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
				MiniSprites[artName] = val2;
				return val2;
			}
			catch
			{
				return null;
			}
		}

		internal static bool IsNullPlaceholder(CardInfo card)
		{
			if ((Object)(object)card == (Object)null)
			{
				return false;
			}
			Type type = NullCardInfoType();
			if (type != null && type.IsInstanceOfType(card))
			{
				return true;
			}
			if (GameObjectHasNullCardInfo(((Component)card).gameObject))
			{
				return true;
			}
			string text = (card.cardName ?? "").Trim();
			if (text.StartsWith("[]", StringComparison.Ordinal))
			{
				return true;
			}
			if (text.Equals("null", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (text.Equals("NullCard", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (text.Equals("Null Card", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			return false;
		}

		internal static bool GameObjectHasNullCardInfo(GameObject go)
		{
			if ((Object)(object)go == (Object)null)
			{
				return false;
			}
			Type type = NullCardInfoType();
			if (type == null)
			{
				return false;
			}
			return (Object)(object)go.GetComponent(type) != (Object)null;
		}

		private static Type NullCardInfoType()
		{
			if (_nullCardInfoResolved)
			{
				return _nullCardInfoType;
			}
			_nullCardInfoResolved = true;
			_nullCardInfoType = AccessTools.TypeByName("Nullmanager.NullCardInfo");
			return _nullCardInfoType;
		}

		internal static void TryAssignSprite(CardInfo info)
		{
			try
			{
				if ((Object)(object)info == (Object)null || IsNullPlaceholder(info))
				{
					return;
				}
				string text = ArtNameFor(info);
				if (string.IsNullOrEmpty(text))
				{
					return;
				}
				RegisterCard(info, text);
				Sprite miniSprite = GetMiniSprite(text);
				if (!((Object)(object)miniSprite == (Object)null))
				{
					Sprite sprite = info.sprite;
					if ((Object)(object)_vanillaTemplateSprite == (Object)null && (Object)(object)sprite != (Object)null && (Object)(object)sprite != (Object)(object)miniSprite)
					{
						_vanillaTemplateSprite = sprite;
					}
					info.sprite = miniSprite;
					CardBarMiniIcons.AttachFancyIcon(info);
					StampPickIcons(info, miniSprite, sprite);
				}
			}
			catch (Exception ex)
			{
				Plugin.Instance?.LogWarn("TryAssignSprite skipped: " + ex.Message);
			}
		}

		internal static void RegisterCard(CardInfo info, string artName)
		{
			if (!((Object)(object)info == (Object)null) && !string.IsNullOrEmpty(artName) && !IsNullPlaceholder(info))
			{
				if (!string.IsNullOrEmpty(info.cardName))
				{
					RegisteredCardNames.Add(info.cardName);
					CardNameToArt[info.cardName] = artName;
				}
				MmCardArtTag mmCardArtTag = ((Component)info).GetComponent<MmCardArtTag>();
				if ((Object)(object)mmCardArtTag == (Object)null)
				{
					mmCardArtTag = ((Component)info).gameObject.AddComponent<MmCardArtTag>();
				}
				if (string.IsNullOrEmpty(mmCardArtTag.ArtName))
				{
					mmCardArtTag.ArtName = artName;
				}
			}
		}

		internal static bool IsRegisteredCardName(string cardName)
		{
			if (!string.IsNullOrEmpty(cardName))
			{
				return CardNameToArt.ContainsKey(cardName);
			}
			return false;
		}

		internal static string ArtNameFor(CardInfo info)
		{
			if ((Object)(object)info == (Object)null || IsNullPlaceholder(info))
			{
				return null;
			}
			MmCardArtTag component = ((Component)info).GetComponent<MmCardArtTag>();
			if ((Object)(object)component != (Object)null && !string.IsNullOrEmpty(component.ArtName))
			{
				return component.ArtName;
			}
			if ((Object)(object)info.cardArt != (Object)null)
			{
				MmCardArtTag component2 = info.cardArt.GetComponent<MmCardArtTag>();
				if ((Object)(object)component2 != (Object)null && !string.IsNullOrEmpty(component2.ArtName))
				{
					return component2.ArtName;
				}
			}
			if ((Object)(object)info.sourceCard != (Object)null && (Object)(object)info.sourceCard != (Object)(object)info)
			{
				string text = ArtNameFor(info.sourceCard);
				if (!string.IsNullOrEmpty(text))
				{
					return text;
				}
			}
			return GuessArtName(info.cardName);
		}

		internal static string GuessArtName(string cardName)
		{
			if (string.IsNullOrEmpty(cardName))
			{
				return null;
			}
			if (cardName.Trim().StartsWith("[]", StringComparison.Ordinal))
			{
				return null;
			}
			if (CardNameToArt.TryGetValue(cardName, out var value))
			{
				return value;
			}
			EnsureArtIndex();
			string text = Compact(cardName);
			if (ArtNames.Contains(text))
			{
				return text;
			}
			if (text == "sandbagsimulator" && ArtNames.Contains("sandbag"))
			{
				return "sandbag";
			}
			return null;
		}

		internal static void BindLoadedCardInfos()
		{
			CardInfo[] array = Resources.FindObjectsOfTypeAll<CardInfo>();
			for (int i = 0; i < array.Length; i++)
			{
				TryAssignSprite(array[i]);
			}
		}

		private static void StampPickIcons(CardInfo info, Sprite mini, Sprite oldSprite)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)info == (Object)null || (Object)(object)mini == (Object)null)
			{
				return;
			}
			Image[] componentsInChildren = ((Component)info).GetComponentsInChildren<Image>(true);
			foreach (Image val in componentsInChildren)
			{
				if (IsStampableImage(val) && SpriteMatches(val.sprite, mini, oldSprite))
				{
					ApplyMini(val, mini);
				}
			}
			SpriteRenderer[] componentsInChildren2 = ((Component)info).GetComponentsInChildren<SpriteRenderer>(true);
			foreach (SpriteRenderer val2 in componentsInChildren2)
			{
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)((Component)val2).GetComponent<MmCardArtTag>() != (Object)null) && SpriteMatches(val2.sprite, mini, oldSprite))
				{
					val2.sprite = mini;
					val2.color = MmArtColorLock.ArtColor;
					if ((Object)(object)((Component)val2).GetComponent<MmArtColorLock>() == (Object)null)
					{
						((Component)val2).gameObject.AddComponent<MmArtColorLock>();
					}
				}
			}
			StampCornerCluster(info, mini);
		}

		private static void StampCornerCluster(CardInfo info, Sprite mini)
		{
			//IL_0091: 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_00a6: 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)
			Transform val = null;
			Transform[] componentsInChildren = ((Component)info).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren)
			{
				if ((Object)(object)val2 != (Object)null && ((Object)val2).name == "EdgePart (2)")
				{
					val = val2;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Image val3 = null;
			Image[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Image>(true);
			foreach (Image val4 in componentsInChildren2)
			{
				if (!IsStampableImage(val4) || ((Object)((Component)val4).transform).name.StartsWith("EdgePart", StringComparison.Ordinal))
				{
					continue;
				}
				RectTransform rectTransform = ((Graphic)val4).rectTransform;
				Rect rect = rectTransform.rect;
				float num = Mathf.Abs(((Rect)(ref rect)).width);
				rect = rectTransform.rect;
				float num2 = Mathf.Abs(((Rect)(ref rect)).height);
				if (!(num > 140f) && !(num2 > 140f) && (!(num < 8f) || !(num2 < 8f)))
				{
					if ((Object)(object)val3 == (Object)null)
					{
						val3 = val4;
						ApplyMini(val4, mini);
					}
					else if (SpriteMatches(val4.sprite, mini, _vanillaTemplateSprite) || (Object)(object)val4.sprite == (Object)(object)val3.sprite)
					{
						((Behaviour)val4).enabled = false;
					}
				}
			}
		}

		private static bool IsStampableImage(Image img)
		{
			if ((Object)(object)img == (Object)null)
			{
				return false;
			}
			if ((Object)(object)((Component)img).GetComponent<MmCardArtTag>() != (Object)null)
			{
				return false;
			}
			if ((Object)(object)((Component)img).GetComponent<MmMovingCardBackground>() != (Object)null)
			{
				return false;
			}
			string name = ((Object)((Component)img).gameObject).name;
			if (name.StartsWith("MM_", StringComparison.Ordinal))
			{
				return false;
			}
			if (name == "ModNameText")
			{
				return false;
			}
			return true;
		}

		private static bool SpriteMatches(Sprite current, Sprite mini, Sprite oldSprite)
		{
			if ((Object)(object)current == (Object)null)
			{
				return false;
			}
			if ((Object)(object)current == (Object)(object)mini)
			{
				return true;
			}
			if ((Object)(object)oldSprite != (Object)null && (Object)(object)current == (Object)(object)oldSprite)
			{
				return true;
			}
			if ((Object)(object)_vanillaTemplateSprite != (Object)null)
			{
				return (Object)(object)current == (Object)(object)_vanillaTemplateSprite;
			}
			return false;
		}

		private static void ApplyMini(Image img, Sprite mini)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			img.sprite = mini;
			img.overrideSprite = mini;
			img.preserveAspect = true;
			((Graphic)img).color = MmArtColorLock.ArtColor;
			((Behaviour)img).enabled = true;
			if ((Object)(object)((Component)img).GetComponent<MmArtColorLock>() == (Object)null)
			{
				((Component)img).gameObject.AddComponent<MmArtColorLock>();
			}
		}

		private static Sprite GetFullSprite(string artName)
		{
			//IL_005f: 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)
			if (FullSprites.TryGetValue(artName, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			string text = ResolvePng(artName + ".png");
			if (text == null)
			{
				return null;
			}
			try
			{
				Texture2D val = LoadTexture(text);
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
				FullSprites[artName] = val2;
				return val2;
			}
			catch
			{
				return null;
			}
		}

		private static string ResolvePng(string fileName)
		{
			string text = Path.Combine(ArtFolder, fileName);
			if (File.Exists(text))
			{
				return text;
			}
			string dllDir = DllDir;
			string text2 = Path.Combine(dllDir, fileName);
			if (File.Exists(text2))
			{
				return text2;
			}
			string text3 = Path.Combine(dllDir, "Art", fileName);
			if (File.Exists(text3))
			{
				return text3;
			}
			return null;
		}

		private static bool DirHasPng(string dir)
		{
			try
			{
				return Directory.Exists(dir) && Directory.GetFiles(dir, "*.png").Length != 0;
			}
			catch
			{
				return false;
			}
		}

		private static void EnsureArtIndex()
		{
			if (_artIndexBuilt)
			{
				return;
			}
			_artIndexBuilt = true;
			try
			{
				IndexDir(ArtFolder);
				IndexDir(DllDir);
				IndexDir(Path.Combine(DllDir, "Art"));
			}
			catch
			{
			}
		}

		private static void IndexDir(string dir)
		{
			if (string.IsNullOrEmpty(dir) || !Directory.Exists(dir))
			{
				return;
			}
			string[] files = Directory.GetFiles(dir, "*.png");
			for (int i = 0; i < files.Length; i++)
			{
				string text = Path.GetFileNameWithoutExtension(files[i]);
				if (!string.IsNullOrEmpty(text))
				{
					if (text.EndsWith("_mini", StringComparison.OrdinalIgnoreCase))
					{
						text = text.Substring(0, text.Length - 5);
					}
					ArtNames.Add(text);
				}
			}
		}

		private static string Compact(string s)
		{
			StringBuilder stringBuilder = new StringBuilder(s.Length);
			foreach (char c in s)
			{
				if (char.IsLetterOrDigit(c))
				{
					stringBuilder.Append(char.ToLowerInvariant(c));
				}
			}
			return stringBuilder.ToString();
		}

		private static Texture2D LoadTexture(string path)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			byte[] array = File.ReadAllBytes(path);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, array))
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			((Texture)val).filterMode = (FilterMode)1;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			Object.DontDestroyOnLoad((Object)(object)val);
			return val;
		}
	}
	internal enum MmCardArtMotion
	{
		None,
		SubtleShake,
		EnergeticShake,
		Jitter
	}
	internal sealed class MmCardArtFxTag : MonoBehaviour
	{
		public MmCardArtMotion Motion;

		public bool MovingBackground;

		public float GlowScale;
	}
	internal sealed class MmArtColorLock : MonoBehaviour
	{
		internal static readonly Color ArtColor = new Color(0.82f, 0.82f, 0.82f, 1f);

		private Image _image;

		private SpriteRenderer _sr;

		private void Awake()
		{
			_image = ((Component)this).GetComponent<Image>();
			_sr = ((Component)this).GetComponent<SpriteRenderer>();
		}

		private void LateUpdate()
		{
			//IL_0014: 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)
			if ((Object)(object)_image != (Object)null)
			{
				((Graphic)_image).color = ArtColor;
			}
			if ((Object)(object)_sr != (Object)null)
			{
				_sr.color = ArtColor;
			}
		}
	}
	internal sealed class MmMovingCardBackground : CardAnimation
	{
		private const int BlobCount = 5;

		private Image[] _blobs;

		private Vector2[] _seeds;

		private Color _tint = new Color(1f, 0.55f, 0.15f, 0.05f);

		private bool _built;

		internal void SetTint(Color themeColor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			_tint = themeColor;
			_tint.a = 0.05f;
			if (_blobs == null)
			{
				return;
			}
			Image[] blobs = _blobs;
			foreach (Image val in blobs)
			{
				if ((Object)(object)val != (Object)null)
				{
					((Graphic)val).color = _tint;
				}
			}
		}

		private void OnEnable()
		{
			EnsureBuilt();
			SetBlobsVisible(on: true);
		}

		private void OnDisable()
		{
			SetBlobsVisible(on: false);
		}

		private void Update()
		{
			//IL_003a: 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_0047: 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_0075: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			if (!_built || _blobs == null)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			for (int i = 0; i < _blobs.Length; i++)
			{
				Image val = _blobs[i];
				if (!((Object)(object)val == (Object)null))
				{
					Vector2 val2 = _seeds[i];
					RectTransform rectTransform = ((Graphic)val).rectTransform;
					float num = Mathf.Sin((unscaledTime + val2.x) * (0.35f + val2.y * 0.4f)) * 28f;
					float num2 = Mathf.Cos((unscaledTime * 0.7f + val2.y) * (0.4f + val2.x * 0.35f)) * 22f;
					rectTransform.anchoredPosition = new Vector2(num, num2);
					float num3 = 0.85f + 0.15f * Mathf.Sin(unscaledTime * (1.1f + val2.x) + val2.y);
					((Transform)rectTransform).localScale = Vector3.one * (0.7f + val2.x * 0.5f) * num3;
					Color tint = _tint;
					tint.a = _tint.a * (0.65f + 0.35f * num3);
					((Graphic)val).color = tint;
				}
			}
		}

		private void EnsureBuilt()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00a0: 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_00ca: 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_00fb: 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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			if (!_built)
			{
				_built = true;
				_blobs = (Image[])(object)new Image[5];
				_seeds = (Vector2[])(object)new Vector2[5];
				for (int i = 0; i < 5; i++)
				{
					GameObject val = new GameObject("MM_BgBlob_" + i, new Type[3]
					{
						typeof(RectTransform),
						typeof(CanvasRenderer),
						typeof(Image)
					});
					val.transform.SetParent(((Component)this).transform, false);
					val.transform.SetAsFirstSibling();
					RectTransform component = val.GetComponent<RectTransform>();
					component.anchorMin = new Vector2(0.5f, 0.5f);
					component.anchorMax = new Vector2(0.5f, 0.5f);
					component.pivot = new Vector2(0.5f, 0.5f);
					component.sizeDelta = new Vector2(220f + (float)i * 40f, 180f + (float)i * 30f);
					component.anchoredPosition = Vector2.zero;
					Image component2 = val.GetComponent<Image>();
					component2.sprite = SoftBlobSprite.Instance;
					component2.type = (Type)0;
					component2.preserveAspect = true;
					((Graphic)component2).raycastTarget = false;
					((Graphic)component2).color = _tint;
					_blobs[i] = component2;
					_seeds[i] = new Vector2(0.15f + (float)i * 0.17f, 0.4f + (float)(i % 3) * 0.2f);
				}
			}
		}

		private void SetBlobsVisible(bool on)
		{
			if (_blobs == null)
			{
				return;
			}
			Image[] blobs = _blobs;
			foreach (Image val in blobs)
			{
				if ((Object)(object)val != (Object)null)
				{
					((Behaviour)val).enabled = on;
				}
			}
		}
	}
	internal static class SoftBlobSprite
	{
		private static Sprite _sprite;

		internal static Sprite Instance
		{
			get
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Expected O, but got Unknown
				//IL_00d0: 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_0083: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_sprite != (Object)null)
				{
					return _sprite;
				}
				Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
				float num = 31.5f;
				for (int i = 0; i < 64; i++)
				{
					for (int j = 0; j < 64; j++)
					{
						float num2 = ((float)j - num) / num;
						float num3 = ((float)i - num) / num;
						float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3);
						float num5 = Mathf.Clamp01(1f - num4);
						num5 = num5 * num5 * (3f - 2f * num5);
						val.SetPixel(j, i, new Color(1f, 1f, 1f, num5));
					}
				}
				val.Apply(false, true);
				((Texture)val).filterMode = (FilterMode)1;
				((Texture)val).wrapMode = (TextureWrapMode)1;
				Object.DontDestroyOnLoad((Object)(object)val);
				_sprite = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f);
				Object.DontDestroyOnLoad((Object)(object)_sprite);
				return _sprite;
			}
		}
	}
	internal static class CardArtFx
	{
		private struct FxSpec
		{
			internal MmCardArtMotion Motion;

			internal bool MovingBg;

			internal float Glow;

			internal FxSpec(MmCardArtMotion motion, bool movingBg, float glow)
			{
				Motion = motion;
				MovingBg = movingBg;
				Glow = glow;
			}
		}

		private static readonly Dictionary<string, FxSpec> Specs = new Dictionary<string, FxSpec>
		{
			["dynamite"] = new FxSpec(MmCardArtMotion.EnergeticShake, movingBg: false, 0f),
			["yeetcannon"] = new FxSpec(MmCardArtMotion.EnergeticShake, movingBg: false, 0f),
			["kickback"] = new FxSpec(MmCardArtMotion.EnergeticShake, movingBg: false, 0f),
			["tasertasertaser"] = new FxSpec(MmCardArtMotion.Jitter, movingBg: false, 0f),
			["fumble"] = new FxSpec(MmCardArtMotion.Jitter, movingBg: false, 0f),
			["bozoshoes"] = new FxSpec(MmCardArtMotion.SubtleShake, movingBg: false, 0f),
			["shove"] = new FxSpec(MmCardArtMotion.SubtleShake, movingBg: false, 0f),
			["thief"] = new FxSpec(MmCardArtMotion.SubtleShake, movingBg: false, 0f),
			["confetti"] = new FxSpec(MmCardArtMotion.SubtleShake, movingBg: false, 0f),
			["returntosender"] = new FxSpec(MmCardArtMotion.None, movingBg: false, 0f),
			["silveregg"] = new FxSpec(MmCardArtMotion.None, movingBg: false, 0f),
			["nestegg"] = new FxSpec(MmCardArtMotion.None, movingBg: false, 0f)
		};

		private const float DefaultGlow = 0f;

		internal static void AttachToTemplate(GameObject root, string artName)
		{
			if (!((Object)(object)root == (Object)null) && !string.IsNullOrEmpty(artName))
			{
				FxSpec fxSpec = Resolve(artName);
				MmCardArtFxTag mmCardArtFxTag = root.GetComponent<MmCardArtFxTag>() ?? root.AddComponent<MmCardArtFxTag>();
				mmCardArtFxTag.Motion = fxSpec.Motion;
				mmCardArtFxTag.MovingBackground = fxSpec.MovingBg;
				mmCardArtFxTag.GlowScale = fxSpec.Glow;
				if ((Object)(object)root.GetComponent<MmArtColorLock>() == (Object)null)
				{
					root.AddComponent<MmArtColorLock>();
				}
				if (!Specs.ContainsKey(artName))
				{
					mmCardArtFxTag.GlowScale = 0f;
				}
				ApplyMotion(root, fxSpec.Motion);
				if (fxSpec.MovingBg)
				{
					((Behaviour)(root.GetComponent<MmMovingCardBackground>() ?? root.AddComponent<MmMovingCardBackground>())).enabled = false;
				}
			}
		}

		internal static float GlowScaleFor(MmCardArtFxTag fx)
		{
			if (Plugin.Configs == null || Plugin.Configs.SoftenCardGlow.Value)
			{
				return 0f;
			}
			if (!((Object)(object)fx != (Object)null))
			{
				return 0f;
			}
			return Mathf.Clamp(fx.GlowScale, 0f, 0.28f);
		}

		private static FxSpec Resolve(string artName)
		{
			if (Specs.TryGetValue(artName, out var value))
			{
				return value;
			}
			return new FxSpec(MmCardArtMotion.None, movingBg: false, 0f);
		}

		private static void ApplyMotion(GameObject root, MmCardArtMotion motion)
		{
			PositionNoise component = root.GetComponent<PositionNoise>();
			if (motion == MmCardArtMotion.None)
			{
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				return;
			}
			PositionNoise val = component ?? root.AddComponent<PositionNoise>();
			((Behaviour)val).enabled = false;
			switch (motion)
			{
			case MmCardArtMotion.SubtleShake:
				val.amount = 4.5f;
				val.speed = 1.1f;
				break;
			case MmCardArtMotion.EnergeticShake:
				val.amount = 9f;
				val.speed = 2.2f;
				break;
			case MmCardArtMotion.Jitter:
				val.amount = 7f;
				val.speed = 4.5f;
				break;
			}
		}
	}
	internal static class CardBarMiniIcons
	{
		private const string ChildName = "MM_MiniIcon";

		private static readonly Dictionary<string, GameObject> FancyPrefabs = new Dictionary<string, GameObject>();

		private static GameObject _fancyHolder;

		private static Type _fancyIconType;

		private static bool _fancyResolved;

		private static readonly FieldInfo CardField = AccessTools.Field(typeof(CardBarButton), "card");

		internal static bool IsMmCard(CardInfo card)
		{
			if ((Object)(object)card == (Object)null || CardArtFactory.IsNullPlaceholder(card))
			{
				return false;
			}
			return !string.IsNullOrEmpty(CardArtFactory.ArtNameFor(card));
		}

		internal static void RestampAll()
		{
			CardBar[] array = Object.FindObjectsOfType<CardBar>();
			for (int i = 0; i < array.Length; i++)
			{
				ApplyAllMmOnBar(array[i]);
			}
		}

		internal static void ApplyToLatestButton(CardBar bar)
		{
			ApplyAllMmOnBar(bar);
		}

		internal static void ApplyAllMmOnBar(CardBar bar)
		{
			if ((Object)(object)bar == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)bar).transform;
			for (int i = 0; i < transform.childCount; i++)
			{
				GameObject gameObject = ((Component)transform.GetChild(i)).gameObject;
				CardBarButton component = gameObject.GetComponent<CardBarButton>();
				if (!((Object)(object)component == (Object)null))
				{
					object? obj = CardField?.GetValue(component);
					CardInfo card = (CardInfo)((obj is CardInfo) ? obj : null);
					Apply(gameObject, card);
				}
			}
		}

		internal static void Apply(GameObject button, CardInfo card)
		{
			if ((Object)(object)button == (Object)null || (Object)(object)card == (Object)null)
			{
				return;
			}
			if (CardArtFactory.IsNullPlaceholder(card) || CardArtFactory.GameObjectHasNullCardInfo(button))
			{
				ClearMmStamp(button);
			}
			else
			{
				if (!IsMmCard(card))
				{
					return;
				}
				CardArtFactory.TryAssignSprite(card);
				AttachFancyIcon(card);
				Sprite val = SpriteFor(card);
				if (!((Object)(object)val == (Object)null))
				{
					TMP_Text[] componentsInChildren = button.GetComponentsInChildren<TMP_Text>(true);
					foreach (TMP_Text obj in componentsInChildren)
					{
						((Behaviour)obj).enabled = false;
						obj.text = "";
					}
					StripFancyOverlays(button);
					StripGlow(button);
					EnsureCleanOverlay(button, val);
					card.sprite = val;
				}
			}
		}

		internal static Sprite SpriteFor(CardInfo card)
		{
			if ((Object)(object)card == (Object)null)
			{
				return null;
			}
			string text = CardArtFactory.ArtNameFor(card);
			if (!string.IsNullOrEmpty(text))
			{
				Sprite miniSprite = CardArtFactory.GetMiniSprite(text);
				if ((Object)(object)miniSprite != (Object)null)
				{
					return miniSprite;
				}
			}
			if (!IsMmCard(card))
			{
				return null;
			}
			return card.sprite;
		}

		internal static void AttachFancyIcon(CardInfo info)
		{
			try
			{
				if ((Object)(object)info == (Object)null || !IsMmCard(info) || CardArtFactory.IsNullPlaceholder(info))
				{
					return;
				}
				Type type = FancyIconType();
				if (type == null)
				{
					return;
				}
				string text = CardArtFactory.ArtNameFor(info);
				if (string.IsNullOrEmpty(text))
				{
					return;
				}
				GameObject orCreateFancyPrefab = GetOrCreateFancyPrefab(text);
				if (!((Object)(object)orCreateFancyPrefab == (Object)null))
				{
					Component val = ((Component)info).gameObject.GetComponent(type);
					if ((Object)(object)val == (Object)null)
					{
						val = ((Component)info).gameObject.AddComponent(type);
					}
					AccessTools.Field(type, "fancyIcon")?.SetValue(val, orCreateFancyPrefab);
				}
			}
			catch (Exception ex)
			{
				Plugin.Instance?.LogWarn("AttachFancyIcon skipped: " + ex.Message);
			}
		}

		private static Type FancyIconType()
		{
			if (_fancyResolved)
			{
				return _fancyIconType;
			}
			_fancyResolved = true;
			_fancyIconType = AccessTools.TypeByName("FancyCardBar.FancyIcon");
			return _fancyIconType;
		}

		private static GameObject GetOrCreateFancyPrefab(string artName)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected O, but got Unknown
			//IL_00c8: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_0047: Expected O, but got Unknown
			if (FancyPrefabs.TryGetValue(artName, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			Sprite miniSprite = CardArtFactory.GetMiniSprite(artName);
			if ((Object)(object)miniSprite == (Object)null)
			{
				return null;
			}
			if (!Object.op_Implicit((Object)(object)_fancyHolder))
			{
				_fancyHolder = new GameObject("MM_FancyBarIconHolder");
				Object.DontDestroyOnLoad((Object)(object)_fancyHolder);
				_fancyHolder.SetActive(false);
			}
			GameObject val = new GameObject("MM_FancyBarIcon_" + artName, new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			val.transform.SetParent(_fancyHolder.transform, false);
			val.SetActive(true);
			RectTransform component = val.GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(128f, 128f);
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.anchoredPosition = Vector2.zero;
			Image component2 = val.GetComponent<Image>();
			component2.sprite = miniSprite;
			component2.overrideSprite = miniSprite;
			component2.preserveAspect = true;
			((Graphic)component2).raycastTarget = false;
			((Graphic)component2).color = Color.white;
			((Graphic)component2).material = null;
			FancyPrefabs[artName] = val;
			return val;
		}

		private static void StripFancyOverlays(GameObject button)
		{
			if ((Object)(object)button == (Object)null)
			{
				return;
			}
			MonoBehaviour[] componentsInChildren = button.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !(((object)val).GetType().Name != "RGBColorShift"))
				{
					((Behaviour)val).enabled = false;
					if ((Object)(object)((Component)val).gameObject != (Object)(object)button)
					{
						((Component)val).gameObject.SetActive(false);
					}
				}
			}
			for (int num = button.transform.childCount - 1; num >= 0; num--)
			{
				Transform child = button.transform.GetChild(num);
				if (!((Object)(object)child == (Object)null) && !(((Object)child).name == "MM_MiniIcon") && !((Object)child).name.StartsWith("MM_FancyBarIcon_", StringComparison.Ordinal) && (Object)(object)((Component)child).GetComponentInChildren<MmCardArtTag>(true) != (Object)null)
				{
					((Component)child).gameObject.SetActive(false);
				}
			}
		}

		private static void EnsureCleanOverlay(GameObject button, Sprite sprite)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_0078: 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_00a2: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			Transform val = button.transform.Find("MM_MiniIcon");
			Image component2;
			if ((Object)(object)val == (Object)null)
			{
				GameObject val2 = new GameObject("MM_MiniIcon", new Type[3]
				{
					typeof(RectTransform),
					typeof(CanvasRenderer),
					typeof(Image)
				});
				val2.transform.SetParent(button.transform, false);
				RectTransform component = val2.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.pivot = new Vector2(0.5f, 0.5f);
				component.offsetMin = new Vector2(3f, 3f);
				component.offsetMax = new Vector2(-3f, -3f);
				component2 = val2.GetComponent<Image>();
				((Graphic)component2).raycastTarget = false;
				component2.preserveAspect = true;
			}
			else
			{
				component2 = ((Component)val).GetComponent<Image>();
				val.SetAsLastSibling();
			}
			if (!((Object)(object)component2 == (Object)null))
			{
				component2.sprite = sprite;
				component2.overrideSprite = sprite;
				((Graphic)component2).color = Color.white;
				((Graphic)component2).material = null;
				((Behaviour)component2).enabled = true;
				((Component)component2).gameObject.SetActive(true);
			}
		}

		private static void ClearMmStamp(GameObject button)
		{
			if ((Object)(object)button == (Object)null)
			{
				return;
			}
			Transform val = button.transform.Find("MM_MiniIcon");
			if ((Object)(object)val != (Object)null)
			{
				((Component)val).gameObject.SetActive(false);
			}
			for (int i = 0; i < button.transform.childCount; i++)
			{
				Transform child = button.transform.GetChild(i);
				if (!((Object)(object)child == (Object)null) && (((Object)child).name.StartsWith("MM_FancyBarIcon_", StringComparison.Ordinal) || (Object)(object)((Component)child).GetComponentInChildren<MmCardArtTag>(true) != (Object)null))
				{
					((Component)child).gameObject.SetActive(false);
				}
			}
			TMP_Text[] componentsInChildren = button.GetComponentsInChildren<TMP_Text>(true);
			foreach (TMP_Text val2 in componentsInChildren)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					((Behaviour)val2).enabled = true;
				}
			}
		}

		private static void StripGlow(GameObject button)
		{
			if ((Object)(object)button == (Object)null)
			{
				return;
			}
			CardVisualsFxPatch.KillAllParticles(button.transform);
			for (int i = 0; i < button.transform.childCount; i++)
			{
				Transform child = button.transform.GetChild(i);
				if (!((Object)(object)child == (Object)null) && !(((Object)child).name == "MM_MiniIcon"))
				{
					string name = ((Object)child).name;
					if (name.IndexOf("glow", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("shine", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("bloom", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("particle", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						((Component)child).gameObject.SetActive(false);
					}
				}
			}
		}
	}
	internal static class CardEncoding
	{
		internal static string Encode(CardInfo card)
		{
			if ((Object)(object)card == (Object)null)
			{
				return "";
			}
			string obj = (((Object)(object)((Component)card).gameObject != (Object)null) ? StripClone(((Object)((Component)card).gameObject).name) : "");
			string text = card.cardName ?? "";
			return obj + "\n" + text;
		}

		internal static void Decode(string payload, out string objectName, out string cardName)
		{
			objectName = payload ?? "";
			cardName = "";
			if (!string.IsNullOrEmpty(payload))
			{
				int num = payload.IndexOf('\n');
				if (num >= 0)
				{
					objectName = payload.Substring(0, num);
					cardName = payload.Substring(num + 1);
				}
			}
		}

		internal static CardInfo Resolve(string payload)
		{
			Decode(payload, out var objectName, out var cardName);
			objectName = StripClone(objectName);
			CardInfo val = null;
			if (!string.IsNullOrEmpty(objectName))
			{
				try
				{
					val = Cards.instance.GetCardWithObjectName(objectName);
				}
				catch
				{
				}
			}
			if ((Object)(object)val == (Object)null && !string.IsNullOrEmpty(cardName))
			{
				try
				{
					val = Cards.instance.GetCardWithName(cardName);
				}
				catch
				{
				}
				if (val == null)
				{
					val = Cards.all?.FirstOrDefault((Func<CardInfo, bool>)((CardInfo c) => (Object)(object)c != (Object)null && !string.IsNullOrEmpty(c.cardName) && string.Equals(c.cardName, cardName, StringComparison.OrdinalIgnoreCase)));
				}
			}
			return val;
		}

		internal static string StripClone(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return name;
			}
			while (name.EndsWith("(Clone)", StringComparison.Ordinal))
			{
				name = name.Substring(0, name.Length - "(Clone)".Length).Trim();
			}
			return name.Trim();
		}

		internal static bool Matches(CardInfo card, string payload)
		{
			if ((Object)(object)card == (Object)null || string.IsNullOrEmpty(payload))
			{
				return false;
			}
			Decode(payload, out var objectName, out var cardName);
			objectName = StripClone(objectName);
			if (!string.IsNullOrEmpty(objectName) && (Object)(object)((Component)card).gameObject != (Object)null && string.Equals(StripClone(((Object)((Component)card).gameObject).name), objectName, StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			if (!string.IsNullOrEmpty(cardName))
			{
				return string.Equals(card.cardName, cardName, StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}

		internal static int FindCardIndex(Player player, string payload)
		{
			List<CardInfo> list = player?.data?.currentCards;
			if (list == null)
			{
				return -1;
			}
			for (int i = 0; i < list.Count; i++)
			{
				if (Matches(list[i], payload))
				{
					return i;
				}
			}
			return -1;
		}

		internal static Player FindHolder(string payload)
		{
			if (PlayerManager.instance?.players == null)
			{
				return null;
			}
			foreach (Player player in PlayerManager.instance.players)
			{
				if (!((Object)(object)player == (Object)null) && FindCardIndex(player, payload) >= 0)
				{
					return player;
				}
			}
			return null;
		}
	}
	internal static class CardOwnership
	{
		internal const float KickbackForce = 1700f;

		internal static bool Has(Player player, CardInfo card)
		{
			if (player?.data?.currentCards == null || (Object)(object)card == (Object)null)
			{
				return false;
			}
			foreach (CardInfo currentCard in player.data.currentCards)
			{
				if (!((Object)(object)currentCard == (Object)null))
				{
					if ((Object)(object)currentCard == (Object)(object)card)
					{
						return true;
					}
					if (!string.IsNullOrEmpty(card.cardName) && string.Equals(currentCard.cardName, card.cardName, StringComparison.OrdinalIgnoreCase))
					{
						return true;
					}
				}
			}
			return false;
		}

		internal static int CountOf(Player player, CardInfo card)
		{
			if (player?.data?.currentCards == null || (Object)(object)card == (Object)null)
			{
				return 0;
			}
			int num = 0;
			foreach (CardInfo currentCard in player.data.currentCards)
			{
				if (!((Object)(object)currentCard == (Object)null) && ((Object)(object)currentCard == (Object)(object)card || (!string.IsNullOrEmpty(card.cardName) && string.Equals(currentCard.cardName, card.cardName, StringComparison.OrdinalIgnoreCase))))
				{
					num++;
				}
			}
			return num;
		}
	}
	internal static class CardPool
	{
		private static MethodInfo _isCardActive;

		internal static bool IsActive(CardInfo card)
		{
			if ((Object)(object)card == (Object)null)
			{
				return false;
			}
			try
			{
				if ((object)_isCardActive == null)
				{
					_isCardActive = AccessTools.Method(AccessTools.TypeByName("UnboundLib.Utils.CardManager"), "IsCardActive", (Type[])null, (Type[])null);
				}
				if (_isCardActive == null)
				{
					return true;
				}
				object obj = card;
				ParameterInfo[] parameters = _isCardActive.GetParameters();
				if (parameters.Length == 1 && parameters[0].ParameterType == typeof(string))
				{
					obj = (((Object)(object)((Component)card).gameObject != (Object)null) ? CardEncoding.StripClone(((Object)((Component)card).gameObject).name) : card.cardName);
				}
				if (_isCardActive.Invoke(null, new object[1] { obj }) is bool result)
				{
					return result;
				}
			}
			catch
			{
			}
			return true;
		}
	}
	internal static class CardStatApply
	{
		internal static CardInfoStat Stat(bool positive, string stat, string amount)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0022: Expected O, but got Unknown
			return new CardInfoStat
			{
				positive = positive,
				stat = stat,
				amount = amount,
				simepleAmount = (SimpleAmount)0
			};
		}

		internal static void AddAmmo(Gun gun, int amount)
		{
			if (!((Object)(object)gun == (Object)null))
			{
				gun.ammo = amount;
				GunAmmo val = ((Component)gun).GetComponent<GunAmmo>() ?? ((Component)gun).GetComponentInChildren<GunAmmo>(true);
				if ((Object)(object)val != (Object)null)
				{
					val.maxAmmo = amount;
				}
			}
		}
	}
	internal static class CardStatus
	{
		private const string CategoryName = "Lean and Mean";

		private const int CategoryPriority = 45;

		private static MethodInfo _registerStat;

		private static object _category;

		internal static void Register()
		{
			if (!Bind())
			{
				return;
			}
			try
			{
				Stat("Bozo Shoes", (Player player) => BozoShoesRuntime.IsMarked(player), (Player _) => "Clown shoes, +50% knockback");
				Stat("Safety Net", (Player player) => CardOwnership.Has(player, SafetyNet.Card), (Player _) => "No edge damage, OOB escape kill");
				Stat("TASER TASER TASER", (Player player) => CardOwnership.Has(player, TaserTaserTaser.Card), (Player _) => "+0.5s stun on hit");
				Stat("Yeet Cannon", (Player player) => CardOwnership.Has(player, YeetCannon.Card), (Player _) => "Strong kick away from gun");
				Stat("Dynamite", (Player player) => CardOwnership.Has(player, Dynamite.Card), (Player _) => "Delayed blast, huge knockback");
				Stat("Draft Sniper", (Player player) => DraftSniperManager.Remaining(player) > 0, (Player player) => (DraftSniperManager.Remaining(player) != 1) ? (DraftSniperManager.Remaining(player) + " locks") : "Click to lock");
				Stat("Silver Egg", SilverEggManager.ShowStat, SilverEggManager.StatusText);
				Plugin.Instance?.Log("Registered card statuses with TabInfo.");
			}
			catch (Exception ex)
			{
				Plugin.Instance?.LogWarn("TabInfo stat registration skipped: " + ex.Message);
			}
		}

		private static bool Bind()
		{
			Type type = AccessTools.TypeByName("TabInfo.Utils.TabInfoManager");
			if (type == null)
			{
				return false;
			}
			try
			{
				MethodInfo methodInfo = AccessTools.Method(type, "RegisterCategory", (Type[])null, (Type[])null);
				_registerStat = AccessTools.Method(type, "RegisterStat", (Type[])null, (Type[])null);
				if (methodInfo == null || _registerStat == null)
				{
					return false;
				}
				_category = methodInfo.Invoke(null, new object[2] { "Lean and Mean", 45 });
				return _category != null;
			}
			catch (Exception ex)
			{
				Plugin.Instance?.LogWarn("TabInfo bind failed: " + ex.Message);
				return false;
			}
		}

		private static void Stat(string name, Func<Player, bool> visible, Func<Player, string> value)
		{
			ParameterInfo[] parameters = _registerStat.GetParameters();
			if (parameters.Length == 4)
			{
				Delegate obj = Delegate.CreateDelegate(parameters[2].ParameterType, visible.Target, visible.Method);
				Delegate obj2 = Delegate.CreateDelegate(parameters[3].ParameterType, value.Target, value.Method);
				_registerStat.Invoke(null, new object[4] { _category, name, obj, obj2 });
			}
		}
	}
	internal static class CardTargetUi
	{
		private sealed class ToastHost : MonoBehaviour
		{
			private TextMeshProUGUI _label;

			private CanvasGroup _group;

			internal void Build()
			{
				//IL_0016: 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_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: 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_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Expected O, but got Unknown
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: 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_014f: Unknown result type (might be due to invalid IL or missing references)
				RectTransform component = ((Component)this).gameObject.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(0.5f, 1f);
				component.anchorMax = new Vector2(0.5f, 1f);
				component.pivot = new Vector2(0.5f, 1f);
				component.anchoredPosition = new Vector2(0f, -28f);
				component.sizeDelta = new Vector2(720f, 56f);
				_group = ((Component)this).gameObject.AddComponent<CanvasGroup>();
				_group.blocksRaycasts = false;
				_group.interactable = false;
				_group.alpha = 0f;
				UiGfx.Round(((Component)this).gameObject.AddComponent<Image>(), UiGfx.Panel);
				GameObject val = new GameObject("Label", new Type[1] { typeof(RectTransform) });
				val.transform.SetParent(((Component)this).transform, false);
				RectTransform component2 = val.GetComponent<RectTransform>();
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				component2.offsetMin = new Vector2(16f, 8f);
				component2.offsetMax = new Vector2(-16f, -8f);
				_label = val.AddComponent<TextMeshProUGUI>();
				UiGfx.StyleTmp(_label, 18f, UiGfx.Title, (TextAlignmentOptions)514);
			}

			internal void Show(string message)
			{
				if (!((Object)(object)_label == (Object)null) && !string.IsNullOrWhiteSpace(message))
				{
					((Component)this).gameObject.SetActive(true);
					((TMP_Text)_label).text = message;
					_group.alpha = 1f;
					((MonoBehaviour)this).CancelInvoke("Hide");
					((MonoBehaviour)this).Invoke("Hide", 3f);
				}
			}

			private void Hide()
			{
				if ((Object)(object)_group != (Object)null)
				{
					_group.alpha = 0f;
				}
			}
		}

		private class Overlay : MonoBehaviour
		{
			private RectTransform _panel;

			private TextMeshProUGUI _title;

			private TextMeshProUGUI _subtitle;

			private Transform _playerGrid;

			private Button _confirmButton;

			private Button _cancelButton;

			private Player _actor;

			private Player _selected;

			private Action<Player> _onConfirm;

			private Action _onCancel;

			private string _confirmLabel;

			internal void Build()
			{
				//IL_000c: 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_0022: 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_0041: 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_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Expected O, but got Unknown
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0150: 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)
				//IL_0178: Expected O, but got Unknown
				//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: 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)
				//IL_021e: Expected O, but got Unknown
				//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d9: Expected O, but got Unknown
				RectTransform component = ((Component)this).gameObject.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
				UiGfx.Solid(CreateImage("Dim", ((Component)this).transform, Vector2.zero, Vector2.one), UiGfx.Dim, raycast: true);
				_panel = CreatePanel("Panel", ((Component)this).transform, new Vector2(560f, 440f));
				UiGfx.Round(((Component)_panel).gameObject.AddComponent<Image>(), UiGfx.Panel);
				UiGfx.AddAccentBar((Transform)(object)_panel);
				VerticalLayoutGroup obj = ((Component)_panel).gameObject.AddComponent<VerticalLayoutGroup>();
				((LayoutGroup)obj).padding = new RectOffset(20, 20, 18, 16);
				((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
				((LayoutGroup)obj).childAlignment = (TextAnchor)1;
				((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false;
				((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
				_title = CreateText("Title", (Transform)(object)_panel, 18f, (FontStyles)1, 26f);
				((Graphic)_title).color = UiGfx.Title;
				_subtitle = CreateText("Subtitle", (Transform)(object)_panel, 13.5f, (FontStyles)0, 36f);
				((Graphic)_subtitle).color = UiGfx.Hint;
				GameObject val = new GameObject("PlayerGrid", new Type[1] { typeof(RectTransform) });
				val.transform.SetParent((Transform)(object)_panel, false);
				_playerGrid = val.transform;
				GridLayoutGroup obj2 = val.AddComponent<GridLayoutGroup>();
				obj2.cellSize = new Vector2(248f, 52f);
				obj2.spacing = new Vector2(10f, 10f);
				obj2.constraint = (Constraint)1;
				obj2.constraintCount = 2;
				((LayoutGroup)obj2).childAlignment = (TextAnchor)1;
				LayoutElement obj3 = val.AddComponent<LayoutElement>();
				obj3.minHeight = 220f;
				obj3.flexibleHeight = 1f;
				obj3.preferredHeight = 260f;
				GameObject val2 = new GameObject("Buttons", new Type[1] { typeof(RectTransform) });
				val2.transform.SetParent((Transform)(object)_panel, false);
				HorizontalLayoutGroup obj4 = val2.AddComponent<HorizontalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)obj4).spacing = 10f;
				((LayoutGroup)obj4).childAlignment = (TextAnchor)4;
				((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = true;
				LayoutElement obj5 = val2.AddComponent<LayoutElement>();
				obj5.minHeight = 32f;
				obj5.preferredHeight = 32f;
				_cancelButton = CreateRowButton("Cancel", val2.transform, "Cancel");
				_confirmButton = CreateRowButton("Confirm", val2.transform, _confirmLabel = "Confirm");
				((UnityEvent)_cancelButton.onClick).AddListener(new UnityAction(Cancel));
			}

			internal void OpenTargetOnly(Player actor, string title, string subtitle, string confirmLabel, Action<Player> onConfirm, bool includeSelf = true, Action onCancel = null)
			{
				_actor = actor;
				_onConfirm = onConfirm;
				_onCancel = onCancel;
				_confirmLabel = confirmLabel;
				((TMP_Text)_title).text = title;
				((TMP_Text)_subtitle).text = subtitle;
				((TMP_Text)((Component)_confirmButton).GetComponentInChildren<TextMeshProUGUI>()).text = confirmLabel;
				_selected = (includeSelf ? actor : null);
				RebuildPlayerButtons(includeSelf);
				((Component)this).gameObject.SetActive(true);
			}

			internal void OpenCardChoices(string title, string subtitle, string confirmLabel, List<(string label, GameObject card)> cards, Action<GameObject> onConfirm, Action onCancel)
			{
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Expected O, but got Unknown
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Expected O, but got Unknown
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Expected O, but got Unknown
				_actor = null;
				_onConfirm = null;
				_onCancel = onCancel;
				_confirmLabel = confirmLabel;
				((TMP_Text)_title).text = title;
				((TMP_Text)_subtitle).text = subtitle;
				((TMP_Text)((Component)_confirmButton).GetComponentInChildren<TextMeshProUGUI>()).text = confirmLabel;
				_selected = null;
				ClearGrid();
				GameObject picked = null;
				foreach (var card in cards)
				{
					if (!((Object)(object)card.card == (Object)null))
					{
						Button button = CreateLabeledButton(card.label);
						GameObject captured = card.card;
						((UnityEvent)button.onClick).AddListener((UnityAction)delegate
						{
							picked = captured;
							Highlight(button);
						});
					}
				}
				((UnityEventBase)_confirmButton.onClick).RemoveAllListeners();
				((UnityEvent)_confirmButton.onClick).AddListener((UnityAction)delegate
				{
					if (!((Object)(object)picked == (Object)null))
					{
						onConfirm?.Invoke(picked);
						Close();
					}
				});
				((UnityEventBase)_cancelButton.onClick).RemoveAllListeners();
				((UnityEvent)_cancelButton.onClick).AddListener(new UnityAction(Cancel));
				((Component)this).gameObject.SetActive(true);
			}

			internal void Close()
			{
				((Component)this).gameObject.SetActive(false);
				ClearGrid();
			}

			private void Cancel()
			{
				Action onCancel = _onCancel;
				_onCancel = null;
				onCancel?.Invoke();
				Close();
			}

			private void RebuildPlayerButtons(bool includeSelf)
			{
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Expected O, but got Unknown
				//IL_0143: Unknown result type (might be due to invalid IL or missing references)
				//IL_014d: Expected O, but got Unknown
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Expected O, but got Unknown
				ClearGrid();
				if (PlayerManager.instance?.players == null)
				{
					return;
				}
				foreach (Player player in PlayerManager.instance.players)
				{
					if (!((Object)(object)player == (Object)null) && (includeSelf || !((Object)(object)_actor != (Object)null) || player.playerID != _actor.playerID))
					{
						string text = PlayerLabels.For(player);
						if ((Object)(object)_actor != (Object)null && player.playerID == _actor.playerID)
						{
							text += " (You)";
						}
						Button button = CreateGridButton(text, player);
						Player captured = player;
						((UnityEvent)button.onClick).AddListener((UnityAction)delegate
						{
							SelectPlayer(captured, button);
						});
					}
				}
				((UnityEventBase)_confirmButton.onClick).RemoveAllListeners();
				((UnityEvent)_confirmButton.onClick).AddListener((UnityAction)delegate
				{
					if (!((Object)(object)_selected == (Object)null))
					{
						_onCancel = null;
						_onConfirm?.Invoke(_selected);
						Close();
					}
				});
				((UnityEventBase)_cancelButton.onClick).RemoveAllListeners();
				((UnityEvent)_cancelButton.onClick).AddListener(new UnityAction(Cancel));
			}

			private void SelectPlayer(Player player, Button button)
			{
				_selected = player;
				Highlight(button);
			}

			private void Highlight(Button selected)
			{
				//IL_0019: 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_0059: Unknown result type (might be due to invalid IL or missing references)
				foreach (Transform item in ((Component)selected).transform.parent)
				{
					Image component = ((Component)item).GetComponent<Image>();
					if ((Object)(object)component != (Object)null)
					{
						((Graphic)component).color = UiGfx.Tile;
					}
				}
				((Graphic)((Component)selected).GetComponent<Image>()).color = UiGfx.TileSelected;
			}

			private Button CreateLabeledButton(string label)
			{
				return CreateTile(label, _playerGrid, selected: false);
			}

			private Button CreateGridButton(string label, Player player)
			{
				bool selected = (Object)(object)_selected != (Object)null && _selected.playerID == player.playerID;
				return CreateTile(label, _playerGrid, selected);
			}

			private static Button CreateTile(string label, Transform parent, bool selected)
			{
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: 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_007d: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = new GameObject("Tile", new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(Button)
				});
				val.transform.SetParent(parent, false);
				UiGfx.Round(val.GetComponent<Image>(), selected ? UiGfx.TileSelected : UiGfx.Tile, raycast: true);
				Button component = val.GetComponent<Button>();
				UiGfx.GhostColors(component);
				((Graphic)CreateInnerText(val.transform, label, 14f)).color = UiGfx.Label;
				return component;
			}

			private void ClearGrid()
			{
				if (!((Object)(object)_playerGrid == (Object)null))
				{
					for (int num = _playerGrid.childCount - 1; num >= 0; num--)
					{
						Object.Destroy((Object)(object)((Component)_playerGrid.GetChild(num)).gameObject);
					}
				}
			}

			private static RectTransform CreatePanel(string name, Transform parent, Vector2 size)
			{
				//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_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: 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_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
				val.transform.SetParent(parent, false);
				RectTransform component = val.GetComponent<RectTransform>();
				component.anchorMin = new Vector2(0.5f, 0.5f);
				component.anchorMax = new Vector2(0.5f, 0.5f);
				component.pivot = new Vector2(0.5f, 0.5f);
				component.sizeDelta = size;
				component.anchoredPosition = Vector2.zero;
				return component;
			}

			private static Image CreateImage(string name, Transform parent, Vector2 min, Vector2 max)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: 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_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = new GameObject(name, new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val.transform.SetParent(parent, false);
				RectTransform component = val.GetComponent<RectTransform>();
				component.anchorMin = min;
				component.anchorMax = max;
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
				return val.GetComponent<Image>();
			}

			private static TextMeshProUGUI CreateText(string name, Transform parent, float size, FontStyles style, float height)
			{
				//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_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
				val.transform.SetParent(parent, false);
				val.AddComponent<LayoutElement>().preferredHeight = height;
				TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
				UiGfx.StyleTmp(obj, size, UiGfx.Title, (TextAlignmentOptions)257);
				((TMP_Text)obj).fontStyle = style;
				return obj;
			}

			private static TextMeshProUGUI CreateInnerText(Transform parent, string label, float size)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: 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_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = new GameObject("Label", new Type[1] { typeof(RectTransform) });
				val.transform.SetParent(parent, false);
				RectTransform component = val.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.offsetMin = new Vector2(10f, 6f);
				component.offsetMax = new Vector2(-10f, -6f);
				TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
				((TMP_Text)obj).text = label;
				UiGfx.StyleTmp(obj, size, UiGfx.Label, (TextAlignmentOptions)514);
				return obj;
			}

			private static Button CreateRowButton(string name, Transform parent, string label)
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: 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_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = new GameObject(name, new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(Button)
				});
				val.transform.SetParent(parent, false);
				val.AddComponent<LayoutElement>().preferredHeight = 32f;
				UiGfx.Round(val.GetComponent<Image>(), UiGfx.Tile, raycast: true);
				Button component = val.GetComponent<Button>();
				UiGfx.GhostColors(component);
				((Graphic)CreateInnerText(val.transform, label, 13f)).color = UiGfx.Label;
				return component;
			}
		}

		private static Overlay _overlay;

		private static ToastHost _toast;

		internal static bool IsOpen
		{
			get
			{
				if ((Object)(object)_overlay != (Object)null)
				{
					return ((Component)_overlay).gameObject.activeSelf;
				}
				return false;
			}
		}

		internal static void OpenSandbag(Player user, Action<Player> onConfirm, Action onCancel = null)
		{
			OpenPlayerTarget(user, "Sandbag Simulator", "Choose who rerolls their cards. The game waits until you confirm.", "Reroll", onConfirm, includeSelf: true, onCancel);
		}

		internal static void OpenPlayerTarget(Player user, string title, string subtitle, string confirmLabel, Action<Player> onConfirm, bool includeSelf, Action onCancel = null)
		{
			EnsureOverlay();
			_overlay.OpenTargetOnly(user, title, subtitle, confirmLabel, onConfirm, includeSelf, onCancel);
		}

		internal static void OpenCardChoices(string title, string subtitle, string confirmLabel, List<(string label, GameObject card)> cards, Action<GameObject> onConfirm, Action onCancel = null)
		{
			EnsureOverlay();
			_overlay.OpenCardChoices(title, subtitle, confirmLabel, cards, onConfirm, onCancel);
		}

		internal static void ShowToast(string message)
		{
			EnsureToast();
			_toast?.Show(message);
		}

		internal static void Close()
		{
			if ((Object)(object)_overlay != (Object)null)
			{
				_overlay.Close();
			}
		}

		private static void EnsureOverlay()
		{
			//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_0059: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_overlay != (Object)null))
			{
				Unbound instance = Unbound.Instance;
				Canvas val = ((instance != null) ? instance.canvas : null);
				if (!((Object)(object)val == (Object)null))
				{
					GameObject val2 = new GameObject("LAMC_CardTargetUi", new Type[1] { typeof(RectTransform) });
					val2.transform.SetParent(((Component)val).transform, false);
					_overlay = val2.AddComponent<Overlay>();
					_overlay.Build();
					val2.SetActive(false);
				}
			}
		}

		private static void EnsureToast()
		{
			//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_0059: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_toast != (Object)null))
			{
				Unbound instance = Unbound.Instance;
				Canvas val = ((instance != null) ? instance.canvas : null);
				if (!((Object)(object)val == (Object)null))
				{
					GameObject val2 = new GameObject("LAMC_Toast", new Type[1] { typeof(RectTransform) });
					val2.transform.SetParent(((Component)val).transform, false);
					_toast = val2.AddComponent<ToastHost>();
					_toast.Build();
					val2.SetActive(true);
				}
			}
		}
	}
	internal static class CurseOnlyPlayers
	{
		private static ulong[] _targets = Array.Empty<ulong>();

		private static bool _parsed;

		private static bool _steamProbed;

		private static MethodInfo _getSteamId;

		private static FieldInfo _steamIdValue;

		private static ulong _localSteamId;

		[ThreadStatic]
		private static bool _reentrant;

		private static int _cachedCount = -1;

		private static int _cachedForPlayer = -1;

		private static float _cachedAt;

		private static bool _announced;

		private static int _cachedLocalId = -1;

		private static int _localIdCachedAt = -1;

		internal static bool Reentrant
		{
			get
			{
				return _reentrant;
			}
			set
			{
				_reentrant = value;
			}
		}

		internal static void ResetCache()
		{
			_cachedCount = -1;
			_cachedForPlayer = -1;
			_cachedLocalId = -1;
			_localIdCachedAt = -1;
		}

		internal static void InvalidateTargets()
		{
			_parsed = false;
		}

		internal static bool AppliesTo(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			ParseTargets();
			if (_targets.Length == 0)
			{
				return false;
			}
			ulong num = LocalSteamId();
			if (num == 0L)
			{
				return false;
			}
			bool flag = false;
			ulong[] targets = _targets;
			for (int i = 0; i < targets.Length; i++)
			{
				if (targets[i] == num)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				if (!_announced)
				{
					_announced = true;
					Plugin.Instance?.Log($"Curse-only is armed for {_targets.Length} account(s); this machine " + $"({num}) is not one of them, so offers are unchanged.");
				}
				return false;
			}
			if (!_announced)
			{
				_announced = true;
				Plugin.Instance?.Log($"Curse-only is ACTIVE for this machine ({num}).");
			}
			if (_localIdCachedAt != Time.frameCount)
			{
				Player val = LocalPlayerUtil.LocalPlayer();
				_cachedLocalId = (((Object)(object)val != (Object)null) ? val.playerID : (-1));
				_localIdCachedAt = Time.frameCount;
			}
			if (_cachedLocalId >= 0)
			{
				return _cachedLocalId == player.playerID;
			}
			return false;
		}

		internal static bool CanRestrict(Player player)
		{
			if ((Object)(object)player == (Object)null || !WwmCurses.IsAvailable)
			{
				return false;
			}
			if (_cachedForPlayer == player.playerID && _cachedCount >= 0 && Time.unscaledTime - _cachedAt < 1f)
			{
				return _cachedCount > 0;
			}
			int num = (_cachedCount = WwmCurses.CountDrawableCurses(player));
			_cachedForPlayer = player.playerID;
			_cachedAt = Time.unscaledTime;
			if (num == 0)
			{
				Plugin.Instance?.LogWarn("Curse-only is configured for this account but no curse is currently drawable; offering normal cards instead so the pick cannot soft-lock.");
			}
			else
			{
				Plugin.Instance?.Log($"Curse-only: restricting this offer to {num} drawable curse(s).");
			}
			return num > 0;
		}

		private static void ParseTargets()
		{
			if (_parsed)
			{
				return;
			}
			_parsed = true;
			string obj = Plugin.Configs?.CurseOnlySteamIds?.Value ?? "";
			List<ulong> list = new List<ulong>();
			string[] array = obj.Split(',', ';', ' ');
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (text.Length != 0)
				{
					if (ulong.TryParse(text, out var result) && result != 0)
					{
						list.Add(result);
					}
					else
					{
						Plugin.Instance?.LogWarn("Ignoring malformed Steam ID '" + text + "' in CurseOnlySteamIds.");
					}
				}
			}
			_targets = list.ToArray();
		}

		private static ulong LocalSteamId()
		{
			if (_localSteamId != 0L)
			{