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 ConfigMaxPlayers; public ConfigEntry ConfigLockKiosk; public ConfigEntry ConfigLobbyDetails; public ConfigEntry ConfigExtraMarshmallows; public ConfigEntry ConfigLateMarshmallows; public ConfigEntry ConfigCheatExtraMarshmallows; public ConfigEntry ConfigExtraBackpacks; public ConfigEntry ConfigCheatExtraBackpacks; public ConfigEntry ConfigVisibleLogTypes; public ConfigEntry ConfigHotDogChance; public ConfigEntry ConfigMenuKey; public ConfigEntry ConfigVoiceFix; public ConfigEntry ConfigAllScoutsHelicopter; public ConfigEntry 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("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("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("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("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("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("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("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("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("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("General", "Config Menu Key", "/f2", "Control path for opening the mod configuration menu (e.g. /f2, /space, /escape)"); Plugin.Logger.LogInfo((object)("ConfigurationHandler: Config Menu Key: " + ConfigMenuKey.Value)); SetupInputAction(); ConfigMenuKey.SettingChanged += OnMenuKeyChanged; ConfigCheatExtraBackpacks = _config.Bind("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("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("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("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 CampfireList = new List(); public const int VanillaMaxPlayers = 4; public static Dictionary> Marshmallows = new Dictionary>(); 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(); _modConfigurationUIComponent.Init(new List