Decompiled source of MetaMarket v1.2.0

MetaMarket.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using On.RoR2;
using On.RoR2.UI;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Stats;
using RoR2.UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MetaMarket")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MetaMarket")]
[assembly: AssemblyTitle("MetaMarket")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 MetaMarket
{
	public class LoadoutUI : MonoBehaviour
	{
		private bool _isOpen = false;

		private string _currentSurvivorName = null;

		private string _currentSurvivorDisplay = null;

		private bool _savePending = false;

		private GameObject _root;

		private Text _indicatorText;

		private GameObject _lobbyIndicator;

		private Text _levelText;

		private RectTransform _xpBarFillRect;

		private Text _xpText;

		private Text _tokenText;

		private GameObject _xpModeGroup;

		private GameObject _challengeModeGroup;

		private RectTransform _challengeBarFillRect;

		private Text _challengeText;

		private RectTransform _scrollViewRect;

		private RectTransform _warningBannerRect;

		private float _scrollBaseTop;

		private Text _survivorText;

		private Text _costText;

		private GameObject _warningBanner;

		private Text _warningText;

		private Transform _gridParent;

		private Transform _equipmentGridParent;

		private readonly List<ItemIconCell> _cells = new List<ItemIconCell>();

		private readonly List<ItemIconCell> _equipmentCells = new List<ItemIconCell>();

		private GameObject _equipmentHeader;

		private List<(string name, ItemDef def, int tierOrder, string displayName, int baseCost)> _cachedItemEntries;

		private List<(string name, EquipmentDef def, int typeOrder, string displayName, int cost)> _cachedEqEntries;

		private string _cachedSurvivorForEntries;

		private const int ICON_SIZE = 64;

		private const int ICON_PADDING = 6;

		private const float WarningBannerHeight = 36f;

		private void Awake()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			BuildCanvas();
			_root.SetActive(false);
			NetworkUser.onNetworkUserBodyPreferenceChanged += new NetworkUserGenericDelegate(OnBodyPreferenceChanged);
			SceneManager.activeSceneChanged += OnSceneChanged;
		}

		private void OnDestroy()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			NetworkUser.onNetworkUserBodyPreferenceChanged -= new NetworkUserGenericDelegate(OnBodyPreferenceChanged);
			SceneManager.activeSceneChanged -= OnSceneChanged;
		}

		private void OnSceneChanged(Scene prev, Scene next)
		{
			bool flag = ((Scene)(ref next)).name == "lobby";
			if ((Object)(object)_lobbyIndicator != (Object)null)
			{
				_lobbyIndicator.SetActive(flag);
			}
			if (_isOpen && !flag)
			{
				Close();
			}
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			KeyboardShortcut value = Plugin.OpenMenuKey.Value;
			if (((KeyboardShortcut)(ref value)).IsDown())
			{
				Toggle();
			}
			if (_savePending)
			{
				_savePending = false;
				ProgressionManager.Save();
			}
		}

		private void OnBodyPreferenceChanged(NetworkUser user)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser != null && !((Object)(object)user != (Object)(object)firstLocalUser.currentNetworkUser))
			{
				SetSurvivorFromBodyIndex(user.bodyIndexPreference);
			}
		}

		private void SetSurvivorFromBodyIndex(BodyIndex bodyIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_000b: 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)
			if ((int)bodyIndex != -1)
			{
				SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(SurvivorCatalog.GetSurvivorIndexFromBodyIndex(bodyIndex));
				if ((Object)(object)survivorDef != (Object)null)
				{
					SetSurvivorFromDef(survivorDef);
				}
			}
		}

		internal void SetSurvivorFromDef(SurvivorDef def)
		{
			_currentSurvivorName = def.cachedName;
			_currentSurvivorDisplay = (Language.IsTokenInvalid(def.displayNameToken) ? def.cachedName : Language.GetString(def.displayNameToken));
			Plugin.Logger.LogInfo((object)("[MetaMarket] Survivor: " + _currentSurvivorDisplay));
			_cachedItemEntries = null;
			_cachedEqEntries = null;
			if (_isOpen)
			{
				_survivorText.text = "Survivor: " + _currentSurvivorDisplay;
				RefreshGrid();
			}
		}

		private void TryReadSurvivorFromNetworkUser()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (!((Object)(object)((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null) == (Object)null))
			{
				BodyIndex bodyIndexPreference = firstLocalUser.currentNetworkUser.bodyIndexPreference;
				if ((int)bodyIndexPreference != -1)
				{
					SetSurvivorFromBodyIndex(bodyIndexPreference);
				}
			}
		}

		private void TryReadSurvivorFromRun()
		{
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser == null)
			{
				return;
			}
			GameObject cachedMasterObject = firstLocalUser.cachedMasterObject;
			CharacterMaster val = ((cachedMasterObject != null) ? cachedMasterObject.GetComponent<CharacterMaster>() : null);
			if (!((Object)(object)val == (Object)null))
			{
				SurvivorDef val2 = SurvivorCatalog.FindSurvivorDefFromBody(val.bodyPrefab);
				if ((Object)(object)val2 != (Object)null)
				{
					SetSurvivorFromDef(val2);
				}
			}
		}

		public void Toggle()
		{
			//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)
			if (_isOpen)
			{
				Close();
				return;
			}
			Scene activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name == "lobby")
			{
				Open();
			}
		}

		public void Open()
		{
			_isOpen = true;
			RunHooks.SyncUnlockedItemsFromProfile();
			_cachedItemEntries = null;
			_cachedEqEntries = null;
			if (_currentSurvivorName == null)
			{
				TryReadSurvivorFromNetworkUser();
			}
			if (_currentSurvivorName == null)
			{
				TryReadSurvivorFromRun();
			}
			Refresh();
			_root.SetActive(true);
		}

		public void Close()
		{
			_isOpen = false;
			_root.SetActive(false);
		}

		public void Refresh()
		{
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			if (_isOpen)
			{
				ProgressionSaveData data = ProgressionManager.Data;
				bool value = Plugin.UseAchievementTokens.Value;
				GameObject xpModeGroup = _xpModeGroup;
				if (xpModeGroup != null)
				{
					xpModeGroup.SetActive(!value);
				}
				GameObject challengeModeGroup = _challengeModeGroup;
				if (challengeModeGroup != null)
				{
					challengeModeGroup.SetActive(value);
				}
				if (value)
				{
					((Component)_levelText).gameObject.SetActive(false);
					int num = ProgressionManager.CompletedChallengeCount();
					int num2 = ProgressionManager.TotalChallengeCount();
					float num3 = ((num2 > 0) ? Mathf.Clamp01((float)num / (float)num2) : 0f);
					_challengeBarFillRect.anchorMax = new Vector2(num3, 1f);
					_challengeText.text = $"{num} / {num2} logbook challenges completed";
					_tokenText.text = $"Challenge Tokens: {data.AvailableTokens}";
				}
				else
				{
					((Component)_levelText).gameObject.SetActive(true);
					int level = data.Level;
					long num4 = ProgressionManager.CurrentLevelXP();
					long num5 = ProgressionManager.XPForNextLevel(level);
					_levelText.text = $"Level {level}";
					float num6 = ((num5 > 0) ? Mathf.Clamp01((float)num4 / (float)num5) : 1f);
					_xpBarFillRect.anchorMax = new Vector2(num6, 1f);
					_xpText.text = $"{num4:N0} / {num5:N0} XP";
					_tokenText.text = $"Total Tokens: {data.AvailableTokens}";
				}
				_survivorText.text = ((_currentSurvivorDisplay != null) ? ("Survivor: " + _currentSurvivorDisplay) : "Survivor: (open character select first)");
				RefreshGrid();
			}
		}

		private void RebuildEntryCache()
		{
			//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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_004f: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Invalid comparison between Unknown and I4
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			ProgressionSaveData data = ProgressionManager.Data;
			_cachedItemEntries = new List<(string, ItemDef, int, string, int)>(data.UnlockedItems.Count);
			foreach (string unlockedItem in data.UnlockedItems)
			{
				ItemIndex val = ItemCatalog.FindItemIndex(unlockedItem);
				if ((int)val == -1)
				{
					continue;
				}
				ItemDef itemDef = ItemCatalog.GetItemDef(val);
				if (!((Object)(object)itemDef == (Object)null))
				{
					int itemCost = ProgressionManager.GetItemCost(itemDef.tier);
					if (itemCost >= 0)
					{
						int item = TierOrder(itemDef.tier);
						string item2 = (Language.IsTokenInvalid(itemDef.nameToken) ? ((Object)itemDef).name : Language.GetString(itemDef.nameToken));
						_cachedItemEntries.Add((unlockedItem, itemDef, item, item2, itemCost));
					}
				}
			}
			_cachedItemEntries.Sort(delegate((string name, ItemDef def, int tierOrder, string displayName, int baseCost) a, (string name, ItemDef def, int tierOrder, string displayName, int baseCost) b)
			{
				int num = a.tierOrder.CompareTo(b.tierOrder);
				return (num != 0) ? num : string.Compare(a.displayName, b.displayName, StringComparison.OrdinalIgnoreCase);
			});
			_cachedEqEntries = new List<(string, EquipmentDef, int, string, int)>(data.UnlockedEquipment.Count);
			foreach (string item5 in data.UnlockedEquipment)
			{
				EquipmentIndex val2 = EquipmentCatalog.FindEquipmentIndex(item5);
				if ((int)val2 == -1)
				{
					continue;
				}
				EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(val2);
				if (!((Object)(object)equipmentDef == (Object)null))
				{
					int equipmentCost = ProgressionManager.GetEquipmentCost(equipmentDef);
					if (equipmentCost >= 0)
					{
						int item3 = EqOrder(equipmentDef);
						string item4 = (Language.IsTokenInvalid(equipmentDef.nameToken) ? ((Object)equipmentDef).name : Language.GetString(equipmentDef.nameToken));
						_cachedEqEntries.Add((item5, equipmentDef, item3, item4, equipmentCost));
					}
				}
			}
			_cachedEqEntries.Sort(delegate((string name, EquipmentDef def, int typeOrder, string displayName, int cost) a, (string name, EquipmentDef def, int typeOrder, string displayName, int cost) b)
			{
				int num = a.typeOrder.CompareTo(b.typeOrder);
				return (num != 0) ? num : string.Compare(a.displayName, b.displayName, StringComparison.OrdinalIgnoreCase);
			});
			_cachedSurvivorForEntries = _currentSurvivorName;
			static int EqOrder(EquipmentDef d)
			{
				if ((Object)(object)d == (Object)null)
				{
					return 99;
				}
				if (d.isLunar)
				{
					return 2;
				}
				if ((Object)(object)d.passiveBuffDef != (Object)null)
				{
					return 1;
				}
				return 0;
			}
			static int TierOrder(ItemTier t)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Expected I4, but got Unknown
				if (1 == 0)
				{
				}
				int result = (int)t switch
				{
					0 => 0, 
					1 => 1, 
					2 => 2, 
					4 => 3, 
					3 => 4, 
					6 => 5, 
					7 => 6, 
					8 => 7, 
					_ => 99, 
				};
				if (1 == 0)
				{
				}
				return result;
			}
		}

		private void RefreshGrid()
		{
			if (_cachedItemEntries == null || _cachedSurvivorForEntries != _currentSurvivorName)
			{
				RebuildEntryCache();
			}
			foreach (ItemIconCell cell in _cells)
			{
				cell.Root.SetActive(false);
			}
			foreach (ItemIconCell equipmentCell in _equipmentCells)
			{
				equipmentCell.Root.SetActive(false);
			}
			if ((Object)(object)_equipmentHeader != (Object)null)
			{
				_equipmentHeader.SetActive(false);
			}
			_costText.text = "";
			if (_currentSurvivorName == null)
			{
				return;
			}
			CharacterLoadout loadout = ProgressionManager.GetLoadout(_currentSurvivorName);
			int num = 0;
			foreach (var cachedItemEntry in _cachedItemEntries)
			{
				loadout.ItemCounts.TryGetValue(cachedItemEntry.name, out var value);
				ItemIconCell itemIconCell;
				if (num < _cells.Count)
				{
					itemIconCell = _cells[num];
				}
				else
				{
					itemIconCell = CreateIconCell(_gridParent);
					_cells.Add(itemIconCell);
				}
				itemIconCell.Configure(cachedItemEntry.name, cachedItemEntry.def, cachedItemEntry.baseCost, value, OnItemClicked);
				itemIconCell.Root.SetActive(true);
				num++;
			}
			if (_cachedEqEntries.Count > 0)
			{
				_equipmentHeader.SetActive(true);
				int num2 = 0;
				foreach (var cachedEqEntry in _cachedEqEntries)
				{
					bool selected = loadout.EquipmentName == cachedEqEntry.name;
					ItemIconCell itemIconCell2;
					if (num2 < _equipmentCells.Count)
					{
						itemIconCell2 = _equipmentCells[num2];
					}
					else
					{
						itemIconCell2 = CreateIconCell(_equipmentGridParent);
						_equipmentCells.Add(itemIconCell2);
					}
					itemIconCell2.ConfigureEquipment(cachedEqEntry.name, cachedEqEntry.def, cachedEqEntry.cost, selected, OnEquipmentClicked);
					itemIconCell2.Root.SetActive(true);
					num2++;
				}
			}
			UpdateCostLabel();
		}

		private void UpdateSingleItemCell(string itemName, int newCount)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (_cachedItemEntries == null)
			{
				return;
			}
			for (int i = 0; i < _cachedItemEntries.Count; i++)
			{
				if (!(_cachedItemEntries[i].name != itemName))
				{
					if (i < _cells.Count)
					{
						_cells[i].UpdateState(newCount, _cachedItemEntries[i].def.tier);
					}
					break;
				}
			}
			UpdateCostLabel();
		}

		private void UpdateEquipmentCells(string prevEqName, string newEqName)
		{
			if (_cachedEqEntries == null)
			{
				return;
			}
			for (int i = 0; i < _cachedEqEntries.Count; i++)
			{
				string item = _cachedEqEntries[i].name;
				if ((item == prevEqName || item == newEqName) && i < _equipmentCells.Count)
				{
					_equipmentCells[i].UpdateEquipmentSelection(item == newEqName);
				}
			}
			UpdateCostLabel();
		}

		private void OnItemClicked(string itemName, int delta)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if (_currentSurvivorName == null)
			{
				return;
			}
			CharacterLoadout loadout = ProgressionManager.GetLoadout(_currentSurvivorName);
			ProgressionSaveData data = ProgressionManager.Data;
			if (delta == 0)
			{
				ProgressionManager.ResetLoadout(_currentSurvivorName);
				RefreshGrid();
				return;
			}
			loadout.ItemCounts.TryGetValue(itemName, out var value);
			int num3;
			if (delta > 0)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex(itemName));
				int num = ((!((Object)(object)itemDef != (Object)null)) ? 1 : ProgressionManager.CostOfNextCopy(itemDef.tier, value));
				int num2 = ProgressionManager.LoadoutCost(_currentSurvivorName);
				if (num2 + num > data.AvailableTokens)
				{
					Plugin.Logger.LogInfo((object)"[MetaMarket] Not enough tokens.");
					return;
				}
				num3 = value + 1;
				loadout.ItemCounts[itemName] = num3;
			}
			else
			{
				if (value <= 0)
				{
					return;
				}
				num3 = value - 1;
				if (num3 == 0)
				{
					loadout.ItemCounts.Remove(itemName);
				}
				else
				{
					loadout.ItemCounts[itemName] = num3;
				}
			}
			_savePending = true;
			UpdateSingleItemCell(itemName, num3);
		}

		private void OnEquipmentClicked(string eqName, int delta)
		{
			//IL_0056: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (_currentSurvivorName == null || delta == 0)
			{
				return;
			}
			CharacterLoadout loadout = ProgressionManager.GetLoadout(_currentSurvivorName);
			ProgressionSaveData data = ProgressionManager.Data;
			string equipmentName = loadout.EquipmentName;
			if (equipmentName == eqName)
			{
				loadout.EquipmentName = null;
			}
			else
			{
				EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(eqName);
				EquipmentDef def = (((int)val != -1) ? EquipmentCatalog.GetEquipmentDef(val) : null);
				int equipmentCost = ProgressionManager.GetEquipmentCost(def);
				loadout.EquipmentName = null;
				int num = ProgressionManager.LoadoutCost(_currentSurvivorName);
				loadout.EquipmentName = equipmentName;
				if (num + equipmentCost > data.AvailableTokens)
				{
					Plugin.Logger.LogInfo((object)"[MetaMarket] Not enough tokens for equipment.");
					return;
				}
				loadout.EquipmentName = eqName;
			}
			_savePending = true;
			UpdateEquipmentCells(equipmentName, loadout.EquipmentName);
		}

		private void UpdateCostLabel()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (_currentSurvivorName == null)
			{
				_costText.text = "";
				SetWarningBanner(show: false);
				return;
			}
			int num = ProgressionManager.LoadoutCost(_currentSurvivorName);
			int availableTokens = ProgressionManager.Data.AvailableTokens;
			bool flag = num > availableTokens;
			((Graphic)_costText).color = Color.white;
			_costText.text = $"Loadout: {num} / {availableTokens} tokens";
			if (flag && (Object)(object)_warningText != (Object)null)
			{
				_warningText.text = $"! OVER BUDGET by {num - availableTokens} token(s) — starting a run will grant NO items !";
			}
			SetWarningBanner(flag);
		}

		private void SetWarningBanner(bool show)
		{
			//IL_006c: 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)
			if ((Object)(object)_warningBanner == (Object)null)
			{
				return;
			}
			bool activeSelf = _warningBanner.activeSelf;
			if (activeSelf != show)
			{
				_warningBanner.SetActive(show);
				if ((Object)(object)_scrollViewRect != (Object)null)
				{
					float num = (show ? (_scrollBaseTop - 36f) : _scrollBaseTop);
					_scrollViewRect.offsetMax = new Vector2(_scrollViewRect.offsetMax.x, num);
				}
			}
		}

		private static ItemIconCell CreateIconCell(Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_005f: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: 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_029e: Expected O, but got Unknown
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Expected O, but got Unknown
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Expected O, but got Unknown
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("IconCell");
			val.transform.SetParent(parent, false);
			LayoutElement val2 = val.AddComponent<LayoutElement>();
			val2.preferredWidth = 70f;
			val2.preferredHeight = 70f;
			GameObject val3 = new GameObject("Border");
			val3.transform.SetParent(val.transform, false);
			RectTransform val4 = val3.AddComponent<RectTransform>();
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = Vector2.one;
			val4.offsetMin = new Vector2(3f, 3f);
			val4.offsetMax = new Vector2(-3f, -3f);
			Image val5 = val3.AddComponent<Image>();
			((Graphic)val5).color = new Color(0.3f, 0.3f, 0.3f, 1f);
			GameObject val6 = new GameObject("Icon");
			val6.transform.SetParent(val3.transform, false);
			RectTransform val7 = val6.AddComponent<RectTransform>();
			val7.anchorMin = Vector2.zero;
			val7.anchorMax = Vector2.one;
			val7.offsetMin = new Vector2(3f, 3f);
			val7.offsetMax = new Vector2(-3f, -3f);
			Image val8 = val6.AddComponent<Image>();
			val8.preserveAspect = true;
			GameObject val9 = new GameObject("SelectedOverlay");
			val9.transform.SetParent(val3.transform, false);
			RectTransform val10 = val9.AddComponent<RectTransform>();
			val10.anchorMin = Vector2.zero;
			val10.anchorMax = Vector2.one;
			Vector2 offsetMin = (val10.offsetMax = Vector2.zero);
			val10.offsetMin = offsetMin;
			((Graphic)val9.AddComponent<Image>()).color = new Color(0.2f, 0.8f, 0.2f, 0.25f);
			val9.SetActive(false);
			GameObject val11 = new GameObject("CountBadge");
			val11.transform.SetParent(val3.transform, false);
			RectTransform val12 = val11.AddComponent<RectTransform>();
			val12.anchorMin = new Vector2(0f, 1f);
			val12.anchorMax = new Vector2(0f, 1f);
			val12.pivot = new Vector2(0f, 1f);
			val12.sizeDelta = new Vector2(28f, 18f);
			val12.anchoredPosition = Vector2.zero;
			((Graphic)val11.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.75f);
			GameObject val13 = new GameObject("CountText");
			val13.transform.SetParent(val11.transform, false);
			RectTransform val14 = val13.AddComponent<RectTransform>();
			val14.anchorMin = Vector2.zero;
			val14.anchorMax = Vector2.one;
			offsetMin = (val14.offsetMax = Vector2.zero);
			val14.offsetMin = offsetMin;
			Text val15 = val13.AddComponent<Text>();
			val15.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val15.fontSize = 12;
			val15.fontStyle = (FontStyle)1;
			((Graphic)val15).color = Color.white;
			val15.alignment = (TextAnchor)4;
			val11.SetActive(false);
			GameObject val16 = new GameObject("CostBadge");
			val16.transform.SetParent(val3.transform, false);
			RectTransform val17 = val16.AddComponent<RectTransform>();
			val17.anchorMin = new Vector2(1f, 0f);
			val17.anchorMax = new Vector2(1f, 0f);
			val17.pivot = new Vector2(1f, 0f);
			val17.sizeDelta = new Vector2(22f, 16f);
			val17.anchoredPosition = Vector2.zero;
			((Graphic)val16.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.7f);
			GameObject val18 = new GameObject("CostText");
			val18.transform.SetParent(val16.transform, false);
			RectTransform val19 = val18.AddComponent<RectTransform>();
			val19.anchorMin = Vector2.zero;
			val19.anchorMax = Vector2.one;
			offsetMin = (val19.offsetMax = Vector2.zero);
			val19.offsetMin = offsetMin;
			Text val20 = val18.AddComponent<Text>();
			val20.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val20.fontSize = 11;
			val20.fontStyle = (FontStyle)1;
			((Graphic)val20).color = new Color(1f, 0.85f, 0.2f);
			val20.alignment = (TextAnchor)4;
			((Graphic)val.AddComponent<Image>()).color = Color.clear;
			TooltipProvider tooltip = val.AddComponent<TooltipProvider>();
			return new ItemIconCell(val, val5, val8, val9, val11, val15, val20, tooltip);
		}

		private void BuildCanvas()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0045: 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_0062: Expected O, but got Unknown
			//IL_0089: 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_00b7: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Expected O, but got Unknown
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Expected O, but got Unknown
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Expected O, but got Unknown
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Expected O, but got Unknown
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Expected O, but got Unknown
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Expected O, but got Unknown
			//IL_072c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0743: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_079f: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07de: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0802: Unknown result type (might be due to invalid IL or missing references)
			//IL_0812: Unknown result type (might be due to invalid IL or missing references)
			//IL_0819: Expected O, but got Unknown
			//IL_0847: Unknown result type (might be due to invalid IL or missing references)
			//IL_085e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Unknown result type (might be due to invalid IL or missing references)
			//IL_088c: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c9: Expected O, but got Unknown
			//IL_08f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_090c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0923: Unknown result type (might be due to invalid IL or missing references)
			//IL_0928: Unknown result type (might be due to invalid IL or missing references)
			//IL_0929: Unknown result type (might be due to invalid IL or missing references)
			//IL_0931: Unknown result type (might be due to invalid IL or missing references)
			//IL_0954: Unknown result type (might be due to invalid IL or missing references)
			//IL_0989: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09be: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b69: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc6: Expected O, but got Unknown
			//IL_0c00: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c39: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c7f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ccb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0daa: Expected O, but got Unknown
			//IL_0ddc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e12: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e75: Expected O, but got Unknown
			//IL_0e95: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ebf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f00: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f07: Expected O, but got Unknown
			//IL_0f31: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fee: Expected O, but got Unknown
			//IL_1021: Unknown result type (might be due to invalid IL or missing references)
			//IL_1038: Unknown result type (might be due to invalid IL or missing references)
			//IL_1049: Unknown result type (might be due to invalid IL or missing references)
			//IL_1053: Expected O, but got Unknown
			//IL_1095: Unknown result type (might be due to invalid IL or missing references)
			//IL_109c: Expected O, but got Unknown
			//IL_10e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_10fd: Expected O, but got Unknown
			//IL_111d: Unknown result type (might be due to invalid IL or missing references)
			//IL_112a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1141: Unknown result type (might be due to invalid IL or missing references)
			//IL_114e: Unknown result type (might be due to invalid IL or missing references)
			//IL_11a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_11da: Expected O, but got Unknown
			//IL_1204: Unknown result type (might be due to invalid IL or missing references)
			//IL_121b: Unknown result type (might be due to invalid IL or missing references)
			//IL_122c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1236: Expected O, but got Unknown
			//IL_12bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_12e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_12f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1305: Unknown result type (might be due to invalid IL or missing references)
			//IL_1319: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("MetaMarketIndicator");
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas val2 = val.AddComponent<Canvas>();
			val2.renderMode = (RenderMode)0;
			val2.sortingOrder = 99;
			CanvasScaler val3 = val.AddComponent<CanvasScaler>();
			val3.uiScaleMode = (ScaleMode)1;
			val3.referenceResolution = new Vector2(1920f, 1080f);
			val.AddComponent<GraphicRaycaster>();
			GameObject val4 = new GameObject("LobbyIndicator");
			val4.transform.SetParent(val.transform, false);
			RectTransform val5 = val4.AddComponent<RectTransform>();
			val5.anchorMin = new Vector2(0f, 0f);
			val5.anchorMax = new Vector2(0f, 0f);
			val5.pivot = new Vector2(0f, 0f);
			val5.sizeDelta = new Vector2(300f, 28f);
			val5.anchoredPosition = new Vector2(10f, 10f);
			((Graphic)val4.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.55f);
			GameObject val6 = new GameObject("Text");
			val6.transform.SetParent(val4.transform, false);
			RectTransform val7 = val6.AddComponent<RectTransform>();
			val7.anchorMin = Vector2.zero;
			val7.anchorMax = Vector2.one;
			val7.offsetMin = new Vector2(8f, 0f);
			val7.offsetMax = Vector2.zero;
			Text val8 = val6.AddComponent<Text>();
			KeyboardShortcut value = Plugin.OpenMenuKey.Value;
			val8.text = $"[{((KeyboardShortcut)(ref value)).MainKey}] Meta Progression";
			val8.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val8.fontSize = 14;
			val8.fontStyle = (FontStyle)1;
			((Graphic)val8).color = new Color(1f, 0.85f, 0.2f);
			val8.alignment = (TextAnchor)3;
			_indicatorText = val8;
			Plugin.OpenMenuKey.SettingChanged += delegate
			{
				//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_0029: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_indicatorText != (Object)null)
				{
					Text indicatorText = _indicatorText;
					KeyboardShortcut value2 = Plugin.OpenMenuKey.Value;
					indicatorText.text = $"[{((KeyboardShortcut)(ref value2)).MainKey}] Meta Progression";
				}
			};
			_lobbyIndicator = val4;
			_lobbyIndicator.SetActive(false);
			_root = new GameObject("MetaMarketPanel");
			Object.DontDestroyOnLoad((Object)(object)_root);
			Canvas val9 = _root.AddComponent<Canvas>();
			val9.renderMode = (RenderMode)0;
			val9.sortingOrder = 100;
			CanvasScaler val10 = _root.AddComponent<CanvasScaler>();
			val10.uiScaleMode = (ScaleMode)1;
			val10.referenceResolution = new Vector2(1920f, 1080f);
			_root.AddComponent<GraphicRaycaster>();
			GameObject val11 = new GameObject("Panel");
			val11.transform.SetParent(_root.transform, false);
			RectTransform val12 = val11.AddComponent<RectTransform>();
			Vector2 val13 = default(Vector2);
			((Vector2)(ref val13))..ctor(0.5f, 0.5f);
			val12.anchorMax = val13;
			val12.anchorMin = val13;
			val12.sizeDelta = new Vector2(780f, 660f);
			val12.anchoredPosition = new Vector2(150f, 0f);
			((Graphic)val11.AddComponent<Image>()).color = new Color(0.05f, 0.05f, 0.08f, 1f);
			float num = -15f;
			RectTransform val14 = MakeRect(val11.transform, "Header", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(10f, num - 30f), new Vector2(-10f, num));
			HorizontalLayoutGroup val15 = ((Component)val14).gameObject.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)val15).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)val15).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val15).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)val15).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val15).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)val15).spacing = 8f;
			MakeLabel(((Component)val14).transform, "META PROGRESSION", 20, (FontStyle)1, Color.white);
			MakeFlexSpacer(((Component)val14).transform);
			_levelText = MakeLabel(((Component)val14).transform, "Level 1", 18, (FontStyle)1, new Color(1f, 0.85f, 0.2f));
			MakeFlexSpacer(((Component)val14).transform);
			MakeButton(((Component)val14).transform, "✕", 18, new UnityAction(Close));
			num -= 38f;
			_xpModeGroup = new GameObject("XPModeGroup");
			_xpModeGroup.transform.SetParent(val11.transform, false);
			RectTransform val16 = _xpModeGroup.AddComponent<RectTransform>();
			val16.anchorMin = new Vector2(0f, 1f);
			val16.anchorMax = new Vector2(1f, 1f);
			val16.offsetMin = new Vector2(10f, num - 44f);
			val16.offsetMax = new Vector2(-10f, num);
			_xpText = MakeLabel(_xpModeGroup.transform, "0 / 50,000 XP", 13, (FontStyle)0, new Color(0.7f, 0.7f, 0.7f));
			RectTransform component = ((Component)_xpText).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(1f, 1f);
			component.offsetMin = new Vector2(0f, -20f);
			component.offsetMax = Vector2.zero;
			GameObject val17 = new GameObject("XPBarBg");
			val17.transform.SetParent(_xpModeGroup.transform, false);
			RectTransform val18 = val17.AddComponent<RectTransform>();
			val18.anchorMin = new Vector2(0f, 1f);
			val18.anchorMax = new Vector2(1f, 1f);
			val18.offsetMin = new Vector2(0f, -44f);
			val18.offsetMax = new Vector2(0f, -24f);
			((Graphic)val17.AddComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 1f);
			GameObject val19 = new GameObject("Fill");
			val19.transform.SetParent(val17.transform, false);
			_xpBarFillRect = val19.AddComponent<RectTransform>();
			_xpBarFillRect.anchorMin = Vector2.zero;
			_xpBarFillRect.anchorMax = new Vector2(0f, 1f);
			val13 = (_xpBarFillRect.offsetMin = (_xpBarFillRect.offsetMax = Vector2.zero));
			((Graphic)val19.AddComponent<Image>()).color = new Color(0.25f, 0.75f, 0.25f, 1f);
			_challengeModeGroup = new GameObject("ChallengeModeGroup");
			_challengeModeGroup.transform.SetParent(val11.transform, false);
			RectTransform val21 = _challengeModeGroup.AddComponent<RectTransform>();
			val21.anchorMin = new Vector2(0f, 1f);
			val21.anchorMax = new Vector2(1f, 1f);
			val21.offsetMin = new Vector2(10f, num - 44f);
			val21.offsetMax = new Vector2(-10f, num);
			_challengeText = MakeLabel(_challengeModeGroup.transform, "0 / 0 challenges completed", 13, (FontStyle)0, new Color(0.7f, 0.7f, 0.7f));
			RectTransform component2 = ((Component)_challengeText).GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 1f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.offsetMin = new Vector2(0f, -20f);
			component2.offsetMax = Vector2.zero;
			GameObject val22 = new GameObject("ChallengeBarBg");
			val22.transform.SetParent(_challengeModeGroup.transform, false);
			RectTransform val23 = val22.AddComponent<RectTransform>();
			val23.anchorMin = new Vector2(0f, 1f);
			val23.anchorMax = new Vector2(1f, 1f);
			val23.offsetMin = new Vector2(0f, -44f);
			val23.offsetMax = new Vector2(0f, -22f);
			((Graphic)val22.AddComponent<Image>()).color = new Color(0.15f, 0.15f, 0.15f, 1f);
			GameObject val24 = new GameObject("Fill");
			val24.transform.SetParent(val22.transform, false);
			_challengeBarFillRect = val24.AddComponent<RectTransform>();
			_challengeBarFillRect.anchorMin = Vector2.zero;
			_challengeBarFillRect.anchorMax = new Vector2(0f, 1f);
			val13 = (_challengeBarFillRect.offsetMin = (_challengeBarFillRect.offsetMax = Vector2.zero));
			((Graphic)val24.AddComponent<Image>()).color = new Color(0.25f, 0.65f, 0.95f, 1f);
			num -= 50f;
			_tokenText = MakeLabel(val11.transform, "Challenge Tokens: 0", 16, (FontStyle)1, new Color(1f, 0.85f, 0.2f));
			PlaceRect((Component)(object)_tokenText, val11.transform, new Vector2(10f, num - 26f), new Vector2(-10f, num));
			num -= 32f;
			RectTransform val26 = MakeRect(val11.transform, "InfoRow", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(10f, num - 22f), new Vector2(-10f, num));
			HorizontalLayoutGroup val27 = ((Component)val26).gameObject.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)val27).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)val27).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val27).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)val27).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val27).childControlWidth = false;
			_survivorText = MakeLabel(((Component)val26).transform, "Survivor: —", 14, (FontStyle)0, new Color(0.7f, 0.9f, 1f));
			((Component)_survivorText).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
			MakeFlexSpacer(((Component)val26).transform);
			_costText = MakeLabel(((Component)val26).transform, "", 13, (FontStyle)0, Color.white);
			_costText.supportRichText = false;
			_costText.horizontalOverflow = (HorizontalWrapMode)1;
			((Component)_costText).gameObject.AddComponent<LayoutElement>().preferredWidth = 320f;
			_costText.alignment = (TextAnchor)5;
			num -= 28f;
			RectTransform val28 = MakeRect(val11.transform, "Divider", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(10f, num - 2f), new Vector2(-10f, num));
			((Graphic)((Component)val28).gameObject.AddComponent<Image>()).color = new Color(0.3f, 0.3f, 0.4f, 1f);
			num -= 8f;
			_warningBanner = new GameObject("OverBudgetBanner");
			_warningBanner.transform.SetParent(val11.transform, false);
			_warningBannerRect = _warningBanner.AddComponent<RectTransform>();
			_warningBannerRect.anchorMin = new Vector2(0f, 1f);
			_warningBannerRect.anchorMax = new Vector2(1f, 1f);
			_warningBannerRect.offsetMin = new Vector2(0f, num - 36f);
			_warningBannerRect.offsetMax = new Vector2(0f, num);
			Image val29 = _warningBanner.AddComponent<Image>();
			((Graphic)val29).color = new Color(0.55f, 0.05f, 0.05f, 0.95f);
			_warningText = new GameObject("WarningText").AddComponent<Text>();
			((Component)_warningText).transform.SetParent(_warningBanner.transform, false);
			RectTransform component3 = ((Component)_warningText).GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.offsetMin = new Vector2(12f, 2f);
			component3.offsetMax = new Vector2(-12f, -2f);
			_warningText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			_warningText.fontSize = 13;
			_warningText.fontStyle = (FontStyle)1;
			((Graphic)_warningText).color = new Color(1f, 0.9f, 0.9f);
			_warningText.alignment = (TextAnchor)4;
			_warningText.horizontalOverflow = (HorizontalWrapMode)0;
			_warningText.supportRichText = false;
			_warningBanner.SetActive(false);
			_scrollBaseTop = num;
			GameObject val30 = new GameObject("ScrollView");
			val30.transform.SetParent(val11.transform, false);
			_scrollViewRect = val30.AddComponent<RectTransform>();
			_scrollViewRect.anchorMin = new Vector2(0f, 0f);
			_scrollViewRect.anchorMax = new Vector2(1f, 1f);
			_scrollViewRect.offsetMin = new Vector2(5f, 28f);
			_scrollViewRect.offsetMax = new Vector2(-5f, _scrollBaseTop);
			RectTransform scrollViewRect = _scrollViewRect;
			ScrollRect val31 = val30.AddComponent<ScrollRect>();
			val31.horizontal = false;
			val31.vertical = true;
			val31.scrollSensitivity = 40f;
			GameObject val32 = new GameObject("Viewport");
			val32.transform.SetParent(val30.transform, false);
			RectTransform val33 = val32.AddComponent<RectTransform>();
			val33.anchorMin = Vector2.zero;
			val33.anchorMax = Vector2.one;
			val13 = (val33.offsetMin = (val33.offsetMax = Vector2.zero));
			((Graphic)val32.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.01f);
			val32.AddComponent<Mask>().showMaskGraphic = false;
			GameObject val35 = new GameObject("Content");
			val35.transform.SetParent(val32.transform, false);
			RectTransform val36 = val35.AddComponent<RectTransform>();
			val36.anchorMin = new Vector2(0f, 1f);
			val36.anchorMax = new Vector2(1f, 1f);
			val36.pivot = new Vector2(0.5f, 1f);
			val13 = (val36.offsetMin = (val36.offsetMax = Vector2.zero));
			VerticalLayoutGroup val38 = val35.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)val38).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)val38).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val38).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val38).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)val38).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)val38).spacing = 0f;
			ContentSizeFitter val39 = val35.AddComponent<ContentSizeFitter>();
			val39.verticalFit = (FitMode)2;
			val39.horizontalFit = (FitMode)0;
			GameObject val40 = new GameObject("ItemsGrid");
			val40.transform.SetParent(val35.transform, false);
			RectTransform val41 = val40.AddComponent<RectTransform>();
			GridLayoutGroup val42 = val40.AddComponent<GridLayoutGroup>();
			val42.cellSize = new Vector2(70f, 70f);
			val42.spacing = new Vector2(4f, 4f);
			((LayoutGroup)val42).padding = new RectOffset(8, 4, 8, 4);
			val42.constraint = (Constraint)1;
			val42.constraintCount = 10;
			val42.startCorner = (Corner)0;
			val42.startAxis = (Axis)0;
			((LayoutGroup)val42).childAlignment = (TextAnchor)0;
			val40.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			GameObject val43 = new GameObject("EquipmentHeader");
			val43.transform.SetParent(val35.transform, false);
			LayoutElement val44 = val43.AddComponent<LayoutElement>();
			val44.preferredHeight = 28f;
			Image val45 = val43.AddComponent<Image>();
			((Graphic)val45).color = new Color(0.12f, 0.12f, 0.18f, 1f);
			GameObject val46 = new GameObject("Text");
			val46.transform.SetParent(val43.transform, false);
			RectTransform val47 = val46.AddComponent<RectTransform>();
			val47.anchorMin = Vector2.zero;
			val47.anchorMax = Vector2.one;
			val47.offsetMin = new Vector2(10f, 0f);
			val47.offsetMax = Vector2.zero;
			Text val48 = val46.AddComponent<Text>();
			val48.text = "Equipment (You can only pick 1)";
			val48.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val48.fontSize = 12;
			val48.fontStyle = (FontStyle)1;
			((Graphic)val48).color = new Color(0.7f, 0.7f, 0.7f);
			val48.alignment = (TextAnchor)3;
			_equipmentHeader = val43;
			_equipmentHeader.SetActive(false);
			GameObject val49 = new GameObject("EquipmentGrid");
			val49.transform.SetParent(val35.transform, false);
			GridLayoutGroup val50 = val49.AddComponent<GridLayoutGroup>();
			val50.cellSize = new Vector2(70f, 70f);
			val50.spacing = new Vector2(4f, 4f);
			((LayoutGroup)val50).padding = new RectOffset(8, 4, 4, 8);
			val50.constraint = (Constraint)1;
			val50.constraintCount = 10;
			val50.startCorner = (Corner)0;
			val50.startAxis = (Axis)0;
			((LayoutGroup)val50).childAlignment = (TextAnchor)0;
			val49.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			val31.viewport = val33;
			val31.content = val36;
			_gridParent = val40.transform;
			_equipmentGridParent = val49.transform;
			Text val51 = MakeLabel(val11.transform, "Left-click to add  ·  Right-click to remove  ·  Middle-click to reset  ·  Hover for details", 11, (FontStyle)0, new Color(0.45f, 0.45f, 0.45f));
			val51.alignment = (TextAnchor)4;
			PlaceRect((Component)(object)val51, val11.transform, new Vector2(0f, 4f), new Vector2(0f, 22f), (Vector2?)new Vector2(0f, 0f), (Vector2?)new Vector2(1f, 0f));
		}

		private static RectTransform MakeRect(Transform parent, string name, Vector2 anchMin, Vector2 anchMax, Vector2 offMin, Vector2 offMax)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001e: 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_002e: 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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = anchMin;
			val2.anchorMax = anchMax;
			val2.offsetMin = offMin;
			val2.offsetMax = offMax;
			return val2;
		}

		private static Text MakeLabel(Transform parent, string text, int size, FontStyle style, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0039: 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)
			GameObject val = new GameObject("Label");
			val.transform.SetParent(parent, false);
			val.AddComponent<RectTransform>();
			Text val2 = val.AddComponent<Text>();
			val2.text = text;
			val2.fontSize = size;
			val2.fontStyle = style;
			((Graphic)val2).color = color;
			val2.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			val2.supportRichText = false;
			return val2;
		}

		private static void PlaceRect(Component c, Transform parent, Vector2 offMin, Vector2 offMax, Vector2? anchMin = null, Vector2? anchMax = null)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = c.GetComponent<RectTransform>();
			((Transform)component).SetParent(parent, false);
			component.anchorMin = (Vector2)(((??)anchMin) ?? new Vector2(0f, 1f));
			component.anchorMax = (Vector2)(((??)anchMax) ?? new Vector2(1f, 1f));
			component.offsetMin = offMin;
			component.offsetMax = offMax;
		}

		private static Button MakeButton(Transform parent, string label, int fontSize, UnityAction onClick)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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)
			GameObject val = new GameObject("Button");
			val.transform.SetParent(parent, false);
			val.AddComponent<RectTransform>();
			((Graphic)val.AddComponent<Image>()).color = new Color(0.3f, 0.1f, 0.1f, 0.9f);
			Button val2 = val.AddComponent<Button>();
			((UnityEvent)val2.onClick).AddListener(onClick);
			val.AddComponent<LayoutElement>().preferredWidth = 36f;
			Text val3 = MakeLabel(val.transform, label, fontSize, (FontStyle)1, Color.white);
			val3.alignment = (TextAnchor)4;
			RectTransform component = ((Component)val3).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			Vector2 offsetMin = (component.offsetMax = Vector2.zero);
			component.offsetMin = offsetMin;
			return val2;
		}

		private static void MakeFlexSpacer(Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			GameObject val = new GameObject("Spacer");
			val.transform.SetParent(parent, false);
			val.AddComponent<RectTransform>();
			val.AddComponent<LayoutElement>().flexibleWidth = 1f;
		}

		private static Color TierColor(ItemTier tier)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected I4, but got Unknown
			//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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			if (1 == 0)
			{
			}
			Color result = (Color)((int)tier switch
			{
				0 => new Color(0.55f, 0.55f, 0.55f), 
				1 => new Color(0.15f, 0.55f, 0.15f), 
				2 => new Color(0.75f, 0.15f, 0.1f), 
				3 => new Color(0.1f, 0.55f, 0.85f), 
				4 => new Color(0.65f, 0.5f, 0.1f), 
				6 => new Color(0.55f, 0.1f, 0.75f), 
				7 => new Color(0.55f, 0.1f, 0.75f), 
				8 => new Color(0.55f, 0.1f, 0.75f), 
				_ => new Color(0.3f, 0.3f, 0.3f), 
			});
			if (1 == 0)
			{
			}
			return result;
		}
	}
	internal class ItemIconCell : IPointerClickHandler, IEventSystemHandler
	{
		private readonly Image _border;

		private readonly Image _icon;

		private readonly GameObject _selOverlay;

		private readonly GameObject _countBadge;

		private readonly Text _countLabel;

		private readonly Text _costLabel;

		private readonly TooltipProvider _tooltip;

		private string _itemName;

		private int _baseCost;

		private int _count;

		private Action<string, int> _onClick;

		public GameObject Root { get; }

		private static Color TierColor(ItemTier tier)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected I4, but got Unknown
			//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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			if (1 == 0)
			{
			}
			Color result = (Color)((int)tier switch
			{
				0 => new Color(0.55f, 0.55f, 0.55f), 
				1 => new Color(0.15f, 0.55f, 0.15f), 
				2 => new Color(0.75f, 0.15f, 0.1f), 
				3 => new Color(0.1f, 0.55f, 0.85f), 
				4 => new Color(0.65f, 0.5f, 0.1f), 
				6 => new Color(0.55f, 0.1f, 0.75f), 
				7 => new Color(0.55f, 0.1f, 0.75f), 
				8 => new Color(0.55f, 0.1f, 0.75f), 
				_ => new Color(0.3f, 0.3f, 0.3f), 
			});
			if (1 == 0)
			{
			}
			return result;
		}

		public ItemIconCell(GameObject root, Image border, Image icon, GameObject selOverlay, GameObject countBadge, Text countLabel, Text costLabel, TooltipProvider tooltip)
		{
			Root = root;
			_border = border;
			_icon = icon;
			_selOverlay = selOverlay;
			_countBadge = countBadge;
			_countLabel = countLabel;
			_costLabel = costLabel;
			_tooltip = tooltip;
			PointerClickRelay pointerClickRelay = root.AddComponent<PointerClickRelay>();
			pointerClickRelay.Target = this;
		}

		public void ConfigureEquipment(string eqName, EquipmentDef eqDef, int cost, bool selected, Action<string, int> onClick)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			_itemName = eqName;
			_baseCost = cost;
			_count = (selected ? 1 : 0);
			_onClick = onClick;
			_icon.sprite = eqDef.pickupIconSprite;
			((Graphic)_icon).color = (Color)(((Object)(object)_icon.sprite != (Object)null) ? Color.white : new Color(0.3f, 0.3f, 0.3f));
			((Graphic)_border).color = (eqDef.isLunar ? new Color(0.1f, 0.55f, 0.85f) : (((Object)(object)eqDef.passiveBuffDef != (Object)null) ? new Color(0.75f, 0.3f, 0f) : new Color(0.55f, 0.55f, 0.55f)));
			_costLabel.text = $"{cost}T";
			_countBadge.SetActive(false);
			_selOverlay.SetActive(selected);
			string overrideTitleText = (Language.IsTokenInvalid(eqDef.nameToken) ? ((Object)eqDef).name : Language.GetString(eqDef.nameToken));
			string overrideBodyText = (Language.IsTokenInvalid(eqDef.descriptionToken) ? "" : Language.GetString(eqDef.descriptionToken));
			_tooltip.overrideTitleText = overrideTitleText;
			_tooltip.overrideBodyText = overrideBodyText;
			_tooltip.titleColor = ((Graphic)_border).color;
			_tooltip.bodyColor = Color.white;
		}

		public void Configure(string itemName, ItemDef itemDef, int baseCost, int count, Action<string, int> onClick)
		{
			//IL_0060: 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)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			_itemName = itemName;
			_baseCost = baseCost;
			_count = count;
			_onClick = onClick;
			_icon.sprite = itemDef.pickupIconSprite;
			((Graphic)_icon).color = (Color)(((Object)(object)_icon.sprite != (Object)null) ? Color.white : new Color(0.3f, 0.3f, 0.3f));
			((Graphic)_border).color = TierColor(itemDef.tier);
			int num = ProgressionManager.CostOfNextCopy(itemDef.tier, count);
			_costLabel.text = $"{num}T";
			if (count > 0)
			{
				_countLabel.text = $"x{count}";
				_countBadge.SetActive(true);
				_selOverlay.SetActive(true);
			}
			else
			{
				_countBadge.SetActive(false);
				_selOverlay.SetActive(false);
			}
			string overrideTitleText = (Language.IsTokenInvalid(itemDef.nameToken) ? ((Object)itemDef).name : Language.GetString(itemDef.nameToken));
			string overrideBodyText = (Language.IsTokenInvalid(itemDef.descriptionToken) ? "" : Language.GetString(itemDef.descriptionToken));
			_tooltip.overrideTitleText = overrideTitleText;
			_tooltip.overrideBodyText = overrideBodyText;
			_tooltip.titleColor = TierColor(itemDef.tier);
			_tooltip.bodyColor = Color.white;
		}

		public void UpdateState(int count, ItemTier tier)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			_count = count;
			int num = ProgressionManager.CostOfNextCopy(tier, count);
			_costLabel.text = $"{num}T";
			if (count > 0)
			{
				_countLabel.text = $"x{count}";
				_countBadge.SetActive(true);
				_selOverlay.SetActive(true);
			}
			else
			{
				_countBadge.SetActive(false);
				_selOverlay.SetActive(false);
			}
		}

		public void UpdateEquipmentSelection(bool selected)
		{
			_count = (selected ? 1 : 0);
			_selOverlay.SetActive(selected);
		}

		public void OnPointerClick(PointerEventData eventData)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Invalid comparison between Unknown and I4
			if ((int)eventData.button == 0)
			{
				_onClick?.Invoke(_itemName, 1);
			}
			else if ((int)eventData.button == 1)
			{
				_onClick?.Invoke(_itemName, -1);
			}
			else if ((int)eventData.button == 2)
			{
				_onClick?.Invoke(_itemName, 0);
			}
		}
	}
	internal class PointerClickRelay : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
	{
		public ItemIconCell Target;

		public void OnPointerClick(PointerEventData eventData)
		{
			Target?.OnPointerClick(eventData);
		}
	}
	[BepInPlugin("com.asgavin.metamarket", "MetaMarket", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		internal static LoadoutUI UI { get; private set; }

		internal static string PluginDirectory { get; private set; }

		internal static ConfigEntry<KeyboardShortcut> OpenMenuKey { get; private set; }

		internal static ConfigEntry<bool> UseAchievementTokens { get; private set; }

		internal static ConfigEntry<bool> GoldDiminishingReturns { get; private set; }

		internal static ConfigEntry<bool> DamageDiminishingReturns { get; private set; }

		internal static ConfigEntry<int> XPBase { get; private set; }

		internal static ConfigEntry<int> XPPerLevel { get; private set; }

		internal static ConfigEntry<int> XPMultiplier { get; private set; }

		internal static ConfigEntry<int> CostTier1 { get; private set; }

		internal static ConfigEntry<int> CostTier2 { get; private set; }

		internal static ConfigEntry<int> CostTier3 { get; private set; }

		internal static ConfigEntry<int> CostLunar { get; private set; }

		internal static ConfigEntry<int> CostBoss { get; private set; }

		internal static ConfigEntry<int> CostVoidTier1 { get; private set; }

		internal static ConfigEntry<int> CostVoidTier2 { get; private set; }

		internal static ConfigEntry<int> CostVoidTier3 { get; private set; }

		internal static ConfigEntry<int> CostEquipmentRegular { get; private set; }

		internal static ConfigEntry<int> CostEquipmentLunar { get; private set; }

		internal static ConfigEntry<int> CostEquipmentElite { get; private set; }

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Expected O, but got Unknown
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Expected O, but got Unknown
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Expected O, but got Unknown
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Expected O, but got Unknown
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Expected O, but got Unknown
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Expected O, but got Unknown
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Expected O, but got Unknown
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Expected O, but got Unknown
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Expected O, but got Unknown
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Expected O, but got Unknown
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Expected O, but got Unknown
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Expected O, but got Unknown
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Expected O, but got Unknown
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Expected O, but got Unknown
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Expected O, but got Unknown
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Expected O, but got Unknown
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Expected O, but got Unknown
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Expected O, but got Unknown
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Expected O, but got Unknown
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Expected O, but got Unknown
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Expected O, but got Unknown
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Expected O, but got Unknown
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Expected O, but got Unknown
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Expected O, but got Unknown
			//IL_049a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Expected O, but got Unknown
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Expected O, but got Unknown
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Expected O, but got Unknown
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			OpenMenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Open Loadout Menu", new KeyboardShortcut((KeyCode)109, Array.Empty<KeyCode>()), "Key to open/close the Meta Progression loadout panel.");
			UseAchievementTokens = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Challenge Tokens", false, "When enabled, the XP and level-up system is bypassed entirely. Your available tokens equal the number of logbook challenges you have completed. Completing a new logbook challenge immediately grants one additional token.");
			GoldDiminishingReturns = ((BaseUnityPlugin)this).Config.Bind<bool>("XP", "Gold Diminishing Returns", true, "When enabled, gold score above 100,000 is counted at 1% (0.01x). Prevents millions of gold from dwarfing all other score contributions.");
			DamageDiminishingReturns = ((BaseUnityPlugin)this).Config.Bind<bool>("XP", "Damage Diminishing Returns", true, "When enabled, highest single-hit damage score above 100,000 follows the same log10 curve as gold, preventing a single massive hit from dwarfing all other contributions.");
			XPBase = ((BaseUnityPlugin)this).Config.Bind<int>("XP", "Base XP Per Level", 50000, "XP required to reach level 2. Every level after that costs this amount plus (level - 1) x Increment.");
			XPPerLevel = ((BaseUnityPlugin)this).Config.Bind<int>("XP", "XP Per Level Increment", 10000, "How much extra XP each level costs compared to the previous one. Set to 0 for a flat cost every level.");
			if (XPPerLevel.Value == 100)
			{
				XPPerLevel.Value = ((((ConfigEntryBase)XPPerLevel).DefaultValue is int num) ? num : 10000);
			}
			XPMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("XP", "XP Multiplier", 100, new ConfigDescription("Percentage of XP earned at the end of a run. 100 = normal, 200 = double, 50 = half.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 10000), Array.Empty<object>()));
			CostTier1 = ((BaseUnityPlugin)this).Config.Bind<int>("Item Costs", "Tier 1 (White)", 1, new ConfigDescription("How many tokens a white item costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			CostTier2 = ((BaseUnityPlugin)this).Config.Bind<int>("Item Costs", "Tier 2 (Green)", 2, new ConfigDescription("How many tokens a green item costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			CostTier3 = ((BaseUnityPlugin)this).Config.Bind<int>("Item Costs", "Tier 3 (Red)", 4, new ConfigDescription("How many tokens a red item costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			CostLunar = ((BaseUnityPlugin)this).Config.Bind<int>("Item Costs", "Lunar", 5, new ConfigDescription("How many tokens a lunar item costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			CostBoss = ((BaseUnityPlugin)this).Config.Bind<int>("Item Costs", "Boss (Yellow)", 5, new ConfigDescription("How many tokens a yellow/boss item costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			CostVoidTier1 = ((BaseUnityPlugin)this).Config.Bind<int>("Item Costs", "Void Tier 1", 2, new ConfigDescription("How many tokens a void white item costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			CostVoidTier2 = ((BaseUnityPlugin)this).Config.Bind<int>("Item Costs", "Void Tier 2", 3, new ConfigDescription("How many tokens a void green item costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			CostVoidTier3 = ((BaseUnityPlugin)this).Config.Bind<int>("Item Costs", "Void Tier 3", 5, new ConfigDescription("How many tokens a void red item costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			CostEquipmentRegular = ((BaseUnityPlugin)this).Config.Bind<int>("Equipment Costs", "Regular Equipment", 3, new ConfigDescription("How many tokens a regular equipment item costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			CostEquipmentLunar = ((BaseUnityPlugin)this).Config.Bind<int>("Equipment Costs", "Lunar Equipment", 5, new ConfigDescription("How many tokens a lunar equipment item costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			CostEquipmentElite = ((BaseUnityPlugin)this).Config.Bind<int>("Equipment Costs", "Elite Equipment", 6, new ConfigDescription("How many tokens an elite equipment item (one with a passive buff) costs in the loadout.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(OpenMenuKey));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(UseAchievementTokens));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(GoldDiminishingReturns));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(DamageDiminishingReturns));
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(XPBase));
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(XPPerLevel));
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(XPMultiplier));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostTier1));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostTier2));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostTier3));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostLunar));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostBoss));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostVoidTier1));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostVoidTier2));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostVoidTier3));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostEquipmentRegular));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostEquipmentLunar));
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(CostEquipmentElite));
			ModSettingsManager.SetModDescription("Meta Progression loadout settings.");
			Logger.LogInfo((object)"[MetaMarket] Risk of Options registered.");
			RunHooks.Init();
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ProgressionManager.PruneAfterCatalogReady));
			GameObject val = new GameObject("MetaMarketUIHost");
			Object.DontDestroyOnLoad((Object)(object)val);
			UI = val.AddComponent<LoadoutUI>();
			Logger.LogInfo((object)"MetaMarket loaded.");
		}

		private void OnDestroy()
		{
			RunHooks.Cleanup();
		}
	}
	[Serializable]
	public class CharacterLoadout
	{
		public Dictionary<string, int> ItemCounts { get; set; } = new Dictionary<string, int>();

		public string EquipmentName { get; set; } = null;
	}
	[Serializable]
	public class ProgressionSaveData
	{
		public long TotalXP { get; set; } = 0L;

		public int Level { get; set; } = 1;

		public int AvailableTokens { get; set; } = 0;

		public HashSet<string> UnlockedItems { get; set; } = new HashSet<string>();

		public HashSet<string> UnlockedEquipment { get; set; } = new HashSet<string>();

		public Dictionary<string, CharacterLoadout> CharacterLoadouts { get; set; } = new Dictionary<string, CharacterLoadout>();
	}
	public static class ProgressionManager
	{
		private static readonly HashSet<string> BlacklistedItems = new HashSet<string> { "ArtifactKey", "PowerPyramid", "BossHunterConsumed", "MasterBattery", "MasterCore", "ScrapYellow", "ScrapWhite", "ScrapGreen", "ScrapRed" };

		private static readonly string[] QualityKeywords = new string[4] { "Uncommon", "Rare", "Epic", "Legendary" };

		private static bool _loaded = false;

		private static string SaveDirectory
		{
			get
			{
				string text = Path.Combine(Paths.ConfigPath, "MetaMarketSaves");
				Directory.CreateDirectory(text);
				return text;
			}
		}

		private static string SavePath => Path.Combine(SaveDirectory, "MetaMarket_" + GetProfileName() + ".json");

		private static string LegacySavePath
		{
			get
			{
				string path = Path.Combine(Plugin.PluginDirectory, "Saves");
				return Path.Combine(path, "MetaMarket_" + GetProfileName() + ".json");
			}
		}

		public static ProgressionSaveData Data { get; private set; } = new ProgressionSaveData();

		public static bool IsBlacklisted(string itemDefName)
		{
			if (BlacklistedItems.Contains(itemDefName))
			{
				return true;
			}
			string[] qualityKeywords = QualityKeywords;
			foreach (string text in qualityKeywords)
			{
				int num = itemDefName.IndexOf(text, StringComparison.Ordinal);
				if (num >= 0)
				{
					string item = itemDefName.Remove(num, text.Length);
					if (BlacklistedItems.Contains(item))
					{
						return true;
					}
				}
			}
			return false;
		}

		private static string GetProfileName()
		{
			try
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				UserProfile val = ((firstLocalUser != null) ? firstLocalUser.userProfile : null);
				if (val != null && !string.IsNullOrEmpty(val.fileName))
				{
					return val.fileName;
				}
			}
			catch
			{
			}
			return "default";
		}

		public static long XPForNextLevel(int currentLevel)
		{
			return Plugin.XPBase.Value + (long)(currentLevel - 1) * (long)Plugin.XPPerLevel.Value;
		}

		public static long TotalXPForLevel(int level)
		{
			long num = 0L;
			for (int i = 1; i < level; i++)
			{
				num += XPForNextLevel(i);
			}
			return num;
		}

		public static void AddXP(long xpGained)
		{
			Data.TotalXP += xpGained;
			bool flag = true;
			while (flag)
			{
				long num = XPForNextLevel(Data.Level);
				long num2 = Data.TotalXP - TotalXPForLevel(Data.Level);
				if (num2 >= num)
				{
					Data.Level++;
					Data.AvailableTokens++;
					Plugin.Logger.LogInfo((object)$"[MetaMarket] Leveled up to {Data.Level}! Tokens: {Data.AvailableTokens}");
				}
				else
				{
					flag = false;
				}
			}
			Save();
		}

		public static void RecalculateTokensFromXP()
		{
			Data.Level = 1;
			while (true)
			{
				long num = XPForNextLevel(Data.Level);
				long num2 = Data.TotalXP - TotalXPForLevel(Data.Level);
				if (num2 >= num)
				{
					Data.Level++;
					continue;
				}
				break;
			}
			Data.AvailableTokens = Data.Level - 1;
			Plugin.Logger.LogInfo((object)$"[MetaMarket] RecalculateTokensFromXP: TotalXP={Data.TotalXP}, Level={Data.Level}, Tokens={Data.AvailableTokens}");
			Save();
		}

		public static void SyncChallengeTokens()
		{
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			UserProfile val = ((firstLocalUser != null) ? firstLocalUser.userProfile : null);
			if (val == null)
			{
				return;
			}
			int num = 0;
			foreach (string achievementIdentifier in AchievementManager.achievementIdentifiers)
			{
				if (val.HasAchievement(achievementIdentifier))
				{
					num++;
				}
			}
			Plugin.Logger.LogInfo((object)$"[MetaMarket] SyncChallengeTokens: {num} challenges completed → {num} tokens");
			Data.AvailableTokens = num;
			Save();
		}

		public static int TotalChallengeCount()
		{
			return AchievementManager.achievementIdentifiers?.Count ?? 0;
		}

		public static int CompletedChallengeCount()
		{
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			UserProfile val = ((firstLocalUser != null) ? firstLocalUser.userProfile : null);
			if (val == null)
			{
				return 0;
			}
			int num = 0;
			foreach (string achievementIdentifier in AchievementManager.achievementIdentifiers)
			{
				if (val.HasAchievement(achievementIdentifier))
				{
					num++;
				}
			}
			return num;
		}

		public static long CurrentLevelXP()
		{
			return Data.TotalXP - TotalXPForLevel(Data.Level);
		}

		public static CharacterLoadout GetLoadout(string survivorName)
		{
			if (!Data.CharacterLoadouts.ContainsKey(survivorName))
			{
				Data.CharacterLoadouts[survivorName] = new CharacterLoadout();
			}
			return Data.CharacterLoadouts[survivorName];
		}

		public static int GetItemCost(ItemTier tier)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected I4, but got Unknown
			if (1 == 0)
			{
			}
			int result = (int)tier switch
			{
				0 => Plugin.CostTier1.Value, 
				1 => Plugin.CostTier2.Value, 
				2 => Plugin.CostTier3.Value, 
				3 => Plugin.CostLunar.Value, 
				4 => Plugin.CostBoss.Value, 
				6 => Plugin.CostVoidTier1.Value, 
				7 => Plugin.CostVoidTier2.Value, 
				8 => Plugin.CostVoidTier3.Value, 
				_ => -1, 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		public static int GetEquipmentCost(EquipmentDef def)
		{
			if ((Object)(object)def == (Object)null)
			{
				return -1;
			}
			if (def.isLunar)
			{
				return Plugin.CostEquipmentLunar.Value;
			}
			if ((Object)(object)def.passiveBuffDef != (Object)null)
			{
				return Plugin.CostEquipmentElite.Value;
			}
			return Plugin.CostEquipmentRegular.Value;
		}

		public static int CostOfNextCopy(ItemTier tier, int currentCount)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			int itemCost = GetItemCost(tier);
			if (itemCost < 0)
			{
				return -1;
			}
			return itemCost + currentCount;
		}

		public static int LoadoutCost(string survivorName)
		{
			//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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between Unknown and I4
			//IL_0055: 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_00e2: 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_00e7: Invalid comparison between Unknown and I4
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			CharacterLoadout loadout = GetLoadout(survivorName);
			int num = 0;
			foreach (KeyValuePair<string, int> itemCount in loadout.ItemCounts)
			{
				if (itemCount.Value <= 0)
				{
					continue;
				}
				ItemIndex val = ItemCatalog.FindItemIndex(itemCount.Key);
				if ((int)val == -1)
				{
					continue;
				}
				ItemDef itemDef = ItemCatalog.GetItemDef(val);
				if (!((Object)(object)itemDef == (Object)null))
				{
					int itemCost = GetItemCost(itemDef.tier);
					if (itemCost >= 0)
					{
						int value = itemCount.Value;
						num += value * itemCost + value * (value - 1) / 2;
					}
				}
			}
			if (!string.IsNullOrEmpty(loadout.EquipmentName))
			{
				EquipmentIndex val2 = EquipmentCatalog.FindEquipmentIndex(loadout.EquipmentName);
				if ((int)val2 != -1)
				{
					EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(val2);
					int equipmentCost = GetEquipmentCost(equipmentDef);
					if (equipmentCost > 0)
					{
						num += equipmentCost;
					}
				}
			}
			return num;
		}

		public static void ResetLoadout(string survivorName)
		{
			CharacterLoadout loadout = GetLoadout(survivorName);
			loadout.ItemCounts.Clear();
			loadout.EquipmentName = null;
			Save();
		}

		public static void UnlockItem(string itemDefName)
		{
			if (Data.UnlockedItems.Add(itemDefName))
			{
				Save();
			}
		}

		public static void UnlockEquipment(string equipmentDefName)
		{
			if (Data.UnlockedEquipment.Add(equipmentDefName))
			{
				Save();
			}
		}

		private static void PruneStaleItems()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Invalid comparison between Unknown and I4
			List<string> list = new List<string>();
			foreach (string unlockedItem in Data.UnlockedItems)
			{
				if ((int)ItemCatalog.FindItemIndex(unlockedItem) == -1 || IsBlacklisted(unlockedItem))
				{
					list.Add(unlockedItem);
				}
			}
			foreach (string item in list)
			{
				Data.UnlockedItems.Remove(item);
				Plugin.Logger.LogWarning((object)("[MetaMarket] Pruned stale item: " + item));
				foreach (CharacterLoadout value in Data.CharacterLoadouts.Values)
				{
					value.ItemCounts.Remove(item);
				}
			}
			List<string> list2 = new List<string>();
			foreach (string item2 in Data.UnlockedEquipment)
			{
				if ((int)EquipmentCatalog.FindEquipmentIndex(item2) == -1 || IsBlacklisted(item2))
				{
					list2.Add(item2);
				}
			}
			foreach (string item3 in list2)
			{
				Data.UnlockedEquipment.Remove(item3);
				Plugin.Logger.LogWarning((object)("[MetaMarket] Pruned stale equipment: " + item3));
				foreach (CharacterLoadout value2 in Data.CharacterLoadouts.Values)
				{
					if (value2.EquipmentName == item3)
					{
						value2.EquipmentName = null;
					}
				}
			}
			if (list.Count > 0 || list2.Count > 0)
			{
				Save();
			}
		}

		public static void Load()
		{
			if (GetProfileName() == "default")
			{
				Plugin.Logger.LogInfo((object)"[MetaMarket] Load() called before profile is ready — deferring.");
				_loaded = false;
				return;
			}
			_loaded = false;
			try
			{
				if (!File.Exists(SavePath))
				{
					string legacySavePath = LegacySavePath;
					if (File.Exists(legacySavePath))
					{
						File.Move(legacySavePath, SavePath);
						Plugin.Logger.LogInfo((object)("[MetaMarket] Migrated save from legacy path: " + legacySavePath));
					}
				}
				if (File.Exists(SavePath))
				{
					string text = File.ReadAllText(SavePath);
					Data = JsonConvert.DeserializeObject<ProgressionSaveData>(text) ?? new ProgressionSaveData();
					Plugin.Logger.LogInfo((object)$"[MetaMarket] Loaded. Level: {Data.Level}, XP: {Data.TotalXP}, Tokens: {Data.AvailableTokens}");
				}
				else
				{
					Data = new ProgressionSaveData();
					Plugin.Logger.LogInfo((object)"[MetaMarket] No save found, starting fresh.");
				}
				_loaded = true;
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("[MetaMarket] Failed to load save: " + ex.Message));
				Data = new ProgressionSaveData();
			}
		}

		public static void PruneAfterCatalogReady()
		{
			PruneStaleItems();
		}

		public static void Save()
		{
			if (!_loaded)
			{
				Plugin.Logger.LogWarning((object)"[MetaMarket] Save() called before Load() completed with a valid profile — skipping to avoid overwriting real save data.");
				return;
			}
			try
			{
				string contents = JsonConvert.SerializeObject((object)Data, (Formatting)1);
				File.WriteAllText(SavePath, contents);
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)("[MetaMarket] Failed to save: " + ex.Message));
			}
		}
	}
	public static class RunHooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Action<Run> <0>__OnRunStart;

			public static hook_Generate <1>__OnRunReportGenerate;

			public static hook_OnEnable <2>__OnCharacterSelectEnabled;

			public static hook_OnDisable <3>__OnCharacterSelectDisabled;

			public static Action <4>__OnLocalUsersUpdated;
		}

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

			public static UnityAction <>9__6_0;

			internal void <InjectLobbyButton>b__6_0()
			{
				Plugin.UI?.Toggle();
			}
		}

		private static GameObject _lobbyButton;

		private static readonly string[] DisplayedStats = new string[13]
		{
			"totalTimeAlive", "totalKills", "totalMinionKills", "totalDeaths", "totalDamageDealt", "totalMinionDamageDealt", "highestDamageDealt", "totalDamageTaken", "highestLevel", "totalGoldCollected",
			"totalItemsCollected", "totalStagesCompleted", "totalPurchases"
		};

		public static void Init()
		{
			//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_003d: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			Run.onRunStartGlobal += OnRunStart;
			object obj = <>O.<1>__OnRunReportGenerate;
			if (obj == null)
			{
				hook_Generate val = OnRunReportGenerate;
				<>O.<1>__OnRunReportGenerate = val;
				obj = (object)val;
			}
			RunReport.Generate += (hook_Generate)obj;
			object obj2 = <>O.<2>__OnCharacterSelectEnabled;
			if (obj2 == null)
			{
				hook_OnEnable val2 = OnCharacterSelectEnabled;
				<>O.<2>__OnCharacterSelectEnabled = val2;
				obj2 = (object)val2;
			}
			CharacterSelectController.OnEnable += (hook_OnEnable)obj2;
			object obj3 = <>O.<3>__OnCharacterSelectDisabled;
			if (obj3 == null)
			{
				hook_OnDisable val3 = OnCharacterSelectDisabled;
				<>O.<3>__OnCharacterSelectDisabled = val3;
				obj3 = (object)val3;
			}
			CharacterSelectController.OnDisable += (hook_OnDisable)ob