using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using AsyncLoggers.DBAPI;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
using LobbyControl.Dependency;
using LobbyControl.Patches;
using LobbyControl.PopUp;
using LobbyControl.TerminalCommands;
using Microsoft.CodeAnalysis;
using ReservedItemSlotCore.Data;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("LobbyControl")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.4.2.0")]
[assembly: AssemblyInformationalVersion("2.4.2+0083f52104f8d34c268be1f26817f13aff08f81b")]
[assembly: AssemblyProduct("Lobby Control")]
[assembly: AssemblyTitle("LobbyControl")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.4.2.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace LobbyControl
{
[BepInPlugin("mattymatty.LobbyControl", "LobbyControl", "2.4.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class LobbyControl : BaseUnityPlugin
{
internal static class PluginConfig
{
internal static class SteamLobby
{
internal static ConfigEntry<bool> AutoLobby;
internal static ConfigEntry<bool> RadarFix;
}
internal static class ItemSync
{
internal static ConfigEntry<bool> GhostItems;
internal static ConfigEntry<bool> ForceDrop;
internal static ConfigEntry<bool> ShotGunReload;
internal static ConfigEntry<bool> SyncOnUse;
internal static ConfigEntry<bool> SyncOnInteract;
internal static ConfigEntry<string> SyncIgnoreName;
}
internal static class SaveLimit
{
internal static ConfigEntry<bool> Enabled;
}
internal static class InvisiblePlayer
{
internal static ConfigEntry<bool> Enabled;
}
internal static class LogSpam
{
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<bool> CalculatePolygonPath;
internal static ConfigEntry<bool> AudioSpatializer;
}
internal static class JoinQueue
{
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<int> ConnectionTimeout;
internal static ConfigEntry<int> ConnectionDelay;
}
internal static void Init(BaseUnityPlugin plugin)
{
ConfigFile config = plugin.Config;
ItemSync.GhostItems = config.Bind<bool>("ItemSync", "ghost_items", true, "prevent the creation of non-grabbable items in case of inventory desync");
ItemSync.ForceDrop = config.Bind<bool>("ItemSync", "force_drop", true, "forcefully drop all items of the player causing the desync");
ItemSync.ShotGunReload = config.Bind<bool>("ItemSync", "shotgun_reload", true, "prevent the shotgun disappearing when reloading it");
ItemSync.SyncOnUse = config.Bind<bool>("ItemSync", "sync_on_use", false, "sync held object upon usage");
ItemSync.SyncOnInteract = config.Bind<bool>("ItemSync", "sync_on_interact", false, "sync held object upon interaction");
ItemSync.SyncIgnoreName = config.Bind<string>("ItemSync", "sync_ignore_name", "Flashlight,Pro-flashlight,Laser pointer", "do not attempt sync on items that are in the list (compatibility with FlashLight toggle, ecc)");
SaveLimit.Enabled = config.Bind<bool>("SaveLimit", "enabled", true, "remove the limit to the amount of items that can be saved");
InvisiblePlayer.Enabled = config.Bind<bool>("InvisiblePlayer", "enabled", true, "attempts to fix late joining players appearing invisible to the rest of the lobby");
SteamLobby.AutoLobby = config.Bind<bool>("SteamLobby", "auto_lobby", false, "automatically reopen the lobby as soon as you reach orbit");
SteamLobby.RadarFix = config.Bind<bool>("SteamLobby", "radar_fix", true, "fix mismatched radar names if a radar booster was activated during the play session");
LogSpam.Enabled = config.Bind<bool>("LogSpam", "enabled", true, "prevent some annoying log spam");
LogSpam.CalculatePolygonPath = config.Bind<bool>("LogSpam", "CalculatePolygonPath", true, "stop pathfinding for dead Enemies");
LogSpam.AudioSpatializer = config.Bind<bool>("LogSpam", "audio_spatializer", true, "disable audio spatialization as there is not spatialization plugin");
JoinQueue.Enabled = config.Bind<bool>("JoinQueue", "enabled", true, "handle joining players as a queue instead of at the same time");
JoinQueue.ConnectionTimeout = config.Bind<int>("JoinQueue", "connection_timeout_ms", 3000, "After how much time discard a hanging connection");
JoinQueue.ConnectionDelay = config.Bind<int>("JoinQueue", "connection_delay_ms", 500, "Delay between each successful connection");
PropertyInfo property = ((object)config).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(config, null);
dictionary.Clear();
config.Save();
}
}
public const string GUID = "mattymatty.LobbyControl";
public const string NAME = "LobbyControl";
public const string VERSION = "2.4.2";
internal static ManualLogSource Log;
public static bool CanModifyLobby = true;
public static bool CanSave = true;
public static bool AutoSaveEnabled = true;
private static readonly string[] IncompatibleGUIDs = new string[3] { "com.github.tinyhoot.ShipLobby", "twig.latecompany", "com.potatoepet.AdvancedCompany" };
internal static readonly List<PluginInfo> FoundIncompatibilities = new List<PluginInfo>();
private void Awake()
{
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Expected O, but got Unknown
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
try
{
PluginInfo[] array = Chainloader.PluginInfos.Values.Where((PluginInfo p) => IncompatibleGUIDs.Contains(p.Metadata.GUID)).ToArray();
if (array.Length != 0)
{
StringBuilder stringBuilder = new StringBuilder("LOBBY CONTROL was DISABLED!\nIncompatible:");
FoundIncompatibilities.AddRange(array);
PluginInfo[] array2 = array;
foreach (PluginInfo val in array2)
{
Log.LogWarning((object)(val.Metadata.Name + " is incompatible!"));
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Incompatibility", val.Metadata.Name);
}
stringBuilder.Append("\n").Append(val.Metadata.Name);
}
Log.LogError((object)$"{array.Length} incompatible mods found! Disabling!");
Harmony val2 = new Harmony("mattymatty.LobbyControl");
PopUpPatch.PopUps.Add(new Tuple<string, string>("LC_Incompatibility", stringBuilder.ToString()));
val2.PatchAll(typeof(PopUpPatch));
return;
}
if (LobbyCompatibilityChecker.Enabled)
{
LobbyCompatibilityChecker.Init("mattymatty.LobbyControl", Version.Parse("2.4.2"), 1, 2);
}
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Awake", "Initializing");
}
Log.LogInfo((object)"Initializing Configs");
PluginConfig.Init((BaseUnityPlugin)(object)this);
CommandManager.Initialize();
Log.LogInfo((object)"Patching Methods");
Harmony val3 = new Harmony("mattymatty.LobbyControl");
val3.PatchAll(Assembly.GetExecutingAssembly());
Log.LogInfo((object)"LobbyControl v2.4.2 Loaded!");
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Awake", "Finished Initializing");
}
}
catch (Exception ex)
{
Log.LogError((object)("Exception while initializing: \n" + ex));
}
}
}
}
namespace LobbyControl.TerminalCommands
{
public class Command
{
public TerminalNode previousTerminalNode;
public bool awaitingConfirmation
{
get
{
return CommandManager.awaitingConfirmationCommand == this;
}
set
{
CommandManager.awaitingConfirmationCommand = (value ? this : null);
}
}
public virtual bool IsCommand(string[] args)
{
return false;
}
public virtual TerminalNode Execute(string[] args)
{
return TerminalPatch.CreateTerminalNode("Execute override was not found.\n\n");
}
public virtual TerminalNode ExecuteConfirmation(string[] args)
{
string text = args[0].ToLower();
if ("confirm".Contains(text) && text.Length > 0)
{
return OnConfirm(args);
}
if ("deny".Contains(text) && text.Length > 0)
{
return OnDeny(args);
}
return OnInvalidInput(args);
}
protected virtual TerminalNode OnConfirm(string[] args)
{
return TerminalPatch.CreateTerminalNode("OnConfirm override was not found.\n\n");
}
protected virtual TerminalNode OnDeny(string[] args)
{
return TerminalPatch.CreateTerminalNode("OnDeny override was not found.\n\n");
}
protected virtual TerminalNode OnInvalidInput(string[] args)
{
return previousTerminalNode;
}
}
internal class CommandManager
{
private static List<Command> commands = new List<Command>();
public static Command awaitingConfirmationCommand;
public static void Initialize()
{
commands = new List<Command>
{
new LobbyCommand()
};
awaitingConfirmationCommand = null;
}
public static bool TryExecuteCommand(string[] array, out TerminalNode terminalNode)
{
terminalNode = null;
string[] args = GetArgs(array, 3);
if (awaitingConfirmationCommand != null)
{
Command command = awaitingConfirmationCommand;
terminalNode = command.ExecuteConfirmation(args);
command.previousTerminalNode = terminalNode;
return true;
}
Command command2 = GetCommand(args);
if (command2 == null)
{
return false;
}
terminalNode = command2.Execute(args);
command2.previousTerminalNode = terminalNode;
return true;
}
public static void OnLocalDisconnect()
{
awaitingConfirmationCommand = null;
}
public static void OnTerminalQuit()
{
awaitingConfirmationCommand = null;
}
private static string[] GetArgs(string[] array, int length)
{
List<string> list = new List<string>();
StringBuilder stringBuilder = new StringBuilder();
int num = 0;
foreach (string text in array)
{
if (!(text.Trim() == string.Empty))
{
num++;
if (num < length)
{
list.Add(text.Trim());
}
else
{
stringBuilder.Append(text.Trim()).Append(" ");
}
}
}
if (stringBuilder.Length > 0)
{
list.Add(stringBuilder.ToString().Trim());
}
if (list.Count > length)
{
return list.ToArray();
}
for (int j = 0; j < length - list.Count; j++)
{
list.Add(string.Empty);
}
return list.ToArray();
}
private static Command GetCommand(string[] args)
{
Command result = null;
commands.ForEach(delegate(Command command)
{
if (result == null && command.IsCommand(args))
{
result = command;
}
});
return result;
}
}
public class LobbyCommand : Command
{
private const string DefaultText = "- status : prints the current lobby status\r\n\r\nSteam:\r\n- open : open the lobby\r\n- close : close the lobby\r\n- private : set lobby to Invite Only\r\n- friend : set lobby to Friends Only\r\n- public : set lobby to Public\r\n- rename [name] : change the name of the lobby\r\n\r\nSaving:\r\n- autosave : toggle autosave for the savefile\r\n- save (name) : save the lobby\r\n- load (name) : load a savefile\r\n- switch (name) : swap savefile without loading it\r\n- clear : reset the current lobby to empty\r\n\r\nExtra:\r\n- dropall : drop all items to the ground\r\n";
public override bool IsCommand(string[] args)
{
if (GameNetworkManager.Instance.isHostingGame)
{
return args[0].Trim().ToLower() == "lobby";
}
return false;
}
public override TerminalNode Execute(string[] args)
{
TerminalNode node = ScriptableObject.CreateInstance<TerminalNode>();
try
{
if (Utility.IsNullOrWhiteSpace(args[1]))
{
return HelpNode();
}
switch (args[1])
{
case "status":
StatusCommand(ref node, args);
break;
case "open":
{
if (PerformOrbitCheck(node, out var errorText10))
{
return errorText10;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
OpenCommand(ref node, args);
}
break;
}
case "close":
{
if (PerformOrbitCheck(node, out var errorText7))
{
return errorText7;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
CloseCommand(ref node, args);
}
break;
}
case "private":
{
if (PerformOrbitCheck(node, out var errorText3))
{
return errorText3;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
PrivateCommand(ref node, args);
}
break;
}
case "friend":
{
if (PerformOrbitCheck(node, out var errorText11))
{
return errorText11;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
FriendCommand(ref node, args);
}
break;
}
case "public":
{
if (PerformOrbitCheck(node, out var errorText2))
{
return errorText2;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
PublicCommand(ref node, args);
}
break;
}
case "rename":
{
if (PerformOrbitCheck(node, out var errorText6))
{
return errorText6;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
RenameCommand(ref node, args);
}
break;
}
case "autosave":
AutoSaveCommand(ref node, args);
break;
case "save":
{
if (PerformOrbitCheck(node, out var errorText8))
{
return errorText8;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
SaveCommand(ref node, args);
}
break;
}
case "load":
{
if (PerformOrbitCheck(node, out var errorText4))
{
return errorText4;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
LoadCommand(ref node, args);
}
break;
}
case "switch":
{
if (PerformOrbitCheck(node, out var errorText9))
{
return errorText9;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
SwitchCommand(ref node, args);
}
break;
}
case "clear":
{
if (PerformOrbitCheck(node, out var errorText5))
{
return errorText5;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
ClearCommand(ref node, args);
}
break;
}
case "dropall":
{
if (PerformOrbitCheck(node, out var errorText))
{
return errorText;
}
if (!LobbyControl.CanModifyLobby)
{
node.displayText = "Lobby cannot be changed at the moment\n\n";
}
else
{
DropAllCommand(ref node, args);
}
break;
}
case "help":
node = HelpNode();
break;
default:
node = HelpNode();
node.displayText = "Invalid Command, options:\n" + node.displayText;
break;
}
}
catch (Exception ex)
{
LobbyControl.Log.LogError((object)("Exception:\n\n" + ex));
node.displayText = "Exception!\n\n";
}
return node;
}
private static bool StatusCommand(ref TerminalNode node, string[] args)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
GameNetworkManager instance = GameNetworkManager.Instance;
if (!instance.currentLobby.HasValue)
{
node.displayText = "Failed to fetch lobby ( was null )\n\n";
return false;
}
Lobby value = instance.currentLobby.Value;
bool flag = LobbyPatcher.IsOpen(value);
LobbyType visibility = LobbyPatcher.GetVisibility(value);
string data = ((Lobby)(ref value)).GetData("name");
bool canSave = LobbyControl.CanSave;
StringBuilder stringBuilder = new StringBuilder("Lobby Status:");
stringBuilder.Append("\n- File is '").Append(instance.currentSaveFileName).Append("'");
stringBuilder.Append("\n- Name is '").Append(data).Append("'");
stringBuilder.Append("\n- Status is ").Append(flag ? "Open" : "Closed");
stringBuilder.Append("\n- Visibility is ").Append(((object)(LobbyType)(ref visibility)).ToString());
stringBuilder.Append("\n- Saving is ").Append(canSave ? "Automatic" : "Manual");
stringBuilder.Append("\n\n");
node.displayText = stringBuilder.ToString();
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool OpenCommand(ref TerminalNode node, string[] args)
{
LobbyControl.Log.LogDebug((object)"Reopening lobby, setting to joinable.");
GameNetworkManager instance = GameNetworkManager.Instance;
if (!instance.currentLobby.HasValue)
{
node.displayText = "Failed to fetch lobby ( was null )\n\n";
return false;
}
instance.SetLobbyJoinable(true);
Object.FindObjectOfType<QuickMenuManager>().inviteFriendsTextAlpha.alpha = 1f;
string text = "Lobby is now Open";
LobbyControl.Log.LogInfo((object)text);
node.displayText = text + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool CloseCommand(ref TerminalNode node, string[] args)
{
LobbyControl.Log.LogDebug((object)"Closing lobby, setting to not joinable.");
GameNetworkManager instance = GameNetworkManager.Instance;
if (!instance.currentLobby.HasValue)
{
node.displayText = "Failed to fetch lobby ( was null )\n\n";
return false;
}
instance.SetLobbyJoinable(false);
Object.FindObjectOfType<QuickMenuManager>().inviteFriendsTextAlpha.alpha = 0f;
string text = "Lobby is now Closed";
LobbyControl.Log.LogInfo((object)text);
node.displayText = text + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool PrivateCommand(ref TerminalNode node, string[] args)
{
//IL_003c: 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)
LobbyControl.Log.LogDebug((object)"Locking lobby, setting to Private.");
GameNetworkManager instance = GameNetworkManager.Instance;
if (!instance.currentLobby.HasValue)
{
node.displayText = "Failed to fetch lobby ( was null )\n\n";
return false;
}
Lobby value = instance.currentLobby.Value;
((Lobby)(ref value)).SetPrivate();
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Visibility", "Private");
}
string text = "Lobby is now Private";
LobbyControl.Log.LogInfo((object)text);
node.displayText = text + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool FriendCommand(ref TerminalNode node, string[] args)
{
//IL_003c: 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_0053: 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)
LobbyControl.Log.LogDebug((object)"Locking lobby, setting to Friends Only.");
GameNetworkManager instance = GameNetworkManager.Instance;
if (!instance.currentLobby.HasValue)
{
node.displayText = "Failed to fetch lobby ( was null )\n\n";
return false;
}
Lobby value = instance.currentLobby.Value;
((Lobby)(ref value)).SetPrivate();
value = instance.currentLobby.Value;
((Lobby)(ref value)).SetFriendsOnly();
string text = "Lobby is now Friends Only";
LobbyControl.Log.LogInfo((object)text);
node.displayText = text + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool PublicCommand(ref TerminalNode node, string[] args)
{
//IL_003c: 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)
LobbyControl.Log.LogDebug((object)"Unlocking lobby, setting to Public.");
GameNetworkManager instance = GameNetworkManager.Instance;
if (!instance.currentLobby.HasValue)
{
node.displayText = "Failed to fetch lobby ( was null )\n\n";
return false;
}
Lobby value = instance.currentLobby.Value;
((Lobby)(ref value)).SetPublic();
string text = "Lobby is now Public";
LobbyControl.Log.LogInfo((object)text);
node.displayText = text + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool RenameCommand(ref TerminalNode node, string[] args)
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: 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)
if (Utility.IsNullOrWhiteSpace(args[2]))
{
node.displayText = "Lobby name cannot be null\n\n";
return false;
}
string text = args[2];
if (text.Length > 40)
{
text = text.Substring(0, 40);
}
LobbyControl.Log.LogDebug((object)("Renaming lobby: \"" + text + "\""));
GameNetworkManager instance = GameNetworkManager.Instance;
if (!instance.currentLobby.HasValue)
{
node.displayText = "Failed to fetch lobby ( was null )\n\n";
return false;
}
instance.lobbyHostSettings.lobbyName = text;
Lobby value = instance.currentLobby.Value;
((Lobby)(ref value)).SetData("name", instance.lobbyHostSettings.lobbyName);
value = instance.currentLobby.Value;
instance.steamLobbyName = ((Lobby)(ref value)).GetData("name");
ES3.Save<string>("HostSettings_Name", instance.steamLobbyName, "LCGeneralSaveData");
string text2 = "Lobby renamed to \"" + text + "\"";
LobbyControl.Log.LogInfo((object)text2);
node.displayText = text2 + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool AutoSaveCommand(ref TerminalNode node, string[] args)
{
LobbyControl.Log.LogDebug((object)"Toggling AutoSave");
LobbyControl.CanSave = (LobbyControl.AutoSaveEnabled = !LobbyControl.AutoSaveEnabled);
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Autosave", LobbyControl.CanSave.ToString());
}
string text = "AutoSaving is now " + (LobbyControl.CanSave ? "On" : "Off");
LobbyControl.Log.LogInfo((object)text);
node.displayText = text + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool SaveCommand(ref TerminalNode node, string[] args)
{
if (StartOfRound.Instance.isChallengeFile)
{
node.displayText = "Cannot Edit Challenge Save\n\n";
return false;
}
LobbyControl.Log.LogDebug((object)"Saving Lobby");
GameNetworkManager instance = GameNetworkManager.Instance;
string currentSaveFileName = instance.currentSaveFileName;
if (!Utility.IsNullOrWhiteSpace(args[2]))
{
string text = args[2];
if (text.Length > 20)
{
text = text.Substring(0, 20);
}
instance.currentSaveFileName = text;
}
if (currentSaveFileName != instance.currentSaveFileName)
{
ES3.CopyFile(currentSaveFileName, instance.currentSaveFileName);
}
LobbyControl.CanSave = true;
HUDManager.Instance.saveDataIconAnimatorB.SetTrigger("save");
instance.SaveGameValues();
string text2 = "Lobby Saved to " + instance.currentSaveFileName;
LobbyControl.CanSave = LobbyControl.AutoSaveEnabled;
instance.currentSaveFileName = currentSaveFileName;
LobbyControl.Log.LogInfo((object)text2);
node.displayText = text2 + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool LoadCommand(ref TerminalNode node, string[] args)
{
if (StartOfRound.Instance.isChallengeFile)
{
node.displayText = "Cannot Edit Challenge Save\n\n";
return false;
}
LobbyControl.Log.LogDebug((object)"Reloading Lobby");
GameNetworkManager instance = GameNetworkManager.Instance;
if (!Utility.IsNullOrWhiteSpace(args[2]))
{
string text = args[2];
if (text.Length > 20)
{
text = text.Substring(0, 20);
}
instance.currentSaveFileName = text;
}
string text2 = "Lobby '" + instance.currentSaveFileName + "' loaded";
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(LoadLobbyCoroutine());
LobbyControl.AutoSaveEnabled = (LobbyControl.CanSave = ES3.Load<bool>("LC_SavingMethod", GameNetworkManager.Instance.currentSaveFileName, true));
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Autosave", LobbyControl.CanSave.ToString());
}
LobbyControl.Log.LogInfo((object)text2);
node.displayText = text2 + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool SwitchCommand(ref TerminalNode node, string[] args)
{
if (StartOfRound.Instance.isChallengeFile)
{
node.displayText = "Cannot Edit Challenge Save\n\n";
return false;
}
LobbyControl.Log.LogDebug((object)"Switching Lobby");
GameNetworkManager instance = GameNetworkManager.Instance;
if (Utility.IsNullOrWhiteSpace(args[2]))
{
node.displayText = "You need to specify a destination for the swap!";
return false;
}
string text = args[2];
if (text.Length > 20)
{
text = text.Substring(0, 20);
}
instance.currentSaveFileName = text;
string text2 = "Lobby is now saving to '" + instance.currentSaveFileName + "'";
node.displayText = text2 + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool ClearCommand(ref TerminalNode node, string[] args)
{
if (StartOfRound.Instance.isChallengeFile)
{
node.displayText = "Cannot Edit Challenge Save\n\n";
return false;
}
LobbyControl.Log.LogDebug((object)"Clearing Lobby");
LobbyControl.CanSave = true;
GameNetworkManager.Instance.ResetSavedGameValues();
LobbyControl.CanSave = LobbyControl.AutoSaveEnabled;
bool flag = LoadCommand(ref node, new string[3]);
if (flag)
{
node.displayText = "Lobby is now Empty!";
}
return flag;
}
private static bool DropAllCommand(ref TerminalNode node, string[] args)
{
LobbyControl.Log.LogDebug((object)"Dropping all Items");
string text = "All Items Dropped";
PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
foreach (PlayerControllerB val in allPlayerScripts)
{
val.DropAllHeldItemsAndSync();
}
node.displayText = text + "\n\n";
node.maxCharactersToType = node.displayText.Length + 2;
return true;
}
private static bool PerformOrbitCheck(TerminalNode terminalNode, out TerminalNode errorText)
{
if (!StartOfRound.Instance.inShipPhase)
{
terminalNode.displayText = "Can only be used while in Orbit\n\n";
errorText = terminalNode;
return true;
}
errorText = null;
return false;
}
private static TerminalNode HelpNode()
{
TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
val.displayText = "- status : prints the current lobby status\r\n\r\nSteam:\r\n- open : open the lobby\r\n- close : close the lobby\r\n- private : set lobby to Invite Only\r\n- friend : set lobby to Friends Only\r\n- public : set lobby to Public\r\n- rename [name] : change the name of the lobby\r\n\r\nSaving:\r\n- autosave : toggle autosave for the savefile\r\n- save (name) : save the lobby\r\n- load (name) : load a savefile\r\n- switch (name) : swap savefile without loading it\r\n- clear : reset the current lobby to empty\r\n\r\nExtra:\r\n- dropall : drop all items to the ground\r\n";
val.clearPreviousText = true;
val.maxCharactersToType = val.displayText.Length + 2;
return val;
}
private static IEnumerator LoadLobbyCoroutine()
{
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Load", "Starting " + GameNetworkManager.Instance.currentSaveFileName);
}
StartOfRound startOfRound = StartOfRound.Instance;
Terminal terminal = Object.FindObjectOfType<Terminal>();
startOfRound.ResetShipFurniture(false, true);
startOfRound.ResetPooledObjects(true);
bool mem = GameNetworkManager.Instance.gameHasStarted;
GameNetworkManager.Instance.gameHasStarted = false;
foreach (KeyValuePair<int, GameObject> item in StartOfRound.Instance.SpawnedShipUnlockables.ToList())
{
UnlockableItem val = startOfRound.unlockablesList.unlockables[item.Key];
if (val.alreadyUnlocked && val.spawnPrefab && !((Object)(object)item.Value == (Object)null))
{
NetworkObject component = item.Value.GetComponent<NetworkObject>();
if ((Object)(object)component != (Object)null && component.IsSpawned)
{
component.Despawn(true);
}
}
}
startOfRound.SpawnedShipUnlockables.Clear();
startOfRound.suitsPlaced = 0;
GameNetworkManager.Instance.ResetUnlockablesListValues(false);
yield return (object)new WaitForSeconds(0.2f);
startOfRound.SetTimeAndPlanetToSavedSettings();
startOfRound.SetMapScreenInfoToCurrentLevel();
terminal.Start();
if (startOfRound.connectedPlayersAmount >= 1)
{
RefreshLobby();
}
ReloadUnlockables();
yield return (object)new WaitForSeconds(0.2f);
startOfRound.LoadShipGrabbableItems();
yield return (object)new WaitForSeconds(0.1f);
if (startOfRound.connectedPlayersAmount >= 1)
{
startOfRound.SyncShipUnlockablesServerRpc();
}
GameNetworkManager.Instance.gameHasStarted = mem;
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Load", "Finshed " + GameNetworkManager.Instance.currentSaveFileName);
}
}
private static void ReloadUnlockables()
{
//IL_0298: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_0241: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_024b: 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_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: 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_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
StartOfRound instance = StartOfRound.Instance;
instance.LoadUnlockables();
try
{
for (int i = 0; i < instance.unlockablesList.unlockables.Count; i++)
{
UnlockableItem val = instance.unlockablesList.unlockables[i];
if (!val.alreadyUnlocked)
{
continue;
}
LobbyControl.Log.LogWarning((object)(val.unlockableName + " starting"));
if (!instance.SpawnedShipUnlockables.ContainsKey(i))
{
instance.SpawnUnlockable(i);
}
PlaceableShipObject val2 = instance.SpawnedShipUnlockables[i].GetComponent<PlaceableShipObject>();
if (val2 == null)
{
val2 = instance.SpawnedShipUnlockables[i].GetComponentInChildren<PlaceableShipObject>();
}
if (val2 == null)
{
continue;
}
LobbyControl.Log.LogWarning((object)(val.unlockableName + " continuing"));
AutoParentToShip parentObject = val2.parentObject;
if ((Object)(object)parentObject != (Object)null)
{
LobbyControl.Log.LogWarning((object)(val.unlockableName + " parentObject"));
if (val.inStorage)
{
val2.parentObject.disableObject = true;
}
Vector3 positionOffset = parentObject.positionOffset;
Vector3 val3 = instance.elevatorTransform.TransformPoint(positionOffset);
Vector3 position = ((Component)val2.mainMesh).transform.position;
Vector3 placedPosition = val3 - (((Component)val2.parentObject).transform.position - position) - (position - ((Component)val2.placeObjectCollider).transform.position);
val.placedPosition = placedPosition;
Quaternion val4 = Quaternion.Euler(parentObject.rotationOffset);
Quaternion val5 = val4 * Quaternion.Inverse(((Component)parentObject).transform.rotation);
Quaternion val6 = val5 * ((Component)val2.mainMesh).transform.rotation;
Vector3 eulerAngles = ((Quaternion)(ref val6)).eulerAngles;
val.placedRotation = eulerAngles;
}
else
{
LobbyControl.Log.LogWarning((object)(val.unlockableName + " parentObjectSecondary"));
Transform parentObjectSecondary = val2.parentObjectSecondary;
Vector3 position2 = parentObjectSecondary.position;
Transform transform = ((Component)val2.mainMesh).transform;
Vector3 position3 = transform.position;
Vector3 placedPosition2 = position2 - (((Component)parentObjectSecondary).transform.position - position3 + (position3 - ((Component)val2.placeObjectCollider).transform.position));
val.placedPosition = placedPosition2;
Quaternion rotation = parentObjectSecondary.rotation;
Quaternion val7 = rotation * Quaternion.Inverse(transform.rotation);
Vector3 eulerAngles2 = ((Quaternion)(ref val7)).eulerAngles;
val.placedRotation = eulerAngles2;
}
}
if (instance.connectedPlayersAmount < 1)
{
return;
}
List<ulong> targetClientIds = instance.ClientPlayerList.Keys.ToList();
ClientRpcParams val8 = default(ClientRpcParams);
val8.Send = new ClientRpcSendParams
{
TargetClientIds = targetClientIds
};
ClientRpcParams val9 = val8;
for (int j = 0; j < instance.unlockablesList.unlockables.Count; j++)
{
UnlockableItem val10 = instance.unlockablesList.unlockables[j];
if (val10.alreadyUnlocked && !val10.inStorage)
{
FastBufferWriter val11 = ((NetworkBehaviour)instance).__beginSendClientRpc(1076853239u, val9, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val11, j);
((NetworkBehaviour)instance).__endSendClientRpc(ref val11, 1076853239u, val9, (RpcDelivery)0);
}
}
instance.SyncShipUnlockablesServerRpc();
}
catch (Exception ex)
{
LobbyControl.Log.LogError((object)ex);
}
}
private static void RefreshLobby()
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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_00a3: 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)
//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_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: 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)
StartOfRound instance = StartOfRound.Instance;
List<ulong> list = new List<ulong>();
List<ulong> list2 = new List<ulong>();
for (int i = 0; i < instance.allPlayerObjects.Length; i++)
{
NetworkObject component = instance.allPlayerObjects[i].GetComponent<NetworkObject>();
if (!component.IsOwnedByServer)
{
list.Add(component.OwnerClientId);
list2.Add(component.OwnerClientId);
}
else if (i == 0)
{
list.Add(NetworkManager.Singleton.LocalClientId);
}
else
{
list.Add(999uL);
}
}
ClientRpcParams val = default(ClientRpcParams);
val.Send = new ClientRpcSendParams
{
TargetClientIds = list2
};
ClientRpcParams val2 = val;
int groupCredits = Object.FindObjectOfType<Terminal>().groupCredits;
int profitQuota = TimeOfDay.Instance.profitQuota;
int quotaFulfilled = TimeOfDay.Instance.quotaFulfilled;
int num = (int)TimeOfDay.Instance.timeUntilDeadline;
PlayerControllerB localPlayerController = StartOfRound.Instance.localPlayerController;
FastBufferWriter val3 = ((NetworkBehaviour)instance).__beginSendClientRpc(886676601u, val2, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val3, localPlayerController.actualClientId);
BytePacker.WriteValueBitPacked(val3, instance.connectedPlayersAmount - 1);
bool flag = true;
((FastBufferWriter)(ref val3)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
((FastBufferWriter)(ref val3)).WriteValueSafe<ulong>(list.ToArray(), default(ForPrimitives));
BytePacker.WriteValueBitPacked(val3, instance.ClientPlayerList[localPlayerController.actualClientId]);
BytePacker.WriteValueBitPacked(val3, groupCredits);
BytePacker.WriteValueBitPacked(val3, instance.currentLevelID);
BytePacker.WriteValueBitPacked(val3, profitQuota);
BytePacker.WriteValueBitPacked(val3, num);
BytePacker.WriteValueBitPacked(val3, quotaFulfilled);
BytePacker.WriteValueBitPacked(val3, instance.randomMapSeed);
((FastBufferWriter)(ref val3)).WriteValueSafe<bool>(ref instance.isChallengeFile, default(ForPrimitives));
((NetworkBehaviour)instance).__endSendClientRpc(ref val3, 886676601u, val2, (RpcDelivery)0);
}
}
}
namespace LobbyControl.PopUp
{
[HarmonyPatch]
public class PopUpPatch
{
public static readonly List<Tuple<string, string>> PopUps = new List<Tuple<string, string>>();
[HarmonyPrefix]
[HarmonyPatch(typeof(MenuManager), "Awake")]
private static void AddPopups(MenuManager __instance)
{
foreach (Tuple<string, string> popUp in PopUps)
{
AppendPopup(popUp.Item1, popUp.Item2);
}
}
private static void AppendPopup(string name, string text)
{
GameObject val = GameObject.Find("/Canvas/MenuContainer/");
GameObject val2 = GameObject.Find("Canvas/MenuContainer/LANWarning/");
if (!((Object)(object)val2 == (Object)null))
{
GameObject val3 = Object.Instantiate<GameObject>(val2, val.transform);
((Object)val3).name = name;
val3.SetActive(true);
GameObject val4 = GameObject.Find("Canvas/MenuContainer/" + name + "/Panel/NotificationText");
TextMeshProUGUI component = val4.GetComponent<TextMeshProUGUI>();
((TMP_Text)component).text = text;
}
}
}
}
namespace LobbyControl.Patches
{
[HarmonyPatch]
internal class DebugPatches
{
}
[HarmonyPatch]
public class ItemSyncPatches
{
[HarmonyPatch]
internal class GhostItemPatches
{
[HarmonyFinalizer]
[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectServerRpc")]
private static Exception CheckOverflow(PlayerControllerB __instance, Exception __exception, NetworkObjectReference grabbedObject)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (__exception != null)
{
__instance.GrabObjectClientRpc(false, grabbedObject);
}
return __exception;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlayerControllerB), "GrabObjectServerRpc")]
private static IEnumerable<CodeInstruction> CheckOverflow(IEnumerable<CodeInstruction> instructions)
{
//IL_015f: 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_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Expected O, but got Unknown
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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_00c2: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: 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)
//IL_0101: Expected O, but got Unknown
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
List<CodeInstruction> list = instructions.ToList();
FieldInfo field = typeof(GrabbableObject).GetField("heldByPlayerOnServer");
MethodInfo method = typeof(GhostItemPatches).GetMethod("CheckGrab", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo method2 = typeof(GhostItemPatches).GetMethod("CheckOwnership", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.IsLdarga(list[i], (int?)null))
{
if (!CodeInstructionExtensions.IsStloc(list[i - 1], (LocalBuilder)null))
{
continue;
}
list[i - 3] = new CodeInstruction(OpCodes.Ldarg_0, (object)null)
{
labels = list[i - 3].labels,
blocks = list[i - 3].blocks
};
list[i - 2] = new CodeInstruction(OpCodes.Call, (object)method)
{
labels = list[i - 2].labels,
blocks = list[i - 2].blocks
};
list.Insert(i - 2, new CodeInstruction(OpCodes.Ldarg_1, (object)null)
{
blocks = list[i - 2].blocks
});
i++;
LobbyControl.Log.LogDebug((object)"Patched GrabObjectServerRpc 1!!");
}
if (CodeInstructionExtensions.LoadsField(list[i], field, false))
{
list[i - 1] = new CodeInstruction(OpCodes.Ldarg_0, (object)null)
{
labels = list[i - 1].labels,
blocks = list[i - 1].blocks
};
list[i] = new CodeInstruction(OpCodes.Call, (object)method2)
{
labels = list[i].labels,
blocks = list[i].blocks
};
LobbyControl.Log.LogDebug((object)"Patched GrabObjectServerRpc 2!!");
}
}
return list;
}
private static bool CheckOwnership(NetworkObject gNetworkObject, PlayerControllerB instance)
{
bool value = LobbyControl.PluginConfig.ItemSync.GhostItems.Value;
GrabbableObject componentInChildren = ((Component)gNetworkObject).GetComponentInChildren<GrabbableObject>();
if (componentInChildren.heldByPlayerOnServer)
{
if (value)
{
return (Object)(object)componentInChildren.playerHeldBy != (Object)(object)instance;
}
return true;
}
return false;
}
private static bool CheckGrab(PlayerControllerB controllerB, NetworkObjectReference currentlyGrabbing)
{
if (!LobbyControl.PluginConfig.ItemSync.GhostItems.Value)
{
return true;
}
NetworkObject val = default(NetworkObject);
if (ReservedItemSlotChecker.Enabled && ((NetworkObjectReference)(ref currentlyGrabbing)).TryGet(ref val, (NetworkManager)null))
{
GrabbableObject componentInChildren = ((Component)val).GetComponentInChildren<GrabbableObject>();
if ((Object)(object)componentInChildren != (Object)null && ReservedItemSlotChecker.HasEmptySlotForReservedItem(controllerB, componentInChildren))
{
LobbyControl.Log.LogDebug((object)("Attempted Grab for " + controllerB.playerUsername + ", was Reserved slot"));
return true;
}
}
int num = controllerB.FirstEmptyItemSlot();
bool flag = num < controllerB.ItemSlots.Length && num >= 0;
LobbyControl.Log.LogDebug((object)$"Attempted Grab for {controllerB.playerUsername}, slot {num}, max {controllerB.ItemSlots.Length}");
if (!flag)
{
LobbyControl.Log.LogError((object)("Grab invalidated for " + controllerB.playerUsername + " out of inventory space!" + (LobbyControl.PluginConfig.ItemSync.ForceDrop.Value ? "" : " ( use lobby dropall to fix )")));
HUDManager.Instance.AddTextToChatOnServer(controllerB.playerUsername + " is out of inventory space!", -1);
if (LobbyControl.PluginConfig.ItemSync.ForceDrop.Value)
{
controllerB.DropAllHeldItemsServerRpc();
}
}
else
{
LobbyControl.Log.LogInfo((object)("Grab validated for " + controllerB.playerUsername + "!"));
}
return flag;
}
}
[HarmonyPatch]
internal class ShotgunPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerControllerB), "DestroyItemInSlotServerRpc")]
private static bool CheckDestroy(PlayerControllerB __instance, int itemSlot)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
//IL_00d1: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015a: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: 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)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening)
{
return true;
}
if ((int)((NetworkBehaviour)__instance).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost))
{
return true;
}
if (!LobbyControl.PluginConfig.ItemSync.ShotGunReload.Value)
{
return true;
}
int num = -1;
int num2 = -1;
GrabbableObject[] itemSlots = __instance.ItemSlots;
foreach (GrabbableObject val in itemSlots)
{
num2++;
ShotgunItem val2 = (ShotgunItem)(object)((val is ShotgunItem) ? val : null);
if ((Object)(object)val2 != (Object)null && val2.isReloading)
{
num = val2.FindAmmoInInventory();
break;
}
}
if (num == -1 || num == itemSlot)
{
return true;
}
LobbyControl.Log.LogWarning((object)(__instance.playerUsername + " was found de-synced while reloading shotgun! attempting sync."));
if (!ReservedItemSlotChecker.Enabled || !ReservedItemSlotChecker.CheckIfReservedItemSlot(__instance, num2))
{
__instance.SwitchToItemSlot(num2, (GrabbableObject)null);
}
ClientRpcParams val3 = default(ClientRpcParams);
val3.Send = new ClientRpcSendParams
{
TargetClientIds = new ulong[1] { __instance.actualClientId }
};
ClientRpcParams val4 = val3;
FastBufferWriter val5 = ((NetworkBehaviour)__instance).__beginSendClientRpc(899109231u, val4, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val5, itemSlot);
((NetworkBehaviour)__instance).__endSendClientRpc(ref val5, 899109231u, val4, (RpcDelivery)0);
val3 = default(ClientRpcParams);
val3.Send = new ClientRpcSendParams
{
TargetClientIds = new ulong[1] { NetworkManager.Singleton.LocalClientId }
};
ClientRpcParams val6 = val3;
FastBufferWriter val7 = ((NetworkBehaviour)__instance).__beginSendClientRpc(899109231u, val6, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val7, num);
((NetworkBehaviour)__instance).__endSendClientRpc(ref val7, 899109231u, val6, (RpcDelivery)0);
return false;
}
}
[HarmonyPatch]
internal class GenericUsablePatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(GrabbableObject), "ActivateItemClientRpc")]
private static void CheckUse(GrabbableObject __instance)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening || (int)((NetworkBehaviour)__instance).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || ((NetworkBehaviour)__instance).IsOwner || !LobbyControl.PluginConfig.ItemSync.SyncOnUse.Value || LobbyControl.PluginConfig.ItemSync.SyncIgnoreName.Value.Split(',').Contains(__instance.itemProperties.itemName) || (Object)(object)__instance == (Object)(object)__instance.playerHeldBy.currentlyHeldObjectServer)
{
return;
}
int num = -1;
for (int i = 0; i < __instance.playerHeldBy.ItemSlots.Length; i++)
{
GrabbableObject val = __instance.playerHeldBy.ItemSlots[i];
if ((Object)(object)val == (Object)(object)__instance)
{
num = i;
break;
}
}
if (num != -1 && (!ReservedItemSlotChecker.Enabled || !ReservedItemSlotChecker.CheckIfReservedItemSlot(__instance.playerHeldBy, num)))
{
LobbyControl.Log.LogWarning((object)(__instance.playerHeldBy.playerUsername + " was found de-synced while using an item! attempting sync."));
__instance.playerHeldBy.SwitchToItemSlot(num, (GrabbableObject)null);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GrabbableObject), "InteractLeftRightClientRpc")]
private static void CheckInteract(GrabbableObject __instance)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Invalid comparison between Unknown and I4
NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager;
if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening || (int)((NetworkBehaviour)__instance).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost) || ((NetworkBehaviour)__instance).IsOwner || !LobbyControl.PluginConfig.ItemSync.SyncOnInteract.Value || LobbyControl.PluginConfig.ItemSync.SyncIgnoreName.Value.Split(',').Contains(__instance.itemProperties.itemName) || (Object)(object)__instance == (Object)(object)__instance.playerHeldBy.currentlyHeldObject)
{
return;
}
int num = -1;
for (int i = 0; i < __instance.playerHeldBy.ItemSlots.Length; i++)
{
GrabbableObject val = __instance.playerHeldBy.ItemSlots[i];
if ((Object)(object)val == (Object)(object)__instance)
{
num = i;
break;
}
}
if (num != -1 && (!ReservedItemSlotChecker.Enabled || !ReservedItemSlotChecker.CheckIfReservedItemSlot(__instance.playerHeldBy, num)))
{
LobbyControl.Log.LogWarning((object)(__instance.playerHeldBy.playerUsername + " was found de-synced while interacting with an item! attempting sync."));
__instance.playerHeldBy.SwitchToItemSlot(num, (GrabbableObject)null);
}
}
}
}
[HarmonyPatch]
internal class JoinPatches
{
private static readonly ConcurrentQueue<ConnectionApprovalResponse> ConnectionQueue = new ConcurrentQueue<ConnectionApprovalResponse>();
private static readonly object _lock = new object();
private static ulong? _currentConnectingPlayer = null;
private static ulong _currentConnectingExpiration = 0uL;
private static bool[] _currentConnectingPlayerConfirmations = new bool[2];
[HarmonyFinalizer]
[HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")]
[HarmonyPriority(10)]
private static Exception ThrottleApprovals(ConnectionApprovalRequest request, ConnectionApprovalResponse response, Exception __exception)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
if (__exception != null)
{
return __exception;
}
if (!response.Approved)
{
return null;
}
if (!LobbyControl.PluginConfig.JoinQueue.Enabled.Value)
{
return null;
}
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Player.Queue", $"Player Enqueued {Encoding.ASCII.GetString(request.Payload)} remaining:{ConnectionQueue.Count}");
}
response.Pending = true;
ConnectionQueue.Enqueue(response);
LobbyControl.Log.LogWarning((object)$"Connection request Enqueued! count:{ConnectionQueue.Count}");
return null;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(StartOfRound), "OnClientConnect")]
private static void OnClientConnect(StartOfRound __instance, ulong clientId)
{
lock (_lock)
{
if (((NetworkBehaviour)__instance).IsServer && LobbyControl.PluginConfig.JoinQueue.Enabled.Value)
{
_currentConnectingPlayerConfirmations = new bool[2];
_currentConnectingPlayer = clientId;
_currentConnectingExpiration = (ulong)(Environment.TickCount + LobbyControl.PluginConfig.JoinQueue.ConnectionTimeout.Value);
}
}
}
[HarmonyFinalizer]
[HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")]
private static void ResetForDc(StartOfRound __instance, int playerObjectNumber)
{
GameObject val = __instance.allPlayerObjects[playerObjectNumber];
PlayerControllerB val2 = __instance.allPlayerScripts[playerObjectNumber];
val.transform.parent = __instance.playersContainer;
val2.justConnected = true;
val2.isCameraDisabled = true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameNetworkManager), "Singleton_OnClientDisconnectCallback")]
private static void OnClientDisconnect(GameNetworkManager __instance, ulong clientId)
{
if (!__instance.isHostingGame)
{
return;
}
LobbyControl.Log.LogInfo((object)$"{clientId} disconnected");
lock (_lock)
{
if (_currentConnectingPlayer == clientId)
{
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Player.Queue", "Player Disconnected!");
}
_currentConnectingPlayer = null;
_currentConnectingExpiration = 0uL;
}
}
}
[HarmonyFinalizer]
[HarmonyPatch(typeof(StartOfRound), "__rpc_handler_682230258")]
private static void ClientConnectionCompleted1(NetworkBehaviour target, __RpcParams rpcParams)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0010: 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)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
StartOfRound val = (StartOfRound)target;
if (!((NetworkBehaviour)val).IsServer)
{
return;
}
ulong senderClientId = rpcParams.Server.Receive.SenderClientId;
lock (_lock)
{
if (_currentConnectingPlayer == senderClientId)
{
_currentConnectingPlayerConfirmations[0] = true;
if (_currentConnectingPlayerConfirmations[1] || GameNetworkManager.Instance.disableSteam)
{
LobbyControl.Log.LogWarning((object)$"{senderClientId} completed the connection");
_currentConnectingPlayer = null;
_currentConnectingExpiration = (ulong)(Environment.TickCount + LobbyControl.PluginConfig.JoinQueue.ConnectionDelay.Value);
}
else
{
LobbyControl.Log.LogWarning((object)$"{senderClientId} is waiting to synchronize the name");
}
}
}
}
[HarmonyFinalizer]
[HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_2504133785")]
private static void ClientConnectionCompleted2(NetworkBehaviour target, __RpcParams rpcParams)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_0010: 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)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB val = (PlayerControllerB)target;
if (!((NetworkBehaviour)val).IsServer)
{
return;
}
ulong senderClientId = rpcParams.Server.Receive.SenderClientId;
lock (_lock)
{
if (_currentConnectingPlayer == senderClientId)
{
_currentConnectingPlayerConfirmations[1] = true;
if (_currentConnectingPlayerConfirmations[0])
{
LobbyControl.Log.LogWarning((object)$"{senderClientId} completed the connection");
_currentConnectingPlayer = null;
_currentConnectingExpiration = (ulong)(Environment.TickCount + LobbyControl.PluginConfig.JoinQueue.ConnectionDelay.Value);
}
else
{
LobbyControl.Log.LogWarning((object)$"{senderClientId} is waiting to synchronize the held items");
}
}
}
}
[HarmonyFinalizer]
[HarmonyPatch(typeof(StartOfRound), "LateUpdate")]
private static void ProcessConnectionQueue()
{
if (!((NetworkBehaviour)StartOfRound.Instance).IsServer || !Monitor.TryEnter(_lock))
{
return;
}
try
{
ConnectionApprovalResponse result;
if (_currentConnectingPlayer.HasValue)
{
if ((ulong)Environment.TickCount < _currentConnectingExpiration)
{
return;
}
if (_currentConnectingPlayer.Value != 0L)
{
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Player.Queue", "Player Timeout!");
}
LobbyControl.Log.LogWarning((object)$"Connection to {_currentConnectingPlayer.Value} expired, Disconnecting!");
try
{
NetworkManager.Singleton.DisconnectClient(_currentConnectingPlayer.Value);
}
catch (Exception ex)
{
LobbyControl.Log.LogError((object)ex);
}
}
_currentConnectingPlayer = null;
_currentConnectingExpiration = 0uL;
}
else if ((ulong)Environment.TickCount >= _currentConnectingExpiration && ConnectionQueue.TryDequeue(out result))
{
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Player.Queue", $"Player Dequeued remaining:{ConnectionQueue.Count}");
}
LobbyControl.Log.LogWarning((object)$"Connection request Resumed! remaining: {ConnectionQueue.Count}");
result.Pending = false;
if (result.Approved)
{
_currentConnectingPlayerConfirmations = new bool[2];
_currentConnectingPlayer = 0uL;
_currentConnectingExpiration = (ulong)Environment.TickCount + 1000uL;
}
}
}
catch (Exception ex2)
{
LobbyControl.Log.LogError((object)ex2);
}
finally
{
Monitor.Exit(_lock);
}
}
[HarmonyFinalizer]
[HarmonyPatch(typeof(StartOfRound), "OnLocalDisconnect")]
private static void FlushConnectionQueue()
{
lock (_lock)
{
_currentConnectingPlayerConfirmations = new bool[2];
_currentConnectingPlayer = null;
_currentConnectingExpiration = 0uL;
if (ConnectionQueue.Count > 0)
{
LobbyControl.Log.LogWarning((object)$"Disconnecting with {ConnectionQueue.Count} pending connection, Flushing!");
}
ConnectionApprovalResponse result;
while (ConnectionQueue.TryDequeue(out result))
{
result.Reason = "Host has disconnected!";
result.Approved = false;
result.Pending = false;
}
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlayerControllerB), "SendNewPlayerValuesClientRpc")]
private static IEnumerable<CodeInstruction> FixRadarNames(IEnumerable<CodeInstruction> instructions)
{
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
//IL_0082: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
if (!LobbyControl.PluginConfig.SteamLobby.RadarFix.Value)
{
return instructions;
}
List<CodeInstruction> list = instructions.ToList();
FieldInfo field = typeof(TransformAndName).GetField("name");
MethodInfo method = typeof(JoinPatches).GetMethod("setNewName", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
for (int i = 0; i < list.Count; i++)
{
CodeInstruction val = list[i];
if (!CodeInstructionExtensions.StoresField(val, field))
{
continue;
}
for (int j = i - 6; j < i; j++)
{
CodeInstruction val2 = list[j];
if (!CodeInstructionExtensions.IsLdloc(val2, (LocalBuilder)null))
{
list[j] = new CodeInstruction(OpCodes.Nop, (object)null)
{
blocks = val2.blocks,
labels = val2.labels
};
}
}
list[i] = new CodeInstruction(OpCodes.Call, (object)method)
{
blocks = val.blocks,
labels = val.labels
};
LobbyControl.Log.LogDebug((object)"SendNewPlayerValuesClientRpc patched!");
}
return list;
}
private static void setNewName(int index, string name)
{
StartOfRound instance = StartOfRound.Instance;
GameObject val = instance.allPlayerObjects[index];
instance.mapScreen.ChangeNameOfTargetTransform(val.transform, name);
}
}
[HarmonyPatch]
internal class LimitPatcher
{
[HarmonyTranspiler]
[HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesClientRpc")]
private static IEnumerable<CodeInstruction> PacketSizePatch(IEnumerable<CodeInstruction> instructions)
{
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Expected O, but got Unknown
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Expected O, but got Unknown
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Expected O, but got Unknown
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Expected O, but got Unknown
if (!LobbyControl.PluginConfig.SaveLimit.Enabled.Value)
{
return instructions;
}
MethodInfo method = typeof(NetworkBehaviour).GetMethod("__beginSendClientRpc", BindingFlags.Instance | BindingFlags.NonPublic);
ConstructorInfo constructor = typeof(FastBufferWriter).GetConstructor(new Type[3]
{
typeof(int),
typeof(Allocator),
typeof(int)
});
List<CodeInstruction> list = new List<CodeInstruction>();
list.AddRange(instructions);
List<CodeInstruction> list2 = list;
for (int i = 0; i < list2.Count; i++)
{
CodeInstruction val = list2[i];
if (CodeInstructionExtensions.Calls(val, method))
{
CodeInstruction val2 = list2[i + 1];
list2.InsertRange(i + 1, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[5]
{
new CodeInstruction(OpCodes.Pop, (object)null)
{
blocks = val2.blocks
},
new CodeInstruction(OpCodes.Ldc_I4, (object)1024)
{
blocks = val2.blocks
},
new CodeInstruction(OpCodes.Ldc_I4_2, (object)null)
{
blocks = val2.blocks
},
new CodeInstruction(OpCodes.Ldc_I4, (object)int.MaxValue)
{
blocks = val2.blocks
},
new CodeInstruction(OpCodes.Newobj, (object)constructor)
{
blocks = val2.blocks
}
});
LobbyControl.Log.LogDebug((object)"Patched PacketSize!");
}
}
return list2;
}
[HarmonyTranspiler]
[HarmonyPriority(800)]
[HarmonyPatch(typeof(StartOfRound), "SyncShipUnlockablesServerRpc")]
private static IEnumerable<CodeInstruction> SyncUnlockablesPatch(IEnumerable<CodeInstruction> instructions)
{
if (!LobbyControl.PluginConfig.SaveLimit.Enabled.Value)
{
return instructions;
}
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
int num = -1;
for (int i = 0; i < list.Count; i++)
{
CodeInstruction val = list[i];
if (CodeInstructionExtensions.LoadsConstant(val, 250L))
{
num = i - 1;
}
else if (num != -1 && val.labels.Count != 0)
{
val.labels.AddRange(list[num].labels);
list.RemoveRange(num, i - 1 - num);
LobbyControl.Log.LogDebug((object)"Patched SyncShipUnlockablesServerRpc!!");
break;
}
}
return list;
}
[HarmonyTranspiler]
[HarmonyPriority(800)]
[HarmonyPatch(typeof(GameNetworkManager), "SaveItemsInShip")]
private static IEnumerable<CodeInstruction> SaveItemsInShipPatch(IEnumerable<CodeInstruction> instructions)
{
if (!LobbyControl.PluginConfig.SaveLimit.Enabled.Value)
{
return instructions;
}
FieldInfo field = typeof(StartOfRound).GetField("maxShipItemCapacity");
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
Label? label = default(Label?);
for (int i = 0; i < list.Count; i++)
{
CodeInstruction val = list[i];
if (CodeInstructionExtensions.LoadsField(val, field, false))
{
CodeInstruction val2 = list[i + 1];
if (CodeInstructionExtensions.Branches(val2, ref label))
{
List<Label> labels = list[i - 2].labels;
CodeInstruction val3 = list[i + 2];
val3.labels.AddRange(labels);
list.RemoveRange(i - 2, 4);
LobbyControl.Log.LogDebug((object)"Patched SaveItemsInShip!!");
break;
}
}
}
return list;
}
}
[HarmonyPatch]
internal class LobbyPatcher
{
private static readonly Dictionary<Lobby, LobbyType> Visibility = new Dictionary<Lobby, LobbyType>();
private static readonly Dictionary<Lobby, bool> Open = new Dictionary<Lobby, bool>();
[HarmonyPostfix]
[HarmonyPatch(typeof(Lobby), "SetJoinable")]
private static void TrackOpenStatus(Lobby __instance, object[] __args, bool __runOriginal)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (__runOriginal)
{
Open[__instance] = (bool)__args[0];
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Status", ((bool)__args[0]) ? "open" : "closed");
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Lobby), "SetPublic")]
private static void TrackPublicStatus(Lobby __instance, bool __runOriginal)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (__runOriginal)
{
Visibility[__instance] = (LobbyType)2;
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Visibility", "public");
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Lobby), "SetPrivate")]
private static void TrackPrivateStatus(Lobby __instance, bool __runOriginal)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (__runOriginal)
{
Visibility[__instance] = (LobbyType)0;
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Visibility", "private");
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Lobby), "SetFriendsOnly")]
private static void trackFriendsOnly(Lobby __instance, bool __runOriginal)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (__runOriginal)
{
Visibility[__instance] = (LobbyType)1;
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Visibility", "friends");
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Lobby), "SetData")]
private static void trackData(Lobby __instance, bool __runOriginal, string key, string value)
{
if (__runOriginal && key == "name" && AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Name", value);
}
}
public static LobbyType GetVisibility(Lobby lobby)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
if (!Visibility.ContainsKey(lobby))
{
return (LobbyType)0;
}
return Visibility[lobby];
}
public static bool IsOpen(Lobby lobby)
{
//IL_0005: 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)
if (Open.ContainsKey(lobby))
{
return GeneralExtensions.GetValueSafe<Lobby, bool>(Open, lobby);
}
return true;
}
}
[HarmonyPatch]
internal class LogSpamFix
{
[HarmonyPatch(typeof(EnemyAI))]
internal class EnemyAIPatch
{
[HarmonyPrefix]
[HarmonyPatch("SetDestinationToPosition")]
private static bool StopIfDead1(EnemyAI __instance)
{
if (!LobbyControl.PluginConfig.LogSpam.Enabled.Value || !LobbyControl.PluginConfig.LogSpam.CalculatePolygonPath.Value)
{
return true;
}
return !__instance.isEnemyDead;
}
[HarmonyPrefix]
[HarmonyPatch("DoAIInterval")]
private static void StopIfDead2(EnemyAI __instance)
{
if (LobbyControl.PluginConfig.LogSpam.Enabled.Value && LobbyControl.PluginConfig.LogSpam.CalculatePolygonPath.Value && __instance.isEnemyDead)
{
__instance.moveTowardsDestination = false;
}
}
[HarmonyPrefix]
[HarmonyPatch("PathIsIntersectedByLineOfSight")]
private static bool StopIfDead3(EnemyAI __instance)
{
if (!LobbyControl.PluginConfig.LogSpam.Enabled.Value || !LobbyControl.PluginConfig.LogSpam.CalculatePolygonPath.Value)
{
return true;
}
return !__instance.isEnemyDead;
}
}
[HarmonyPatch]
internal class AudioSpatializerPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(NetworkSceneManager), "OnSceneLoaded")]
private static void DisableSpatializers()
{
if (!LobbyControl.PluginConfig.LogSpam.AudioSpatializer.Value || !Utility.IsNullOrWhiteSpace(AudioSettings.GetSpatializerPluginName()))
{
return;
}
try
{
AudioSource[] array = Resources.FindObjectsOfTypeAll<AudioSource>();
AudioSource[] array2 = array;
foreach (AudioSource val in array2)
{
if (val.spatialize)
{
val.spatialize = false;
}
}
}
catch (Exception arg)
{
LobbyControl.Log.LogError((object)$"Exception disabling spatializers: {arg}");
}
}
}
}
[HarmonyPatch]
internal class NetworkPatcher
{
[HarmonyTranspiler]
[HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")]
private static IEnumerable<CodeInstruction> FixConnectionApprovalPrefix(IEnumerable<CodeInstruction> instructions)
{
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Expected O, but got Unknown
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_00e8: Expected O, but got Unknown
FieldInfo field = typeof(GameNetworkManager).GetField("gameHasStarted");
List<CodeInstruction> list = instructions.ToList();
Label? label = default(Label?);
for (int i = 0; i < list.Count; i++)
{
CodeInstruction val = list[i];
if (CodeInstructionExtensions.LoadsField(val, field, false))
{
CodeInstruction val2 = list[i + 1];
CodeInstruction val3 = list[i - 1];
if (CodeInstructionExtensions.Branches(val2, ref label))
{
list[i - 1] = new CodeInstruction(OpCodes.Nop, (object)null)
{
labels = val3.labels,
blocks = val3.blocks
};
list[i] = new CodeInstruction(OpCodes.Nop, (object)null)
{
labels = val.labels,
blocks = val.blocks
};
list[i + 1] = new CodeInstruction(OpCodes.Br, (object)label)
{
labels = val2.labels,
blocks = val2.blocks
};
LobbyControl.Log.LogDebug((object)"Patched ConnectionApproval!!");
break;
}
}
}
return list;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(GameNetworkManager), "ConnectionApproval")]
[HarmonyPriority(20)]
private static void FixConnectionApprovalPostFix(GameNetworkManager __instance, bool __runOriginal, ConnectionApprovalResponse response)
{
//IL_0035: 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)
if (__runOriginal && response.Approved)
{
if (__instance.gameHasStarted && response.Approved && __instance.currentLobby.HasValue && LobbyPatcher.IsOpen(__instance.currentLobby.Value))
{
LobbyControl.Log.LogDebug((object)"Approving incoming late connection.");
}
else if (!LobbyControl.CanModifyLobby)
{
LobbyControl.Log.LogDebug((object)"Late connection refused ( ship was landed ).");
response.Reason = "Ship has already landed!";
response.Approved = false;
}
else if (!__instance.disableSteam && (!__instance.currentLobby.HasValue || !LobbyPatcher.IsOpen(__instance.currentLobby.Value)))
{
LobbyControl.Log.LogDebug((object)"Late connection refused ( lobby was closed ).");
response.Reason = "Lobby has been closed!";
response.Approved = false;
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(QuickMenuManager), "InviteFriendsButton")]
private static void FixFriendInviteButton(bool __runOriginal)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (__runOriginal)
{
GameNetworkManager instance = GameNetworkManager.Instance;
if (GameNetworkManager.Instance.gameHasStarted && instance.currentLobby.HasValue && LobbyPatcher.IsOpen(instance.currentLobby.Value))
{
GameNetworkManager.Instance.InviteFriendsUI();
}
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameNetworkManager), "LeaveLobbyAtGameStart")]
private static bool PreventSteamLobbyLeaving(GameNetworkManager __instance)
{
LobbyControl.Log.LogDebug((object)"Preventing the closing of Steam lobby.");
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(StartOfRound), "StartGame")]
private static void CloseSteamLobby(StartOfRound __instance)
{
if (((NetworkBehaviour)__instance).IsServer && __instance.inShipPhase)
{
LobbyControl.Log.LogDebug((object)"Setting lobby to not joinable.");
LobbyControl.CanModifyLobby = false;
GameNetworkManager.Instance.SetLobbyJoinable(false);
Object.FindObjectOfType<QuickMenuManager>().inviteFriendsTextAlpha.alpha = 0f;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Start")]
private static void ResetStatus(StartOfRound __instance, bool __runOriginal)
{
if (__runOriginal)
{
LobbyControl.CanModifyLobby = true;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "EndOfGame")]
[HarmonyPriority(0)]
private static IEnumerator ReopenSteamLobby(IEnumerator coroutine, StartOfRound __instance, bool __runOriginal)
{
if (!__runOriginal)
{
yield break;
}
while (coroutine.MoveNext())
{
yield return coroutine.Current;
}
if (!((NetworkBehaviour)__instance).IsServer)
{
yield break;
}
yield return (object)new WaitForSeconds(0.5f);
yield return (object)new WaitUntil((Func<bool>)(() => !__instance.firingPlayersCutsceneRunning));
LobbyControl.Log.LogDebug((object)"Lobby can be re-opened");
LobbyControl.CanModifyLobby = true;
if (LobbyControl.PluginConfig.SteamLobby.AutoLobby.Value)
{
GameNetworkManager instance = GameNetworkManager.Instance;
if (instance.currentLobby.HasValue)
{
instance.SetLobbyJoinable(true);
Object.FindObjectOfType<QuickMenuManager>().inviteFriendsTextAlpha.alpha = 1f;
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "OnPlayerConnectedClientRpc")]
private static void ResetDcFlags(StartOfRound __instance, ulong clientId, int assignedPlayerObjectId)
{
PlayerControllerB val = __instance.allPlayerScripts[assignedPlayerObjectId];
val.disconnectedMidGame = false;
val.DisablePlayerModel(((Component)val).gameObject, true, true);
}
}
[HarmonyPatch]
internal class SavePatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(GameNetworkManager), "SaveGameValues")]
private static bool PreventSave(GameNetworkManager __instance)
{
if (LobbyControl.CanSave && __instance.isHostingGame)
{
ES3.Save<bool>("LC_SavingMethod", LobbyControl.AutoSaveEnabled, __instance.currentSaveFileName);
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Save", "Saving " + GameNetworkManager.Instance.currentSaveFileName);
}
}
return LobbyControl.CanSave;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(GameNetworkManager), "ResetSavedGameValues")]
private static bool PreventSaveFileReset(GameNetworkManager __instance)
{
return LobbyControl.CanSave;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Start")]
private static void ReadCustomLobbyStatus(StartOfRound __instance, bool __runOriginal)
{
if (__runOriginal && ((NetworkBehaviour)__instance).IsServer)
{
LobbyControl.AutoSaveEnabled = (LobbyControl.CanSave = ES3.Load<bool>("LC_SavingMethod", GameNetworkManager.Instance.currentSaveFileName, true));
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("LobbyControl", "Lobby.Autosave", LobbyControl.CanSave.ToString());
}
}
}
}
[HarmonyPatch]
internal class TerminalPatch
{
private const string COMMAND = "\n\n>LOBBY [command] (lobby name)\ntype lobby help for more info.\n\n";
[HarmonyPatch(typeof(Terminal), "Start")]
[HarmonyPrefix]
private static void StartPatch(ref TerminalNodesList ___terminalNodes)
{
OverrideTerminalNodes(___terminalNodes);
}
private static void OverrideTerminalNodes(TerminalNodesList terminalNodes)
{
OverrideHelpTerminalNode(terminalNodes);
}
private static void OverrideHelpTerminalNode(TerminalNodesList terminalNodes)
{
TerminalNode val = null;
TerminalKeyword[] allKeywords = terminalNodes.allKeywords;
foreach (TerminalKeyword val2 in allKeywords)
{
if (val2.word == "other")
{
val = val2.specialKeywordResult;
}
}
if (val != null)
{
string displayText = val.displayText;
string text = displayText.Replace("\n\n>LOBBY [command] (lobby name)\ntype lobby help for more info.\n\n", "").Trim();
text = ((!GameNetworkManager.Instance.isHostingGame) ? (text + "\n\n") : (text + "\n\n>LOBBY [command] (lobby name)\ntype lobby help for more info.\n\n"));
val.displayText = text;
}
}
[HarmonyPatch(typeof(Terminal), "ParsePlayerSentence")]
[HarmonyPrefix]
private static bool ParsePlayerSentencePatch(ref Terminal __instance, ref TerminalNode __result, bool __runOriginal)
{
if (!__runOriginal)
{
return false;
}
string[] array = __instance.screenText.text.Substring(__instance.screenText.text.Length - __instance.textAdded).Split(' ');
if (CommandManager.TryExecuteCommand(array, out var terminalNode))
{
if ((Object)(object)terminalNode == (Object)null)
{
__result = CreateTerminalNode("Error: terminalNode is null!\n\n");
return false;
}
__result = terminalNode;
return false;
}
return true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Terminal), "QuitTerminal")]
private static void QuitTerminalPatch()
{
CommandManager.OnTerminalQuit();
}
[HarmonyPatch(typeof(StartOfRound), "OnLocalDisconnect")]
[HarmonyPrefix]
private static void OnLocalDisconnectPatch()
{
CommandManager.OnLocalDisconnect();
}
internal static TerminalNode CreateTerminalNode(string message, bool clearPreviousText = true)
{
TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
val.displayText = message;
val.clearPreviousText = clearPreviousText;
val.maxCharactersToType = 50;
return val;
}
}
[HarmonyPatch]
internal class TransparentPlayerFix
{
private static readonly HashSet<int> ToRespawn = new HashSet<int>();
[HarmonyPrefix]
[HarmonyPatch(typeof(StartOfRound), "OnPlayerDC")]
[HarmonyPriority(800)]
private static void OnPlayerDCPatch(StartOfRound __instance, int playerObjectNumber, ulong clientId)
{
if (!LobbyControl.PluginConfig.InvisiblePlayer.Enabled.Value)
{
return;
}
PlayerControllerB val = __instance.allPlayerScripts[playerObjectNumber];
if (val.isPlayerDead)
{
LobbyControl.Log.LogWarning((object)("Player " + val.playerUsername + " disconnected while Dead!"));
if (((NetworkBehaviour)__instance).IsServer)
{
LobbyControl.Log.LogInfo((object)("Player " + val.playerUsername + " added to the list of Respawnables"));
ToRespawn.Add(playerObjectNumber);
}
LobbyControl.Log.LogDebug((object)("Model of player " + val.playerUsername + " has been re-enabled"));
val.DisablePlayerModel(((Component)val).gameObject, true, true);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(StartOfRound), "OnLocalDisconnect")]
private static void PreventDc()
{
ToRespawn.Clear();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(PlayerControllerB), "__rpc_handler_2504133785")]
private static void RespawnDcPlayer(NetworkBehaviour target, __RpcParams rpcParams)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
PlayerControllerB val = (PlayerControllerB)(object)((target is PlayerControllerB) ? target : null);
if (!LobbyControl.PluginConfig.InvisiblePlayer.Enabled.Value)
{
return;
}
ulong senderClientId = rpcParams.Server.Receive.SenderClientId;
StartOfRound instance = StartOfRound.Instance;
int num = instance.ClientPlayerList[senderClientId];
if (((NetworkBehaviour)val).IsServer && ToRespawn.Contains(num))
{
ToRespawn.Remove(num);
try
{
List<ulong> list = instance.ClientPlayerList.Keys.ToList();
list.Remove(senderClientId);
list.Remove(NetworkManager.Singleton.LocalClientId);
ClientRpcParams val2 = default(ClientRpcParams);
val2.Send = new ClientRpcSendParams
{
TargetClientIds = list
};
ClientRpcParams val3 = val2;
FastBufferWriter val4 = ((NetworkBehaviour)val).__beginSendClientRpc(168339603u, val3, (RpcDelivery)0);
BytePacker.WriteValueBitPacked(val4, num);
bool flag = false;
((FastBufferWriter)(ref val4)).WriteValueSafe<bool>(ref flag, default(ForPrimitives));
Vector3 zero = Vector3.zero;
((FastBufferWriter)(ref val4)).WriteValueSafe(ref zero);
BytePacker.WriteValueBitPacked(val4, 12);
BytePacker.WriteValueBitPacked(val4, 0);
((NetworkBehaviour)val).__endSendClientRpc(ref val4, 168339603u, val3, (RpcDelivery)0);
LobbyControl.Log.LogInfo((object)("Player " + val.playerUsername + " has been killed by host"));
val4 = ((NetworkBehaviour)instance).__beginSendClientRpc(1279156295u, val3, (RpcDelivery)0);
((NetworkBehaviour)instance).__endSendClientRpc(ref val4, 1279156295u, val3, (RpcDelivery)0);
LobbyControl.Log.LogInfo((object)("Player " + val.playerUsername + " has been revived on other clients"));
}
catch (Exception arg)
{
LobbyControl.Log.LogError((object)$"Exception while respawning dead players {arg}");
}
ToRespawn.Clear();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(StartOfRound), "Awake")]
private static void ClearOnBoot(StartOfRound __instance)
{
if (((NetworkBehaviour)__instance).IsServer)
{
ToRespawn.Clear();
}
}
}
}
namespace LobbyControl.Dependency
{
public static class AsyncLoggerProxy
{
private static bool? _enabled;
public static bool Enabled
{
get
{
if (_enabled.HasValue)
{
return _enabled.Value;
}
try
{
_enabled = isDbEnabled();
}
catch (Exception)
{
_enabled = false;
return false;
}
return _enabled.Value;
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void WriteEvent(string source, string tag, string data, DateTime? timestamp = null)
{
SqliteLogger.WriteEvent(source, tag, data, timestamp);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void WriteData(string source, string tag, string data, DateTime? timestamp = null)
{
SqliteLogger.WriteData(source, tag, data, timestamp);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static bool isDbEnabled()
{
return SqliteLogger.Enabled;
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static int getExecutionID()
{
return SqliteLogger.ExecutionId;
}
}
public static class LobbyCompatibilityChecker
{
public static bool Enabled => Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility");
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void Init(string GUID, Version version, int Level, int strictness)
{
PluginHelper.RegisterPlugin(GUID, version, (CompatibilityLevel)Level, (VersionStrictness)strictness);
}
}
public static class ReservedItemSlotChecker
{
public static bool Enabled => Chainloader.PluginInfos.ContainsKey("FlipMods.ReservedItemSlotCore");
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static bool CheckIfReservedItemSlot(PlayerControllerB playerController, int itemSlotIndex)
{
if (ReservedPlayerData.allPlayerData.TryGetValue(playerController, out var value))
{
return value.IsReservedItemSlot(itemSlotIndex);
}
return false;
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static bool HasEmptySlotForReservedItem(PlayerControllerB playerController, GrabbableObject grabbableObject)
{
if (ReservedPlayerData.allPlayerData.TryGetValue(playerController, out var value))
{
return value.GetFirstEmptySlotForReservedItem(grabbableObject.itemProperties.itemName) != null;
}
return false;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}