using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PlayerLimitLift.patches;
using PurrNet;
using PurrNet.Packing;
using TMPro;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("officerballs.PlayerLimitLift")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4")]
[assembly: AssemblyProduct("officerballs.PlayerLimitLift")]
[assembly: AssemblyTitle("officerballs.PlayerLimitLift")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.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 PlayerLimitLift
{
[BepInPlugin("officerballs.PlayerLimitLift", "Player Limit Lift", "1.0.4.0")]
public class Plugin : BaseUnityPlugin
{
public const string modGUID = "officerballs.PlayerLimitLift";
public const string modName = "Player Limit Lift";
public const string modVersion = "1.0.4.0";
private Harmony harmony = new Harmony("officerballs.PlayerLimitLift");
public ManualLogSource mls = Logger.CreateLogSource("officerballs.PlayerLimitLift");
private void Awake()
{
mls.LogInfo((object)"Player Limit Lifted to 128.");
harmony.PatchAll(typeof(PlayerLimitPatch));
harmony.PatchAll(typeof(ServerNameModder));
harmony.PatchAll(typeof(TextChannelManagerPatch));
}
}
}
namespace PlayerLimitLift.patches
{
[HarmonyPatch(typeof(MainMenuUIController))]
public class PlayerLimitPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void AwakePatch(ref TextMeshProUGUI ____filterPlayerText)
{
MonoSingleton<MultiplayerManager>.I.FilterPlayerValue = 128;
((TMP_Text)____filterPlayerText).text = "128";
}
[HarmonyPatch("ButtonChangeFilterPlayer")]
[HarmonyPrefix]
public static bool Button1Patch(int value, MainMenuUIController __instance, ref TextMeshProUGUI ____filterPlayerText)
{
int filterPlayerValue = MonoSingleton<MultiplayerManager>.I.FilterPlayerValue;
filterPlayerValue = ((value == 1) ? ((filterPlayerValue - 1 + 1) % 128 + 1) : ((filterPlayerValue != 1) ? (filterPlayerValue - 1) : 128));
MonoSingleton<MultiplayerManager>.I.FilterPlayerValue = filterPlayerValue;
((TMP_Text)____filterPlayerText).text = filterPlayerValue.ToString();
return false;
}
[HarmonyPatch("ButtonChangeFilterListPlayer")]
[HarmonyPrefix]
public static bool Button2Patch(int value, MainMenuUIController __instance, ref TextMeshProUGUI ____filterListPlayerText)
{
int filterListPlayerValue = MonoSingleton<MultiplayerManager>.I.FilterListPlayerValue;
filterListPlayerValue = ((value == 1) ? ((filterListPlayerValue + 1) % 128) : ((filterListPlayerValue != 0) ? (filterListPlayerValue - 1) : 128));
MonoSingleton<MultiplayerManager>.I.FilterListPlayerValue = filterListPlayerValue;
((TMP_Text)____filterListPlayerText).text = ((filterListPlayerValue == 0) ? MonoSingleton<SettingsController>.I.AllString.String : filterListPlayerValue.ToString());
return false;
}
}
[HarmonyPatch(typeof(MultiplayerManager))]
public class ServerNameModder
{
[HarmonyPatch("CreateLobby")]
[HarmonyPrefix]
public static void NameChanger()
{
int filterPlayerValue = MonoSingleton<MultiplayerManager>.I.FilterPlayerValue;
string text = MonoSingleton<MainMenuUIController>.I.CreateSessionNameInputField.text;
if (filterPlayerValue > 16)
{
MonoSingleton<MainMenuUIController>.I.CreateSessionNameInputField.text = "[MODDED] " + text;
}
}
}
public static class SSS
{
public static T GetMethodWithoutOverrides<T>(this MethodInfo method, object callFrom) where T : Delegate
{
IntPtr functionPointer = method.MethodHandle.GetFunctionPointer();
return (T)Activator.CreateInstance(typeof(T), callFrom, functionPointer);
}
}
[HarmonyPatch(typeof(TextChannelManager))]
public class TextChannelManagerPatch
{
[HarmonyPatch(typeof(TextChannelManager), "SendMessageAsync_Original_0")]
[HarmonyPrefix]
public static bool SendMessagePatcher(TextChannelManager __instance, ref byte[] textBytes, ref byte[] userName, ref bool isLocal, ref Vector3 pos, ref string playerID, ref RPCInfo info, ref string ____playerId)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
string @string = Encoding.Unicode.GetString(textBytes);
string string2 = Encoding.Unicode.GetString(userName);
int num = 0;
PlayerPanelController i = NetworkSingleton<PlayerPanelController>.I;
for (int j = 0; j < i.PlayerIDs.Count; j++)
{
if (info.sender == i.PlayerIDs[j])
{
num = j;
break;
}
}
if (num > 15)
{
num = 15;
}
PlayerID sender = info.sender;
PlayerID? localPlayer = ((NetworkIdentity)__instance).localPlayer;
if (!localPlayer.HasValue || !(sender == localPlayer.GetValueOrDefault()))
{
MethodInfo methodInfo = AccessTools.Method(typeof(TextChannelManager), "OnChannelMessageReceived", (Type[])null, (Type[])null);
methodInfo.Invoke(__instance, new object[6] { string2, @string, pos, isLocal, num, playerID });
return false;
}
if (playerID != ____playerId)
{
MethodInfo methodInfo2 = AccessTools.Method(typeof(TextChannelManager), "AddMessageUI", (Type[])null, (Type[])null);
methodInfo2.Invoke(__instance, new object[4] { string2, @string, isLocal, num });
int num2 = -1;
for (int k = 0; k < i.PlayerSteamIDs.Count; k++)
{
if (i.PlayerSteamIDs[k] == playerID)
{
num2 = k;
break;
}
}
if (num2 != -1 && num2 < i.PlayerTransforms.Count)
{
NetworkTransform val = i.PlayerTransforms[num2];
if ((Object)(object)val != (Object)null)
{
TextBubbleController componentInChildren = ((Component)val).GetComponentInChildren<TextBubbleController>();
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.ShowTextBubble(textBytes, isLocal, pos, playerID);
}
}
}
return false;
}
MethodInfo methodInfo3 = AccessTools.Method(typeof(TextChannelManager), "AddMessageUI", (Type[])null, (Type[])null);
methodInfo3.Invoke(__instance, new object[4] { string2, @string, isLocal, num });
__instance.MainTextBubble.ShowTextBubble(textBytes, isLocal, pos, playerID);
return false;
}
[HarmonyPatch(typeof(TextChannelManager), "OnReceivedRpc")]
[HarmonyPrefix]
public static bool RPCInterceptPatcher(ref int id, ref RPCInfo info, ref RPCPacket packet, ref BitPacker stream, ref bool asServer, TextChannelManager __instance)
{
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//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_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
if ((id == 0) & asServer)
{
int num = -1;
List<PlayerID> playerIDs = NetworkSingleton<PlayerPanelController>.I.PlayerIDs;
for (int i = 0; i < playerIDs.Count; i++)
{
if (info.sender == playerIDs[i])
{
num = i;
break;
}
}
if (num > 15)
{
byte[] array = null;
Packer<byte[]>.Read(stream, ref array);
byte[] array2 = null;
Packer<byte[]>.Read(stream, ref array2);
bool flag = false;
Packer<bool>.Read(stream, ref flag);
Vector3 zero = Vector3.zero;
Packer<Vector3>.Read(stream, ref zero);
string text = null;
Packer<string>.Read(stream, ref text);
__instance.SendMessageAsync(array, array2, flag, zero, text, default(RPCInfo));
return false;
}
}
if (id == 0)
{
__instance.HandleRPCGenerated_0(stream, packet, info, asServer);
return false;
}
MethodInfo method = AccessTools.DeclaredMethod(typeof(TextChannelManager), "OnReceivedRpc", (Type[])null, (Type[])null);
method.GetMethodWithoutOverrides<Action<int, BitPacker, RPCPacket, RPCInfo, bool>>(__instance)(id, stream, packet, info, asServer);
return false;
}
}
}