Decompiled source of BRCPlus v1.4.4

BRCPlus.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BRCPlus.Patches;
using BRCPlus.Phone;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using CommonAPI.Phone;
using HarmonyLib;
using Reptile;
using Reptile.Phone;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Playables;
using UnityEngine.UI;

[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
{
	public class BRCPlusNotification : MonoBehaviour
	{
		private GameObject _canvasGo;

		private TextMeshProUGUI _label;

		private Coroutine _hideCoroutine;

		public static BRCPlusNotification Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		private void EnsureCreated()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_canvasGo != (Object)null))
			{
				Core instance = Core.Instance;
				object obj;
				if (instance == null)
				{
					obj = null;
				}
				else
				{
					UIManager uIManager = instance.UIManager;
					obj = ((uIManager != null) ? ((Component)uIManager).transform : null);
				}
				Transform val = (Transform)obj;
				if (!((Object)(object)val == (Object)null))
				{
					_canvasGo = new GameObject("BRCPlus_Notification");
					_canvasGo.transform.SetParent(val, false);
					_canvasGo.SetActive(false);
					Canvas obj2 = _canvasGo.AddComponent<Canvas>();
					obj2.renderMode = (RenderMode)0;
					obj2.sortingOrder = 200;
					_canvasGo.AddComponent<CanvasScaler>();
					_canvasGo.AddComponent<GraphicRaycaster>();
					GameObject val2 = new GameObject("NotificationLabel");
					val2.transform.SetParent(_canvasGo.transform, false);
					_label = val2.AddComponent<TextMeshProUGUI>();
					((TMP_Text)_label).text = "";
					((TMP_Text)_label).fontSize = 22f;
					((Graphic)_label).color = new Color(0f, 1f, 0f);
					((TMP_Text)_label).alignment = (TextAlignmentOptions)260;
					((TMP_Text)_label).enableWordWrapping = true;
					RectTransform component = val2.GetComponent<RectTransform>();
					component.anchorMin = new Vector2(1f, 1f);
					component.anchorMax = new Vector2(1f, 1f);
					component.pivot = new Vector2(1f, 1f);
					component.sizeDelta = new Vector2(600f, 160f);
					component.anchoredPosition = new Vector2(-16f, -10f);
				}
			}
		}

		public void ShowMessage(string message)
		{
			EnsureCreated();
			if (!((Object)(object)_canvasGo == (Object)null) && !((Object)(object)_label == (Object)null))
			{
				if (_hideCoroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(_hideCoroutine);
				}
				((TMP_Text)_label).text = message;
				_canvasGo.SetActive(true);
				_hideCoroutine = ((MonoBehaviour)this).StartCoroutine(HideAfterDelay(4f));
			}
		}

		private IEnumerator HideAfterDelay(float seconds)
		{
			yield return (object)new WaitForSecondsRealtime(seconds);
			_hideCoroutine = null;
			if ((Object)(object)_canvasGo != (Object)null)
			{
				_canvasGo.SetActive(false);
			}
			if ((Object)(object)_label != (Object)null)
			{
				((TMP_Text)_label).text = "";
			}
		}
	}
	[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[2] { "Normal", "Quick" };

		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> MaxScores { get; private set; }

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

		public static ConfigEntry<bool> MaxMultiplier { 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_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; }

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

		public static ConfigEntry<float> SnailDropSpeed { get; private set; }

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

		public static ConfigEntry<float> SnailLaunchSpeed { get; private set; }

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

		public static ConfigEntry<float> SnailDashSpeed { get; private set; }

		public static ConfigEntry<KeyCode> SnailDashKey { get; private set; }

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

		public static ConfigEntry<float> SnailReverseSpeed { get; private set; }

		public static ConfigEntry<KeyCode> SnailReverseKey { get; private set; }

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

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

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

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

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

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

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

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

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

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

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

		private void Awake()
		{
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_0620: Expected O, but got Unknown
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Expected O, but got Unknown
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0657: 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).");
			MaxScores = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "MaxScores", false, "When true, every trick adds 99,000,000 to the trick score.");
			InstaKillMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "InstaKillMode", false, "When true, any hit kills an enemy instantly regardless of their HP.");
			MaxMultiplier = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats", "MaxMultiplier", false, "When true, each multiplier increment adds 99 instead of 1.");
			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.");
			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_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.");
			SnailDrop = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "SnailDrop", false, "When true, enables the Snail Drop mechanic.");
			SnailDropSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "SnailDropSpeed", 20f, "The amount of extra downward speed added when Snail Drop activates.");
			SnailLaunch = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "SnailLaunch", false, "When true, pressing the Phone Down button while the phone is closed converts all speed into upward speed and adds extra units.");
			SnailLaunchSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "SnailLaunchSpeed", 20f, "The amount of extra upward speed added when Snail Launch activates.");
			SnailDash = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "SnailDash", false, "When true, pressing R converts all current speed to forward speed and adds extra units.");
			SnailDashSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "SnailDashSpeed", 20f, "The amount of extra forward speed added when Snail Dash activates.");
			SnailDashKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Movement", "SnailDashKey", (KeyCode)99, "The key that triggers Snail Dash.");
			SnailReverse = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "SnailReverse", false, "When true, enables the Snail Reverse mechanic.");
			SnailReverseSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Movement", "SnailReverseSpeed", 20f, "The amount of extra backward speed added when Snail Reverse activates.");
			SnailReverseKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Movement", "SnailReverseKey", (KeyCode)122, "The key that triggers Snail Reverse.");
			CanAlwaysBoost = ((BaseUnityPlugin)this).Config.Bind<bool>("Movement", "CanAlwaysBoost", false, "When true, the player can always boost in the air without needing to land or touch a grind/wallrun first.");
			AmbientManagerFix = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimization Patches", "AmbientManagerFix", false, "When true, replaces the per-frame AnimationCurve allocation in AmbientManager with a Mathf.SmoothStep calculation, reducing GC pressure during ambient zone transitions.");
			NPCRepScanFix = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimization Patches", "NPCRepScanFix", false, "When true, throttles the per-frame NPC and GameplayEvent REP requirement scan in WorldHandler to run once every 60 frames instead of every frame.");
			SkipPlayerAudio = ((BaseUnityPlugin)this).Config.Bind<bool>("Optimization Patches", "SkipPlayerAudio", false, "When true, skips UpdateMoveStyleMovementAudio entirely, disabling the player character's movement audio loop.");
			InvisiblePlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("Fun", "Invisible Player", false, "When true, hides the player's mesh.");
			InvisibleStyle = ((BaseUnityPlugin)this).Config.Bind<bool>("Fun", "Invisible Style", false, "When true, hides the player's move style mesh (skateboard, skates, BMX).");
			InvisiblePhone = ((BaseUnityPlugin)this).Config.Bind<bool>("Fun", "Invisible Phone", false, "When true, hides the player's phone mesh.");
			InvisibleSpraycan = ((BaseUnityPlugin)this).Config.Bind<bool>("Fun", "Invisible Spraycan", false, "When true, hides the player's spraycan mesh.");
			PhoneSize = ((BaseUnityPlugin)this).Config.Bind<string>("Fun", "Phone Size", "Normal", "Phone mesh scale: Normal, Small, Big, Huge, EXTRA HUGE.");
			SpraycanSize = ((BaseUnityPlugin)this).Config.Bind<string>("Fun", "Spraycan Size", "Normal", "Spraycan mesh scale: Normal, Small, Big, Huge, EXTRA HUGE.");
			OtherCharactersSize = ((BaseUnityPlugin)this).Config.Bind<string>("Fun", "Other Characters Size", "Normal", "NPC scale: Normal, Small, Big, Huge, EXTRA HUGE.");
			NormalizePlayerSizeConfig();
			NormalizeGravityConfig();
			NormalizeSkipCutsceneModeConfig();
			NormalizeGoonModeConfig();
			_harmony = new Harmony("com.brcplus");
			_harmony.PatchAll();
			StageManager.OnStagePostInitialization += new OnStageInitializedDelegate(OnStagePostInitialization);
			AppBRCPlus.Initialize();
			GameObject val = new GameObject("BRCPlus_Notification");
			val.AddComponent<BRCPlusNotification>();
			Object.DontDestroyOnLoad((Object)val);
		}

		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()
		{
			PropDisguiseManager.InvalidateCache();
			ConfigEntry<bool> showGraffiti = ShowGraffiti;
			if (showGraffiti != null && !showGraffiti.Value)
			{
				WorldHandler instance = WorldHandler.instance;
				if (((instance == null) ? null : instance.SceneObjectsRegister?.grafSpots) != null)
				{
					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);
						}
					}
				}
			}
			ConfigEntry<bool> invisiblePlayer = InvisiblePlayer;
			if (invisiblePlayer != null && invisiblePlayer.Value)
			{
				WorldHandler instance2 = WorldHandler.instance;
				ApplyInvisibleTo((instance2 != null) ? instance2.GetCurrentPlayer() : null);
			}
			ConfigEntry<bool> invisibleStyle = InvisibleStyle;
			if (invisibleStyle != null && invisibleStyle.Value)
			{
				WorldHandler instance3 = WorldHandler.instance;
				ApplyInvisibleStyleTo((instance3 != null) ? instance3.GetCurrentPlayer() : null);
			}
			ConfigEntry<bool> invisiblePhone = InvisiblePhone;
			if (invisiblePhone != null && invisiblePhone.Value)
			{
				WorldHandler instance4 = WorldHandler.instance;
				ApplyInvisiblePhoneTo((instance4 != null) ? instance4.GetCurrentPlayer() : null);
			}
			ConfigEntry<bool> invisibleSpraycan = InvisibleSpraycan;
			if (invisibleSpraycan != null && invisibleSpraycan.Value)
			{
				WorldHandler instance5 = WorldHandler.instance;
				ApplyInvisibleSpraycanTo((instance5 != null) ? instance5.GetCurrentPlayer() : null);
			}
			WorldHandler instance6 = WorldHandler.instance;
			ApplyPhoneSizeTo((instance6 != null) ? instance6.GetCurrentPlayer() : null);
			WorldHandler instance7 = WorldHandler.instance;
			ApplySpraycanSizeTo((instance7 != null) ? instance7.GetCurrentPlayer() : null);
			ApplyOtherCharactersSizeTo();
		}

		internal static void NormalizeSprayModeConfig()
		{
			if (SprayMode != null)
			{
				string value = SprayMode.Value;
				if (value != "Normal" && value != "Quick")
				{
					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";
				}
			}
		}

		public static void ApplyPlayerSizeTo(Player player)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)player == (Object)null) && PlayerSize != null)
			{
				float num = PlayerSize.Value switch
				{
					"EXTRA HUGE" => 6f, 
					"Huge" => 3f, 
					"Big" => 1.5f, 
					"Small" => 0.5f, 
					_ => 1f, 
				};
				((Component)player).transform.localScale = new Vector3(num, num, num);
			}
		}

		public static void ApplyInvisibleTo(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			CharacterVisual value = Traverse.Create((object)player).Field("characterVisual").GetValue<CharacterVisual>();
			if (!((Object)(object)value == (Object)null))
			{
				SkinnedMeshRenderer mainRenderer = value.mainRenderer;
				if ((Object)(object)mainRenderer != (Object)null)
				{
					((Renderer)mainRenderer).enabled = !(InvisiblePlayer?.Value ?? false);
				}
			}
		}

		public static void ApplyInvisibleStyleTo(Player player)
		{
			bool hide;
			if (!((Object)(object)player == (Object)null))
			{
				CharacterVisual value = Traverse.Create((object)player).Field("characterVisual").GetValue<CharacterVisual>();
				if (!((Object)(object)value == (Object)null))
				{
					hide = InvisibleStyle?.Value ?? false;
					PlayerMoveStyleProps moveStyleProps = value.moveStyleProps;
					SetRenderers(moveStyleProps.skateboard);
					SetRenderers(moveStyleProps.specialSkateBoard);
					SetRenderers(moveStyleProps.skateL);
					SetRenderers(moveStyleProps.skateR);
					SetRenderers(moveStyleProps.bmxFrame);
					SetRenderers(moveStyleProps.bmxHandlebars);
					SetRenderers(moveStyleProps.bmxWheelF);
					SetRenderers(moveStyleProps.bmxWheelR);
					SetRenderers(moveStyleProps.bmxGear);
					SetRenderers(moveStyleProps.bmxPedalL);
					SetRenderers(moveStyleProps.bmxPedalR);
				}
			}
			void SetRenderers(GameObject go)
			{
				if (!((Object)(object)go == (Object)null))
				{
					Renderer[] componentsInChildren = go.GetComponentsInChildren<Renderer>(true);
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].enabled = !hide;
					}
				}
			}
		}

		public static void ApplyInvisiblePhoneTo(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			CharacterVisual value = Traverse.Create((object)player).Field("characterVisual").GetValue<CharacterVisual>();
			if ((Object)(object)value == (Object)null)
			{
				return;
			}
			object value2 = Traverse.Create((object)value).Field("VFX").GetValue();
			if (value2 == null)
			{
				return;
			}
			GameObject value3 = Traverse.Create(value2).Field("phone").GetValue<GameObject>();
			if (!((Object)(object)value3 == (Object)null))
			{
				Renderer[] componentsInChildren = value3.GetComponentsInChildren<Renderer>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].enabled = !(InvisiblePhone?.Value ?? false);
				}
			}
		}

		public static void ApplyInvisibleSpraycanTo(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			CharacterVisual value = Traverse.Create((object)player).Field("characterVisual").GetValue<CharacterVisual>();
			if ((Object)(object)value == (Object)null)
			{
				return;
			}
			object value2 = Traverse.Create((object)value).Field("VFX").GetValue();
			if (value2 == null)
			{
				return;
			}
			GameObject value3 = Traverse.Create(value2).Field("spraycan").GetValue<GameObject>();
			if (!((Object)(object)value3 == (Object)null))
			{
				Renderer[] componentsInChildren = value3.GetComponentsInChildren<Renderer>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].enabled = !(InvisibleSpraycan?.Value ?? false);
				}
			}
		}

		public static void ApplyPhoneSizeTo(Player player)
		{
			//IL_00dc: 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)
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			CharacterVisual value = Traverse.Create((object)player).Field("characterVisual").GetValue<CharacterVisual>();
			if ((Object)(object)value == (Object)null)
			{
				return;
			}
			object value2 = Traverse.Create((object)value).Field("VFX").GetValue();
			if (value2 != null)
			{
				GameObject value3 = Traverse.Create(value2).Field("phone").GetValue<GameObject>();
				if (!((Object)(object)value3 == (Object)null))
				{
					string obj = PhoneSize?.Value ?? "Normal";
					value3.transform.localScale = Vector3.one * obj switch
					{
						"EXTRA HUGE" => 6f, 
						"Huge" => 3f, 
						"Big" => 1.5f, 
						"Small" => 0.5f, 
						_ => 1f, 
					};
				}
			}
		}

		public static void ApplySpraycanSizeTo(Player player)
		{
			//IL_00dc: 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)
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			CharacterVisual value = Traverse.Create((object)player).Field("characterVisual").GetValue<CharacterVisual>();
			if ((Object)(object)value == (Object)null)
			{
				return;
			}
			object value2 = Traverse.Create((object)value).Field("VFX").GetValue();
			if (value2 != null)
			{
				GameObject value3 = Traverse.Create(value2).Field("spraycan").GetValue<GameObject>();
				if (!((Object)(object)value3 == (Object)null))
				{
					string obj = SpraycanSize?.Value ?? "Normal";
					value3.transform.localScale = Vector3.one * obj switch
					{
						"EXTRA HUGE" => 6f, 
						"Huge" => 3f, 
						"Big" => 1.5f, 
						"Small" => 0.5f, 
						_ => 1f, 
					};
				}
			}
		}

		public static void ApplyOtherCharactersSizeTo()
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			WorldHandler instance = WorldHandler.instance;
			if (((instance == null) ? null : instance.SceneObjectsRegister?.NPCs) == null)
			{
				return;
			}
			float num = (OtherCharactersSize?.Value ?? "Normal") switch
			{
				"EXTRA HUGE" => 6f, 
				"Huge" => 3f, 
				"Big" => 1.5f, 
				"Small" => 0.5f, 
				_ => 1f, 
			};
			foreach (NPC nPC in instance.SceneObjectsRegister.NPCs)
			{
				if ((Object)(object)nPC != (Object)null)
				{
					((Component)nPC).transform.localScale = new Vector3(num, num, num);
				}
			}
		}

		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 bool _cacheReady = false;

		public static void InvalidateCache()
		{
			_cacheReady = false;
			_propByIndex.Clear();
		}

		private static int HashString(string s)
		{
			return s.GetHashCode();
		}

		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()
		{
			if (_cacheReady)
			{
				return;
			}
			_cacheReady = true;
			_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 static readonly List<(BasicEnemy enemy, bool destroyOnRemove)> SpawnedEnemies = new List<(BasicEnemy, bool)>();

		private const int SaveFilesSlotCount = 3;

		private static readonly Characters[] _spawnableCharacters = ((Characters[])Enum.GetValues(typeof(Characters))).Where((Characters c) => (int)c != -1 && (int)c != 26).ToArray();

		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 RemoveMostRecentSpawnedObject()
		{
			if (_spawnedObjects.Count != 0)
			{
				int index = _spawnedObjects.Count - 1;
				GameObject val = _spawnedObjects[index];
				_spawnedObjects.RemoveAt(index);
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
		}

		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);
				}
			}
		}

		private static bool TransformContainsDescendant(Transform parent, Transform descendant)
		{
			Transform val = descendant;
			while ((Object)(object)val != (Object)null)
			{
				if ((Object)(object)val == (Object)(object)parent)
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		private static Transform GetWallrunCloneRoot(WallrunLine line)
		{
			if ((Object)(object)line == (Object)null)
			{
				return null;
			}
			Transform transform = ((Component)line).transform;
			Transform node = line.node0;
			Transform node2 = line.node1;
			if ((Object)(object)node == (Object)null || (Object)(object)node2 == (Object)null)
			{
				return transform;
			}
			Transform val = transform;
			while ((Object)(object)val != (Object)null)
			{
				if (TransformContainsDescendant(val, node) && TransformContainsDescendant(val, node2))
				{
					return val;
				}
				val = val.parent;
			}
			return transform;
		}

		private static void SpawnWallrunInFrontOfPlayer()
		{
			//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_004e: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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)
			WorldHandler instance = WorldHandler.instance;
			Player val = ((instance != null) ? instance.GetCurrentPlayer() : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			WallrunLine val2 = Object.FindObjectOfType<WallrunLine>(true);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			Transform wallrunCloneRoot = GetWallrunCloneRoot(val2);
			if (!((Object)(object)wallrunCloneRoot == (Object)null))
			{
				Vector3 val3 = Vector3.ProjectOnPlane(val.tf.forward, Vector3.up);
				Vector3 val4 = ((Vector3)(ref val3)).normalized;
				if (((Vector3)(ref val4)).sqrMagnitude < 0.01f)
				{
					val4 = val.tf.forward;
				}
				Vector3 position = val.tf.position + val4 * 5f;
				GameObject val5 = Object.Instantiate<GameObject>(((Component)wallrunCloneRoot).gameObject);
				val5.transform.position = position;
				val5.transform.rotation = Quaternion.LookRotation(-val4);
				SetLayerRecursively(val5, 0);
				WallrunLine componentInChildren = val5.GetComponentInChildren<WallrunLine>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((Component)componentInChildren).gameObject.layer = 13;
					componentInChildren.attachedWallrunLine0 = null;
					componentInChildren.attachedWallrunLine1 = null;
				}
				RemoveAllMeshRenderersFrom(val5);
				AddGreyBoxVisualToWallrunClone(val5);
				val5.SetActive(true);
				_spawnedObjects.Add(val5);
			}
		}

		private static void RemoveAllMeshRenderersFrom(GameObject root)
		{
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			MeshRenderer[] componentsInChildren = root.GetComponentsInChildren<MeshRenderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if ((Object)(object)componentsInChildren[i] != (Object)null)
				{
					Object.Destroy((Object)(object)componentsInChildren[i]);
				}
			}
		}

		private static void AddGreyBoxVisualToWallrunClone(GameObject cloneGo)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_01df: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			BoxCollider componentInChildren = cloneGo.GetComponentInChildren<BoxCollider>(true);
			Collider val = (Collider)(object)componentInChildren;
			if ((Object)(object)val == (Object)null)
			{
				val = cloneGo.GetComponentInChildren<Collider>(true);
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Mesh val2 = null;
			GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)3);
			if ((Object)(object)val3 != (Object)null)
			{
				MeshFilter component = val3.GetComponent<MeshFilter>();
				if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null)
				{
					val2 = component.sharedMesh;
				}
				Object.Destroy((Object)(object)val3);
			}
			if (!((Object)(object)val2 == (Object)null))
			{
				GameObject val4 = new GameObject("WallrunVisual");
				val4.transform.SetParent(((Component)val).transform, false);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					val4.transform.localPosition = componentInChildren.center;
					val4.transform.localRotation = Quaternion.identity;
					val4.transform.localScale = componentInChildren.size;
				}
				else
				{
					Bounds bounds = val.bounds;
					Vector3 lossyScale = ((Component)val).transform.lossyScale;
					val4.transform.localPosition = Vector3.zero;
					val4.transform.localRotation = Quaternion.identity;
					val4.transform.localScale = new Vector3((lossyScale.x > 0.001f) ? (((Bounds)(ref bounds)).size.x / lossyScale.x) : ((Bounds)(ref bounds)).size.x, (lossyScale.y > 0.001f) ? (((Bounds)(ref bounds)).size.y / lossyScale.y) : ((Bounds)(ref bounds)).size.y, (lossyScale.z > 0.001f) ? (((Bounds)(ref bounds)).size.z / lossyScale.z) : ((Bounds)(ref bounds)).size.z);
				}
				val4.AddComponent<MeshFilter>().sharedMesh = val2;
				MeshRenderer val5 = val4.AddComponent<MeshRenderer>();
				Shader val6 = Shader.Find("Standard");
				if ((Object)(object)val6 != (Object)null)
				{
					Material val7 = new Material(val6);
					val7.color = new Color(0.45f, 0.45f, 0.45f);
					((Renderer)val5).sharedMaterial = val7;
				}
				SetLayerRecursively(val4, 0);
			}
		}

		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("Map Chunks");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(ShowLocationsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Map Options");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(ShowMapOptionsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
			SimplePhoneButton val6 = PhoneUIUtility.CreateSimpleButton("Movement");
			((PhoneButton)val6).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val6).OnConfirm, new Action(ShowMovementMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val6);
			SimplePhoneButton val7 = PhoneUIUtility.CreateSimpleButton("Characters");
			((PhoneButton)val7).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val7).OnConfirm, new Action(ShowCharactersMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val7);
			SimplePhoneButton val8 = PhoneUIUtility.CreateSimpleButton("Graffiti");
			((PhoneButton)val8).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val8).OnConfirm, new Action(ShowGraffitiMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val8);
			SimplePhoneButton val9 = PhoneUIUtility.CreateSimpleButton("Enemy");
			((PhoneButton)val9).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val9).OnConfirm, new Action(ShowEnemyMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val9);
			SimplePhoneButton val10 = PhoneUIUtility.CreateSimpleButton("Heat");
			((PhoneButton)val10).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val10).OnConfirm, new Action(ShowHeatMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val10);
			SimplePhoneButton val11 = PhoneUIUtility.CreateSimpleButton("Optimize");
			((PhoneButton)val11).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val11).OnConfirm, new Action(ShowOptimizeMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val11);
			SimplePhoneButton val12 = PhoneUIUtility.CreateSimpleButton("UI Options");
			((PhoneButton)val12).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val12).OnConfirm, new Action(ShowUIOptionsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val12);
			SimplePhoneButton val13 = PhoneUIUtility.CreateSimpleButton("Cut Scenes");
			((PhoneButton)val13).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val13).OnConfirm, new Action(ShowCutScenesMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val13);
			SimplePhoneButton val14 = PhoneUIUtility.CreateSimpleButton("Save Files");
			((PhoneButton)val14).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val14).OnConfirm, new Action(ShowSaveFilesMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val14);
			SimplePhoneButton val15 = PhoneUIUtility.CreateSimpleButton("Cheats");
			((PhoneButton)val15).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val15).OnConfirm, new Action(ShowCheatsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val15);
		}

		private void ShowMapOptionsMenu()
		{
			base.ScrollView.RemoveAllButtons();
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Reset High Score");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, new Action(ResetHighScore));
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Spray All Graffiti Spots");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(SprayAllGraffitiSpots));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Unlock Robo Posts");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(UnlockRoboPosts));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Get Collectibles");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(GetAllCollectables));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Reload Map");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(ReloadMap));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
			SimplePhoneButton val6 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val6).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val6).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val6);
		}

		private void ReloadMap()
		{
			Core instance = Core.Instance;
			if ((Object)(object)((instance != null) ? instance.BaseModule : null) == (Object)null)
			{
				return;
			}
			BaseModule baseModule = instance.BaseModule;
			if (baseModule.IsLoading || !baseModule.IsPlayingInStage)
			{
				return;
			}
			StageManager stageManager = baseModule.StageManager;
			if (stageManager != null)
			{
				if (baseModule.IsInGamePaused)
				{
					baseModule.UnPauseGame((PauseType)65535);
				}
				((App)this).MyPhone.TurnOff(true);
				stageManager.RestartStage();
			}
		}

		private static void ResetHighScore()
		{
			Core instance = Core.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				SaveManager saveManager = instance.SaveManager;
				if (saveManager == null)
				{
					obj = null;
				}
				else
				{
					SaveSlotData currentSaveSlot = saveManager.CurrentSaveSlot;
					obj = ((currentSaveSlot != null) ? currentSaveSlot.GetCurrentStageProgress() : null);
				}
			}
			StageProgress val = (StageProgress)obj;
			if (val != null)
			{
				val.highestCombo = 0f;
				Core.Instance.SaveManager.SaveCurrentSaveSlot();
				BRCPlusNotification.Instance?.ShowMessage("High score reset!");
			}
		}

		private void ShowCheatsMenu()
		{
			base.ScrollView.RemoveAllButtons();
			bool flag = BRCPlusPlugin.GodMode?.Value ?? false;
			SimplePhoneButton godModeCheatsBtn = PhoneUIUtility.CreateSimpleButton("God Mode: " + (flag ? "On" : "Off"));
			SimplePhoneButton obj = godModeCheatsBtn;
			((PhoneButton)obj).OnConfirm = (Action)Delegate.Combine(((PhoneButton)obj).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.GodMode != null)
				{
					BRCPlusPlugin.GodMode.Value = !BRCPlusPlugin.GodMode.Value;
					((TMP_Text)godModeCheatsBtn.Label).text = "God Mode: " + (BRCPlusPlugin.GodMode.Value ? "On" : "Off");
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)godModeCheatsBtn);
			bool flag2 = BRCPlusPlugin.MaxScores?.Value ?? false;
			SimplePhoneButton maxScoresBtn = PhoneUIUtility.CreateSimpleButton("Max Scores: " + (flag2 ? "On" : "Off"));
			SimplePhoneButton obj2 = maxScoresBtn;
			((PhoneButton)obj2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)obj2).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.MaxScores != null)
				{
					BRCPlusPlugin.MaxScores.Value = !BRCPlusPlugin.MaxScores.Value;
					((TMP_Text)maxScoresBtn.Label).text = "Max Scores: " + (BRCPlusPlugin.MaxScores.Value ? "On" : "Off");
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)maxScoresBtn);
			bool flag3 = BRCPlusPlugin.InstaKillMode?.Value ?? false;
			SimplePhoneButton instaKillBtn = PhoneUIUtility.CreateSimpleButton("Insta Kill Mode: " + (flag3 ? "On" : "Off"));
			SimplePhoneButton obj3 = instaKillBtn;
			((PhoneButton)obj3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)obj3).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.InstaKillMode != null)
				{
					BRCPlusPlugin.InstaKillMode.Value = !BRCPlusPlugin.InstaKillMode.Value;
					((TMP_Text)instaKillBtn.Label).text = "Insta Kill Mode: " + (BRCPlusPlugin.InstaKillMode.Value ? "On" : "Off");
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)instaKillBtn);
			bool flag4 = BRCPlusPlugin.MaxMultiplier?.Value ?? false;
			SimplePhoneButton maxMultiplierBtn = PhoneUIUtility.CreateSimpleButton("Max Multiplier: " + (flag4 ? "On" : "Off"));
			SimplePhoneButton obj4 = maxMultiplierBtn;
			((PhoneButton)obj4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)obj4).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.MaxMultiplier != null)
				{
					BRCPlusPlugin.MaxMultiplier.Value = !BRCPlusPlugin.MaxMultiplier.Value;
					((TMP_Text)maxMultiplierBtn.Label).text = "Max Multiplier: " + (BRCPlusPlugin.MaxMultiplier.Value ? "On" : "Off");
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)maxMultiplierBtn);
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Spray All Graffiti Spots");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, new Action(SprayAllGraffitiSpots));
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Unlock All Characters");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(UnlockAllCharacters));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Unlock All Music");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(UnlockAllMusic));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Unlock All Graffiti");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(UnlockAllGraffiti));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Unlock All Dances");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(UnlockAllDances));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
			SimplePhoneButton val6 = PhoneUIUtility.CreateSimpleButton("Unlock All Outfits");
			((PhoneButton)val6).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val6).OnConfirm, new Action(UnlockAllOutfits));
			base.ScrollView.AddButton((PhoneButton)(object)val6);
			SimplePhoneButton val7 = PhoneUIUtility.CreateSimpleButton("Unlock All Move Style Skins");
			((PhoneButton)val7).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val7).OnConfirm, new Action(UnlockAllMoveStyleSkins));
			base.ScrollView.AddButton((PhoneButton)(object)val7);
			SimplePhoneButton val8 = PhoneUIUtility.CreateSimpleButton("Get Collectibles");
			((PhoneButton)val8).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val8).OnConfirm, new Action(GetAllCollectables));
			base.ScrollView.AddButton((PhoneButton)(object)val8);
			SimplePhoneButton val9 = PhoneUIUtility.CreateSimpleButton("Unlock Robo Posts");
			((PhoneButton)val9).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val9).OnConfirm, new Action(UnlockRoboPosts));
			base.ScrollView.AddButton((PhoneButton)(object)val9);
			SimplePhoneButton val10 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val10).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val10).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val10);
		}

		private static void UnlockAllCharacters()
		{
			//IL_003f: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			Core instance = Core.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				SaveManager saveManager = instance.SaveManager;
				obj = ((saveManager != null) ? saveManager.CurrentSaveSlot : null);
			}
			SaveSlotData val = (SaveSlotData)obj;
			if (val == null)
			{
				return;
			}
			foreach (Characters value in Enum.GetValues(typeof(Characters)))
			{
				if ((int)value != -1 && (int)value != 26)
				{
					val.UnlockCharacter(value);
				}
			}
			BRCPlusNotification.Instance?.ShowMessage("All characters unlocked!");
		}

		private static void UnlockAllMusic()
		{
			WorldHandler instance = WorldHandler.instance;
			Player val = ((instance != null) ? instance.GetCurrentPlayer() : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Core instance2 = Core.Instance;
			object obj;
			if (instance2 == null)
			{
				obj = null;
			}
			else
			{
				APlatform platform = instance2.Platform;
				obj = ((platform != null) ? platform.User : null);
			}
			AUser val2 = (AUser)obj;
			if (val2 == null)
			{
				return;
			}
			Phone value = Traverse.Create((object)val).Field("phone").GetValue<Phone>();
			if ((Object)(object)value == (Object)null)
			{
				return;
			}
			AppMusicPlayer appInstance = value.GetAppInstance<AppMusicPlayer>();
			if ((Object)(object)appInstance == (Object)null)
			{
				return;
			}
			AUnlockable[] unlockables = ((App)appInstance).Unlockables;
			if (unlockables == null)
			{
				return;
			}
			AUnlockable[] array = unlockables;
			foreach (AUnlockable val3 in array)
			{
				if (!((Object)(object)val3 == (Object)null))
				{
					UnlockableSaveData unlockableSaveDataFor = val2.GetUnlockableSaveDataFor(val3);
					if (unlockableSaveDataFor != null)
					{
						unlockableSaveDataFor.IsUnlocked = true;
					}
				}
			}
			Core.Instance.SaveManager.SaveCurrentSaveSlot();
			BRCPlusNotification.Instance?.ShowMessage("All music unlocked!");
		}

		private static void UnlockAllDances()
		{
			Core instance = Core.Instance;
			object obj;
			if (instance == null)
			{
				obj = null;
			}
			else
			{
				SaveManager saveManager = instance.SaveManager;
				obj = ((saveManager != null) ? saveManager.CurrentSaveSlot : null);
			}
			SaveSlotData val = (SaveSlotData)obj;
			if (val != null)
			{
				for (int i = 0; i < 6; i++)
				{
					val.UnlockDance(i);
				}
				Core.Instance.SaveManager.SaveCurrentSaveSlot();
				BRCPlusNotification.Instance?.ShowMessage("All dances unlocked!");
			}
		}

		private static void UnlockAllOutfits()
		{
			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;
			if (val == null)
			{
				return;
			}
			CharacterSelectUI val2 = Object.FindObjectOfType<CharacterSelectUI>(true);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			OutfitUnlockable[] value = Traverse.Create((object)val2).Field("outfitUnlockables").GetValue<OutfitUnlockable[]>();
			if (value == null)
			{
				return;
			}
			OutfitUnlockable[] array = value;
			foreach (OutfitUnlockable val3 in array)
			{
				if (!((Object)(object)val3 == (Object)null))
				{
					val.GetUnlockableSaveDataFor((AUnlockable)(object)val3).IsUnlocked = true;
				}
			}
			Core.Instance.SaveManager.SaveCurrentSaveSlot();
			BRCPlusNotification.Instance?.ShowMessage("All outfits unlocked!");
		}

		private static void UnlockAllMoveStyleSkins()
		{
			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;
			if (val == null)
			{
				return;
			}
			StyleSwitchMenu val2 = Object.FindObjectOfType<StyleSwitchMenu>(true);
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			Traverse val3 = Traverse.Create((object)val2);
			MoveStyleSkin[][] array = new MoveStyleSkin[3][]
			{
				val3.Field("skateboardUnlockables").GetValue<MoveStyleSkin[]>(),
				val3.Field("bmxUnlockables").GetValue<MoveStyleSkin[]>(),
				val3.Field("rollerSkatesUnlockables").GetValue<MoveStyleSkin[]>()
			};
			foreach (MoveStyleSkin[] array2 in array)
			{
				if (array2 == null)
				{
					continue;
				}
				MoveStyleSkin[] array3 = array2;
				foreach (MoveStyleSkin val4 in array3)
				{
					if (!((Object)(object)val4 == (Object)null))
					{
						val.GetUnlockableSaveDataFor((AUnlockable)(object)val4).IsUnlocked = true;
					}
				}
			}
			Core.Instance.SaveManager.SaveCurrentSaveSlot();
			BRCPlusNotification.Instance?.ShowMessage("All move style skins unlocked!");
		}

		private static void UnlockAllGraffiti()
		{
			WorldHandler instance = WorldHandler.instance;
			Player val = ((instance != null) ? instance.GetCurrentPlayer() : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Core instance2 = Core.Instance;
			object obj;
			if (instance2 == null)
			{
				obj = null;
			}
			else
			{
				APlatform platform = instance2.Platform;
				obj = ((platform != null) ? platform.User : null);
			}
			AUser val2 = (AUser)obj;
			if (val2 == null)
			{
				return;
			}
			Phone value = Traverse.Create((object)val).Field("phone").GetValue<Phone>();
			if ((Object)(object)value == (Object)null)
			{
				return;
			}
			AppGraffiti appInstance = value.GetAppInstance<AppGraffiti>();
			if ((Object)(object)appInstance == (Object)null)
			{
				return;
			}
			AUnlockable[] unlockables = ((App)appInstance).Unlockables;
			if (unlockables == null)
			{
				return;
			}
			AUnlockable[] array = unlockables;
			foreach (AUnlockable val3 in array)
			{
				if (!((Object)(object)val3 == (Object)null))
				{
					UnlockableSaveData unlockableSaveDataFor = val2.GetUnlockableSaveDataFor(val3);
					if (unlockableSaveDataFor != null)
					{
						unlockableSaveDataFor.IsUnlocked = true;
					}
				}
			}
			Core.Instance.SaveManager.SaveCurrentSaveSlot();
			BRCPlusNotification.Instance?.ShowMessage("All graffiti unlocked!");
		}

		private static void GetAllCollectables()
		{
			WorldHandler instance = WorldHandler.instance;
			if (((instance == null) ? null : instance.SceneObjectsRegister?.gameplayEvents) == null)
			{
				return;
			}
			Player currentPlayer = instance.GetCurrentPlayer();
			if ((Object)(object)currentPlayer == (Object)null)
			{
				return;
			}
			int num = 0;
			foreach (GameplayEvent gameplayEvent in instance.SceneObjectsRegister.gameplayEvents)
			{
				Collectable val = (Collectable)(object)((gameplayEvent is Collectable) ? gameplayEvent : null);
				if (!((Object)(object)val == (Object)null) && !Traverse.Create((object)val).Field("pickedUp").GetValue<bool>())
				{
					val.PickupCollectable(currentPlayer);
					num++;
				}
			}
			BRCPlusNotification.Instance?.ShowMessage((num > 0) ? string.Format("Collected {0} collectable{1}!", num, (num == 1) ? "" : "s") : "No collectables found.");
		}

		private static void UnlockRoboPosts()
		{
			ComboMascotSystem[] array = Object.FindObjectsOfType<ComboMascotSystem>();
			if (array == null || array.Length == 0)
			{
				BRCPlusNotification.Instance?.ShowMessage("No robo posts found in this map.");
				return;
			}
			int num = 0;
			ComboMascotSystem[] array2 = array;
			foreach (ComboMascotSystem val in array2)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val.door1 == (Object)null) && val.door1.isActive)
				{
					val.SetState((State)3);
					num++;
				}
			}
			BRCPlusNotification.Instance?.ShowMessage((num > 0) ? string.Format("Unlocked {0} robo post{1}!", num, (num == 1) ? "" : "s") : "All robo posts already unlocked.");
		}

		private static bool ShouldSkipSpot(GraffitiSpot spot)
		{
			if (((UnityEventBase)spot.OnFinish).GetPersistentEventCount() > 0)
			{
				return true;
			}
			GraffitiSpotFinisher val = (GraffitiSpotFinisher)(object)((spot is GraffitiSpotFinisher) ? spot : null);
			if (val == null)
			{
				return false;
			}
			Traverse val2 = Traverse.Create((object)val);
			if (val2.Field("enemyExtension").GetValue() != null)
			{
				return true;
			}
			if (val2.Field("enemyDamager").GetValue() != null)
			{
				return true;
			}
			if (val2.Field("encounter").GetValue() != null)
			{
				return true;
			}
			return false;
		}

		private static void SprayAllGraffitiSpots()
		{
			//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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Invalid comparison between Unknown and I4
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Invalid comparison between Unknown and I4
			//IL_00d7: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Invalid comparison between Unknown and I4
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Invalid comparison between Unknown and I4
			WorldHandler instance = WorldHandler.instance;
			if (((instance == null) ? null : instance.SceneObjectsRegister?.grafSpots) == null)
			{
				return;
			}
			Player currentPlayer = instance.GetCurrentPlayer();
			if ((Object)(object)currentPlayer == (Object)null)
			{
				return;
			}
			Characters val = (Characters)(GraffitiPatch.Player_character?.GetValue(currentPlayer) ?? ((object)(Characters)12));
			int num = 0;
			foreach (GraffitiSpot grafSpot in instance.SceneObjectsRegister.grafSpots)
			{
				if ((Object)(object)grafSpot == (Object)null)
				{
					continue;
				}
				if (ShouldSkipSpot(grafSpot))
				{
					num++;
				}
				else
				{
					if ((int)Traverse.Create((object)grafSpot).Field("state").GetValue<GraffitiState>() == 2 && (int)grafSpot.topCrew == 1)
					{
						continue;
					}
					GraffitiArtInfo graffitiArtInfoPublic = GraffitiPatch.GetGraffitiArtInfoPublic(grafSpot);
					if ((Object)(object)graffitiArtInfoPublic == (Object)null)
					{
						continue;
					}
					GraffitiArt val2 = null;
					if ((int)grafSpot.size == 0)
					{
						val2 = graffitiArtInfoPublic.FindByCharacter(val);
					}
					else
					{
						List<GraffitiArt> list = graffitiArtInfoPublic.FindBySize(grafSpot.size);
						if (list != null && list.Count > 0)
						{
							val2 = list[0];
						}
						if (val2 == null)
						{
							val2 = graffitiArtInfoPublic.FindByCharacter(val);
						}
					}
					if (val2 != null)
					{
						bool flag = (int)grafSpot.bottomCrew == 1 || (int)grafSpot.bottomCrew == 7;
						GraffitiPatch.GraffitiSpot_Paint?.Invoke(grafSpot, new object[3]
						{
							(object)(Crew)1,
							val2,
							currentPlayer
						});
						grafSpot.GiveRep(true, flag);
						grafSpot.SetLastPlayer(currentPlayer);
						grafSpot.SetState((GraffitiState)2);
						GraffitiPatch.GraffitiSpot_SpawnRep?.Invoke(grafSpot, null);
					}
				}
			}
			string text = "All graffiti spots in this map sprayed!";
			if (num > 0)
			{
				text = text + "\n" + num + " story related spot" + ((num == 1) ? " was" : "s were") + " skipped.";
			}
			BRCPlusNotification.Instance?.ShowMessage(text);
		}

		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();
			BRCPlusPlugin.NormalizeSkipCutsceneModeConfig();
			string text = BRCPlusPlugin.SkipCutsceneMode?.Value ?? "Normal";
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Skip Cut Scene Mode: " + text);
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).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];
					ShowCutScenesMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			foreach (var cutsceneEntry in GetCutsceneEntries())
			{
				string item = cutsceneEntry.label;
				Func<PlayableDirector> getter = cutsceneEntry.getter;
				SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton(item);
				((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
				{
					PlayableDirector val4 = getter();
					if (!((Object)(object)val4 == (Object)null) && !((Object)(object)SequenceHandler.instance == (Object)null))
					{
						SequenceHandler.instance.StartEnteringSequence(val4, (GameplayEvent)null, true, true, true, true, true, (ProgressObject)null, true, false, (Battle)null, false);
					}
				});
				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 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("Become A Prop");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, new Action(ShowPropsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Spawn Something");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, new Action(ShowSpawnSomethingMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			BRCPlusPlugin.NormalizeGravityConfig();
			string text = BRCPlusPlugin.Gravity?.Value ?? "Normal";
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Gravity: " + text);
			((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("Size Options");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(ShowSizeOptionsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Invisible Options");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(ShowInvisibleOptionsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
			SimplePhoneButton val6 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val6).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val6).OnConfirm, new Action(PopulateButtons));
			base.ScrollView.AddButton((PhoneButton)(object)val6);
		}

		private void ShowSizeOptionsMenu()
		{
			base.ScrollView.RemoveAllButtons();
			BRCPlusPlugin.NormalizePlayerSizeConfig();
			string text = BRCPlusPlugin.PlayerSize?.Value ?? "Normal";
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Player Size: " + text);
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.PlayerSize != null)
				{
					string[] playerSizeOptions4 = BRCPlusPlugin.PlayerSizeOptions;
					int num4 = Array.IndexOf(playerSizeOptions4, BRCPlusPlugin.PlayerSize.Value);
					num4 = ((num4 >= 0) ? (num4 + 1) : 0) % playerSizeOptions4.Length;
					BRCPlusPlugin.PlayerSize.Value = playerSizeOptions4[num4];
					WorldHandler instance3 = WorldHandler.instance;
					BRCPlusPlugin.ApplyPlayerSizeTo((instance3 != null) ? instance3.GetCurrentPlayer() : null);
					ShowSizeOptionsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			string text2 = BRCPlusPlugin.PhoneSize?.Value ?? "Normal";
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Phone Size: " + text2);
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.PhoneSize != null)
				{
					string[] playerSizeOptions3 = BRCPlusPlugin.PlayerSizeOptions;
					int num3 = Array.IndexOf(playerSizeOptions3, BRCPlusPlugin.PhoneSize.Value);
					num3 = ((num3 >= 0) ? (num3 + 1) : 0) % playerSizeOptions3.Length;
					BRCPlusPlugin.PhoneSize.Value = playerSizeOptions3[num3];
					WorldHandler instance2 = WorldHandler.instance;
					BRCPlusPlugin.ApplyPhoneSizeTo((instance2 != null) ? instance2.GetCurrentPlayer() : null);
					ShowSizeOptionsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			string text3 = BRCPlusPlugin.SpraycanSize?.Value ?? "Normal";
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Spraycan Size: " + text3);
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.SpraycanSize != null)
				{
					string[] playerSizeOptions2 = BRCPlusPlugin.PlayerSizeOptions;
					int num2 = Array.IndexOf(playerSizeOptions2, BRCPlusPlugin.SpraycanSize.Value);
					num2 = ((num2 >= 0) ? (num2 + 1) : 0) % playerSizeOptions2.Length;
					BRCPlusPlugin.SpraycanSize.Value = playerSizeOptions2[num2];
					WorldHandler instance = WorldHandler.instance;
					BRCPlusPlugin.ApplySpraycanSizeTo((instance != null) ? instance.GetCurrentPlayer() : null);
					ShowSizeOptionsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			string text4 = BRCPlusPlugin.OtherCharactersSize?.Value ?? "Normal";
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Other Characters Size: " + text4);
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.OtherCharactersSize != null)
				{
					string[] playerSizeOptions = BRCPlusPlugin.PlayerSizeOptions;
					int num = Array.IndexOf(playerSizeOptions, BRCPlusPlugin.OtherCharactersSize.Value);
					num = ((num >= 0) ? (num + 1) : 0) % playerSizeOptions.Length;
					BRCPlusPlugin.OtherCharactersSize.Value = playerSizeOptions[num];
					BRCPlusPlugin.ApplyOtherCharactersSizeTo();
					ShowSizeOptionsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(ShowFunMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
		}

		private void ShowInvisibleOptionsMenu()
		{
			base.ScrollView.RemoveAllButtons();
			bool flag = BRCPlusPlugin.InvisiblePlayer?.Value ?? false;
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Invisible Player: " + (flag ? "On" : "Off"));
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.InvisiblePlayer != null)
				{
					BRCPlusPlugin.InvisiblePlayer.Value = !BRCPlusPlugin.InvisiblePlayer.Value;
					WorldHandler instance4 = WorldHandler.instance;
					BRCPlusPlugin.ApplyInvisibleTo((instance4 != null) ? instance4.GetCurrentPlayer() : null);
					ShowInvisibleOptionsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			bool flag2 = BRCPlusPlugin.InvisibleStyle?.Value ?? false;
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Invisible Style: " + (flag2 ? "On" : "Off"));
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.InvisibleStyle != null)
				{
					BRCPlusPlugin.InvisibleStyle.Value = !BRCPlusPlugin.InvisibleStyle.Value;
					WorldHandler instance3 = WorldHandler.instance;
					BRCPlusPlugin.ApplyInvisibleStyleTo((instance3 != null) ? instance3.GetCurrentPlayer() : null);
					ShowInvisibleOptionsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			bool flag3 = BRCPlusPlugin.InvisiblePhone?.Value ?? false;
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Invisible Phone: " + (flag3 ? "On" : "Off"));
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.InvisiblePhone != null)
				{
					BRCPlusPlugin.InvisiblePhone.Value = !BRCPlusPlugin.InvisiblePhone.Value;
					WorldHandler instance2 = WorldHandler.instance;
					BRCPlusPlugin.ApplyInvisiblePhoneTo((instance2 != null) ? instance2.GetCurrentPlayer() : null);
					ShowInvisibleOptionsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			bool flag4 = BRCPlusPlugin.InvisibleSpraycan?.Value ?? false;
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Invisible Spraycan: " + (flag4 ? "On" : "Off"));
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, (Action)delegate
			{
				if (BRCPlusPlugin.InvisibleSpraycan != null)
				{
					BRCPlusPlugin.InvisibleSpraycan.Value = !BRCPlusPlugin.InvisibleSpraycan.Value;
					WorldHandler instance = WorldHandler.instance;
					BRCPlusPlugin.ApplyInvisibleSpraycanTo((instance != null) ? instance.GetCurrentPlayer() : null);
					ShowInvisibleOptionsMenu();
				}
			});
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Back");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(ShowFunMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
		}

		private void ShowSpawnSomethingMenu()
		{
			base.ScrollView.RemoveAllButtons();
			SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Remove Recent Object");
			((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
			{
				RemoveMostRecentSpawnedObject();
				ShowSpawnSomethingMenu();
			});
			base.ScrollView.AddButton((PhoneButton)(object)val);
			SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("Remove Spawned Objects");
			((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
			{
				RemoveAllSpawnedObjects();
				ShowSpawnSomethingMenu();
			});
			base.ScrollView.AddButton((PhoneButton)(object)val2);
			SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("Spawn Props");
			((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, new Action(ShowSpawnPropsMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val3);
			SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("Spawn Character");
			((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, new Action(ShowSpawnNPCMenu));
			base.ScrollView.AddButton((PhoneButton)(object)val4);
			SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("Spawn Wallrun");
			((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, new Action(SpawnWallrunInFrontOfPlayer));
			base.ScrollView.AddButton((PhoneButton)(object)val5);
			SimplePhoneButton val6 = PhoneUIUtility.CreateSimpleButton("Spawn Vending Machine");
			((PhoneButton)val6).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val6).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: