Decompiled source of LobbyImprovements REPO v1.0.5

BepInEx/plugins/LobbyImprovements/uk.1a3.lobbyimprovements.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using LobbyImprovements.Patches;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using Steamworks.Data;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("uk.1a3.lobbyimprovements")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+ea1e9899cb48b87996af808baf7b4f65a7975011")]
[assembly: AssemblyProduct("LobbyImprovements")]
[assembly: AssemblyTitle("uk.1a3.lobbyimprovements")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LobbyImprovements
{
	[BepInPlugin("uk.1a3.lobbyimprovements", "LobbyImprovements", "1.0.5")]
	internal class PluginLoader : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("uk.1a3.lobbyimprovements");

		private static bool initialized;

		internal static ConfigEntry<string> playerNamePrefixSelected;

		internal static ConfigEntry<bool> singleplayerLobbyMenu;

		internal static ConfigEntry<bool> saveDeleteEnabled;

		internal static ConfigEntry<bool> savePublicEnabled;

		internal static ConfigEntry<bool> testerOverlayEnabled;

		internal static ConfigEntry<bool> testerOverlayModule;

		internal static ConfigEntry<bool> moonPhaseUIEnabled;

		internal static ConfigEntry<bool> splashScreenUIEnabled;

		internal static ManualLogSource StaticLogger { get; private set; }

		internal static ConfigFile StaticConfig { get; private set; }

		private void Awake()
		{
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			if (initialized)
			{
				return;
			}
			initialized = true;
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			StaticConfig = ((BaseUnityPlugin)this).Config;
			try
			{
				harmony.PatchAll(typeof(ChatCommands));
			}
			catch (Exception ex)
			{
				StaticLogger.LogError((object)("ChatCommands Patch Failed: " + ex));
			}
			try
			{
				harmony.PatchAll(typeof(PlayerNamePrefix));
			}
			catch (Exception ex2)
			{
				StaticLogger.LogError((object)("PlayerNamePrefix Patch Failed: " + ex2));
				playerNamePrefixSelected = StaticConfig.Bind<string>("Name Prefix", "Selected", "none", new ConfigDescription("Which prefix would you like to use?", (AcceptableValueBase)null, Array.Empty<object>()));
				playerNamePrefixSelected.SettingChanged += delegate
				{
					PlayerNamePrefix.WorldSpaceUIParent_UpdatePlayerName(PlayerAvatar.instance);
					if (GameManager.Multiplayer())
					{
						PlayerNamePrefix.PhotonSetCustomProperty(PhotonNetwork.LocalPlayer, "playerNamePrefix", playerNamePrefixSelected?.Value);
					}
				};
			}
			saveDeleteEnabled = StaticConfig.Bind<bool>("Saves", "Deletion", true, "Should saves be automatically deleted when everyone dies?");
			savePublicEnabled = StaticConfig.Bind<bool>("Saves", "Public Lobbies", false, "Should public lobbies have save files?");
			try
			{
				harmony.PatchAll(typeof(PublicLobbySaves));
			}
			catch (Exception ex3)
			{
				StaticLogger.LogError((object)("PublicLobbySaves Patch Failed: " + ex3));
			}
			try
			{
				harmony.PatchAll(typeof(ServerListSearch));
			}
			catch (Exception ex4)
			{
				StaticLogger.LogError((object)("ServerListSearch Patch Failed: " + ex4));
			}
			singleplayerLobbyMenu = StaticConfig.Bind<bool>("Singleplayer", "Lobby Menu", false, "Should the lobby menu be enabled in singleplayer?");
			try
			{
				harmony.PatchAll(typeof(MenuPageLobbySP));
			}
			catch (Exception ex5)
			{
				StaticLogger.LogError((object)("MenuPageLobbySP Patch Failed: " + ex5));
			}
			testerOverlayEnabled = StaticConfig.Bind<bool>("Tester Overlay", "Enabled", false, "Should the tester overlay be shown?");
			testerOverlayEnabled.SettingChanged += delegate
			{
				SetupTesterOverlay(testerOverlayEnabled.Value);
			};
			testerOverlayModule = StaticConfig.Bind<bool>("Tester Overlay", "Show Module", true, "Should the name of the module you are in be shown?");
			SetupTesterOverlay(testerOverlayEnabled.Value);
			moonPhaseUIEnabled = StaticConfig.Bind<bool>("Fast Startup", "Moon Phase", true, "Should the moon phase animation be shown?");
			splashScreenUIEnabled = StaticConfig.Bind<bool>("Fast Startup", "Splash Screen", true, "Should the splash screen be shown?");
			try
			{
				harmony.PatchAll(typeof(FastStartup));
			}
			catch (Exception ex6)
			{
				StaticLogger.LogError((object)("FastStartup Patch Failed: " + ex6));
			}
			StaticLogger.LogInfo((object)"Patches Loaded");
		}

		private static void SetupTesterOverlay(bool _enabled)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			GameObject val = GameObject.Find("TesterOverlay");
			if (_enabled && (Object)(object)val == (Object)null)
			{
				GameObject val2 = new GameObject("TesterOverlay")
				{
					hideFlags = (HideFlags)61
				};
				Object.DontDestroyOnLoad((Object)val2);
				val2.AddComponent<TesterOverlay>();
			}
			else if (!_enabled && (Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val);
			}
		}
	}
	public class TesterOverlay : MonoBehaviour
	{
		private string text;

		private string moduleName;

		private void OnGUI()
		{
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			//IL_0187: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Expected O, but got Unknown
			//IL_01a4: Expected O, but got Unknown
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(this.text))
			{
				if (!SteamClient.IsValid || !Object.op_Implicit((Object)(object)BuildManager.instance))
				{
					return;
				}
				this.text = $"{BuildManager.instance.version.title}\n{SteamClient.Name} ({SteamClient.SteamId})";
			}
			string text = this.text;
			if (PluginLoader.testerOverlayModule.Value && SemiFunc.RunIsLevel())
			{
				List<RoomVolume> currentRooms = PlayerAvatar.instance?.RoomVolumeCheck.CurrentRooms.Where((RoomVolume r) => Object.op_Implicit((Object)(object)r.Module)).ToList();
				List<RoomVolume> list = currentRooms;
				if (list != null && list.Any())
				{
					if (currentRooms.All((RoomVolume r) => (Object)(object)r.MapModule == (Object)(object)currentRooms[0].MapModule))
					{
						moduleName = ((Object)currentRooms[0].Module).name.Replace("(Clone)", "");
					}
					if (moduleName != null)
					{
						text = moduleName + "\n" + text;
					}
				}
				else
				{
					moduleName = null;
				}
			}
			else
			{
				moduleName = null;
			}
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 13,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)8,
				wordWrap = false,
				normal = new GUIStyleState
				{
					textColor = Color.white
				}
			};
			GUIStyle val2 = new GUIStyle(val)
			{
				normal = new GUIStyleState
				{
					textColor = Color.black
				}
			};
			float num = 400f;
			float num2 = (float)Screen.width - num - 4f;
			float num3 = val.CalcHeight(new GUIContent(text), num);
			float num4 = (float)Screen.height - num3 - 20f;
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(num2, num4, num, num3);
			GUI.Label(new Rect(((Rect)(ref val3)).x + 1f, ((Rect)(ref val3)).y + 1f, ((Rect)(ref val3)).width, ((Rect)(ref val3)).height), text, val2);
			GUI.Label(val3, text, val);
		}
	}
	internal static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "uk.1a3.lobbyimprovements";

		public const string PLUGIN_NAME = "LobbyImprovements";

		public const string PLUGIN_VERSION = "1.0.5";
	}
}
namespace LobbyImprovements.Patches
{
	[HarmonyPatch]
	public class ChatCommands
	{
		private static string defaultTeamName;

		[HarmonyPatch(typeof(SemiFunc), "Command")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void SemiFunc_Command(string _command)
		{
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_089f: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_08df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0902: Expected I4, but got Unknown
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: Invalid comparison between Unknown and I4
			//IL_09b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0984: Unknown result type (might be due to invalid IL or missing references)
			//IL_098d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			string[] array = _command.Split(' ');
			string text = ((array.Length != 0) ? array[0].ToLower() : "");
			string[] value = ((array.Length > 1) ? array[1..] : Array.Empty<string>());
			if (text == null)
			{
				return;
			}
			switch (text.Length)
			{
			case 8:
				switch (text[4])
				{
				case 'c':
				{
					if (text == "/setcash" && SemiFunc.IsMasterClientOrSingleplayer() && int.TryParse(string.Join(' ', value).ToLower(), out var result))
					{
						SemiFunc.StatSetRunCurrency(result);
						if (SemiFunc.RunIsShop())
						{
							RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)5);
						}
						else if (SemiFunc.RunIsLevel() && (int)(RoundDirector.instance?.extractionPointCurrent?.currentState).GetValueOrDefault() > 1)
						{
							RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)0);
						}
					}
					break;
				}
				case 'n':
				{
					if (!(text == "/setname") || !SemiFunc.IsMasterClientOrSingleplayer() || string.IsNullOrWhiteSpace(StatsManager.instance.saveFileCurrent))
					{
						break;
					}
					string text2 = string.Join(' ', value).Trim();
					if (!(text2 == StatsManager.instance.teamName))
					{
						if (string.IsNullOrWhiteSpace(text2))
						{
							text2 = defaultTeamName ?? "R.E.P.O.";
						}
						StatsManager.instance.teamName = text2;
						SemiFunc.SaveFileSave();
						PluginLoader.StaticLogger.LogInfo((object)("Updated name of " + StatsManager.instance.saveFileCurrent + " to " + StatsManager.instance.teamName));
					}
					break;
				}
				}
				break;
			case 9:
				switch (text[4])
				{
				case 'l':
				{
					if (text == "/setlevel" && SemiFunc.IsMasterClientOrSingleplayer() && int.TryParse(string.Join(' ', value).ToLower(), out var result2) && result2 > 0)
					{
						RunManager.instance.levelsCompleted = result2 - 1;
						SemiFunc.StatSetRunLevel(RunManager.instance.levelsCompleted);
						if (SemiFunc.RunIsShop())
						{
							RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)5);
						}
						else if (SemiFunc.RunIsLevel())
						{
							RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)0);
						}
					}
					break;
				}
				case 's':
				{
					if (!(text == "/setscene") || !SemiFunc.IsMasterClientOrSingleplayer())
					{
						break;
					}
					string levelName = string.Join(' ', value).ToLower();
					if (levelName == "recording")
					{
						RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)6);
						break;
					}
					if (levelName == "shop")
					{
						RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)5);
						break;
					}
					if (levelName == "menu")
					{
						RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)3);
						break;
					}
					if (levelName == "random")
					{
						RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)1);
						break;
					}
					List<Level> source4 = (from x in Resources.FindObjectsOfTypeAll<Level>()
						where Object.op_Implicit((Object)(object)x) && ((Object)x).name != "Level - Main Menu" && ((Object)x).name != "Level - Splash Screen" && ((Object)x).name != "Level - Tutorial"
						select x).ToList();
					RunManager.instance.debugLevel = ((IEnumerable<Level>)source4).FirstOrDefault((Func<Level, bool>)((Level x) => Regex.Replace(((Object)x).name, "^Level - ", "").ToLower() == levelName));
					if ((Object)(object)RunManager.instance.debugLevel != (Object)null)
					{
						RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)0);
						RunManager.instance.debugLevel = null;
						break;
					}
					PluginLoader.StaticLogger.LogInfo((object)("Available Levels: " + string.Join(", ", from x in source4.Select((Level x) => Regex.Replace(((Object)x).name, "^Level - ", "").ToLower()).Concat(new <>z__ReadOnlySingleElementList<string>("random"))
						orderby x
						select x)));
					break;
				}
				case 'u':
				{
					if (!(text == "/valuable") || !SemiFunc.IsMasterClientOrSingleplayer())
					{
						break;
					}
					string itemName = string.Join(' ', value).ToLower();
					List<ValuableObject> source3 = (from x in Resources.FindObjectsOfTypeAll<ValuableObject>()
						where Object.op_Implicit((Object)(object)x)
						select x).ToList();
					ValuableObject val7 = ((IEnumerable<ValuableObject>)source3).FirstOrDefault((Func<ValuableObject, bool>)((ValuableObject x) => Regex.Replace(((Object)x).name, "( |^)Valuable( |$)", "", RegexOptions.IgnoreCase).ToLower() == itemName));
					if ((Object)(object)val7 != (Object)null)
					{
						LevelPoint val8 = SemiFunc.LevelPointsGetClosestToPlayer();
						Vector3 val9 = default(Vector3);
						((Vector3)(ref val9))..ctor(((Component)val8).transform.position.x, ((Component)val8).transform.position.y + 1f, ((Component)val8).transform.position.z);
						Type volumeType = val7.volumeType;
						string text3 = (int)volumeType switch
						{
							0 => ValuableDirector.instance.tinyPath, 
							1 => ValuableDirector.instance.smallPath, 
							2 => ValuableDirector.instance.mediumPath, 
							3 => ValuableDirector.instance.bigPath, 
							4 => ValuableDirector.instance.widePath, 
							5 => ValuableDirector.instance.tallPath, 
							6 => ValuableDirector.instance.veryTallPath, 
							_ => "", 
						};
						((GameManager.instance.gameMode != 0) ? PhotonNetwork.InstantiateRoomObject(ValuableDirector.instance.resourcePath + text3 + "/" + ((Object)val7).name, val9, ((Component)val8).transform.rotation, (byte)0, (object[])null) : Object.Instantiate<GameObject>(((Component)val7).gameObject, val9, ((Component)val8).transform.rotation)).GetComponent<ValuableObject>().DollarValueSetLogic();
						PlayerController.instance.playerAvatarScript.ChatMessageSend("Spawned Valuable!");
					}
					else
					{
						PluginLoader.StaticLogger.LogInfo((object)("Available Valuables: " + string.Join(", ", from x in source3
							select Regex.Replace(((Object)x).name, "( |^)Valuable( |$)", "", RegexOptions.IgnoreCase).ToLower() into x
							orderby x
							select x)));
					}
					break;
				}
				}
				break;
			case 6:
			{
				if (!(text == "/enemy") || !SemiFunc.IsMasterClientOrSingleplayer())
				{
					break;
				}
				string enemyName = string.Join(' ', value).ToLower();
				List<EnemySetup> source2 = (from x in EnemyDirector.instance.enemiesDifficulty1.Concat(EnemyDirector.instance.enemiesDifficulty2).Concat(EnemyDirector.instance.enemiesDifficulty3)
					where Object.op_Implicit((Object)(object)x) && !((Object)x).name.Contains("Enemy Group - ")
					select x).ToList();
				EnemySetup val4 = ((IEnumerable<EnemySetup>)source2).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup x) => Regex.Replace(((Object)x).name, "^Enemy - ", "").ToLower() == enemyName));
				if ((Object)(object)val4 != (Object)null)
				{
					EnemyDirector.instance.debugSpawnClose = true;
					EnemyDirector.instance.debugNoSpawnedPause = true;
					EnemyDirector.instance.debugNoSpawnIdlePause = true;
					EnemyDirector.instance.debugEnemyEnableTime = 999f;
					EnemyDirector.instance.debugEnemyDisableTime = 3f;
					LevelPoint val5 = SemiFunc.LevelPointsGetClosestToPlayer();
					foreach (GameObject spawnObject in val4.spawnObjects)
					{
						GameObject val6 = ((GameManager.instance.gameMode != 0) ? PhotonNetwork.InstantiateRoomObject(LevelGenerator.Instance.ResourceEnemies + "/" + ((Object)spawnObject).name, ((Component)val5).transform.position, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(spawnObject, ((Component)val5).transform.position, Quaternion.identity));
						EnemyParent component = val6.GetComponent<EnemyParent>();
						if (Object.op_Implicit((Object)(object)component))
						{
							component.SetupDone = true;
							Enemy componentInChildren = val6.GetComponentInChildren<Enemy>();
							if (componentInChildren != null)
							{
								componentInChildren.EnemyTeleported(((Component)val5).transform.position);
							}
							component.firstSpawnPointUsed = true;
						}
					}
					PlayerController.instance.playerAvatarScript.ChatMessageSend("Spawned Enemy!");
				}
				else
				{
					PluginLoader.StaticLogger.LogInfo((object)("Available Enemies: " + string.Join(", ", from x in source2
						select Regex.Replace(((Object)x).name, "^Enemy - ", "").ToLower() into x
						orderby x
						select x)));
				}
				break;
			}
			case 5:
			{
				if (!(text == "/item") || !SemiFunc.IsMasterClientOrSingleplayer())
				{
					break;
				}
				string itemName2 = string.Join(' ', value).ToLower();
				List<Item> source = (from x in Resources.FindObjectsOfTypeAll<Item>()
					where Object.op_Implicit((Object)(object)x)
					select x).ToList();
				Item val = ((IEnumerable<Item>)source).FirstOrDefault((Func<Item, bool>)((Item x) => Regex.Replace(((Object)x).name, "^Item ", "").ToLower() == itemName2));
				if ((Object)(object)val != (Object)null)
				{
					LevelPoint val2 = SemiFunc.LevelPointsGetClosestToPlayer();
					Vector3 val3 = default(Vector3);
					((Vector3)(ref val3))..ctor(((Component)val2).transform.position.x, ((Component)val2).transform.position.y + 1f, ((Component)val2).transform.position.z);
					if (GameManager.instance.gameMode == 0)
					{
						Object.Instantiate<GameObject>(val.prefab, val3, ((Component)val2).transform.rotation);
					}
					else
					{
						PhotonNetwork.InstantiateRoomObject("Items/" + ((Object)val.prefab).name, val3, ((Component)val2).transform.rotation, (byte)0, (object[])null);
					}
					PlayerController.instance.playerAvatarScript.ChatMessageSend("Spawned Item!");
				}
				else
				{
					PluginLoader.StaticLogger.LogInfo((object)("Available Items: " + string.Join(", ", from x in source
						select Regex.Replace(((Object)x).name, "^Item ", "").ToLower() into x
						orderby x
						select x)));
				}
				break;
			}
			case 7:
				break;
			}
		}

		[HarmonyPatch(typeof(ChatManager), "Update")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool ChatManager_Update(ChatManager __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected I4, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			if ((int)__instance.chatState == 1 && Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)118))
			{
				string text = __instance.chatMessage + GUIUtility.systemCopyBuffer;
				__instance.chatMessage = text.Substring(0, Math.Min(text.Length, 50));
				((TMP_Text)__instance.chatText).text = __instance.chatMessage;
				((SemiUI)ChatUI.instance).SemiUITextFlashColor(Color.cyan, 0.2f);
				((SemiUI)ChatUI.instance).SemiUISpringShakeY(2f, 5f, 0.2f);
				MenuManager.instance.MenuEffectClick((MenuClickEffectType)4, (MenuPage)null, 1f, 0.2f, true);
			}
			if (SemiFunc.IsMultiplayer())
			{
				return true;
			}
			if (SemiFunc.IsMainMenu())
			{
				((SemiUI)ChatUI.instance).Hide();
			}
			__instance.PossessionActive();
			if (Object.op_Implicit((Object)(object)__instance.playerAvatar) && __instance.playerAvatar.isDisabled && (__instance.possessBatchQueue.Count > 0 || __instance.currentBatch != null))
			{
				__instance.InterruptCurrentPossessBatch();
			}
			if (!LevelGenerator.Instance.Generated)
			{
				__instance.NewLevelResets();
				return false;
			}
			__instance.ImportantFetches();
			__instance.PossessChatCustomLogic();
			if (!__instance.textMeshFetched || !__instance.localPlayerAvatarFetched)
			{
				return false;
			}
			ChatState chatState = __instance.chatState;
			switch ((int)chatState)
			{
			case 0:
				__instance.StateInactive();
				break;
			case 1:
				__instance.StateActive();
				break;
			case 2:
				__instance.StatePossessed();
				break;
			case 3:
				__instance.StateSend();
				break;
			}
			__instance.PossessChatCustomLogic();
			if (SemiFunc.IsMainMenu())
			{
				if ((int)__instance.chatState != 0)
				{
					__instance.StateSet((ChatState)0);
				}
				__instance.chatActive = false;
			}
			else
			{
				if (__instance.spamTimer > 0f)
				{
					__instance.spamTimer -= Time.deltaTime;
				}
				if (SemiFunc.FPSImpulse15() && __instance.betrayalActive && PlayerController.instance.playerAvatarScript.RoomVolumeCheck.inTruck)
				{
					__instance.PossessCancelSelfDestruction();
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(StatsManager), "Awake")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void StatsManager_Awake(StatsManager __instance)
		{
			if (defaultTeamName == null)
			{
				defaultTeamName = __instance.teamName;
			}
		}

		[HarmonyPatch(typeof(StatsManager), "ResetAllStats")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void StatsManager_ResetAllStats(StatsManager __instance)
		{
			if (defaultTeamName != null)
			{
				__instance.teamName = defaultTeamName;
			}
		}
	}
	[HarmonyPatch]
	public class FastStartup
	{
		[HarmonyPatch(typeof(MoonUI), "Check")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void MoonUI_Check(MoonUI __instance)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			if (!PluginLoader.moonPhaseUIEnabled.Value && (int)__instance.state > 0)
			{
				__instance.skip = true;
				__instance.SetState((State)8);
			}
		}

		[HarmonyPatch(typeof(RunManager), "Awake")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static void RunManager_Awake(RunManager __instance)
		{
			if (!PluginLoader.splashScreenUIEnabled.Value)
			{
				__instance.levelCurrent = __instance.levelMainMenu;
			}
		}
	}
	[HarmonyPatch]
	public class MenuPageLobbySP
	{
		[HarmonyPatch(typeof(DataDirector), "SaveDeleteCheck")]
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static bool DataDirector_SaveDeleteCheck()
		{
			return PluginLoader.saveDeleteEnabled.Value;
		}

		[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static void RunManager_ChangeLevel_Prefix(RunManager __instance, bool _completedLevel, bool _levelFailed, ChangeLevelType _changeLevelType = 0)
		{
			if (PluginLoader.singleplayerLobbyMenu.Value && !SemiFunc.IsMultiplayer() && (SemiFunc.MenuLevel() || SemiFunc.IsMasterClientOrSingleplayer()) && !__instance.restarting && _levelFailed && (Object)(object)__instance.levelCurrent == (Object)(object)__instance.levelArena)
			{
				__instance.debugLevel = __instance.levelLobbyMenu;
				PluginLoader.StaticLogger.LogInfo((object)"Setting debug level");
			}
		}

		[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void RunManager_ChangeLevel_Postfix(RunManager __instance, bool _completedLevel, bool _levelFailed, ChangeLevelType _changeLevelType = 0)
		{
			if (!SemiFunc.IsMultiplayer() && __instance.gameOver && (Object)(object)__instance.debugLevel == (Object)(object)__instance.levelLobbyMenu)
			{
				__instance.debugLevel = null;
				PluginLoader.StaticLogger.LogInfo((object)"Resetting debug level");
			}
		}

		[HarmonyPatch(typeof(SemiFunc), "MenuActionSingleplayerGame")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool SemiFunc_MenuActionSingleplayerGame(string saveFileName)
		{
			if (!PluginLoader.singleplayerLobbyMenu.Value)
			{
				return true;
			}
			RunManager.instance.ResetProgress();
			GameManager.instance.SetConnectRandom(false);
			if (saveFileName != null)
			{
				PluginLoader.StaticLogger.LogInfo((object)"Loading save");
				SemiFunc.SaveFileLoad(saveFileName);
			}
			else
			{
				SemiFunc.SaveFileCreate();
			}
			RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)3);
			return false;
		}

		[HarmonyPatch(typeof(MenuPageLobby), "Awake")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageLobby_Awake(MenuPageLobby __instance)
		{
			if (SemiFunc.IsMultiplayer())
			{
				return true;
			}
			MenuPageLobby.instance = __instance;
			__instance.menuPage = ((Component)__instance).GetComponent<MenuPage>();
			TextMeshProUGUI roomNameText = __instance.roomNameText;
			string cloudRegion = PhotonNetwork.CloudRegion;
			Room currentRoom = PhotonNetwork.CurrentRoom;
			((TMP_Text)roomNameText).text = cloudRegion + " " + ((currentRoom != null) ? currentRoom.Name : null);
			((TMP_Text)__instance.chatPromptText).text = InputManager.instance.InputDisplayReplaceTags("Press [chat] to use commands");
			return false;
		}

		[HarmonyPatch(typeof(MenuPageLobby), "Start")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageLobby_Start(MenuPageLobby __instance)
		{
			if (SemiFunc.IsMultiplayer())
			{
				return true;
			}
			((Component)__instance.inviteButton).gameObject.SetActive(false);
			return false;
		}

		[HarmonyPatch(typeof(MenuPageLobby), "ButtonStart")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageLobby_ButtonStart(MenuPageLobby __instance)
		{
			if (SemiFunc.IsMultiplayer() || __instance.joiningPlayer)
			{
				return true;
			}
			SteamManager.instance.LockLobby();
			DataDirector.instance.RunsPlayedAdd();
			if (RunManager.instance.loadLevel == 0)
			{
				RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)1);
			}
			else
			{
				RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)5);
			}
			return false;
		}
	}
	[HarmonyPatch]
	public class PlayerNamePrefix
	{
		private static bool prefixSingleRequest = true;

		private static string playerPrefixUrl = "https://api.1a3.uk/srv1/repo/prefixes.json";

		private static Dictionary<string, List<string>> playerPrefixData = new Dictionary<string, List<string>>();

		private static IEnumerator GetPlayerNamePrefixes(string[] steamIds, string logType)
		{
			steamIds = (from x in steamIds
				where Regex.IsMatch(x, "^76[0-9]{15}$")
				orderby x
				select x).ToArray();
			string text = playerPrefixUrl ?? "";
			if (steamIds.Length != 0)
			{
				text = text + "?" + string.Join("&", steamIds.Select((string id) => "id=" + id));
			}
			UnityWebRequest www = UnityWebRequest.Get(text);
			yield return www.SendWebRequest();
			string[] source = steamIds;
			SteamId steamId = SteamClient.SteamId;
			bool flag = source.Contains<string>(((object)(SteamId)(ref steamId)).ToString());
			AcceptableValueList<string> val = null;
			if ((int)www.result == 1)
			{
				try
				{
					Dictionary<string, List<string>> dictionary = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(www.downloadHandler.text);
					PluginLoader.StaticLogger.LogInfo((object)$"[GetPlayerNamePrefixes | {logType}] Successfully found prefixes for {dictionary.Count} players");
					if (steamIds.Length != 0)
					{
						foreach (KeyValuePair<string, List<string>> item in dictionary)
						{
							playerPrefixData[item.Key] = item.Value;
						}
					}
					else
					{
						playerPrefixData = dictionary;
					}
					if (!flag)
					{
						steamId = SteamClient.SteamId;
						if (dictionary.ContainsKey(((object)(SteamId)(ref steamId)).ToString()))
						{
							flag = true;
						}
					}
					if (flag)
					{
						steamId = SteamClient.SteamId;
						List<string> prefixDataForSteamId = GetPrefixDataForSteamId(((object)(SteamId)(ref steamId)).ToString());
						if (prefixDataForSteamId.Count > 0)
						{
							PluginLoader.StaticLogger.LogInfo((object)string.Format("[GetPlayerNamePrefixes | {0}] {1} has {2} prefixes: {3}", logType, SteamClient.SteamId, prefixDataForSteamId.Count, string.Join(", ", prefixDataForSteamId)));
						}
						val = new AcceptableValueList<string>(prefixDataForSteamId.Prepend("none").ToArray());
					}
				}
				catch (JsonException val2)
				{
					JsonException val3 = val2;
					PluginLoader.StaticLogger.LogError((object)("[GetPlayerNamePrefixes | " + logType + "] Failed to parse prefixes: " + ((Exception)(object)val3).Message));
				}
			}
			else
			{
				PluginLoader.StaticLogger.LogError((object)("[GetPlayerNamePrefixes | " + logType + "] Failed to fetch prefixes: " + www.error));
			}
			if (!flag)
			{
				yield break;
			}
			PluginLoader.playerNamePrefixSelected = PluginLoader.StaticConfig.Bind<string>("Name Prefix", "Selected", "none", new ConfigDescription("Which prefix would you like to use?", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			PluginLoader.playerNamePrefixSelected.SettingChanged += delegate
			{
				WorldSpaceUIParent_UpdatePlayerName(PlayerAvatar.instance);
				if (GameManager.Multiplayer())
				{
					PhotonSetCustomProperty(PhotonNetwork.LocalPlayer, "playerNamePrefix", PluginLoader.playerNamePrefixSelected?.Value);
				}
			};
		}

		public static List<string> GetPrefixDataForSteamId(string steamId)
		{
			if (playerPrefixData.TryGetValue(steamId, out var value))
			{
				return value;
			}
			return new List<string>();
		}

		public static string GetPrefixStringForPlayer(PlayerAvatar playerAvatar)
		{
			if (!Object.op_Implicit((Object)(object)playerAvatar))
			{
				return null;
			}
			string text = "";
			string text2 = "";
			string text3 = null;
			if (playerAvatar.isLocal)
			{
				text3 = PluginLoader.playerNamePrefixSelected?.Value;
			}
			else if (((Dictionary<object, object>)(object)playerAvatar.photonView.Owner.CustomProperties).ContainsKey((object)"playerNamePrefix"))
			{
				text3 = (string)playerAvatar.photonView.Owner.CustomProperties[(object)"playerNamePrefix"];
			}
			List<string> prefixDataForSteamId = GetPrefixDataForSteamId(playerAvatar.steamID);
			if (prefixDataForSteamId.Contains("developer") && text3 == "developer")
			{
				text = "<color=#ff0062>[DEV]</color> ";
			}
			else if (prefixDataForSteamId.Contains("tester") && text3 == "tester")
			{
				text = "<color=#ff8b00>[TESTER]</color> ";
			}
			if (!string.IsNullOrWhiteSpace(text))
			{
				return text + Regex.Replace(playerAvatar.playerName ?? "", "<.*?>", string.Empty) + text2;
			}
			return null;
		}

		public static void PhotonSetCustomProperty(Player photonPlayer, object key, object value)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			Hashtable customProperties = PhotonNetwork.LocalPlayer.CustomProperties;
			Hashtable val = new Hashtable();
			DictionaryEntryEnumerator enumerator = customProperties.GetEnumerator();
			try
			{
				while (((DictionaryEntryEnumerator)(ref enumerator)).MoveNext())
				{
					DictionaryEntry current = ((DictionaryEntryEnumerator)(ref enumerator)).Current;
					val[current.Key] = current.Value;
				}
			}
			finally
			{
				((IDisposable)(DictionaryEntryEnumerator)(ref enumerator)).Dispose();
			}
			val[key] = value;
			photonPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
		}

		public static void WorldSpaceUIParent_UpdatePlayerName(PlayerAvatar _player)
		{
			if (Object.op_Implicit((Object)(object)_player?.worldSpaceUIPlayerName))
			{
				string prefixStringForPlayer = GetPrefixStringForPlayer(_player);
				if (!string.IsNullOrWhiteSpace(prefixStringForPlayer))
				{
					((TMP_Text)_player.worldSpaceUIPlayerName.text).richText = true;
					((TMP_Text)_player.worldSpaceUIPlayerName.text).text = prefixStringForPlayer;
				}
				else
				{
					((TMP_Text)_player.worldSpaceUIPlayerName.text).richText = false;
					((TMP_Text)_player.worldSpaceUIPlayerName.text).text = _player.playerName;
				}
			}
		}

		[HarmonyPatch(typeof(SteamManager), "Awake")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		internal static void SteamManager_Awake(SteamManager __instance)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			if (prefixSingleRequest)
			{
				((MonoBehaviour)__instance).StartCoroutine(GetPlayerNamePrefixes(Array.Empty<string>(), "SteamManager_Awake"));
				return;
			}
			string[] array = new string[1];
			SteamId steamId = SteamClient.SteamId;
			array[0] = ((object)(SteamId)(ref steamId)).ToString();
			string[] array2 = array;
			if (array2.Length != 0)
			{
				((MonoBehaviour)__instance).StartCoroutine(GetPlayerNamePrefixes(array2, "SteamManager_Awake"));
			}
		}

		[HarmonyPatch(typeof(SteamManager), "OnLobbyEntered")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		internal static void SteamManager_OnLobbyEntered(SteamManager __instance, Lobby _lobby)
		{
			if (!prefixSingleRequest)
			{
				string[] array = ((Lobby)(ref _lobby)).Members.Select((Friend x) => ((object)(SteamId)(ref x.Id)).ToString()).Where(delegate(string x)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					SteamId steamId = SteamClient.SteamId;
					return x != ((object)(SteamId)(ref steamId)).ToString();
				}).ToArray();
				if (array.Length != 0)
				{
					((MonoBehaviour)__instance).StartCoroutine(GetPlayerNamePrefixes(array, "SteamManager_OnLobbyEntered"));
				}
			}
		}

		[HarmonyPatch(typeof(SteamManager), "OnLobbyMemberJoined")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		internal static void SteamManager_OnLobbyMemberJoined(SteamManager __instance, Lobby _lobby, Friend _friend)
		{
			if (!prefixSingleRequest)
			{
				string[] array = new string[1] { ((object)(SteamId)(ref _friend.Id)).ToString() };
				if (array.Length != 0)
				{
					((MonoBehaviour)__instance).StartCoroutine(GetPlayerNamePrefixes(array, "SteamManager_OnLobbyMemberJoined"));
				}
			}
		}

		[HarmonyPatch(typeof(PlayerAvatar), "Awake")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		internal static void PlayerAvatar_Awake(PlayerAvatar __instance)
		{
			if (SemiFunc.IsMultiplayer() && __instance.isLocal)
			{
				PhotonSetCustomProperty(PhotonNetwork.LocalPlayer, "playerNamePrefix", PluginLoader.playerNamePrefixSelected?.Value);
			}
		}

		[HarmonyPatch(typeof(MenuPageLobby), "Update")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void MenuPageLobby_Update(MenuPageLobby __instance)
		{
			foreach (GameObject listObject in __instance.listObjects)
			{
				MenuPlayerListed component = listObject.GetComponent<MenuPlayerListed>();
				PlayerAvatar playerAvatar = component.playerAvatar;
				if (Object.op_Implicit((Object)(object)playerAvatar))
				{
					TextMeshProUGUI playerName = component.playerName;
					string prefixStringForPlayer = GetPrefixStringForPlayer(playerAvatar);
					if (!string.IsNullOrWhiteSpace(prefixStringForPlayer))
					{
						((TMP_Text)playerName).richText = true;
						((TMP_Text)playerName).text = prefixStringForPlayer;
					}
					else
					{
						((TMP_Text)playerName).richText = false;
						((TMP_Text)playerName).text = playerAvatar.playerName;
					}
				}
			}
		}

		private static IEnumerator DelayedUpdatePauseMenuSliders(MenuPageEsc __instance)
		{
			yield return null;
			foreach (KeyValuePair<PlayerAvatar, MenuSliderPlayerMicGain> playerMicGainSlider in __instance.playerMicGainSliders)
			{
				PlayerAvatar key = playerMicGainSlider.Key;
				TextMeshProUGUI elementNameText = playerMicGainSlider.Value.menuSlider.elementNameText;
				string prefixStringForPlayer = GetPrefixStringForPlayer(key);
				if (!string.IsNullOrWhiteSpace(prefixStringForPlayer))
				{
					((TMP_Text)elementNameText).richText = true;
					((TMP_Text)elementNameText).text = prefixStringForPlayer;
				}
				else
				{
					((TMP_Text)elementNameText).richText = false;
					((TMP_Text)elementNameText).text = key.playerName;
				}
			}
		}

		[HarmonyPatch(typeof(MenuPageEsc), "PlayerGainSlidersUpdate")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void MenuPageEsc_PlayerGainSlidersUpdate(MenuPageEsc __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(DelayedUpdatePauseMenuSliders(__instance));
		}

		[HarmonyPatch(typeof(WorldSpaceUIParent), "PlayerName")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void WorldSpaceUIParent_PlayerName(PlayerAvatar _player)
		{
			WorldSpaceUIParent_UpdatePlayerName(_player);
		}

		[HarmonyPatch(typeof(MonoBehaviourPunCallbacks), "OnPlayerPropertiesUpdate")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		internal static void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
		{
			if (!((Dictionary<object, object>)(object)changedProps).ContainsKey((object)"playerNamePrefix"))
			{
				return;
			}
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (player.photonView.Owner == targetPlayer)
				{
					WorldSpaceUIParent_UpdatePlayerName(player);
					break;
				}
			}
		}
	}
	[HarmonyPatch]
	public class PublicLobbySaves
	{
		public static bool lobbyPublic;

		public static string saveFileCurrent;

		[HarmonyPatch(typeof(MainMenuOpen), "MainMenuSetState")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void MainMenuOpen_MainMenuSetState()
		{
			lobbyPublic = false;
			saveFileCurrent = null;
		}

		[HarmonyPatch(typeof(MenuButton), "OnSelect")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuButton_OnSelect(MenuButton __instance)
		{
			if (!PluginLoader.savePublicEnabled.Value || !lobbyPublic)
			{
				return true;
			}
			if (__instance.menuButtonPopUp.headerText == "Start a new game?" && __instance.menuButtonPopUp.bodyText == "Do you want to start a game?")
			{
				MenuPage currentMenuPage = MenuManager.instance.currentMenuPage;
				MenuPageSaves obj = ((currentMenuPage != null) ? ((Component)currentMenuPage).GetComponent<MenuPageSaves>() : null);
				if (obj != null)
				{
					obj.OnNewGame();
				}
				return !Object.op_Implicit((Object)(object)obj);
			}
			if (__instance.menuButtonPopUp.headerText == "Load save?" && __instance.menuButtonPopUp.bodyText == "Load this save file?")
			{
				MenuPage currentMenuPage2 = MenuManager.instance.currentMenuPage;
				MenuPageSaves obj2 = ((currentMenuPage2 != null) ? ((Component)currentMenuPage2).GetComponent<MenuPageSaves>() : null);
				if (obj2 != null)
				{
					obj2.OnLoadGame();
				}
				return !Object.op_Implicit((Object)(object)obj2);
			}
			return true;
		}

		[HarmonyPatch(typeof(MenuPageServerList), "ButtonCreateNew")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageServerList_ButtonCreateNew(MenuPageServerList __instance)
		{
			if (!PluginLoader.savePublicEnabled.Value || __instance.searchInProgress)
			{
				return true;
			}
			SemiFunc.MainMenuSetMultiplayer();
			lobbyPublic = true;
			MenuManager.instance.PageCloseAll();
			MenuManager.instance.PageOpen((MenuPageIndex)11, false);
			return false;
		}

		[HarmonyPatch(typeof(MenuPageSaves), "OnNewGame")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageSaves_OnNewGame(MenuPageSaves __instance)
		{
			saveFileCurrent = null;
			if (!PluginLoader.savePublicEnabled.Value || __instance.saveFiles.Count >= 10 || !SemiFunc.MainMenuIsMultiplayer() || !lobbyPublic)
			{
				return true;
			}
			MenuPage currentMenuPage = MenuManager.instance.currentMenuPage;
			((Component)MenuManager.instance.PageOpenOnTop((MenuPageIndex)15)).GetComponent<MenuPageServerListCreateNew>().menuPageParent = currentMenuPage;
			return false;
		}

		[HarmonyPatch(typeof(MenuPageSaves), "OnLoadGame")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageSaves_OnLoadGame(MenuPageSaves __instance)
		{
			if (!PluginLoader.savePublicEnabled.Value || !SemiFunc.MainMenuIsMultiplayer() || !lobbyPublic)
			{
				return true;
			}
			saveFileCurrent = StatsManager.instance.saveFileCurrent;
			MenuPage currentMenuPage = MenuManager.instance.currentMenuPage;
			((Component)MenuManager.instance.PageOpenOnTop((MenuPageIndex)15)).GetComponent<MenuPageServerListCreateNew>().menuPageParent = currentMenuPage;
			return false;
		}

		[HarmonyPatch(typeof(MenuPageServerListCreateNew), "ExitPage")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageServerListCreateNew_ExitPage(MenuPageServerListCreateNew __instance)
		{
			if (!PluginLoader.savePublicEnabled.Value)
			{
				return true;
			}
			MenuManager.instance.PageCloseAllExcept((MenuPageIndex)11);
			MenuManager.instance.PageSetCurrent((MenuPageIndex)11, __instance.menuPageParent);
			return false;
		}

		[HarmonyPatch(typeof(MenuPageSaves), "OnGoBack")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageSaves_OnGoBack(MenuPageSaves __instance)
		{
			if (!PluginLoader.savePublicEnabled.Value || !lobbyPublic)
			{
				return true;
			}
			MenuManager.instance.PageCloseAll();
			MenuManager.instance.PageOpen((MenuPageIndex)14, false);
			return false;
		}

		[HarmonyPatch(typeof(SemiFunc), "SaveFileCreate")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool SemiFunc_SaveFileCreate(NetworkConnect __instance)
		{
			if (!PluginLoader.savePublicEnabled.Value || !GameManager.instance.connectRandom || string.IsNullOrWhiteSpace(saveFileCurrent))
			{
				return true;
			}
			PluginLoader.StaticLogger.LogInfo((object)("[Public Lobby] Loading Save File: " + saveFileCurrent));
			SemiFunc.SaveFileLoad(saveFileCurrent);
			return false;
		}

		[HarmonyPatch(typeof(SemiFunc), "SaveFileSave")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void SemiFunc_SaveFileSave()
		{
			if (PluginLoader.savePublicEnabled.Value && GameManager.instance.connectRandom)
			{
				StatsManager.instance.SaveFileSave();
			}
		}

		[HarmonyPatch(typeof(DataDirector), "SaveDeleteCheck")]
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		[HarmonyWrapSafe]
		private static void DataDirector_SaveDeleteCheck_Prefix()
		{
			GameManager.instance.connectRandom = false;
		}

		[HarmonyPatch(typeof(DataDirector), "SaveDeleteCheck")]
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		[HarmonyWrapSafe]
		private static void DataDirector_SaveDeleteCheck_Postfix()
		{
			GameManager.instance.connectRandom = lobbyPublic;
		}
	}
	[HarmonyPatch]
	public class ServerListSearch
	{
		[HarmonyPatch(typeof(MenuPageServerListSearch), "Update")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static void MenuPageServerListSearch_Update(MenuPageServerListSearch __instance)
		{
			if (Input.GetKey((KeyCode)306) && Input.GetKeyDown((KeyCode)118))
			{
				string systemCopyBuffer = GUIUtility.systemCopyBuffer;
				Match match = Regex.Match(systemCopyBuffer, "steam://joinlobby/\\d+/(\\d+)/\\d+");
				if (match.Success)
				{
					string value = match.Groups[1].Value;
					MenuTextInput menuTextInput = __instance.menuTextInput;
					menuTextInput.textCurrent += value;
				}
				else
				{
					MenuTextInput menuTextInput2 = __instance.menuTextInput;
					menuTextInput2.textCurrent += systemCopyBuffer;
				}
			}
		}

		[HarmonyPatch(typeof(MenuPageServerList), "SetSearch")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageServerList_SetSearch(string _searchString)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(_searchString) && Regex.IsMatch(_searchString, "^[0-9]{17,19}$") && ulong.TryParse(_searchString, out var result))
			{
				if (SteamApps.BuildId <= 18995935)
				{
					MenuManager instance = MenuManager.instance;
					if (instance != null)
					{
						instance.PageCloseAll();
					}
					MenuManager instance2 = MenuManager.instance;
					if (instance2 != null)
					{
						instance2.PageOpen((MenuPageIndex)0, false);
					}
				}
				SteamManager.instance.OnGameLobbyJoinRequested(new Lobby(SteamId.op_Implicit(result)), SteamClient.SteamId);
				return false;
			}
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
internal sealed class <>z__ReadOnlySingleElementList<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T>
{
	private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator<T>
	{
		object IEnumerator.Current => _item;

		T IEnumerator<T>.Current => _item;

		public Enumerator(T item)
		{
			_item = item;
		}

		bool IEnumerator.MoveNext()
		{
			if (!_moveNextCalled)
			{
				return _moveNextCalled = true;
			}
			return false;
		}

		void IEnumerator.Reset()
		{
			_moveNextCalled = false;
		}

		void IDisposable.Dispose()
		{
		}
	}

	int ICollection.Count => 1;

	bool ICollection.IsSynchronized => false;

	object ICollection.SyncRoot => this;

	object IList.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	bool IList.IsFixedSize => true;

	bool IList.IsReadOnly => true;

	int IReadOnlyCollection<T>.Count => 1;

	T IReadOnlyList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
	}

	int ICollection<T>.Count => 1;

	bool ICollection<T>.IsReadOnly => true;

	T IList<T>.this[int index]
	{
		get
		{
			if (index != 0)
			{
				throw new IndexOutOfRangeException();
			}
			return _item;
		}
		set
		{
			throw new NotSupportedException();
		}
	}

	public <>z__ReadOnlySingleElementList(T item)
	{
		_item = item;
	}

	IEnumerator IEnumerable.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection.CopyTo(Array array, int index)
	{
		array.SetValue(_item, index);
	}

	int IList.Add(object value)
	{
		throw new NotSupportedException();
	}

	void IList.Clear()
	{
		throw new NotSupportedException();
	}

	bool IList.Contains(object value)
	{
		return EqualityComparer<T>.Default.Equals(_item, (T)value);
	}

	int IList.IndexOf(object value)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, (T)value))
		{
			return -1;
		}
		return 0;
	}

	void IList.Insert(int index, object value)
	{
		throw new NotSupportedException();
	}

	void IList.Remove(object value)
	{
		throw new NotSupportedException();
	}

	void IList.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}

	IEnumerator<T> IEnumerable<T>.GetEnumerator()
	{
		return new Enumerator(_item);
	}

	void ICollection<T>.Add(T item)
	{
		throw new NotSupportedException();
	}

	void ICollection<T>.Clear()
	{
		throw new NotSupportedException();
	}

	bool ICollection<T>.Contains(T item)
	{
		return EqualityComparer<T>.Default.Equals(_item, item);
	}

	void ICollection<T>.CopyTo(T[] array, int arrayIndex)
	{
		array[arrayIndex] = _item;
	}

	bool ICollection<T>.Remove(T item)
	{
		throw new NotSupportedException();
	}

	int IList<T>.IndexOf(T item)
	{
		if (!EqualityComparer<T>.Default.Equals(_item, item))
		{
			return -1;
		}
		return 0;
	}

	void IList<T>.Insert(int index, T item)
	{
		throw new NotSupportedException();
	}

	void IList<T>.RemoveAt(int index)
	{
		throw new NotSupportedException();
	}
}