using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PEAKUnlimited.Configuration;
using PEAKUnlimited.Model.GameInfo;
using PEAKUnlimited.Patches;
using PEAKUnlimited.Util.Debugging;
using Peak.Network;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
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("3.6.7.0")]
[assembly: AssemblyInformationalVersion("3.6.7+bd53f0a09b7c9b6b0dbbedaf681e45eadbe54f61")]
[assembly: AssemblyProduct("PEAKUnlimited")]
[assembly: AssemblyTitle("PEAKUnlimited")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.6.7.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;
public static 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> ConfigVisibleLogTypes;
public ConfigEntry<float> ConfigHotDogChance;
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 string VisibleLogTypes => ConfigVisibleLogTypes.Value;
public int CheatBackpacks => ConfigCheatExtraBackpacks.Value;
public ConfigurationHandler(ConfigFile configFile)
{
_config = configFile;
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));
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 and hot dogs are spawned for the extra players");
Plugin.Logger.LogInfo((object)("ConfigurationHandler: Extra marshmallows enabled: " + ConfigExtraMarshmallows.Value));
ConfigHotDogChance = _config.Bind<float>("General", "HotDogChance", 0.375f, "Controls the chance of hot dogs being spawned instead of marshmallows for extra players, Range: 0-1");
Plugin.Logger.LogInfo((object)("ConfigurationHandler: Hot dog chance set to: " + ConfigHotDogChance.Value));
if (ConfigHotDogChance.Value < 0f)
{
ConfigHotDogChance.Value = 0f;
}
else if (ConfigHotDogChance.Value > 1f)
{
ConfigHotDogChance.Value = 1f;
}
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));
ConfigVisibleLogTypes = _config.Bind<string>("General", "VisibleLogTypes", "", "Determines what types of debug messages are visible in the Bepinex Logs, Options include: " + string.Join(", ", Enum.GetNames(typeof(DebugLogType))));
Plugin.Logger.LogInfo((object)("ConfigurationHandler: Log Types Enabled: " + string.Join(", ", Enum.GetNames(typeof(DebugLogType)))));
ConfigLateMarshmallows = _config.Bind<bool>("General", "LateJoinMarshmallows", true, "Controls whether additional marshmallows are spawned for players who join late (mid run), and removed for those who leave early");
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 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", "3.6.7")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
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 => "3.6.7";
private void Awake()
{
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_021f: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin PEAKUnlimited is loaded!");
ConfigurationHandler = new ConfigurationHandler(((BaseUnityPlugin)this).Config);
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Plugin PEAKUnlimited set the Max Players to " + ConfigurationHandler.ConfigMaxPlayers.Value + "!");
_harmony.PatchAll(typeof(NetworkingUtilitiesHostRoomOptionsPatch));
_harmony.PatchAll(typeof(SteamLobbyHandlerSetLobbyDataPatch));
_harmony.PatchAll(typeof(CampfireAwakePatch));
_harmony.PatchAll(typeof(OnPlayerLeftRoomPatch));
_harmony.PatchAll(typeof(OnPlayerEnteredRoomPatch));
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Marshmallow patches successful!");
_harmony.PatchAll(typeof(StartGamePatch));
_harmony.PatchAll(typeof(LoadIslandMasterPatch));
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Kiosk patches successful!");
_harmony.PatchAll(typeof(EndSequenceRoutinePatch));
_harmony.PatchAll(typeof(WaitingForPlayersUIPatch));
_harmony.PatchAll(typeof(EndScreenStartPatch));
_harmony.PatchAll(typeof(EndScreenNextPatch));
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "End screen patches successful!");
_harmony.PatchAll(typeof(PlayerConnectionLogAwakePatch));
_harmony.PatchAll(typeof(PlayClickedPatch));
_harmony.PatchAll(typeof(LeaveLobbyPatch));
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Player connection log patches successful!");
_harmony.PatchAll(typeof(AssignMixerGroupPatch));
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Audio patches successful!");
_harmony.PatchAll(typeof(SingleItemSpawnerTrySpawnItemsPatch));
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Item Spawner 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 Campfire Food", ConfigurationHandler.ConfigExtraMarshmallows, () => PhotonNetwork.InRoom && (int)GameHandler.GetService<RichPresenceService>().m_currentState != 1),
Option.Float("Hot Dog Chance", ConfigurationHandler.ConfigHotDogChance, 0f, 1f, 0.005f, () => PhotonNetwork.InRoom && (int)GameHandler.GetService<RichPresenceService>().m_currentState != 1),
Option.Bool("Late Join Campfire Food", ConfigurationHandler.ConfigLateMarshmallows, () => 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 Campfire Food", 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 enum CampfireFoods
{
Marshmallow = 46,
Glizzy = 154
}
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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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)
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 val4 = campfirePosition + val3;
val4.y += -0.05f;
Vector3 val5 = SetToGround(val4);
if (Vector3.Distance(val4, val5) <= 1f)
{
val4 = val5;
}
list.Add(val4);
}
return list;
}
public static List<GameObject> SpawnMarshmallows(int number, Vector3 campfirePosition, Vector3 campfireAngles, Segment advanceToSegment)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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_0085: 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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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_00b1: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: 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)
List<GameObject> list = new List<GameObject>();
foreach (Vector3 item in GetEvenlySpacedPointsAroundCampfire(number, 2f, 2.5f, campfirePosition, campfireAngles, advanceToSegment))
{
float num = Random.Range(0f, 1f);
float value = Plugin.ConfigurationHandler.ConfigHotDogChance.Value;
CampfireFoods campfireFoods = ((!(num < value)) ? CampfireFoods.Marshmallow : CampfireFoods.Glizzy);
ushort key = (ushort)campfireFoods;
Item val = SingletonAsset<ItemDatabase>.Instance.itemLookup[key];
val.GetName();
Vector3 val2 = campfirePosition - item;
Quaternion val3 = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up);
val3 *= Quaternion.Euler(0f, Random.Range(-30f, -150f), 0f);
list.Add(((Component)Add(val, item, val3)).gameObject);
}
return list;
}
private static Vector3 SetToGround(Vector3 vector)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
return HelperFunctions.GetGroundPos(vector, (LayerType)1, 0f);
}
public static Item Add(Item item, Vector3 position, Quaternion rotation)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
if (!PhotonNetwork.IsConnected)
{
return null;
}
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.CampfireLogic, $"Spawn item: {((Object)item).name} at {position}");
return PhotonNetwork.Instantiate("0_Items/" + ((Object)item).name, position, rotation, (byte)0, (object[])null).GetComponent<Item>();
}
}
}
namespace PEAKUnlimited.Util.Debugging
{
public enum DebugLogType
{
MarshmallowLogic,
CampfireLogic,
BackpackLogic,
NetworkingLogic,
PatchingLogic,
EndScreenLogic
}
public class UnlimitedLogger
{
private static UnlimitedLogger _instance;
private HashSet<DebugLogType> logTypeMap = new HashSet<DebugLogType>();
public static UnlimitedLogger GetInstance()
{
if (_instance == null)
{
_instance = new UnlimitedLogger();
}
return _instance;
}
private UnlimitedLogger()
{
string[] array = Plugin.ConfigurationHandler.VisibleLogTypes.Split(new string[1] { ", " }, StringSplitOptions.None);
foreach (string text in array)
{
if (Enum.TryParse<DebugLogType>(text, ignoreCase: true, out var result))
{
logTypeMap.Add(result);
}
else
{
Console.WriteLine("Invalid enum name: " + text);
}
}
}
public void DebugMessage(LogLevel logLevel, DebugLogType logType, string message)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (logTypeMap.Contains(logType))
{
Plugin.Logger.Log(logLevel, (object)("[" + logType.ToString() + "]: " + message));
}
}
}
}
namespace PEAKUnlimited.Patches
{
public class AssignMixerGroupPatch
{
[HarmonyPatch(typeof(PlayerHandler), "AssignMixerGroup")]
[HarmonyPrefix]
private static bool Prefix(ref byte __result, Character character)
{
for (byte b = 0; b < ConfigurationHandler.ConfigMaxPlayers.Value; 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)
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.CampfireLogic, $"Campfire Awake Patch! Number of known campfires: {Plugin.CampfireList.Count}");
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.CampfireLogic, new CampfireInfo().GetInfoMessage(__instance));
if (PhotonNetwork.IsMasterClient && !(__instance.nameOverride == "NAME_PORTABLE STOVE"))
{
if (Plugin.ConfigurationHandler.IsExtraBackpacksEnabled)
{
AddBackpacks(__instance);
}
AddMarshmallows(__instance);
Plugin.IsAfterAwake = true;
}
}
private static void AddMarshmallows(Campfire __instance)
{
//IL_00db: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
if (PhotonNetwork.IsMasterClient && !((Object)((Component)((Component)__instance).gameObject.transform.parent).gameObject).name.ToLower().Contains("wings"))
{
Plugin.CampfireList.Add(__instance);
int num = Math.Min(4, PhotonNetwork.CurrentRoom.PlayerCount);
if (Plugin.ConfigurationHandler.IsExtraMarshmallowsEnabled)
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.MarshmallowLogic, "Marshmallowification enabled and starting!");
num = PhotonNetwork.CurrentRoom.PlayerCount;
}
if (Plugin.ConfigurationHandler.CheatMarshmallows != 0)
{
num = Plugin.ConfigurationHandler.CheatMarshmallows;
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.MarshmallowLogic, "Cheatmallows enabled!");
}
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.MarshmallowLogic, $"Will spawn {num} marshmallows for {PhotonNetwork.CurrentRoom.PlayerCount} people!");
Vector3 position = ((Component)__instance).gameObject.transform.position;
Vector3 eulerAngles = ((Component)__instance).gameObject.transform.eulerAngles;
Plugin.Marshmallows.Add(__instance, Utility.SpawnMarshmallows(num, position, eulerAngles, __instance.advanceToSegment));
}
}
private static void AddBackpacks(Campfire __instance)
{
//IL_00f9: 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_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: 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_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: 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_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: 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_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.BackpackLogic, "Backpackification enabled and starting!");
Item item = SingletonAsset<ItemDatabase>.Instance.itemLookup[6];
int num = PhotonNetwork.CurrentRoom.PlayerCount - 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)
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.BackpackLogic, "Cheat Backpacks enabled = " + Plugin.ConfigurationHandler.CheatBackpacks);
num2 = Plugin.ConfigurationHandler.CheatBackpacks - 1;
}
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.BackpackLogic, "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);
}
Quaternion rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
((Component)Utility.Add(item, position, rotation)).transform.parent = ((Component)__instance).gameObject.transform;
}
return;
}
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.BackpackLogic, "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)
{
Plugin.CampfireList.Clear();
Singleton<PeakHandler>.Instance.EndScreenComplete();
}
}
}
public class EndScreenStartPatch : MonoBehaviour
{
[HarmonyPatch(typeof(EndScreen), "Start")]
[HarmonyPrefix]
private static void Prefix(EndScreen __instance)
{
int playerCount = PhotonNetwork.CurrentRoom.PlayerCount;
if (playerCount <= 4)
{
return;
}
EndScreenScoutWindow[] array = (EndScreenScoutWindow[])(object)new EndScreenScoutWindow[playerCount];
Image[] array2 = (Image[])(object)new Image[playerCount];
Image[] array3 = (Image[])(object)new Image[playerCount];
Image[] array4 = (Image[])(object)new Image[playerCount];
Transform[] array5 = (Transform[])(object)new Transform[playerCount];
for (int i = 0; i < playerCount; 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++)
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.EndScreenLogic, "Deactivating an end screen");
Object.Destroy((Object)(object)((Component)__instance.scoutWindows[i]).gameObject);
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.EndScreenLogic, "Deleted an end screen");
}
}
}
public class LeaveLobbyPatch
{
[HarmonyPatch(typeof(SteamLobbyHandler), "LeaveLobby")]
[HarmonyPostfix]
private static void Postfix(SteamLobbyHandler __instance)
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.NetworkingLogic, "Left Lobby");
PlayerConnectionLogAwakePatch.isHost = false;
}
}
public class LoadIslandMasterPatch
{
[HarmonyPatch(typeof(AirportCheckInKiosk), "LoadIslandMaster")]
[HarmonyPrefix]
private static bool Prefix()
{
if (Plugin.ConfigurationHandler.LockKiosk)
{
bool flag = !PhotonNetwork.IsMasterClient || !Plugin.HasHostStarted;
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.NetworkingLogic, $"Host Only Kiosk Logic being tested: Should Cancel Island Load = {flag}");
if (!PhotonNetwork.IsMasterClient || !Plugin.HasHostStarted)
{
return false;
}
}
Plugin.HasHostStarted = false;
return true;
}
}
public class NetworkingUtilitiesHostRoomOptionsPatch
{
[HarmonyPatch(typeof(NetworkingUtilities), "HostRoomOptions")]
[HarmonyPrefix]
private static bool Prefix(ref RoomOptions __result)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: 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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
__result = new RoomOptions
{
IsVisible = false,
MaxPlayers = ConfigurationHandler.ConfigMaxPlayers.Value,
PublishUserId = true
};
return false;
}
}
public class OnPlayerEnteredRoomPatch
{
[HarmonyPatch(typeof(PlayerConnectionLog), "OnPlayerEnteredRoom")]
[HarmonyPostfix]
private static void Postfix()
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: 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_0155: 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_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.NetworkingLogic, "Someone has joined the room! Number: " + PhotonNetwork.CurrentRoom.PlayerCount + "/" + ConfigurationHandler.ConfigMaxPlayers.Value);
if (!Plugin.ConfigurationHandler.IsLateMarshmallowsEnabled || Plugin.CampfireList == null || Plugin.CampfireList.Count == 0)
{
return;
}
Segment val;
try
{
val = Singleton<MapHandler>.Instance.GetCurrentSegment();
}
catch (Exception ex)
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)2, DebugLogType.NetworkingLogic, "Error getting current segment: " + ex);
val = (Segment)0;
}
if (!Plugin.IsAfterAwake || !PhotonNetwork.IsMasterClient || Plugin.ConfigurationHandler.CheatMarshmallows != 0)
{
return;
}
foreach (KeyValuePair<Campfire, List<GameObject>> marshmallow in Plugin.Marshmallows)
{
if (marshmallow.Key.advanceToSegment <= val)
{
continue;
}
foreach (GameObject item in marshmallow.Value)
{
PhotonNetwork.Destroy(item);
}
}
Plugin.Marshmallows.Clear();
foreach (Campfire campfire in Plugin.CampfireList)
{
if (campfire.advanceToSegment > val)
{
Plugin.Marshmallows.Add(campfire, Utility.SpawnMarshmallows(PhotonNetwork.CurrentRoom.PlayerCount, ((Component)campfire).transform.position, ((Component)campfire).gameObject.transform.eulerAngles, campfire.advanceToSegment));
}
}
}
}
public class OnPlayerLeftRoomPatch : MonoBehaviour
{
[HarmonyPatch(typeof(PlayerConnectionLog), "OnPlayerLeftRoom")]
[HarmonyPostfix]
private static void Postfix()
{
//IL_0066: 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_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_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.NetworkingLogic, "Someone has left the room! Number: " + PhotonNetwork.CurrentRoom.PlayerCount + "/" + ConfigurationHandler.ConfigMaxPlayers.Value);
if (!Plugin.ConfigurationHandler.IsLateMarshmallowsEnabled || Plugin.CampfireList == null || Plugin.CampfireList.Count == 0)
{
return;
}
Segment currentSegment = Singleton<MapHandler>.Instance.GetCurrentSegment();
if (!Plugin.IsAfterAwake || !PhotonNetwork.IsMasterClient || Plugin.ConfigurationHandler.CheatMarshmallows != 0)
{
return;
}
foreach (KeyValuePair<Campfire, List<GameObject>> marshmallow in Plugin.Marshmallows)
{
if (marshmallow.Key.advanceToSegment <= currentSegment)
{
continue;
}
foreach (GameObject item in marshmallow.Value)
{
PhotonNetwork.Destroy(item);
}
}
Plugin.Marshmallows.Clear();
foreach (Campfire campfire in Plugin.CampfireList)
{
if (campfire.advanceToSegment > currentSegment)
{
Plugin.Marshmallows.Add(campfire, Utility.SpawnMarshmallows(PhotonNetwork.CurrentRoom.PlayerCount, ((Component)campfire).transform.position, ((Component)campfire).gameObject.transform.eulerAngles, campfire.advanceToSegment));
}
}
}
}
public class PlayClickedPatch
{
[HarmonyPatch(typeof(MainMenuMainPage), "PlayClicked")]
[HarmonyPostfix]
private static void Postfix(MainMenuMainPage __instance)
{
Plugin.CampfireList.Clear();
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.NetworkingLogic, "Play clicked, this player is the lobby host!");
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_02a5: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: 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_00b1: 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_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: 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_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: 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)} {ConfigurationHandler.ConfigMaxPlayers.Value} </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.IsLateMarshmallowsEnabled)
{
text = "Disabled";
}
__instance.AddMessage(__instance.GetColorTag(__instance.joinedColor) + " Late join marshmallows: </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 SingleItemSpawnerTrySpawnItemsPatch
{
[HarmonyPatch(typeof(Spawner), "TrySpawnItems")]
[HarmonyPrefix]
private static bool Prefix(ref List<PhotonView> __result, Spawner __instance)
{
if (((Object)((Component)__instance).gameObject).name == "CampfireFoodSpawner")
{
__result = new List<PhotonView>();
return false;
}
return true;
}
}
public class StartGamePatch
{
[HarmonyPatch(typeof(AirportCheckInKiosk), "StartGame")]
[HarmonyPrefix]
private static void Prefix()
{
if (PhotonNetwork.IsMasterClient)
{
Plugin.HasHostStarted = true;
}
}
}
public class SteamLobbyHandlerSetLobbyDataPatch
{
[HarmonyPatch(typeof(SteamLobbyHandler), "SetLobbyData")]
[HarmonyPostfix]
private static void Postfix(SteamLobbyHandler __instance)
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
Plugin.Logger.LogInfo((object)("Setting lobby member limit to " + ConfigurationHandler.ConfigMaxPlayers.Value));
SteamMatchmaking.SetLobbyMemberLimit(__instance.m_currentLobby, ConfigurationHandler.ConfigMaxPlayers.Value);
}
}
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.Model.GameInfo
{
public class CampfireInfo : IGameInfo<Campfire>
{
public string GetInfoMessage(Campfire gameInstance)
{
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.AppendLine("Campfire Info:");
stringBuilder.AppendLine("- Next Segment: " + ((object)(Segment)(ref gameInstance.advanceToSegment)).ToString());
stringBuilder.AppendLine($"- Lit: {gameInstance.Lit}");
return stringBuilder.ToString();
}
}
public interface IGameInfo<T>
{
string GetInfoMessage(T gameInstance);
}
}
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 | v" + Plugin.Version;
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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
float num = _hintStyle.CalcHeight(new GUIContent("Test"), 9999f) * 2f;
for (int i = 200; i < Screen.width - Pad * 2; i += 20)
{
if (_hintStyle.CalcHeight(new GUIContent(hintText), (float)i) <= num)
{
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)
//IL_020b: 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))
{
AdjustNumerical(-1);
}
if (Input.GetKeyDown((KeyCode)275))
{
AdjustNumerical(1);
}
float y = ((InputControl<Vector2>)(object)Mouse.current.scroll).ReadValue().y;
if (y > 0f)
{
AdjustNumerical(1);
}
else if (y < 0f)
{
AdjustNumerical(-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 num2 = option.IntEntry.Value + option.Step;
if (num2 > option.MaxInt)
{
num2 = option.MinInt;
}
option.IntEntry.Value = num2;
break;
}
case Option.OptionType.Float:
{
float num = option.FloatEntry.Value + option.FloatStep;
if (num > option.MaxFloat)
{
num = option.MinFloat;
}
option.FloatEntry.Value = num;
break;
}
case Option.OptionType.InputAction:
_waitingForBinding = true;
_bindingTarget = option;
break;
case Option.OptionType.String:
break;
}
}
private void AdjustNumerical(int delta)
{
Option option = _options[_selectedIndex];
if (!option.IsDisabled())
{
if (option.Type == Option.OptionType.Int)
{
int value = Mathf.Clamp(option.IntEntry.Value + delta * option.Step, option.MinInt, option.MaxInt);
option.IntEntry.Value = value;
}
else if (option.Type == Option.OptionType.Float)
{
float value2 = Mathf.Clamp(option.FloatEntry.Value + (float)delta * option.FloatStep, option.MinFloat, option.MaxFloat);
option.FloatEntry.Value = value2;
}
}
}
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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: 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_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Unknown result type (might be due to invalid IL or missing references)
//IL_0328: Unknown result type (might be due to invalid IL or missing references)
//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: 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) * 2f;
int num4 = Pad + (int)num + 8 + (int)num2 + Pad + (int)num3;
Rect val = default(Rect);
((Rect)(ref val))..ctor(20f, 20f, (float)PanelWidth, (float)num4);
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 num5 = ((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, num5, ((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;
num5 += (float)(RowHeight + 4);
}
Rect val4 = new Rect(((Rect)(ref val)).x + (float)Pad, ((Rect)(ref val)).yMax - (float)Pad - num3, ((Rect)(ref val)).width - (float)(Pad * 2), num3);
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;
}
}
}
public class Option
{
public enum OptionType
{
Bool,
Int,
String,
InputAction,
Float
}
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; } = () => "";
public ConfigEntry<float> FloatEntry { get; set; }
public float MinFloat { get; set; }
public float MaxFloat { get; set; }
public float FloatStep { get; set; }
private Option(string label, OptionType type)
{
Label = label;
Type = type;
}
public static Option Float(string label, ConfigEntry<float> entry, float min, float max, float step = 0.05f, Func<bool>? isDisabled = null)
{
return new Option(label, OptionType.Float)
{
FloatEntry = entry,
MinFloat = min,
MaxFloat = max,
FloatStep = step,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = () => entry.Value.ToString("F3")
};
}
public static Option Bool(string label, ConfigEntry<bool> entry, Func<bool>? isDisabled = null)
{
return new Option(label, OptionType.Bool)
{
BoolEntry = entry,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = () => (!entry.Value) ? "OFF" : "ON"
};
}
public static Option InputAction(string label, ConfigEntry<string> entry, Func<bool>? isDisabled = null)
{
return new Option(label, OptionType.InputAction)
{
StringEntry = entry,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = delegate
{
string[] array = entry.Value.Split("/");
return (array.Length <= 1) ? entry.Value : array[^1].ToUpper();
}
};
}
public static Option Int(string label, ConfigEntry<int> entry, int min, int max, int step = 1, Func<bool>? isDisabled = null)
{
return new Option(label, OptionType.Int)
{
IntEntry = entry,
MinInt = min,
MaxInt = max,
Step = step,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = () => entry.Value.ToString()
};
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}