Decompiled source of SandboxImprovements v1.0.1

SandboxImprovements.dll

Decompiled an hour 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 BepInEx;
using HarmonyLib;
using InControl;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using SandboxImprovements.Utilities;
using TMPro;
using UnboundLib;
using UnboundLib.GameModes;
using UnboundLib.Utils;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.UI.ProceduralImage;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SandboxImprovements
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.rsmind.rounds.sandboximprovements", "Sandbox Improvements", "1.0.0")]
	[BepInProcess("Rounds.exe")]
	public class SandboxImprovements : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__15_0;

			public static UnityAction <>9__16_0;

			public static UnityAction <>9__16_1;

			public static UnityAction<bool> <>9__24_0;

			internal void <Start>b__15_0()
			{
			}

			internal void <CreateButtons>b__16_0()
			{
				MapSelectMenuHandler.instance.mapMenuCanvas.SetActive(true);
				MapSelectMenuHandler.instance.UpdateEnabledMaps();
				Animator[] componentsInChildren = ((Component)MapSelectMenuHandler.CategoryContent).GetComponentsInChildren<Animator>();
				foreach (Animator val in componentsInChildren)
				{
					val.SetTrigger(((Component)MapSelectMenuHandler.ScrollViews[((Object)((Component)((Component)val).gameObject.GetComponentInParent<Button>()).gameObject).name]).gameObject.activeSelf.ToString());
				}
			}

			internal void <CreateButtons>b__16_1()
			{
				GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu").GetComponent<EscapeMenuHandler>().ToggleEsc();
				CardSpawnMenuHandler.cardMenuCanvas.SetActive(true);
				CardSpawnMenuHandler.instance.UpdateEnabledCards();
				Animator[] componentsInChildren = ((Component)CardSpawnMenuHandler.CategoryContent).GetComponentsInChildren<Animator>();
				foreach (Animator val in componentsInChildren)
				{
					val.SetTrigger(((Component)CardSpawnMenuHandler.ScrollViews[((Object)((Component)((Component)val).gameObject.GetComponentInParent<Button>()).gameObject).name]).gameObject.activeSelf.ToString());
				}
			}

			internal void <OptionGUI>b__24_0(bool val)
			{
				showKeys = val;
			}
		}

		private const string ModId = "com.rsmind.rounds.sandboximprovements";

		private const string ModName = "Sandbox Improvements";

		private const string CompatibilityModName = "SandboxImprovements";

		public const string Version = "1.0.0";

		public const string ModInitials = "SI";

		public static bool Debug = true;

		internal static AssetBundle Assets;

		internal static GameObject KeyHintText;

		internal static GameObject MapSelectButton;

		internal static GameObject CardSpawnButton;

		public static SandboxImprovements instance { get; private set; }

		public static bool showKeys
		{
			get
			{
				return PlayerPrefs.GetInt(GetConfigKey("showKeys"), 1) == 1;
			}
			internal set
			{
				PlayerPrefs.SetInt(GetConfigKey("showKeys"), value ? 1 : 0);
			}
		}

		private void Awake()
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			Unbound.RegisterClientSideMod("com.rsmind.rounds.sandboximprovements");
			Assets = AssetUtils.LoadAssetBundleFromResources("sandboximprovements", typeof(SandboxImprovements).Assembly);
			if ((Object)(object)Assets == (Object)null)
			{
				Debug.Log((object)"Failed to load Fancy Card Bar asset bundle");
			}
			((Component)this).gameObject.AddComponent<MapSelectMenuHandler>();
			((Component)this).gameObject.AddComponent<CardSpawnMenuHandler>();
			Harmony val = new Harmony("com.rsmind.rounds.sandboximprovements");
			val.PatchAll();
			SceneManager.sceneLoaded += CreateButtons;
		}

		private void Start()
		{
			//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_002c: Expected O, but got Unknown
			instance = this;
			object obj = <>c.<>9__15_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__15_0 = val;
				obj = (object)val;
			}
			Unbound.RegisterMenu("Sandbox Improvements", (UnityAction)obj, (Action<GameObject>)OptionGUI, (GameObject)null, true);
		}

		private static void CreateButtons(Scene scene, LoadSceneMode mode)
		{
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Expected O, but got Unknown
			if ((Object)(object)KeyHintText == (Object)null)
			{
				KeyHintText = Object.Instantiate<GameObject>(Assets.LoadAsset<GameObject>("Hotkey Visualizer"), GameObject.Find("Game/UI/UI_Game/Canvas").transform);
				KeyHintText.GetComponent<Canvas>().sortingLayerName = "MostFront";
				KeyHintText.GetComponent<Canvas>().overrideSorting = true;
			}
			if ((Object)(object)MapSelectButton == (Object)null)
			{
				GameObject gameObject = GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu/Main/Group").gameObject;
				object obj = <>c.<>9__16_0;
				if (obj == null)
				{
					UnityAction val = delegate
					{
						MapSelectMenuHandler.instance.mapMenuCanvas.SetActive(true);
						MapSelectMenuHandler.instance.UpdateEnabledMaps();
						Animator[] componentsInChildren2 = ((Component)MapSelectMenuHandler.CategoryContent).GetComponentsInChildren<Animator>();
						foreach (Animator val4 in componentsInChildren2)
						{
							val4.SetTrigger(((Component)MapSelectMenuHandler.ScrollViews[((Object)((Component)((Component)val4).gameObject.GetComponentInParent<Button>()).gameObject).name]).gameObject.activeSelf.ToString());
						}
					};
					<>c.<>9__16_0 = val;
					obj = (object)val;
				}
				MapSelectButton = MenuHandler.CreateButton("Select Map", gameObject, (UnityAction)obj, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
				CopyComponent<ProceduralImage>(GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu/Main/Group/Menu").GetComponent<ProceduralImage>(), MapSelectButton);
				CopyComponent<FreeModifier>(GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu/Main/Group/Menu").GetComponent<FreeModifier>(), MapSelectButton);
				MapSelectButton.GetComponent<RectTransform>().sizeDelta = new Vector2(2050.3f, 90f);
				MapSelectButton.GetComponent<Selectable>().transition = (Transition)1;
				MapSelectButton.GetComponent<Selectable>().colors = GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu/Main/Group/Menu").GetComponent<Selectable>().colors;
				MapSelectButton.transform.SetSiblingIndex(MapSelectButton.transform.parent.childCount - 2);
			}
			if (!((Object)(object)CardSpawnButton == (Object)null))
			{
				return;
			}
			GameObject gameObject2 = GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu/Main/Group").gameObject;
			object obj2 = <>c.<>9__16_1;
			if (obj2 == null)
			{
				UnityAction val2 = delegate
				{
					GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu").GetComponent<EscapeMenuHandler>().ToggleEsc();
					CardSpawnMenuHandler.cardMenuCanvas.SetActive(true);
					CardSpawnMenuHandler.instance.UpdateEnabledCards();
					Animator[] componentsInChildren = ((Component)CardSpawnMenuHandler.CategoryContent).GetComponentsInChildren<Animator>();
					foreach (Animator val3 in componentsInChildren)
					{
						val3.SetTrigger(((Component)CardSpawnMenuHandler.ScrollViews[((Object)((Component)((Component)val3).gameObject.GetComponentInParent<Button>()).gameObject).name]).gameObject.activeSelf.ToString());
					}
				};
				<>c.<>9__16_1 = val2;
				obj2 = (object)val2;
			}
			CardSpawnButton = MenuHandler.CreateButton("Spawn Cards", gameObject2, (UnityAction)obj2, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			CopyComponent<ProceduralImage>(GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu/Main/Group/Menu").GetComponent<ProceduralImage>(), CardSpawnButton);
			CopyComponent<FreeModifier>(GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu/Main/Group/Menu").GetComponent<FreeModifier>(), CardSpawnButton);
			CardSpawnButton.GetComponent<RectTransform>().sizeDelta = new Vector2(2050.3f, 90f);
			CardSpawnButton.GetComponent<Selectable>().transition = (Transition)1;
			CardSpawnButton.GetComponent<Selectable>().colors = GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu/Main/Group/Menu").GetComponent<Selectable>().colors;
			CardSpawnButton.transform.SetSiblingIndex(CardSpawnButton.transform.parent.childCount - 2);
		}

		private static T CopyComponent<T>(T original, GameObject destination) where T : Component
		{
			Type type = ((object)original).GetType();
			Component val = destination.AddComponent(type);
			FieldInfo[] fields = type.GetFields();
			FieldInfo[] array = fields;
			foreach (FieldInfo fieldInfo in array)
			{
				fieldInfo.SetValue(val, fieldInfo.GetValue(original));
			}
			return (T)(object)((val is T) ? val : null);
		}

		private void Update()
		{
			bool flag = GameModeManager.CurrentHandlerID == "Sandbox";
			KeyHintText.SetActive(flag && showKeys);
			MapSelectButton.SetActive(flag);
			CardSpawnButton.SetActive(flag);
		}

		public static void GetRidOfSandboxTutorial()
		{
			CurveAnimation component = GameObject.Find("Game/Code/Game Modes/[GameMode] Sandbox/Canvas/Image").GetComponent<CurveAnimation>();
			component.Stop();
			ExtensionMethods.InvokeMethod((object)component, "ResetAnimationState", Array.Empty<object>());
		}

		internal static string GetConfigKey(string name)
		{
			return "SandboxImprovements_" + name.ToLower();
		}

		private static void OptionGUI(GameObject menu)
		{
			TextMeshProUGUI val2 = default(TextMeshProUGUI);
			MenuHandler.CreateText("Sandbox Improvements Options", menu, ref val2, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateText(" ", menu, ref val2, 30, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
			MenuHandler.CreateToggle(showKeys, "Show Key Prompts", menu, (UnityAction<bool>)delegate(bool val)
			{
				showKeys = val;
			}, 60, true, (Color?)null, (TMP_FontAsset)null, (Material)null, (TextAlignmentOptions?)null);
		}
	}
}
namespace SandboxImprovements.Utilities
{
	public class CardSpawnMenuHandler : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <EnableCardsInCategory>d__25 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string category;

			public CardSpawnMenuHandler <>4__this;

			private List<GameObject>.Enumerator <>s__1;

			private GameObject <cardObject>5__2;

			private bool <active>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <EnableCardsInCategory>d__25(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<cardObject>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						if (!<>4__this.cardObjectsInCategory.ContainsKey(category))
						{
							return false;
						}
						<>s__1 = <>4__this.cardObjectsInCategory[category].GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						<cardObject>5__2 = null;
						break;
					}
					if (<>s__1.MoveNext())
					{
						<cardObject>5__2 = <>s__1.Current;
						<active>5__3 = <>4__this.ActiveOnSearch(((Object)<cardObject>5__2).name);
						<cardObject>5__2.gameObject.SetActive(<active>5__3);
						UpdateVisualsCardObj(<cardObject>5__2);
						<>2__current = (object)new WaitForEndOfFrame();
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>s__1).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static CardSpawnMenuHandler instance;

		internal static readonly Dictionary<string, Transform> ScrollViews = new Dictionary<string, Transform>();

		public static readonly Dictionary<GameObject, Action> cardObjs = new Dictionary<GameObject, Action>();

		public static readonly List<Action> defaultCardActions = new List<Action>();

		private readonly Dictionary<string, List<GameObject>> cardObjectsInCategory = new Dictionary<string, List<GameObject>>();

		private readonly List<GameObject> categoryObjs = new List<GameObject>();

		public static GameObject cardMenuCanvas;

		private GameObject cardObjAsset;

		private GameObject cardScrollViewAsset;

		private GameObject categoryButtonAsset;

		private Transform scrollViewTrans;

		internal static Transform CategoryContent;

		private static bool sortedByName = true;

		private static TextMeshProUGUI cardAmountText;

		private int currentColumnAmount = 5;

		private string currentCategory = "Vanilla";

		private string currentSearch = "";

		private bool toggledAll;

		private Coroutine cardVisualsCoroutine = null;

		internal static Color uncommonColor = new Color(0f, 0.5f, 1f, 1f);

		internal static Color rareColor = new Color(1f, 0.2f, 1f, 1f);

		private void Start()
		{
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Expected O, but got Unknown
			instance = this;
			Camera component = GameObject.Find("MainCamera").GetComponent<Camera>();
			GameObject val = SandboxImprovements.Assets.LoadAsset<GameObject>("CardMenuCanvas");
			cardObjAsset = SandboxImprovements.Assets.LoadAsset<GameObject>("CardObj");
			cardScrollViewAsset = SandboxImprovements.Assets.LoadAsset<GameObject>("CardScrollView");
			categoryButtonAsset = SandboxImprovements.Assets.LoadAsset<GameObject>("CategoryButton");
			cardMenuCanvas = Object.Instantiate<GameObject>(val);
			Object.DontDestroyOnLoad((Object)(object)cardMenuCanvas);
			Canvas component2 = cardMenuCanvas.GetComponent<Canvas>();
			component2.renderMode = (RenderMode)1;
			component2.worldCamera = component;
			cardMenuCanvas.SetActive(false);
			scrollViewTrans = cardMenuCanvas.transform.Find("CardMenu/ScrollViews");
			CategoryContent = cardMenuCanvas.transform.Find("CardMenu/Top/Categories/ButtonsScroll/Viewport/Content");
			GameObject gameObject = ((Component)cardMenuCanvas.transform.Find("CardMenu/Top/InputField")).gameObject;
			((UnityEvent<string>)(object)gameObject.GetComponent<TMP_InputField>().onValueChanged).AddListener((UnityAction<string>)delegate(string value)
			{
				currentSearch = value;
				Button[] componentsInChildren4 = ((Component)ScrollViews[currentCategory]).GetComponentsInChildren<Button>(true);
				foreach (Button val11 in componentsInChildren4)
				{
					bool flag = ActiveOnSearch(((Object)((Component)val11).gameObject).name);
					((Component)val11).gameObject.SetActive(flag);
					if (flag)
					{
						UpdateVisualsCardObj(((Component)val11).gameObject);
					}
				}
			});
			((TMP_Text)((Component)cardMenuCanvas.transform.Find("CardMenu/Top/SortBy")).GetComponentInChildren<TextMeshProUGUI>()).text = "Sort By: " + (sortedByName ? "Name" : "Rarity");
			Button component3 = ((Component)cardMenuCanvas.transform.Find("CardMenu/Top/SortBy")).GetComponent<Button>();
			((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
			{
				sortedByName = !sortedByName;
				((TMP_Text)((Component)cardMenuCanvas.transform.Find("CardMenu/Top/SortBy")).GetComponentInChildren<TextMeshProUGUI>()).text = "Sort By: " + (sortedByName ? "Name" : "Rarity");
				SortCardMenus(sortedByName);
			});
			Transform val2 = cardMenuCanvas.transform.Find("CardMenu/Top/CardAmount");
			cardAmountText = ((Component)val2).GetComponentInChildren<TextMeshProUGUI>();
			Slider[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Slider>();
			Slider[] array = componentsInChildren;
			foreach (Slider val3 in array)
			{
				((UnityEvent<float>)(object)val3.onValueChanged).AddListener((UnityAction<float>)delegate(float amount)
				{
					int amount2 = (int)amount;
					ChangeCardColumnAmountMenus(amount2);
				});
			}
			ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)this, 0.5f, (Action)delegate
			{
				//IL_039d: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a7: Expected O, but got Unknown
				//IL_0431: Unknown result type (might be due to invalid IL or missing references)
				//IL_0438: Expected O, but got Unknown
				//IL_0453: Unknown result type (might be due to invalid IL or missing references)
				//IL_045a: Expected O, but got Unknown
				cardMenuCanvas.SetActive(true);
				foreach (string category2 in CardManager.categories)
				{
					GameObject val4 = Object.Instantiate<GameObject>(cardScrollViewAsset, scrollViewTrans);
					val4.SetActive(true);
					((Object)val4).name = category2;
					ScrollViews.Add(category2, val4.transform);
				}
				foreach (KeyValuePair<string, Card> card in CardManager.cards)
				{
					Card cardValue = card.Value;
					if (cardValue != null)
					{
						Transform val5 = ScrollViews[cardValue.category].Find("Viewport/Content");
						GameObject val6 = Object.Instantiate<GameObject>(cardObjAsset, val5);
						((Object)val6).name = card.Key;
						CardInfo cardInfo = cardValue.cardInfo;
						if (!((Object)(object)cardInfo == (Object)null))
						{
							SetupCardVisuals(cardInfo, val6);
							val6.SetActive(false);
							if (!cardObjectsInCategory.ContainsKey(cardValue.category))
							{
								cardObjectsInCategory.Add(cardValue.category, new List<GameObject>());
							}
							cardObjectsInCategory[cardValue.category].Add(val6);
							cardObjs[val6] = CardAction;
							defaultCardActions.Add(CardAction);
							UpdateVisualsCardObj(val6);
						}
					}
					void CardAction()
					{
						if (cardValue.enabled)
						{
							ExtensionMethods.InvokeMethod((object)((Component)MenuControllerHandler.instance).gameObject.GetComponent<DevConsole>(), "SpawnCard", new object[1] { cardValue.cardInfo.cardName });
						}
					}
				}
				UpdateCardColumnAmountMenus();
				foreach (Transform value in ScrollViews.Values)
				{
					SetActive(((Component)value).transform, active: false);
					if (((Object)value).name == "Vanilla")
					{
						SetActive(((Component)value).transform, active: true);
					}
				}
				TextMeshProUGUI viewingText = ((Component)cardMenuCanvas.transform.Find("CardMenu/Top/Viewing")).gameObject.GetComponentInChildren<TextMeshProUGUI>();
				List<string> list = new string[1] { "Vanilla" }.Concat(CardManager.categories.OrderBy((string x) => x).Except(new string[1] { "Vanilla" })).ToList();
				foreach (string category in list)
				{
					GameObject categoryObj = Object.Instantiate<GameObject>(categoryButtonAsset, CategoryContent);
					categoryObj.SetActive(true);
					((Object)categoryObj).name = category;
					((TMP_Text)categoryObj.GetComponentInChildren<TextMeshProUGUI>()).text = category;
					((UnityEvent)categoryObj.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
					{
						//IL_0154: Unknown result type (might be due to invalid IL or missing references)
						Animator[] componentsInChildren2 = ((Component)CategoryContent).GetComponentsInChildren<Animator>();
						foreach (Animator val9 in componentsInChildren2)
						{
							if (!categoryObj.GetComponentsInChildren<Animator>().Contains(val9))
							{
								val9.SetTrigger("False");
							}
						}
						Animator[] componentsInChildren3 = categoryObj.GetComponentsInChildren<Animator>();
						foreach (Animator val10 in componentsInChildren3)
						{
							val10.SetTrigger("True");
						}
						string text = "Viewing: " + category;
						if (!(((TMP_Text)viewingText).text == text))
						{
							((TMP_Text)viewingText).text = text;
							foreach (KeyValuePair<string, Transform> scrollView in ScrollViews)
							{
								DisableCardsInCategory(scrollView.Key);
								SetActive(scrollView.Value, active: false);
							}
							((Component)ScrollViews[category]).GetComponent<ScrollRect>().normalizedPosition = new Vector2(0f, 1f);
							SetActive(((Component)ScrollViews[category]).transform, active: true);
							currentCategory = category;
						}
					});
					categoryObjs.Add(categoryObj);
					Toggle toggle = categoryObj.GetComponentInChildren<Toggle>();
					((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate
					{
						toggle.isOn = CardManager.IsCategoryActive(category);
					});
					UpdateCategoryVisuals(categoryObj, CardManager.IsCategoryActive(category), firstTime: true);
				}
				for (int j = 0; j < cardObjs.Keys.Count; j++)
				{
					ButtonClickedEvent val7 = new ButtonClickedEvent();
					UnityAction val8 = new UnityAction(cardObjs.ElementAt(j).Value.Invoke);
					((UnityEvent)val7).AddListener(val8);
					cardObjs.ElementAt(j).Key.GetComponent<Button>().onClick = val7;
				}
				cardMenuCanvas.GetComponent<Canvas>().sortingOrder = 256;
				cardMenuCanvas.SetActive(false);
			});
		}

		public void UpdateEnabledCards()
		{
			foreach (GameObject categoryObj in categoryObjs)
			{
				UpdateCategoryVisuals(categoryObj, CardManager.IsCategoryActive(((Object)categoryObj).name), firstTime: true);
			}
		}

		private void UpdateCategoryVisuals(GameObject categoryObj, bool enabledVisuals, bool firstTime = false)
		{
			foreach (KeyValuePair<string, Transform> item in ScrollViews.Where((KeyValuePair<string, Transform> obj) => obj.Key == ((Object)categoryObj).name))
			{
				((Component)item.Value.Find("Darken")).gameObject.SetActive(!enabledVisuals);
			}
			if (!firstTime)
			{
				string[] cardsInCategory = CardManager.GetCardsInCategory(((Object)categoryObj).name);
				foreach (GameObject item2 in cardObjs.Keys.Where((GameObject o) => cardsInCategory.Contains(((Object)o).name)))
				{
					UpdateVisualsCardObj(item2);
				}
			}
			Toggle componentInChildren = categoryObj.GetComponentInChildren<Toggle>();
			componentInChildren.isOn = CardManager.IsCategoryActive(((Object)categoryObj).name);
		}

		private bool ActiveOnSearch(string cardName)
		{
			string[] array = (cardName.Contains("__") ? cardName.Split(new string[1] { "__" }, StringSplitOptions.None) : new string[1] { cardName });
			string text = ((array.Length > 2) ? array[2] : array[0]);
			return currentSearch == "" || text.ToUpper().Contains(currentSearch.ToUpper());
		}

		private void DisableCards()
		{
			foreach (GameObject item in CardManager.categories.SelectMany((string category) => cardObjectsInCategory[category]))
			{
				item.SetActive(false);
			}
		}

		private void DisableCardsInCategory(string category)
		{
			if (!cardObjectsInCategory.ContainsKey(category))
			{
				return;
			}
			foreach (GameObject item in cardObjectsInCategory[category])
			{
				item.SetActive(false);
			}
		}

		[IteratorStateMachine(typeof(<EnableCardsInCategory>d__25))]
		private IEnumerator EnableCardsInCategory(string category)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <EnableCardsInCategory>d__25(0)
			{
				<>4__this = this,
				category = category
			};
		}

		private static void SetupCardVisuals(CardInfo cardInfo, GameObject parent)
		{
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Invalid comparison between Unknown and I4
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Invalid comparison between Unknown and I4
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(((Component)cardInfo).gameObject, parent.gameObject.transform);
			val.AddComponent<MenuCard>();
			val.SetActive(true);
			GameObject val2 = FindObjectInChildren(val, "Front");
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			GameObject val3 = FindObjectInChildren(val, "Back");
			Object.Destroy((Object)(object)val3);
			GameObject val4 = FindObjectInChildren(val, "Damagable");
			Object.Destroy((Object)(object)val4);
			CardVisuals[] componentsInChildren = val.GetComponentsInChildren<CardVisuals>();
			foreach (CardVisuals val5 in componentsInChildren)
			{
				val5.firstValueToSet = true;
			}
			GameObject obj = FindObjectInChildren(val, "BlockFront");
			if (obj != null)
			{
				obj.SetActive(false);
			}
			CanvasGroup[] componentsInChildren2 = val.GetComponentsInChildren<CanvasGroup>();
			CanvasGroup[] array = componentsInChildren2;
			foreach (CanvasGroup val6 in array)
			{
				val6.alpha = 1f;
			}
			GameObject val7 = FindObjectInChildren(val2.gameObject, "UI_ParticleSystem");
			if ((Object)(object)val7 != (Object)null)
			{
				Object.Destroy((Object)(object)val7);
			}
			if ((Object)(object)cardInfo.cardArt != (Object)null)
			{
				GameObject val8 = FindObjectInChildren(val2.gameObject, "Art");
				if ((Object)(object)val8 != (Object)null)
				{
					CardAnimationHandler cardAnimationHandler = val.AddComponent<CardAnimationHandler>();
					cardAnimationHandler.ToggleAnimation(value: false);
				}
			}
			GameObject val9 = FindObjectInChildren(val2.gameObject, "Background");
			if ((Object)(object)val9 == (Object)null)
			{
				return;
			}
			val9.transform.localScale = new Vector3(1f, 1f, 1f);
			RectTransform component = val9.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(1500f, 1500f);
			Image imageComponent = val9.gameObject.GetComponentInChildren<Image>(true);
			if ((Object)(object)imageComponent != (Object)null)
			{
				imageComponent.preserveAspect = true;
				((Graphic)imageComponent).color = new Color(0.16f, 0.16f, 0.16f, 1f);
			}
			Mask componentInChildren = val9.gameObject.GetComponentInChildren<Mask>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.showMaskGraphic = true;
			}
			RectTransform orAddComponent = ExtensionMethods.GetOrAddComponent<RectTransform>(val, false);
			((Transform)orAddComponent).localScale = 8f * Vector3.one;
			orAddComponent.anchorMin = Vector2.zero;
			orAddComponent.anchorMax = Vector2.one;
			orAddComponent.offsetMin = Vector2.zero;
			orAddComponent.offsetMax = Vector2.zero;
			orAddComponent.pivot = new Vector2(0.5f, 0.5f);
			Color cardColor = CardChoice.instance.GetCardColor(cardInfo.colorTheme);
			List<Image> list = (from x in val2.GetComponentsInChildren<Image>(true)
				where ((Object)((Component)x).gameObject.transform).name.Contains("FRAME")
				select x).ToList();
			foreach (Image item in list)
			{
				((Graphic)item).color = cardColor;
			}
			Transform child = val2.transform.GetChild(1);
			if ((Object)(object)child != (Object)null)
			{
				TextMeshProUGUI component2 = ((Component)child).GetComponent<TextMeshProUGUI>();
				if ((Object)(object)component2 != (Object)null)
				{
					((TMP_Text)component2).text = cardInfo.cardName.ToUpper();
					((Graphic)component2).color = cardColor;
				}
			}
			if ((int)cardInfo.rarity == 0)
			{
				return;
			}
			Color color = (((int)cardInfo.rarity == 1) ? uncommonColor : rareColor);
			foreach (Image item2 in from triangleObject in FindObjectsInChildren(val2.gameObject, "Triangle")
				select triangleObject.GetComponent<Image>() into imageComponentLoop
				where (Object)(object)imageComponent != (Object)null
				select imageComponentLoop)
			{
				((Graphic)item2).color = color;
			}
		}

		private static IEnumerable<GameObject> FindObjectsInChildren(GameObject gameObject, string gameObjectName)
		{
			Transform[] componentsInChildren = gameObject.GetComponentsInChildren<Transform>(true);
			return (from item in componentsInChildren
				where ((Object)item).name == gameObjectName
				select ((Component)item).gameObject).ToList();
		}

		private static GameObject FindObjectInChildren(GameObject gameObject, string gameObjectName)
		{
			Transform[] componentsInChildren = gameObject.GetComponentsInChildren<Transform>(true);
			return (from item in componentsInChildren
				where ((Object)item).name == gameObjectName
				select ((Component)item).gameObject).FirstOrDefault();
		}

		public static void UpdateVisualsCardObj(GameObject cardObject, bool? cardEnabled = null)
		{
			if (cardEnabled ?? CardManager.cards[((Object)cardObject).name].enabled)
			{
				cardObject.SetActive(true);
				CurveAnimation[] componentsInChildren = cardObject.GetComponentsInChildren<CurveAnimation>();
				foreach (CurveAnimation val in componentsInChildren)
				{
					if (((Component)val).gameObject.activeInHierarchy)
					{
						val.PlayIn();
					}
				}
				return;
			}
			cardObject.SetActive(false);
			CurveAnimation[] componentsInChildren2 = cardObject.GetComponentsInChildren<CurveAnimation>();
			foreach (CurveAnimation val2 in componentsInChildren2)
			{
				if (((Component)val2).gameObject.activeInHierarchy)
				{
					val2.PlayIn();
					val2.PlayOut();
				}
			}
		}

		internal static void RestoreCardToggleVisuals()
		{
			foreach (GameObject key in cardObjs.Keys)
			{
				UpdateVisualsCardObj(key);
			}
		}

		internal void RestoreCardToggleVisuals(string category)
		{
			if (!cardObjectsInCategory.ContainsKey(category))
			{
				return;
			}
			foreach (GameObject key in cardObjs.Keys)
			{
				UpdateVisualsCardObj(key);
			}
		}

		internal void SortCardMenus(bool alph)
		{
			foreach (string category in CardManager.categories)
			{
				Transform source = ScrollViews[category].Find("Viewport/Content");
				List<Transform> list = new List<Transform>();
				list.AddRange(((IEnumerable)source).Cast<Transform>());
				List<Transform> list2 = (alph ? list.OrderBy((Transform t) => ((Object)t).name).ToList() : (from t in list
					orderby CardManager.cards[((Object)t).name].cardInfo.rarity, ((Object)t).name
					select t).ToList());
				int num = 0;
				foreach (Transform item in list2)
				{
					item.SetSiblingIndex(num);
					num++;
				}
			}
		}

		private static void ChangeCardColumnAmountMenus(int amount)
		{
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			Vector2 cellSize = default(Vector2);
			((Vector2)(ref cellSize))..ctor(220f, 300f);
			float num = 1.5f;
			if (amount > 3)
			{
				switch (amount)
				{
				case 4:
					((Vector2)(ref cellSize))..ctor(170f, 240f);
					num = 1.2f;
					break;
				default:
					((Vector2)(ref cellSize))..ctor(136f, 192f);
					num = 0.9f;
					break;
				case 6:
					((Vector2)(ref cellSize))..ctor(112f, 158f);
					num = 0.75f;
					break;
				case 7:
					((Vector2)(ref cellSize))..ctor(97f, 137f);
					num = 0.65f;
					break;
				case 8:
					((Vector2)(ref cellSize))..ctor(85f, 120f);
					num = 0.55f;
					break;
				case 9:
					((Vector2)(ref cellSize))..ctor(75f, 106f);
					num = 0.45f;
					break;
				case 10:
					((Vector2)(ref cellSize))..ctor(68f, 96f);
					num = 0.4f;
					break;
				}
			}
			instance.currentColumnAmount = amount;
			((TMP_Text)cardAmountText).text = "Cards Per Line: " + amount;
			foreach (string category in CardManager.categories)
			{
				Transform val = ScrollViews[category].Find("Viewport/Content");
				GridLayoutGroup component = ((Component)val).gameObject.GetComponent<GridLayoutGroup>();
				component.cellSize = cellSize;
				component.constraintCount = amount;
				((LayoutGroup)component).childAlignment = (TextAnchor)1;
				List<Transform> list = new List<Transform>();
				list.AddRange(((IEnumerable)val).Cast<Transform>());
				foreach (RectTransform item in list.Select((Transform cardTransform) => ExtensionMethods.GetOrAddComponent<RectTransform>(((Component)cardTransform.GetChild(2)).gameObject, false)))
				{
					((Transform)item).localScale = num * Vector3.one * 10f;
				}
			}
		}

		public static void UpdateCardColumnAmountMenus()
		{
			ChangeCardColumnAmountMenus(instance.currentColumnAmount);
		}

		public static void SetActive(Transform trans, bool active)
		{
			if (active)
			{
				Camera component = GameObject.Find("MainCamera").GetComponent<Camera>();
				Canvas component2 = cardMenuCanvas.GetComponent<Canvas>();
				component2.renderMode = (RenderMode)1;
				component2.worldCamera = component;
			}
			if ((Object)(object)((Component)trans).gameObject != (Object)null)
			{
				((Component)trans).gameObject.SetActive(active);
			}
			ExtensionMethods.ExecuteAfterFrames((MonoBehaviour)(object)Unbound.Instance, 1, (Action)delegate
			{
				if (active)
				{
					if (instance.cardVisualsCoroutine != null)
					{
						((MonoBehaviour)Unbound.Instance).StopCoroutine(instance.cardVisualsCoroutine);
					}
					instance.cardVisualsCoroutine = ((MonoBehaviour)Unbound.Instance).StartCoroutine((instance.currentCategory != null) ? instance.EnableCardsInCategory(instance.currentCategory) : instance.EnableCardsInCategory("Vanilla"));
				}
				else
				{
					instance.DisableCardsInCategory(instance.currentCategory ?? "Vanilla");
				}
			});
		}
	}
	internal class MenuCard : MonoBehaviour
	{
		private ScaleShake scaleShake;

		private void Start()
		{
			scaleShake = ((Component)this).GetComponentInChildren<ScaleShake>();
		}

		private void Update()
		{
			if ((Object)(object)scaleShake == (Object)null)
			{
				scaleShake = ((Component)this).GetComponentInChildren<ScaleShake>();
			}
			else if (!(scaleShake.targetScale <= 1f))
			{
				scaleShake.targetScale = 1f;
			}
		}
	}
	internal class CardAnimationHandler : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		private bool toggled;

		public void OnPointerEnter(PointerEventData eventData)
		{
			ToggleAnimation(value: true);
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			ToggleAnimation(value: false);
		}

		public void ToggleAnimation(bool value)
		{
			Animator[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<Animator>();
			foreach (Animator val in componentsInChildren)
			{
				if (((Behaviour)val).enabled != value)
				{
					((Behaviour)val).enabled = value;
				}
			}
			PositionNoise[] componentsInChildren2 = ((Component)this).gameObject.GetComponentsInChildren<PositionNoise>();
			foreach (PositionNoise val2 in componentsInChildren2)
			{
				if (((Behaviour)val2).enabled != value)
				{
					((Behaviour)val2).enabled = value;
				}
			}
			toggled = value;
		}

		private void Update()
		{
			ToggleAnimation(toggled);
		}
	}
	public class MapSelectMenuHandler : MonoBehaviour
	{
		public static MapSelectMenuHandler instance;

		public GameObject mapMenuCanvas;

		internal static readonly Dictionary<string, Transform> ScrollViews = new Dictionary<string, Transform>();

		internal static Transform CategoryContent;

		private Transform scrollViewTrans;

		private GUIStyle guiStyle;

		private GameObject mapObj;

		private GameObject categoryButton;

		private GameObject scrollView;

		private readonly List<string> levelsThatNeedToRedrawn = new List<string>();

		private readonly List<GameObject> categoryObjs = new List<GameObject>();

		public readonly List<GameObject> lvlObjs = new List<GameObject>();

		private bool disabled;

		private bool toggledAll;

		private static TextMeshProUGUI mapAmountText;

		private string CurrentCategory => ScrollViews.Where(delegate(KeyValuePair<string, Transform> scroll)
		{
			KeyValuePair<string, Transform> keyValuePair2 = scroll;
			return ((Component)keyValuePair2.Value).gameObject.activeInHierarchy;
		}).Select(delegate(KeyValuePair<string, Transform> scroll)
		{
			KeyValuePair<string, Transform> keyValuePair = scroll;
			return keyValuePair.Key;
		}).FirstOrDefault();

		public void Start()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			instance = this;
			Camera component = GameObject.Find("MainCamera").GetComponent<Camera>();
			GameObject val = SandboxImprovements.Assets.LoadAsset<GameObject>("MapMenuCanvas");
			mapObj = SandboxImprovements.Assets.LoadAsset<GameObject>("MapObj");
			categoryButton = SandboxImprovements.Assets.LoadAsset<GameObject>("CategoryButton");
			scrollView = SandboxImprovements.Assets.LoadAsset<GameObject>("MapScrollView");
			GUIStyle val2 = new GUIStyle
			{
				fontSize = 100
			};
			val2.normal.textColor = Color.black;
			guiStyle = val2;
			mapMenuCanvas = Object.Instantiate<GameObject>(val);
			Object.DontDestroyOnLoad((Object)(object)mapMenuCanvas);
			Canvas component2 = mapMenuCanvas.GetComponent<Canvas>();
			component2.renderMode = (RenderMode)1;
			component2.worldCamera = component;
			mapMenuCanvas.SetActive(false);
			CategoryContent = mapMenuCanvas.transform.Find("MapMenu/Top/Categories/ButtonsScroll/Viewport/Content");
			scrollViewTrans = mapMenuCanvas.transform.Find("MapMenu/ScrollViews");
			GameObject gameObject = ((Component)mapMenuCanvas.transform.Find("MapMenu/Top/InputField")).gameObject;
			((UnityEvent<string>)(object)gameObject.GetComponent<TMP_InputField>().onValueChanged).AddListener((UnityAction<string>)delegate(string value)
			{
				foreach (Button item in ScrollViews.SelectMany((KeyValuePair<string, Transform> scrollViewPair) => ((Component)scrollViewPair.Value).GetComponentsInChildren<Button>(true)))
				{
					if (value == "")
					{
						((Component)item).gameObject.SetActive(true);
					}
					else
					{
						((Component)item).gameObject.SetActive(((Object)item).name.ToUpper().Contains(value.ToUpper()));
					}
				}
			});
			Transform val3 = mapMenuCanvas.transform.Find("MapMenu/Top/MapAmount");
			mapAmountText = ((Component)val3).GetComponentInChildren<TextMeshProUGUI>();
			Slider[] componentsInChildren = ((Component)val3).GetComponentsInChildren<Slider>();
			Slider[] array = componentsInChildren;
			foreach (Slider val4 in array)
			{
				((UnityEvent<float>)(object)val4.onValueChanged).AddListener((UnityAction<float>)delegate(float amount)
				{
					int amount2 = (int)amount;
					ChangeMapColumnAmountMenus(amount2);
				});
			}
			ExtensionMethods.ExecuteAfterSeconds((MonoBehaviour)(object)this, 0.5f, (Action)delegate
			{
				//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d9: Expected O, but got Unknown
				//IL_0374: Unknown result type (might be due to invalid IL or missing references)
				//IL_037e: Expected O, but got Unknown
				mapMenuCanvas.SetActive(true);
				Type typeFromHandle = typeof(LevelManager);
				FieldInfo field = typeFromHandle.GetField("categories", BindingFlags.Static | BindingFlags.NonPublic);
				List<string> list = (List<string>)field.GetValue(null);
				foreach (string item2 in list)
				{
					GameObject val5 = Object.Instantiate<GameObject>(scrollView, scrollViewTrans);
					val5.SetActive(false);
					((Object)val5).name = item2;
					ScrollViews.Add(item2, val5.transform);
					if (item2 == "Vanilla")
					{
						val5.SetActive(true);
					}
				}
				foreach (KeyValuePair<string, Level> level in LevelManager.levels)
				{
					if (!File.Exists(Path.Combine("./LevelImages", LevelManager.GetVisualName(level.Key) + ".png")))
					{
						levelsThatNeedToRedrawn.Add(level.Key);
					}
					Transform val6 = ScrollViews[level.Value.category].Find("Viewport/Content");
					GameObject val7 = Object.Instantiate<GameObject>(mapObj, val6);
					val7.SetActive(true);
					((Object)val7).name = level.Key;
					((TMP_Text)val7.GetComponentInChildren<TextMeshProUGUI>()).text = LevelManager.GetVisualName(level.Value.name);
					((UnityEvent)val7.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
					{
						if (level.Value.enabled)
						{
							ExtensionMethods.InvokeMethod((object)LevelManager.instance, "SpawnMap", new object[1] { "/" + level.Key });
							mapMenuCanvas.SetActive(false);
							GameObject.Find("Game/UI/UI_Game/Canvas/EscapeMenu").GetComponent<EscapeMenuHandler>().ToggleEsc();
							SandboxImprovements.GetRidOfSandboxTutorial();
						}
					});
					lvlObjs.Add(val7);
					UpdateVisualsLevelObj(val7);
					UpdateImage(val7, Path.Combine("./LevelImages", LevelManager.GetVisualName(level.Key) + ".png"));
				}
				TextMeshProUGUI viewingText = ((Component)mapMenuCanvas.transform.Find("MapMenu/Top/Viewing")).gameObject.GetComponentInChildren<TextMeshProUGUI>();
				List<string> list2 = new string[2] { "Vanilla", "Default physics" }.Concat(list.OrderBy((string c) => c).Except(new string[2] { "Vanilla", "Default physics" })).ToList();
				foreach (string category in list2)
				{
					GameObject categoryObj = Object.Instantiate<GameObject>(categoryButton, CategoryContent);
					categoryObj.SetActive(true);
					((Object)categoryObj).name = category;
					((TMP_Text)categoryObj.GetComponentInChildren<TextMeshProUGUI>()).text = category;
					((UnityEvent)categoryObj.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
					{
						//IL_0108: Unknown result type (might be due to invalid IL or missing references)
						Animator[] componentsInChildren2 = ((Component)CategoryContent).GetComponentsInChildren<Animator>();
						foreach (Animator val8 in componentsInChildren2)
						{
							if (!categoryObj.GetComponentsInChildren<Animator>().Contains(val8))
							{
								val8.SetTrigger("False");
							}
						}
						Animator[] componentsInChildren3 = categoryObj.GetComponentsInChildren<Animator>();
						foreach (Animator val9 in componentsInChildren3)
						{
							val9.SetTrigger("True");
						}
						foreach (KeyValuePair<string, Transform> scrollView in ScrollViews)
						{
							((Component)scrollView.Value).gameObject.SetActive(false);
						}
						categoryObjs.Add(categoryObj);
						((Component)ScrollViews[category]).GetComponent<ScrollRect>().normalizedPosition = new Vector2(0f, 1f);
						((Component)ScrollViews[category]).gameObject.SetActive(true);
						((TMP_Text)viewingText).text = "Viewing: " + category;
					});
					Toggle toggle = categoryObj.GetComponentInChildren<Toggle>();
					((UnityEvent<bool>)(object)toggle.onValueChanged).AddListener((UnityAction<bool>)delegate
					{
						toggle.isOn = LevelManager.IsCategoryActive(category);
					});
					UpdateCategoryVisuals(categoryObj, LevelManager.IsCategoryActive(category));
				}
				mapMenuCanvas.GetComponent<Canvas>().sortingOrder = 256;
				mapMenuCanvas.SetActive(false);
			});
		}

		private void UpdateCategoryVisuals(GameObject categoryObj, bool enabledVisuals)
		{
			foreach (KeyValuePair<string, Transform> item in ScrollViews.Where((KeyValuePair<string, Transform> obj) => obj.Key == ((Object)categoryObj).name))
			{
				((Component)item.Value.Find("Darken")).gameObject.SetActive(!enabledVisuals);
			}
			Toggle componentInChildren = categoryObj.GetComponentInChildren<Toggle>();
			componentInChildren.isOn = enabledVisuals;
		}

		public void UpdateEnabledMaps()
		{
			foreach (GameObject categoryObj in categoryObjs)
			{
				UpdateCategoryVisuals(categoryObj, LevelManager.IsCategoryActive(((Object)categoryObj).name));
			}
			foreach (GameObject lvlObj in lvlObjs)
			{
				UpdateVisualsLevelObj(lvlObj);
			}
		}

		public static void UpdateVisualsLevelObj(GameObject lvlObj)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if (LevelManager.levels.ContainsKey(((Object)lvlObj).name))
			{
				if (LevelManager.levels[((Object)lvlObj).name].enabled)
				{
					lvlObj.SetActive(true);
					((Graphic)((Component)lvlObj.transform.Find("Image")).GetComponent<Image>()).color = Color.white;
					((Graphic)((Component)lvlObj.transform.Find("Background")).GetComponent<Image>()).color = new Color(0.2352941f, 0.2352941f, 0.2352941f, 0.8470588f);
					((Graphic)lvlObj.GetComponentInChildren<TextMeshProUGUI>()).color = new Color(0.5372549f, 0.5372549f, 0.5372549f, 1f);
				}
				else
				{
					lvlObj.SetActive(false);
				}
			}
		}

		private static void UpdateImage(GameObject mapObject, string imagePath)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_005c: 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)
			if (File.Exists(imagePath))
			{
				GameObject gameObject = ((Component)mapObject.transform.Find("Image")).gameObject;
				byte[] array = File.ReadAllBytes(imagePath);
				Texture2D val = new Texture2D(1, 1);
				ImageConversion.LoadImage(val, array);
				gameObject.GetComponent<Image>().sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
		}

		private static void ChangeMapColumnAmountMenus(int amount)
		{
			//IL_001b: 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_0022: 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_010a: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(164f, 112f);
			float num = 4f / (float)amount;
			val *= num;
			((TMP_Text)mapAmountText).text = "Maps Per Line: " + amount;
			Type typeFromHandle = typeof(LevelManager);
			FieldInfo field = typeFromHandle.GetField("categories", BindingFlags.Static | BindingFlags.NonPublic);
			List<string> source = (List<string>)field.GetValue(null);
			foreach (GridLayoutGroup item in from category in source
				select ScrollViews[category].Find("Viewport/Content") into categoryMenu
				where (Object)(object)categoryMenu != (Object)null
				select ((Component)categoryMenu).gameObject.GetComponent<GridLayoutGroup>())
			{
				item.cellSize = val;
				item.constraintCount = amount;
				item.spacing = new Vector2(5f * num, 5f * num);
			}
		}

		public void SetActive(bool active)
		{
			Camera component = GameObject.Find("MainCamera").GetComponent<Camera>();
			Canvas component2 = mapMenuCanvas.GetComponent<Canvas>();
			component2.renderMode = (RenderMode)1;
			component2.worldCamera = component;
		}
	}
	[Serializable]
	public class PlayerActionsAdditionalData
	{
		public PlayerAction hookBattleStart;

		public PlayerAction hookPickStart;

		public PlayerAction hookPickEnd;

		public PlayerAction hookPlayerPickStart;

		public PlayerAction hookPlayerPickEnd;

		public PlayerAction hookPointStart;

		public PlayerAction hookPointEnd;

		public PlayerAction hookRoundStart;

		public PlayerAction hookRoundEnd;

		public PlayerActionsAdditionalData()
		{
			hookBattleStart = null;
			hookPickStart = null;
			hookPickEnd = null;
			hookPlayerPickStart = null;
			hookPlayerPickEnd = null;
			hookPointStart = null;
			hookPointEnd = null;
			hookRoundStart = null;
			hookRoundEnd = null;
		}
	}
	public static class PlayerActionsExtension
	{
		public static readonly ConditionalWeakTable<PlayerActions, PlayerActionsAdditionalData> data = new ConditionalWeakTable<PlayerActions, PlayerActionsAdditionalData>();

		public static PlayerActionsAdditionalData GetAdditionalData(this PlayerActions playerActions)
		{
			return data.GetOrCreateValue(playerActions);
		}

		public static void AddData(this PlayerActions playerActions, PlayerActionsAdditionalData value)
		{
			try
			{
				data.Add(playerActions, value);
			}
			catch (Exception)
			{
			}
		}
	}
	[HarmonyPatch(typeof(PlayerActions))]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPatch(new Type[] { })]
	internal class PlayerActionsPatchPlayerActions
	{
		private static void Postfix(PlayerActions __instance)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Expected O, but got Unknown
			__instance.GetAdditionalData().hookBattleStart = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Sandbox Call Battle Start" });
			__instance.GetAdditionalData().hookPickStart = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Sandbox Call Pick Start" });
			__instance.GetAdditionalData().hookPickEnd = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Sandbox Call Pick End" });
			__instance.GetAdditionalData().hookPlayerPickStart = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Sandbox Call Player Pick Start" });
			__instance.GetAdditionalData().hookPlayerPickEnd = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Sandbox Call Player Pick End" });
			__instance.GetAdditionalData().hookPointStart = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Sandbox Call Point Start" });
			__instance.GetAdditionalData().hookPointEnd = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Sandbox Call Point End" });
			__instance.GetAdditionalData().hookRoundStart = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Sandbox Call Round Start" });
			__instance.GetAdditionalData().hookRoundEnd = (PlayerAction)typeof(PlayerActions).InvokeMember("CreatePlayerAction", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod, null, __instance, new object[1] { "Sandbox Call Round End" });
		}
	}
	[HarmonyPatch(typeof(PlayerActions), "CreateWithKeyboardBindings")]
	internal class PlayerActionsPatchCreateWithKeyboardBindings
	{
		private static void Postfix(ref PlayerActions __result)
		{
			__result.GetAdditionalData().hookBattleStart.AddDefaultBinding((Key[])(object)new Key[1] { (Key)42 });
			__result.GetAdditionalData().hookPickStart.AddDefaultBinding((Key[])(object)new Key[1] { (Key)56 });
			__result.GetAdditionalData().hookPickEnd.AddDefaultBinding((Key[])(object)new Key[1] { (Key)45 });
			__result.GetAdditionalData().hookPlayerPickStart.AddDefaultBinding((Key[])(object)new Key[1] { (Key)60 });
			__result.GetAdditionalData().hookPlayerPickEnd.AddDefaultBinding((Key[])(object)new Key[1] { (Key)43 });
			__result.GetAdditionalData().hookPointStart.AddDefaultBinding((Key[])(object)new Key[1] { (Key)44 });
			__result.GetAdditionalData().hookPointEnd.AddDefaultBinding((Key[])(object)new Key[1] { (Key)46 });
			__result.GetAdditionalData().hookRoundStart.AddDefaultBinding((Key[])(object)new Key[1] { (Key)50 });
			__result.GetAdditionalData().hookRoundEnd.AddDefaultBinding((Key[])(object)new Key[1] { (Key)47 });
		}
	}
	[HarmonyPatch(typeof(GeneralInput), "Update")]
	internal class GeneralInputPatchUpdate
	{
		private static void Postfix(GeneralInput __instance)
		{
			if (GameModeManager.CurrentHandlerID != "Sandbox" || GameObject.Find("Game/UI/UI_Game/Canvas/Console").GetComponent<TMP_InputField>().isFocused)
			{
				return;
			}
			PlayerActionsAdditionalData additionalData = ((Component)__instance).GetComponent<CharacterData>().playerActions.GetAdditionalData();
			if (((OneAxisInputControl)additionalData.hookBattleStart).WasPressed)
			{
				if (SandboxImprovements.Debug)
				{
					Debug.Log((object)"Battle Start");
				}
				((MonoBehaviour)SandboxImprovements.instance).StartCoroutine(GameModeManager.TriggerHook("BattleStart"));
			}
			if (((OneAxisInputControl)additionalData.hookPickStart).WasPressed)
			{
				if (SandboxImprovements.Debug)
				{
					Debug.Log((object)"Pick Start");
				}
				((MonoBehaviour)SandboxImprovements.instance).StartCoroutine(GameModeManager.TriggerHook("PickStart"));
			}
			if (((OneAxisInputControl)additionalData.hookPickEnd).WasPressed)
			{
				if (SandboxImprovements.Debug)
				{
					Debug.Log((object)"Pick End");
				}
				((MonoBehaviour)SandboxImprovements.instance).StartCoroutine(GameModeManager.TriggerHook("PickEnd"));
			}
			if (((OneAxisInputControl)additionalData.hookPlayerPickStart).WasPressed)
			{
				if (SandboxImprovements.Debug)
				{
					Debug.Log((object)"Player Pick Start");
				}
				((MonoBehaviour)SandboxImprovements.instance).StartCoroutine(GameModeManager.TriggerHook("PlayerPickStart"));
			}
			if (((OneAxisInputControl)additionalData.hookPlayerPickEnd).WasPressed)
			{
				if (SandboxImprovements.Debug)
				{
					Debug.Log((object)"Player Pick End");
				}
				((MonoBehaviour)SandboxImprovements.instance).StartCoroutine(GameModeManager.TriggerHook("PlayerPickEnd"));
			}
			if (((OneAxisInputControl)additionalData.hookPointStart).WasPressed)
			{
				if (SandboxImprovements.Debug)
				{
					Debug.Log((object)"Point Start");
				}
				((MonoBehaviour)SandboxImprovements.instance).StartCoroutine(GameModeManager.TriggerHook("PointStart"));
			}
			if (((OneAxisInputControl)additionalData.hookPointEnd).WasPressed)
			{
				if (SandboxImprovements.Debug)
				{
					Debug.Log((object)"Point End");
				}
				((MonoBehaviour)SandboxImprovements.instance).StartCoroutine(GameModeManager.TriggerHook("PointEnd"));
			}
			if (((OneAxisInputControl)additionalData.hookRoundStart).WasPressed)
			{
				if (SandboxImprovements.Debug)
				{
					Debug.Log((object)"Round Start");
				}
				((MonoBehaviour)SandboxImprovements.instance).StartCoroutine(GameModeManager.TriggerHook("RoundStart"));
			}
			if (((OneAxisInputControl)additionalData.hookRoundEnd).WasPressed)
			{
				if (SandboxImprovements.Debug)
				{
					Debug.Log((object)"Round End");
				}
				((MonoBehaviour)SandboxImprovements.instance).StartCoroutine(GameModeManager.TriggerHook("RoundEnd"));
			}
			if (SandboxImprovements.KeyHintText.activeSelf)
			{
				((TMP_Text)((Component)SandboxImprovements.KeyHintText.transform.Find("BattleStart/Key")).GetComponent<TextMeshProUGUI>()).text = ((additionalData.hookBattleStart.Bindings.Count < 1) ? " " : additionalData.hookBattleStart.Bindings[0].Name);
				((TMP_Text)((Component)SandboxImprovements.KeyHintText.transform.Find("Pick/Start")).GetComponent<TextMeshProUGUI>()).text = ((additionalData.hookPickStart.Bindings.Count < 1) ? " " : additionalData.hookPickStart.Bindings[0].Name);
				((TMP_Text)((Component)SandboxImprovements.KeyHintText.transform.Find("Pick/End")).GetComponent<TextMeshProUGUI>()).text = ((additionalData.hookPickEnd.Bindings.Count < 1) ? " " : additionalData.hookPickEnd.Bindings[0].Name);
				((TMP_Text)((Component)SandboxImprovements.KeyHintText.transform.Find("PlayerPick/Start")).GetComponent<TextMeshProUGUI>()).text = ((additionalData.hookPlayerPickStart.Bindings.Count < 1) ? " " : additionalData.hookPlayerPickStart.Bindings[0].Name);
				((TMP_Text)((Component)SandboxImprovements.KeyHintText.transform.Find("PlayerPick/End")).GetComponent<TextMeshProUGUI>()).text = ((additionalData.hookPlayerPickEnd.Bindings.Count < 1) ? " " : additionalData.hookPlayerPickEnd.Bindings[0].Name);
				((TMP_Text)((Component)SandboxImprovements.KeyHintText.transform.Find("Point/Start")).GetComponent<TextMeshProUGUI>()).text = ((additionalData.hookPointStart.Bindings.Count < 1) ? " " : additionalData.hookPointStart.Bindings[0].Name);
				((TMP_Text)((Component)SandboxImprovements.KeyHintText.transform.Find("Point/End")).GetComponent<TextMeshProUGUI>()).text = ((additionalData.hookPointEnd.Bindings.Count < 1) ? " " : additionalData.hookPointEnd.Bindings[0].Name);
				((TMP_Text)((Component)SandboxImprovements.KeyHintText.transform.Find("Round/Start")).GetComponent<TextMeshProUGUI>()).text = ((additionalData.hookRoundStart.Bindings.Count < 1) ? " " : additionalData.hookRoundStart.Bindings[0].Name);
				((TMP_Text)((Component)SandboxImprovements.KeyHintText.transform.Find("Round/End")).GetComponent<TextMeshProUGUI>()).text = ((additionalData.hookRoundEnd.Bindings.Count < 1) ? " " : additionalData.hookRoundEnd.Bindings[0].Name);
			}
		}
	}
}
namespace SandboxImprovements.Patches
{
	[HarmonyPatch(typeof(EscapeMenuHandler))]
	public class EscapeMenuHandlerPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool Update(EscapeMenuHandler __instance)
		{
			if (!Input.GetKeyDown((KeyCode)27))
			{
				return true;
			}
			if (GameModeManager.CurrentHandlerID == "Sandbox")
			{
				SandboxImprovements.GetRidOfSandboxTutorial();
			}
			if (MapSelectMenuHandler.instance.mapMenuCanvas.activeInHierarchy)
			{
				MapSelectMenuHandler.instance.mapMenuCanvas.SetActive(false);
				return false;
			}
			if (CardSpawnMenuHandler.cardMenuCanvas.activeInHierarchy)
			{
				CardSpawnMenuHandler.cardMenuCanvas.SetActive(false);
				return false;
			}
			return true;
		}
	}
}