Decompiled source of CharacterWhitelist v1.3.2

CharacterWhitelist.dll

Decompiled a year ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using CrewBoom;
using CrewBoom.Data;
using CrewBoomAPI;
using HarmonyLib;
using Reptile;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("CharacterWhitelist")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.2.0")]
[assembly: AssemblyInformationalVersion("1.3.2")]
[assembly: AssemblyProduct("CharacterWhitelist")]
[assembly: AssemblyTitle("CharacterWhitelist")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.2.0")]
[module: UnverifiableCode]
namespace CharacterWhitelist
{
	[BepInPlugin("CharacterWhitelist", "CharacterWhitelist", "1.3.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class CharacterWhitelistPlugin : BaseUnityPlugin
	{
		private const string CrewBoomGUID = "CrewBoom";

		private static ConfigEntry<bool> _alwaysAllowBaseCharacters;

		private static ConfigEntry<ListType> _listType;

		private static ConfigEntry<string> _characterList;

		private static ConfigEntry<bool> _inGameUI;

		public static bool InGameUI => _inGameUI.Value;

		public static ListType ListType
		{
			get
			{
				return _listType.Value;
			}
			set
			{
				_listType.Value = value;
			}
		}

		public static bool AlwaysAllowBaseCharacters
		{
			get
			{
				return _alwaysAllowBaseCharacters.Value;
			}
			set
			{
				_alwaysAllowBaseCharacters.Value = value;
			}
		}

		public static HashSet<string> CharacterSet { get; private set; }

		private static string GetCharacterInternalName(Characters character)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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)
			//IL_0010: Invalid comparison between Unknown and I4
			bool num = (int)character <= 26;
			string result = ((object)(Characters)(ref character)).ToString();
			if (!num)
			{
				if (!IsCrewBoomInstalled())
				{
					return "";
				}
				return CrewBoomStep();
			}
			return result;
			string CrewBoomStep()
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Expected I4, but got Unknown
				if (CrewBoomAPIDatabase.IsInitialized)
				{
					Guid characterGuid = default(Guid);
					if (!CrewBoomAPIDatabase.GetUserGuidForCharacter((int)character, ref characterGuid))
					{
						return "";
					}
					return GetNameForCrewBoomCharacter(characterGuid);
				}
				return "";
			}
		}

		public static void ClearCharacterList()
		{
			CharacterSet.Clear();
			UpdateCharacterListFromCharacterSet();
		}

		public static void RemoveCharacterFromList(Characters character)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CharacterSet.Remove(GetCharacterInternalName(character));
			UpdateCharacterListFromCharacterSet();
		}

		public static void AddCharacterToList(Characters character)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CharacterSet.Add(GetCharacterInternalName(character));
			UpdateCharacterListFromCharacterSet();
		}

		private static void UpdateCharacterListFromCharacterSet()
		{
			List<string> list = CharacterSet.ToList();
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < list.Count; i++)
			{
				stringBuilder.Append(list[i]);
				if (i < list.Count - 1)
				{
					stringBuilder.Append(", ");
				}
			}
			_characterList.SettingChanged -= UpdateCharacterListEvent;
			_characterList.Value = stringBuilder.ToString();
			_characterList.SettingChanged += UpdateCharacterListEvent;
		}

		public static bool IsCharacterInList(Characters character)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return CharacterSet.Contains(GetCharacterInternalName(character));
		}

		public static bool IsCharacterAllowed(Characters character)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (ListType == ListType.Disabled)
			{
				return true;
			}
			if ((int)character <= 26 && AlwaysAllowBaseCharacters)
			{
				return true;
			}
			string characterInternalName = GetCharacterInternalName(character);
			if (CharacterSet.Contains(characterInternalName))
			{
				return ListType == ListType.Whitelist;
			}
			return ListType == ListType.Blacklist;
		}

		private static string GetNameForCrewBoomCharacter(Guid characterGuid)
		{
			if (CharacterDatabase._characterBundlePaths.TryGetValue(characterGuid, out var value))
			{
				return Path.GetFileNameWithoutExtension(value);
			}
			return null;
		}

		private void Awake()
		{
			Configure();
			Initialize();
		}

		private void Configure()
		{
			_inGameUI = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "InGameUI", true, "Displays a UI for blacklisting/whitelisting characters at the cypher in-game.");
			_alwaysAllowBaseCharacters = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AlwaysAllowBaseCharacters", false, "Makes basegame non-custom characters not affected, so they will be displayed at all times even if not whitelisted.");
			_listType = ((BaseUnityPlugin)this).Config.Bind<ListType>("General", "ListType", ListType.Disabled, "Type of list, in case you want a whitelist (only allow listed characters), a blacklist (allow any character except those on the list) or to disable it, which has no effect.");
			_characterList = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CharacterList", "", "Case sensitive comma separated list of character filenames (without the .cbb extension) to whitelist/blacklist (e.g. patrick, akko, reiko, spaceGirl, eightBall).");
			UpdateCharacterList();
			_characterList.SettingChanged += UpdateCharacterListEvent;
		}

		private void Initialize()
		{
			((MonoBehaviour)this).StartCoroutine(DelayedInitialization());
		}

		private IEnumerator DelayedInitialization()
		{
			yield return null;
			try
			{
				new Harmony("CharacterWhitelist").PatchAll();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin CharacterWhitelist 1.3.2 is loaded!");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)string.Format("Plugin {0} {1} failed to load!{2}{3}", "CharacterWhitelist", "1.3.2", Environment.NewLine, ex));
			}
		}

		private static void UpdateCharacterListEvent(object sender, EventArgs e)
		{
			UpdateCharacterList();
		}

		private static void UpdateCharacterList()
		{
			HashSet<string> hashSet = new HashSet<string>();
			string[] array = _characterList.Value.Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (!string.IsNullOrEmpty(text))
				{
					hashSet.Add(text);
				}
			}
			CharacterSet = hashSet;
		}

		internal static bool IsCrewBoomInstalled()
		{
			return Chainloader.PluginInfos.Keys.Any((string x) => x == "CrewBoom");
		}
	}
	public class CharacterWhitelistUI : MonoBehaviour
	{
		internal const int AddToRemoveFromListActionID = 1;

		internal const int SwitchListTypeActionID = 48;

		internal const int ClearListActionID = 47;

		internal const int ToggleBaseCharactersActionID = 45;

		internal static CharacterWhitelistUI Instance;

		private TextMeshProUGUI _infoLabel;

		private TextMeshProUGUI _addRemoveLabel;

		private TextMeshProUGUI _switchListTypeLabel;

		private TextMeshProUGUI _clearListLabel;

		private TextMeshProUGUI _toggleBaseCharactersLabel;

		private static TextMeshProUGUI MakeLabel(TextMeshProUGUI reference, string name)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			TMP_FontAsset font = ((TMP_Text)reference).font;
			float fontSize = ((TMP_Text)reference).fontSize;
			Material fontMaterial = ((TMP_Text)reference).fontMaterial;
			TextMeshProUGUI obj = new GameObject(name).AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj).font = font;
			((TMP_Text)obj).fontSize = fontSize;
			((TMP_Text)obj).fontMaterial = fontMaterial;
			((TMP_Text)obj).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)obj).fontStyle = (FontStyles)1;
			((TMP_Text)obj).outlineWidth = 0.2f;
			return obj;
		}

		private static TextMeshProUGUI MakeGlyph(TextMeshProUGUI reference, int actionID)
		{
			TextMeshProUGUI val = MakeLabel(reference, "");
			UIButtonGlyphComponent obj = ((Component)val).gameObject.AddComponent<UIButtonGlyphComponent>();
			obj.inputActionID = actionID;
			obj.localizedGlyphTextComponent = val;
			obj.localizedTextComponent = val;
			((Behaviour)obj).enabled = true;
			return val;
		}

		internal static void InitializeUI(GameplayUI gameplayUI)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Instance != (Object)null))
			{
				Instance = new GameObject("Character Whitelist UI Root").AddComponent<CharacterWhitelistUI>();
				((Component)Instance).transform.SetParent((Transform)(object)((Component)((Component)gameplayUI).transform.parent).GetComponent<RectTransform>(), false);
				Instance.Init();
				Instance.Deactivate();
			}
		}

		private void Init()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: 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_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = ((Component)Instance).gameObject.AddComponent<RectTransform>();
			val.anchorMin = Vector2.zero;
			val.anchorMax = Vector2.one;
			TextMeshProUGUI[] componentsInChildren = ((Component)Core.Instance.UIManager.danceAbilityUI).GetComponentsInChildren<TextMeshProUGUI>(true);
			TextMeshProUGUI val2 = null;
			TextMeshProUGUI[] array = componentsInChildren;
			foreach (TextMeshProUGUI val3 in array)
			{
				if (((Object)((Component)((TMP_Text)val3).transform).gameObject).name == "DanceSelectConfirmText")
				{
					val2 = val3;
				}
			}
			if (!((Object)(object)val2 == (Object)null))
			{
				float num = 100f;
				float num2 = -50f;
				float num3 = 50f;
				float num4 = 75f;
				_infoLabel = MakeLabel(val2, "InfoLabel");
				((TMP_Text)_infoLabel).text = "Tryce is on the list";
				((TMP_Text)_infoLabel).rectTransform.anchorMin = new Vector2(0f, 0f);
				((TMP_Text)_infoLabel).rectTransform.anchorMax = new Vector2(1f, 1f);
				((TMP_Text)_infoLabel).rectTransform.pivot = new Vector2(0f, 1f);
				((TMP_Text)_infoLabel).rectTransform.anchoredPosition = new Vector2(num, num3);
				((Transform)((TMP_Text)_infoLabel).rectTransform).SetParent((Transform)(object)val, false);
				_addRemoveLabel = MakeLabel(val2, "AddRemoveLabel");
				((TMP_Text)_addRemoveLabel).text = "Add to List";
				((TMP_Text)_addRemoveLabel).rectTransform.anchorMin = new Vector2(0f, 0f);
				((TMP_Text)_addRemoveLabel).rectTransform.anchorMax = new Vector2(1f, 1f);
				((TMP_Text)_addRemoveLabel).rectTransform.pivot = new Vector2(0f, 1f);
				((TMP_Text)_addRemoveLabel).rectTransform.anchoredPosition = new Vector2(num + num4, num3 + num2);
				((Transform)((TMP_Text)_addRemoveLabel).rectTransform).SetParent((Transform)(object)val, false);
				TextMeshProUGUI obj = MakeGlyph(val2, 1);
				((TMP_Text)obj).rectTransform.anchorMin = new Vector2(0f, 0f);
				((TMP_Text)obj).rectTransform.anchorMax = new Vector2(1f, 1f);
				((TMP_Text)obj).rectTransform.pivot = new Vector2(0f, 1f);
				((TMP_Text)obj).rectTransform.anchoredPosition = new Vector2(num, num3 + num2);
				((Transform)((TMP_Text)obj).rectTransform).SetParent((Transform)(object)val, false);
				_switchListTypeLabel = MakeLabel(val2, "ListTypeLabel");
				((TMP_Text)_switchListTypeLabel).text = "List Type: Whitelist";
				((TMP_Text)_switchListTypeLabel).rectTransform.anchorMin = new Vector2(0f, 0f);
				((TMP_Text)_switchListTypeLabel).rectTransform.anchorMax = new Vector2(1f, 1f);
				((TMP_Text)_switchListTypeLabel).rectTransform.pivot = new Vector2(0f, 1f);
				((TMP_Text)_switchListTypeLabel).rectTransform.anchoredPosition = new Vector2(num + num4, num3 + num2 * 2f);
				((Transform)((TMP_Text)_switchListTypeLabel).rectTransform).SetParent((Transform)(object)val, false);
				TextMeshProUGUI obj2 = MakeGlyph(val2, 48);
				((TMP_Text)obj2).rectTransform.anchorMin = new Vector2(0f, 0f);
				((TMP_Text)obj2).rectTransform.anchorMax = new Vector2(1f, 1f);
				((TMP_Text)obj2).rectTransform.pivot = new Vector2(0f, 1f);
				((TMP_Text)obj2).rectTransform.anchoredPosition = new Vector2(num, num3 + num2 * 2f);
				((Transform)((TMP_Text)obj2).rectTransform).SetParent((Transform)(object)val, false);
				_clearListLabel = MakeLabel(val2, "ClearListLabel");
				((TMP_Text)_clearListLabel).text = "Clear List";
				((TMP_Text)_clearListLabel).rectTransform.anchorMin = new Vector2(0f, 0f);
				((TMP_Text)_clearListLabel).rectTransform.anchorMax = new Vector2(1f, 1f);
				((TMP_Text)_clearListLabel).rectTransform.pivot = new Vector2(0f, 1f);
				((TMP_Text)_clearListLabel).rectTransform.anchoredPosition = new Vector2(num + num4, num3 + num2 * 3f);
				((Transform)((TMP_Text)_clearListLabel).rectTransform).SetParent((Transform)(object)val, false);
				TextMeshProUGUI obj3 = MakeGlyph(val2, 47);
				((TMP_Text)obj3).rectTransform.anchorMin = new Vector2(0f, 0f);
				((TMP_Text)obj3).rectTransform.anchorMax = new Vector2(1f, 1f);
				((TMP_Text)obj3).rectTransform.pivot = new Vector2(0f, 1f);
				((TMP_Text)obj3).rectTransform.anchoredPosition = new Vector2(num, num3 + num2 * 3f);
				((Transform)((TMP_Text)obj3).rectTransform).SetParent((Transform)(object)val, false);
				_toggleBaseCharactersLabel = MakeLabel(val2, "BaseCharacterLabel");
				((TMP_Text)_toggleBaseCharactersLabel).text = "Base characters are exempt";
				((TMP_Text)_toggleBaseCharactersLabel).rectTransform.anchorMin = new Vector2(0f, 0f);
				((TMP_Text)_toggleBaseCharactersLabel).rectTransform.anchorMax = new Vector2(1f, 1f);
				((TMP_Text)_toggleBaseCharactersLabel).rectTransform.pivot = new Vector2(0f, 1f);
				((TMP_Text)_toggleBaseCharactersLabel).rectTransform.anchoredPosition = new Vector2(num + num4, num3 + num2 * 4f);
				((Transform)((TMP_Text)_toggleBaseCharactersLabel).rectTransform).SetParent((Transform)(object)val, false);
				TextMeshProUGUI obj4 = MakeGlyph(val2, 45);
				((TMP_Text)obj4).rectTransform.anchorMin = new Vector2(0f, 0f);
				((TMP_Text)obj4).rectTransform.anchorMax = new Vector2(1f, 1f);
				((TMP_Text)obj4).rectTransform.pivot = new Vector2(0f, 1f);
				((TMP_Text)obj4).rectTransform.anchoredPosition = new Vector2(num, num3 + num2 * 4f);
				((Transform)((TMP_Text)obj4).rectTransform).SetParent((Transform)(object)val, false);
			}
		}

		public void Activate(Characters currentCharacter)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).gameObject.SetActive(true);
			UpdateLabels(currentCharacter);
		}

		public void Deactivate()
		{
			((Component)this).gameObject.SetActive(false);
		}

		private string GetCharacterName(Characters character)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			IGameTextLocalizer localizer = Core.Instance.Localizer;
			if ((int)character < 26)
			{
				return localizer.GetCharacterName(character);
			}
			if (CharacterWhitelistPlugin.IsCrewBoomInstalled())
			{
				return CrewBoomStep();
			}
			return null;
			string CrewBoomStep()
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				CustomCharacter val = default(CustomCharacter);
				if (CrewBoomAPIDatabase.IsInitialized && CharacterDatabase.GetCharacter(character, ref val))
				{
					return val.Definition.CharacterName;
				}
				return null;
			}
		}

		public void UpdateLabels(Characters currentCharacter)
		{
			//IL_0001: 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: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			string text = GetCharacterName(currentCharacter).ToUpperInvariant();
			text = (((int)currentCharacter > 26) ? (text + " (Custom)") : (text + " (Base)"));
			if (CharacterWhitelistPlugin.IsCharacterInList(currentCharacter))
			{
				((Graphic)_infoLabel).color = Color32.op_Implicit(new Color32((byte)54, (byte)217, (byte)0, byte.MaxValue));
				((TMP_Text)_infoLabel).text = text + " is on the List";
				((TMP_Text)_addRemoveLabel).text = "Remove from List";
			}
			else
			{
				((Graphic)_infoLabel).color = ((Graphic)_switchListTypeLabel).color;
				((TMP_Text)_infoLabel).text = text + " is NOT on the List";
				((TMP_Text)_addRemoveLabel).text = "Add to List";
			}
			string text2 = "<color=#0d2fb8>Disabled</color>";
			switch (CharacterWhitelistPlugin.ListType)
			{
			case ListType.Whitelist:
				text2 = "<color=#36d900>Whitelist</color>";
				break;
			case ListType.Blacklist:
				text2 = "<color=#e01907>Blacklist</color>";
				break;
			}
			((TMP_Text)_switchListTypeLabel).text = "List Type: " + text2;
			((TMP_Text)_clearListLabel).text = $"Clear List ({CharacterWhitelistPlugin.CharacterSet.Count} Characters)";
			if (CharacterWhitelistPlugin.AlwaysAllowBaseCharacters)
			{
				((TMP_Text)_toggleBaseCharactersLabel).text = "Base characters: Always shown";
			}
			else
			{
				((TMP_Text)_toggleBaseCharactersLabel).text = "Base characters: Affected by List";
			}
		}

		internal static void DestroyUI()
		{
			if ((Object)(object)Instance != (Object)null)
			{
				Object.Destroy((Object)(object)Instance);
			}
			Instance = null;
		}

		public void UpdateUI(CharacterSelect characterSelect)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			GameInput gameInput = characterSelect.gameInput;
			Characters character = characterSelect.CharactersInCircle[characterSelect.selectionInCircle].character;
			bool flag = CharacterWhitelistPlugin.IsCharacterInList(character);
			if (gameInput.GetButtonNew(1, 0))
			{
				if (flag)
				{
					CharacterWhitelistPlugin.RemoveCharacterFromList(character);
				}
				else
				{
					CharacterWhitelistPlugin.AddCharacterToList(character);
				}
				Core.Instance.AudioManager.PlaySfxUI((SfxCollectionID)23, (AudioClipID)547, 0f);
				UpdateLabels(character);
			}
			if (gameInput.GetButtonNew(48, 0))
			{
				switch (CharacterWhitelistPlugin.ListType)
				{
				case ListType.Whitelist:
					CharacterWhitelistPlugin.ListType = ListType.Blacklist;
					break;
				case ListType.Blacklist:
					CharacterWhitelistPlugin.ListType = ListType.Disabled;
					break;
				case ListType.Disabled:
					CharacterWhitelistPlugin.ListType = ListType.Whitelist;
					break;
				}
				Core.Instance.AudioManager.PlaySfxUI((SfxCollectionID)23, (AudioClipID)547, 0f);
				UpdateLabels(character);
			}
			if (gameInput.GetButtonNew(47, 0))
			{
				CharacterWhitelistPlugin.ClearCharacterList();
				Core.Instance.AudioManager.PlaySfxUI((SfxCollectionID)23, (AudioClipID)547, 0f);
				UpdateLabels(character);
			}
			if (gameInput.GetButtonNew(45, 0))
			{
				CharacterWhitelistPlugin.AlwaysAllowBaseCharacters = !CharacterWhitelistPlugin.AlwaysAllowBaseCharacters;
				Core.Instance.AudioManager.PlaySfxUI((SfxCollectionID)23, (AudioClipID)547, 0f);
				UpdateLabels(character);
			}
		}
	}
	public enum ListType
	{
		Whitelist,
		Blacklist,
		Disabled
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "CharacterWhitelist";

		public const string PLUGIN_NAME = "CharacterWhitelist";

		public const string PLUGIN_VERSION = "1.3.2";
	}
}
namespace CharacterWhitelist.Patches
{
	[HarmonyPatch(typeof(CharacterSelect))]
	internal static class CharacterSelectPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("SetState")]
		private static void SetState_Postfix(CharacterSelect __instance, CharSelectState setState)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if ((int)setState != 1)
			{
				if ((Object)(object)CharacterWhitelistUI.Instance != (Object)null)
				{
					CharacterWhitelistUI.Instance.Deactivate();
				}
			}
			else if ((Object)(object)CharacterWhitelistUI.Instance != (Object)null && CharacterWhitelistPlugin.InGameUI)
			{
				CharacterWhitelistUI.Instance.Activate(__instance.CharactersInCircle[__instance.selectionInCircle].character);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("MoveSelection")]
		private static void MoveSelection_Postfix(CharacterSelect __instance)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)CharacterWhitelistUI.Instance != (Object)null && ((Behaviour)CharacterWhitelistUI.Instance).isActiveAndEnabled)
			{
				CharacterWhitelistUI.Instance.UpdateLabels(__instance.CharactersInCircle[__instance.selectionInCircle].character);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("StopCharacterSelect")]
		private static void StopCharacterSelect_Postfix()
		{
			if ((Object)(object)CharacterWhitelistUI.Instance != (Object)null)
			{
				CharacterWhitelistUI.Instance.Deactivate();
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("CharSelectUpdate")]
		private static void CharSelectUpdate_Postfix(CharacterSelect __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			if ((int)__instance.state == 1 && CharacterWhitelistPlugin.InGameUI && (Object)(object)CharacterWhitelistUI.Instance != (Object)null && ((Behaviour)CharacterWhitelistUI.Instance).isActiveAndEnabled)
			{
				CharacterWhitelistUI.Instance.UpdateUI(__instance);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("PopulateListOfSelectableCharacters")]
		private static void PopulateListOfSelectableCharacters_Postfix(CharacterSelect __instance, Player player)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			List<Characters> list = __instance.selectableCharacters.Where(CharacterWhitelistPlugin.IsCharacterAllowed).ToList();
			if (list.Count < 2)
			{
				Characters item = player.character;
				if (list.Count > 0)
				{
					item = list[0];
				}
				while (list.Count < 2)
				{
					list.Add(item);
				}
			}
			__instance.selectableCharacters = list;
		}
	}
	[HarmonyPatch(typeof(GameplayUI))]
	internal static class GameplayUIPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Init")]
		private static void Init_Postfix(GameplayUI __instance)
		{
			CharacterWhitelistUI.InitializeUI(__instance);
		}
	}
}