Decompiled source of BRCPlus v1.2.0

BRCPlus.dll

Decompiled 7 months 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.Cryptography;
using System.Text;
using BRCPlus.Phone;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using CommonAPI.Phone;
using HarmonyLib;
using Reptile;
using Reptile.Phone;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Playables;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("BRCPlus")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BRCPlus")]
[assembly: AssemblyTitle("BRCPlus")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace BRCPlus
{
	[BepInPlugin("com.brcplus", "BRC Plus", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BRCPlusPlugin : BaseUnityPlugin
	{
		private static string _pluginFolder;

		public static readonly string[] SprayModeOptions = new string[3] { "Normal", "Quick", "Auto" };

		public static readonly string[] PlayerSizeOptions = new string[5] { "Normal", "Small", "Big", "Huge", "EXTRA HUGE" };

		public static readonly string[] GravityOptions = new string[3] { "Normal", "Low", "High" };

		private Harmony _harmony;

		public static readonly string[] SkipCutsceneModeOptions = new string[3] { "Normal", "Force button", "Auto Skip" };

		public static readonly string[] GoonModeOptions = new string[2] { "Normal", "Auto" };

		public static ConfigEntry<bool> DisableHeat { get; private set; }

		public static ConfigEntry<bool> GodMode { get; private set; }

		public static ConfigEntry<bool> InfiniteBoost { get; private set; }

		public static ConfigEntry<bool> AlwaysInSpeedZone { get; private set; }

		public static ConfigEntry<bool> InfiniteAirDash { get; private set; }

		public static ConfigEntry<string> GoonMode { get; private set; }

		public static ConfigEntry<bool> LockStoredSpeed { get; private set; }

		public static ConfigEntry<int> ConfigForcedStoredSpeed { get; private set; }

		public static ConfigEntry<bool> UseStoredSpeedInConfig { get; private set; }

		public static ConfigEntry<string> SprayMode { get; private set; }

		public static ConfigEntry<bool> GetBoostsFromGraffiti { get; private set; }

		public static ConfigEntry<bool> UIVisible_HealthBar { get; private set; }

		public static ConfigEntry<bool> UIVisible_BoostBar { get; private set; }

		public static ConfigEntry<bool> UIVisible_Score { get; private set; }

		public static ConfigEntry<bool> UIVisible_Context { get; private set; }

		public static ConfigEntry<bool> UIVisible_Rep { get; private set; }

		public static ConfigEntry<bool> UIVisible_Combo { get; private set; }

		public static ConfigEntry<bool> UIVisible_ShowGainingBoostsAnim { get; private set; }

		public static ConfigEntry<string> PlayerSize { get; private set; }

		public static ConfigEntry<string> Gravity { get; private set; }

		public static ConfigEntry<string> SkipCutsceneMode { get; private set; }

		public static ConfigEntry<bool> ShowGraffiti { get; private set; }

		public static ConfigEntry<bool> EnabledDebugMenu { get; private set; }

		private void Awake()
		{
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Expected O, but got Unknown
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Expected O, but got Unknown
			_pluginFolder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			DisableHeat = ((BaseUnityPlugin)this).Config.Bind<bool>("Heat", "DisableHeat", false, "When true, disables the entire heat/wanted system (no stars, no police chases from crimes).");
			GodMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "GodMode", false, "When true, the player's health cannot go down (invulnerable to damage).");
			InfiniteBoost = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "Infinite Boost", false, "When true, the player's boost is always kept at maximum so they never lose boost.");
			AlwaysInSpeedZone = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "Always In Speed Zone", false, "When true, the game always treats the player as being in a speed zone (e.g. for slide/vert tricks).");
			InfiniteAirDash = ((BaseUnityPlugin)this).Config.Bind<bool>("Toggles", "Infinite Air Dash", false, "When true, you can air dash any number of times in the air without landing first (normally only once per air time).");
			GoonMode = ((BaseUnityPlugin)this).Config.Bind<string>("Movement", "GoonMode", "Normal", "Goon Mode: Normal = default. Auto = always trigger edge boost when touching any wall run.");
			LockStoredSpeed = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "LockStoredSpeed", false, "When true, the wall run stored speed (used when you run off or jump) cannot change and stays at its current value.");
			ConfigForcedStoredSpeed = ((BaseUnityPlugin)this).Config.Bind<int>("Movement", "ConfigForcedStoredSpeed", 600, "Stored speed used when 'Use Stored Speed In Config' is enabled. Enter as a whole number (e.g. 600, 700). A decimal is applied before the last digit (600 = 60.0 speed) to match how other mods display it.");
			UseStoredSpeedInConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "UseStoredSpeedInConfig", false, "When true, wall run stored speed is always forced to the ConfigForcedStoredSpeed value.");
			SprayMode = ((BaseUnityPlugin)this).Config.Bind<string>("Graffiti", "SprayMode", "Normal", "Spray mode: Normal = full minigame. Quick = paint instantly when you start. Auto = paint instantly when in range (no button).");
			GetBoostsFromGraffiti = ((BaseUnityPlugin)this).Config.Bind<bool>("Graffiti", "GetBoostsFromGraffiti", true, "When true, spraying graffiti (new pieces) fills your boost meter. When false, no boost is given from graffiti.");
			NormalizeSprayModeConfig();
			string text = "UI Options";
			UIVisible_HealthBar = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Health Bar", true, "Show the health bar.");
			UIVisible_BoostBar = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Boost Bar", true, "Show the boost/charge bar.");
			UIVisible_Score = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Score", true, "Show the score display.");
			UIVisible_Context = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Context Icons", true, "Show context icons (graffiti, talk, break chains).");
			UIVisible_Rep = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Rep", true, "Show the rep display.");
			UIVisible_Combo = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Combo", true, "Show the combo mascot and combo UI.");
			UIVisible_ShowGainingBoostsAnim = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Show Gaining Boosts Anim", true, "Show the gaining boost animation (flying icons when you gain boost).");
			string text2 = "Fun";
			PlayerSize = ((BaseUnityPlugin)this).Config.Bind<string>(text2, "Player Size", "Normal", "Player scale: Normal, Small, or Big.");
			Gravity = ((BaseUnityPlugin)this).Config.Bind<string>(text2, "Gravity", "Normal", "Gravity: Normal (default), Low (floaty), or High (heavy).");
			SkipCutsceneMode = ((BaseUnityPlugin)this).Config.Bind<string>("Toggles", "SkipCutsceneMode", "Normal", "Cutscene skip: Normal = default behaviour. Force button = skip button always available. Auto Skip = skip all cutscenes automatically.");
			ShowGraffiti = ((BaseUnityPlugin)this).Config.Bind<bool>("Hide Objects", "ShowGraffiti", true, "When true, graffiti spots are visible and work as normal. When false, all graffiti spots on the stage are disabled on load (saves some performance).");
			EnabledDebugMenu = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "EnabledDebugMenu", false, "When true, enables the game's debug menu (toggle in-game). Requires restart to take effect.");
			NormalizePlayerSizeConfig();
			NormalizeGravityConfig();
			NormalizeSkipCutsceneModeConfig();
			NormalizeGoonModeConfig();
			_harmony = new Harmony("com.brcplus");
			_harmony.PatchAll();
			StageManager.OnStagePostInitialization += new OnStageInitializedDelegate(OnStagePostInitialization);
			AppBRCPlus.Initialize();
		}

		private void OnDestroy()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			StageManager.OnStagePostInitialization -= new OnStageInitializedDelegate(OnStagePostInitialization);
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private static void OnStagePostInitialization()
		{
			ConfigEntry<bool> showGraffiti = ShowGraffiti;
			if (showGraffiti == null || showGraffiti.Value)
			{
				return;
			}
			WorldHandler instance = WorldHandler.instance;
			if (((instance == null) ? null : instance.SceneObjectsRegister?.grafSpots) == null)
			{
				return;
			}
			foreach (GraffitiSpot grafSpot in instance.SceneObjectsRegister.grafSpots)
			{
				if ((Object)(object)grafSpot != (Object)null && (Object)(object)((Component)grafSpot).gameObject != (Object)null)
				{
					((Component)grafSpot).gameObject.SetActive(false);
				}
			}
		}

		internal static void NormalizeSprayModeConfig()
		{
			if (SprayMode != null)
			{
				string value = SprayMode.Value;
				if (value != "Normal" && value != "Quick" && value != "Auto")
				{
					SprayMode.Value = "Normal";
				}
			}
		}

		internal static void NormalizePlayerSizeConfig()
		{
			if (PlayerSize != null)
			{
				string value = PlayerSize.Value;
				if (value != "Normal" && value != "Small" && value != "Big" && value != "Huge" && value != "EXTRA HUGE")
				{
					PlayerSize.Value = "Normal";
				}
			}
		}

		internal static void NormalizeGravityConfig()
		{
			if (Gravity != null)
			{
				string value = Gravity.Value;
				if (value != "Normal" && value != "Low" && value != "High")
				{
					Gravity.Value = "Normal";
				}
			}
		}

		internal static void NormalizeSkipCutsceneModeConfig()
		{
			if (SkipCutsceneMode != null)
			{
				string value = SkipCutsceneMode.Value;
				if (Array.IndexOf(SkipCutsceneModeOptions, value) < 0)
				{
					SkipCutsceneMode.Value = "Normal";
				}
			}
		}

		internal static void NormalizeGoonModeConfig()
		{
			if (GoonMode == null)
			{
				return;
			}
			string value = GoonMode.Value;
			switch (value)
			{
			case "Disabled":
			case "False":
			case "false":
				GoonMode.Value = "Normal";
				return;
			case "Enabled":
			case "True":
			case "true":
				GoonMode.Value = "Auto";
				return;
			}
			if (Array.IndexOf(GoonModeOptions, value) < 0)
			{
				GoonMode.Value = "Normal";
			}
		}

		public static string GetAppIconPath(string filename)
		{
			if (!string.IsNullOrEmpty(_pluginFolder))
			{
				return Path.Combine(_pluginFolder, filename);
			}
			return null;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.brcplus";

		public const string PLUGIN_NAME = "BRC Plus";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	public class GameDebugBridge : AGameDebug
	{
		private UIManager _uiManager;

		private bool _menuCreated;

		public override bool IsShowingDebugMenu
		{
			get
			{
				DebugMenuController value = Traverse.Create((object)_uiManager).Field("debugMenuUIRoot").GetValue<DebugMenuController>();
				if ((Object)(object)value != (Object)null)
				{
					return ((AMenuController)value).IsEnabled;
				}
				return false;
			}
		}

		public GameDebugBridge(BaseModule baseModule, SaveManager saveManager, GameInput gameInput, UIManager uIManager)
			: base(baseModule, saveManager, gameInput, uIManager)
		{
			_uiManager = uIManager;
		}

		protected override void InitializeFPSCounter()
		{
		}

		protected override void UpdateKeyboardInput()
		{
			if (base.baseModule.IsPlayingInStage)
			{
				base.gameInput.EnableControllerMap(3, 0);
			}
			if (base.gameInput.GetButtonNew(40, 0))
			{
				((AGameDebug)this).ToggleDebugMenu();
			}
		}

		protected override void UpdateJoystickInput()
		{
			if (base.baseModule.IsPlayingInStage)
			{
				base.gameInput.EnableControllerMap(3, 0);
			}
			if (base.gameInput.GetButtonNew(40, 0))
			{
				((AGameDebug)this).ToggleDebugMenu();
			}
		}

		public override void ToggleDebugMenu()
		{
			DebugMenuController val = Traverse.Create((object)_uiManager).Field("debugMenuUIRoot").GetValue<DebugMenuController>();
			if ((Object)(object)val != (Object)null && ((AMenuController)val).IsEnabled)
			{
				_uiManager.PopCurrentMenu();
				if (base.baseModule.IsInGamePaused)
				{
					base.baseModule.UnPauseGame((PauseType)64);
				}
				return;
			}
			if ((Object)(object)val == (Object)null && (Object)(object)_uiManager.debugUIPrefab != (Object)null && !_menuCreated)
			{
				_menuCreated = true;
				GameObject obj = Object.Instantiate<GameObject>(_uiManager.debugUIPrefab);
				obj.transform.SetParent(((Component)_uiManager).transform, false);
				DebugMenuController componentInChildren = obj.GetComponentInChildren<DebugMenuController>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.InitDebugMenu((AGameDebug)(object)this, base.baseModule, base.saveManager, _uiManager);
					Traverse.Create((object)_uiManager).Field("debugMenuUIRoot").SetValue((object)componentInChildren);
					val = componentInChildren;
				}
			}
			if ((Object)(object)val != (Object)null && !((AMenuController)val).IsEnabled)
			{
				base.baseModule.PauseGame((PauseType)64);
				((Component)val).gameObject.SetActive(true);
				((AMenuController)val).Activate();
				_uiManager.PushNewMenu((IUIMenuController)(object)val);
				_uiManager.ForceFocusOnTopMenu();
			}
		}

		public override void ToggleFPSCounter()
		{
		}

		public override void CycleFPSCounterPreset()
		{
		}

		public override void RestartStage()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.baseModule != (Object)null && base.baseModule.StageManager != null)
			{
				base.baseModule.SwitchStage(base.baseModule.CurrentStage);
			}
		}

		public override void SelectStage(Stage stage)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)base.baseModule != (Object)null)
			{
				base.baseModule.SwitchStage(stage);
			}
		}

		public override void CycleQualitySettings()
		{
		}

		public override void UpdateLocalizationLanguage(SystemLanguage systemLanguage)
		{
		}
	}
	public static class PropDisguiseManager
	{
		private static Dictionary<int, GameObject> _propByIndex = new Dictionary<int, GameObject>();

		private static Dictionary<Player, (GameObject disguise, int id)> _playerDisguises = new Dictionary<Player, (GameObject, int)>();

		private static int HashString(string s)
		{
			byte[] bytes = Encoding.UTF8.GetBytes(s);
			return BitConverter.ToInt32(MD5.Create().ComputeHash(bytes), 0);
		}

		private static string GetHierarchyPath(GameObject go)
		{
			string text = ((Object)go).name;
			Transform val = go.transform;
			while ((Object)(object)val.parent != (Object)null)
			{
				val = val.parent;
				text = ((Object)val).name + "/" + text;
			}
			return text;
		}

		private static int GenerateGameObjectID(GameObject obj)
		{
			return HashString(GetHierarchyPath(obj) + "$" + obj.transform.GetSiblingIndex());
		}

		private static void CacheProps()
		{
			_propByIndex.Clear();
			Junk[] array = Object.FindObjectsOfType<Junk>();
			foreach (Junk val in array)
			{
				StageChunk componentInParent = ((Component)val).GetComponentInParent<StageChunk>();
				JunkStageHandler componentInParent2 = ((Component)val).GetComponentInParent<JunkStageHandler>();
				if (!((Object)(object)componentInParent == (Object)null) || !((Object)(object)componentInParent2 == (Object)null))
				{
					int key = GenerateGameObjectID(((Component)val).gameObject);
					_propByIndex[key] = ((Component)val).gameObject;
				}
			}
			StreetLife[] array2 = Object.FindObjectsOfType<StreetLife>();
			foreach (StreetLife val2 in array2)
			{
				if (!((Object)(object)((Component)val2).GetComponentInParent<StageChunk>() == (Object)null) && !((Object)(object)((Component)val2).GetComponent<MoveAlongPoints>() != (Object)null))
				{
					int key2 = GenerateGameObjectID(((Component)val2).gameObject);
					_propByIndex[key2] = ((Component)val2).gameObject;
				}
			}
		}

		public static List<(int id, string label)> GetPropsForMenu()
		{
			CacheProps();
			List<(int, string)> list = new List<(int, string)>();
			foreach (KeyValuePair<int, GameObject> item in _propByIndex)
			{
				if (!((Object)(object)item.Value == (Object)null))
				{
					list.Add((item.Key, ((Object)item.Value).name));
				}
			}
			return list;
		}

		public static GameObject GetPropSourceById(int id)
		{
			CacheProps();
			if (!_propByIndex.TryGetValue(id, out var value))
			{
				return null;
			}
			return value;
		}

		public static int? GetNearestPropId(Player player)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			CacheProps();
			if (_propByIndex.Count == 0)
			{
				return null;
			}
			Vector3 position = ((Component)player).transform.position;
			int value = 0;
			float num = float.MaxValue;
			bool flag = true;
			foreach (KeyValuePair<int, GameObject> item in _propByIndex)
			{
				if (!((Object)(object)item.Value == (Object)null))
				{
					float num2 = Vector3.Distance(position, item.Value.transform.position);
					if (flag || num2 < num)
					{
						flag = false;
						num = num2;
						value = item.Key;
					}
				}
			}
			if (!flag)
			{
				return value;
			}
			return null;
		}

		public static bool HasDisguise(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			CleanupNullDisguises();
			if (_playerDisguises.TryGetValue(player, out (GameObject, int) value))
			{
				return (Object)(object)value.Item1 != (Object)null;
			}
			return false;
		}

		private static void CleanupNullDisguises()
		{
			List<Player> list = new List<Player>();
			foreach (KeyValuePair<Player, (GameObject, int)> playerDisguise in _playerDisguises)
			{
				if ((Object)(object)playerDisguise.Value.Item1 == (Object)null)
				{
					list.Add(playerDisguise.Key);
				}
			}
			foreach (Player item in list)
			{
				_playerDisguises.Remove(item);
			}
		}

		private static void SetPlayerVisualVisible(Player player, bool visible)
		{
			Transform value = Traverse.Create((object)player).Field("visualTf").GetValue<Transform>();
			if ((Object)(object)value != (Object)null && (Object)(object)((Component)value).gameObject != (Object)null)
			{
				((Component)value).gameObject.SetActive(visible);
			}
		}

		private static void AutoAdjustProp(GameObject disguise, Player player)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: 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_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			Renderer componentInChildren = disguise.GetComponentInChildren<Renderer>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return;
			}
			Bounds localBounds = componentInChildren.localBounds;
			Vector3[] array = (Vector3[])(object)new Vector3[8]
			{
				new Vector3(((Bounds)(ref localBounds)).min.x, ((Bounds)(ref localBounds)).min.y, ((Bounds)(ref localBounds)).min.z),
				new Vector3(((Bounds)(ref localBounds)).min.x, ((Bounds)(ref localBounds)).min.y, ((Bounds)(ref localBounds)).max.z),
				new Vector3(((Bounds)(ref localBounds)).min.x, ((Bounds)(ref localBounds)).max.y, ((Bounds)(ref localBounds)).max.z),
				new Vector3(((Bounds)(ref localBounds)).min.x, ((Bounds)(ref localBounds)).max.y, ((Bounds)(ref localBounds)).min.z),
				new Vector3(((Bounds)(ref localBounds)).max.x, ((Bounds)(ref localBounds)).max.y, ((Bounds)(ref localBounds)).max.z),
				new Vector3(((Bounds)(ref localBounds)).max.x, ((Bounds)(ref localBounds)).max.y, ((Bounds)(ref localBounds)).min.z),
				new Vector3(((Bounds)(ref localBounds)).max.x, ((Bounds)(ref localBounds)).min.y, ((Bounds)(ref localBounds)).min.z),
				new Vector3(((Bounds)(ref localBounds)).max.x, ((Bounds)(ref localBounds)).min.y, ((Bounds)(ref localBounds)).max.z)
			};
			Vector3 val = Vector3.zero;
			float num = float.MaxValue;
			for (int i = 0; i < array.Length; i++)
			{
				Vector3 val2 = ((Component)componentInChildren).transform.TransformPoint(array[i]);
				Vector3 val3 = ((Component)player).transform.InverseTransformPoint(val2);
				val += val3;
				if (val3.y < num)
				{
					num = val3.y;
				}
			}
			val /= (float)array.Length;
			val.y = num;
			disguise.transform.localPosition = -val;
		}

		public static bool ApplyDisguise(Player player, int disguiseId)
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			CacheProps();
			if (!_propByIndex.TryGetValue(disguiseId, out var value) || (Object)(object)value == (Object)null)
			{
				return false;
			}
			RemoveDisguise(player);
			SetPlayerVisualVisible(player, visible: false);
			GameObject val = Object.Instantiate<GameObject>(value);
			val.SetActive(true);
			bool flag = false;
			Junk component = val.GetComponent<Junk>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
				flag = true;
			}
			Rigidbody component2 = val.GetComponent<Rigidbody>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
			StreetLife component3 = val.GetComponent<StreetLife>();
			if ((Object)(object)component3 != (Object)null)
			{
				Animator component4 = val.GetComponent<Animator>();
				if ((Object)(object)component4 != (Object)null)
				{
					int num = Animator.StringToHash(((object)(IdleAnimation)(ref component3.idleAnimation)).ToString());
					component4.Play(num, 0);
				}
				Object.Destroy((Object)(object)component3);
			}
			val.transform.SetParent(((Component)player).transform);
			val.transform.SetLocalPositionAndRotation(Vector3.zero, Quaternion.identity);
			if (flag)
			{
				val.transform.rotation = value.transform.rotation;
			}
			val.transform.localScale = value.transform.localScale;
			if ((Object)(object)WorldHandler.instance != (Object)null && (Object)(object)WorldHandler.instance.GetCurrentPlayer() == (Object)(object)player)
			{
				if ((Object)(object)component3 == (Object)null)
				{
					AutoAdjustProp(val, player);
				}
				val.layer = 15;
				Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>();
				foreach (Collider val2 in componentsInChildren)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						Object.Destroy((Object)(object)val2);
					}
				}
			}
			_playerDisguises[player] = (val, disguiseId);
			return true;
		}

		public static bool RemoveDisguise(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			CleanupNullDisguises();
			if (!_playerDisguises.TryGetValue(player, out (GameObject, int) value))
			{
				return false;
			}
			_playerDisguises.Remove(player);
			if ((Object)(object)value.Item1 != (Object)null)
			{
				Object.Destroy((Object)(object)value.Item1);
			}
			SetPlayerVisualVisible(player, visible: true);
			return true;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BRCPlus";

		public const string PLUGIN_NAME = "BRCPlus";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace BRCPlus.Phone
{
	public class AppBRCPlus : CustomApp
	{
		private static List<GameObject> _spawnedObjects = new List<GameObject>();

		private const int SaveFilesSlotCount = 3;

		private static readonly (string Label, Stage Stage)[] TravelableMaps = new(string, Stage)[8]
		{
			("Hideout", (Stage)5),
			("Police Station", (Stage)8),
			("Versum Hill", (Stage)4),
			("Millennium Mall", (Stage)6),
			("Mataan", (Stage)7),
			("Pyramid Island", (Stage)9),
			("Millennium Square", (Stage)11),
			("Brink Terminal", (Stage)12)
		};

		public static void RemoveAllSpawnedObjects()
		{
			foreach (GameObject spawnedObject in _spawnedObjects)
			{
				if ((Object)(object)spawnedObject != (Object)null)
				{
					Object.Destroy((Object)(object)spawnedObject);
				}
			}
			_spawnedObjects.Clear();
		}

		private static void SetLayerRecursively(GameObject go, int layer)
		{
			if (!((Object)(object)go == (Object)null))
			{
				go.layer = layer;
				for (int i = 0; i < go.transform.childCount; i++)
				{
					SetLayerRecursively(((Component)go.transform.GetChild(i)).gameObject, layer);
				}
			}
		}

		public static void Initialize()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Sprite val = null;
			string appIconPath = BRCPlusPlugin.GetAppIconPath("AppIcon.png");
			if (!string.IsNullOrEmpty(appIconPath) && File.Exists(appIconPath))
			{
				try
				{
					byte[] array = File.ReadAllBytes(appIconPath);
					Texture2D val2 = new Texture2D(2, 2);
					if (ImageConversion.LoadImage(val2, array))
					{
						((Texture)val2).wrapMode = (TextureWrapMode)1;
						((Texture)val2).filterMode = (FilterMode)1;
						val2.Apply();
						val = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f));
					}
				}
				catch
				{
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				PhoneAPI.RegisterApp<AppBRCPlus>("BRC Plus", val);
			}
			else
			{
				PhoneAPI.RegisterApp<AppBRCPlus>("BRC Plus", (Sprite)null);
			}
		}

		public override void OnAppInit()
		{
			((CustomApp)this).OnAppInit();
			((CustomApp)this).CreateIconlessTitleBar("BRC Plus", 80f);
			base.ScrollView = PhoneScrollView.Create((CustomApp)(object)this, 275f, 1600f);
			PopulateButtons();
		}

		public override void OnAppEnable()
		{
			((App)this).OnAppEnable();
			PopulateButtons();
		}

		private void PopulateButtons()
		{
			base.ScrollView.RemoveAllButtons();
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Fun");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, new Action(ShowFunMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Toggles");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(ShowTogglesMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Maps");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(ShowMapsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Movement");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(ShowMovementMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Characters");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(ShowCharactersMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
			SimplePhoneButton val6 = PhoneUIUtility.CreateSimpleButton("Graffiti");
			((PhoneButton)val6).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val6).OnConfirm, new Action(ShowGraffitiMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val6);
			SimplePhoneButton val7 = PhoneUIUtility.CreateSimpleButton("Heat");
			((PhoneButton)val7).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val7).OnConfirm, new Action(ShowHeatMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val7);
			SimplePhoneButton val8 = PhoneUIUtility.CreateSimpleButton("Optimize");
			((PhoneButton)val8).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val8).OnConfirm, new Action(ShowOptimizeMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val8);
			SimplePhoneButton val9 = PhoneUIUtility.CreateSimpleButton("UI Options");
			((PhoneButton)val9).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val9).OnConfirm, new Action(ShowUIOptionsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val9);
			SimplePhoneButton val10 = PhoneUIUtility.CreateSimpleButton("Cut Scenes");
			((PhoneButton)val10).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val10).OnConfirm, new Action(ShowCutScenesMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val10);
			SimplePhoneButton val11 = PhoneUIUtility.CreateSimpleButton("Save Files");
			((PhoneButton)val11).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val11).OnConfirm, new Action(ShowSaveFilesMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val11);
		}

		private static List<(string label, Func<PlayableDirector> getter)> GetCutsceneEntries()
		{
			return new List<(string, Func<PlayableDirector>)>
			{
				("Police 0 Stars", () => GetPoliceCutscene(0)),
				("Police 1 Star", () => GetPoliceCutscene(1)),
				("Police 2 Stars", () => GetPoliceCutscene(2)),
				("Police 3 Stars", () => GetPoliceCutscene(3)),
				("Police 4 Stars", () => GetPoliceCutscene(4)),
				("Police 5 Stars", () => GetPoliceCutscene(5)),
				("Police 6 Stars", () => GetPoliceCutscene(6)),
				("Combo Mascot Open Door", delegate
				{
					ComboMascotSystem val2 = Object.FindObjectOfType<ComboMascotSystem>();
					return (!((Object)(object)val2 != (Object)null)) ? null : val2.openDoorSequence;
				}),
				("Public Toilet", delegate
				{
					PublicToilet val = Object.FindObjectOfType<PublicToilet>();
					return (!((Object)(object)val != (Object)null)) ? null : Traverse.Create((object)val).Field("sequence").GetValue<PlayableDirector>();
				})
			};
		}

		private static PlayableDirector GetPoliceCutscene(int stars)
		{
			PoliceCutscenes val = Object.FindObjectOfType<PoliceCutscenes>();
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			string text = "cutsceneFor" + stars + "Stars";
			return Traverse.Create((object)val).Field(text).GetValue<PlayableDirector>();
		}

		private void ShowCutScenesMenu()
		{
			base.ScrollView.RemoveAllButtons();
			foreach (var cutsceneEntry in GetCutsceneEntries())
			{
				string item = cutsceneEntry.label;
				Func<PlayableDirector> getter = cutsceneEntry.getter;
				SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton(item);
				((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
				{
					PlayableDirector val3 = getter();
					if (!((Object)(object)val3 == (Object)null) && !((Object)(object)SequenceHandler.instance == (Object)null))
					{
						SequenceHandler.instance.StartEnteringSequence(val3, (GameplayEvent)null, true, true, true, true, true, (ProgressObject)null, true, false, (Battle)null, false);
					}
				});
				base.ScrollView.AddButton((PhoneButton)(object)val);
			}
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
		}

		private void ShowSaveFilesMenu()
		{
			base.ScrollView.RemoveAllButtons();
			Core instance = Core.Instance;
			SaveManager saveManager = ((instance != null) ? instance.SaveManager : null);
			BaseModule baseModule = ((instance != null) ? instance.BaseModule : null);
			if (saveManager == null || (Object)(object)baseModule == (Object)null)
			{
				SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Save data unavailable");
				((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
				{
				});
				base.ScrollView.AddButton((PhoneButton)(object)val);
				SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Back");
				((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(PopulateButtons));
				base.ScrollView.AddButton((PhoneButton)(object)val2);
				return;
			}
			for (int i = 0; i < 3; i++)
			{
				SaveSlotData saveSlotData = saveManager.GetSaveSlotData(i);
				int slot = i;
				SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton(GetSaveSlotButtonLabel(i + 1, saveSlotData, instance.Localizer));
				((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, (Action)delegate
				{
					LoadIntoSaveSlot(slot, saveManager, baseModule);
				});
				base.ScrollView.AddButton((PhoneButton)(object)val3);
			}
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
		}

		private static string GetSaveSlotButtonLabel(int displayNumber, SaveSlotData data, IGameTextLocalizer localizer)
		{
			//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_0020: Expected I4, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (data == null)
			{
				return $"Save {displayNumber} (Empty)";
			}
			int num = (int)Story.GetObjectiveInfo(data).chapter;
			object obj = ((localizer != null) ? localizer.GetStageName(data.CurrentStage) : null);
			if (obj == null)
			{
				Stage currentStage = data.CurrentStage;
				obj = ((object)(Stage)(ref currentStage)).ToString();
			}
			string arg = (string)obj;
			return $"Save {displayNumber} - Chapter {num} ({arg})";
		}

		private void LoadIntoSaveSlot(int slotId, SaveManager saveManager, BaseModule baseModule)
		{
			//IL_0031: 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_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)
			if (baseModule.IsLoading || !saveManager.IsSaveSlotOccupied(slotId))
			{
				return;
			}
			SaveSlotData currentSaveSlot = saveManager.CurrentSaveSlot;
			if (currentSaveSlot != null && currentSaveSlot.saveSlotId == slotId)
			{
				Stage currentStage = saveManager.CurrentSaveSlot.CurrentStage;
				if (baseModule.CurrentStage == currentStage)
				{
					return;
				}
			}
			((MonoBehaviour)baseModule).StartCoroutine(LoadIntoSaveSlotAtEndOfFrame(slotId, saveManager, baseModule));
		}

		private static IEnumerator LoadIntoSaveSlotAtEndOfFrame(int slotId, SaveManager saveManager, BaseModule baseModule)
		{
			yield return (object)new WaitForEndOfFrame();
			if (!baseModule.IsLoading && saveManager.IsSaveSlotOccupied(slotId))
			{
				saveManager.SaveBeforeStageExit();
				saveManager.SetCurrentSaveSlot(slotId);
				SaveSlotData currentSaveSlot = saveManager.CurrentSaveSlot;
				Stage val = (Stage)((currentSaveSlot == null) ? 5 : ((int)currentSaveSlot.CurrentStage));
				if (baseModule.IsInGamePaused)
				{
					baseModule.UnPauseGame((PauseType)65535);
				}
				baseModule.SwitchStage(val);
			}
		}

		private void ShowFunMenu()
		{
			base.ScrollView.RemoveAllButtons();
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Props");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, new Action(ShowPropsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val);
			BRCPlusPlugin.NormalizePlayerSizeConfig();
			string text = BRCPlusPlugin.PlayerSize?.Value ?? "Normal";
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Player Size: " + text);
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.PlayerSize != null)
				{
					string[] playerSizeOptions = BRCPlusPlugin.PlayerSizeOptions;
					int num2 = Array.IndexOf(playerSizeOptions, BRCPlusPlugin.PlayerSize.Value);
					num2 = ((num2 >= 0) ? (num2 + 1) : 0) % playerSizeOptions.Length;
					BRCPlusPlugin.PlayerSize.Value = playerSizeOptions[num2];
					ShowFunMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			BRCPlusPlugin.NormalizeGravityConfig();
			string text2 = BRCPlusPlugin.Gravity?.Value ?? "Normal";
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Gravity: " + text2);
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.Gravity != null)
				{
					string[] gravityOptions = BRCPlusPlugin.GravityOptions;
					int num = Array.IndexOf(gravityOptions, BRCPlusPlugin.Gravity.Value);
					num = ((num >= 0) ? (num + 1) : 0) % gravityOptions.Length;
					BRCPlusPlugin.Gravity.Value = gravityOptions[num];
					ShowFunMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Spawn Something");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(ShowSpawnSomethingMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
		}

		private void ShowSpawnSomethingMenu()
		{
			base.ScrollView.RemoveAllButtons();
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Remove Spawned Objects");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
			{
				RemoveAllSpawnedObjects();
				ShowSpawnSomethingMenu();
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Spawn Props");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(ShowSpawnPropsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Spawn Character");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(ShowSpawnNPCMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Spawn Vending Machine");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, (Action)delegate
			{
				//IL_0033: 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_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: 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_0096: 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_0060: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				WorldHandler instance2 = WorldHandler.instance;
				Player val12 = ((instance2 != null) ? instance2.GetCurrentPlayer() : null);
				if (!((Object)(object)val12 == (Object)null))
				{
					VendingMachine val13 = Object.FindObjectOfType<VendingMachine>(true);
					if (!((Object)(object)val13 == (Object)null))
					{
						Vector3 val14 = Vector3.ProjectOnPlane(val12.tf.forward, Vector3.up);
						Vector3 val15 = ((Vector3)(ref val14)).normalized;
						if (((Vector3)(ref val15)).sqrMagnitude < 0.01f)
						{
							val15 = val12.tf.forward;
						}
						Vector3 position2 = val12.tf.position + val15 * 3f;
						GameObject val16 = Object.Instantiate<GameObject>(((Component)val13).gameObject);
						val16.transform.position = position2;
						val16.transform.rotation = Quaternion.LookRotation(val15);
						BreakableObject[] componentsInChildren = val16.GetComponentsInChildren<BreakableObject>(true);
						for (int i = 0; i < componentsInChildren.Length; i++)
						{
							Object.Destroy((Object)(object)componentsInChildren[i]);
						}
						BoxCollider component = val16.GetComponent<BoxCollider>();
						if ((Object)(object)component != (Object)null && ((Collider)component).isTrigger)
						{
							BoxCollider obj = val16.AddComponent<BoxCollider>();
							obj.center = component.center;
							obj.size = component.size;
							((Collider)obj).isTrigger = false;
						}
						SetLayerRecursively(val16, 0);
						val16.SetActive(true);
						_spawnedObjects.Add(val16);
					}
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Spawn Car");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, (Action)delegate
			{
				//IL_0033: 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_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: 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_0096: 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_0060: 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)
				WorldHandler instance = WorldHandler.instance;
				Player val7 = ((instance != null) ? instance.GetCurrentPlayer() : null);
				if (!((Object)(object)val7 == (Object)null))
				{
					Car val8 = Object.FindObjectOfType<Car>(true);
					if (!((Object)(object)val8 == (Object)null))
					{
						Vector3 val9 = Vector3.ProjectOnPlane(val7.tf.forward, Vector3.up);
						Vector3 val10 = ((Vector3)(ref val9)).normalized;
						if (((Vector3)(ref val10)).sqrMagnitude < 0.01f)
						{
							val10 = val7.tf.forward;
						}
						Vector3 position = val7.tf.position + val10 * 3f;
						GameObject val11 = Object.Instantiate<GameObject>(((Component)val8).gameObject);
						val11.transform.position = position;
						val11.transform.rotation = Quaternion.LookRotation(val10);
						SetLayerRecursively(val11, 0);
						val11.SetActive(true);
						_spawnedObjects.Add(val11);
					}
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val5);
			SimplePhoneButton val6 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val6).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val6).OnConfirm, new Action(ShowFunMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val6);
		}

		private void ShowSpawnNPCMenu()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			base.ScrollView.RemoveAllButtons();
			foreach (Characters value in Enum.GetValues(typeof(Characters)))
			{
				if ((int)value == -1 || (int)value == 26)
				{
					continue;
				}
				Characters character = value;
				SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton(GetCharacterDisplayName(character));
				((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
				{
					//IL_0024: Unknown result type (might be due to invalid IL or missing references)
					//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_0059: Unknown result type (might be due to invalid IL or missing references)
					//IL_005e: Unknown result type (might be due to invalid IL or missing references)
					//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)
					//IL_0088: Unknown result type (might be due to invalid IL or missing references)
					//IL_008d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0093: Unknown result type (might be due to invalid IL or missing references)
					//IL_0098: Unknown result type (might be due to invalid IL or missing references)
					//IL_009d: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
					//IL_00bd: 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)
					WorldHandler instance = WorldHandler.instance;
					Player val4 = ((instance != null) ? instance.GetCurrentPlayer() : null);
					if ((Object)(object)val4 == (Object)null)
					{
						return;
					}
					try
					{
						CharacterVisual val5 = val4.CharacterConstructor.CreateNewCharacterVisual(character, val4.animatorController, false, 0f);
						if (!((Object)(object)val5 == (Object)null))
						{
							Vector3 val6 = Vector3.ProjectOnPlane(val4.tf.forward, Vector3.up);
							Vector3 val7 = ((Vector3)(ref val6)).normalized;
							if (((Vector3)(ref val7)).sqrMagnitude < 0.01f)
							{
								val7 = val4.tf.forward;
							}
							Vector3 position = val4.tf.position + val7 * 3f;
							((Component)val5).gameObject.SetActive(true);
							((Component)val5).transform.position = position;
							((Component)val5).transform.rotation = Quaternion.LookRotation(val7);
							_spawnedObjects.Add(((Component)val5).gameObject);
						}
					}
					catch
					{
					}
				});
				base.ScrollView.AddButton((PhoneButton)(object)val2);
			}
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(ShowSpawnSomethingMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
		}

		private void ShowSpawnPropsMenu()
		{
			base.ScrollView.RemoveAllButtons();
			foreach (var item3 in PropDisguiseManager.GetPropsForMenu())
			{
				int item = item3.id;
				string item2 = item3.label;
				int propId = item;
				SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton(item2);
				((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
				{
					//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_0042: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					//IL_004b: 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_0071: Unknown result type (might be due to invalid IL or missing references)
					//IL_0076: Unknown result type (might be due to invalid IL or missing references)
					//IL_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_009e: 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_0065: Unknown result type (might be due to invalid IL or missing references)
					//IL_006a: Unknown result type (might be due to invalid IL or missing references)
					WorldHandler instance = WorldHandler.instance;
					Player val3 = ((instance != null) ? instance.GetCurrentPlayer() : null);
					if (!((Object)(object)val3 == (Object)null))
					{
						GameObject propSourceById = PropDisguiseManager.GetPropSourceById(propId);
						if (!((Object)(object)propSourceById == (Object)null))
						{
							Vector3 val4 = Vector3.ProjectOnPlane(val3.tf.forward, Vector3.up);
							Vector3 val5 = ((Vector3)(ref val4)).normalized;
							if (((Vector3)(ref val5)).sqrMagnitude < 0.01f)
							{
								val5 = val3.tf.forward;
							}
							Vector3 position = val3.tf.position + val5 * 3f;
							GameObject val6 = Object.Instantiate<GameObject>(propSourceById);
							val6.SetActive(true);
							val6.transform.position = position;
							val6.transform.rotation = propSourceById.transform.rotation;
							_spawnedObjects.Add(val6);
						}
					}
				});
				base.ScrollView.AddButton((PhoneButton)(object)val);
			}
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(ShowSpawnSomethingMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
		}

		private void ShowPropsMenu()
		{
			base.ScrollView.RemoveAllButtons();
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Turn Into Nearest Prop");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
			{
				WorldHandler instance2 = WorldHandler.instance;
				Player val6 = ((instance2 != null) ? instance2.GetCurrentPlayer() : null);
				if (!((Object)(object)val6 == (Object)null))
				{
					int? nearestPropId = PropDisguiseManager.GetNearestPropId(val6);
					if (nearestPropId.HasValue)
					{
						PropDisguiseManager.ApplyDisguise(val6, nearestPropId.Value);
					}
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Remove Prop");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
			{
				WorldHandler instance = WorldHandler.instance;
				Player val5 = ((instance != null) ? instance.GetCurrentPlayer() : null);
				if (!((Object)(object)val5 == (Object)null) && PropDisguiseManager.HasDisguise(val5))
				{
					PropDisguiseManager.RemoveDisguise(val5);
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Props in this map");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(ShowPropsInThisMapMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(ShowFunMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
		}

		private void ShowPropsInThisMapMenu()
		{
			base.ScrollView.RemoveAllButtons();
			foreach (var item3 in PropDisguiseManager.GetPropsForMenu())
			{
				int item = item3.id;
				string item2 = item3.label;
				int propId = item;
				SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton(item2);
				((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
				{
					WorldHandler instance = WorldHandler.instance;
					Player val3 = ((instance != null) ? instance.GetCurrentPlayer() : null);
					if (!((Object)(object)val3 == (Object)null))
					{
						PropDisguiseManager.ApplyDisguise(val3, propId);
					}
				});
				base.ScrollView.AddButton((PhoneButton)(object)val);
			}
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(ShowPropsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
		}

		private void ShowMapsMenu()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			base.ScrollView.RemoveAllButtons();
			(string, Stage)[] travelableMaps = TravelableMaps;
			for (int i = 0; i < travelableMaps.Length; i++)
			{
				(string, Stage) tuple = travelableMaps[i];
				string item = tuple.Item1;
				Stage item2 = tuple.Item2;
				SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton(item);
				Stage stageToLoad = item2;
				((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					TravelToStage(stageToLoad);
				});
				base.ScrollView.AddButton((PhoneButton)(object)val);
			}
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
		}

		private void TravelToStage(Stage stage)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			Core instance = Core.Instance;
			if ((Object)(object)((instance != null) ? instance.BaseModule : null) == (Object)null)
			{
				return;
			}
			BaseModule baseModule = instance.BaseModule;
			if (baseModule.IsLoading)
			{
				return;
			}
			StageManager stageManager = baseModule.StageManager;
			if (stageManager != null)
			{
				if (baseModule.IsInGamePaused)
				{
					baseModule.UnPauseGame((PauseType)65535);
				}
				stageManager.ExitCurrentStage(stage, (Stage)(-1));
			}
		}

		private void ShowGraffitiMenu()
		{
			base.ScrollView.RemoveAllButtons();
			BRCPlusPlugin.NormalizeSprayModeConfig();
			string text = BRCPlusPlugin.SprayMode?.Value ?? "Normal";
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Spray Mode: " + text);
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.SprayMode != null)
				{
					string[] sprayModeOptions = BRCPlusPlugin.SprayModeOptions;
					int num = Array.IndexOf(sprayModeOptions, BRCPlusPlugin.SprayMode.Value);
					num = ((num >= 0) ? (num + 1) : 0) % sprayModeOptions.Length;
					BRCPlusPlugin.SprayMode.Value = sprayModeOptions[num];
					ShowGraffitiMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			bool flag = BRCPlusPlugin.GetBoostsFromGraffiti?.Value ?? true;
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Get Boosts From Graffiti: " + (flag ? "On" : "Off"));
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.GetBoostsFromGraffiti != null)
				{
					BRCPlusPlugin.GetBoostsFromGraffiti.Value = !BRCPlusPlugin.GetBoostsFromGraffiti.Value;
					ShowGraffitiMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
		}

		private void ShowHeatMenu()
		{
			base.ScrollView.RemoveAllButtons();
			bool flag = BRCPlusPlugin.DisableHeat?.Value ?? false;
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Disable Heat: " + (flag ? "On" : "Off"));
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.DisableHeat != null)
				{
					BRCPlusPlugin.DisableHeat.Value = !BRCPlusPlugin.DisableHeat.Value;
					ShowHeatMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Add Heat");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(AddHeat));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Remove Heat");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(RemoveHeat));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
		}

		private void ShowCharactersMenu()
		{
			base.ScrollView.RemoveAllButtons();
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Base Characters");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, new Action(ShowBaseCharactersMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val);
			if (IsCrewBoomOrCharacterSwapAvailable())
			{
				SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Custom Characters");
				((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(ShowCustomCharactersMenu));
				base.ScrollView.AddButton((PhoneButton)(object)val2);
			}
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Swap Outfit");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(SwapOutfit));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Swap Style");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(SwapStyle));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Random Character");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(RandomCharacter));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
			SimplePhoneButton val6 = PhoneUIUtility.CreateSimpleButton("Random Outfit");
			((PhoneButton)val6).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val6).OnConfirm, new Action(RandomOutfit));
			base.ScrollView.AddButton((PhoneButton)(object)val6);
			SimplePhoneButton val7 = PhoneUIUtility.CreateSimpleButton("Full Random");
			((PhoneButton)val7).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val7).OnConfirm, new Action(FullRandom));
			base.ScrollView.AddButton((PhoneButton)(object)val7);
			SimplePhoneButton val8 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val8).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val8).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val8);
		}

		private void ShowCustomCharactersMenu()
		{
			base.ScrollView.RemoveAllButtons();
			Dictionary<int, string> dictionary = TryGetCustomCharactersList();
			if (dictionary != null && dictionary.Count > 0)
			{
				foreach (KeyValuePair<int, string> item in dictionary.OrderBy<KeyValuePair<int, string>, string>((KeyValuePair<int, string> kv) => kv.Value, StringComparer.OrdinalIgnoreCase).ThenBy((KeyValuePair<int, string> kv) => kv.Key).ToList())
				{
					int characterId = item.Key;
					SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton(item.Value);
					((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
					{
						SwapToCharacter((Characters)characterId);
					});
					base.ScrollView.AddButton((PhoneButton)(object)val);
				}
			}
			else
			{
				SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("No custom characters loaded");
				((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
				{
				});
				base.ScrollView.AddButton((PhoneButton)(object)val2);
			}
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(ShowCharactersMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
		}

		private static void SwapStyle()
		{
			//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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Invalid comparison between Unknown and I4
			//IL_007f: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Invalid comparison between Unknown and I4
			WorldHandler instance = WorldHandler.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Player currentPlayer = instance.GetCurrentPlayer();
			if ((Object)(object)currentPlayer == (Object)null || GetPlayerIsAI(currentPlayer))
			{
				return;
			}
			Core instance2 = Core.Instance;
			object obj;
			if (instance2 == null)
			{
				obj = null;
			}
			else
			{
				SaveManager saveManager = instance2.SaveManager;
				obj = ((saveManager != null) ? saveManager.CurrentSaveSlot : null);
			}
			SaveSlotData val = (SaveSlotData)obj;
			if (val == null)
			{
				return;
			}
			Characters playerCharacter = GetPlayerCharacter(currentPlayer);
			CharacterProgress characterProgress = val.GetCharacterProgress(playerCharacter);
			if (characterProgress != null)
			{
				MoveStyle val2 = GetPlayerMoveStyleEquipped(currentPlayer);
				if ((int)val2 == 0 || (int)val2 == 4 || (int)val2 == 5)
				{
					val2 = characterProgress.moveStyle;
				}
				MoveStyle nextMoveStyleInCycle = GetNextMoveStyleInCycle(val2);
				currentPlayer.SetCurrentMoveStyleEquipped(nextMoveStyleInCycle, true, true);
				currentPlayer.SwitchToEquippedMovestyle(true, false, true, true);
				characterProgress.moveStyle = nextMoveStyleInCycle;
				Core.Instance.SaveManager.SaveCurrentSaveSlot();
			}
		}

		private static MoveStyle GetNextMoveStyleInCycle(MoveStyle current)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected I4, but got Unknown
			return (MoveStyle)((current - 1) switch
			{
				1 => 3, 
				2 => 1, 
				0 => 2, 
				_ => 2, 
			});
		}

		private static MoveStyle GetPlayerMoveStyleEquipped(Player player)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			return Traverse.Create((object)player).Field("moveStyleEquipped").GetValue<MoveStyle>();
		}

		private static List<Characters> GetAvailableCharacters()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			List<Characters> list = new List<Characters>();
			foreach (Characters value in Enum.GetValues(typeof(Characters)))
			{
				if ((int)value != -1 && (int)value != 26 && IsBaseCharacterAvailable(value))
				{
					list.Add(value);
				}
			}
			Dictionary<int, string> dictionary = TryGetCustomCharactersList();
			if (dictionary != null)
			{
				foreach (int key in dictionary.Keys)
				{
					Characters item = (Characters)key;
					if (!list.Contains(item))
					{
						list.Add(item);
					}
				}
			}
			return list;
		}

		private static void RandomCharacter()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			List<Characters> availableCharacters = GetAvailableCharacters();
			if (availableCharacters == null || availableCharacters.Count == 0)
			{
				return;
			}
			WorldHandler instance = WorldHandler.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				Player currentPlayer = instance.GetCurrentPlayer();
				if (!((Object)(object)currentPlayer == (Object)null) && !GetPlayerIsAI(currentPlayer))
				{
					SwapToCharacter(availableCharacters[Random.Range(0, availableCharacters.Count)]);
				}
			}
		}

		private static void RandomOutfit()
		{
			//IL_009d: 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_0053: 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)
			WorldHandler instance = WorldHandler.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Player currentPlayer = instance.GetCurrentPlayer();
			if ((Object)(object)currentPlayer == (Object)null || GetPlayerIsAI(currentPlayer))
			{
				return;
			}
			Core instance2 = Core.Instance;
			object obj;
			if (instance2 == null)
			{
				obj = null;
			}
			else
			{
				SaveManager saveManager = instance2.SaveManager;
				obj = ((saveManager != null) ? saveManager.CurrentSaveSlot : null);
			}
			SaveSlotData val = (SaveSlotData)obj;
			if (val == null)
			{
				return;
			}
			Characters playerCharacter = GetPlayerCharacter(currentPlayer);
			CharacterProgress characterProgress = val.GetCharacterProgress(playerCharacter);
			if (characterProgress == null)
			{
				return;
			}
			int num = Random.Range(0, 4);
			try
			{
				currentPlayer.SetOutfit(num);
				instance.SetNPCOutfit(playerCharacter, num);
				characterProgress.outfit = num;
				Core.Instance.SaveManager.SaveCurrentSaveSlot();
			}
			catch (NoOutfitException)
			{
				try
				{
					currentPlayer.SetOutfit(0);
					instance.SetNPCOutfit(playerCharacter, 0);
					characterProgress.outfit = 0;
					Core.Instance.SaveManager.SaveCurrentSaveSlot();
				}
				catch (NoOutfitException)
				{
				}
			}
		}

		private static void FullRandom()
		{
			RandomCharacter();
			RandomOutfit();
		}

		private static void SwapOutfit()
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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)
			WorldHandler instance = WorldHandler.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Player currentPlayer = instance.GetCurrentPlayer();
			if ((Object)(object)currentPlayer == (Object)null)
			{
				return;
			}
			Core instance2 = Core.Instance;
			object obj;
			if (instance2 == null)
			{
				obj = null;
			}
			else
			{
				SaveManager saveManager = instance2.SaveManager;
				obj = ((saveManager != null) ? saveManager.CurrentSaveSlot : null);
			}
			SaveSlotData val = (SaveSlotData)obj;
			if (val == null)
			{
				return;
			}
			Characters playerCharacter = GetPlayerCharacter(currentPlayer);
			CharacterProgress characterProgress = val.GetCharacterProgress(playerCharacter);
			if (characterProgress == null)
			{
				return;
			}
			int num = (characterProgress.outfit + 1) % 4;
			try
			{
				currentPlayer.SetOutfit(num);
				instance.SetNPCOutfit(playerCharacter, num);
				Core.Instance.SaveManager.SaveCurrentSaveSlot();
			}
			catch (NoOutfitException)
			{
				try
				{
					currentPlayer.SetOutfit(0);
					instance.SetNPCOutfit(playerCharacter, 0);
					characterProgress.outfit = 0;
					Core.Instance.SaveManager.SaveCurrentSaveSlot();
				}
				catch (NoOutfitException)
				{
				}
			}
		}

		private static Characters GetPlayerCharacter(Player player)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			return Traverse.Create((object)player).Field("character").GetValue<Characters>();
		}

		private static bool GetPlayerIsAI(Player player)
		{
			return Traverse.Create((object)player).Field("isAI").GetValue<bool>();
		}

		private static CharacterVisual GetPlayerCharacterVisual(Player player)
		{
			return Traverse.Create((object)player).Field("characterVisual").GetValue<CharacterVisual>();
		}

		private static bool IsCrewBoomOrCharacterSwapAvailable()
		{
			try
			{
				if (Chainloader.PluginInfos == null)
				{
					return false;
				}
				foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
				{
					PluginInfo value = pluginInfo.Value;
					object obj;
					if (value == null)
					{
						obj = null;
					}
					else
					{
						BepInPlugin metadata = value.Metadata;
						obj = ((metadata != null) ? metadata.GUID : null);
					}
					if (obj == null)
					{
						obj = "";
					}
					string text = (string)obj;
					if (text.IndexOf("CrewBoom", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("CharacterSwapApp", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return true;
					}
				}
				return false;
			}
			catch
			{
				return false;
			}
		}

		private static Dictionary<int, string> TryGetCustomCharactersList()
		{
			if (!IsCrewBoomOrCharacterSwapAvailable())
			{
				return null;
			}
			try
			{
				Type type = null;
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					try
					{
						type = assembly.GetType("CharacterSwapApp.AppCharacterSwapList");
						if (type != null)
						{
							break;
						}
					}
					catch
					{
					}
				}
				if (type == null)
				{
					return null;
				}
				MethodInfo method = type.GetMethod("ListOfCustomCharacters", BindingFlags.Static | BindingFlags.Public);
				if (method == null)
				{
					return null;
				}
				if (method.Invoke(null, null) is Dictionary<int, string> result)
				{
					return result;
				}
				return null;
			}
			catch
			{
				return null;
			}
		}

		private static bool IsBaseCharacterAvailable(Characters c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			if ((int)c != 17 && (int)c != 18)
			{
				return true;
			}
			Core instance = Core.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				APlatform platform = instance.Platform;
				obj = ((platform != null) ? platform.DownloadableContent : null);
			}
			if (obj == null || (Object)(object)instance.BaseModule == (Object)null)
			{
				return false;
			}
			object value = Traverse.Create((object)instance.BaseModule).Field("characterDownloadableContent").GetValue();
			if (value == null)
			{
				return false;
			}
			return instance.Platform.DownloadableContent.IsDownloadableContentUnlocked((DownloadableContentItem)((value is DownloadableContentItem) ? value : null));
		}

		private void ShowBaseCharactersMenu()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			base.ScrollView.RemoveAllButtons();
			foreach (Characters value in Enum.GetValues(typeof(Characters)))
			{
				if ((int)value != -1 && (int)value != 26 && IsBaseCharacterAvailable(value))
				{
					Characters character = value;
					SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton(GetCharacterDisplayName(character));
					((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
					{
						//IL_0001: Unknown result type (might be due to invalid IL or missing references)
						SwapToCharacter(character);
					});
					base.ScrollView.AddButton((PhoneButton)(object)val2);
				}
			}
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(ShowCharactersMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
		}

		private static string GetCharacterDisplayName(Characters c)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			Core instance = Core.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				IGameTextLocalizer localizer = instance.Localizer;
				obj = ((localizer != null) ? localizer.GetCharacterName(c) : null);
			}
			string text = (string)obj;
			if (!string.IsNullOrEmpty(text))
			{
				return text;
			}
			string text2 = ((object)(Characters)(ref c)).ToString();
			if (string.IsNullOrEmpty(text2))
			{
				return text2;
			}
			string text3 = char.ToUpperInvariant(text2[0]).ToString();
			for (int i = 1; i < text2.Length; i++)
			{
				text3 = ((!char.IsUpper(text2[i])) ? (text3 + text2[i]) : (text3 + " " + text2[i]));
			}
			return text3;
		}

		private static void SwapToCharacter(Characters character)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			WorldHandler instance = WorldHandler.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Player currentPlayer = instance.GetCurrentPlayer();
			if ((Object)(object)currentPlayer == (Object)null)
			{
				return;
			}
			Core instance2 = Core.Instance;
			object obj;
			if (instance2 == null)
			{
				obj = null;
			}
			else
			{
				SaveManager saveManager = instance2.SaveManager;
				obj = ((saveManager != null) ? saveManager.CurrentSaveSlot : null);
			}
			SaveSlotData val = (SaveSlotData)obj;
			int num = 0;
			MoveStyle val2 = (MoveStyle)2;
			if (val != null)
			{
				CharacterProgress characterProgress = val.GetCharacterProgress(character);
				if (characterProgress != null)
				{
					num = characterProgress.outfit;
					val2 = characterProgress.moveStyle;
				}
			}
			currentPlayer.SetCharacter(character, num);
			currentPlayer.InitVisual();
			currentPlayer.SetCurrentMoveStyleEquipped(val2, true, true);
		}

		private void ShowMovementMenu()
		{
			base.ScrollView.RemoveAllButtons();
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Goons");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, new Action(ShowGoonsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val);
			bool flag = BRCPlusPlugin.InfiniteBoost?.Value ?? false;
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Infinite Boost: " + (flag ? "On" : "Off"));
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.InfiniteBoost != null)
				{
					BRCPlusPlugin.InfiniteBoost.Value = !BRCPlusPlugin.InfiniteBoost.Value;
					ShowMovementMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			bool flag2 = BRCPlusPlugin.InfiniteAirDash?.Value ?? false;
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Infinite Air Dash: " + (flag2 ? "On" : "Off"));
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.InfiniteAirDash != null)
				{
					BRCPlusPlugin.InfiniteAirDash.Value = !BRCPlusPlugin.InfiniteAirDash.Value;
					ShowMovementMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			bool flag3 = BRCPlusPlugin.AlwaysInSpeedZone?.Value ?? false;
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Always In Speed Zone: " + (flag3 ? "On" : "Off"));
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.AlwaysInSpeedZone != null)
				{
					BRCPlusPlugin.AlwaysInSpeedZone.Value = !BRCPlusPlugin.AlwaysInSpeedZone.Value;
					ShowMovementMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
		}

		private void ShowGoonsMenu()
		{
			base.ScrollView.RemoveAllButtons();
			string text = BRCPlusPlugin.GoonMode?.Value ?? "Normal";
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Goon Mode: " + text);
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.GoonMode != null)
				{
					string[] goonModeOptions = BRCPlusPlugin.GoonModeOptions;
					int num = Array.IndexOf(goonModeOptions, BRCPlusPlugin.GoonMode.Value);
					num = ((num >= 0) ? (num + 1) : 0) % goonModeOptions.Length;
					BRCPlusPlugin.GoonMode.Value = goonModeOptions[num];
					ShowGoonsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			bool flag = BRCPlusPlugin.UseStoredSpeedInConfig?.Value ?? false;
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Use Stored Speed In Config: " + (flag ? "On" : "Off"));
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.UseStoredSpeedInConfig != null)
				{
					BRCPlusPlugin.UseStoredSpeedInConfig.Value = !BRCPlusPlugin.UseStoredSpeedInConfig.Value;
					ShowGoonsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			bool flag2 = BRCPlusPlugin.LockStoredSpeed?.Value ?? false;
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Lock Stored Speed: " + (flag2 ? "On" : "Off"));
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.LockStoredSpeed != null)
				{
					BRCPlusPlugin.LockStoredSpeed.Value = !BRCPlusPlugin.LockStoredSpeed.Value;
					ShowGoonsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(ShowMovementMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
		}

		private void ShowTogglesMenu()
		{
			base.ScrollView.RemoveAllButtons();
			bool flag = BRCPlusPlugin.GodMode?.Value ?? false;
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("God Mode: " + (flag ? "On" : "Off"));
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.GodMode != null)
				{
					BRCPlusPlugin.GodMode.Value = !BRCPlusPlugin.GodMode.Value;
					ShowTogglesMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			BRCPlusPlugin.NormalizeSkipCutsceneModeConfig();
			string text = BRCPlusPlugin.SkipCutsceneMode?.Value ?? "Normal";
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Skip Cutscene Mode: " + text);
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.SkipCutsceneMode != null)
				{
					string[] skipCutsceneModeOptions = BRCPlusPlugin.SkipCutsceneModeOptions;
					int num = Array.IndexOf(skipCutsceneModeOptions, BRCPlusPlugin.SkipCutsceneMode.Value);
					num = ((num >= 0) ? (num + 1) : 0) % skipCutsceneModeOptions.Length;
					BRCPlusPlugin.SkipCutsceneMode.Value = skipCutsceneModeOptions[num];
					ShowTogglesMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
		}

		private void ShowOptimizeMenu()
		{
			base.ScrollView.RemoveAllButtons();
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Hide Objects");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, new Action(ShowHideObjectsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
		}

		private void ShowHideObjectsMenu()
		{
			base.ScrollView.RemoveAllButtons();
			bool flag = BRCPlusPlugin.ShowGraffiti?.Value ?? true;
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Show Graffiti: " + (flag ? "True" : "False"));
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.ShowGraffiti != null)
				{
					BRCPlusPlugin.ShowGraffiti.Value = !BRCPlusPlugin.ShowGraffiti.Value;
					ShowHideObjectsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(ShowOptimizeMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
		}

		private void ShowUIOptionsMenu()
		{
			base.ScrollView.RemoveAllButtons();
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Visible");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, new Action(ShowUIVisibleMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
		}

		private void ShowUIVisibleMenu()
		{
			base.ScrollView.RemoveAllButtons();
			AddUIVisibleToggle("Health Bar", BRCPlusPlugin.UIVisible_HealthBar);
			AddUIVisibleToggle("Boost Bar", BRCPlusPlugin.UIVisible_BoostBar);
			AddUIVisibleToggle("Score", BRCPlusPlugin.UIVisible_Score);
			AddUIVisibleToggle("Context Icons", BRCPlusPlugin.UIVisible_Context);
			AddUIVisibleToggle("Rep", BRCPlusPlugin.UIVisible_Rep);
			AddUIVisibleToggle("Combo", BRCPlusPlugin.UIVisible_Combo);
			AddUIVisibleToggle("Show Gaining Boosts Anim", BRCPlusPlugin.UIVisible_ShowGainingBoostsAnim);
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, new Action(ShowUIOptionsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val);
		}

		private void AddUIVisibleToggle(string label, ConfigEntry<bool> config)
		{
			if (config != null)
			{
				bool value = config.Value;
				SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton(label + ": " + (value ? "Visible" : "Hidden"));
				((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
				{
					config.Value = !config.Value;
					ShowUIVisibleMenu();
				});
				base.ScrollView.AddButton((PhoneButton)(object)val);
			}
		}

		private void AddHeat()
		{
			ConfigEntry<bool> disableHeat = BRCPlusPlugin.DisableHeat;
			if (disableHeat != null && disableHeat.Value)
			{
				return;
			}
			WantedManager instance = WantedManager.instance;
			if (!((Object)(object)instance == (Object)null))
			{
				int num = Mathf.Min((instance.Wanted ? instance.WantedStars : 0) + 1, 7);
				instance.SetDebugStarAmount(num);
				if (num >= 1 && !instance.Wanted)
				{
					typeof(WantedManager).GetMethod("MakePlayerWanted", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(instance, new object[1] { (object)(Crime)0 });
				}
			}
		}

		private void RemoveHeat()
		{
			ConfigEntry<bool> disableHeat = BRCPlusPlugin.DisableHeat;
			if (disableHeat != null && disableHeat.Value)
			{
				return;
			}
			WantedManager instance = WantedManager.instance;
			if (!((Object)(object)instance == (Object)null) && instance.Wanted)
			{
				if (instance.WantedStars <= 1)
				{
					instance.StopPlayerWantedStatus(true);
				}
				else
				{
					typeof(WantedManager).GetMethod("DecreaseStars", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(instance, null);
				}
			}
		}
	}
}
namespace BRCPlus.Patches
{
	[HarmonyPatch(typeof(AirDashAbility))]
	[HarmonyPatch("OnStartAbility")]
	internal static class AirDashOnStartAbilityPatch
	{
		public static void Postfix(AirDashAbility __instance)
		{
			ConfigEntry<bool> infiniteAirDash = BRCPlusPlugin.InfiniteAirDash;
			if (infiniteAirDash != null && infiniteAirDash.Value)
			{
				__instance.haveAirDash = true;
			}
		}
	}
	[HarmonyPatch(typeof(APlatform))]
	[HarmonyPatch("CreateDebugInstanceForPlatform")]
	internal static class APlatformCreateDebugInstanceForPlatformPatch
	{
		public static bool Prefix(BaseModule baseModule, SaveManager saveManager, GameInput gameInput, UIManager uIManager, ref AGameDebug __result)
		{
			ConfigEntry<bool> enabledDebugMenu = BRCPlusPlugin.EnabledDebugMenu;
			if (enabledDebugMenu == null || !enabledDebugMenu.Value)
			{
				return true;
			}
			__result = (AGameDebug)(object)new GameDebugBridge(baseModule, saveManager, gameInput, uIManager);
			return false;
		}
	}
	[HarmonyPatch(typeof(Player))]
	internal static class GraffitiPatch
	{
		private static bool _suppressGraffitiBoost;

		private static float _savedBoostCharge;

		private static bool IsQuickOrAuto()
		{
			string text = BRCPlusPlugin.SprayMode?.Value ?? "Normal";
			if (!(text == "Quick"))
			{
				return text == "Auto";
			}
			return true;
		}

		private static bool IsAuto()
		{
			return (BRCPlusPlugin.SprayMode?.Value ?? "Normal") == "Auto";
		}

		private static GraffitiArtInfo GetGraffitiArtInfo(GraffitiSpot spot)
		{
			return Traverse.Create((object)spot).Property("GraffitiArtInfo", (object[])null).GetValue<GraffitiArtInfo>();
		}

		private static GraffitiArt GetGraffitiArtForSpot(GraffitiSpot spot, Player player)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			GraffitiArtInfo graffitiArtInfo = GetGraffitiArtInfo(spot);
			if ((Object)(object)graffitiArtInfo == (Object)null)
			{
				return null;
			}
			Characters value = Traverse.Create((object)player).Field("character").GetValue<Characters>();
			if ((int)spot.size == 0)
			{
				return graffitiArtInfo.FindByCharacter(value);
			}
			List<GraffitiArt> list = graffitiArtInfo.FindBySize(spot.size);
			if (list == null || list.Count == 0)
			{
				return null;
			}
			Core instance = Core.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				APlatform platform = instance.Platform;
				obj = ((platform != null) ? platform.User : null);
			}
			AUser val = (AUser)obj;
			List<GraffitiArt> list2 = new List<GraffitiArt>();
			for (int i = 0; i < list.Count; i++)
			{
				GraffitiArt val2 = list[i];
				if ((Object)(object)val2?.unlockable != (Object)null && val != null && val.GetUnlockableSaveDataFor((AUnlockable)(object)val2.unlockable).IsUnlocked)
				{
					list2.Add(val2);
				}
			}
			if (list2.Count == 0)
			{
				return graffitiArtInfo.FindByCharacter(value);
			}
			return list2[Random.Range(0, list2.Count)];
		}

		[HarmonyPrefix]
		[HarmonyPatch("StartGraffitiMode")]
		private static bool StartGraffitiMode_Prefix(Player __instance, GraffitiSpot graffitiSpot)
		{
			//IL_01b6: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected I4, but got Unknown
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Expected I4, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Invalid comparison between Unknown and I4
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Invalid comparison between Unknown and I4
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Expected I4, but got Unknown
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			if (!IsQuickOrAuto())
			{
				return true;
			}
			Traverse val = Traverse.Create((object)__instance);
			if (__instance.IsBusyWithSequence() || __instance.IsDead())
			{
				return true;
			}
			if (val.Field("ability").GetValue() == val.Field("danceAbility").GetValue())
			{
				return true;
			}
			if (val.Field("isAI").GetValue<bool>())
			{
				return true;
			}
			GraffitiArt graffitiArtForSpot = GetGraffitiArtForSpot(graffitiSpot, __instance);
			if (graffitiArtForSpot == null)
			{
				return true;
			}
			TrickType val2 = (TrickType)16;
			GraffitiSize size = graffitiSpot.size;
			switch (size - 1)
			{
			case 0:
				val2 = (TrickType)17;
				break;
			case 1:
				val2 = (TrickType)18;
				break;
			case 2:
				val2 = (TrickType)19;
				break;
			}
			bool flag = (int)graffitiSpot.bottomCrew == 1 || (int)graffitiSpot.bottomCrew == 7;
			__instance.DoTrick(val2, graffitiArtForSpot.title, 0);
			typeof(GraffitiSpot).GetMethod("Paint", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(graffitiSpot, new object[3]
			{
				(object)(Crew)1,
				graffitiArtForSpot,
				__instance
			});
			graffitiSpot.GiveRep(false, flag);
			graffitiSpot.SetLastPlayer(__instance);
			graffitiSpot.SetState((GraffitiState)2);
			typeo