Decompiled source of VoidCrew MorePlayers v1.0.2

BepInEx/plugins/VoidCrew_8Players.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using CG;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using RSG;
using Steamworks;
using ToolClasses;
using UnityEngine;
using UnityEngine.UIElements;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("VoidCrew_8Players")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VoidCrew_8Players")]
[assembly: AssemblyTitle("VoidCrew_8Players")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
[HarmonyPatch(typeof(PhotonService), "PhotonCreateRoom")]
public static class PhotonNetworkCreateRoomPatch
{
	private static ManualLogSource logger;

	public static void InitializeLogger(ManualLogSource logSource)
	{
		logger = logSource;
	}

	[HarmonyPrefix]
	public static bool PhotonCreateRoomPrefix(bool publicRoom, PhotonService __instance)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Expected O, but got Unknown
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Expected O, but got Unknown
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		Dictionary<string, RoomInfo> value = Traverse.Create((object)__instance).Field("_cachedRoomList").GetValue<Dictionary<string, RoomInfo>>();
		Promise value2 = Traverse.Create((object)__instance).Field("_createRoomPromise").GetValue<Promise>();
		CSteamID currentLobbyID = Singleton<SteamService>.I.GetCurrentLobbyID();
		string text = ((object)(CSteamID)(ref currentLobbyID)).ToString();
		if (value.ContainsKey(text))
		{
			value2.Reject(new Exception("Room already exists! " + text));
			return false;
		}
		RoomOptions val = new RoomOptions();
		val.IsVisible = publicRoom;
		val.MaxPlayers = 4;
		val.PlayerTtl = 0;
		val.EmptyRoomTtl = 0;
		val.CleanupCacheOnLeave = false;
		RoomOptions val2 = val;
		Hashtable val3 = new Hashtable();
		((Dictionary<object, object>)(object)val3).Add((object)"R_IH", (object)true);
		((Dictionary<object, object>)(object)val3).Add((object)"R_Na", (object)(PhotonNetwork.NickName + " Room"));
		((Dictionary<object, object>)(object)val3).Add((object)"R_AR", (object)0);
		object key = "R_Sy";
		GUIDUnion val4 = default(GUIDUnion);
		((Dictionary<object, object>)(object)val3).Add(key, (object)((GUIDUnion)(ref val4)).AsIntArray());
		((Dictionary<object, object>)(object)val3).Add((object)"R_Di", (object)0);
		object key2 = "R_Sh";
		val4 = default(GUIDUnion);
		((Dictionary<object, object>)(object)val3).Add(key2, (object)((GUIDUnion)(ref val4)).AsIntArray());
		val2.CustomRoomProperties = val3;
		val.CustomRoomPropertiesForLobby = new string[6] { "R_IH", "R_Na", "R_AR", "R_Sy", "R_Di", "R_Sh" };
		val.PublishUserId = true;
		RoomOptions val5 = val;
		Debug.Log((object)("Creating PhotonNetwork room: " + text), (Object)null);
		PhotonNetwork.CreateRoom(text, val5, Traverse.Create((object)__instance).Field("_lobby").GetValue<TypedLobby>(), (string[])null);
		return false;
	}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public class MatchmakingRoomPatch
{
	private static ManualLogSource logger;

	public static void InitializeLogger(ManualLogSource logSource)
	{
		logger = logSource;
	}

	[HarmonyPostfix]
	public static void PhotonCreateRoomPostfix(MatchmakingRoomSetup __instance)
	{
		ManualLogSource obj = logger;
		if (obj != null)
		{
			obj.LogDebug((object)"MatchmakingRoomSetup Constructor Postfix called");
		}
		SliderInt value = Traverse.Create((object)__instance).Field("playerLimitInput").GetValue<SliderInt>();
		if (value != null)
		{
			((BaseSlider<int>)(object)value).lowValue = 1;
			((BaseSlider<int>)(object)value).highValue = 8;
			((BaseField<int>)(object)value).value = 8;
		}
	}
}
namespace DismantleAllStationsMod
{
	[BepInPlugin("com.Vengeanze.VoidCrew_MorePlayers", "MorePlayers", "1.0.1")]
	public class Players8 : BaseUnityPlugin
	{
		private Harmony harmony;

		private static ManualLogSource modLogger;

		private void Awake()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			modLogger = ((BaseUnityPlugin)this).Logger;
			PhotonNetworkCreateRoomPatch.InitializeLogger(modLogger);
			MatchmakingRoomPatch.InitializeLogger(modLogger);
			modLogger.LogInfo((object)"Initializing MorePlayers");
			harmony = new Harmony("com.Vengeanze.VoidCrew_MorePlayers");
			harmony.PatchAll(typeof(PhotonNetworkCreateRoomPatch));
			harmony.PatchAll(typeof(MatchmakingRoomPatch));
			modLogger.LogInfo((object)"Harmony patches applied");
		}
	}
}