Decompiled source of MorePlayers v1.0.2

MorePlayers.dll

Decompiled 4 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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: AssemblyCompany("MorePlayers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Unlocks the player limit beyond 6 for both private and public lobbies (up to 20).")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+ff50a90f475332b15b011f1a64b8c532872e3f2b")]
[assembly: AssemblyProduct("MorePlayers")]
[assembly: AssemblyTitle("MorePlayers")]
[assembly: AssemblyVersion("1.0.2.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 MorePlayers
{
	[BepInPlugin("semimodder-moreplayers", "More Players", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ConfigEntry<int> CfgMaxPlayers;

		private const int PHOTON_HARD_CAP = 20;

		private void Awake()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			CfgMaxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxPlayers", 10, "Maximum number of players allowed in a lobby (2–20). Only the HOST needs this mod. Restart required after changing.");
			int num = Mathf.Clamp(CfgMaxPlayers.Value, 2, 20);
			if (num != CfgMaxPlayers.Value)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)$"[MorePlayers] MaxPlayers clamped to {num} (valid range 2-{20}).");
				CfgMaxPlayers.Value = num;
			}
			new Harmony("semimodder-moreplayers").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[MorePlayers] Loaded! Max players set to {CfgMaxPlayers.Value}.");
		}
	}
	[HarmonyPatch(typeof(GameManager), "Awake")]
	public static class GameManager_Awake_Patch
	{
		public static void Postfix(GameManager __instance)
		{
			int num = (__instance.maxPlayers = (__instance.maxPlayersPhoton = Plugin.CfgMaxPlayers.Value));
			__instance.matchmakingMaxPlayers = false;
			Debug.Log((object)$"[MorePlayers] GameManager overridden → maxPlayers={num}");
		}
	}
	[HarmonyPatch(typeof(GameManager), "SetMaxPlayers")]
	public static class GameManager_SetMaxPlayers_Patch
	{
		public static void Prefix(ref int _target)
		{
			int value = Plugin.CfgMaxPlayers.Value;
			if (_target < value)
			{
				_target = value;
			}
		}
	}
}