Decompiled source of BigLobbyMod v2.3.0

BigMonoLobby.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using UnityEngine;
using UnityEngine.UI;

[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.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("BigMonoLobby")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.1.2.0")]
[assembly: AssemblyInformationalVersion("2.1.2")]
[assembly: AssemblyProduct("Bigger Lobby Mod")]
[assembly: AssemblyTitle("BigMonoLobby")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.2.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 BigMonoLobby
{
	[BepInPlugin("BigMonoLobby", "Bigger Lobby Mod", "2.1.2")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch]
		public static class LobbyPatch
		{
			private static MethodBase TargetMethod()
			{
				return AccessTools.Method("Online:CreateLobby", (Type[])null, (Type[])null);
			}

			private static void Prefix(ref int maxPlayers)
			{
				maxPlayers = MaxPlayers.Value;
			}
		}

		[HarmonyPatch]
		public static class LobbyPatchSetMaxLobbyPlayers
		{
			private static MethodBase TargetMethod()
			{
				return AccessTools.Method("Online:SetMaxLobbyPlayers", (Type[])null, (Type[])null);
			}

			private static void Prefix(ref int count)
			{
				count = MaxPlayers.Value;
			}
		}

		[HarmonyPatch]
		public static class Patch_CreateLobby
		{
			private static MethodBase TargetMethod()
			{
				return AccessTools.Method(typeof(SteamMatchmaking), "CreateLobbyAsync", new Type[1] { typeof(int) }, (Type[])null);
			}

			private static void Prefix([HarmonyArgument(0)] ref int maxMembers)
			{
				Logger.LogInfo((object)$"Overriding MaxPlayers: {maxMembers} → {MaxPlayers.Value}");
				maxMembers = MaxPlayers.Value;
			}
		}

		[HarmonyPatch(typeof(GameManager), "IsJoinable")]
		public static class JoinablePatch
		{
			private static bool Prefix(ref JoinResult __result)
			{
				if (AllowPermaJoin.Value)
				{
					__result = (JoinResult)0;
					Logger.LogInfo((object)"GameManager.JoinResult.IsJoinable");
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Mission), "GetMaxPlayers")]
		public static class Patch_GetMaxPlayers
		{
			private static bool Prefix(ref int __result)
			{
				__result = MaxPlayers.Value;
				return false;
			}
		}

		[HarmonyPatch(typeof(GameManager), "Start")]
		public static class Patch_GameManager_Start
		{
			private static void Postfix()
			{
				if (GameManager.players != null && GameManager.players.Capacity != MaxPlayers.Value)
				{
					GameManager.players.Capacity = MaxPlayers.Value;
				}
			}
		}

		[HarmonyPatch(typeof(StartMenu), "Start")]
		public static class Patch_StartMenu_Start
		{
			private static void Postfix(StartMenu __instance)
			{
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Expected O, but got Unknown
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_0162: Unknown result type (might be due to invalid IL or missing references)
				//IL_016e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Expected O, but got Unknown
				if ((Object)(object)lg == (Object)null)
				{
					LoadEmbeddedAssetBundle();
				}
				if ((Object)(object)__instance == (Object)null)
				{
					return;
				}
				Transform transform = ((Component)__instance).transform;
				Transform val = null;
				foreach (Transform item in transform)
				{
					Transform val2 = item;
					if (((Object)val2).name == "Mycopunk")
					{
						val = val2;
						break;
					}
					foreach (Transform item2 in val2)
					{
						Transform val3 = item2;
						if (((Object)val3).name == "Mycopunk")
						{
							val = val3;
							break;
						}
					}
					if ((Object)(object)val != (Object)null)
					{
						break;
					}
				}
				if (!((Object)(object)val == (Object)null))
				{
					Transform val4 = Object.Instantiate<Transform>(val, val);
					if (val4.childCount > 0)
					{
						((Component)val4.GetChild(0)).gameObject.SetActive(false);
					}
					val4.localPosition = new Vector3(686.1016f, -258.7273f, 0f);
					val4.localRotation = Quaternion.Euler(0f, 0f, 7.0052f);
					val4.localScale = Vector3.one * 0.225f;
					Image componentInChildren = ((Component)val4).GetComponentInChildren<Image>(true);
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.sprite = lg;
					}
				}
			}
		}

		internal static ManualLogSource Logger;

		public static ConfigEntry<int> MaxPlayers;

		public static ConfigEntry<bool> AllowPermaJoin;

		public static ConfigEntry<string> LobbyName;

		public static AssetBundle assets;

		public static Sprite lg;

		public void Awake()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin BigMonoLobby is loaded!");
			MaxPlayers = ((BaseUnityPlugin)this).Config.Bind<int>("BigLobbyMod", "MaxPlayers", 32, "Maximum number of players allowed in a lobby");
			AllowPermaJoin = ((BaseUnityPlugin)this).Config.Bind<bool>("BigLobbyMod", "AllowPermaJoin", false, "Make the lobby always joinable");
			Logger.LogInfo((object)$"Config loaded. MaxPlayers = {MaxPlayers.Value}");
			Harmony val = new Harmony("com.catalyss.biglobby");
			val.PatchAll();
		}

		public static void LoadEmbeddedAssetBundle()
		{
			Logger.LogInfo((object)"Loading embedded AssetBundle...");
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string name) => name.EndsWith("biglobby"));
			if (text == null)
			{
				Logger.LogError((object)"Embedded resource 'biglobby' not found!");
				return;
			}
			using (Stream stream = executingAssembly.GetManifestResourceStream(text))
			{
				if (stream == null)
				{
					Logger.LogError((object)"Failed to get stream for embedded AssetBundle 'biglobby'.");
					return;
				}
				using MemoryStream memoryStream = new MemoryStream();
				stream.CopyTo(memoryStream);
				assets = AssetBundle.LoadFromMemory(memoryStream.ToArray());
			}
			if ((Object)(object)assets == (Object)null)
			{
				Logger.LogError((object)"Failed to load AssetBundle from memory.");
				return;
			}
			Logger.LogInfo((object)"AssetBundle 'biglobby' loaded successfully.");
			lg = assets.LoadAsset<Sprite>("biglobby_subtext");
			if ((Object)(object)lg == (Object)null)
			{
				Logger.LogError((object)"Failed to load 'biglobby_subtext' prefab from AssetBundle.");
			}
			else
			{
				Logger.LogInfo((object)"Prefab 'biglobby_subtext' loaded successfully.");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BigMonoLobby";

		public const string PLUGIN_NAME = "Bigger Lobby Mod";

		public const string PLUGIN_VERSION = "2.1.2";
	}
}