Decompiled source of MorePlayers v1.0.0

MorePlayers.dll

Decompiled 11 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AvocadoShark;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MorePlayers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MorePlayers")]
[assembly: AssemblyTitle("MorePlayers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MorePlayers;

[BepInPlugin("com.moreplayers.roadsideresearch", "MorePlayers", "1.0.0")]
public class Plugin : BasePlugin
{
	public const string GUID = "com.moreplayers.roadsideresearch";

	public const string Name = "MorePlayers";

	public const string Version = "1.0.0";

	internal static ManualLogSource Log;

	internal static ConfigEntry<int> MaxPlayerCount;

	public override void Load()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Expected O, but got Unknown
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BasePlugin)this).Log;
		MaxPlayerCount = ((BasePlugin)this).Config.Bind<int>("General", "MaxPlayers", 8, new ConfigDescription("Maximum number of players allowed in a session (game default is 4)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 200), Array.Empty<object>()));
		ManualLogSource log = Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(39, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("MorePlayers loaded! Max players set to ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(MaxPlayerCount.Value);
		}
		log.LogInfo(val);
		Harmony val2 = new Harmony("com.moreplayers.roadsideresearch");
		val2.PatchAll(typeof(FusionConnectionPatch));
		val2.PatchAll(typeof(MenuCanvasPatch));
		Log.LogInfo((object)"Harmony patches applied");
	}
}
[HarmonyPatch]
public static class FusionConnectionPatch
{
	[HarmonyPatch(typeof(FusionConnection), "Awake")]
	[HarmonyPostfix]
	public static void AwakePostfix(FusionConnection __instance)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		int num = (__instance.MaxPlayers = Plugin.MaxPlayerCount.Value);
		ManualLogSource log = Plugin.Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 1, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral("FusionConnection.MaxPlayers overridden to ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
		}
		log.LogInfo(val);
	}
}
[HarmonyPatch]
public static class MenuCanvasPatch
{
	[HarmonyPatch(typeof(MenuCanvas), "Awake")]
	[HarmonyPostfix]
	public static void AwakePostfix(MenuCanvas __instance)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Expected O, but got Unknown
		Slider slider = __instance.slider;
		if ((Object)(object)slider != (Object)null)
		{
			int value = Plugin.MaxPlayerCount.Value;
			slider.maxValue = value;
			ManualLogSource log = Plugin.Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("MenuCanvas slider max value set to ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(value);
			}
			log.LogInfo(val);
		}
	}
}