Decompiled source of Bigger Walk v0.2.2

Bigger_Walk.dll

Decompiled 5 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Bigger_Walk")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6cef217c5352de403ecfa7abb899fbdebadd1960")]
[assembly: AssemblyProduct("Bigger Walk")]
[assembly: AssemblyTitle("Bigger_Walk")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 Bigger_Walk
{
	public static class HouseNetworkManagerPatch
	{
		public static void OnStartServerPrefix(HouseNetworkManager __instance)
		{
			Plugin.Log.LogInfo((object)"HouseNetworkManager.OnStartServer");
			ApplyMaxConnections((NetworkManager)(object)__instance);
		}

		public static void OnStartHostPrefix(HouseNetworkManager __instance)
		{
			Plugin.Log.LogInfo((object)"HouseNetworkManager.OnStartHost");
			ApplyMaxConnections((NetworkManager)(object)__instance);
		}

		public static void CreateHostEosLobbyAsyncPrefix(HouseNetworkManager __instance)
		{
			Plugin.Log.LogInfo((object)"HouseNetworkManager.CreateHostEosLobbyAsync");
			ApplyMaxConnections((NetworkManager)(object)__instance);
		}

		public static void ApplyMaxConnections(NetworkManager networkManager)
		{
			if ((Object)(object)networkManager == (Object)null)
			{
				Plugin.Log.LogInfo((object)"Could not set max connections");
				return;
			}
			int maxConnections = networkManager.maxConnections;
			networkManager.maxConnections = Plugin.MaxConnections.Value;
			Plugin.Log.LogInfo((object)("Set maxConnections " + maxConnections + " to " + networkManager.maxConnections));
		}
	}
	[BepInPlugin("Bigger_Walk", "Bigger Walk", "1.0.0")]
	public class Plugin : BasePlugin
	{
		internal static ManualLogSource Log;

		private Harmony harmony;

		internal static ConfigEntry<int> MaxConnections;

		public override void Load()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			MaxConnections = ((BasePlugin)this).Config.Bind<int>("General", "MaxPlayerCount", 40, "Maximum number of players allowed in the lobby.");
			harmony = new Harmony("Bigger_Walk");
			HarmonyPatches();
			Log.LogInfo((object)"Bigger Walk Loaded");
		}

		private void HarmonyPatches()
		{
			TryPatch(AccessTools.Method(typeof(HouseNetworkManager), "OnStartServer", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeof(HouseNetworkManagerPatch), "OnStartServerPrefix", (Type[])null, (Type[])null), null, "HouseNetworkManager.OnStartServer");
			TryPatch(AccessTools.Method(typeof(HouseNetworkManager), "OnStartHost", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeof(HouseNetworkManagerPatch), "OnStartHostPrefix", (Type[])null, (Type[])null), null, "HouseNetworkManager.OnStartHost");
			TryPatch(AccessTools.Method(typeof(HouseNetworkManager), "CreateHostEosLobbyAsync", Type.EmptyTypes, (Type[])null), AccessTools.Method(typeof(HouseNetworkManagerPatch), "CreateHostEosLobbyAsyncPrefix", (Type[])null, (Type[])null), null, "HouseNetworkManager.CreateHostEosLobbyAsync");
		}

		private void TryPatch(MethodInfo original, MethodInfo prefix, MethodInfo postfix, string patchName)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (original == null)
			{
				Log.LogError((object)("Failed to find patch target: " + patchName));
				return;
			}
			try
			{
				harmony.Patch((MethodBase)original, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(prefix), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(postfix), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Patches patchInfo = Harmony.GetPatchInfo((MethodBase)original);
				int valueOrDefault = (patchInfo?.Prefixes?.Count).GetValueOrDefault();
				int valueOrDefault2 = (patchInfo?.Postfixes?.Count).GetValueOrDefault();
				Log.LogInfo((object)("Installed patch for " + patchName + " prefixes=" + valueOrDefault + " postfixes=" + valueOrDefault2));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Failed to apply the patch for " + patchName + ": " + ex));
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Bigger_Walk";

		public const string PLUGIN_NAME = "Bigger Walk";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}