Decompiled source of InGameRoomMenu v1.0.1

InGameRoomMenu.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
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.Bootstrap;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using ToolClasses;
using UnityEngine;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;
using VoidManager.Utilities;

[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.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("InGameRoomMenu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Template")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("InGameRoomMenu")]
[assembly: AssemblyTitle("InGameRoomMenu")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 InGameRoomMenu
{
	[BepInPlugin("InGameRoomMenu", "InGameRoomMenu", "1.0.1")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin InGameRoomMenu is loaded!");
		}
	}
	internal class UGRMGUI : ModSettingsMenu
	{
		private string ErrorMessage;

		private string RoomName;

		private string PlayerLimit;

		private static GUIStyle MinSizeStyle;

		public override string Name()
		{
			return "In-Game Room Menu";
		}

		public override void Draw()
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			if (!Game.InGame || !PhotonNetwork.InRoom)
			{
				GUILayout.Label("Must be in game", Array.Empty<GUILayoutOption>());
				return;
			}
			if (RoomName == null)
			{
				((ModSettingsMenu)this).OnOpen();
			}
			GUILayout.Label("Usage: While in game and host, change values below and hit 'apply'.", Array.Empty<GUILayoutOption>());
			SettingGroup("Room Name - Current Value: " + PunSingleton<PhotonService>.Instance.GetCurrentRoomName(), ref RoomName, SetRooomName);
			bool currentRoomPrivate = PunSingleton<PhotonService>.Instance.GetCurrentRoomPrivate();
			if (GUILayout.Button("Room Publicity: " + (currentRoomPrivate ? "Private" : "Public"), Array.Empty<GUILayoutOption>()) && PhotonNetwork.IsMasterClient)
			{
				PunSingleton<PhotonService>.Instance.SetCurrentRoomPrivate(!currentRoomPrivate);
			}
			SettingGroup($"Player Limit - Current Value: {PhotonNetwork.CurrentRoom.MaxPlayers}", ref PlayerLimit, SetPlayerLimit);
			if (!string.IsNullOrWhiteSpace(ErrorMessage))
			{
				GUI.color = Color.red;
				GUILayout.Label(ErrorMessage, Array.Empty<GUILayoutOption>());
				GUI.color = Color.white;
			}
		}

		private void SetRooomName()
		{
			if (RoomName != PunSingleton<PhotonService>.Instance.GetCurrentRoomName())
			{
				PunSingleton<PhotonService>.Instance.SetCurrentRoomName(RoomName);
				RoomName = PunSingleton<PhotonService>.Instance.GetCurrentRoomName();
			}
		}

		private void SetPlayerLimit()
		{
			byte b = 4;
			Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos;
			if (pluginInfos.ContainsKey("MaxPlayers"))
			{
				b = byte.MaxValue;
			}
			else if (pluginInfos.ContainsKey("Space.HobosIn.Voider_Crew"))
			{
				b = 8;
			}
			if (byte.TryParse(PlayerLimit, out var result) && result != PhotonNetwork.CurrentRoom.MaxPlayers)
			{
				if (result <= b && result > 0)
				{
					ErrorMessage = null;
					PhotonNetwork.CurrentRoom.MaxPlayers = result;
				}
				else
				{
					ErrorMessage = $"Player limit must be a number between 1 and {b}";
				}
			}
			else
			{
				ErrorMessage = $"Player limit must be a number between 1 and {b}";
			}
		}

		private static void SettingGroup(string label, ref string settingvalue, Action func)
		{
			GUILayout.Label(label, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			settingvalue = GUILayout.TextField(settingvalue, Array.Empty<GUILayoutOption>());
			if (PhotonNetwork.IsMasterClient && GUILayout.Button("Apply", MinSizeStyle, Array.Empty<GUILayoutOption>()))
			{
				func?.Invoke();
			}
			GUILayout.EndHorizontal();
		}

		public override void OnOpen()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			ErrorMessage = null;
			if (Game.InGame)
			{
				RoomName = PunSingleton<PhotonService>.Instance.GetCurrentRoomName();
				PlayerLimit = PhotonNetwork.CurrentRoom.MaxPlayers.ToString();
			}
			if (MinSizeStyle == null)
			{
				MinSizeStyle = new GUIStyle(GUI.skin.button);
				MinSizeStyle.stretchWidth = false;
			}
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)3;

		public override string Author => "Dragon";

		public override string Description => "Allows host to manage room settings during gameplay. Accessed with F5 menu.";
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "InGameRoomMenu";

		public const string PLUGIN_NAME = "InGameRoomMenu";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}