Decompiled source of Swap Bros v2.1.4

UMM/Mods/Swap Bros Mod/Swap Bros Mod.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BroMakerLib;
using BroMakerLib.CustomObjects.Bros;
using BroMakerLib.Infos;
using BroMakerLib.Loaders;
using BroMakerLib.Storages;
using HarmonyLib;
using UnityEngine;
using UnityModManagerNet;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Swap Bros Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Swap Bros Mod")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7b145b4b-2661-4412-bf74-4e2482c98898")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Swap_Bros_Mod;

public class HarmonyPatches
{
	[HarmonyPatch(typeof(Player), "SpawnHero")]
	private static class Player_SpawnHero_Patch
	{
		private static void Prefix(Player __instance, ref HeroType nextHeroType)
		{
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Invalid comparison between Unknown and I4
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Expected I4, but got Unknown
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Expected I4, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Invalid comparison between Unknown and I4
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Expected I4, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected I4, but got Unknown
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Expected I4, but got Unknown
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			if (!Main.enabled)
			{
				return;
			}
			try
			{
				if (Main.manualSpawn)
				{
					Main.manualSpawn = false;
					return;
				}
				int playerNum = __instance.playerNum;
				if (!Main.settings.alwaysChosen)
				{
					if (GameState.Instance.hardCoreMode && !Main.settings.ignoreCurrentUnlocked)
					{
						Main.CreateBroList();
					}
					if (Main.settings.filterBros && Main.brosRemoved && !GameModeController.IsHardcoreMode)
					{
						if (!Main.settings.ignoreForcedBros && (int)Map.MapData.forcedBro != 1000)
						{
							nextHeroType = (HeroType)(int)Map.MapData.forcedBro;
							int num = Main.currentBroList.IndexOf(Main.HeroTypeToString(nextHeroType));
							if (num == -1)
							{
								num = 0;
							}
							if (Main.settings.enableBromaker)
							{
								Main.DisableCustomBroSpawning(playerNum);
							}
							Main.settings.selGridInt[playerNum] = num;
							return;
						}
						if (!Main.settings.ignoreForcedBros && Map.MapData.forcedBros != null && Map.MapData.forcedBros.Count() > 0)
						{
							string text = Main.currentBroListUnseen[Random.Range(0, Main.currentBroListUnseen.Count())];
							nextHeroType = (HeroType)(int)Main.StringToHeroType(text);
							int num2 = Main.currentBroList.IndexOf(text);
							if (num2 == -1)
							{
								num2 = 0;
							}
							if (Main.settings.enableBromaker)
							{
								Main.DisableCustomBroSpawning(playerNum);
							}
							Main.settings.selGridInt[playerNum] = num2;
							return;
						}
						int num3 = 0;
						if (Main.settings.useVanillaBroSelection && Main.currentBroListUnseen.Count() > 0)
						{
							string name = string.Empty;
							if ((Object)(object)__instance.character != (Object)null)
							{
								if (!Main.settings.enableBromaker || !Main.CheckIfCustomBro(__instance.character, ref name))
								{
									name = Main.HeroTypeToString(__instance.character.heroType);
								}
								if (Main.currentBroListUnseen.Contains(name) && Main.currentBroListUnseen.Count() > 1)
								{
									Main.currentBroListUnseen.Remove(name);
								}
								else
								{
									name = string.Empty;
								}
							}
							num3 = Main.currentBroList.IndexOf(Main.currentBroListUnseen[Random.Range(0, Main.currentBroListUnseen.Count())]);
							if (name != string.Empty)
							{
								Main.currentBroListUnseen.Add(name);
							}
							if (num3 == -1)
							{
								num3 = 0;
							}
						}
						else
						{
							num3 = Random.Range(0, Main.currentBroList.Count());
						}
						if (Main.IsBroCustom(num3))
						{
							Main.MakeCustomBroSpawn(playerNum, Main.currentBroList[num3]);
							nextHeroType = (HeroType)0;
						}
						else
						{
							if (Main.settings.enableBromaker)
							{
								Main.DisableCustomBroSpawning(playerNum);
							}
							nextHeroType = (HeroType)(int)Main.StringToHeroType(Main.currentBroList[num3]);
						}
						Main.settings.selGridInt[playerNum] = num3;
					}
					else
					{
						Main.SetSelectedBro(__instance.playerNum, nextHeroType);
					}
				}
				else
				{
					if (!Main.settings.ignoreForcedBros && Map.MapData != null && ((int)Map.MapData.forcedBro != 1000 || (Map.MapData.forcedBros != null && Map.MapData.forcedBros.Count() > 0)))
					{
						return;
					}
					if (GameState.Instance.hardCoreMode && !Main.settings.ignoreCurrentUnlocked)
					{
						Main.CreateBroList();
						if (Main.settings.enableBromaker && Main.IsBroCustom(Main.settings.selGridInt[playerNum]))
						{
							Main.MakeCustomBroSpawn(playerNum, Main.GetSelectedBroName(playerNum));
							nextHeroType = (HeroType)0;
							return;
						}
						if (Main.settings.enableBromaker)
						{
							Main.DisableCustomBroSpawning(playerNum);
						}
						nextHeroType = (HeroType)(int)Main.GetSelectedBroHeroType(playerNum);
					}
					else if (Main.settings.enableBromaker && Main.IsBroCustom(Main.settings.selGridInt[playerNum]))
					{
						Main.MakeCustomBroSpawn(playerNum, Main.GetSelectedBroName(playerNum));
						nextHeroType = (HeroType)0;
					}
					else
					{
						if (Main.settings.enableBromaker)
						{
							Main.DisableCustomBroSpawning(playerNum);
						}
						nextHeroType = (HeroType)(int)Main.GetSelectedBroHeroType(playerNum);
					}
				}
			}
			catch (Exception ex)
			{
				Main.Log("Exception occurred while spawning bro: " + ex.ToString());
			}
		}

		private static void Postfix(Player __instance, ref HeroType nextHeroType)
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			if (!Main.enabled)
			{
				return;
			}
			if (Main.settings.enableBromaker)
			{
				Main.EnableCustomBroSpawning();
				string name = "";
				if (Main.CheckIfCustomBro(__instance.character, ref name))
				{
					if (name != Main.GetSelectedBroName(__instance.playerNum))
					{
						Main.settings.selGridInt[__instance.playerNum] = Main.currentBroList.IndexOf(name);
						if (Main.settings.selGridInt[__instance.playerNum] == -1)
						{
							Main.CreateBroList();
							Main.settings.selGridInt[__instance.playerNum] = Main.currentBroList.IndexOf(name);
						}
					}
					Main.currentBroListUnseen.Remove(name);
				}
				else
				{
					Main.currentBroListUnseen.Remove(Main.HeroTypeToString(nextHeroType));
				}
			}
			else
			{
				Main.currentBroListUnseen.Remove(Main.HeroTypeToString(nextHeroType));
			}
			if (Main.currentBroListUnseen.Count() != 0)
			{
				return;
			}
			if (!Main.settings.ignoreForcedBros && Map.MapData != null && Map.MapData.forcedBros != null && Map.MapData.forcedBros.Count > 0)
			{
				Main.currentBroListUnseen.Clear();
				for (int i = 0; i < Map.MapData.forcedBros.Count(); i++)
				{
					Main.currentBroListUnseen.Add(Main.HeroTypeToString(Map.MapData.forcedBros[i]));
				}
			}
			else
			{
				Main.currentBroListUnseen.AddRange(Main.currentBroList);
			}
		}
	}

	[HarmonyPatch(typeof(Player), "GetInput")]
	private static class Player_GetInput_Patch
	{
		public static void Postfix(Player __instance)
		{
			if (!Main.enabled)
			{
				return;
			}
			int playerNum = __instance.playerNum;
			bool flag = Main.wasKeyPressed(Main.settings.swapLeftKeys[__instance.playerNum]);
			bool flag2 = Main.wasKeyPressed(Main.settings.swapRightKeys[__instance.playerNum]);
			if (((!(flag || flag2) || Main.cooldown != 0f || !__instance.IsAlive()) && (!Main.settings.clickingEnabled || !Main.switched[playerNum])) || !((Object)(object)__instance.character.pilottedUnit == (Object)null))
			{
				return;
			}
			if (Main.settings.clickingEnabled && Main.switched[playerNum])
			{
				Main.SwapToSpecificBro(playerNum, Main.settings.selGridInt[playerNum]);
				Main.switched[playerNum] = false;
				return;
			}
			Main.EnsureBroListUpdated();
			int num = Main.settings.selGridInt[playerNum];
			if (flag)
			{
				num--;
				if (num < 0)
				{
					num = Main.maxBroNum;
				}
			}
			else if (flag2)
			{
				num++;
				if (num > Main.maxBroNum)
				{
					num = 0;
				}
			}
			if (Main.SwapToSpecificBro(playerNum, num))
			{
				Main.cooldown = Main.settings.swapCoolDown;
			}
		}
	}

	[HarmonyPatch(typeof(Player), "Update")]
	private static class Player_Update_Patch
	{
		private static void Prefix(Player __instance)
		{
			if (Main.enabled && Main.cooldown > 0f)
			{
				__instance.character.SetInvulnerable(0f, false, false);
				Main.cooldown -= Time.unscaledDeltaTime;
				if (Main.cooldown < 0f)
				{
					Main.cooldown = 0f;
				}
			}
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "SetInvulnerable")]
	private static class TestVanDammeAnim_SetInvulnerable_Patch
	{
		private static bool Prefix(TestVanDammeAnim __instance, float time, bool restartBubble = true)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (time == 0f && !restartBubble)
			{
				Traverse.Create(typeof(TestVanDammeAnim)).Field("invulnerableTime").SetValue((object)0);
				((Unit)__instance).invulnerable = false;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Map), "Awake")]
	private static class Map_Awake_Patch
	{
		private static void Postfix()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (!Main.enabled)
			{
				return;
			}
			Main.currentBroListUnseen.Clear();
			if (!Main.settings.ignoreForcedBros && Map.MapData != null && Map.MapData.forcedBros != null && Map.MapData.forcedBros.Count > 0)
			{
				Main.currentBroListUnseen.Clear();
				for (int i = 0; i < Map.MapData.forcedBros.Count(); i++)
				{
					Main.currentBroListUnseen.Add(Main.HeroTypeToString(Map.MapData.forcedBros[i]));
				}
			}
			else
			{
				Main.currentBroListUnseen.AddRange(Main.currentBroList);
			}
		}
	}
}
public enum DPAD
{
	LEFT,
	RIGHT,
	UP,
	DOWN,
	NONE
}
public class KeyBind
{
	public KeyCode kc;

	public bool waitingForInput;

	public string DPADString = "NONE";

	public DPAD DPADKey = DPAD.NONE;

	public string joystick = "NONE";
}
public static class Main
{
	[CompilerGenerated]
	private sealed class <BindKey>d__33 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public KeyBind kb;

		private KeyCode[] <keyCodes>5__2;

		private bool <exit>5__3;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<keyCodes>5__2 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Invalid comparison between Unknown and I4
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				InputReader.IsBlocked = true;
				<>2__current = (object)new WaitForSeconds(0.2f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<keyCodes>5__2 = Enum.GetValues(typeof(KeyCode)).Cast<KeyCode>().ToArray();
				<exit>5__3 = false;
				break;
			case 2:
				<>1__state = -1;
				break;
			}
			if (!<exit>5__3)
			{
				KeyCode[] array = <keyCodes>5__2;
				foreach (KeyCode val in array)
				{
					if (Input.GetKeyUp(val))
					{
						if ((int)val == 127)
						{
							kb.kc = (KeyCode)0;
						}
						else
						{
							kb.kc = val;
						}
						kb.waitingForInput = false;
						kb.DPADKey = DPAD.NONE;
						<exit>5__3 = true;
					}
				}
				CheckDPADDirection(ref kb);
				if (kb.DPADKey != DPAD.NONE)
				{
					kb.kc = (KeyCode)0;
					kb.waitingForInput = false;
					<exit>5__3 = true;
				}
				<>2__current = null;
				<>1__state = 2;
				return true;
			}
			InputReader.IsBlocked = false;
			return false;
		}

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

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

	public static ModEntry mod;

	public static bool enabled;

	public static float cooldown = 0f;

	public static Settings settings;

	public static int currentCharIndex = 0;

	public static bool[] switched = new bool[4];

	public static bool manualSpawn = false;

	public static bool creatingBroList = false;

	public static List<string> allNormal = new List<string>
	{
		"Rambro", "Brommando", "B. A. Broracus", "Brodell Walker", "Bro Hard", "MacBrover", "Brade", "Bro Dredd", "Bro In Black", "Snake Broskin",
		"Brominator", "Brobocop", "Indiana Brones", "Ash Brolliams", "Mr. Anderbro", "The Boondock Bros", "Brochete", "Bronan the Brobarian", "Ellen Ripbro", "Time Bro",
		"Broniversal Soldier", "Colonel James Broddock", "Cherry Broling", "Bro Max", "The Brode", "Double Bro Seven", "The Brodator", "The Brocketeer", "Broheart", "The Brofessional",
		"Broden", "The Brolander", "Dirty Brory", "Tank Bro", "Bro Lee", "Seth Brondle", "Xebro", "Desperabro", "Broffy the Vampire Slayer", "Burt Brommer",
		"Demolition Bro"
	};

	public static List<string> allExpendabros = new List<string> { "Broney Ross", "Lee Broxmas", "Bronnar Jensen", "Bro Caesar", "Trent Broser", "Broctor Death", "Toll Broad" };

	public static List<string> allUnfinished = new List<string> { "Chev Brolios", "Casey Broback", "The Scorpion Bro" };

	public static List<string> allCustomBros = new List<string>();

	public static List<string> actuallyAllCustomBros = new List<string>();

	public static List<string> allBros = new List<string>();

	public static int numCustomBros = 0;

	public static List<string> currentBroList = new List<string>();

	public static List<string> currentBroListUnseen = new List<string>();

	public static string[] broList;

	public static string[] previousSelection = new string[4] { "", "", "", "" };

	public static int maxBroNum = 40;

	public static bool isHardcore = false;

	public static bool changingEnabledBros = false;

	public static float displayWarningTime = 0f;

	public static bool[] filteredBroList;

	public static bool brosRemoved = false;

	public static GUIStyle buttonStyle;

	public static GUIStyle warningStyle;

	public static float cachedFilterWidth = 0f;

	public static string[] axis6 = new string[4] { "Joy1 Axis 6", "Joy2 Axis 6", "Joy3 Axis 6", "Joy4 Axis 6" };

	public static string[] axis7 = new string[4] { "Joy1 Axis 7", "Joy2 Axis 7", "Joy3 Axis 7", "Joy4 Axis 7" };

	private static bool Load(ModEntry modEntry)
	{
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Expected O, but got Unknown
		modEntry.OnGUI = OnGUI;
		modEntry.OnSaveGUI = OnSaveGUI;
		modEntry.OnToggle = OnToggle;
		settings = ModSettings.Load<Settings>(modEntry);
		if (settings.selGridInt.Length < 4)
		{
			settings.selGridInt = new int[4];
		}
		Harmony val = new Harmony(modEntry.Info.Id);
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		mod = modEntry;
		try
		{
			val.PatchAll(executingAssembly);
		}
		catch (Exception ex)
		{
			mod.Logger.Error(ex.ToString());
		}
		if (settings.enableBromakerDefault && !settings.enableBromaker)
		{
			try
			{
				LoadCustomBros();
				settings.enableBromaker = true;
			}
			catch
			{
				settings.enableBromaker = false;
			}
		}
		else if (settings.enableBromaker)
		{
			try
			{
				LoadCustomBros();
			}
			catch
			{
				Log("BroMaker is not installed.");
				settings.enableBromaker = false;
			}
		}
		int[] array = new int[4];
		settings.selGridInt.CopyTo(array, 0);
		CreateBroList();
		settings.selGridInt = array;
		if (settings.enabledBros == null || settings.enabledBros.Count() == 0)
		{
			allBros = new List<string>();
			allBros.AddRange(allNormal);
			if (settings.includeExpendabros)
			{
				allBros.AddRange(allExpendabros);
			}
			if (settings.includeUnfinishedCharacters)
			{
				allBros.AddRange(allUnfinished);
			}
			if (settings.enableBromaker)
			{
				allBros.AddRange(allCustomBros);
			}
			settings.enabledBros = new List<string>(allBros);
			filteredBroList = Enumerable.Repeat(element: true, allBros.Count()).ToArray();
		}
		return true;
	}

	private static void OnGUI(ModEntry modEntry)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: 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_0078: 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)
		//IL_0547: Unknown result type (might be due to invalid IL or missing references)
		//IL_0560: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Expected O, but got Unknown
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0576: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Expected O, but got Unknown
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Expected O, but got Unknown
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Invalid comparison between Unknown and I4
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Expected O, but got Unknown
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0336: Expected O, but got Unknown
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Expected O, but got Unknown
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0384: Expected O, but got Unknown
		//IL_072e: Unknown result type (might be due to invalid IL or missing references)
		//IL_073e: Expected O, but got Unknown
		//IL_0407: Unknown result type (might be due to invalid IL or missing references)
		//IL_0420: Expected O, but got Unknown
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_0463: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: Expected O, but got Unknown
		//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ce: Expected O, but got Unknown
		//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0803: Expected O, but got Unknown
		//IL_0870: Unknown result type (might be due to invalid IL or missing references)
		//IL_085f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0896: Expected O, but got Unknown
		//IL_0924: Unknown result type (might be due to invalid IL or missing references)
		//IL_0929: Unknown result type (might be due to invalid IL or missing references)
		//IL_096e: Unknown result type (might be due to invalid IL or missing references)
		//IL_098b: Expected O, but got Unknown
		//IL_0a41: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a1e: Unknown result type (might be due to invalid IL or missing references)
		if (buttonStyle == null)
		{
			buttonStyle = new GUIStyle(GUI.skin.button);
			buttonStyle.normal.textColor = Color.red;
			buttonStyle.hover.textColor = Color.red;
			buttonStyle.active.textColor = Color.red;
			buttonStyle.onHover.textColor = Color.green;
			buttonStyle.onNormal.textColor = Color.green;
			buttonStyle.onActive.textColor = Color.green;
		}
		if (warningStyle == null)
		{
			warningStyle = new GUIStyle(GUI.skin.label);
			warningStyle.normal.textColor = Color.red;
			warningStyle.hover.textColor = Color.red;
			warningStyle.active.textColor = Color.red;
			warningStyle.onHover.textColor = Color.red;
			warningStyle.onNormal.textColor = Color.red;
			warningStyle.onActive.textColor = Color.red;
		}
		if (isHardcore != GameModeController.IsHardcoreMode)
		{
			isHardcore = GameModeController.IsHardcoreMode;
			if (!settings.ignoreCurrentUnlocked)
			{
				CreateBroList();
			}
		}
		if (settings.enableBromaker && CustomCountChanged() && (!GameModeController.IsHardcoreMode || settings.ignoreCurrentUnlocked))
		{
			LoadCustomBros();
			CreateBroList();
		}
		if (cachedFilterWidth <= 0f)
		{
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			Rect rect = GUILayoutUtility.GetRect(0f, 0f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if ((int)Event.current.type == 7 && ((Rect)(ref rect)).width > 1f)
			{
				cachedFilterWidth = ((Rect)(ref rect)).width - 25f;
			}
			GUILayout.EndHorizontal();
			return;
		}
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
		settings.clickingEnabled = GUILayout.Toggle(settings.clickingEnabled, new GUIContent("Clicking a new bro causes swap", "Clicking a bro in the menu below will swap you to that bro immediately"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
		if (settings.filterBros != (settings.filterBros = GUILayout.Toggle(settings.filterBros, new GUIContent("Filter Bros", "Only spawn as enabled characters"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })))
		{
			CreateBroList();
		}
		settings.ignoreForcedBros = GUILayout.Toggle(settings.ignoreForcedBros, new GUIContent("Ignore Forced Bros", "Controls whether levels which force you to use specific bros can be overidden by filtering or always spawn as chosen."), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
		Rect lastRect = GUILayoutUtility.GetLastRect();
		((Rect)(ref lastRect)).y = ((Rect)(ref lastRect)).y + 20f;
		((Rect)(ref lastRect)).width = ((Rect)(ref lastRect)).width + 700f;
		GUI.Label(lastRect, GUI.tooltip);
		GUILayout.EndVertical();
		GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
		settings.alwaysChosen = GUILayout.Toggle(settings.alwaysChosen, new GUIContent("Always spawn as chosen bro", "Prevents restarting a level or collecting a new bro from swapping to a new character"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
		bool ignoreCurrentUnlocked = settings.ignoreCurrentUnlocked;
		if (settings.ignoreCurrentUnlocked)
		{
			settings.ignoreCurrentUnlocked = GUILayout.Toggle(settings.ignoreCurrentUnlocked, new GUIContent("Ignore currently unlocked bros in IronBro", "Enabled: In IronBro you can switch to any bro regardless of who you have collected"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
		}
		else
		{
			settings.ignoreCurrentUnlocked = GUILayout.Toggle(settings.ignoreCurrentUnlocked, new GUIContent("Ignore currently unlocked bros in IronBro", "Disabled: In IronBro you can only switch to bros you have collected"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
		}
		if (ignoreCurrentUnlocked != settings.ignoreCurrentUnlocked && isHardcore)
		{
			CreateBroList();
		}
		settings.useVanillaBroSelection = GUILayout.Toggle(settings.useVanillaBroSelection, new GUIContent("Use Vanilla Randomization", settings.useVanillaBroSelection ? "Enabled: When filtering bros, prioritize bros that you haven't played yet on this level" : "Disabled: When filtering bros, choose completely randomly from the enabled bros"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
		GUI.Label(lastRect, GUI.tooltip);
		GUILayout.EndVertical();
		GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
		if (settings.includeExpendabros != (settings.includeExpendabros = GUILayout.Toggle(settings.includeExpendabros, new GUIContent("Include Expendabro Bros", "Include bros from Expendabros"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })))
		{
			CreateBroList();
			CreateFilteredBroList();
		}
		if (settings.enableBromaker != (settings.enableBromaker = GUILayout.Toggle(settings.enableBromaker, new GUIContent("Include BroMaker Bros", "Shows custom bros installed with BroMaker"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })))
		{
			settings.enableBromakerDefault = false;
			if (settings.enableBromaker)
			{
				try
				{
					LoadCustomBros();
					CreateBroList();
					CreateFilteredBroList();
				}
				catch
				{
					Log("BroMaker is not installed.");
					settings.enableBromaker = false;
				}
			}
			else
			{
				CreateBroList();
				CreateFilteredBroList();
			}
		}
		if (settings.includeUnfinishedCharacters != (settings.includeUnfinishedCharacters = GUILayout.Toggle(settings.includeUnfinishedCharacters, new GUIContent("Include Unfinished Bros", "Include bros the developers didn't finish"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) })))
		{
			CreateBroList();
			CreateFilteredBroList();
		}
		GUI.Label(lastRect, GUI.tooltip);
		string tooltip = GUI.tooltip;
		GUILayout.EndVertical();
		GUILayout.EndHorizontal();
		GUILayout.Space(30f);
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.Label($"Cooldown between swaps: {settings.swapCoolDown:0.00}s", (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Width(225f),
			GUILayout.ExpandWidth(false)
		});
		settings.swapCoolDown = GUILayout.HorizontalSlider(settings.swapCoolDown, 0f, 2f, (GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.EndHorizontal();
		GUILayout.Space(20f);
		GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
		GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
		for (int i = 0; i < 4; i++)
		{
			if (GUILayout.Button("Player " + (i + 1) + " Options - " + (settings.showSettings[i] ? "Hide" : "Show"), (GUILayoutOption[])(object)new GUILayoutOption[0]))
			{
				settings.showSettings[i] = !settings.showSettings[i];
			}
			if (!settings.showSettings[i])
			{
				continue;
			}
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (GUILayout.Button(new GUIContent("Swap Bro Left: " + (settings.swapLeftKeys[i].waitingForInput ? "Press Any Key/Button" : ((settings.swapLeftKeys[i].DPADKey == DPAD.NONE) ? ((object)(KeyCode)(ref settings.swapLeftKeys[i].kc)).ToString() : ("DPAD " + settings.swapLeftKeys[i].DPADString))), "Set a key for swapping bros, or press Delete to unbind"), (GUILayoutOption[])(object)new GUILayoutOption[0]) && !InputReader.IsBlocked)
			{
				settings.swapLeftKeys[i].waitingForInput = true;
				((MonoBehaviour)UI.Instance).StartCoroutine(BindKey(settings.swapLeftKeys[i], i));
			}
			if (GUILayout.Button(new GUIContent("Swap Bro Right: " + (settings.swapRightKeys[i].waitingForInput ? "Press Any Key/Button" : ((settings.swapRightKeys[i].DPADKey == DPAD.NONE) ? ((object)(KeyCode)(ref settings.swapRightKeys[i].kc)).ToString() : ("DPAD " + settings.swapRightKeys[i].DPADString))), "Set a key for swapping bros, or press Delete to unbind"), (GUILayoutOption[])(object)new GUILayoutOption[0]) && !InputReader.IsBlocked)
			{
				settings.swapRightKeys[i].waitingForInput = true;
				((MonoBehaviour)UI.Instance).StartCoroutine(BindKey(settings.swapRightKeys[i], i));
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (GUILayout.Button(changingEnabledBros ? new GUIContent("Save Changes", "") : new GUIContent("Enter Filtering Mode", "Enable or disable bros for all players"), (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(false),
				GUILayout.Width(300f)
			}))
			{
				changingEnabledBros = !changingEnabledBros;
				if (changingEnabledBros)
				{
					displayWarningTime = 0f;
					settings.filterBros = true;
					CreateFilteredBroList();
				}
				else
				{
					bool flag = false;
					for (int j = 0; j < filteredBroList.Length; j++)
					{
						if (filteredBroList[j])
						{
							flag = true;
							break;
						}
					}
					if (flag)
					{
						displayWarningTime = 0f;
						UpdateFilteredBroList();
						CreateBroList();
					}
					else
					{
						displayWarningTime = 10f;
						changingEnabledBros = !changingEnabledBros;
					}
				}
			}
			lastRect = GUILayoutUtility.GetLastRect();
			((Rect)(ref lastRect)).y = ((Rect)(ref lastRect)).y + 20f;
			((Rect)(ref lastRect)).width = ((Rect)(ref lastRect)).width + 700f;
			if (!changingEnabledBros)
			{
				GUILayout.FlexibleSpace();
				if (GUILayout.Button(new GUIContent(settings.sortingMethodName, "Change the sorting used for displaying the bro list"), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }))
				{
					switch (settings.sorting)
					{
					case SortingMethod.UnlockOrder:
						settings.sorting = SortingMethod.AlphabeticalAZ;
						settings.sortingMethodName = "Sorting Method: Alphabetical A-Z";
						break;
					case SortingMethod.AlphabeticalAZ:
						settings.sorting = SortingMethod.AlphabeticalZA;
						settings.sortingMethodName = "Sorting Method: Alphabetical Z-A";
						break;
					case SortingMethod.AlphabeticalZA:
						settings.sorting = SortingMethod.UnlockOrder;
						settings.sortingMethodName = "Sorting Method: Unlock Order";
						break;
					}
					CreateBroList();
				}
			}
			if (displayWarningTime <= 0f)
			{
				if (!GUI.tooltip.Equals(tooltip))
				{
					GUI.Label(lastRect, GUI.tooltip);
				}
				tooltip = GUI.tooltip;
			}
			else
			{
				displayWarningTime -= Time.unscaledDeltaTime;
				GUI.Label(lastRect, "Must have at least one bro enabled", warningStyle);
				tooltip = GUI.tooltip;
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(25f);
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (!creatingBroList)
			{
				if (changingEnabledBros)
				{
					int num = 5;
					int num2 = allBros.Count();
					float num3 = cachedFilterWidth / (float)num;
					GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
					GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
					for (int k = 0; k < num2; k++)
					{
						if (k % num == 0)
						{
							GUILayout.EndHorizontal();
							GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
						}
						filteredBroList[k] = GUILayout.Toggle(filteredBroList[k], allBros[k], buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
						{
							GUILayout.Height(26f),
							GUILayout.Width(num3)
						});
					}
					GUILayout.EndHorizontal();
					GUILayout.Space(20f);
					GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
					if (GUILayout.Button("Select All", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) }))
					{
						for (int l = 0; l < filteredBroList.Length; l++)
						{
							filteredBroList[l] = true;
						}
					}
					if (GUILayout.Button("Unselect All", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(200f) }))
					{
						for (int m = 0; m < filteredBroList.Length; m++)
						{
							filteredBroList[m] = false;
						}
					}
					GUILayout.EndHorizontal();
					GUILayout.EndVertical();
				}
				else
				{
					if (settings.selGridInt[i] < 0 || settings.selGridInt[i] >= broList.Length)
					{
						settings.selGridInt[i] = 0;
					}
					if (settings.selGridInt[i] <= maxBroNum)
					{
						if (settings.clickingEnabled)
						{
							if (settings.selGridInt[i] != (settings.selGridInt[i] = GUILayout.SelectionGrid(settings.selGridInt[i], broList, 5, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f * Mathf.Ceil((float)broList.Length / 5f)) })) && (Object)(object)Map.Instance != (Object)null)
							{
								switched[i] = true;
							}
						}
						else
						{
							settings.selGridInt[i] = GUILayout.SelectionGrid(settings.selGridInt[i], broList, 5, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f * Mathf.Ceil((float)broList.Length / 5f)) });
						}
					}
					else
					{
						CreateBroList();
					}
				}
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(10f);
		}
		GUILayout.EndVertical();
		GUILayout.EndHorizontal();
	}

	public static void CheckDPADDirection(ref KeyBind kb)
	{
		for (int i = 0; i < 4; i++)
		{
			float axis = Input.GetAxis(axis6[i]);
			float axis2 = Input.GetAxis(axis7[i]);
			if ((double)axis < -0.8)
			{
				kb.DPADString = "Joy" + (i + 1) + " LEFT";
				kb.DPADKey = DPAD.LEFT;
				kb.joystick = "Joy" + (i + 1) + " Axis 6";
				return;
			}
			if ((double)axis > 0.8)
			{
				kb.DPADString = "Joy" + (i + 1) + " RIGHT";
				kb.DPADKey = DPAD.RIGHT;
				kb.joystick = "Joy" + (i + 1) + " Axis 6";
				return;
			}
			if ((double)axis2 < -0.8)
			{
				kb.DPADString = "Joy" + (i + 1) + " DOWN";
				kb.DPADKey = DPAD.DOWN;
				kb.joystick = "Joy" + (i + 1) + " Axis 7";
				return;
			}
			if ((double)axis2 > 0.8)
			{
				kb.DPADString = "Joy" + (i + 1) + " UP";
				kb.DPADKey = DPAD.UP;
				kb.joystick = "Joy" + (i + 1) + " Axis 7";
				return;
			}
		}
		kb.DPADString = "NONE";
		kb.DPADKey = DPAD.NONE;
		kb.joystick = "NONE";
	}

	private static IEnumerator BindKey(KeyBind kb, int player)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <BindKey>d__33(0)
		{
			kb = kb
		};
	}

	public static bool wasKeyPressed(KeyBind kb)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		if ((int)kb.kc != 0)
		{
			return Input.GetKeyUp(kb.kc);
		}
		if (kb.DPADKey != DPAD.NONE)
		{
			float axis = Input.GetAxis(kb.joystick);
			if (!((double)axis < -0.8) || (kb.DPADKey != 0 && kb.DPADKey != DPAD.DOWN))
			{
				if ((double)axis > 0.8)
				{
					if (kb.DPADKey != DPAD.RIGHT)
					{
						return kb.DPADKey == DPAD.DOWN;
					}
					return true;
				}
				return false;
			}
			return true;
		}
		return false;
	}

	private static void OnSaveGUI(ModEntry modEntry)
	{
		((ModSettings)settings).Save(modEntry);
	}

	private static bool OnToggle(ModEntry modEntry, bool value)
	{
		enabled = value;
		return true;
	}

	public static void Log(string str)
	{
		mod.Logger.Log(str);
	}

	public static void CreateBroList()
	{
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		creatingBroList = true;
		brosRemoved = false;
		if (currentBroList != null)
		{
			for (int i = 0; i < 4; i++)
			{
				if (settings.selGridInt[i] > 0 && settings.selGridInt[i] < currentBroList.Count())
				{
					previousSelection[i] = currentBroList[settings.selGridInt[i]];
				}
			}
		}
		if (GameModeController.IsHardcoreMode && !settings.ignoreCurrentUnlocked)
		{
			currentBroList = new List<string>();
			for (int j = 0; j < GameState.Instance.currentWorldmapSave.hardcoreModeAvailableBros.Count(); j++)
			{
				currentBroList.Add(HeroTypeToString(GameState.Instance.currentWorldmapSave.hardcoreModeAvailableBros[j]));
			}
			if (settings.enableBromaker)
			{
				LoadCustomBros();
				if (OnlyCustomBrosInHardcore())
				{
					currentBroList.Clear();
				}
				currentBroList.AddRange(allCustomBros);
			}
		}
		else if (settings.filterBros && settings.enabledBros.Count() > 0)
		{
			currentBroList = new List<string>();
			for (int k = 0; k < allNormal.Count(); k++)
			{
				if (settings.enabledBros.Contains(allNormal[k]))
				{
					currentBroList.Add(allNormal[k]);
				}
				else
				{
					brosRemoved = true;
				}
			}
			if (settings.includeExpendabros)
			{
				for (int l = 0; l < allExpendabros.Count(); l++)
				{
					if (settings.enabledBros.Contains(allExpendabros[l]))
					{
						currentBroList.Add(allExpendabros[l]);
					}
					else
					{
						brosRemoved = true;
					}
				}
			}
			if (settings.includeUnfinishedCharacters)
			{
				for (int m = 0; m < allUnfinished.Count(); m++)
				{
					if (settings.enabledBros.Contains(allUnfinished[m]))
					{
						currentBroList.Add(allUnfinished[m]);
					}
					else
					{
						brosRemoved = true;
					}
				}
			}
			if (settings.enableBromaker)
			{
				for (int n = 0; n < allCustomBros.Count(); n++)
				{
					if (settings.enabledBros.Contains(allCustomBros[n]))
					{
						currentBroList.Add(allCustomBros[n]);
					}
					else
					{
						brosRemoved = true;
					}
				}
			}
		}
		else
		{
			currentBroList = new List<string>();
			currentBroList.AddRange(allNormal);
			if (settings.includeExpendabros)
			{
				currentBroList.AddRange(allExpendabros);
			}
			if (settings.includeUnfinishedCharacters)
			{
				currentBroList.AddRange(allUnfinished);
			}
			if (settings.enableBromaker)
			{
				currentBroList.AddRange(allCustomBros);
			}
		}
		maxBroNum = currentBroList.Count() - 1;
		if (settings.sorting == SortingMethod.AlphabeticalAZ)
		{
			currentBroList.Sort();
		}
		else if (settings.sorting == SortingMethod.AlphabeticalZA)
		{
			currentBroList.Sort();
			currentBroList.Reverse();
		}
		broList = currentBroList.ToArray();
		for (int num = 0; num < 4; num++)
		{
			settings.selGridInt[num] = currentBroList.IndexOf(previousSelection[num]);
			if (settings.selGridInt[num] == -1)
			{
				settings.selGridInt[num] = 0;
			}
		}
		currentBroListUnseen.Clear();
		currentBroListUnseen.AddRange(currentBroList);
		creatingBroList = false;
	}

	public static void CreateFilteredBroList()
	{
		allBros = new List<string>();
		allBros.AddRange(allNormal);
		if (settings.includeExpendabros)
		{
			allBros.AddRange(allExpendabros);
		}
		if (settings.includeUnfinishedCharacters)
		{
			allBros.AddRange(allUnfinished);
		}
		if (settings.enableBromaker)
		{
			allBros.AddRange(allCustomBros);
		}
		if (settings.sorting == SortingMethod.AlphabeticalAZ)
		{
			allBros.Sort();
		}
		else if (settings.sorting == SortingMethod.AlphabeticalZA)
		{
			allBros.Sort();
			allBros.Reverse();
		}
		filteredBroList = Enumerable.Repeat(element: false, allBros.Count()).ToArray();
		for (int i = 0; i < settings.enabledBros.Count(); i++)
		{
			int num = allBros.IndexOf(settings.enabledBros[i]);
			if (num != -1)
			{
				filteredBroList[num] = true;
			}
		}
	}

	public static void UpdateFilteredBroList()
	{
		settings.enabledBros.Clear();
		for (int i = 0; i < filteredBroList.Length; i++)
		{
			if (filteredBroList[i])
			{
				settings.enabledBros.Add(allBros[i]);
			}
		}
	}

	public static bool CustomCountChanged()
	{
		if (GameModeController.IsHardcoreMode && !settings.ignoreCurrentUnlocked)
		{
			return BroSpawnManager.GetAllSpawnableBrosNames().Count() != allCustomBros.Count();
		}
		return BroSpawnManager.GetAllUnlockedBrosNames().Count() != allCustomBros.Count();
	}

	public static void LoadCustomBros()
	{
		if (GameModeController.IsHardcoreMode && !settings.ignoreCurrentUnlocked)
		{
			allCustomBros = BroSpawnManager.GetAllSpawnableBrosNames();
			actuallyAllCustomBros = BroSpawnManager.GetAllUnlockedBrosNames();
		}
		else
		{
			allCustomBros = BroSpawnManager.GetAllUnlockedBrosNames();
			actuallyAllCustomBros = allCustomBros;
		}
	}

	public static bool IsBroCustom(int index)
	{
		return actuallyAllCustomBros.Contains(currentBroList[index]);
	}

	public static string GetSelectedBroName(int playerNum)
	{
		return currentBroList[settings.selGridInt[playerNum]];
	}

	public static HeroType GetSelectedBroHeroType(int playerNum)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		return StringToHeroType(currentBroList[settings.selGridInt[playerNum]]);
	}

	public static void SetSelectedBro(int playerNum, HeroType nextHero)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		if (GameModeController.IsHardcoreMode && !settings.ignoreCurrentUnlocked)
		{
			settings.selGridInt[playerNum] = currentBroList.IndexOf(HeroTypeToString(nextHero));
			if (settings.selGridInt[playerNum] == -1)
			{
				settings.selGridInt[playerNum] = 0;
			}
		}
		else
		{
			settings.selGridInt[playerNum] = currentBroList.IndexOf(HeroTypeToString(nextHero));
		}
	}

	public static bool CheckIfCustomBro(TestVanDammeAnim character, ref string name)
	{
		if (character is CustomHero)
		{
			name = ((CustomBroforceObjectInfo)((CustomHero)((character is CustomHero) ? character : null)).Info).name;
			return true;
		}
		return false;
	}

	public static void MakeCustomBroSpawn(int curPlayer, string name)
	{
		LoadHero.willReplaceBro[curPlayer] = true;
		Settings.instance.overrideNextBroSpawn = true;
		Settings.instance.nextBroSpawn = name;
	}

	public static void EnableCustomBroSpawning()
	{
		Settings.instance.disableSpawning = false;
	}

	public static void DisableCustomBroSpawning(int curPlayer)
	{
		Settings.instance.disableSpawning = true;
		LoadHero.willReplaceBro[curPlayer] = false;
	}

	public static bool IsCustomBroSpawning(int curPlayer)
	{
		return LoadHero.willReplaceBro[curPlayer];
	}

	public static bool IsCustcenePlaying()
	{
		return LoadHero.playCutscene;
	}

	public static int GetHardcoreCount()
	{
		if (settings.enableBromaker)
		{
			return GameState.Instance.currentWorldmapSave.hardcoreModeAvailableBros.Count() + GetBromakerHardcoreAmount();
		}
		return GameState.Instance.currentWorldmapSave.hardcoreModeAvailableBros.Count();
	}

	public static int GetBromakerHardcoreAmount()
	{
		return BroSpawnManager.HardcoreAvailableBros.Count();
	}

	public static bool OnlyCustomBrosInHardcore()
	{
		return Settings.instance.onlyCustomInHardcore;
	}

	public static string HeroTypeToString(HeroType hero)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected I4, but got Unknown
		return (int)hero switch
		{
			0 => "Rambro", 
			1 => "Brommando", 
			2 => "B. A. Broracus", 
			3 => "Brodell Walker", 
			9 => "Bro Hard", 
			5 => "MacBrover", 
			4 => "Brade", 
			8 => "Bro Dredd", 
			6 => "Bro In Black", 
			11 => "Snake Broskin", 
			12 => "Brominator", 
			7 => "Brobocop", 
			13 => "Indiana Brones", 
			14 => "Ash Brolliams", 
			15 => "Mr. Anderbro", 
			16 => "The Boondock Bros", 
			17 => "Brochete", 
			18 => "Bronan the Brobarian", 
			19 => "Ellen Ripbro", 
			21 => "Time Bro", 
			23 => "Broniversal Soldier", 
			22 => "Colonel James Broddock", 
			20 => "Cherry Broling", 
			32 => "Bro Max", 
			31 => "The Brode", 
			33 => "Double Bro Seven", 
			34 => "The Brodator", 
			38 => "The Brocketeer", 
			37 => "Broheart", 
			35 => "The Brofessional", 
			40 => "Broden", 
			41 => "The Brolander", 
			43 => "Dirty Brory", 
			39 => "Tank Bro", 
			42 => "Bro Lee", 
			36 => "Seth Brondle", 
			45 => "Xebro", 
			48 => "Desperabro", 
			47 => "Broffy the Vampire Slayer", 
			49 => "Burt Brommer", 
			51 => "Demolition Bro", 
			24 => "Broney Ross", 
			25 => "Lee Broxmas", 
			26 => "Bronnar Jensen", 
			27 => "Bro Caesar", 
			28 => "Trent Broser", 
			29 => "Broctor Death", 
			30 => "Toll Broad", 
			50 => "Chev Brolios", 
			44 => "Casey Broback", 
			46 => "The Scorpion Bro", 
			_ => "", 
		};
	}

	public static HeroType StringToHeroType(string hero)
	{
		return (HeroType)(hero switch
		{
			"Rambro" => 0, 
			"Brommando" => 1, 
			"B. A. Broracus" => 2, 
			"Brodell Walker" => 3, 
			"Bro Hard" => 9, 
			"MacBrover" => 5, 
			"Brade" => 4, 
			"Bro Dredd" => 8, 
			"Bro In Black" => 6, 
			"Snake Broskin" => 11, 
			"Brominator" => 12, 
			"Brobocop" => 7, 
			"Indiana Brones" => 13, 
			"Ash Brolliams" => 14, 
			"Mr. Anderbro" => 15, 
			"The Boondock Bros" => 16, 
			"Brochete" => 17, 
			"Bronan the Brobarian" => 18, 
			"Ellen Ripbro" => 19, 
			"Time Bro" => 21, 
			"Broniversal Soldier" => 23, 
			"Colonel James Broddock" => 22, 
			"Cherry Broling" => 20, 
			"Bro Max" => 32, 
			"The Brode" => 31, 
			"Double Bro Seven" => 33, 
			"The Brodator" => 34, 
			"The Brocketeer" => 38, 
			"Broheart" => 37, 
			"The Brofessional" => 35, 
			"Broden" => 40, 
			"The Brolander" => 41, 
			"Dirty Brory" => 43, 
			"Tank Bro" => 39, 
			"Bro Lee" => 42, 
			"Seth Brondle" => 36, 
			"Xebro" => 45, 
			"Desperabro" => 48, 
			"Broffy the Vampire Slayer" => 47, 
			"Burt Brommer" => 49, 
			"Demolition Bro" => 51, 
			"Broney Ross" => 24, 
			"Lee Broxmas" => 25, 
			"Bronnar Jensen" => 26, 
			"Bro Caesar" => 27, 
			"Trent Broser" => 28, 
			"Broctor Death" => 29, 
			"Toll Broad" => 30, 
			"Chev Brolios" => 50, 
			"Casey Broback" => 44, 
			"The Scorpion Bro" => 46, 
			_ => -1, 
		});
	}

	public static void EnsureBroListUpdated()
	{
		try
		{
			if (!enabled)
			{
				return;
			}
			if (GameModeController.IsHardcoreMode && !settings.ignoreCurrentUnlocked)
			{
				if (GetHardcoreCount() != currentBroList.Count)
				{
					CreateBroList();
				}
			}
			else if (settings.enableBromaker && CustomCountChanged())
			{
				LoadCustomBros();
				CreateBroList();
			}
		}
		catch (Exception ex)
		{
			Log("Exception in EnsureBroListUpdated: " + ex.ToString());
		}
	}

	public static bool SwapToSpecificBro(int playerNum, int broIndex)
	{
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (!enabled)
			{
				return false;
			}
			if (playerNum < 0 || playerNum > 3)
			{
				return false;
			}
			if (broIndex < 0 || broIndex >= currentBroList.Count)
			{
				return false;
			}
			Player val = HeroController.players[playerNum];
			if ((Object)(object)val == (Object)null || !val.IsAlive() || (Object)(object)val.character == (Object)null)
			{
				return false;
			}
			if ((Object)(object)val.character.pilottedUnit != (Object)null)
			{
				return false;
			}
			Vector3 characterPosition = val.GetCharacterPosition();
			float num = (float)Traverse.Create((object)val.character).Field("xI").GetValue();
			float num2 = (float)Traverse.Create((object)val.character).Field("yI").GetValue();
			settings.selGridInt[playerNum] = broIndex;
			manualSpawn = true;
			if (settings.enableBromaker && IsBroCustom(broIndex))
			{
				MakeCustomBroSpawn(playerNum, GetSelectedBroName(playerNum));
				val.SetSpawnPositon(val._character, (SpawnType)7, false, characterPosition);
				val.SpawnHero((HeroType)0);
			}
			else
			{
				val.SetSpawnPositon(val._character, (SpawnType)7, false, characterPosition);
				if (settings.enableBromaker)
				{
					DisableCustomBroSpawning(playerNum);
				}
				val.SpawnHero(GetSelectedBroHeroType(playerNum));
				if (settings.enableBromaker)
				{
					EnableCustomBroSpawning();
				}
			}
			((Unit)val.character).SetPositionAndVelocity(characterPosition.x, characterPosition.y, num, num2);
			val.character.SetInvulnerable(0f, false, false);
			return true;
		}
		catch (Exception ex)
		{
			Log("Exception in SwapToSpecificBro: " + ex.ToString());
			return false;
		}
	}
}
public enum SortingMethod
{
	UnlockOrder,
	AlphabeticalAZ,
	AlphabeticalZA
}
public class Settings : ModSettings
{
	public bool alwaysChosen;

	public bool ignoreCurrentUnlocked;

	public bool includeExpendabros;

	public bool includeUnfinishedCharacters;

	public bool clickingEnabled = true;

	public bool enableBromaker;

	public bool enableBromakerDefault = true;

	public float swapCoolDown = 0.5f;

	public int[] selGridInt = new int[4];

	public bool[] showSettings = new bool[4] { true, false, false, false };

	public KeyBind[] swapLeftKeys = new KeyBind[4]
	{
		new KeyBind(),
		new KeyBind(),
		new KeyBind(),
		new KeyBind()
	};

	public KeyBind[] swapRightKeys = new KeyBind[4]
	{
		new KeyBind(),
		new KeyBind(),
		new KeyBind(),
		new KeyBind()
	};

	public List<string> enabledBros = new List<string>();

	public bool filterBros;

	public bool useVanillaBroSelection = true;

	public bool ignoreForcedBros;

	public SortingMethod sorting;

	public string sortingMethodName = "Sorting Method: Unlock Order";

	public override void Save(ModEntry modEntry)
	{
		ModSettings.Save<Settings>(this, modEntry);
	}
}