Decompiled source of HoloCheck v0.1.5

BepInEx/plugins/bricks04.holoCheck.dll

Decompiled 3 months 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 System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Steamworks;
using Steamworks.Data;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("bricks04.holoCheck")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+895a53b81970e2f8cefa6d9ae428c83edc296d4e")]
[assembly: AssemblyProduct("HoloCheck")]
[assembly: AssemblyTitle("bricks04.holoCheck")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.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;
		}
	}
	[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 HoloCheck
{
	internal class HoloCheckConfig
	{
		public readonly ConfigEntry<string> configAllowedSteamIDs;

		public readonly ConfigEntry<string> configPasskey;

		public readonly ConfigEntry<bool> configPayloadInjection;

		public HoloCheckConfig(ConfigFile cfg)
		{
			cfg.Bind<string>("General", "READ ME", "PLEASE READ ME", "To use whitelisting, please obtain the steam IDs of everyone you wish to allow into the server. While active, a steam ID check will be performed regardless of if you use a private or public server. Whitelisting will not work if you use LAN mode.");
			cfg.Bind<string>("General", "Contact", "andrew3199 or Xitter@bricks041lol, email [email protected]", "Please contact me if you find any issues with the mod, or if you have any questions. (Please do not spam any of these contact channels as I will block people if needed.)");
			configAllowedSteamIDs = cfg.Bind<string>("General", "Allowed Steam IDs", "", "A comma-separated string, containing a list of Steam IDs that you wish to allow entry into your servers. Ensure that there is no whitespace in the string. Example - '123456789,987654321,011131017'. YOUR STEAM ID IS NOT THE SAME THING AS THE STEAM FRIEND CODE! Obtain steam IDs by going to your profile, and taking the numbers at the end of the URL. ");
			configPayloadInjection = cfg.Bind<bool>("General", "Payload Injection Method", false, "Whether to utilise payload injections or version changes for passkey checking. Set to true if you do not wish for the version number to be changed eg. A different mod modifies this number and actively uses it.");
		}
	}
	[BepInPlugin("bricks04.holoCheck", "HoloCheck", "1.0.0")]
	public class HoloCheck : BaseUnityPlugin
	{
		internal static string[] allowedSteamIDs;

		internal static int originalVersion = 0;

		internal static int targetVersion = 999950;

		public static string passkey = "";

		public static bool payloadInjection = false;

		public static bool displaySettings = false;

		internal static HoloCheckConfig BoundConfig { get; private set; } = null;


		public static HoloCheck Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		public static void SaveConfig()
		{
			string text = "";
			string[] array = allowedSteamIDs;
			foreach (string text2 in array)
			{
				text = text + "," + text2;
			}
			Logger.LogInfo((object)text);
			((ConfigEntryBase)BoundConfig.configAllowedSteamIDs).BoxedValue = text;
			((ConfigEntryBase)BoundConfig.configPayloadInjection).BoxedValue = payloadInjection;
		}

		private void Awake()
		{
			BoundConfig = new HoloCheckConfig(((BaseUnityPlugin)this).Config);
			string text = (string)((ConfigEntryBase)BoundConfig.configAllowedSteamIDs).BoxedValue;
			allowedSteamIDs = text.Split(",");
			if (allowedSteamIDs[0] == "")
			{
				allowedSteamIDs = Array.Empty<string>();
			}
			payloadInjection = (bool)((ConfigEntryBase)BoundConfig.configPayloadInjection).BoxedValue;
			passkey = "";
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)$"Passkey = {passkey}, Steam IDs = {allowedSteamIDs.Length}");
			Logger.LogInfo((object)"bricks04.holoCheck v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("bricks04.holoCheck");
			}
			Logger.LogInfo((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogInfo((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "bricks04.holoCheck";

		public const string PLUGIN_NAME = "HoloCheck";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace HoloCheck.Patches
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	public class GameNetworkManagerPatches
	{
		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePostFix()
		{
			HoloCheck.Logger.LogInfo((object)"GameNetworkManager awoken!");
		}

		[HarmonyPatch("ConnectionApproval")]
		[HarmonyPostfix]
		private static void ConnectionApprovalPostFix(GameNetworkManager __instance, ConnectionApprovalRequest request, ConnectionApprovalResponse response)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (HoloCheck.allowedSteamIDs.Length != 0)
			{
				CheckForSteamID(__instance, request, response);
			}
			CheckForPassPIN(__instance, request, response);
		}

		[HarmonyPatch("SetConnectionDataBeforeConnecting")]
		[HarmonyPostfix]
		[HarmonyAfter(new string[] { "me.swipez.melonloader.morecompany" })]
		private static void SetConnectionDataPostFix(GameNetworkManager __instance)
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			HoloCheck.Logger.LogInfo((object)("Checking Connection data = " + Encoding.ASCII.GetString(NetworkManager.Singleton.NetworkConfig.ConnectionData)));
			if (HoloCheck.payloadInjection)
			{
				__instance.localClientWaitingForApproval = true;
				HoloCheck.Logger.LogInfo((object)("Pass to inject: " + HoloCheck.passkey.ToString()));
				if (__instance.disableSteam)
				{
					NetworkManager.Singleton.NetworkConfig.ConnectionData = Encoding.ASCII.GetBytes(__instance.gameVersionNum + "," + 32 + "," + HoloCheck.passkey.ToString());
				}
				else
				{
					NetworkManager.Singleton.NetworkConfig.ConnectionData = Encoding.ASCII.GetBytes(__instance.gameVersionNum + "," + SteamId.op_Implicit(SteamClient.SteamId) + "," + HoloCheck.passkey.ToString());
				}
				HoloCheck.Logger.LogInfo((object)("Post-injection Connection data = " + Encoding.ASCII.GetString(NetworkManager.Singleton.NetworkConfig.ConnectionData)));
			}
		}

		[HarmonyPatch("SteamMatchmaking_OnLobbyCreated")]
		[HarmonyPostfix]
		private static void S_OnLobbyCreatedPostFix(GameNetworkManager __instance, ref Result result, ref Lobby lobby)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			HoloCheck.Logger.LogInfo((object)"Running onLobbyCreated patch");
			HoloCheck.Logger.LogInfo((object)result);
			HoloCheck.Logger.LogInfo((object)lobby);
			if (!__instance.disableSteam && __instance.lobbyHostSettings.isLobbyPublic && (HoloCheck.allowedSteamIDs.Length != 0 || HoloCheck.passkey.Length > 0))
			{
				HoloCheck.Logger.LogInfo((object)"Changing the lobby mode to an Invisible lobby. ");
				((Lobby)(ref lobby)).SetInvisible();
			}
		}

		private static void CheckForSteamID(GameNetworkManager __instance, ConnectionApprovalRequest request, ConnectionApprovalResponse response)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			HoloCheck.Logger.LogInfo((object)"A connection approval check happened! Checking for steamID");
			HoloCheck.Logger.LogInfo((object)__instance.disallowConnection);
			HoloCheck.Logger.LogInfo((object)__instance.disableSteam);
			HoloCheck.Logger.LogInfo((object)response.Approved);
			bool flag = !__instance.disallowConnection;
			if (__instance.disableSteam)
			{
				HoloCheck.Logger.LogWarning((object)"You are in LAN mode, or you somehow have Steam disabled! User ID checks will not be conducted. ");
			}
			if (flag && response.Approved && !__instance.disableSteam)
			{
				string @string = Encoding.ASCII.GetString(request.Payload);
				string[] array = @string.Split(",");
				string[] array2 = array;
				foreach (string text in array2)
				{
					HoloCheck.Logger.LogInfo((object)text);
				}
				HoloCheck.Logger.LogInfo((object)("Steam ID = " + array[1]));
				HoloCheck.Logger.LogInfo((object)HoloCheck.allowedSteamIDs);
				if (HoloCheck.allowedSteamIDs.Contains(array[1]))
				{
					HoloCheck.Logger.LogWarning((object)("User " + array[1] + " was approved to join the server! "));
					flag = true;
				}
				else
				{
					HoloCheck.Logger.LogWarning((object)("User " + array[1] + " attempted to join the server, but has been denied because they are not on the list. "));
					response.Reason = "Your account has not been approved to join this server.";
					flag = false;
				}
				response.Approved = flag;
			}
		}

		private static void CheckForPassPIN(GameNetworkManager __instance, ConnectionApprovalRequest request, ConnectionApprovalResponse response)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			HoloCheck.Logger.LogInfo((object)"A connection approval check happened! Checking for pass");
			bool approved = response.Approved;
			if (__instance.disallowConnection)
			{
				return;
			}
			string @string = Encoding.ASCII.GetString(request.Payload);
			string[] array = @string.Split(",");
			HoloCheck.Logger.LogInfo((object)("Length of Payload = " + array.Length));
			switch (array.Length)
			{
			case 3:
				HoloCheck.Logger.LogInfo((object)("Attempted Passkey = " + array[2]));
				HoloCheck.Logger.LogInfo((object)("Passkey to check = " + HoloCheck.passkey.ToString()));
				if (array[2].ToString() == HoloCheck.passkey.ToString())
				{
					HoloCheck.Logger.LogWarning((object)"User's password matches.");
					break;
				}
				HoloCheck.Logger.LogWarning((object)"User attempted to join the server, but has been denied because their passkey does not match. Overriding any previous connection approval.");
				response.Reason = "Your account has not been approved to join this server.";
				approved = false;
				break;
			case 1:
			case 2:
				HoloCheck.Logger.LogInfo((object)("Attempted Version = " + array[0]));
				if (array[0] == HoloCheck.targetVersion.ToString())
				{
					HoloCheck.Logger.LogWarning((object)"User's password matches.");
					break;
				}
				HoloCheck.Logger.LogWarning((object)"User attempted to join the server, but has been denied because their passkey does not match. Overriding any previous connection approval.");
				response.Reason = "Your account has not been approved to join this server.";
				approved = false;
				break;
			default:
				HoloCheck.Logger.LogError((object)"No case found for payload handling! Immediately rejecting user by default.");
				response.Reason = "Your account cannot join the server for safety reasons.";
				approved = false;
				break;
			}
			response.Approved = approved;
		}
	}
	[HarmonyPatch(typeof(SteamLobbyManager))]
	public class SteamLobbyManagerPatches
	{
		private static SteamLobbyManager lobbyManager;

		[HarmonyPatch("OnEnable")]
		[HarmonyPostfix]
		private static void OnEnablePostfix(SteamLobbyManager __instance)
		{
			HoloCheck.Logger.LogInfo((object)"OnEnable postfix patch run!");
			lobbyManager = __instance;
		}

		public static void CallRefreshServerListButton()
		{
			if ((Object)(object)lobbyManager == (Object)null)
			{
				HoloCheck.Logger.LogError((object)"There is no stored reference to the game's SteamLobbyManager!");
				return;
			}
			HoloCheck.Logger.LogInfo((object)"Forcing a server list refresh!");
			lobbyManager.RefreshServerListButton();
		}

		[HarmonyPatch("LoadServerList")]
		[HarmonyPostfix]
		private static void LoadServerListPostfix()
		{
			if (HoloCheck.passkey == "")
			{
				HoloCheck.Logger.LogWarning((object)"Accessing the server list with no passkey set!");
				UIPatches.DisplayWarningMessage("> No Passkey Set!", 10f);
			}
		}
	}
	[HarmonyPatch(typeof(MenuManager))]
	public class UIPatches
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__EnableHoloCheckSettingsPanel;

			public static UnityAction <1>__DisableHoloCheckSettingsPanel;

			public static UnityAction <2>__RevealPasskeyButton;

			public static UnityAction <3>__ChangePasskeyButton;

			public static UnityAction <4>__InjectorButtonPressed;
		}

		public static AssetBundle HoloCheckUIAssets;

		public static GameObject holoCheckUI;

		public static GameObject instantiatedUI;

		public static GameObject enableHoloCheckSettingsButton;

		public static GameObject disableHoloCheckSettingsButton;

		public static GameObject settingsPanel;

		public static GameObject passkeyField;

		public static GameObject passkeyMode;

		public static GameObject pendingChangesAlert;

		public static GameObject revealPasskeyButton;

		public static GameObject changePasskeyButton;

		private static RectTransform settingsClosedPasskeyPosition;

		private static RectTransform settingsOpenPasskeyPosition;

		public static GameObject injectorButton;

		public static GameObject injectorText;

		private static float inputMessageTimer;

		private static bool userWarned;

		[HarmonyPatch("Awake")]
		[HarmonyPrefix]
		private static void AwakePrefix()
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "holocheckassetbundle"));
			if ((Object)(object)val == (Object)null)
			{
				HoloCheck.Logger.LogError((object)"Failed to load custom assets. If custom assets were previously loaded, you can safely ignore this error. ");
				return;
			}
			HoloCheckUIAssets = val;
			HoloCheck.Logger.LogInfo((object)"Custom assets loaded!");
		}

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePostfix()
		{
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Expected O, but got Unknown
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Expected O, but got Unknown
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Expected O, but got Unknown
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Expected O, but got Unknown
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Expected O, but got Unknown
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				holoCheckUI = HoloCheckUIAssets.LoadAsset<GameObject>("HoloCheckUI");
				instantiatedUI = Object.Instantiate<GameObject>(holoCheckUI);
				enableHoloCheckSettingsButton = ((Component)instantiatedUI.transform.Find("Canvas").Find("ActivateButton")).gameObject;
				disableHoloCheckSettingsButton = ((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("Back Button")).gameObject;
				settingsPanel = ((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel")).gameObject;
				passkeyMode = ((Component)instantiatedUI.transform.Find("Canvas").Find("Passkey Mode")).gameObject;
				passkeyField = ((Component)instantiatedUI.transform.Find("Canvas").Find("Passkey Mode").Find("Passkey Field")).gameObject;
				pendingChangesAlert = ((Component)instantiatedUI.transform.Find("Canvas").Find("Passkey Mode").Find("Unsaved Changes Label")).gameObject;
				revealPasskeyButton = ((Component)instantiatedUI.transform.Find("Canvas").Find("Passkey Mode").Find("Reveal Button")).gameObject;
				changePasskeyButton = ((Component)instantiatedUI.transform.Find("Canvas").Find("Passkey Mode").Find("Change Button")).gameObject;
				settingsClosedPasskeyPosition = ((Component)instantiatedUI.transform.Find("Canvas").Find("Menu Closed Passkey")).gameObject.GetComponent<RectTransform>();
				settingsOpenPasskeyPosition = ((Component)instantiatedUI.transform.Find("Canvas").Find("Menu Opened Passkey")).gameObject.GetComponent<RectTransform>();
				injectorButton = ((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("Injector Mode")
					.Find("InjectorButton")).gameObject;
				injectorText = ((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("Injector Mode")
					.Find("Text (TMP)")).gameObject;
				passkeyField.GetComponent<TMP_InputField>().contentType = (ContentType)7;
				if (HoloCheck.passkey != "")
				{
					passkeyField.GetComponent<TMP_InputField>().text = HoloCheck.passkey;
				}
				else
				{
					passkeyField.GetComponent<TMP_InputField>().text = "";
				}
				passkeyField.GetComponent<TMP_InputField>().ForceLabelUpdate();
				ButtonClickedEvent onClick = enableHoloCheckSettingsButton.GetComponent<Button>().onClick;
				object obj = <>O.<0>__EnableHoloCheckSettingsPanel;
				if (obj == null)
				{
					UnityAction val = EnableHoloCheckSettingsPanel;
					<>O.<0>__EnableHoloCheckSettingsPanel = val;
					obj = (object)val;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj);
				ButtonClickedEvent onClick2 = disableHoloCheckSettingsButton.GetComponent<Button>().onClick;
				object obj2 = <>O.<1>__DisableHoloCheckSettingsPanel;
				if (obj2 == null)
				{
					UnityAction val2 = DisableHoloCheckSettingsPanel;
					<>O.<1>__DisableHoloCheckSettingsPanel = val2;
					obj2 = (object)val2;
				}
				((UnityEvent)onClick2).AddListener((UnityAction)obj2);
				ButtonClickedEvent onClick3 = revealPasskeyButton.GetComponent<Button>().onClick;
				object obj3 = <>O.<2>__RevealPasskeyButton;
				if (obj3 == null)
				{
					UnityAction val3 = RevealPasskeyButton;
					<>O.<2>__RevealPasskeyButton = val3;
					obj3 = (object)val3;
				}
				((UnityEvent)onClick3).AddListener((UnityAction)obj3);
				ButtonClickedEvent onClick4 = changePasskeyButton.GetComponent<Button>().onClick;
				object obj4 = <>O.<3>__ChangePasskeyButton;
				if (obj4 == null)
				{
					UnityAction val4 = ChangePasskeyButton;
					<>O.<3>__ChangePasskeyButton = val4;
					obj4 = (object)val4;
				}
				((UnityEvent)onClick4).AddListener((UnityAction)obj4);
				ButtonClickedEvent onClick5 = injectorButton.GetComponent<Button>().onClick;
				object obj5 = <>O.<4>__InjectorButtonPressed;
				if (obj5 == null)
				{
					UnityAction val5 = InjectorButtonPressed;
					<>O.<4>__InjectorButtonPressed = val5;
					obj5 = (object)val5;
				}
				((UnityEvent)onClick5).AddListener((UnityAction)obj5);
				if (HoloCheck.payloadInjection)
				{
					((Graphic)injectorButton.GetComponent<Image>()).color = Color.green;
					((TMP_Text)injectorText.GetComponent<TextMeshProUGUI>()).text = "Payload Injection enabled";
				}
				else
				{
					((Graphic)injectorButton.GetComponent<Image>()).color = Color.white;
					((TMP_Text)injectorText.GetComponent<TextMeshProUGUI>()).text = "Payload Injection disabled";
				}
				PopulateUserList();
				RewriteRuleset();
			}
			catch (Exception ex)
			{
				HoloCheck.Logger.LogError((object)ex);
			}
		}

		[HarmonyPatch("SetLoadingScreen")]
		[HarmonyPostfix]
		private static void SetLoadingScreenPostfix(bool isLoading, RoomEnter result)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Invalid comparison between Unknown and I4
			HoloCheck.Logger.LogInfo((object)("RoomEnter Result = " + ((object)(RoomEnter)(ref result)).ToString()));
			if ((int)result == 5 && !isLoading)
			{
				HoloCheck.Logger.LogError((object)"Fatal RoomEnter result detected! Please RESTART your game before reattempting join!");
				DisplayRestartWarning();
			}
		}

		private static void DisplayRestartWarning()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			((TMP_Text)pendingChangesAlert.GetComponent<TextMeshProUGUI>()).text = "> Unexpected error. Please restart game.";
			inputMessageTimer = -60f;
			((Graphic)pendingChangesAlert.GetComponent<TextMeshProUGUI>()).color = Color.red;
			pendingChangesAlert.SetActive(true);
		}

		[HarmonyPatch("ConfirmHostButton")]
		[HarmonyPrefix]
		private static bool ConfirmHostButtonPrefix(MenuManager __instance)
		{
			HoloCheck.Logger.LogInfo((object)"Host Button Confirm pressed!");
			if (HoloCheck.passkey == "" && !userWarned)
			{
				HoloCheck.Logger.LogWarning((object)"No passkey and user has not been warned!");
				((TMP_Text)__instance.tipTextHostSettings).text = "You are about to create a lobby without a passkey!\nPress [Confirm] again to proceed.";
				userWarned = true;
				return false;
			}
			return true;
		}

		private static void InjectorButtonPressed()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			HoloCheck.Logger.LogInfo((object)"Injector Button pressed!");
			HoloCheck.payloadInjection = !HoloCheck.payloadInjection;
			if (HoloCheck.payloadInjection)
			{
				((Graphic)injectorButton.GetComponent<Image>()).color = Color.green;
				VersionPatches.ResetVersionNumber();
				((TMP_Text)injectorText.GetComponent<TextMeshProUGUI>()).text = "Payload Injection enabled";
			}
			else
			{
				((Graphic)injectorButton.GetComponent<Image>()).color = Color.white;
				VersionPatches.ChangePasskey(HoloCheck.passkey);
				((TMP_Text)injectorText.GetComponent<TextMeshProUGUI>()).text = "Payload Injection disabled";
			}
		}

		private static void EnableHoloCheckSettingsPanel()
		{
			HoloCheck.Logger.LogInfo((object)"Enable HoloCheck Settings button pressed!");
			HoloCheck.displaySettings = true;
			settingsPanel.SetActive(true);
			enableHoloCheckSettingsButton.SetActive(false);
		}

		private static void DisableHoloCheckSettingsPanel()
		{
			HoloCheck.Logger.LogInfo((object)"Disable HoloCheck settings button pressed!");
			HoloCheck.displaySettings = false;
			settingsPanel.SetActive(false);
			enableHoloCheckSettingsButton.SetActive(true);
		}

		private static void ChangePasskeyButton()
		{
			HoloCheck.Logger.LogInfo((object)("Change Passkey button pressed! Attempting to change passkey to " + passkeyField.GetComponent<TMP_InputField>().text));
			DateTime now = DateTime.Now;
			HoloCheck.Logger.LogInfo((object)now.ToString("MM-dd"));
			if ((now.ToString("MM-dd") == "05-25") & ((passkeyField.GetComponent<TMP_InputField>().text == "0525") | (passkeyField.GetComponent<TMP_InputField>().text == "2505")))
			{
				HoloCheck.Logger.LogError((object)"VGhpcyBpcyBhIG1lbW9yaXVtIHRvIEdvb2dob3VsLCB0aGUgbG92ZWx5IGdob3VsIHRoYXQgaGFzIHNpbmNlIHBhc3NlZCBhd2F5Li4uClRvZGF5IHdvdWxkIGhhdmUgYmVlbiBhIGRheSB3aGVuIHdlIGNlbGVicmF0ZWQgeW91ciBncm93dGgsIHdoZXJlIHdlIHdvdWxkIGhhdmUgZ2l2ZW4geW91IGxvdmVseSBnaWZ0cyBkZXNlcnZpbmcgZm9yIGEgbG92ZWx5IGdob3VsLgpJIGhvcGUgdGhhdCB3aGVuIHRoaXMgZGF5IGNvbWVzLCB3ZSBzdGlsbCBoYXZlIHlvdXIgc291bCBidXJuaW5nIGluIG91ciBoZWFydHMuIEkgaG9wZSB0aGF0IHdlIHdpbGwgc3RpbGwgcHJlcGFyZSBnaWZ0cyBmb3IgeW91LCBhbmQgZXZlbiBpZiB5b3UgY2FuJ3QgcmVjaWV2ZSB0aGVtIHBoeXNpY2FsbHkgYW55bW9yZSwgSSBob3BlIHRoZSBnaWZ0cyB3aWxsIHJlYWNoIHlvdSBzb21laG93LiAKWW91J3ZlIGRvbmUgc28gbXVjaCBmb3IgZXZlcnlvbmUgaGVyZSwgSSBob3BlIHRoYXQgd2UgY2FuIGhvbGQgYW5kIHByZXNlcnZlIHlvdXIgbGVnYWN5IGluIHN1cHBvcnRpbmcgb3VyIGxvdmVseSB6b21iaWUuIEkgaG9wZSB0aGF0IHlvdSBjYW4gd2F0Y2ggZG93biBvbiB1cyBhbmQgc21pbGUsIGFuZCB0aGF0IHdoZW4gd2Ugam9pbiB5b3UsIHdlIGNhbiBoYXZlIGEgYmlnIGh1ZyB0b2dldGhlci4gCkkgcGVyc29uYWxseSB3aXNoIEkgY291bGQgaGF2ZSB0YWxrZWQgd2l0aCB5b3UgbW9yZS4gSSBob3BlIHRoYXQgd2hlbiB0aGUgdGltZSBjb21lcyBmb3IgbWUsIEkgY2FuIHJpZ2h0IG15IHdyb25ncywgYW5kIGtlZXAgeW91IGNvbXBhbnkuIApXZSB3aWxsIHJlbWVtYmVyIHlvdSwgR29vLiBNYXkgeW91IHJlc3QgaW4gZXRlcm5hbCBwZWFjZS4g");
			}
			string text = CheckStringPasskeyValidity(passkeyField.GetComponent<TMP_InputField>().text);
			if ((text == "") | (passkeyField.GetComponent<TMP_InputField>().text.Length == 0))
			{
				HoloCheck.passkey = passkeyField.GetComponent<TMP_InputField>().text;
				VersionPatches.ChangePasskey(HoloCheck.passkey);
				HoloCheck.SaveConfig();
				((TMP_Text)pendingChangesAlert.GetComponent<TextMeshProUGUI>()).text = "> Change successful.";
				userWarned = false;
				inputMessageTimer = 0f;
				pendingChangesAlert.SetActive(true);
				RewriteRuleset();
			}
			else
			{
				HoloCheck.Logger.LogError((object)text.Split("|")[0]);
				((TMP_Text)pendingChangesAlert.GetComponent<TextMeshProUGUI>()).text = text.Split("|")[1];
				inputMessageTimer = 0f;
				pendingChangesAlert.SetActive(true);
			}
			SteamLobbyManagerPatches.CallRefreshServerListButton();
		}

		public static void DisplayWarningMessage(string message, float time = 5f)
		{
			((TMP_Text)pendingChangesAlert.GetComponent<TextMeshProUGUI>()).text = message;
			inputMessageTimer = 5f - time;
			pendingChangesAlert.SetActive(true);
		}

		public static string CheckStringPasskeyValidity(string passkeyToCheck)
		{
			if (Regex.IsMatch(passkeyToCheck, "^\\d*$"))
			{
				if (Regex.IsMatch(passkeyToCheck, "^\\d{1,4}$"))
				{
					return "";
				}
				return "Entered passkey value is too long!|> Entered value too long! (4 max)";
			}
			return "Entered passkey value is not a number!|> Entered value is not a number!";
		}

		private static void RevealPasskeyButton()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			if ((int)passkeyField.GetComponent<TMP_InputField>().contentType == 7)
			{
				HoloCheck.Logger.LogInfo((object)"Change to standard");
				passkeyField.GetComponent<TMP_InputField>().contentType = (ContentType)0;
			}
			else
			{
				HoloCheck.Logger.LogInfo((object)"Change to password");
				passkeyField.GetComponent<TMP_InputField>().contentType = (ContentType)7;
			}
			passkeyField.GetComponent<TMP_InputField>().ForceLabelUpdate();
		}

		private static void PopulateUserList()
		{
			GameObject gameObject = ((Component)holoCheckUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("UserScrollArea")
				.Find("Content")
				.Find("UserPanel")).gameObject;
			GameObject gameObject2 = ((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("UserScrollArea")
				.Find("Content")).gameObject;
			GameObject gameObject3 = ((Component)holoCheckUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("UserScrollArea")
				.Find("Content")
				.Find("EndPanel")).gameObject;
			Object.Destroy((Object)(object)((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("UserScrollArea")
				.Find("Content")
				.Find("UserPanel")).gameObject);
			Object.Destroy((Object)(object)((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("UserScrollArea")
				.Find("Content")
				.Find("EndPanel")).gameObject);
			string[] allowedSteamIDs = HoloCheck.allowedSteamIDs;
			foreach (string text in allowedSteamIDs)
			{
				GameObject val = Object.Instantiate<GameObject>(gameObject, gameObject2.transform);
				((TMP_Text)((Component)val.transform.GetChild(0)).gameObject.GetComponentInChildren<TextMeshProUGUI>()).text = text;
			}
			Object.Instantiate<GameObject>(gameObject3, gameObject2.transform);
		}

		private static void RewriteRuleset()
		{
			GameObject gameObject = ((Component)instantiatedUI.transform.Find("Canvas").Find("HoloCheckPanel").Find("CurrentRulesetBorder")
				.Find("Text (TMP)")).gameObject;
			string text = "Active Ruleset: \n\n";
			if (HoloCheck.passkey != "")
			{
				text += "> Users must install HoloCheck\n\n> Users must enter the correct passkey\n\n";
				if (HoloCheck.payloadInjection)
				{
					text += "> Users must enable Payload Injection\n\n";
				}
			}
			if (HoloCheck.allowedSteamIDs.Length != 0)
			{
				text = text + "> The user's SteamID must be present on the whitelist.\nWhitelist Length : " + HoloCheck.allowedSteamIDs.Length + "\n\n";
			}
			((TMP_Text)gameObject.GetComponent<TextMeshProUGUI>()).text = text;
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePostfix()
		{
			inputMessageTimer += Time.deltaTime;
			if ((double)inputMessageTimer >= 5.0 && pendingChangesAlert.activeSelf)
			{
				pendingChangesAlert.SetActive(false);
			}
		}
	}
	[HarmonyPatch(typeof(GameNetworkManager))]
	public class VersionPatches
	{
		private static GameNetworkManager instance;

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void StartPostFix(GameNetworkManager __instance)
		{
			instance = __instance;
			if (!HoloCheck.payloadInjection)
			{
				ChangeVersionWithPasskey(HoloCheck.passkey, __instance);
			}
		}

		[HarmonyPatch("JoinLobby")]
		[HarmonyPrefix]
		private static void JoinLobbyPrefix(GameNetworkManager __instance)
		{
			if (!HoloCheck.payloadInjection)
			{
				ChangeVersionWithPasskey(HoloCheck.passkey, __instance);
			}
		}

		public static void ChangePasskey(string passkey)
		{
			if (!HoloCheck.payloadInjection)
			{
				ChangeVersionWithPasskey(passkey, instance);
			}
		}

		public static void ResetVersionNumber()
		{
			if (instance.gameVersionNum != HoloCheck.originalVersion)
			{
				instance.gameVersionNum = HoloCheck.originalVersion;
				HoloCheck.Logger.LogInfo((object)"Resetting the version back to the original number.");
				HoloCheck.Logger.LogInfo((object)("The new version is = " + instance.gameVersionNum));
			}
			else
			{
				HoloCheck.Logger.LogWarning((object)"Detected version matches the target version! ");
			}
		}

		private static void ChangeVersionWithPasskey(string passkey, GameNetworkManager __instance)
		{
			HoloCheck.Logger.LogInfo((object)"VersionPatches awoken!");
			if (HoloCheck.originalVersion == 0)
			{
				HoloCheck.originalVersion = __instance.gameVersionNum;
			}
			HoloCheck.Logger.LogInfo((object)("Original Version = " + HoloCheck.originalVersion));
			if (HoloCheck.passkey != "")
			{
				HoloCheck.targetVersion = int.Parse("1" + passkey + HoloCheck.originalVersion);
			}
			else
			{
				HoloCheck.targetVersion = HoloCheck.originalVersion;
			}
			HoloCheck.Logger.LogInfo((object)("Detected Version = " + __instance.gameVersionNum));
			HoloCheck.Logger.LogInfo((object)("Target Version = " + HoloCheck.targetVersion));
			if (__instance.gameVersionNum != HoloCheck.targetVersion)
			{
				__instance.gameVersionNum = HoloCheck.targetVersion;
				HoloCheck.Logger.LogInfo((object)"Detected version number does not match the intended version number, applying fix");
				HoloCheck.Logger.LogInfo((object)("The new version is = " + __instance.gameVersionNum));
			}
			else
			{
				HoloCheck.Logger.LogWarning((object)"Detected version matches the target version!");
			}
		}
	}
}