Decompiled source of KingKombatArena v1.4.2

KingKombatArena.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.AI;
using EntityStates.AI.Walker;
using EntityStates.Bandit2;
using EntityStates.CaptainDefenseMatrixItem;
using EntityStates.CaptainSupplyDrop;
using EntityStates.Loader;
using EntityStates.Treebot.Weapon;
using EntityStates.VagrantNovaItem;
using EntityStates.VoidSurvivor.Weapon;
using HG;
using IL.EntityStates.CaptainDefenseMatrixItem;
using IL.RoR2;
using IL.RoR2.Items;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using NS_KingKombatArena;
using NS_KingModUtilities;
using On.EntityStates.AI;
using On.EntityStates.AI.Walker;
using On.EntityStates.Bandit2;
using On.EntityStates.CaptainSupplyDrop;
using On.EntityStates.Loader;
using On.EntityStates.Treebot.Weapon;
using On.EntityStates.VagrantNovaItem;
using On.EntityStates.VoidSurvivor.Weapon;
using On.RoR2;
using On.RoR2.CharacterAI;
using On.RoR2.Items;
using On.RoR2.Navigation;
using On.RoR2.Orbs;
using On.RoR2.Projectile;
using On.RoR2.Skills;
using On.RoR2.Stats;
using On.RoR2.UI;
using On.RoR2.UI.MainMenu;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Items;
using RoR2.Navigation;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using RoR2.UI.MainMenu;
using TMPro;
using Unity;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;
using UnityEngine.Video;

[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KingKombatArena")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyProduct("KingKombatArena")]
[assembly: AssemblyTitle("KingKombatArena")]
[assembly: AssemblyInformationalVersion("1.0.0+a299dfd1c7c4e425b930012dad449c11a97e6498")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NS_KingKombatArena
{
	public static class Bans
	{
		public const int MINIMUM_ITEMS = 3;

		public static List<string> GetBannedTraitsList()
		{
			List<string> list = new List<string>();
			string[] array = Configuration.BannedTraits.Value.Split(',');
			foreach (string item in array)
			{
				list.Add(item);
			}
			return list;
		}

		public static bool IsTraitBanned(string traitDBName, List<string> bannedList)
		{
			return bannedList.Contains(traitDBName);
		}

		public static void ToggleBanTrait(string traitDBName)
		{
			List<string> bannedTraitsList = GetBannedTraitsList();
			if (bannedTraitsList.Contains(traitDBName))
			{
				bannedTraitsList.Remove(traitDBName);
				string text = "";
				foreach (string item in bannedTraitsList)
				{
					text = text + item + ",";
				}
				text.Remove(text.Length - 1);
				Configuration.BannedTraits.Value = text;
			}
			else if (CanBanTrait())
			{
				ConfigEntry<string> bannedTraits = Configuration.BannedTraits;
				bannedTraits.Value = bannedTraits.Value + "," + traitDBName;
			}
		}

		public static bool CanBanTrait()
		{
			if (GetUnbannedTraitsCount() <= 3)
			{
				return false;
			}
			return true;
		}

		public static int GetUnbannedTraitsCount()
		{
			int num = 0;
			for (int i = 0; i < TraitBank.Traits.GetCount(); i++)
			{
				if (IsTraitBanned(TraitBank.GetTrait(i).GetDBName(), GetBannedTraitsList()))
				{
					num++;
				}
			}
			return TraitBank.Traits.GetCount() - num;
		}

		public static void ValidateBans_Traits()
		{
			if (GetUnbannedTraitsCount() < 3)
			{
				ClearAllTraitBans();
			}
		}

		public static void ClearAllTraitBans()
		{
			Configuration.BannedTraits.Value = "";
		}

		public static List<string> GetBannedAIMasterNamesList()
		{
			List<string> bannedBaseAIMonsterMasterList = GetBannedBaseAIMonsterMasterList();
			string[] array = Configuration.BannedAIMasters.Value.Split(',');
			foreach (string item in array)
			{
				bannedBaseAIMonsterMasterList.Add(item);
			}
			return bannedBaseAIMonsterMasterList;
		}

		public static void ToggleBanAIMaster(string characterMasterName)
		{
			List<string> bannedAIMasterNamesList = GetBannedAIMasterNamesList();
			if (bannedAIMasterNamesList.Contains(characterMasterName))
			{
				bannedAIMasterNamesList.Remove(characterMasterName);
				string text = "";
				foreach (string item in bannedAIMasterNamesList)
				{
					text = text + item + ",";
				}
				text.Remove(text.Length - 1);
				Configuration.BannedAIMasters.Value = text;
			}
			else if (CanBanAISurvivors())
			{
				ConfigEntry<string> bannedAIMasters = Configuration.BannedAIMasters;
				bannedAIMasters.Value = bannedAIMasters.Value + "," + characterMasterName;
			}
		}

		public static List<string> GetBannedBaseAIMonsterMasterList()
		{
			return new List<string> { "HereticMonsterMaster", "SeekerMonsterMaster" };
		}

		public static List<string> GetAllBaseBannedItemAndEquipmentNamesList()
		{
			List<string> list = new List<string>();
			foreach (ItemDef baseBannedItems in GetBaseBannedItemsList())
			{
				list.Add(baseBannedItems.nameToken);
			}
			foreach (EquipmentDef baseBannedEquipment in GetBaseBannedEquipmentList())
			{
				if ((Object)(object)baseBannedEquipment != (Object)null)
				{
					list.Add(baseBannedEquipment.nameToken);
				}
				else
				{
					Debug.LogWarning((object)"NULL EquipmentDef being added???");
				}
			}
			return list;
		}

		public static List<string> GetAdditionalBannedItemAndEquipmentNamesList()
		{
			List<string> list = new List<string>();
			string[] array = Configuration.AdditionalBannedItemsAndEquipmentNames.Value.Split(',');
			foreach (string item in array)
			{
				list.Add(item);
			}
			return list;
		}

		private static ItemDef GetItemDefByNameToken(string nameToken)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
			AllItemsEnumerator enumerator = allItems.GetEnumerator();
			try
			{
				while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
				{
					ItemDef itemDef = ItemCatalog.GetItemDef(((AllItemsEnumerator)(ref enumerator)).Current);
					if (itemDef.nameToken == nameToken)
					{
						return itemDef;
					}
				}
			}
			finally
			{
				((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
			}
			return null;
		}

		private static EquipmentDef GetEquipmentDefByNameToken(string nameToken)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			GenericStaticEnumerable<EquipmentIndex, AllEquipmentEnumerator> allEquipment = EquipmentCatalog.allEquipment;
			AllEquipmentEnumerator enumerator = allEquipment.GetEnumerator();
			try
			{
				while (((AllEquipmentEnumerator)(ref enumerator)).MoveNext())
				{
					EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(((AllEquipmentEnumerator)(ref enumerator)).Current);
					if (equipmentDef.nameToken == nameToken)
					{
						return equipmentDef;
					}
				}
			}
			finally
			{
				((IDisposable)(AllEquipmentEnumerator)(ref enumerator)).Dispose();
			}
			return null;
		}

		private static List<EquipmentDef> GetBaseBannedEquipmentList()
		{
			return new List<EquipmentDef>
			{
				Equipment.Meteor,
				Equipment.Gateway,
				Equipment.Scanner,
				Equipment.Recycle,
				Equipment.QuestVolatileBattery,
				Equipment.AffixBlue,
				Equipment.AffixEcho,
				Equipment.AffixHaunted,
				Equipment.AffixLunar,
				Equipment.AffixPoison,
				Equipment.AffixRed,
				Equipment.AffixWhite,
				Equipment.BurnNearby,
				Equipment.LunarPotion,
				GetEquipmentDefByNameToken("EQUIPMENT_BOSSHUNTERCONSUMED_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_BOSSHUNTER_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_AFFIXEARTH_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_AFFIXSECRETSPEED_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_AFFIXVOID_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_GUMMYCLONE_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_LUNARPORTALONUSE_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_MULTISHOPCARD_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_ORBONUSE_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_VENDINGMACHINE_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_AFFIXBEAD_NAME"),
				GetEquipmentDefByNameToken("EQUIPMENT_AFFIXAURELIONITE_NAME")
			};
		}

		public static List<EquipmentDef> GetBannedEquipmentList(List<string> additionalBannedItemAndEquipmentList)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			List<EquipmentDef> baseBannedEquipmentList = GetBaseBannedEquipmentList();
			GenericStaticEnumerable<EquipmentIndex, AllEquipmentEnumerator> allEquipment = EquipmentCatalog.allEquipment;
			AllEquipmentEnumerator enumerator = allEquipment.GetEnumerator();
			try
			{
				while (((AllEquipmentEnumerator)(ref enumerator)).MoveNext())
				{
					EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(((AllEquipmentEnumerator)(ref enumerator)).Current);
					if (additionalBannedItemAndEquipmentList.Contains(equipmentDef.nameToken))
					{
						baseBannedEquipmentList.Add(equipmentDef);
					}
				}
				return baseBannedEquipmentList;
			}
			finally
			{
				((IDisposable)(AllEquipmentEnumerator)(ref enumerator)).Dispose();
			}
		}

		private static List<ItemDef> GetBaseBannedItemsList()
		{
			return new List<ItemDef>
			{
				Items.Bandolier,
				Items.Firework,
				Items.WardOnLevel,
				Items.TPHealingNova,
				Items.Squid,
				Items.Dagger,
				Items.Plant,
				Items.TreasureCache,
				Items.ExtraLife,
				Items.FocusConvergence,
				Items.LunarTrinket,
				Items.MonstersOnShrineUse,
				Items.RandomDamageZone,
				Items.HeadHunter,
				Items.SprintOutOfCombat,
				Items.HealWhileSafe,
				Items.TitanGoldDuringTP,
				Items.ScrapWhite,
				Items.ScrapGreen,
				Items.ScrapRed,
				Items.ScrapYellow,
				Items.ArtifactKey,
				Items.ExtraLifeConsumed,
				Items.TonicAffliction,
				Items.CrippleWardOnLevel,
				Items.RoboBallBuddy,
				GetItemDefByNameToken("ITEM_DRONEWEAPONS_NAME"),
				GetItemDefByNameToken("ITEM_PERMANENTDEBUFFONHIT_NAME"),
				GetItemDefByNameToken("ITEM_RANDOMLYLUNAR_NAME"),
				GetItemDefByNameToken("ITEM_MINORCONSTRUCTONKILL_NAME"),
				GetItemDefByNameToken("ITEM_WARCRYONCOMBAT_NAME"),
				GetItemDefByNameToken("ITEM_LUNARWINGS_NAME"),
				GetItemDefByNameToken("ITEM_BURNNEARBY_NAME"),
				GetItemDefByNameToken("ITEM_TEMPESTONKILL_NAME"),
				GetItemDefByNameToken("ITEM_HEALINGPOTIONCONSUMED_NAME"),
				GetItemDefByNameToken("ITEM_EXTRALIFEVOIDCONSUMED_NAME"),
				GetItemDefByNameToken("ITEM_SCRAPWHITESUPPRESSED_NAME"),
				GetItemDefByNameToken("ITEM_REGENERATINGSCRAPCONSUMED_NAME"),
				GetItemDefByNameToken("ITEM_CRITHEAL_NAME"),
				GetItemDefByNameToken("ITEM_ANCESTRALINCUBATOR_NAME"),
				GetItemDefByNameToken("ITEM_SCRAPGREENSUPPRESSED_NAME"),
				GetItemDefByNameToken("ITEM_EMPOWERALWAYS_NAME"),
				GetItemDefByNameToken("ITEM_SKULLCOUNTER_NAME"),
				GetItemDefByNameToken("ITEM_FRAGILEDAMAGEBONUSCONSUMED_NAME"),
				GetItemDefByNameToken("ITEM_SCRAPREDSUPPRESSED_NAME"),
				GetItemDefByNameToken("ITEM_TREASURECACHEVOID_NAME"),
				GetItemDefByNameToken("ITEM_CRITGLASSESVOID_NAME"),
				GetItemDefByNameToken("ITEM_EXTRALIFEVOID_NAME"),
				GetItemDefByNameToken("ITEM_CLOVERVOID_NAME"),
				GetItemDefByNameToken("ITEM_VOIDMEGACRABITEM_NAME"),
				GetItemDefByNameToken("ITEM_REGENERATINGSCRAP_NAME"),
				GetItemDefByNameToken("ITEM_RANDOMEQUIPMENTTRIGGER_NAME"),
				GetItemDefByNameToken("ITEM_SPEEDBOOSTPICKUP_NAME"),
				GetItemDefByNameToken("ITEM_FREECHEST_NAME"),
				GetItemDefByNameToken("ITEM_LOWERPRICEDCHESTS_NAME"),
				GetItemDefByNameToken("ITEM_BARRAGEONBOSS_NAME"),
				GetItemDefByNameToken("ITEM_CAPTAINDEFENSEMATRIX_NAME"),
				GetItemDefByNameToken("ITEM_ITEMDROPCHANCEONKILL_NAME"),
				GetItemDefByNameToken("ITEM_LUNARSUN_NAME"),
				GetItemDefByNameToken("ITEM_SHINYPEARL_NAME"),
				GetItemDefByNameToken("ITEM_PEARL_NAME"),
				GetItemDefByNameToken("ITEM_ONLEVELUPFREEUNLOCK_NAME"),
				GetItemDefByNameToken("ITEM_BEETLEGLAND_NAME"),
				GetItemDefByNameToken("ITEM_LOWERPRICEDCHESTSCONSUMED_NAME"),
				GetItemDefByNameToken("ITEM_TELEPORTONLOWHEALTHCONSUMED_NAME"),
				GetItemDefByNameToken("ITEM_LEMURIANHARNESS_NAME"),
				GetItemDefByNameToken("ITEM_TELEPORTONLOWHEALTH_NAME"),
				GetItemDefByNameToken("ITEM_EXTRASHRINEITEM_NAME"),
				GetItemDefByNameToken("ITEM_EXTRASTATSONLEVELUP_NAME")
			};
		}

		public static List<ItemDef> GetBannedItemsList(List<string> additionalBannedItemAndEquipmentList)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			List<ItemDef> baseBannedItemsList = GetBaseBannedItemsList();
			GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
			AllItemsEnumerator enumerator = allItems.GetEnumerator();
			try
			{
				while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
				{
					ItemDef itemDef = ItemCatalog.GetItemDef(((AllItemsEnumerator)(ref enumerator)).Current);
					if (additionalBannedItemAndEquipmentList.Contains(itemDef.nameToken))
					{
						baseBannedItemsList.Add(itemDef);
					}
				}
				return baseBannedItemsList;
			}
			finally
			{
				((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
			}
		}

		public static void ToggleBanItemAndEquipment(string itemEquipmentName)
		{
			List<string> additionalBannedItemAndEquipmentNamesList = GetAdditionalBannedItemAndEquipmentNamesList();
			if (additionalBannedItemAndEquipmentNamesList.Contains(itemEquipmentName))
			{
				additionalBannedItemAndEquipmentNamesList.Remove(itemEquipmentName);
				string text = "";
				foreach (string item in additionalBannedItemAndEquipmentNamesList)
				{
					text = text + item + ",";
				}
				text.Remove(text.Length - 1);
				Configuration.AdditionalBannedItemsAndEquipmentNames.Value = text;
			}
			else if (CanBanItemAndEquipment(itemEquipmentName))
			{
				ConfigEntry<string> additionalBannedItemsAndEquipmentNames = Configuration.AdditionalBannedItemsAndEquipmentNames;
				additionalBannedItemsAndEquipmentNames.Value = additionalBannedItemsAndEquipmentNames.Value + "," + itemEquipmentName;
			}
		}

		private static int GetTierCount(ItemTier targetItemTier, bool includeBanned)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			List<ItemDef> bannedItemsList = GetBannedItemsList(GetAdditionalBannedItemAndEquipmentNamesList());
			GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
			AllItemsEnumerator enumerator = allItems.GetEnumerator();
			try
			{
				while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
				{
					ItemDef itemDef = ItemCatalog.GetItemDef(((AllItemsEnumerator)(ref enumerator)).Current);
					if ((includeBanned || !bannedItemsList.Contains(itemDef)) && itemDef.tier == targetItemTier)
					{
						num++;
					}
				}
				return num;
			}
			finally
			{
				((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
			}
		}

		private static int GetEquipmentCount(bool includeBanned)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			List<EquipmentDef> bannedEquipmentList = GetBannedEquipmentList(GetAdditionalBannedItemAndEquipmentNamesList());
			GenericStaticEnumerable<EquipmentIndex, AllEquipmentEnumerator> allEquipment = EquipmentCatalog.allEquipment;
			AllEquipmentEnumerator enumerator = allEquipment.GetEnumerator();
			try
			{
				while (((AllEquipmentEnumerator)(ref enumerator)).MoveNext())
				{
					EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(((AllEquipmentEnumerator)(ref enumerator)).Current);
					if ((includeBanned || !bannedEquipmentList.Contains(equipmentDef)) && (Object)(object)equipmentDef != (Object)null && !equipmentDef.isLunar)
					{
						num++;
					}
				}
				return num;
			}
			finally
			{
				((IDisposable)(AllEquipmentEnumerator)(ref enumerator)).Dispose();
			}
		}

		public static void ProcessDropTableBans(Run run, List<ItemDef> bannedItems, List<EquipmentDef> bannedEquipment)
		{
			run.availableTier1DropList.RemoveAll((PickupIndex x) => bannedItems.Contains(ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(x).itemIndex)));
			run.availableTier2DropList.RemoveAll((PickupIndex x) => bannedItems.Contains(ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(x).itemIndex)));
			run.availableTier3DropList.RemoveAll((PickupIndex x) => bannedItems.Contains(ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(x).itemIndex)));
			run.availableLunarItemDropList.RemoveAll((PickupIndex x) => bannedItems.Contains(ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(x).itemIndex)));
			run.availableBossDropList.RemoveAll((PickupIndex x) => bannedItems.Contains(ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(x).itemIndex)));
			run.availableLunarEquipmentDropList.RemoveAll((PickupIndex x) => bannedEquipment.Contains(EquipmentCatalog.GetEquipmentDef(PickupCatalog.GetPickupDef(x).equipmentIndex)));
			run.availableLunarEquipmentDropList.RemoveAll((PickupIndex x) => bannedEquipment.Contains(EquipmentCatalog.GetEquipmentDef(PickupCatalog.GetPickupDef(x).equipmentIndex)));
			run.availableEquipmentDropList.RemoveAll((PickupIndex x) => bannedEquipment.Contains(EquipmentCatalog.GetEquipmentDef(PickupCatalog.GetPickupDef(x).equipmentIndex)));
			run.availableVoidTier1DropList.RemoveAll((PickupIndex x) => bannedItems.Contains(ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(x).itemIndex)));
			run.availableVoidTier2DropList.RemoveAll((PickupIndex x) => bannedItems.Contains(ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(x).itemIndex)));
			run.availableVoidTier3DropList.RemoveAll((PickupIndex x) => bannedItems.Contains(ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(x).itemIndex)));
		}

		public static bool CanBanAISurvivors()
		{
			if (KingKombatArenaMainPlugin.GenerateListOfAIMonsterMasterGOs(includeBanned: false).Count <= 1)
			{
				return false;
			}
			return true;
		}

		private static ItemDef FindItemDef(string itemName)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			GenericStaticEnumerable<ItemIndex, AllItemsEnumerator> allItems = ItemCatalog.allItems;
			AllItemsEnumerator enumerator = allItems.GetEnumerator();
			try
			{
				while (((AllItemsEnumerator)(ref enumerator)).MoveNext())
				{
					ItemDef itemDef = ItemCatalog.GetItemDef(((AllItemsEnumerator)(ref enumerator)).Current);
					if ((Object)(object)itemDef != (Object)null && itemDef.nameToken == itemName)
					{
						return itemDef;
					}
				}
			}
			finally
			{
				((IDisposable)(AllItemsEnumerator)(ref enumerator)).Dispose();
			}
			return null;
		}

		public static bool CanBanItem(ItemTier itemTier)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			bool result = true;
			if (GetTierCount(itemTier, includeBanned: false) <= 3)
			{
				result = false;
			}
			return result;
		}

		public static bool CanBanItem(string itemAndEquipmentName)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			bool result = true;
			ItemDef val = FindItemDef(itemAndEquipmentName);
			if ((Object)(object)val != (Object)null && !CanBanItem(val.tier))
			{
				result = false;
			}
			return result;
		}

		public static bool CanBanEquipment()
		{
			bool result = true;
			if (GetEquipmentCount(includeBanned: false) <= 3)
			{
				result = false;
			}
			return result;
		}

		private static bool CanBanItemAndEquipment(string itemAndEquipmentName)
		{
			bool result = true;
			if (!CanBanItem(itemAndEquipmentName))
			{
				result = false;
			}
			if (!CanBanEquipment())
			{
				result = false;
			}
			return result;
		}

		public static void ClearAllAISurvivorBans()
		{
			Configuration.BannedAIMasters.Value = "";
		}

		public static void ValidateBans_AISurvivors()
		{
			if (KingKombatArenaMainPlugin.GenerateListOfAIMonsterMasterGOs(includeBanned: false).Count < 1)
			{
				ClearAllAISurvivorBans();
			}
		}

		public static void ClearAllItemAndEquipmenBans()
		{
			Configuration.AdditionalBannedItemsAndEquipmentNames.Value = "";
		}

		public static void ValidateBan_ItemsAndEquipment()
		{
			bool flag = true;
			for (int i = 0; i < 5; i++)
			{
				if (GetTierCount((ItemTier)i, includeBanned: false) < 3)
				{
					flag = false;
				}
			}
			bool flag2 = true;
			if (GetEquipmentCount(includeBanned: false) < 3)
			{
				flag2 = false;
			}
			if (!flag2 || !flag)
			{
				ClearAllItemAndEquipmenBans();
			}
		}

		public static void ValidateAll()
		{
			ValidateBans_AISurvivors();
			ValidateBan_ItemsAndEquipment();
			ValidateBans_Traits();
		}
	}
	public struct Bet
	{
		public uint amount;

		public CharacterMaster ownerMaster;

		public CharacterMaster targetMaster;
	}
	public class BetManager
	{
		private List<Bet> m_currentBets = new List<Bet>();

		private readonly float m_baseBetWinMult = 0.5f;

		public void RecalculateBetMultipliers()
		{
			for (int i = 0; i < 2; i++)
			{
				ref ParticipantData reference = ref NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.AccessDuelingParticipantData(i);
				reference.betMultiplier = 1f + m_baseBetWinMult + reference.CalculateLoseChance();
			}
		}

		public void AddBet(in Bet newBet)
		{
			if (CanAddBet(newBet))
			{
				m_currentBets.Add(newBet);
				CharacterMaster ownerMaster = newBet.ownerMaster;
				ownerMaster.money -= newBet.amount;
				MainPlugin.DebugWarning("BetManager::AddBet(); owner: " + ((Object)newBet.ownerMaster).name + " | amount = " + newBet.amount + " | target: " + ((Object)newBet.targetMaster).name);
			}
			else
			{
				MainPlugin.DebugWarning("BetManager::AddBet(); owner: " + ((Object)newBet.ownerMaster).name + " | Failed to Add Bet, not enough money, already bet or is dueling!");
			}
		}

		public bool CanAddBet(Bet newBet)
		{
			bool num = newBet.ownerMaster.money >= newBet.amount;
			bool flag = m_currentBets.Where((Bet x) => (Object)(object)x.ownerMaster == (Object)(object)newBet.ownerMaster).Count() > 0;
			bool flag2 = NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.IsCharacterDueling(newBet.ownerMaster);
			if (num && !flag)
			{
				return !flag2;
			}
			return false;
		}

		public void ProcessWinnings(CharacterMaster winnerMaster)
		{
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < m_currentBets.Count; i++)
			{
				Bet bet = m_currentBets[i];
				if (!((Object)(object)bet.targetMaster == (Object)(object)winnerMaster) || !((Object)(object)bet.ownerMaster != (Object)null) || !((Object)(object)bet.targetMaster != (Object)null))
				{
					continue;
				}
				ParticipantData participantData = NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.AccessParticipantData(bet.ownerMaster);
				ParticipantData participantData2 = NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.AccessParticipantData(bet.targetMaster);
				if (participantData.IsConnectedAndAlive())
				{
					uint num = (uint)Mathf.RoundToInt((float)Mathf.Max(1, Mathf.RoundToInt((float)bet.amount * participantData2.betMultiplier)));
					MainPlugin.DebugWarning("BetManager::ProcessWinnings(); " + ((Object)bet.ownerMaster).name + " has won: " + num + " | betMult = " + participantData2.betMultiplier);
					MainPlugin.SendChatMessageToAll(participantData.GetBestMasterName() + " won bet and earned " + Util.GenerateColoredString("$" + num.ToString("n0"), Color32.op_Implicit(Color.yellow)));
					KingKombatArenaMainPlugin.AccessCurrentKombatArenaInstance().GrantMoney(bet.ownerMaster, num);
					if (participantData.HasTrait("GamblerTrait"))
					{
						GamblerTrait.GenerateBonusBetMoney(num, bet.ownerMaster);
					}
					CharacterBody body = bet.ownerMaster.GetBody();
					if ((Object)(object)body != (Object)null)
					{
						NetworkedGameModeManager.instance.CallCmdSpawnAboveHeadFX(((Component)body).gameObject, ((Object)KingKombatArenaAssets.BetWinningFXGO).name, 5f);
						NetworkedGameModeManager.instance.CallCmdPlaySoundEvent(((Component)body).gameObject, KombatArenaSounds.ka_betwin);
					}
				}
			}
			m_currentBets.Clear();
		}

		public uint GetTotalBetPool()
		{
			uint num = 0u;
			foreach (Bet currentBet in m_currentBets)
			{
				num += currentBet.amount;
			}
			return num;
		}

		public uint GetTotalBetAmount(CharacterMaster targetMaster)
		{
			uint num = 0u;
			foreach (Bet currentBet in m_currentBets)
			{
				if ((Object)(object)targetMaster == (Object)(object)currentBet.targetMaster)
				{
					num += currentBet.amount;
				}
			}
			return num;
		}
	}
	public class BettingHandler : CharacterModComponent
	{
		private bool m_isBettingWindowOpen;

		public bool m_placedBet;

		private const float DEFAULT_BETTING_LIMIT = 0.5f;

		private static int kCmdCmdAddBet;

		protected override bool InitUI()
		{
			if (UIManager.Get().FindHUDUIElement("UI_Betting") is UI_Betting uI_Betting && uI_Betting.Init(this))
			{
				return true;
			}
			return false;
		}

		protected override void InternalUpdate()
		{
			((CharacterModComponent)this).InternalUpdate();
			if (!((NetworkBehaviour)this).hasAuthority)
			{
				return;
			}
			if (CanBet())
			{
				if (((CharacterModComponent)this).GetPlayerInput().GetButtonDown(10))
				{
					SetIsBettingWindowOpen(!GetIsBettingWindowOpen());
				}
			}
			else
			{
				SetIsBettingWindowOpen(val: false);
			}
			if ((Object)(object)NetworkedGameModeManager.instance != (Object)null && !NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.IsPreparingDuel())
			{
				m_placedBet = false;
			}
		}

		public bool CanBet()
		{
			bool result = false;
			if ((Object)(object)NetworkedGameModeManager.instance != (Object)null)
			{
				bool flag = NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.IsCharacterDueling(((CharacterModComponent)this).GetCharacterBody().master);
				result = NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.IsPreparingDuel() && !m_placedBet && !flag && KingKombatArenaMainPlugin.IsInWaitingArea(((Component)this).gameObject);
			}
			return result;
		}

		public void SetIsBettingWindowOpen(bool val)
		{
			if ((!val || !((Component)this).GetComponent<KingKombatArenaComponent>().HasUIOpen()) && m_isBettingWindowOpen != val)
			{
				m_isBettingWindowOpen = val;
			}
		}

		public bool GetIsBettingWindowOpen()
		{
			return m_isBettingWindowOpen;
		}

		[Command]
		public void CmdAddBet(uint amount, GameObject ownerMasterGO, GameObject targetMasterGO)
		{
			AddBetServer(amount, ownerMasterGO.GetComponent<CharacterMaster>(), targetMasterGO.GetComponent<CharacterMaster>());
		}

		[Server]
		public void AddBetServer(uint amount, CharacterMaster ownerMaster, CharacterMaster targetMaster)
		{
			if (!NetworkServer.active)
			{
				Debug.LogWarning((object)"[Server] function 'System.Void NS_KingKombatArena.BettingHandler::AddBetServer(System.UInt32,RoR2.CharacterMaster,RoR2.CharacterMaster)' called on client");
				return;
			}
			BetManager betManager = NetworkedGameModeManager.instance.m_betManager;
			Bet newBet = new Bet
			{
				amount = amount,
				ownerMaster = ownerMaster,
				targetMaster = targetMaster
			};
			betManager.AddBet(in newBet);
		}

		public static float GetMaxBetLimitMult(CharacterMaster characterMaster)
		{
			float result = 0.5f;
			ParticipantData participantData = NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.AccessParticipantData(characterMaster);
			if (participantData.HasTrait("GamblerTrait"))
			{
				result = 1f;
			}
			return result;
		}

		private void UNetVersion()
		{
		}

		protected static void InvokeCmdCmdAddBet(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"Command CmdAddBet called on client.");
			}
			else
			{
				((BettingHandler)(object)obj).CmdAddBet(reader.ReadPackedUInt32(), reader.ReadGameObject(), reader.ReadGameObject());
			}
		}

		public void CallCmdAddBet(uint amount, GameObject ownerMasterGO, GameObject targetMasterGO)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"Command function CmdAddBet called on server.");
				return;
			}
			if (((NetworkBehaviour)this).isServer)
			{
				CmdAddBet(amount, ownerMasterGO, targetMasterGO);
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)5);
			val.WritePackedUInt32((uint)kCmdCmdAddBet);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.WritePackedUInt32(amount);
			val.Write(ownerMasterGO);
			val.Write(targetMasterGO);
			((NetworkBehaviour)this).SendCommandInternal(val, 0, "CmdAddBet");
		}

		static BettingHandler()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			kCmdCmdAddBet = -689115717;
			NetworkBehaviour.RegisterCommandDelegate(typeof(BettingHandler), kCmdCmdAddBet, new CmdDelegate(InvokeCmdCmdAddBet));
			NetworkCRC.RegisterBehaviour("BettingHandler", 0);
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			bool flag = ((CharacterModComponent)this).OnSerialize(writer, forceAll);
			bool flag2 = default(bool);
			return flag2 || flag;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			((CharacterModComponent)this).OnDeserialize(reader, initialState);
		}
	}
	public class KingKombatArenaComponent : CharacterModComponent
	{
		public LobbyShopHandler m_lobbyShopHandler;

		public BettingHandler m_bettingHandler;

		public TraitHandler m_traitHandler;

		private float m_forcedRecalculationTimer;

		private static int kCmdCmdRequestSkip;

		protected override void Awake()
		{
			((CharacterModComponent)this).Awake();
			m_lobbyShopHandler = ((Component)this).GetComponent<LobbyShopHandler>();
			m_bettingHandler = ((Component)this).GetComponent<BettingHandler>();
			m_traitHandler = ((Component)this).GetComponent<TraitHandler>();
		}

		protected override void InternalUpdate()
		{
			((CharacterModComponent)this).InternalUpdate();
			if (KingKombatArenaMainPlugin.s_GAME_MODE_ACTIVE)
			{
				if (((NetworkBehaviour)this).hasAuthority && KingKombatArenaMainPlugin.IsInWaitingArea(((Component)this).gameObject) && ((CharacterModComponent)this).GetPlayerInput().GetButtonDown(6))
				{
					CallCmdRequestSkip(((Component)((CharacterModComponent)this).GetCharacterBody().master).gameObject);
				}
				if (m_forcedRecalculationTimer <= 0f)
				{
					m_forcedRecalculationTimer = 1f;
					((CharacterModComponent)this).GetCharacterBody().RecalculateStats();
				}
				m_forcedRecalculationTimer -= Time.deltaTime;
			}
		}

		public bool HasUIOpen()
		{
			if (!m_lobbyShopHandler.GetIsShopOpen() && !m_bettingHandler.GetIsBettingWindowOpen())
			{
				return m_traitHandler.IsTraitSelectionOpen();
			}
			return true;
		}

		public void CloseAllUIButTraitSelection()
		{
			m_lobbyShopHandler.SetIsOpenShop(val: false);
			m_bettingHandler.SetIsBettingWindowOpen(val: false);
		}

		private void OnGUI()
		{
			if (MainPlugin.DEBUG_MODE)
			{
				_ = KingKombatArenaMainPlugin.s_GAME_MODE_ACTIVE;
			}
		}

		[Command]
		public void CmdRequestSkip(GameObject _characterMasterGO)
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if ((((StateMachine)KingKombatArenaMainPlugin.AccessCurrentKombatArenaInstance().GetKombatArenaStateMachine()).GetCurrentState() as KombatArenaBaseState).CanRequestSkip() && (Object)(object)NetworkedGameModeManager.instance != (Object)null)
			{
				ref NetworkedGameModeData currentNetworkedGameModeData = ref NetworkedGameModeManager.instance.m_currentNetworkedGameModeData;
				if (!currentNetworkedGameModeData.HasRequestedSkip(_characterMasterGO))
				{
					SkipRequest newSkipRequest = new SkipRequest
					{
						characterMasterGO = _characterMasterGO
					};
					currentNetworkedGameModeData.AddSkipRequest(in newSkipRequest);
					CharacterMaster component = _characterMasterGO.GetComponent<CharacterMaster>();
					object[] args = new object[4]
					{
						MainPlugin.GetBestMasterName(component),
						Util.GenerateColoredString("Skip", ColorCatalog.GetColor((ColorIndex)5)),
						currentNetworkedGameModeData.GetSkipRequestCount().ToString("n0"),
						NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.GetNumberOfAliveHumans().ToString("n0")
					};
					MainPlugin.SendChatMessageToAll(string.Format("{0} has requested to {1} [{2}/{3}]", args));
				}
			}
		}

		private void UNetVersion()
		{
		}

		protected static void InvokeCmdCmdRequestSkip(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"Command CmdRequestSkip called on client.");
			}
			else
			{
				((KingKombatArenaComponent)(object)obj).CmdRequestSkip(reader.ReadGameObject());
			}
		}

		public void CallCmdRequestSkip(GameObject _characterMasterGO)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"Command function CmdRequestSkip called on server.");
				return;
			}
			if (((NetworkBehaviour)this).isServer)
			{
				CmdRequestSkip(_characterMasterGO);
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)5);
			val.WritePackedUInt32((uint)kCmdCmdRequestSkip);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.Write(_characterMasterGO);
			((NetworkBehaviour)this).SendCommandInternal(val, 0, "CmdRequestSkip");
		}

		static KingKombatArenaComponent()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			kCmdCmdRequestSkip = 1572259733;
			NetworkBehaviour.RegisterCommandDelegate(typeof(KingKombatArenaComponent), kCmdCmdRequestSkip, new CmdDelegate(InvokeCmdCmdRequestSkip));
			NetworkCRC.RegisterBehaviour("KingKombatArenaComponent", 0);
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			bool flag = ((CharacterModComponent)this).OnSerialize(writer, forceAll);
			bool flag2 = default(bool);
			return flag2 || flag;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			((CharacterModComponent)this).OnDeserialize(reader, initialState);
		}
	}
	public enum EChestType
	{
		SMALL,
		LARGE,
		LEGENDARY,
		LUNAR,
		BOSS,
		EQUIPMENT,
		VOID,
		MAX
	}
	public enum EItemType
	{
		WHITE,
		GREEN,
		RED,
		LUNAR,
		BOSS,
		EQUIPMENT,
		VOID,
		MAX
	}
	public class LobbyShopHandler : CharacterModComponent
	{
		private static uint[] s_costArray;

		private static readonly float[,] s_chanceGrid;

		public const int CHEST_ITEM_SELECTION_COUNT = 3;

		private bool m_isShopOpen;

		public Action m_onShopOpen;

		public Action m_onShopClose;

		public Action m_onShopActive;

		private UI_LobbyShop m_ui;

		private static int kCmdCmdPurchaseItem;

		private static int kCmdCmdPurchaseEquipment;

		private static int kCmdCmdSpendMoney;

		private static int kRpcRpcForceBossItemSelection;

		private static Color GetItemTypeColor(EItemType itemType)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			Color result = Color.white;
			switch (itemType)
			{
			case EItemType.WHITE:
				result = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)1));
				break;
			case EItemType.GREEN:
				result = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)2));
				break;
			case EItemType.RED:
				result = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)3));
				break;
			case EItemType.LUNAR:
				result = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)4));
				break;
			case EItemType.BOSS:
				result = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)13));
				break;
			case EItemType.EQUIPMENT:
				result = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)5));
				break;
			case EItemType.VOID:
				result = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)25));
				break;
			}
			return result;
		}

		public static string GenerateChestDescription(EChestType chestType)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			text = text + "Pick an Item from a selection of " + 3 + "\n";
			text += MainPlugin.ColorText("Item Rarity Chances:\n", "#C7B96A");
			for (int i = 0; i < 7; i++)
			{
				EItemType eItemType = (EItemType)i;
				float chestItemChance = GetChestItemChance(chestType, eItemType);
				if (chestItemChance != 0f)
				{
					text = text + string.Format("{0} : {1}", Util.GenerateColoredString(eItemType.ToString(), Color32.op_Implicit(GetItemTypeColor(eItemType))), MainPlugin.ColorText("%" + KingUtil.MultToPercent(chestItemChance).ToString("n0"), "#999999")) + "\n";
				}
			}
			return text;
		}

		public static uint GetCostOfChest(EChestType chestType)
		{
			return s_costArray[(int)chestType];
		}

		public void SetIsOpenShop(bool val)
		{
			if ((!val || !((Component)this).GetComponent<KingKombatArenaComponent>().HasUIOpen()) && m_isShopOpen != val)
			{
				m_isShopOpen = val;
				if (m_isShopOpen)
				{
					m_onShopOpen?.Invoke();
				}
				else
				{
					m_onShopClose?.Invoke();
				}
			}
		}

		public bool GetIsShopOpen()
		{
			return m_isShopOpen;
		}

		protected override void InternalUpdate()
		{
			((CharacterModComponent)this).InternalUpdate();
			if (!((NetworkBehaviour)this).hasAuthority || !NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.isBuiltAndReady)
			{
				return;
			}
			if (KingKombatArenaMainPlugin.IsInWaitingArea(((Component)this).gameObject))
			{
				if (((CharacterModComponent)this).GetPlayerInput().GetButtonDown(9) && !m_ui.IsChoosingItem())
				{
					SetIsOpenShop(!GetIsShopOpen());
				}
			}
			else
			{
				m_ui.ForceCloseShop();
			}
			if (GetIsShopOpen())
			{
				m_onShopActive?.Invoke();
			}
		}

		protected override bool InitUI()
		{
			m_ui = UIManager.Get().FindHUDUIElement("UI_LobbyShop") as UI_LobbyShop;
			if (m_ui != null && m_ui.Init(this))
			{
				return true;
			}
			return false;
		}

		public CharacterMaster GetCharacterMaster()
		{
			return ((CharacterModComponent)this).GetCharacterBody().master;
		}

		private static bool IsValidChance(EChestType chestType)
		{
			float num = 0f;
			for (int i = 0; i < 7; i++)
			{
				num += GetChestItemChance(chestType, (EItemType)i);
			}
			return num == 1f;
		}

		public static float GetChestItemChance(EChestType chestType, EItemType eItemType)
		{
			return s_chanceGrid[(int)chestType, (int)eItemType];
		}

		public static PickupIndex GeneratePickupIndex(EChestType chestType, ref List<PickupIndex>[] itemPickupLists)
		{
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			if (MainPlugin.DEBUG_MODE && !IsValidChance(chestType))
			{
				MainPlugin.DebugWarning("GetChestItemChance(); Invalid Chance Amount : chestType = " + chestType);
			}
			float num = Random.Range(0f, 1f);
			EItemType eItemType = EItemType.MAX;
			for (int i = 0; i < 7; i++)
			{
				num -= GetChestItemChance(chestType, (EItemType)i);
				if (num <= 0f)
				{
					eItemType = (EItemType)i;
					MainPlugin.DebugLog("GeneratePickupIndex(); Selected: " + eItemType);
					break;
				}
			}
			ref List<PickupIndex> reference = ref itemPickupLists[(int)eItemType];
			int index = Random.Range(0, reference.Count);
			PickupIndex result = reference[index];
			reference.RemoveAt(index);
			return result;
		}

		public static List<PickupIndex> GeneratePickupIndexes(EChestType chestType, int count)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			MainPlugin.DebugLog("GeneratePickupIndexes(); chestType = " + chestType);
			List<PickupIndex> list = new List<PickupIndex>();
			List<PickupIndex>[] itemPickupLists = new List<PickupIndex>[7];
			for (int i = 0; i < 7; i++)
			{
				itemPickupLists[i] = GetItemPickupList((EItemType)i);
			}
			for (int j = 0; j < count; j++)
			{
				list.Add(GeneratePickupIndex(chestType, ref itemPickupLists));
			}
			return list;
		}

		public static List<PickupIndex> GetItemPickupList(EItemType itemType)
		{
			List<PickupIndex> list = new List<PickupIndex>();
			switch (itemType)
			{
			case EItemType.WHITE:
				list = Run.instance.availableTier1DropList;
				break;
			case EItemType.GREEN:
				list = Run.instance.availableTier2DropList;
				break;
			case EItemType.RED:
				list = Run.instance.availableTier3DropList;
				break;
			case EItemType.LUNAR:
				list = Run.instance.availableLunarItemDropList;
				break;
			case EItemType.BOSS:
				list = Run.instance.availableBossDropList;
				break;
			case EItemType.EQUIPMENT:
				list = Run.instance.availableEquipmentDropList;
				break;
			case EItemType.VOID:
				list.AddRange(Run.instance.availableVoidTier1DropList);
				list.AddRange(Run.instance.availableVoidTier2DropList);
				list.AddRange(Run.instance.availableVoidTier3DropList);
				list = list.Distinct().ToList();
				break;
			}
			List<PickupIndex> list2 = new List<PickupIndex>();
			list2.AddRange(list);
			return list2;
		}

		public void PurchaseItem(CharacterMaster purchaserCharacterMaster, PickupDef pickupDef)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected I4, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected I4, but got Unknown
			if ((int)pickupDef.itemIndex != -1)
			{
				CallCmdPurchaseItem(((Component)purchaserCharacterMaster).gameObject, (int)pickupDef.itemIndex);
			}
			else if ((int)pickupDef.equipmentIndex != -1)
			{
				CallCmdPurchaseEquipment(((Component)purchaserCharacterMaster).gameObject, (int)pickupDef.equipmentIndex);
			}
		}

		public void AttemptPurchaseAI()
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.5f;
			int num2 = Mathf.FloorToInt((float)GetCharacterMaster().money / (float)GetCostOfChest(EChestType.SMALL));
			for (int i = 0; i < num2; i++)
			{
				if (!(Random.Range(0f, 1f) < num))
				{
					continue;
				}
				List<EChestType> list = new List<EChestType>();
				for (int j = 0; j < 7; j++)
				{
					EChestType eChestType = (EChestType)j;
					if (eChestType != EChestType.BOSS && CanAfford(GetCharacterMaster(), GetCostOfChest(eChestType)))
					{
						list.Add(eChestType);
					}
				}
				if (list.Count > 0)
				{
					int index = Random.Range(0, list.Count);
					EChestType chestType = list[index];
					List<PickupIndex> list2 = GeneratePickupIndexes(chestType, 3);
					int index2 = Random.Range(0, list2.Count);
					CallCmdSpendMoney(((Component)GetCharacterMaster()).gameObject, GetCostOfChest(chestType));
					PurchaseItem(GetCharacterMaster(), PickupCatalog.GetPickupDef(list2[index2]));
				}
			}
		}

		private void OnGUI()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Invalid comparison between Unknown and I4
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_010a: 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 (!MainPlugin.DEBUG_MODE || !MainPlugin.DEBUG_DISPLAY || !KingKombatArenaMainPlugin.s_GAME_MODE_ACTIVE || !((NetworkBehaviour)this).hasAuthority || !((Object)(object)GetCharacterMaster() != (Object)null) || !((Object)(object)GetCharacterMaster().playerCharacterMasterController != (Object)null))
			{
				return;
			}
			if (GUI.Button(new Rect((float)(Screen.width / 2), 50f, 100f, 30f), "Give Money"))
			{
				GetCharacterMaster().GiveMoney(1000u);
			}
			if (!GUI.Button(new Rect((float)(Screen.width / 2 + 100), 50f, 100f, 30f), "Kill Monsters"))
			{
				return;
			}
			Object[] array = Object.FindObjectsByType(typeof(CharacterBody), (FindObjectsSortMode)0);
			MainPlugin.DebugLog($"Found Character Bodies : {array.Length}");
			Object[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				CharacterBody val = (CharacterBody)array2[i];
				if ((int)val.teamComponent.teamIndex == 2)
				{
					DamageInfo val2 = new DamageInfo();
					val2.position = ((Component)val).transform.position;
					val2.damage = 99999f;
					val.healthComponent.TakeDamage(val2);
				}
			}
		}

		public bool CanAfford(CharacterMaster characterMaster, uint cost)
		{
			return characterMaster.money >= cost;
		}

		[Command]
		public void CmdPurchaseItem(GameObject characterMasterGO, int itemIndex)
		{
			MainPlugin.DebugLog("CmdPurchaseItem() Called! " + ((Object)characterMasterGO).name + " | itemIndex = " + itemIndex);
			CharacterMaster component = characterMasterGO.GetComponent<CharacterMaster>();
			Inventory inventory = component.GetBody().inventory;
			if ((Object)(object)inventory == (Object)null)
			{
				inventory = component.inventory;
			}
			ItemDef itemDef = ItemCatalog.GetItemDef((ItemIndex)itemIndex);
			if ((Object)(object)itemDef != (Object)null)
			{
				inventory.GiveItem(itemDef, 1);
			}
		}

		[Command]
		public void CmdPurchaseEquipment(GameObject characterMasterGO, int equipmentIndex)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			MainPlugin.DebugLog("CmdPurchaseItem() Called! " + ((Object)characterMasterGO).name + " | equipmentIndex = " + equipmentIndex);
			CharacterMaster component = characterMasterGO.GetComponent<CharacterMaster>();
			Inventory inventory = component.GetBody().inventory;
			if ((Object)(object)inventory == (Object)null)
			{
				inventory = component.inventory;
			}
			EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef((EquipmentIndex)equipmentIndex);
			if ((Object)(object)equipmentDef != (Object)null)
			{
				inventory.SetEquipmentIndex(equipmentDef.equipmentIndex);
			}
		}

		[Command]
		public void CmdSpendMoney(GameObject characterMasterGO, uint moneyAmount)
		{
			CharacterMaster component = characterMasterGO.GetComponent<CharacterMaster>();
			if ((Object)(object)component != (Object)null && CanAfford(component, moneyAmount))
			{
				component.money -= moneyAmount;
			}
		}

		[ClientRpc]
		public void RpcForceBossItemSelection()
		{
			if (((NetworkBehaviour)this).hasAuthority)
			{
				SetIsOpenShop(val: true);
				if (m_ui != null)
				{
					m_ui.ForceBossItemSelection();
				}
			}
		}

		static LobbyShopHandler()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			s_costArray = new uint[7] { 120u, 250u, 600u, 700u, 800u, 400u, 800u };
			s_chanceGrid = new float[7, 7]
			{
				{ 0.9f, 0.1f, 0f, 0f, 0f, 0f, 0f },
				{ 0.05f, 0.9f, 0.05f, 0f, 0f, 0f, 0f },
				{ 0f, 0f, 1f, 0f, 0f, 0f, 0f },
				{ 0f, 0f, 0f, 1f, 0f, 0f, 0f },
				{ 0f, 0f, 0f, 0f, 1f, 0f, 0f },
				{ 0f, 0f, 0f, 0f, 0f, 1f, 0f },
				{ 0f, 0f, 0f, 0f, 0f, 0f, 1f }
			};
			kCmdCmdPurchaseItem = 2130527218;
			NetworkBehaviour.RegisterCommandDelegate(typeof(LobbyShopHandler), kCmdCmdPurchaseItem, new CmdDelegate(InvokeCmdCmdPurchaseItem));
			kCmdCmdPurchaseEquipment = 234999823;
			NetworkBehaviour.RegisterCommandDelegate(typeof(LobbyShopHandler), kCmdCmdPurchaseEquipment, new CmdDelegate(InvokeCmdCmdPurchaseEquipment));
			kCmdCmdSpendMoney = -1180497472;
			NetworkBehaviour.RegisterCommandDelegate(typeof(LobbyShopHandler), kCmdCmdSpendMoney, new CmdDelegate(InvokeCmdCmdSpendMoney));
			kRpcRpcForceBossItemSelection = 1390678965;
			NetworkBehaviour.RegisterRpcDelegate(typeof(LobbyShopHandler), kRpcRpcForceBossItemSelection, new CmdDelegate(InvokeRpcRpcForceBossItemSelection));
			NetworkCRC.RegisterBehaviour("LobbyShopHandler", 0);
		}

		private void UNetVersion()
		{
		}

		protected static void InvokeCmdCmdPurchaseItem(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"Command CmdPurchaseItem called on client.");
			}
			else
			{
				((LobbyShopHandler)(object)obj).CmdPurchaseItem(reader.ReadGameObject(), (int)reader.ReadPackedUInt32());
			}
		}

		protected static void InvokeCmdCmdPurchaseEquipment(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"Command CmdPurchaseEquipment called on client.");
			}
			else
			{
				((LobbyShopHandler)(object)obj).CmdPurchaseEquipment(reader.ReadGameObject(), (int)reader.ReadPackedUInt32());
			}
		}

		protected static void InvokeCmdCmdSpendMoney(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"Command CmdSpendMoney called on client.");
			}
			else
			{
				((LobbyShopHandler)(object)obj).CmdSpendMoney(reader.ReadGameObject(), reader.ReadPackedUInt32());
			}
		}

		public void CallCmdPurchaseItem(GameObject characterMasterGO, int itemIndex)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"Command function CmdPurchaseItem called on server.");
				return;
			}
			if (((NetworkBehaviour)this).isServer)
			{
				CmdPurchaseItem(characterMasterGO, itemIndex);
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)5);
			val.WritePackedUInt32((uint)kCmdCmdPurchaseItem);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.Write(characterMasterGO);
			val.WritePackedUInt32((uint)itemIndex);
			((NetworkBehaviour)this).SendCommandInternal(val, 0, "CmdPurchaseItem");
		}

		public void CallCmdPurchaseEquipment(GameObject characterMasterGO, int equipmentIndex)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"Command function CmdPurchaseEquipment called on server.");
				return;
			}
			if (((NetworkBehaviour)this).isServer)
			{
				CmdPurchaseEquipment(characterMasterGO, equipmentIndex);
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)5);
			val.WritePackedUInt32((uint)kCmdCmdPurchaseEquipment);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.Write(characterMasterGO);
			val.WritePackedUInt32((uint)equipmentIndex);
			((NetworkBehaviour)this).SendCommandInternal(val, 0, "CmdPurchaseEquipment");
		}

		public void CallCmdSpendMoney(GameObject characterMasterGO, uint moneyAmount)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"Command function CmdSpendMoney called on server.");
				return;
			}
			if (((NetworkBehaviour)this).isServer)
			{
				CmdSpendMoney(characterMasterGO, moneyAmount);
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)5);
			val.WritePackedUInt32((uint)kCmdCmdSpendMoney);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.Write(characterMasterGO);
			val.WritePackedUInt32(moneyAmount);
			((NetworkBehaviour)this).SendCommandInternal(val, 0, "CmdSpendMoney");
		}

		protected static void InvokeRpcRpcForceBossItemSelection(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"RPC RpcForceBossItemSelection called on server.");
			}
			else
			{
				((LobbyShopHandler)(object)obj).RpcForceBossItemSelection();
			}
		}

		public void CallRpcForceBossItemSelection()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"RPC Function RpcForceBossItemSelection called on client.");
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)2);
			val.WritePackedUInt32((uint)kRpcRpcForceBossItemSelection);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcForceBossItemSelection");
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			bool flag = ((CharacterModComponent)this).OnSerialize(writer, forceAll);
			bool flag2 = default(bool);
			return flag2 || flag;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			((CharacterModComponent)this).OnDeserialize(reader, initialState);
		}
	}
	public class TraitHandler : CharacterModComponent
	{
		private Trait m_currentTrait;

		private static int kCmdCmdSetTrait;

		private static int kRpcRpcPromptTraitSelection;

		public void AssignTrait(Trait newTrait)
		{
			m_currentTrait = newTrait;
			if (GetCurrentTrait() != null)
			{
				GetCurrentTrait().OnTraitEnabled(((CharacterModComponent)this).GetCharacterBody());
			}
		}

		protected override void InternalUpdate()
		{
			((CharacterModComponent)this).InternalUpdate();
			if (!KingKombatArenaMainPlugin.s_GAME_MODE_ACTIVE)
			{
				return;
			}
			if (GetCurrentTrait() != null)
			{
				if (((NetworkBehaviour)this).hasAuthority || NetworkServer.active)
				{
					UpdateActiveTrait();
				}
			}
			else if (NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.isBuiltAndReady)
			{
				int traitIndex = NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.AccessParticipantData(((CharacterModComponent)this).GetCharacterBody().master).GetTraitIndex();
				if (traitIndex != -1)
				{
					Trait trait = TraitBank.GetTrait(traitIndex);
					Trait trait2 = Activator.CreateInstance(trait.GetType()) as Trait;
					trait2.SetBuffDef(trait.GetBuffDef());
					AssignTrait(trait2);
				}
			}
		}

		public Trait GetCurrentTrait()
		{
			return m_currentTrait;
		}

		private void UpdateActiveTrait()
		{
			GetCurrentTrait().OnUpdate();
		}

		protected override void OnFirstUpdate()
		{
			((CharacterModComponent)this).OnFirstUpdate();
		}

		private void ShowTraitSelectionUI()
		{
			KingKombatArenaComponent component = ((Component)this).GetComponent<KingKombatArenaComponent>();
			if ((Object)(object)component != (Object)null)
			{
				component.CloseAllUIButTraitSelection();
			}
			UI_TraitSelection uI_TraitSelection = UIManager.Get().FindHUDUIElement("UI_TraitSelection") as UI_TraitSelection;
			if (!uI_TraitSelection.IsActive())
			{
				MainPlugin.DebugWarning("ShowTraitSelectionUI()");
				uI_TraitSelection.SetupTraitOptions(GenerateSelectableTraitIndexes());
				uI_TraitSelection.SetTraitSelectionActive(active: true);
			}
		}

		public int[] GenerateSelectableTraitIndexes()
		{
			List<string> bannedList = KingUtil.CreateListFromString(NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.m_cachedKombatArenaRules.config_bannedTraits);
			List<int> list = new List<int>();
			for (int i = 0; i < TraitBank.Traits.GetCount(); i++)
			{
				if (!Bans.IsTraitBanned(TraitBank.GetTrait(i).GetDBName(), bannedList))
				{
					list.Add(i);
				}
			}
			int[] array = new int[3];
			for (int j = 0; j < 3; j++)
			{
				int index = Random.Range(0, list.Count);
				array[j] = list[index];
				list.RemoveAt(index);
			}
			return array;
		}

		private void OnDestroy()
		{
			if (GetCurrentTrait() != null)
			{
				GetCurrentTrait().OnTraitDisabled();
			}
		}

		protected override bool InitUI()
		{
			if (UIManager.Get().FindHUDUIElement("UI_TraitSelection") is UI_TraitSelection uI_TraitSelection && uI_TraitSelection.Init(this))
			{
				return true;
			}
			return false;
		}

		public bool IsTraitSelectionOpen()
		{
			if (UIManager.Get().FindHUDUIElement("UI_TraitSelection") is UI_TraitSelection uI_TraitSelection)
			{
				return uI_TraitSelection.IsActive();
			}
			return false;
		}

		[Command]
		public void CmdSetTrait(int traitIndex)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.isBuiltAndReady)
			{
				ref ParticipantData reference = ref NetworkedGameModeManager.instance.m_currentNetworkedGameModeData.AccessParticipantData(((CharacterModComponent)this).GetCharacterBody().master);
				if (reference.SetTraitIndex(traitIndex))
				{
					Trait trait = TraitBank.GetTrait(traitIndex);
					MainPlugin.SendChatMessageToAll($"{reference.GetBestMasterName()} Selected Trait: {Util.GenerateColoredString(trait.GetDisplayName(), ColorCatalog.GetColor((ColorIndex)13))}");
				}
			}
		}

		[ClientRpc]
		public void RpcPromptTraitSelection()
		{
			if (((NetworkBehaviour)this).hasAuthority)
			{
				ShowTraitSelectionUI();
			}
			else if (NetworkServer.active && (Object)(object)((CharacterModComponent)this).GetCharacterBody() != (Object)null && (Object)(object)((CharacterModComponent)this).GetCharacterBody().master != (Object)null && (Object)(object)((CharacterModComponent)this).GetCharacterBody().master.playerCharacterMasterController == (Object)null)
			{
				CallCmdSetTrait(TraitBank.GetRandomTraitIndex(includeBanned: false));
			}
		}

		private void OnGUI()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (!MainPlugin.DEBUG_MODE || !((NetworkBehaviour)this).hasAuthority || !((CharacterModComponent)this).IsInit() || !IsTraitSelectionOpen())
			{
				return;
			}
			for (int i = 0; i < TraitBank.Traits.GetCount(); i++)
			{
				if (GUI.Button(new Rect(100f, (float)(100 + 30 * i), 100f, 30f), TraitBank.GetTrait(i).GetDisplayName()))
				{
					CallCmdSetTrait(i);
				}
			}
		}

		private void UNetVersion()
		{
		}

		protected static void InvokeCmdCmdSetTrait(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"Command CmdSetTrait called on client.");
			}
			else
			{
				((TraitHandler)(object)obj).CmdSetTrait((int)reader.ReadPackedUInt32());
			}
		}

		public void CallCmdSetTrait(int traitIndex)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"Command function CmdSetTrait called on server.");
				return;
			}
			if (((NetworkBehaviour)this).isServer)
			{
				CmdSetTrait(traitIndex);
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)5);
			val.WritePackedUInt32((uint)kCmdCmdSetTrait);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			val.WritePackedUInt32((uint)traitIndex);
			((NetworkBehaviour)this).SendCommandInternal(val, 0, "CmdSetTrait");
		}

		protected static void InvokeRpcRpcPromptTraitSelection(NetworkBehaviour obj, NetworkReader reader)
		{
			if (!NetworkClient.active)
			{
				Debug.LogError((object)"RPC RpcPromptTraitSelection called on server.");
			}
			else
			{
				((TraitHandler)(object)obj).RpcPromptTraitSelection();
			}
		}

		public void CallRpcPromptTraitSelection()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				Debug.LogError((object)"RPC Function RpcPromptTraitSelection called on client.");
				return;
			}
			NetworkWriter val = new NetworkWriter();
			val.Write((short)0);
			val.Write((short)2);
			val.WritePackedUInt32((uint)kRpcRpcPromptTraitSelection);
			val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
			((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcPromptTraitSelection");
		}

		static TraitHandler()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			kCmdCmdSetTrait = -1862245976;
			NetworkBehaviour.RegisterCommandDelegate(typeof(TraitHandler), kCmdCmdSetTrait, new CmdDelegate(InvokeCmdCmdSetTrait));
			kRpcRpcPromptTraitSelection = 6952788;
			NetworkBehaviour.RegisterRpcDelegate(typeof(TraitHandler), kRpcRpcPromptTraitSelection, new CmdDelegate(InvokeRpcRpcPromptTraitSelection));
			NetworkCRC.RegisterBehaviour("TraitHandler", 0);
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			bool flag = ((CharacterModComponent)this).OnSerialize(writer, forceAll);
			bool flag2 = default(bool);
			return flag2 || flag;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			((CharacterModComponent)this).OnDeserialize(reader, initialState);
		}
	}
	public static class Configuration
	{
		public static ConfigEntry<bool> EnableAnnouncer { get; set; }

		public static ConfigEntry<string> BannedAIMasters { get; set; }

		public static ConfigEntry<string> AdditionalBannedItemsAndEquipmentNames { get; set; }

		public static ConfigEntry<string> BannedTraits { get; set; }

		public static ConfigEntry<bool> EnableStunsAndShocksDuringDuels { get; set; }

		public static ConfigEntry<bool> EnableMusic { get; set; }

		public static ConfigEntry<float> HealingMultDuringDuels { get; set; }

		public static ConfigEntry<float> FarmingSpawnDelayInterval { get; set; }

		public static ConfigEntry<bool> EnableMajorityVotingForSkip { get; set; }

		public static void Initialise(BaseUnityPlugin baseUnityPlugin)
		{
			EnableAnnouncer = baseUnityPlugin.Config.Bind<bool>("Sound", "Enable Announcer Voice", true, "Enable/Disable Announcer voice lines!");
			EnableMusic = baseUnityPlugin.Config.Bind<bool>("Sound", "Enable Music", true, "Enable/Disable Music!");
			BannedAIMasters = baseUnityPlugin.Config.Bind<string>("Bans", "Ban AI Survivors", "", "DO NOT EDIT; You can edit this via an in-game option");
			AdditionalBannedItemsAndEquipmentNames = baseUnityPlugin.Config.Bind<string>("Bans", "Ban Items and Equipment", "", "DO NOT EDIT; You can edit this via an in-game option");
			BannedTraits = baseUnityPlugin.Config.Bind<string>("Bans", "Ban Traits", "", "DO NOT EDIT; You can edit this via an in-game option");
			EnableStunsAndShocksDuringDuels = baseUnityPlugin.Config.Bind<bool>("Gameplay", "Enable Stuns/Shocks During Duels", true, "Enable/Disable stuns/shocks during duels");
			HealingMultDuringDuels = baseUnityPlugin.Config.Bind<float>("Gameplay", "Healing Multiplier During Duels", 1f, "Multiplies the healing amount during duels (Both Regen & Non-Regen)");
			FarmingSpawnDelayInterval = baseUnityPlugin.Config.Bind<float>("Performance", "Farming Spawn Delay Interval", 0f, "The time delay between spawning each monster (in seconds) for the farming phase, if your game freezes when spawning in monsters, increase this value.");
			EnableMajorityVotingForSkip = baseUnityPlugin.Config.Bind<bool>("Tweaks", "Enable Majority Voting For Round Time Skipping", true, "Enable/Disable Majority Voting For Round Time Skipping");
		}
	}
	public class DuelIntroCamera : MonoBehaviour
	{
		private ForcedCamera m_forcedCamera;

		public static readonly float DUEL_INTRO_TIME = 5.8f;

		private AkAudioListener m_audioListener;

		private LTSeq m_currentDuelIntroSequence;

		public Transform GetCameraAnchorTransform()
		{
			return ((Component)m_forcedCamera).transform;
		}

		public void Start()
		{
			GameObject gameObject = ((Component)MainPlugin.FindTransformRecursive(((Component)this).transform, "CameraAnchor")).gameObject;
			m_forcedCamera = gameObject.AddComponent<ForcedCamera>();
			m_forcedCamera.allowUserHud = false;
			m_forcedCamera.allowUserLook = false;
			m_forcedCamera.entryLerpDuration = 0f;
			m_forcedCamera.exitLerpDuration = 1f;
			((Behaviour)m_forcedCamera).enabled = false;
			gameObject.AddComponent<AkGameObj>();
			m_audioListener = gameObject.AddComponent<AkAudioListener>();
			((Behaviour)m_audioListener).enabled = false;
		}

		private void Update()
		{
			if (!((Object)(object)NetworkedGameModeManager.instance != (Object)null))
			{
				return;
			}
			NetworkedGameModeData currentNetworkedGameModeData = NetworkedGameModeManager.instance.m_currentNetworkedGameModeData;
			bool flag = currentNetworkedGameModeData.IsDueling() && currentNetworkedGameModeData.IsIntroDuelActive();
			bool flag2 = (Object)(object)KingKombatArenaMainPlugin.s_cachedLocalCharacterMaster != (Object)null && currentNetworkedGameModeData.IsCharacterDueling(KingKombatArenaMainPlugin.s_cachedLocalCharacterMaster);
			((Behaviour)m_forcedCamera).enabled = flag && flag2;
			bool flag3 = currentNetworkedGameModeData.IsDueling() && !flag2;
			AkAudioListener component = ((Component)CameraRigController.readOnlyInstancesList[0].sceneCam).GetComponent<AkAudioListener>();
			if (((Behaviour)m_audioListener).enabled != flag3)
			{
				((Behaviour)m_audioListener).enabled = flag3;
				if ((Object)(object)component != (Object)null)
				{
					((Behaviour)component).enabled = !flag3;
				}
			}
			if (flag)
			{
				DoDuelIntroCameraAnimation();
			}
			if (!currentNetworkedGameModeData.IsIntroDuelActive() && m_currentDuelIntroSequence != null)
			{
				LeanTween.cancel(m_currentDuelIntroSequence.id);
				m_currentDuelIntroSequence = null;
			}
		}

		private void DoDuelIntroCameraAnimation()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			if (m_currentDuelIntroSequence != null)
			{
				return;
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, -0.2f, -1.2f);
			float num = DUEL_INTRO_TIME / 2f;
			m_currentDuelIntroSequence = LeanTween.sequence(true);
			for (int i = 0; i < 2; i++)
			{
				Vector3 duelist_Position = KingKombatArenaMainPlugin.GetCombatAreaSpawnPosition(i);
				duelist_Position.y = KingKombatArenaMainPlugin.COMBAT_AREA_POSITION.y;
				m_currentDuelIntroSequence.append((Action)delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					((Component)this).transform.position = duelist_Position;
				});
				m_currentDuelIntroSequence.append(LeanTween.moveLocal(((Component)m_forcedCamera).gameObject, val, 0f));
				m_currentDuelIntroSequence.append(LeanTween.moveLocalY(((Component)m_forcedCamera).gameObject, 0.4f, num));
			}
		}
	}
	public static class FarmingDataContainer
	{
		private static List<FarmingRoundData> s_farmingRoundDatas;

		public const int s_NUMBER_FARMING_ROUNDS_SET = 20;

		public static void SetupFarmingRounds()
		{
			if (s_farmingRoundDatas == null)
			{
				s_farmingRoundDatas = new List<FarmingRoundData>();
				FarmableMonsterData farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.beetle,
					count = 5u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(0, in farmableMonsterData);
				int num = 0 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.lesserWisp,
					count = 6u,
					moneyReward = 8u
				};
				AddFarmableMonsterData(num, in farmableMonsterData);
				int num2 = num + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.beetle,
					count = 4u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num2, in farmableMonsterData);
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.lesserWisp,
					count = 6u,
					moneyReward = 8u
				};
				AddFarmableMonsterData(num2, in farmableMonsterData);
				int num3 = num2 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.lemurian,
					count = 6u,
					moneyReward = 15u
				};
				AddFarmableMonsterData(num3, in farmableMonsterData);
				int num4 = num3 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.lemurian,
					count = 6u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num4, in farmableMonsterData);
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.lesserWisp,
					count = 4u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num4, in farmableMonsterData);
				int num5 = num4 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.golem,
					count = 2u,
					moneyReward = 50u
				};
				AddFarmableMonsterData(num5, in farmableMonsterData);
				int num6 = num5 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.lemurian,
					count = 10u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num6, in farmableMonsterData);
				int num7 = num6 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.golem,
					count = 4u,
					moneyReward = 50u
				};
				AddFarmableMonsterData(num7, in farmableMonsterData);
				int num8 = num7 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.jellyfish,
					count = 10u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num8, in farmableMonsterData);
				int num9 = num8 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.bossBeetleQueen,
					count = 1u,
					moneyReward = 150u
				};
				AddFarmableMonsterData(num9, in farmableMonsterData);
				SetFarmingRoundAsBoss(num9);
				int num10 = num9 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.imp,
					count = 6u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num10, in farmableMonsterData);
				int num11 = num10 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.imp,
					count = 6u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num11, in farmableMonsterData);
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.lemurian,
					count = 4u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num11, in farmableMonsterData);
				int num12 = num11 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.lesserWisp,
					count = 12u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num12, in farmableMonsterData);
				int num13 = num12 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.beetle,
					count = 6u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num13, in farmableMonsterData);
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.jellyfish,
					count = 4u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num13, in farmableMonsterData);
				int num14 = num13 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.bossVagrant,
					count = 1u,
					moneyReward = 200u
				};
				AddFarmableMonsterData(num14, in farmableMonsterData);
				SetFarmingRoundAsBoss(num14);
				int num15 = num14 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.vulture,
					count = 6u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num15, in farmableMonsterData);
				int num16 = num15 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.vulture,
					count = 6u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num16, in farmableMonsterData);
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.lesserWisp,
					count = 4u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num16, in farmableMonsterData);
				int num17 = num16 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.lemurian,
					count = 6u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num17, in farmableMonsterData);
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.jellyfish,
					count = 4u,
					moneyReward = 10u
				};
				AddFarmableMonsterData(num17, in farmableMonsterData);
				int num18 = num17 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.greaterWisp,
					count = 2u,
					moneyReward = 50u
				};
				AddFarmableMonsterData(num18, in farmableMonsterData);
				int num19 = num18 + 1;
				farmableMonsterData = new FarmableMonsterData
				{
					monsterSpawnCard = MonsterSpawnCards.bossTitanGolemPlains,
					count = 1u,
					moneyReward = 300u
				};
				AddFarmableMonsterData(num19, in farmableMonsterData);
				SetFarmingRoundAsBoss(num19);
				GenerateEliteFarmingRounds(Elites.Lightning, 1, 2u);
				GenerateEliteFarmingRounds(Elites.Ice, 2, 3u);
				GenerateEliteFarmingRounds(Elites.Fire, 3, 4u);
				GenerateEliteFarmingRounds(Elites.Haunted, 4, 5u);
				ValidateFarmingRounds();
			}
		}

		private static void GenerateEliteFarmingRounds(EliteDef eliteDef, int roundSetCount, uint countMult = 1u)
		{
			for (int i = 0; i < 20; i++)
			{
				for (int j = 0; j < s_farmingRoundDatas[i].farmableMonsterDatas.Count; j++)
				{
					FarmableMonsterData farmableMonsterData = s_farmingRoundDatas[i].farmableMonsterDatas[j];
					farmableMonsterData.eliteDef = eliteDef;
					farmableMonsterData.count *= countMult;
					AddFarmableMonsterData(roundSetCount * 20 + i, in farmableMonsterData);
				}
			}
		}

		private static void ValidateFarmingRounds()
		{
			if (!MainPlugin.DEBUG_MODE)
			{
				return;
			}
			int num = 0;
			foreach (FarmingRoundData s_farmingRoundData in s_farmingRoundDatas)
			{
				foreach (FarmableMonsterData farmableMonsterData in s_farmingRoundData.farmableMonsterDatas)
				{
					if ((Object)(object)farmableMonsterData.monsterSpawnCard == (Object)null)
					{
						MainPlugin.DebugError("ValidateFarmingRounds(); Invalid farmableMonsterData; monsterSpawnCard is NULL : s_farmingRoundDatas's Index =" + num);
					}
				}
				num++;
			}
		}

		private static void SetFarmingRoundAsBoss(int farmLevel)
		{
			s_farmingRoundDatas[farmLevel].isBossRound = true;
		}

		private static void AddFarmableMonsterData(int farmLevel, in FarmableMonsterData farmableMonsterData)
		{
			if (farmLevel >= s_farmingRoundDatas.Count)
			{
				s_farmingRoundDatas.Add(new FarmingRoundData());
			}
			s_farmingRoundDatas[farmLevel].farmableMonsterDatas.Add(farmableMonsterData);
		}

		public static FarmingRoundData GetCurrentFarmingRoundData(int farmingLevel)
		{
			if (farmingLevel < s_farmingRoundDatas.Count)
			{
				return s_farmingRoundDatas[farmingLevel];
			}
			return s_farmingRoundDatas[s_farmingRoundDatas.Count - 1];
		}
	}
	public static class MonsterSpawnCards
	{
		private const string spawnCardsPath = "spawncards/characterspawncards/";

		public static CharacterSpawnCard beetle = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("cscBeetle"));

		public static CharacterSpawnCard golem = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("cscGolem"));

		public static CharacterSpawnCard lemurian = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("cscLemurian"));

		public static CharacterSpawnCard lesserWisp = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("cscLesserWisp"));

		public static CharacterSpawnCard greaterWisp = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("cscGreaterWisp"));

		public static CharacterSpawnCard imp = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("cscImp"));

		public static CharacterSpawnCard vulture = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("cscVulture"));

		public static CharacterSpawnCard jellyfish = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("cscJellyfish"));

		public static CharacterSpawnCard bossVagrant = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("cscVagrant"));

		public static CharacterSpawnCard bossBeetleQueen = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("cscBeetleQueen"));

		public static CharacterSpawnCard bossTitanGolemPlains = LegacyResourcesAPI.Load<CharacterSpawnCard>(ConstructPath("titan/cscTitanGolemPlains"));

		private static string ConstructPath(string spawnCardFileName)
		{
			return "spawncards/characterspawncards/" + spawnCardFileName;
		}
	}
	public class FarmingRoundData
	{
		public List<FarmableMonsterData> farmableMonsterDatas = new List<FarmableMonsterData>();

		public bool isBossRound;

		public uint GetTotalMoneyReward()
		{
			uint num = 0u;
			foreach (FarmableMonsterData farmableMonsterData in farmableMonsterDatas)
			{
				num += farmableMonsterData.moneyReward * farmableMonsterData.count;
			}
			return num;
		}
	}
	public struct FarmableMonsterData
	{
		public CharacterSpawnCard monsterSpawnCard;

		public uint count;

		public uint moneyReward;

		public EliteDef eliteDef;
	}
	public struct OptionElement
	{
		public GameObject uiElementGO;

		public Func<string> valueFunc;
	}
	public enum EOptionType
	{
		PLUSMINUS,
		BUTTON,
		MAX
	}
	public class GameModeMenuUI
	{
		private GameObject m_characterSelectGO;

		private Button m_toggleButton;

		private Button m_optionsButton;

		private GameObject m_optionsPanelGO;

		private GameObject m_optionsScrollViewContentGO;

		private GameObject m_banPanelGO;

		private GameObject m_banScrollViewContentGO;

		private List<OptionElement> m_optionElements = new List<OptionElement>();

		private List<GameObject> m_banElements = new List<GameObject>();

		private GameObject m_warningPanel;

		private Text m_incompatibleModListText;

		private Button m_proceedButton;

		private Button m_returnButton;

		private Action m_unbanAllAction;

		public GameModeMenuUI(GameObject characterSelectGO)
		{
			m_characterSelectGO = characterSelectGO;
		}

		public void SetupUI()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_00af: 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_018b: Expected O, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Expected O, but got Unknown
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0706: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Expected O, but got Unknown
			//IL_07d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07de: Expected O, but got Unknown
			//IL_080b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0815: Expected O, but got Unknown
			GameObject val = UIManager.CreateUIElement(MainPlugin.FindTransformRecursive(m_characterSelectGO.transform, "ReadyPanel"), KingKombatArenaAssets.GameModeToggleButton_UIGO, (EHUDSkew)2);
			val.transform.localScale = new Vector3(5f, 5f, 1f);
			val.SetActive(true);
			m_toggleButton = val.GetComponentInChildren<Button>();
			((UnityEvent)m_toggleButton.onClick).AddListener((UnityAction)delegate
			{
				OnGameModeTogglePressed();
			});
			TooltipProvider obj = KingUtil.SetupTooltipProvider(((Component)m_toggleButton).gameObject);
			obj.titleToken = $"KING KOMBAT ARENA";
			obj.bodyToken = string.Format("Duke it out in round to round farming and dueling; buy chests to enhance your character; bet on the winner of duels and win big!\n\nThe last one standing is the victor!\n\nIf you win from Round {0} onwards, you will also earn {1}", 20.ToString("n0"), Util.GenerateColoredString("Lunar Coins!", ColorCatalog.GetColor((ColorIndex)12)));
			m_optionsPanelGO = ((Component)MainPlugin.FindTransformRecursive(val.transform, "OptionsPanel")).gameObject;
			m_optionsPanelGO.gameObject.SetActive(false);
			m_optionsScrollViewContentGO = ((Component)MainPlugin.FindTransformRecursive(m_optionsPanelGO.transform, "Content")).gameObject;
			m_banPanelGO = ((Component)MainPlugin.FindTransformRecursive(val.transform, "BanPanel")).gameObject;
			m_banPanelGO.gameObject.SetActive(false);
			m_banScrollViewContentGO = ((Component)MainPlugin.FindTransformRecursive(m_banPanelGO.transform, "Content")).gameObject;
			((UnityEvent)((Component)MainPlugin.FindTransformRecursive(m_banPanelGO.transform, "ReturnButton")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				m_banPanelGO.SetActive(false);
			});
			((UnityEvent)((Component)MainPlugin.FindTransformRecursive(m_banPanelGO.transform, "UnbanAllButton")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				m_unbanAllAction?.Invoke();
			});
			CreateOptionElement_PlusMinus("CPU COUNT", () => KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.aiCount.ToString("n0"), delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddAICount(1);
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddAICount(-1);
			});
			CreateOptionElement_PlusMinus("LIVES", () => KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.lifeCount.ToString("n0"), delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddLifeCount(1);
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddLifeCount(-1);
			});
			CreateOptionElement_PlusMinus("STARTING MONEY", () => KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.startingMoney.ToString("n0"), delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddStartingMoney(20);
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddStartingMoney(-20);
			});
			CreateOptionElement_PlusMinus("STARTING REROLLS", () => KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.rerollCount.ToString("n0"), delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddRerollCount(1);
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddRerollCount(-1);
			});
			TooltipProvider obj2 = KingUtil.SetupTooltipProvider(CreateOptionElement_PlusMinus("PEACE ROUNDS", () => KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.peaceRounds.ToString("n0"), delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddPeaceRounds(1);
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddPeaceRounds(-1);
			}));
			obj2.titleToken = $"PEACE ROUNDS";
			obj2.bodyToken = string.Format("Lives are not lost during peace rounds!\n" + Util.GenerateColoredString("Enabling this option increases the round requirement for earning lunar coins from winning", ColorCatalog.GetColor((ColorIndex)12)));
			TooltipProvider obj3 = KingUtil.SetupTooltipProvider(CreateOptionElement_PlusMinus("DUEL TIME LIMIT", () => KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.duelTimeLimit.ToString("n0") + " Seconds", delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddDuelTimeLimit(5f);
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddDuelTimeLimit(-5f);
			}));
			obj3.titleToken = $"DUEL TIME LIMIT";
			obj3.bodyToken = $"changing this will de-sync the final battle music";
			CreateOptionElement_PlusMinus("FARMING TIME LIMIT", () => KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.farmingTimeLimit.ToString("n0") + " Seconds", delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddFarmingTimeLimit(5f);
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddFarmingTimeLimit(-5f);
			});
			CreateOptionElement_PlusMinus("LOBBY WAIT TIME LIMIT", () => KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.lobbyWaitTimeLimit.ToString("n0") + " Seconds", delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddLobbyWaitTimeLimit(5f);
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddLobbyWaitTimeLimit(-5f);
			});
			TooltipProvider obj4 = KingUtil.SetupTooltipProvider(CreateOptionElement_PlusMinus("CPU DIFFICULTY", delegate
			{
				float hardAIMult = KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.hardAIMult;
				return (hardAIMult == 0f) ? "NORMAL" : ("+" + KingUtil.MultToPercent(hardAIMult).ToString("n0") + "%");
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddHardAIMult(0.5f);
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddHardAIMult(-0.5f);
			}));
			obj4.titleToken = $"CPU DIFFICULTY";
			obj4.bodyToken = string.Format("When you win a game, gain an additional {0} for every increase!", Util.GenerateColoredString("1 Lunar Coin", ColorCatalog.GetColor((ColorIndex)12)));
			TooltipProvider obj5 = KingUtil.SetupTooltipProvider(CreateOptionElement_PlusMinus("FARMING DIFFICULTY", delegate
			{
				float num = KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.farmingDifficulty;
				return (num == 0f) ? "NORMAL" : ("+" + KingUtil.MultToPercent(num * 0.25f).ToString("n0") + "%");
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddFarmingDifficulty(1);
			}, delegate
			{
				KingKombatArenaMainPlugin.s_kombatArenaRulesForSetup.AddFarmingDifficulty(-1);
			}));
			obj5.titleToken = $"FARMING DIFFICULTY";
			obj5.bodyToken = string.Format("Increase the difficulty of the farming rounds!\nGain an additional {0} for every increase!", Util.GenerateColoredString("1 Lunar Coin", ColorCatalog.GetColor((ColorIndex)12)));
			CreateOptionElement_Button("CPU SURVIVORS", "BAN", Color.red, delegate
			{
				m_banPanelGO.SetActive(!m_banPanelGO.activeInHierarchy);
				if (m_banPanelGO.activeInHierarchy)
				{
					RebuildBanElements_AISurvivor();
					m_unbanAllAction = (Action)Delegate.Combine(m_unbanAllAction, new Action(ClearAllAISurvivorBans));
				}
				else
				{
					m_unbanAllAction = (Action)Delegate.Remove(m_unbanAllAction, new Action(ClearAllAISurvivorBans));
				}
			});
			CreateOptionElement_Button("ITEMS AND EQUIPMENT", "BAN", Color.red, delegate
			{
				m_banPanelGO.SetActive(!m_banPanelGO.activeInHierarchy);
				if (m_banPanelGO.activeInHierarchy)
				{
					RebuildBanElements_ItemsAndEquipment();
					m_unbanAllAction = (Action)Delegate.Combine(m_unbanAllAction, new Action(ClearAllItemAndEquipmenBans));
				}
				else
				{
					m_unbanAllAction = (Action)Delegate.Combine(m_unbanAllAction, new Action(ClearAllItemAndEquipmenBans));
				}
			});
			CreateOptionElement_Button("TRAITS", "BAN", Color.red, delegate
			{
				m_banPanelGO.SetActive(!m_banPanelGO.activeInHierarchy);
				if (m_banPanelGO.activeInHierarchy)
				{
					RebuildBanElements_Traits();
					m_unbanAllAction = (Action)Delegate.Combine(m_unbanAllAction, new Action(ClearAllTraitBans));
				}
				else
				{
					m_unbanAllAction = (Action)Delegate.Combine(m_unbanAllAction, new Action(ClearAllTraitBans));
				}
			});
			m_optionsButton = ((Component)MainPlugin.FindTransformRecursive(val.transform, "OptionsButton")).GetComponent<Button>();
			((Component)m_optionsButton).gameObject.SetActive(false);
			((UnityEvent)m_optionsButton.onClick).AddListener((UnityAction)delegate
			{
				m_optionsPanelGO.SetActive(!m_optionsPanelGO.activeInHierarchy);
			});
			m_warningPanel = ((Component)MainPlugin.FindTransformRecursive(val.transform, "WarningPanel")).gameObject;
			m_warningPanel.SetActive(false);
			m_incompatibleModListText = ((Component)MainPlugin.FindTransformRecursive(val.transform, "ModListText")).GetComponent<Text>();
			m_proceedButton = ((Component)MainPlugin.FindTransformRecursive(val.transform, "ProceedButton")).GetComponent<Button>();
			((UnityEvent)m_proceedButton.onClick).AddListener((UnityAction)delegate
			{
				m_warningPanel.SetActive(false);
				SetGameModeActive(value: true);
			});
			m_returnButton = ((Component)MainPlugin.FindTransformRecursive(val.transform, "ReturnButton")).GetComponent<Button>();
			((UnityEvent)m_returnButton.onClick).AddListener((UnityAction)delegate
			{
				m_warningPanel.SetActive(false);
			});
			RefreshUI();
		}

		private void ClearAllAISurvivorBans()
		{
			Bans.ClearAllAISurvivorBans();
			RebuildBanElements_AISurvivor();
		}

		private void ClearAllItemAndEquipmenBans()
		{
			Bans.ClearAllItemAndEquipmenBans();
			RebuildBanElements_ItemsAndEquipment();
		}

		private void ClearAllTraitBans()
		{
			Bans.ClearAllTraitBans();
			RebuildBanElements_Traits();
		}

		private void SetGameModeActive(bool value)
		{
			KingKombatArenaMainPlugin.s_GAME_MODE_ACTIVE = value;
			RefreshUI();
		}

		private void OnGameModeTogglePressed()
		{
			List<string> incompatibleModsLoaded = KingKombatArenaMainPlugin.GetIncompatibleModsLoaded();
			bool flag = !KingKombatArenaMainPlugin.s_GAME_MODE_ACTIVE;
			if (incompatibleModsLoaded.Count == 0 || !flag)
			{
				SetGameModeActive(flag);
				return;
			}
			m_warningPanel.SetActive(true);
			string text = "";
			foreach (string item in incompatibleModsLoaded)
			{
				text = text + "- " + item + "\n";
			}
			m_incompatibleModListText.text = text;
		}

		public void RefreshUI()
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			((Component)m_optionsButton).gameObject.SetActive(KingKombatArenaMainPlugin.s_GAME_MODE_ACTIVE && NetworkServer.active);
			if (!KingKombatArenaMainPlugin.s_GAME_MODE_ACTIVE)
			{
				m_optionsPanelGO.SetActive(false);
				m_banPanelGO.SetActive(false);
			}
			if (!m_optionsPanelGO.gameObject.activeInHierarchy)
			{
				m_banPanelGO.SetActive(false);
			}
			Text component = ((Component)MainPlugin.FindTransformRecursive(((Component)m_toggleButton).transform, "EnableText")).GetComponent<Text>();
			component.text = (KingKombatArenaMainPlugin.s_GAME_MODE_ACTIVE ? "ENABLED" : "DISABLED");
			((Graphic)component).color = (KingKombatArenaMainPlugin.s_GAME_MODE_ACTIVE ? Color.green : Color.red);
			((Selectable)m_toggleButton).interactable = NetworkServer.active;
			RefreshOptionValueUI();
		}

		private void RefreshOptionValueUI()
		{
			foreach (OptionElement optionElement in m_optionElements)
			{
				((Component)MainPlugin.FindTransformRecursive(optionElement.uiElementGO.transform, "ValueText")).GetComponent<Text>().text = optionElement.valueFunc?.Invoke();
			}
		}

		private GameObject CreateOptionElement(string optionName, Func<string> valueRetreiveFunc, EOptionType optionType)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			int num = 86;
			int num2 = 85;
			int num3 = 30;
			GameObject val = null;
			switch (optionType)
			{
			case EOptionType.PLUSMINUS:
				val = KingKombatArenaAssets.OptionContainerPlusMinus_UIGO;
				break;
			case EOptionType.BUTTON:
				val = KingKombatArenaAssets.OptionContainerButton_UIGO;
				break;
			}
			GameObject val2 = UIManager.CreateUIElement(m_optionsScrollViewContentGO.transform, val, (EHUDSkew)2);
			val2.transform.localScale = new Vector3(5f, 5f, 1f);
			val2.SetActive(true);
			RectTransform component = m_optionsScrollViewContentGO.GetComponent<RectTransform>();
			((Component)MainPlugin.FindTransformRecursive(val2.transform, "TitleText")).GetComponent<Text>().text = optionName;
			m_optionElements.Add(new OptionElement
			{
				uiElementGO = val2,
				valueFunc = valueRetreiveFunc
			});
			Vector2 sizeDelta = component.sizeDelta;
			component.sizeDelta = new Vector2(sizeDelta.x, (float)(m_optionElements.Count * num));
			for (int i = 0; i < m_optionElements.Count; i++)
			{
				int num4 = -(num2 / 2) + i * -num2;
				m_optionElements[i].uiElementGO.transform.localPosition = new Vector3((float)num3, (float)num4, 120f);
			}
			RefreshOptionValueUI();
			return val2;
		}

		private GameObject CreateOptionElement_PlusMinus(string optionName, Func<string> valueRetreiveFunc, Action plusAction, Action minusAction)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			GameObject obj = CreateOptionElement(optionName, valueRetreiveFunc, EOptionType.PLUSMINUS);
			((UnityEvent)((Component)MainPlugin.FindTransformRecursive(obj.transform, "OptionPlusButton")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				plusAction();
				RefreshOptionValueUI();
			});
			((UnityEvent)((Component)MainPlugin.FindTransformRecursive(obj.transform, "OptionMinusButton")).GetComponent<Button>().onClick).AddListener((UnityAction)delegate
			{
				minusAction();
				RefreshOptionValueUI();
			});
			return obj;
		}

		private GameObject CreateOptionElement_Button(string optionName, string buttonNameText, Color buttonColor, Action onClickAction)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = CreateOptionElement(optionName, null, EOptionType.BUTTON);
			Button component = ((Component)MainPlugin.FindTransformRecursive(obj.transform, "Button")).GetComponent<Button>();
			((UnityEvent)component.onClick).AddListener((UnityAction)delegate
			{
				onClickAction();
				RefreshOptionValueUI();
			});
			((Graphic)((Selectable)component).image).color = buttonColor;
			((Component)MainPlugin.FindTransformRecursive(((Component)component).transform, "Text")).GetComponent<Text>().text = buttonNameText;
			return obj;
		}

		private void CleanUpBanElements()
		{
			foreach (GameObject banElement in m_banElements)
			{
				Object.Destroy((Object)(object)banElement);
			}
			m_banElements.Clear();
		}

		private bool ShouldHideItem(ItemDef itemDef)
		{
			if (!((Object)(object)itemDef.pickupIconSprite == (Object)null))
			{
				if ((Object)(ob