Decompiled source of PEAK Unlimited v3.3.0

PEAKUnlimited.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PEAKUnlimited.Configuration;
using PEAKUnlimited.Patches;
using Photon.Pun;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PEAKUnlimited")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+5b2e811ab2b5a7ab36abb3d8d7bada50fd5fe24e")]
[assembly: AssemblyProduct("PEAKUnlimited")]
[assembly: AssemblyTitle("PEAKUnlimited")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PEAKUnlimited
{
	public class ConfigurationHandler
	{
		private ConfigFile _config = new ConfigFile(Path.Combine(Paths.ConfigPath, "PEAKUnlimited.cfg"), true);

		public ConfigEntry<int> ConfigMaxPlayers;

		public ConfigEntry<bool> ConfigLockKiosk;

		public ConfigEntry<bool> ConfigLobbyDetails;

		public ConfigEntry<bool> ConfigExtraMarshmallows;

		public ConfigEntry<bool> ConfigLateMarshmallows;

		public ConfigEntry<int> ConfigCheatExtraMarshmallows;

		public ConfigEntry<bool> ConfigExtraBackpacks;

		public ConfigEntry<int> ConfigCheatExtraBackpacks;

		public ConfigEntry<string> ConfigMenuKey;

		public InputAction MenuAction { get; set; }

		public int MaxPlayers => ConfigMaxPlayers.Value;

		public bool LockKiosk => ConfigLockKiosk.Value;

		public bool IsLobbyDetailsEnabled => ConfigLobbyDetails.Value;

		public bool IsExtraMarshmallowsEnabled => ConfigExtraMarshmallows.Value;

		public bool IsLateMarshmallowsEnabled => ConfigLateMarshmallows.Value;

		public int CheatMarshmallows => ConfigCheatExtraMarshmallows.Value;

		public bool IsExtraBackpacksEnabled => ConfigExtraBackpacks.Value;

		public int CheatBackpacks => ConfigCheatExtraBackpacks.Value;

		public ConfigurationHandler()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Plugin.Logger.LogInfo((object)"ConfigurationHandler initialising");
			ConfigMaxPlayers = _config.Bind<int>("General", "MaxPlayers", 20, "The maximum number of players you want to be able to join your lobby (Including yourself). Warning: untested, higher numbers may be unstable! Range: 1-20");
			if (ConfigMaxPlayers.Value == 0)
			{
				ConfigMaxPlayers.Value = 1;
			}
			else if (ConfigMaxPlayers.Value > 30)
			{
				ConfigMaxPlayers.Value = 30;
			}
			Plugin.Logger.LogInfo((object)("ConfigurationHandler: Max Players Loaded: " + ConfigMaxPlayers.Value));
			ConfigMaxPlayers.SettingChanged += OnMaxPlayersChanged;
			ConfigLockKiosk = _config.Bind<bool>("General", "LockKiosk", false, "Allows you to stop other players starting the game from the Airport Kiosk");
			Plugin.Logger.LogInfo((object)("ConfigurationHandler: Lock Kiosk enabled: " + ConfigLockKiosk.Value));
			ConfigLobbyDetails = _config.Bind<bool>("General", "LobbyDetails", true, "Prints the lobby details in the join log when a game is started");
			Plugin.Logger.LogInfo((object)("ConfigurationHandler: Lobby details enabled: " + ConfigLobbyDetails.Value));
			ConfigExtraMarshmallows = _config.Bind<bool>("General", "ExtraMarshmallows", true, "Controls whether additional marshmallows are spawned for the extra players");
			Plugin.Logger.LogInfo((object)("ConfigurationHandler: Extra marshmallows enabled: " + ConfigExtraMarshmallows.Value));
			ConfigExtraBackpacks = _config.Bind<bool>("General", "ExtraBackpacks", true, "Controls whether additional backpacks have a chance to be spawned for extra players");
			Plugin.Logger.LogInfo((object)("ConfigurationHandler: Extra backpacks enabled: " + ConfigExtraBackpacks.Value));
			ConfigLateMarshmallows = _config.Bind<bool>("General", "LateJoinMarshmallows", false, "Controls whether additional marshmallows are spawned for players who join late (mid run), and removed for those who leave early (Experimental + Untested)");
			Plugin.Logger.LogInfo((object)("ConfigurationHandler: Late Marshmallows enabled: " + ConfigLateMarshmallows.Value));
			ConfigCheatExtraMarshmallows = _config.Bind<int>("General", "Cheat Marshmallows", 0, "(Cheat, disabled by default) This will set the desired amount of marshmallows to the campfires as a cheat, requires ExtraMarshmallows to be enabled. Capped at 30.");
			if (ConfigCheatExtraMarshmallows.Value > 30)
			{
				ConfigCheatExtraMarshmallows.Value = 30;
			}
			else if (ConfigCheatExtraMarshmallows.Value < 0)
			{
				ConfigCheatExtraMarshmallows.Value = 0;
			}
			Plugin.Logger.LogInfo((object)("ConfigurationHandler: Cheat Marshmallows set to: " + ConfigCheatExtraMarshmallows.Value));
			ConfigMenuKey = _config.Bind<string>("General", "Config Menu Key", "<Keyboard>/f2", "Control path for opening the mod configuration menu (e.g. <Keyboard>/f2, <Keyboard>/space, <Keyboard>/escape)");
			Plugin.Logger.LogInfo((object)("ConfigurationHandler: Config Menu Key: " + ConfigMenuKey.Value));
			SetupInputAction();
			ConfigMenuKey.SettingChanged += OnMenuKeyChanged;
			ConfigCheatExtraBackpacks = _config.Bind<int>("General", "Cheat Backpacks", 0, "(Cheat, disabled by default) Sets how many backpacks will spawn as a cheat, requires ExtraBackpacks to also be enabled. Capped at 10.");
			if (ConfigCheatExtraBackpacks.Value > 10)
			{
				ConfigCheatExtraBackpacks.Value = 10;
			}
			else if (ConfigCheatExtraBackpacks.Value < 0)
			{
				ConfigCheatExtraBackpacks.Value = 0;
			}
			Plugin.Logger.LogInfo((object)("ConfigurationHandler: Cheat Backpacks set to: " + ConfigCheatExtraBackpacks.Value));
			Plugin.Logger.LogInfo((object)"ConfigurationHandler initialised");
		}

		private void OnMaxPlayersChanged(object sender, EventArgs e)
		{
			NetworkConnector.MAX_PLAYERS = MaxPlayers;
			Plugin.Logger.LogInfo((object)("Set the Max Players to " + NetworkConnector.MAX_PLAYERS + "!"));
		}

		private void OnMenuKeyChanged(object sender, EventArgs e)
		{
			SetupInputAction();
		}

		private void SetupInputAction()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			InputAction menuAction = MenuAction;
			if (menuAction != null)
			{
				menuAction.Dispose();
			}
			MenuAction = new InputAction((string)null, (InputActionType)1, (string)null, (string)null, (string)null, (string)null);
			InputActionSetupExtensions.AddBinding(MenuAction, ConfigMenuKey.Value, (string)null, (string)null, (string)null);
			MenuAction.Enable();
		}
	}
	[BepInPlugin("PEAKUnlimited", "PEAKUnlimited", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static int NumberOfPlayers = 1;

		public static ConfigurationHandler ConfigurationHandler;

		private readonly Harmony _harmony = new Harmony("PEAKUnlimited");

		public static List<Campfire> CampfireList = new List<Campfire>();

		public static bool IsAfterAwake = false;

		public const int VanillaMaxPlayers = 4;

		public static Dictionary<Campfire, List<GameObject>> Marshmallows = new Dictionary<Campfire, List<GameObject>>();

		public static bool HasHostStarted = false;

		private ModConfigurationUI _ui;

		public const string Id = "PEAKUnlimited";

		public static string Name => "PEAKUnlimited";

		public static string Version => "0.1.0";

		private void Awake()
		{
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin PEAKUnlimited is loaded!");
			ConfigurationHandler = new ConfigurationHandler();
			NetworkConnector.MAX_PLAYERS = ConfigurationHandler.MaxPlayers;
			Logger.LogInfo((object)("Plugin PEAKUnlimited set the Max Players to " + NetworkConnector.MAX_PLAYERS + "!"));
			_harmony.PatchAll(typeof(CampfireAwakePatch));
			_harmony.PatchAll(typeof(OnPlayerLeftRoomPatch));
			_harmony.PatchAll(typeof(OnPlayerEnteredRoomPatch));
			Logger.LogInfo((object)"Marshmallow patches successful!");
			_harmony.PatchAll(typeof(StartGamePatch));
			_harmony.PatchAll(typeof(LoadIslandMasterPatch));
			Logger.LogInfo((object)"Kiosk patches successful!");
			_harmony.PatchAll(typeof(EndSequenceRoutinePatch));
			_harmony.PatchAll(typeof(WaitingForPlayersUIPatch));
			_harmony.PatchAll(typeof(EndScreenStartPatch));
			_harmony.PatchAll(typeof(EndScreenNextPatch));
			Logger.LogInfo((object)"End screen patches successful!");
			_harmony.PatchAll(typeof(PlayerConnectionLogAwakePatch));
			_harmony.PatchAll(typeof(PlayClickedPatch));
			_harmony.PatchAll(typeof(LeaveLobbyPatch));
			Logger.LogInfo((object)"Player connection log patches successful!");
			_harmony.PatchAll(typeof(AssignMixerGroupPatch));
			Logger.LogInfo((object)"Audio patches successful!");
			GameObject val = new GameObject("PEAKUnlimitedUI");
			Object.DontDestroyOnLoad((Object)(object)val);
			_ui = val.AddComponent<ModConfigurationUI>();
			_ui.Init(new List<Option>
			{
				Option.Int("Max Players", ConfigurationHandler.ConfigMaxPlayers, 1, 30, 1, () => PhotonNetwork.InRoom),
				Option.Bool("Extra Backpacks", ConfigurationHandler.ConfigExtraBackpacks, () => PhotonNetwork.InRoom && (int)GameHandler.GetService<RichPresenceService>().m_currentState != 1),
				Option.Bool("Extra Marshmallows", ConfigurationHandler.ConfigExtraMarshmallows, () => PhotonNetwork.InRoom && (int)GameHandler.GetService<RichPresenceService>().m_currentState != 1),
				Option.Bool("Host Locked Kiosk", ConfigurationHandler.ConfigLockKiosk, () => PhotonNetwork.InRoom && (int)GameHandler.GetService<RichPresenceService>().m_currentState != 1),
				Option.Bool("Lobby Details", ConfigurationHandler.ConfigLobbyDetails, () => PhotonNetwork.InRoom && (int)GameHandler.GetService<RichPresenceService>().m_currentState != 1),
				Option.Int("Cheat Marshmallows", ConfigurationHandler.ConfigCheatExtraMarshmallows, 0, 30, 1, () => PhotonNetwork.InRoom && (int)GameHandler.GetService<RichPresenceService>().m_currentState != 1),
				Option.Int("Cheat Backpacks", ConfigurationHandler.ConfigCheatExtraBackpacks, 0, 10, 1, () => PhotonNetwork.InRoom && (int)GameHandler.GetService<RichPresenceService>().m_currentState != 1),
				Option.InputAction("Menu Key", ConfigurationHandler.ConfigMenuKey)
			});
		}
	}
	public static class Utility
	{
		public static List<Vector3> GetEvenlySpacedPointsAroundCampfire(int numPoints, float innerRadius, float outerRadius, Vector3 campfirePosition, Vector3 campfireAngles, Segment advanceToSegment)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			Quaternion val = Quaternion.Euler(campfireAngles);
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < numPoints; i++)
			{
				float num = outerRadius;
				if (i % 2 == 0)
				{
					num = innerRadius;
				}
				float num2 = (float)i * MathF.PI * 2f / (float)numPoints;
				float num3 = num * Mathf.Cos(num2);
				float num4 = num * Mathf.Sin(num2);
				((Vector3)(ref val2))..ctor(num3, 0f, num4);
				Vector3 val3 = val * val2;
				Vector3 item = campfirePosition + val3;
				item.y += -0.05f;
				list.Add(item);
			}
			return list;
		}

		public static List<GameObject> SpawnMarshmallows(int number, Vector3 campfirePosition, Vector3 campfireAngles, Segment advanceToSegment)
		{
			//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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			List<GameObject> list = new List<GameObject>();
			Item val = SingletonAsset<ItemDatabase>.Instance.itemLookup[46];
			Plugin.Logger.LogInfo((object)("Plugin PeakUnlimited " + val.GetName()));
			val.GetName();
			foreach (Vector3 item in GetEvenlySpacedPointsAroundCampfire(number, 2f, 2.5f, campfirePosition, campfireAngles, advanceToSegment))
			{
				list.Add(((Component)Add(val, item)).gameObject);
			}
			Plugin.Logger.LogInfo((object)("Plugin PeakUnlimited added with position: " + val.GetName()));
			return list;
		}

		public static Item Add(Item item, Vector3 position)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.IsConnected)
			{
				return null;
			}
			Plugin.Logger.LogInfo((object)$"Spawn item: {item} at {position}");
			return PhotonNetwork.Instantiate("0_Items/" + ((Object)item).name, position, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f), (byte)0, (object[])null).GetComponent<Item>();
		}
	}
}
namespace PEAKUnlimited.Patches
{
	public class Option
	{
		public enum OptionType
		{
			Bool,
			Int,
			String,
			InputAction
		}

		public string Label { get; set; }

		public OptionType Type { get; set; }

		public ConfigEntry<bool> BoolEntry { get; set; }

		public ConfigEntry<int> IntEntry { get; set; }

		public ConfigEntry<string> StringEntry { get; set; }

		public int MinInt { get; set; }

		public int MaxInt { get; set; }

		public int Step { get; set; }

		public Func<bool> IsDisabled { get; set; } = () => false;


		public Func<string> DisplayValue { get; set; } = () => "";


		private Option(string label, OptionType type)
		{
			Label = label;
			Type = type;
		}

		public static Option Bool(string label, ConfigEntry<bool> entry, Func<bool>? isDisabled = null)
		{
			ConfigEntry<bool> entry2 = entry;
			return new Option(label, OptionType.Bool)
			{
				BoolEntry = entry2,
				IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
				DisplayValue = () => (!entry2.Value) ? "OFF" : "ON"
			};
		}

		public static Option InputAction(string label, ConfigEntry<string> entry, Func<bool>? isDisabled = null)
		{
			ConfigEntry<string> entry2 = entry;
			return new Option(label, OptionType.InputAction)
			{
				StringEntry = entry2,
				IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
				DisplayValue = delegate
				{
					string[] array = entry2.Value.Split("/");
					return (array.Length <= 1) ? entry2.Value : array[^1].ToUpper();
				}
			};
		}

		public static Option Int(string label, ConfigEntry<int> entry, int min, int max, int step = 1, Func<bool>? isDisabled = null)
		{
			ConfigEntry<int> entry2 = entry;
			return new Option(label, OptionType.Int)
			{
				IntEntry = entry2,
				MinInt = min,
				MaxInt = max,
				Step = step,
				IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
				DisplayValue = () => entry2.Value.ToString()
			};
		}
	}
	public class AssignMixerGroupPatch
	{
		[HarmonyPatch(typeof(PlayerHandler), "AssignMixerGroup")]
		[HarmonyPrefix]
		private static bool Prefix(ref byte __result, Character character)
		{
			for (byte b = 0; b < NetworkConnector.MAX_PLAYERS; b++)
			{
				if (!PlayerHandler.Instance.m_assignedVoiceGroups.ContainsKey(b) || !ClassExtensionsMethods.UnityObjectExists<Character>(PlayerHandler.Instance.m_assignedVoiceGroups[b]))
				{
					PlayerHandler.Instance.m_assignedVoiceGroups[b] = character;
					__result = b;
					return false;
				}
			}
			__result = byte.MaxValue;
			return false;
		}
	}
	public class CampfireAwakePatch
	{
		[HarmonyPatch(typeof(Campfire), "Awake")]
		[HarmonyPostfix]
		private static void Postfix(Campfire __instance)
		{
			Plugin.Logger.LogInfo((object)"Campfire Awake Patch!");
			if (PhotonNetwork.IsMasterClient)
			{
				if (Plugin.ConfigurationHandler.IsExtraBackpacksEnabled)
				{
					AddBackpacks(__instance);
				}
				if (Plugin.ConfigurationHandler.IsExtraMarshmallowsEnabled)
				{
					AddMarshmallows(__instance);
				}
				Plugin.IsAfterAwake = true;
			}
		}

		private static void AddMarshmallows(Campfire __instance)
		{
			//IL_00f5: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)"Marshmallowification enabled and starting!");
			if (((Object)((Component)((Component)__instance).gameObject.transform.parent).gameObject).name.ToLower().Contains("wings"))
			{
				return;
			}
			Plugin.CampfireList.Add(__instance);
			Plugin.Logger.LogInfo((object)"Marshmellowifying campfire...!");
			int number = Plugin.NumberOfPlayers - 4;
			if (Plugin.ConfigurationHandler.CheatMarshmallows != 0)
			{
				Plugin.Logger.LogInfo((object)"Adding cheatmellows!");
				number = Plugin.ConfigurationHandler.CheatMarshmallows - 4 - 1;
				if (Plugin.NumberOfPlayers < 4)
				{
					number = Plugin.ConfigurationHandler.CheatMarshmallows - Plugin.NumberOfPlayers - 1;
				}
			}
			Plugin.Logger.LogInfo((object)"Start of campfire patch!");
			if (PhotonNetwork.IsMasterClient && (Plugin.NumberOfPlayers > 4 || Plugin.ConfigurationHandler.CheatMarshmallows != 0))
			{
				Plugin.Logger.LogInfo((object)("More than 4 players, preparing to marshmallowify! Number: " + Plugin.NumberOfPlayers));
				Vector3 position = ((Component)__instance).gameObject.transform.position;
				Vector3 eulerAngles = ((Component)__instance).gameObject.transform.eulerAngles;
				Plugin.Marshmallows.Add(__instance, Utility.SpawnMarshmallows(number, position, eulerAngles, __instance.advanceToSegment));
			}
			else
			{
				Plugin.Logger.LogInfo((object)"Not enough players for extra marshmallows, use the extra marshmallows cheat configuration option to override this!");
			}
		}

		private static void AddBackpacks(Campfire __instance)
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			Plugin.Logger.LogInfo((object)"Backpackification enabled and starting!");
			Item item = SingletonAsset<ItemDatabase>.Instance.itemLookup[6];
			int num = Plugin.NumberOfPlayers - 4;
			int num2 = 0;
			if (num > 0)
			{
				double num3 = (double)num * 0.25;
				if (num3 % 4.0 == 0.0)
				{
					num2 = (int)num3;
				}
				else
				{
					num2 = (int)num3;
					if ((double)Random.Range(0f, 1f) <= num3 - (double)num2)
					{
						num2++;
					}
				}
			}
			if (Plugin.ConfigurationHandler.CheatBackpacks != 0)
			{
				Plugin.Logger.LogInfo((object)("Cheat Backpacks enabled = " + Plugin.ConfigurationHandler.CheatBackpacks));
				num2 = Plugin.ConfigurationHandler.CheatBackpacks - 1;
			}
			Plugin.Logger.LogInfo((object)("Backpacks enabled = " + num2));
			if (num2 > 0)
			{
				foreach (Vector3 item2 in Utility.GetEvenlySpacedPointsAroundCampfire(num2, 3.3f, 3.7f, ((Component)__instance).gameObject.transform.position, ((Component)__instance).gameObject.transform.eulerAngles, __instance.advanceToSegment))
				{
					Vector3 position = item2;
					if (((Object)((Component)((Component)__instance).gameObject.transform.parent).gameObject).name.ToLower().Contains("wings"))
					{
						position = item2 + new Vector3(0f, 10f, 0f);
					}
					((Component)Utility.Add(item, position)).transform.parent = ((Component)__instance).gameObject.transform;
				}
				return;
			}
			Plugin.Logger.LogInfo((object)"Not enough players to add additional backpacks, use the Cheat Backpack configuration setting if you want to override this!");
		}
	}
	public class EndScreenNextPatch
	{
		[HarmonyPatch(typeof(EndScreen), "Next")]
		[HarmonyPostfix]
		private static void PostFix()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Singleton<PeakHandler>.Instance.EndScreenComplete();
			}
		}
	}
	public class EndScreenStartPatch : MonoBehaviour
	{
		[HarmonyPatch(typeof(EndScreen), "Start")]
		[HarmonyPrefix]
		private static void Prefix(EndScreen __instance)
		{
			if (Character.AllCharacters.Count <= 4)
			{
				return;
			}
			EndScreenScoutWindow[] array = (EndScreenScoutWindow[])(object)new EndScreenScoutWindow[Character.AllCharacters.Count];
			Image[] array2 = (Image[])(object)new Image[Character.AllCharacters.Count];
			Image[] array3 = (Image[])(object)new Image[Character.AllCharacters.Count];
			Image[] array4 = (Image[])(object)new Image[Character.AllCharacters.Count];
			Transform[] array5 = (Transform[])(object)new Transform[Character.AllCharacters.Count];
			for (int i = 0; i < Character.AllCharacters.Count; i++)
			{
				if (i >= __instance.scouts.Length)
				{
					if ((Object)(object)__instance.scoutWindows[0] == (Object)null)
					{
						array[i] = null;
					}
					else
					{
						array[i] = Object.Instantiate<EndScreenScoutWindow>(__instance.scoutWindows[0], ((Component)__instance.scoutWindows[0]).transform.parent);
					}
					if ((Object)(object)__instance.scouts[0] == (Object)null)
					{
						array2[i] = null;
					}
					else
					{
						array2[i] = Object.Instantiate<Image>(__instance.scouts[0], ((Component)__instance.scouts[0]).transform.parent);
					}
					if ((Object)(object)__instance.scoutsAtPeak[0] == (Object)null)
					{
						array3[i] = null;
					}
					else
					{
						array3[i] = Object.Instantiate<Image>(__instance.scoutsAtPeak[0], ((Component)__instance.scoutsAtPeak[0]).transform.parent);
					}
					if ((Object)(object)__instance.oldPip[0] == (Object)null)
					{
						array4[i] = null;
					}
					else
					{
						array4[i] = Object.Instantiate<Image>(__instance.oldPip[0], ((Component)__instance.oldPip[0]).transform.parent);
					}
					if ((Object)(object)__instance.scoutLines[0] == (Object)null)
					{
						array5[i] = null;
					}
					else
					{
						array5[i] = Object.Instantiate<Transform>(__instance.scoutLines[0], ((Component)__instance.scoutLines[0]).transform.parent);
					}
				}
				else
				{
					array[i] = __instance.scoutWindows[i];
					array2[i] = __instance.scouts[i];
					array3[i] = __instance.scoutsAtPeak[i];
					array4[i] = __instance.oldPip[i];
					array5[i] = __instance.scoutLines[i];
				}
			}
			__instance.scoutWindows = array;
			__instance.scouts = array2;
			__instance.scoutsAtPeak = array3;
			__instance.oldPip = array4;
			__instance.scoutLines = array5;
		}
	}
	public class EndSequenceRoutinePatch : MonoBehaviour
	{
		[HarmonyPatch(typeof(EndScreen), "EndSequenceRoutine")]
		[HarmonyPostfix]
		private static void Postfix(EndScreen __instance)
		{
			for (int i = 4; i < Character.AllCharacters.Count; i++)
			{
				Plugin.Logger.LogInfo((object)"Deactivating an end screen");
				Object.Destroy((Object)(object)((Component)__instance.scoutWindows[i]).gameObject);
				Plugin.Logger.LogInfo((object)"Deleted an end screen");
			}
		}
	}
	public class LeaveLobbyPatch
	{
		[HarmonyPatch(typeof(SteamLobbyHandler), "LeaveLobby")]
		[HarmonyPostfix]
		private static void Postfix(SteamLobbyHandler __instance)
		{
			Plugin.Logger.LogInfo((object)"Left Lobby");
			PlayerConnectionLogAwakePatch.isHost = false;
		}
	}
	public class LoadIslandMasterPatch
	{
		[HarmonyPatch(typeof(AirportCheckInKiosk), "LoadIslandMaster")]
		[HarmonyPrefix]
		private static bool Prefix()
		{
			if (Plugin.ConfigurationHandler.LockKiosk)
			{
				Plugin.Logger.LogInfo((object)"Load Island Master Patch running");
				if (!PhotonNetwork.IsMasterClient || !Plugin.HasHostStarted)
				{
					return false;
				}
			}
			Plugin.HasHostStarted = false;
			return true;
		}
	}
	public class OnPlayerEnteredRoomPatch
	{
		[HarmonyPatch(typeof(PlayerConnectionLog), "OnPlayerEnteredRoom")]
		[HarmonyPostfix]
		private static void Postfix(PlayerConnectionLog __instance)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			Plugin.NumberOfPlayers++;
			Plugin.Logger.LogInfo((object)("Someone has joined the room! Number: " + Plugin.NumberOfPlayers + "/" + NetworkConnector.MAX_PLAYERS));
			if (!Plugin.ConfigurationHandler.IsLateMarshmallowsEnabled || !Plugin.IsAfterAwake || !PhotonNetwork.IsMasterClient || Plugin.NumberOfPlayers <= 4 || Plugin.ConfigurationHandler.CheatMarshmallows != 0)
			{
				return;
			}
			foreach (Campfire campfire in Plugin.CampfireList)
			{
				Vector3 position = ((Component)campfire).gameObject.transform.position;
				Plugin.Logger.LogInfo((object)"Spawning a marshmallow!");
				Plugin.Marshmallows[campfire].Add(Utility.SpawnMarshmallows(1, position, ((Component)campfire).gameObject.transform.eulerAngles, campfire.advanceToSegment)[0]);
			}
		}
	}
	public class OnPlayerLeftRoomPatch : MonoBehaviour
	{
		[HarmonyPatch(typeof(PlayerConnectionLog), "OnPlayerLeftRoom")]
		[HarmonyPostfix]
		private static void Postfix(PlayerConnectionLog __instance)
		{
			Plugin.NumberOfPlayers--;
			if (Plugin.NumberOfPlayers < 0)
			{
				Plugin.NumberOfPlayers = 0;
			}
			Plugin.Logger.LogInfo((object)("Someone has left the room! Number: " + Plugin.NumberOfPlayers + "/" + NetworkConnector.MAX_PLAYERS));
			if (!Plugin.ConfigurationHandler.IsLateMarshmallowsEnabled || !Plugin.IsAfterAwake || !PhotonNetwork.IsMasterClient || Plugin.NumberOfPlayers < 4 || Plugin.ConfigurationHandler.CheatMarshmallows != 0)
			{
				return;
			}
			Plugin.Logger.LogInfo((object)"Removing a marshmallow!");
			foreach (Campfire campfire in Plugin.CampfireList)
			{
				Plugin.Logger.LogInfo((object)("Removing a marshmallow! " + Plugin.Marshmallows[campfire].Count));
				Plugin.Logger.LogInfo((object)("Removing a marshmallow! " + ((Object)Plugin.Marshmallows[campfire][0].gameObject).name));
				Object.Destroy((Object)(object)Plugin.Marshmallows[campfire][0]);
				Plugin.Marshmallows[campfire].RemoveAt(0);
				Plugin.Logger.LogInfo((object)("Removing a marshmallow! " + Plugin.Marshmallows[campfire].Count));
				Plugin.Logger.LogInfo((object)("Removing a marshmallow! " + ((Object)Plugin.Marshmallows[campfire][0].gameObject).name));
			}
		}
	}
	public class PlayClickedPatch
	{
		[HarmonyPatch(typeof(MainMenuMainPage), "PlayClicked")]
		[HarmonyPostfix]
		private static void Postfix(MainMenuMainPage __instance)
		{
			Plugin.Logger.LogInfo((object)"Play clicked");
			PlayerConnectionLogAwakePatch.isHost = true;
		}
	}
	public class PlayerConnectionLogAwakePatch
	{
		public static bool isHost;

		[HarmonyPatch(typeof(PlayerConnectionLog), "Awake")]
		[HarmonyPostfix]
		private static void Postfix(PlayerConnectionLog __instance)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: 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_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			if (!isHost || (Object)(object)GameObject.Find("AirportGateKiosk") == (Object)null)
			{
				return;
			}
			__instance.AddMessage(__instance.GetColorTag(__instance.joinedColor) + " Lobby started with: </color>" + __instance.GetColorTag(__instance.userColor) + " PEAK Unlimited </color>");
			if (Plugin.ConfigurationHandler.IsLobbyDetailsEnabled)
			{
				__instance.AddMessage($"{__instance.GetColorTag(__instance.joinedColor)} Max players: </color>{__instance.GetColorTag(__instance.userColor)} {NetworkConnector.MAX_PLAYERS} </color>");
				string text = "Enabled";
				if (!Plugin.ConfigurationHandler.IsExtraMarshmallowsEnabled)
				{
					text = "Disabled";
				}
				__instance.AddMessage(__instance.GetColorTag(__instance.joinedColor) + " Extra marshmallows: </color>" + __instance.GetColorTag(__instance.userColor) + " " + text + " </color>");
				text = "Enabled";
				if (!Plugin.ConfigurationHandler.IsExtraBackpacksEnabled)
				{
					text = "Disabled";
				}
				__instance.AddMessage(__instance.GetColorTag(__instance.joinedColor) + " Extra backpacks: </color>" + __instance.GetColorTag(__instance.userColor) + " " + text + " </color>");
				text = "Enabled";
				if (!Plugin.ConfigurationHandler.LockKiosk)
				{
					text = "Disabled";
				}
				__instance.AddMessage(__instance.GetColorTag(__instance.joinedColor) + " Host only kiosk: </color>" + __instance.GetColorTag(__instance.userColor) + " " + text + " </color>");
				if (Plugin.ConfigurationHandler.CheatMarshmallows > 0)
				{
					__instance.AddMessage($"{__instance.GetColorTag(__instance.joinedColor)} Cheat marshmallows: </color>{__instance.GetColorTag(__instance.userColor)} {Plugin.ConfigurationHandler.CheatMarshmallows} </color>");
				}
				if (Plugin.ConfigurationHandler.CheatBackpacks > 0)
				{
					__instance.AddMessage($"{__instance.GetColorTag(__instance.joinedColor)} Cheat backpacks: </color>{__instance.GetColorTag(__instance.userColor)} {Plugin.ConfigurationHandler.CheatBackpacks} </color>");
				}
			}
			__instance.AddMessage(__instance.GetColorTag(__instance.joinedColor) + " Configure PEAK Unlimited with: </color>" + __instance.GetColorTag(__instance.userColor) + " F2 </color>");
		}
	}
	public class StartGamePatch
	{
		[HarmonyPatch(typeof(AirportCheckInKiosk), "StartGame")]
		[HarmonyPrefix]
		private static void Prefix()
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Plugin.HasHostStarted = true;
			}
		}
	}
	public class WaitingForPlayersUIPatch : MonoBehaviour
	{
		[HarmonyPatch(typeof(WaitingForPlayersUI), "Update")]
		[HarmonyPrefix]
		private static void Prefix(WaitingForPlayersUI __instance)
		{
			if (__instance.scoutImages.Length >= Character.AllCharacters.Count)
			{
				return;
			}
			Image[] array = (Image[])(object)new Image[Character.AllCharacters.Count];
			Image val = __instance.scoutImages[0];
			for (int i = 0; i < Character.AllCharacters.Count; i++)
			{
				if (i < 4)
				{
					array[i] = __instance.scoutImages[i];
				}
				else
				{
					array[i] = Object.Instantiate<Image>(val, ((Component)val).transform.parent);
				}
			}
			__instance.scoutImages = array;
		}
	}
}
namespace PEAKUnlimited.Configuration
{
	public class ModConfigurationUI : MonoBehaviour
	{
		private List<Option> _options;

		private bool _visible;

		private int _selectedIndex;

		private bool _prevCursorVisible;

		private CursorLockMode _prevCursorLock;

		private bool _waitingForBinding;

		private Option _bindingTarget;

		private Texture2D _whiteTex;

		private GUIStyle _titleStyle;

		private GUIStyle _rowStyle;

		private GUIStyle _hintStyle;

		private string titleText = "PEAK Unlimited Settings";

		private string hintText = "F2: Open/Close • Tab or ↑/↓:  Move • Enter/Click: Change • Scroll Wheel or ←/→ Arrows: Adjust Numerical Values • +/-: Scale Menu";

		private int RowHeight = 32;

		private int PanelWidth = 460;

		private int Pad = 12;

		private int TitleFontSize = 22;

		private int OptionFontSize = 16;

		private int HintFontSize = 14;

		private void CalculatePanelWidth()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0011: 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_005d: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			float num = _titleStyle.CalcSize(new GUIContent(titleText)).x;
			foreach (Option option in _options)
			{
				float x = _rowStyle.CalcSize(new GUIContent(option.Label + ": " + option.DisplayValue())).x;
				if (x > num)
				{
					num = x;
				}
			}
			int num2 = CalculateHintWidth();
			num = Mathf.Max(num, (float)num2);
			PanelWidth = Mathf.Clamp((int)num + Pad * 2, 460, Screen.width - Pad * 2);
		}

		private int CalculateHintWidth()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			float num = _hintStyle.CalcHeight(new GUIContent("Test"), 9999f);
			float num2 = num * 2f;
			for (int i = 200; i < Screen.width - Pad * 2; i += 20)
			{
				float num3 = _hintStyle.CalcHeight(new GUIContent(hintText), (float)i);
				if (num3 <= num2)
				{
					return i;
				}
			}
			return Screen.width - Pad * 2;
		}

		private void Scale(int scale)
		{
			if (scale >= 0 || HintFontSize >= 2)
			{
				TitleFontSize += scale * 2;
				OptionFontSize += scale * 2;
				HintFontSize += scale * 2;
				RowHeight = OptionFontSize + 16;
				CalculatePanelWidth();
			}
		}

		public void Init(List<Option> options)
		{
			_options = options ?? new List<Option>();
			_selectedIndex = 0;
			hintText = Plugin.ConfigurationHandler.ConfigMenuKey.Value.Split("/")[^1].ToUpper() + ": Open/Close • Tab or ↑/↓:  Move • Enter/Click: Change • Scroll Wheel or ←/→ Arrows: Adjust Numerical Values • +/-: Scale Menu";
		}

		private void EnsureStyles()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//IL_00a0: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_whiteTex == (Object)null)
			{
				_whiteTex = new Texture2D(1, 1);
				_whiteTex.SetPixel(0, 0, Color.white);
				_whiteTex.Apply();
			}
			_titleStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = TitleFontSize,
				alignment = (TextAnchor)3,
				fontStyle = (FontStyle)1
			};
			_rowStyle = new GUIStyle(GUI.skin.button)
			{
				alignment = (TextAnchor)3,
				fontSize = OptionFontSize,
				padding = new RectOffset(10, 10, 4, 4)
			};
			_hintStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = HintFontSize,
				alignment = (TextAnchor)3,
				wordWrap = true
			};
		}

		private void Update()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			if (_waitingForBinding && ((ButtonControl)Keyboard.current.anyKey).wasPressedThisFrame)
			{
				Enumerator<KeyControl> enumerator = Keyboard.current.allKeys.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						KeyControl current = enumerator.Current;
						if (((ButtonControl)current).wasPressedThisFrame)
						{
							string path = ((InputControl)current).path;
							_bindingTarget.StringEntry.Value = path;
							Plugin.Logger.LogInfo((object)("Rebound " + _bindingTarget.Label + " to " + path));
							_waitingForBinding = false;
							hintText = _bindingTarget.DisplayValue() + ": Open/Close • Tab or ↑/↓:  Move • Enter/Click: Change • Scroll Wheel or ←/→ Arrows: Adjust Numerical Values • +/-: Scale Menu";
							_bindingTarget = null;
							break;
						}
					}
					return;
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
			}
			if (Plugin.ConfigurationHandler.MenuAction != null && Plugin.ConfigurationHandler.MenuAction.WasPerformedThisFrame() && (PlayerConnectionLogAwakePatch.isHost || (int)GameHandler.GetService<RichPresenceService>().m_currentState == 0))
			{
				_visible = !_visible;
				if (_visible)
				{
					OnOpened();
				}
				else
				{
					OnClosed();
				}
			}
			if (_visible && _options.Count != 0)
			{
				if (Input.GetKeyDown((KeyCode)9))
				{
					bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303);
					CycleSelection((!flag) ? 1 : (-1));
				}
				if (Input.GetKeyDown((KeyCode)61) || Input.GetKeyDown((KeyCode)43))
				{
					Scale(1);
				}
				if (Input.GetKeyDown((KeyCode)45))
				{
					Scale(-1);
				}
				if (Input.GetKeyDown((KeyCode)273))
				{
					CycleSelection(-1);
				}
				if (Input.GetKeyDown((KeyCode)274))
				{
					CycleSelection(1);
				}
				if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
				{
					ToggleSelected();
				}
				if (Input.GetKeyDown((KeyCode)276))
				{
					AdjustInt(-1);
				}
				if (Input.GetKeyDown((KeyCode)275))
				{
					AdjustInt(1);
				}
				float axis = Input.GetAxis("Mouse ScrollWheel");
				if (axis > 0f)
				{
					AdjustInt(1);
				}
				else if (axis < 0f)
				{
					AdjustInt(-1);
				}
			}
		}

		private void ToggleSelected()
		{
			Option option = _options[_selectedIndex];
			if (option.IsDisabled())
			{
				return;
			}
			switch (option.Type)
			{
			case Option.OptionType.Bool:
				option.BoolEntry.Value = !option.BoolEntry.Value;
				break;
			case Option.OptionType.Int:
			{
				int num = option.IntEntry.Value + option.Step;
				if (num > option.MaxInt)
				{
					num = option.MinInt;
				}
				option.IntEntry.Value = num;
				break;
			}
			case Option.OptionType.InputAction:
				_waitingForBinding = true;
				_bindingTarget = option;
				break;
			case Option.OptionType.String:
				break;
			}
		}

		private void AdjustInt(int delta)
		{
			Option option = _options[_selectedIndex];
			if (!option.IsDisabled() && option.Type == Option.OptionType.Int)
			{
				int value = Mathf.Clamp(option.IntEntry.Value + delta * option.Step, option.MinInt, option.MaxInt);
				option.IntEntry.Value = value;
			}
		}

		private void OnOpened()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			_prevCursorVisible = Cursor.visible;
			_prevCursorLock = Cursor.lockState;
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
			if (_options.Count > 0 && _options[_selectedIndex].IsDisabled())
			{
				CycleSelection(1);
			}
		}

		private void OnClosed()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Cursor.visible = _prevCursorVisible;
			Cursor.lockState = _prevCursorLock;
		}

		private void CycleSelection(int delta)
		{
			if (_options.Count == 0)
			{
				return;
			}
			int selectedIndex = _selectedIndex;
			do
			{
				_selectedIndex = (_selectedIndex + delta) % _options.Count;
				if (_selectedIndex < 0)
				{
					_selectedIndex += _options.Count;
				}
			}
			while (_options[_selectedIndex].IsDisabled() && _selectedIndex != selectedIndex);
		}

		private void OnGUI()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			if (!_visible)
			{
				return;
			}
			EnsureStyles();
			CalculatePanelWidth();
			float num = _titleStyle.CalcHeight(new GUIContent(titleText), (float)(PanelWidth - Pad * 2));
			float num2 = _options.Count * (RowHeight + 4);
			float num3 = _hintStyle.CalcHeight(new GUIContent("Test"), 9999f);
			float num4 = num3 * 2f;
			int num5 = Pad + (int)num + 8 + (int)num2 + Pad + (int)num4;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(20f, 20f, (float)PanelWidth, (float)num5);
			GUI.color = new Color(0f, 0f, 0f, 0.75f);
			GUI.DrawTexture(val, (Texture)(object)_whiteTex);
			GUI.color = Color.white;
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(((Rect)(ref val)).x + (float)Pad, ((Rect)(ref val)).y + (float)Pad, ((Rect)(ref val)).width - (float)(Pad * 2), num);
			GUI.Label(val2, titleText, _titleStyle);
			float num6 = ((Rect)(ref val2)).yMax + 8f;
			Rect val3 = default(Rect);
			for (int i = 0; i < _options.Count; i++)
			{
				((Rect)(ref val3))..ctor(((Rect)(ref val)).x + (float)Pad, num6, ((Rect)(ref val)).width - (float)(Pad * 2), (float)RowHeight);
				Option option = _options[i];
				if (((Rect)(ref val3)).Contains(Event.current.mousePosition) && !option.IsDisabled())
				{
					_selectedIndex = i;
				}
				if ((i == _selectedIndex && !option.IsDisabled()) || !(option.Label == "Menu Key") || !_waitingForBinding)
				{
					GUI.color = new Color(1f, 1f, 1f, 0.24f);
					GUI.DrawTexture(val3, (Texture)(object)_whiteTex);
					GUI.color = Color.white;
				}
				GUI.enabled = !option.IsDisabled();
				if (option.Label == "Menu Key" && _waitingForBinding)
				{
					GUI.color = new Color(0f, 0f, 0f, 0.6f);
					GUI.DrawTexture(val3, (Texture)(object)_whiteTex);
					GUI.color = Color.white;
					GUI.Button(val3, "Press any key...", _rowStyle);
				}
				else if (GUI.Button(val3, option.Label + ": " + option.DisplayValue(), _rowStyle) && !option.IsDisabled())
				{
					ToggleSelected();
				}
				GUI.enabled = true;
				num6 += (float)(RowHeight + 4);
			}
			Rect val4 = default(Rect);
			((Rect)(ref val4))..ctor(((Rect)(ref val)).x + (float)Pad, ((Rect)(ref val)).yMax - (float)Pad - num4, ((Rect)(ref val)).width - (float)(Pad * 2), num4);
			GUI.Label(val4, hintText, _hintStyle);
			GUI.Label(val4, hintText, _hintStyle);
		}

		private void OnDestroy()
		{
			if ((Object)(object)_whiteTex != (Object)null)
			{
				Object.Destroy((Object)(object)_whiteTex);
				_whiteTex = null;
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}