Decompiled source of MorePlayersV80 v1.0.1

MorePlayersV80.dll

Decompiled 2 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MorePlayersV80")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MorePlayersV80")]
[assembly: AssemblyTitle("MorePlayersV80")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 MorePlayersV80
{
	[BepInPlugin("fr.moreplayersv80.lethalcompany", "MorePlayersV80", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ConfigEntry<int> MaxPlayers;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			MaxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxPlayers", 16, "Nombre maximum de joueurs dans le lobby.");
			_harmony = new Harmony("fr.moreplayersv80.lethalcompany");
			_harmony.PatchAll(typeof(LobbyCreatedPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"MorePlayersV80 chargé ! MaxPlayers = {MaxPlayers.Value}");
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyCreated")]
	public static class LobbyCreatedPatch
	{
		[HarmonyPostfix]
		private static void Postfix(object result, object lobby)
		{
			try
			{
				if (lobby == null)
				{
					Plugin.Log.LogWarning((object)"[PATCH] Lobby null");
					return;
				}
				Type type = lobby.GetType();
				MethodInfo method = type.GetMethod("set_MaxMembers");
				if (method != null)
				{
					method.Invoke(lobby, new object[1] { Plugin.MaxPlayers.Value });
					Plugin.Log.LogInfo((object)$"[SUCCESS] Lobby MaxMembers définie à {Plugin.MaxPlayers.Value}");
				}
				else
				{
					Plugin.Log.LogWarning((object)"[PATCH] set_MaxMembers introuvable");
				}
				MethodInfo method2 = type.GetMethod("SetJoinable");
				if (method2 != null)
				{
					method2.Invoke(lobby, new object[1] { true });
					Plugin.Log.LogInfo((object)"[PATCH] SetJoinable(true)");
				}
				else
				{
					Plugin.Log.LogWarning((object)"[PATCH] SetJoinable introuvable");
				}
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"[PATCH] Erreur : {arg}");
			}
		}
	}
	internal static class PluginInfo
	{
		public const string PLUGIN_GUID = "fr.moreplayersv80.lethalcompany";

		public const string PLUGIN_NAME = "MorePlayersV80";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}