using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PEAKUnlimited.Configuration;
using PEAKUnlimited.Model.GameInfo;
using PEAKUnlimited.Patches;
using PEAKUnlimited.Patches.Voice;
using PEAKUnlimited.Util;
using PEAKUnlimited.Util.Debugging;
using Peak.Network;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.EventSystems;
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.8.0.0")]
[assembly: AssemblyInformationalVersion("3.8.0+a586f8657587942649bb9bc636e9145f3984580e")]
[assembly: AssemblyProduct("PEAKUnlimited")]
[assembly: AssemblyTitle("PEAKUnlimited")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.8.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;
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 ConfigEntry<bool> ConfigVoiceFix;
public ConfigEntry<bool> ConfigAllScoutsHelicopter;
public ConfigEntry<bool> ConfigNamePlateFix;
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 bool AllScoutsHelicopter => ConfigAllScoutsHelicopter.Value;
public bool NamePlateFix => ConfigNamePlateFix.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", "PatchingLogic, NetworkingLogic", "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));
ConfigVoiceFix = _config.Bind<bool>("Experimental", "VoiceFix", false, "Fixes voice chat issues with >4 players. Experimental, restart game if changed.");
Plugin.Logger.LogInfo((object)("ConfigurationHandler: Voice fix enabled: " + ConfigVoiceFix.Value));
ConfigAllScoutsHelicopter = _config.Bind<bool>("Experimental", "AllScoutsInHelicopter", false, "If enabled, the mod will try to put all of the (alive) scouts into the helicopter when you escape.");
Plugin.Logger.LogInfo((object)("ConfigurationHandler: Helicopter fix enabled: " + ConfigAllScoutsHelicopter.Value));
ConfigNamePlateFix = _config.Bind<bool>("Extra", "Nameplate fix", true, "Fixes incorrect nameplates above people's heads. Should be on, only turn off if it is causing issues");
Plugin.Logger.LogInfo((object)("ConfigurationHandler: Nameplate fix enabled: " + ConfigNamePlateFix.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.8.0")]
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 const int VanillaMaxPlayers = 4;
public static Dictionary<Campfire, List<GameObject>> Marshmallows = new Dictionary<Campfire, List<GameObject>>();
public static bool HasHostStarted = false;
private ModConfigurationUI _modConfigurationUIComponent;
private GameObject _modUIGameObject;
public const string Id = "PEAKUnlimited";
public static string Name => "PEAKUnlimited";
public static string Version => "3.8.0";
private void Awake()
{
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
//IL_032a: 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.NetworkingLogic, $"Pre-max-players change: {NetworkingUtilities.MAX_PLAYERS}! Applying patch...");
_harmony.PatchAll(typeof(NetworkingUtilitiesGetMaxPlayersPatch));
object value = typeof(NetworkingUtilities).GetProperty("MAX_PLAYERS").GetValue(null);
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.NetworkingLogic, $"Post-max-players patch: {value}");
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Plugin PEAKUnlimited set the Max Players to " + ConfigurationHandler.ConfigMaxPlayers.Value + "!");
_harmony.PatchAll(typeof(NetworkingUtilitiesHostRoomOptionsPatch));
_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!");
if (ConfigurationHandler.ConfigVoiceFix.Value)
{
_harmony.PatchAll(typeof(CharacterVoiceHandlerStartPatch));
_harmony.PatchAll(typeof(CharacterVoiceHandlerUpdatePatch));
_harmony.PatchAll(typeof(PlayerHandlerAssignMixerGroupPatch));
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Audio patches enabled!");
}
else
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Audio patches disabled.");
}
_harmony.PatchAll(typeof(SingleItemSpawnerTrySpawnItemsPatch));
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Item Spawner patches successful!");
_harmony.PatchAll(typeof(AudioLevelsInitNavigationPatch));
_harmony.PatchAll(typeof(UIPlayerNamesPatches));
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Nameplate patches successful!");
_harmony.PatchAll(typeof(PeakHandlerPatches));
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.PatchingLogic, "Helicopter patches successful!");
_modUIGameObject = new GameObject("PEAKUnlimitedUI");
Object.DontDestroyOnLoad((Object)(object)_modUIGameObject);
_modConfigurationUIComponent = _modUIGameObject.AddComponent<ModConfigurationUI>();
_modConfigurationUIComponent.Init(new List<Option>
{
Option.Int("Max Players", ConfigurationHandler.ConfigMaxPlayers, 1, 30, 1, () => PhotonNetwork.InRoom),
Option.Bool("Extra Backpacks", ConfigurationHandler.ConfigExtraBackpacks, () => PhotonNetwork.InRoom && GameHandler.IsOnIsland),
Option.Bool("Extra Campfire Food", ConfigurationHandler.ConfigExtraMarshmallows, () => PhotonNetwork.InRoom && GameHandler.IsOnIsland),
Option.Float("Hot Dog Chance", ConfigurationHandler.ConfigHotDogChance, 0f, 1f, 0.005f, () => PhotonNetwork.InRoom && GameHandler.IsOnIsland),
Option.Bool("Late Join Campfire Food", ConfigurationHandler.ConfigLateMarshmallows, () => PhotonNetwork.InRoom && GameHandler.IsOnIsland),
Option.Bool("Host Locked Kiosk", ConfigurationHandler.ConfigLockKiosk, () => PhotonNetwork.InRoom && GameHandler.IsOnIsland),
Option.Bool("Lobby Details", ConfigurationHandler.ConfigLobbyDetails, () => PhotonNetwork.InRoom && GameHandler.IsOnIsland),
Option.Int("Cheat Campfire Food", ConfigurationHandler.ConfigCheatExtraMarshmallows, 0, 30, 1, () => PhotonNetwork.InRoom && GameHandler.IsOnIsland),
Option.Int("Cheat Backpacks", ConfigurationHandler.ConfigCheatExtraBackpacks, 0, 10, 1, () => PhotonNetwork.InRoom && GameHandler.IsOnIsland),
Option.Bool("Experimental: Fix Voice Chat", ConfigurationHandler.ConfigVoiceFix, () => PhotonNetwork.InRoom),
Option.Bool("Experimental: All Scouts in Helicopter", ConfigurationHandler.ConfigAllScoutsHelicopter, () => PhotonNetwork.InRoom),
Option.InputAction("Menu Key", ConfigurationHandler.ConfigMenuKey)
});
}
private void OnDestroy()
{
_harmony.UnpatchSelf();
Object.Destroy((Object)(object)_modUIGameObject);
Logger.LogInfo((object)("Plugin " + Name + " unloaded!"));
}
}
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 void SpawnMarshmallows(int number, Campfire campfire)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
//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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
Vector3 position = ((Component)campfire).transform.position;
Vector3 eulerAngles = ((Component)campfire).transform.eulerAngles;
Segment advanceToSegment = campfire.advanceToSegment;
List<GameObject> list = new List<GameObject>();
foreach (Vector3 item in GetEvenlySpacedPointsAroundCampfire(number, 2f, 2.5f, position, eulerAngles, 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 = position - item;
Quaternion val3 = Quaternion.LookRotation(((Vector3)(ref val2)).normalized, Vector3.up);
val3 *= Quaternion.Euler(0f, Random.Range(-30f, -150f), 0f);
list.Add(InstantiateItem(val, item, val3));
}
Plugin.Marshmallows.Add(campfire, 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 GameObject InstantiateItem(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);
}
}
}
namespace PEAKUnlimited.Util
{
public static class PlayerCountChangeUtilities
{
public static void ForgetCampfiresAndMarshmallows()
{
if (Plugin.Marshmallows != null)
{
Plugin.Marshmallows.Clear();
}
if (Plugin.CampfireList != null)
{
Plugin.CampfireList.Clear();
}
}
public static void RespawnMarshmallows()
{
//IL_00b1: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if (!GameHandler.IsOnIslandAndInitialized)
{
return;
}
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)2, DebugLogType.MarshmallowLogic, "We are on the island.");
if (!Plugin.ConfigurationHandler.IsLateMarshmallowsEnabled)
{
return;
}
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)2, DebugLogType.MarshmallowLogic, "Late marshmallows are enabled.");
if (Plugin.CampfireList == null || Plugin.CampfireList.Count == 0)
{
return;
}
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)2, DebugLogType.MarshmallowLogic, "The campfire list exists and is not empty.");
Segment val;
try
{
val = Singleton<MapHandler>.Instance.GetCurrentSegment();
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)2, DebugLogType.MarshmallowLogic, "Segment found: " + ((object)(Segment)(ref val)).ToString());
}
catch (Exception ex)
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)2, DebugLogType.MarshmallowLogic, "Error getting current segment, will refresh all campfires: " + ex);
val = (Segment)0;
}
if (!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)
{
Utility.SpawnMarshmallows(PhotonNetwork.CurrentRoom.PlayerCount, campfire);
}
}
}
}
}
namespace PEAKUnlimited.Util.Debugging
{
public enum DebugLogType
{
MarshmallowLogic,
CampfireLogic,
BackpackLogic,
NetworkingLogic,
PatchingLogic,
EndScreenLogic,
AudioSliderLogic
}
public class SteamLobbyAPIPlayerIsInLobbyPatch
{
[HarmonyPatch(typeof(SteamLobbyAPI), "PlayerIsInLobby")]
[HarmonyPrefix]
private static bool Prefix(ref bool __result)
{
__result = true;
return false;
}
}
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
{
Plugin.Logger.LogInfo((object)("Invalid enum name found while setting up Logger: '" + text + "'. Check your configuration file!"));
}
}
}
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 AudioLevelsInitNavigationPatch
{
public class AudioLevelSliderScrollForwarder : MonoBehaviour, IScrollHandler, IEventSystemHandler
{
private ScrollRect _scroll;
public void SetScroll(ScrollRect scroll)
{
_scroll = scroll;
}
public void OnScroll(PointerEventData e)
{
ScrollRect scroll = _scroll;
if (scroll != null)
{
scroll.OnScroll(e);
}
}
}
[HarmonyPatch(typeof(AudioLevels), "InitNavigation")]
[HarmonyPostfix]
private static void Postfix(AudioLevels __instance)
{
if (!Object.op_Implicit((Object)(object)__instance.mainPage))
{
return;
}
int maxPlayers = Plugin.ConfigurationHandler.MaxPlayers;
int count = __instance.sliders.Count;
if (count < maxPlayers)
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.AudioSliderLogic, $"Adding sliders: {count} -> {maxPlayers}");
AudioLevelSlider? obj = __instance.sliders.FirstOrDefault();
GameObject val = ((obj != null) ? ((Component)obj).gameObject : null);
if (!((Object)(object)val == (Object)null))
{
AddSliders(__instance, val, count, maxPlayers);
SetupAudioLevelsScroll();
__instance._dirty = true;
}
}
}
private static void AddSliders(AudioLevels instance, GameObject template, int existing, int max)
{
int num = max - existing;
for (int i = 0; i < num; i++)
{
GameObject obj = Object.Instantiate<GameObject>(template, template.transform.parent);
((Object)obj).name = $"AudioLevelSlider ({existing + i})";
AudioLevelSlider component = obj.GetComponent<AudioLevelSlider>();
instance.sliders.Add(component);
component.Init(PhotonNetwork.LocalPlayer);
}
}
private static void SetupAudioLevelsScroll()
{
GameObject val = GameObject.Find("AudioLevels");
if (!((Object)(object)val == (Object)null))
{
Transform parent = val.transform.parent;
if (!(((parent != null) ? ((Object)parent).name : null) == "AudioLevelsScroll"))
{
GameObject obj = CreateScrollRoot(val);
GameObject viewport = CreateViewport(obj);
RectTransform val2 = MoveContent(val, viewport);
ScrollRect val3 = ConfigureScroll(obj, viewport, val2);
CreateScrollbar(obj, val3);
ConfigureLayout(val);
LayoutRebuilder.ForceRebuildLayoutImmediate(val2);
Canvas.ForceUpdateCanvases();
ForwardScrollEvents(val, val3);
obj.transform.SetSiblingIndex(val.transform.GetSiblingIndex());
val3.verticalNormalizedPosition = 1f;
}
}
}
private static GameObject CreateScrollRoot(GameObject audioLevels)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: 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_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
GameObject val = new GameObject("AudioLevelsScroll", new Type[2]
{
typeof(RectTransform),
typeof(ScrollRect)
});
val.transform.SetParent(audioLevels.transform.parent, false);
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = new Vector2(1f, 0f);
component.anchorMax = new Vector2(1f, 1f);
component.pivot = new Vector2(1f, 1f);
component.anchoredPosition = Vector2.zero;
component.sizeDelta = new Vector2(300f, 0f);
return val;
}
private static GameObject CreateViewport(GameObject scrollGameObject)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: 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_007a: 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_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Expected O, but got Unknown
GameObject val = new GameObject("Viewport", new Type[3]
{
typeof(RectTransform),
typeof(Image),
typeof(Mask)
});
val.transform.SetParent(scrollGameObject.transform, false);
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = new Vector2(-20f, 0f);
((Behaviour)val.GetComponent<Image>()).enabled = false;
val.GetComponent<Mask>().showMaskGraphic = false;
return val;
}
private static RectTransform MoveContent(GameObject audioLevels, GameObject viewport)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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)
audioLevels.transform.SetParent(viewport.transform, false);
RectTransform component = audioLevels.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0f, 1f);
component.anchorMax = new Vector2(1f, 1f);
component.pivot = new Vector2(0.5f, 1f);
component.anchoredPosition = Vector2.zero;
component.offsetMin = new Vector2(0f, component.offsetMin.y);
component.offsetMax = new Vector2(0f, component.offsetMax.y);
return component;
}
private static ScrollRect ConfigureScroll(GameObject scrollGameObject, GameObject viewport, RectTransform rectTransform)
{
ScrollRect component = scrollGameObject.GetComponent<ScrollRect>();
component.viewport = viewport.GetComponent<RectTransform>();
component.content = rectTransform;
component.horizontal = false;
component.vertical = true;
component.inertia = true;
component.decelerationRate = 0.08f;
component.scrollSensitivity = 25f;
component.movementType = (MovementType)1;
return component;
}
private static void CreateScrollbar(GameObject scrollGameObject, ScrollRect scrollRect)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: 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_0150: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject("Scrollbar", new Type[3]
{
typeof(RectTransform),
typeof(Image),
typeof(Scrollbar)
});
val.transform.SetParent(scrollGameObject.transform, false);
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = new Vector2(1f, 0f);
component.anchorMax = new Vector2(1f, 1f);
component.sizeDelta = new Vector2(20f, 0f);
((Graphic)val.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.3f);
GameObject val2 = new GameObject("Handle", new Type[2]
{
typeof(RectTransform),
typeof(Image)
});
val2.transform.SetParent(val.transform, false);
RectTransform component2 = val2.GetComponent<RectTransform>();
component2.anchorMin = Vector2.zero;
component2.anchorMax = Vector2.one;
component2.offsetMin = new Vector2(4f, 4f);
component2.offsetMax = new Vector2(-4f, -4f);
((Graphic)val2.GetComponent<Image>()).color = new Color(1f, 1f, 1f, 0.55f);
Scrollbar component3 = val.GetComponent<Scrollbar>();
component3.direction = (Direction)2;
component3.handleRect = component2;
((Selectable)component3).targetGraphic = (Graphic)(object)val2.GetComponent<Image>();
scrollRect.verticalScrollbar = component3;
scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)2;
}
private static void ConfigureLayout(GameObject audioLevels)
{
VerticalLayoutGroup component = audioLevels.GetComponent<VerticalLayoutGroup>();
if ((Object)(object)component != (Object)null)
{
((LayoutGroup)component).padding.right = 50;
((Behaviour)component).enabled = true;
}
(audioLevels.GetComponent<ContentSizeFitter>() ?? audioLevels.AddComponent<ContentSizeFitter>()).verticalFit = (FitMode)2;
}
private static void ForwardScrollEvents(GameObject audioLevels, ScrollRect scroll)
{
Transform[] componentsInChildren = audioLevels.GetComponentsInChildren<Transform>(true);
foreach (Transform val in componentsInChildren)
{
(((Component)val).GetComponent<AudioLevelSliderScrollForwarder>() ?? ((Component)val).gameObject.AddComponent<AudioLevelSliderScrollForwarder>()).SetScroll(scroll);
}
}
}
public class CampfireAwakePatch
{
[CompilerGenerated]
private sealed class <WaitForRoomAndRun>d__3 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Campfire instance;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForRoomAndRun>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (PhotonNetwork.CurrentRoom == null)
{
<>2__current = null;
<>1__state = 1;
return true;
}
if (!PhotonNetwork.IsMasterClient)
{
return false;
}
if (instance.nameOverride == "NAME_PORTABLE STOVE")
{
return false;
}
if (Plugin.ConfigurationHandler.IsExtraBackpacksEnabled)
{
AddBackpacks(instance);
}
AddMarshmallows(instance);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[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}");
if (PhotonNetwork.CurrentRoom == null)
{
((MonoBehaviour)__instance).StartCoroutine(WaitForRoomAndRun(__instance));
return;
}
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.CampfireLogic, new CampfireInfo().GetInfoMessage(__instance));
if (!PhotonNetwork.IsMasterClient)
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.CampfireLogic, "Campfire Awake Patch! Not the master client, returning!");
}
else if (!(__instance.nameOverride == "NAME_PORTABLE STOVE"))
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.CampfireLogic, "Testing 123");
if (Plugin.ConfigurationHandler.IsExtraBackpacksEnabled)
{
AddBackpacks(__instance);
}
AddMarshmallows(__instance);
}
}
private static void AddMarshmallows(Campfire __instance)
{
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!");
Utility.SpawnMarshmallows(num, __instance);
}
}
private static void AddBackpacks(Campfire __instance)
{
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: 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_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: 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_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: 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];
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.BackpackLogic, "Backpackification enabled and starting! 1");
int num;
try
{
num = PhotonNetwork.CurrentRoom.PlayerCount - 4;
}
catch
{
num = 0;
}
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.BackpackLogic, "Backpackification enabled and starting! 2");
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++;
}
}
}
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.BackpackLogic, "Backpackification enabled and starting! 3");
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);
Utility.InstantiateItem(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!");
}
[IteratorStateMachine(typeof(<WaitForRoomAndRun>d__3))]
private static IEnumerator WaitForRoomAndRun(Campfire instance)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForRoomAndRun>d__3(0)
{
instance = instance
};
}
}
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)
{
PlayerCountChangeUtilities.ForgetCampfiresAndMarshmallows();
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 NetworkingUtilitiesGetMaxPlayersPatch
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPrefix]
private static bool Prefix(ref int __result)
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.NetworkingLogic, "Get max players patch!");
__result = ConfigurationHandler.ConfigMaxPlayers.Value;
return false;
}
}
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()
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.NetworkingLogic, "Someone has joined the room! Number: " + PhotonNetwork.CurrentRoom.PlayerCount + "/" + ConfigurationHandler.ConfigMaxPlayers.Value);
PlayerCountChangeUtilities.RespawnMarshmallows();
}
}
public class OnPlayerLeftRoomPatch
{
[HarmonyPatch(typeof(PlayerConnectionLog), "OnPlayerLeftRoom")]
[HarmonyPostfix]
private static void Postfix()
{
UnlimitedLogger.GetInstance().DebugMessage((LogLevel)16, DebugLogType.NetworkingLogic, "Someone has left the room! Number: " + PhotonNetwork.CurrentRoom.PlayerCount + "/" + ConfigurationHandler.ConfigMaxPlayers.Value);
PlayerCountChangeUtilities.RespawnMarshmallows();
}
}
[HarmonyPatch(typeof(PeakHandler))]
public class PeakHandlerPatches
{
[HarmonyPatch("EndCutscene")]
[HarmonyPrefix]
private static void EndCutscenePrefix(PeakHandler __instance)
{
if (!Plugin.ConfigurationHandler.AllScoutsHelicopter)
{
return;
}
Plugin.Logger.LogInfo((object)"[PeakHandler] EndCutscene Prefix called");
int maxPlayers = Plugin.ConfigurationHandler.MaxPlayers;
if (__instance.cutsceneScoutRefs == null || __instance.cutsceneScoutRefs.Length == 0)
{
Plugin.Logger.LogInfo((object)"[PeakHandler] cutsceneScoutRefs is null or empty");
return;
}
if (__instance.cutsceneScoutRefs.Length >= maxPlayers)
{
Plugin.Logger.LogInfo((object)"[PeakHandler] Arrays are already large enough");
return;
}
CustomizationRefs[] cutsceneScoutRefs = __instance.cutsceneScoutRefs;
EndCutsceneScoutHelper[] cutsceneScoutAnims = __instance.cutsceneScoutAnims;
GameObject gameObject = ((Component)((Component)cutsceneScoutRefs[0]).transform.parent).gameObject;
Transform parent = gameObject.transform.parent;
CustomizationRefs[] array = (CustomizationRefs[])(object)new CustomizationRefs[maxPlayers];
EndCutsceneScoutHelper[] array2 = (EndCutsceneScoutHelper[])(object)new EndCutsceneScoutHelper[maxPlayers];
for (int i = 0; i < cutsceneScoutRefs.Length; i++)
{
array[i] = cutsceneScoutRefs[i];
array2[i] = cutsceneScoutAnims[i];
}
for (int j = cutsceneScoutRefs.Length; j < maxPlayers; j++)
{
Plugin.Logger.LogInfo((object)$"[PeakHandler] Creating a clone: P ({j + 1})");
GameObject obj = Object.Instantiate<GameObject>(gameObject, parent);
((Object)obj).name = $"P ({j + 1})";
CustomizationRefs componentInChildren = obj.GetComponentInChildren<CustomizationRefs>(true);
EndCutsceneScoutHelper componentInChildren2 = obj.GetComponentInChildren<EndCutsceneScoutHelper>(true);
((Object)((Component)componentInChildren).transform).name = $"Scout P{j + 1} Sit";
obj.SetActive(false);
array[j] = componentInChildren;
array2[j] = componentInChildren2;
}
__instance.cutsceneScoutRefs = array;
__instance.cutsceneScoutAnims = array2;
Plugin.Logger.LogInfo((object)"[PeakHandler] Finished expanding arrays");
}
[HarmonyPatch("SetCosmetics")]
[HarmonyPostfix]
private static void SetCosmeticsPostfix(PeakHandler __instance, List<Character> characters)
{
//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_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: 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)
//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Unknown result type (might be due to invalid IL or missing references)
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.ConfigurationHandler.AllScoutsHelicopter)
{
return;
}
Plugin.Logger.LogInfo((object)"[PeakHandler] SetCosmetics Postfix called");
if (characters == null)
{
Plugin.Logger.LogInfo((object)"[PeakHandler] characters list is null");
return;
}
Plugin.Logger.LogInfo((object)$"[PeakHandler] Total characters passed in: {characters.Count}");
List<Character> list = (from c in characters
where c.refs.stats.won
orderby ((MonoBehaviourPun)c).photonView.ViewID
select c).ToList();
Plugin.Logger.LogInfo((object)$"[PeakHandler] Valid (won) characters: {list.Count}");
if (list.Count <= 4)
{
Plugin.Logger.LogInfo((object)"[PeakHandler] <= 4 players, nothing to extend");
return;
}
List<AnimatedMouth> list2 = (List<AnimatedMouth>)AccessTools.Field(typeof(PeakHandler), "localMouths").GetValue(__instance);
for (int i = 4; i < list.Count && i < __instance.cutsceneScoutRefs.Length; i++)
{
Plugin.Logger.LogInfo((object)$"[PeakHandler] Processing extra player index {i}");
Character val = list[i];
CustomizationRefs val2 = __instance.cutsceneScoutRefs[i];
if ((Object)(object)val2 == (Object)null)
{
Plugin.Logger.LogInfo((object)$"[PeakHandler] scout at index {i} is null");
continue;
}
((Component)((Component)val2).transform.parent).gameObject.SetActive(true);
val.refs.customization.SetCustomizationForRef(val2);
if (val.data.isSkeleton)
{
val2.SetSkeleton(true, false);
}
BadgeUnlocker.SetBadges(val, val2.sashRenderer);
AnimatedMouth component = ((Component)val2).GetComponent<AnimatedMouth>();
component.audioSource = ((Component)val).GetComponent<AnimatedMouth>().audioSource;
if (val.IsLocal)
{
Plugin.Logger.LogInfo((object)$"[PeakHandler] Adding local mouth for player {i}");
list2.Add(component);
}
}
int count = list.Count;
if (count <= 1)
{
return;
}
CustomizationRefs[] cutsceneScoutRefs = __instance.cutsceneScoutRefs;
Transform transform = ((Component)cutsceneScoutRefs[0]).transform;
Transform transform2 = ((Component)cutsceneScoutRefs[3]).transform;
float x = transform.localPosition.x;
float x2 = transform2.localPosition.x;
Plugin.Logger.LogInfo((object)$"[PeakHandler] Repositioning & scaling {count} players");
Vector3 localScale = ((Component)cutsceneScoutRefs[0]).transform.localScale;
_ = ((Component)cutsceneScoutRefs[0]).transform.parent.localScale;
for (int j = 0; j < count && j < cutsceneScoutRefs.Length; j++)
{
CustomizationRefs val3 = cutsceneScoutRefs[j];
if (!((Object)(object)val3 == (Object)null))
{
Transform parent = ((Component)val3).transform.parent;
((Component)parent).gameObject.SetActive(true);
float num = (float)j / (float)(count - 1);
float x3 = Mathf.Lerp(x, x2, num);
Vector3 localPosition = ((Component)val3).transform.localPosition;
localPosition.x = x3;
((Component)val3).transform.localPosition = localPosition;
float num2 = Mathf.Clamp(4f / (float)count, 0.01f, 1f);
((Component)val3).transform.localScale = localScale * num2;
parent.localRotation = ((Component)cutsceneScoutRefs[0]).transform.parent.localRotation;
}
}
}
}
public class PlayClickedPatch
{
[HarmonyPatch(typeof(MainMenuMainPage), "PlayClicked")]
[HarmonyPostfix]
private static void Postfix(MainMenuMainPage __instance)
{
PlayerCountChangeUtilities.ForgetCampfiresAndMarshmallows();
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;
}
}
}
[HarmonyPatch(typeof(UIPlayerNames))]
internal class UIPlayerNamesPatches
{
private static void FixArrayLengths(UIPlayerNames instance)
{
if (!Plugin.ConfigurationHandler.NamePlateFix)
{
return;
}
int maxPlayers = Plugin.ConfigurationHandler.MaxPlayers;
if (instance.playerNameText != null && instance.playerNameText.Length < maxPlayers)
{
PlayerName[] playerNameText = instance.playerNameText;
int num = playerNameText.Length;
PlayerName val = playerNameText[0];
Transform parent = ((Component)val).transform.parent;
PlayerName[] array = (PlayerName[])(object)new PlayerName[maxPlayers];
for (int i = 0; i < num; i++)
{
array[i] = playerNameText[i];
}
for (int j = num; j < maxPlayers; j++)
{
PlayerName val2 = Object.Instantiate<PlayerName>(val, parent);
((Component)val2).gameObject.SetActive(false);
val2.group.alpha = 0f;
val2.audioImageTimeout = 0f;
array[j] = val2;
}
instance.playerNameText = array;
}
}
[HarmonyPatch("Init")]
[HarmonyPrefix]
private static void InitPrefix(UIPlayerNames __instance)
{
if (Plugin.ConfigurationHandler.NamePlateFix)
{
FixArrayLengths(__instance);
}
}
[HarmonyPatch("UpdateName")]
[HarmonyPrefix]
private static bool UpdateNamePrefix(UIPlayerNames __instance, int index)
{
if (!Plugin.ConfigurationHandler.NamePlateFix)
{
return true;
}
FixArrayLengths(__instance);
if (__instance.playerNameText == null)
{
return false;
}
if (index >= __instance.playerNameText.Length)
{
return false;
}
return true;
}
[HarmonyPatch("DisableName")]
[HarmonyPrefix]
private static bool DisableNamePrefix(UIPlayerNames __instance, int index)
{
if (!Plugin.ConfigurationHandler.NamePlateFix)
{
return true;
}
if (__instance.playerNameText == null)
{
return false;
}
if (index >= __instance.playerNameText.Length)
{
return false;
}
return 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.Patches.Voice
{
public class CharacterVoiceHandlerStartPatch
{
[HarmonyPatch(typeof(CharacterVoiceHandler), "Start")]
[HarmonyPostfix]
private static void Postfix(CharacterVoiceHandler __instance)
{
if (!__instance.m_character.IsLocal)
{
byte b = PlayerHandler.AssignMixerGroup(__instance.m_character);
try
{
__instance.m_source.outputAudioMixerGroup = __instance.GetMixerGroup(b);
}
catch
{
__instance.m_source.outputAudioMixerGroup = null;
}
__instance.m_parameter = __instance.GetMixerGroupParameter((byte)(b % 4));
}
}
}
public class CharacterVoiceHandlerUpdatePatch
{
[HarmonyPatch(typeof(CharacterVoiceHandler), "Update")]
[HarmonyPostfix]
private static void Postfix(CharacterVoiceHandler __instance)
{
if (!((Object)(object)__instance.m_character == (Object)null))
{
float playerLevel = AudioLevels.GetPlayerLevel(((MonoBehaviourPun)__instance.m_character).photonView.Owner.UserId);
__instance.m_source.volume = playerLevel;
}
}
}
public class PlayerHandlerAssignMixerGroupPatch
{
[HarmonyPatch(typeof(PlayerHandler), "AssignMixerGroup")]
[HarmonyPrefix]
private static bool Prefix(ref byte __result, Character character)
{
int actorNumber = ((MonoBehaviourPun)character).photonView.Owner.ActorNumber;
__result = (byte)(actorNumber % 4);
PlayerHandler.Instance.m_assignedVoiceGroups[__result] = character;
return false;
}
}
}
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_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: 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>()._presence.State == 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)
{
}
}
}