Decompiled source of LobbyImprovements REPO v1.1.2

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

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
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.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using LobbyImprovements.Patches;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using Steamworks.Data;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[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.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+5dd64629bc70d57112b6b650becf9e0776ddda1b")]
[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
{
	public class ObjectScreenshotTaker : MonoBehaviour
	{
		private enum ScreenshotTypes
		{
			None,
			Modules,
			Enemies,
			Items,
			Valuables
		}

		[CompilerGenerated]
		private sealed class <TakeScreenshotsCoroutine>d__21 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ObjectScreenshotTaker <>4__this;

			public string ssType;

			public GameObject[] modules;

			private GameObject[] <>7__wrap1;

			private int <>7__wrap2;

			private GameObject <module>5__4;

			private string <fileName>5__5;

			private bool <useCollisionsForBounds>5__6;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TakeScreenshotsCoroutine>d__21(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>7__wrap1 = null;
				<module>5__4 = null;
				<fileName>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0594: Unknown result type (might be due to invalid IL or missing references)
				//IL_0599: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_061a: Unknown result type (might be due to invalid IL or missing references)
				//IL_061f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0623: Unknown result type (might be due to invalid IL or missing references)
				//IL_0628: Unknown result type (might be due to invalid IL or missing references)
				//IL_063c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0641: Unknown result type (might be due to invalid IL or missing references)
				//IL_03be: Unknown result type (might be due to invalid IL or missing references)
				//IL_068f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0694: Unknown result type (might be due to invalid IL or missing references)
				//IL_0698: Unknown result type (might be due to invalid IL or missing references)
				//IL_069d: Unknown result type (might be due to invalid IL or missing references)
				//IL_06d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_052f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0314: Unknown result type (might be due to invalid IL or missing references)
				//IL_031e: Expected O, but got Unknown
				//IL_071c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0721: Unknown result type (might be due to invalid IL or missing references)
				//IL_0725: Unknown result type (might be due to invalid IL or missing references)
				//IL_072a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0741: Unknown result type (might be due to invalid IL or missing references)
				//IL_091a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0924: Expected O, but got Unknown
				//IL_0496: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a0: Expected O, but got Unknown
				//IL_036a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0374: Expected O, but got Unknown
				//IL_08fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_08d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_090f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_0207: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				ObjectScreenshotTaker objectScreenshotTaker = <>4__this;
				Bounds val;
				float num2;
				Vector3 val2;
				Vector3 val3;
				float num3;
				float num4;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (!Directory.Exists(objectScreenshotTaker.SavePath + "/" + ssType))
					{
						Directory.CreateDirectory(objectScreenshotTaker.SavePath + "/" + ssType);
					}
					<>7__wrap1 = modules;
					<>7__wrap2 = 0;
					goto IL_0997;
				case 1:
					<>1__state = -1;
					<useCollisionsForBounds>5__6 = false;
					if (ssType == "Enemies")
					{
						Enemy componentInChildren = objectScreenshotTaker.moduleObject.GetComponentInChildren<Enemy>();
						if (componentInChildren != null)
						{
							componentInChildren.Freeze(7f);
						}
						if (((Object)<module>5__4).name != "Enemy - Beamer" && ((Object)<module>5__4).name != "Enemy - Slow Walker" && ((Object)<module>5__4).name != "Enemy - Upscream")
						{
							<useCollisionsForBounds>5__6 = true;
						}
						if (((Object)<module>5__4).name == "Enemy - Floater" || ((Object)<module>5__4).name == "Enemy - Runner" || ((Object)<module>5__4).name == "Enemy - Slow Walker" || ((Object)<module>5__4).name == "Enemy - Tumbler")
						{
							<>2__current = (object)new WaitForSeconds(1f);
							<>1__state = 2;
							return true;
						}
						if (((Object)<module>5__4).name == "Enemy - Hidden" || ((Object)<module>5__4).name == "Enemy - Hunter")
						{
							<>2__current = (object)new WaitForSeconds(5f);
							<>1__state = 3;
							return true;
						}
					}
					else if (ssType == "Items")
					{
						Rigidbody component = objectScreenshotTaker.moduleObject.GetComponent<Rigidbody>();
						if (Object.op_Implicit((Object)(object)component))
						{
							component.useGravity = false;
							component.velocity = Vector3.zero;
							component.constraints = (RigidbodyConstraints)126;
						}
						PhysGrabObjectImpactDetector component2 = objectScreenshotTaker.moduleObject.GetComponent<PhysGrabObjectImpactDetector>();
						if (Object.op_Implicit((Object)(object)component2) && !component2.particleDisable)
						{
							component2.particleDisable = true;
						}
						if (((Object)<module>5__4).name == "Item Cart Cannon" || ((Object)<module>5__4).name == "Item Cart Laser")
						{
							ItemCartCannonMain component3 = objectScreenshotTaker.moduleObject.GetComponent<ItemCartCannonMain>();
							if (component3 != null)
							{
								ItemBattery battery = component3.battery;
								if (battery != null)
								{
									BatteryVisualLogic batteryVisualLogic = battery.batteryVisualLogic;
									if (batteryVisualLogic != null)
									{
										((Component)batteryVisualLogic).gameObject.SetActive(false);
									}
								}
							}
						}
						<useCollisionsForBounds>5__6 = true;
						if (((Object)<module>5__4).name == "Item Melee Baseball Bat" || ((Object)<module>5__4).name == "Item Melee Frying Pan")
						{
							<>2__current = (object)new WaitForSeconds(1f);
							<>1__state = 4;
							return true;
						}
					}
					else if (ssType == "Modules")
					{
						PhysGrabObject[] array = Object.FindObjectsOfType<PhysGrabObject>();
						foreach (PhysGrabObject val4 in array)
						{
							if (!val4.hasHinge)
							{
								val4.DestroyPhysGrabObject();
							}
						}
					}
					else if (ssType == "Valuables")
					{
						Rigidbody component4 = objectScreenshotTaker.moduleObject.GetComponent<Rigidbody>();
						if (Object.op_Implicit((Object)(object)component4))
						{
							component4.useGravity = false;
							component4.velocity = Vector3.zero;
							component4.constraints = (RigidbodyConstraints)126;
						}
						PhysGrabObjectImpactDetector component5 = objectScreenshotTaker.moduleObject.GetComponent<PhysGrabObjectImpactDetector>();
						if (Object.op_Implicit((Object)(object)component5) && !component5.particleDisable)
						{
							component5.particleDisable = true;
						}
						if (((Object)<module>5__4).name == "Valuable Gumball")
						{
							<useCollisionsForBounds>5__6 = true;
						}
					}
					goto IL_0587;
				case 2:
					<>1__state = -1;
					goto IL_0587;
				case 3:
					<>1__state = -1;
					goto IL_0587;
				case 4:
					<>1__state = -1;
					goto IL_0587;
				case 5:
					{
						<>1__state = -1;
						objectScreenshotTaker.TakeScreenshot(<fileName>5__5);
						PluginLoader.StaticLogger.LogDebug((object)("Screenshot saved: " + <fileName>5__5));
						Object.Destroy((Object)(object)objectScreenshotTaker.moduleObject);
						if (Time.timeScale == 0f)
						{
							Time.timeScale = 1f;
						}
						<fileName>5__5 = null;
						<module>5__4 = null;
						goto IL_0989;
					}
					IL_0587:
					val = objectScreenshotTaker.CalculateBounds(objectScreenshotTaker.moduleObject, <useCollisionsForBounds>5__6);
					num2 = Mathf.Max(new float[3]
					{
						((Bounds)(ref val)).size.x,
						((Bounds)(ref val)).size.y,
						((Bounds)(ref val)).size.z
					});
					objectScreenshotTaker.ScreenshotCamera.orthographic = !((Object)<module>5__4).name.StartsWith("Enemy Valuable - ");
					objectScreenshotTaker.ScreenshotCamera.orthographicSize = num2 * 0.8f;
					val2 = new Vector3(1f, 1f, -1f);
					val3 = ((Vector3)(ref val2)).normalized;
					if (ssType == "Enemies")
					{
						val3 = Vector3.forward;
					}
					else if ((ssType == "Items" && ((Object)<module>5__4).name.StartsWith("Item Upgrade ")) || ssType == "Valuables")
					{
						val2 = new Vector3(1f, 1f, 1f);
						val3 = ((Vector3)(ref val2)).normalized;
					}
					num3 = 1f;
					if (ssType == "Items")
					{
						num3 = 0.75f;
					}
					num4 = num2 * num3;
					((Component)objectScreenshotTaker.ScreenshotCamera).transform.position = ((Bounds)(ref val)).center + val3 * num4;
					((Component)objectScreenshotTaker.ScreenshotCamera).transform.LookAt(((Bounds)(ref val)).center);
					if (Object.op_Implicit((Object)(object)objectScreenshotTaker.ScreenshotLight))
					{
						((Component)objectScreenshotTaker.ScreenshotLight).transform.position = ((Bounds)(ref val)).center + val3 * num4;
						((Component)objectScreenshotTaker.ScreenshotLight).transform.LookAt(((Bounds)(ref val)).center);
					}
					if (ssType != "Modules")
					{
						if (Object.op_Implicit((Object)(object)objectScreenshotTaker.ScreenshotLight))
						{
							if (ssType == "Valuables" && (((Object)<module>5__4).name == "Valuable Goblet" || ((Object)<module>5__4).name == "Valuable GoldFish" || ((Object)<module>5__4).name == "Valuable GoldTooth" || ((Object)<module>5__4).name == "Valuable Piano" || ((Object)<module>5__4).name == "Valuable SilverFish" || ((Object)<module>5__4).name == "Valuable Trophy" || ((Object)<module>5__4).name == "Valuable Wizard Griffin Statue" || ((Object)<module>5__4).name == "Valuable Wizard Master Potion" || ((Object)<module>5__4).name == "Valuable Wizard Sword"))
							{
								((Behaviour)objectScreenshotTaker.ScreenshotLight).enabled = true;
							}
							else
							{
								((Behaviour)objectScreenshotTaker.ScreenshotLight).enabled = false;
							}
						}
						if ((ssType == "Enemies" && ((Object)<module>5__4).name == "Enemy - Gnome") || (ssType == "Items" && ((Object)<module>5__4).name == "Item Duck Bucket"))
						{
							objectScreenshotTaker.ambientLight = new Color(0.5f, 0.5f, 0.5f);
						}
						else
						{
							objectScreenshotTaker.ambientLight = new Color(1f, 1f, 1f);
						}
						RenderSettings.ambientLight = objectScreenshotTaker.ambientLight.Value;
					}
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 5;
					return true;
					IL_0989:
					<>7__wrap2++;
					goto IL_0997;
					IL_0997:
					if (<>7__wrap2 < <>7__wrap1.Length)
					{
						<module>5__4 = <>7__wrap1[<>7__wrap2];
						if (Object.op_Implicit((Object)(object)<module>5__4) && (!(ssType == "Modules") || !((Object)<module>5__4).name.StartsWith("Start Room - Shop")))
						{
							string text = ((Object)<module>5__4).name;
							if (ssType == "Enemies")
							{
								text = ((Object)<module>5__4).name.Replace("Enemy - ", "");
							}
							else if (ssType == "Modules")
							{
								text = Regex.Replace(((Object)<module>5__4).name, " - [0-9]+ - ", " - ");
							}
							<fileName>5__5 = objectScreenshotTaker.SavePath + "/" + ssType + "/" + text + ".png";
							if (!File.Exists(<fileName>5__5))
							{
								string objectResourcePathForMP = objectScreenshotTaker.GetObjectResourcePathForMP(ssType, <module>5__4);
								if (!string.IsNullOrWhiteSpace(objectResourcePathForMP))
								{
									if (ssType == "Valuables" && ((Object)<module>5__4).name.StartsWith("Surplus Valuable - "))
									{
										Time.timeScale = 0f;
									}
									objectScreenshotTaker.moduleObject = ((GameManager.instance.gameMode != 0) ? PhotonNetwork.InstantiateRoomObject(objectResourcePathForMP, Vector3.zero, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(<module>5__4, Vector3.zero, Quaternion.identity));
									<>2__current = null;
									<>1__state = 1;
									return true;
								}
							}
						}
						goto IL_0989;
					}
					<>7__wrap1 = null;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <TakeScreenshotsOfEnemies>d__15 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ObjectScreenshotTaker <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TakeScreenshotsOfEnemies>d__15(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Expected O, but got Unknown
				int num = <>1__state;
				ObjectScreenshotTaker objectScreenshotTaker = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					objectScreenshotTaker.screenshotType = ScreenshotTypes.Enemies;
					objectScreenshotTaker.ScreenshotStart();
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					List<GameObject> source = (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 ((IEnumerable<GameObject>)x.spawnObjects).FirstOrDefault((Func<GameObject, bool>)((GameObject o) => !((Object)o).name.Contains("Director")))).ToList();
					<>2__current = ((MonoBehaviour)objectScreenshotTaker).StartCoroutine(objectScreenshotTaker.TakeScreenshotsCoroutine((from x in source.Distinct()
						orderby ((Object)x).name
						select x).ToArray(), "Enemies", "Enemies"));
					<>1__state = 2;
					return true;
				}
				case 2:
					<>1__state = -1;
					objectScreenshotTaker.ScreenshotEnd();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <TakeScreenshotsOfItems>d__16 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ObjectScreenshotTaker <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TakeScreenshotsOfItems>d__16(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Expected O, but got Unknown
				int num = <>1__state;
				ObjectScreenshotTaker objectScreenshotTaker = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					objectScreenshotTaker.screenshotType = ScreenshotTypes.Items;
					objectScreenshotTaker.ScreenshotStart();
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					List<Item> source = (from x in Resources.FindObjectsOfTypeAll<Item>()
						where Object.op_Implicit((Object)(object)x) && Object.op_Implicit((Object)(object)x.prefab)
						select x).ToList();
					<>2__current = ((MonoBehaviour)objectScreenshotTaker).StartCoroutine(objectScreenshotTaker.TakeScreenshotsCoroutine((from x in source
						orderby ((Object)x).name
						select x.prefab).Distinct().ToArray(), "Items", "Items"));
					<>1__state = 2;
					return true;
				}
				case 2:
					<>1__state = -1;
					objectScreenshotTaker.ScreenshotEnd();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <TakeScreenshotsOfModules>d__17 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ObjectScreenshotTaker <>4__this;

			private List<Level> <levels>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TakeScreenshotsOfModules>d__17(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<levels>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Expected O, but got Unknown
				int num = <>1__state;
				ObjectScreenshotTaker objectScreenshotTaker = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					objectScreenshotTaker.screenshotType = ScreenshotTypes.Modules;
					objectScreenshotTaker.ScreenshotStart();
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<levels>5__2 = (from x in Resources.FindObjectsOfTypeAll<Level>()
						where Object.op_Implicit((Object)(object)x) && ((Object)x).name != "Level - Lobby" && ((Object)x).name != "Level - Lobby Menu" && ((Object)x).name != "Level - Main Menu" && ((Object)x).name != "Level - Splash Screen"
						select x).ToList();
					<>2__current = ((MonoBehaviour)objectScreenshotTaker).StartCoroutine(objectScreenshotTaker.TakeScreenshotsCoroutine((from x in (from x in <levels>5__2.SelectMany((Level x) => x.StartRooms)
							where Object.op_Implicit((Object)(object)x)
							select x).Distinct()
						orderby ((Object)x).name
						select x).ToArray(), "StartRoom", "Modules"));
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)objectScreenshotTaker).StartCoroutine(objectScreenshotTaker.TakeScreenshotsCoroutine((from x in (from x in <levels>5__2.SelectMany((Level x) => x.ModulesNormal1.Concat(x.ModulesNormal2).Concat(x.ModulesNormal3))
							where Object.op_Implicit((Object)(object)x)
							select x).Distinct()
						orderby ((Object)x).name
						select x).ToArray(), "Normal", "Modules"));
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)objectScreenshotTaker).StartCoroutine(objectScreenshotTaker.TakeScreenshotsCoroutine((from x in (from x in <levels>5__2.SelectMany((Level x) => x.ModulesPassage1.Concat(x.ModulesPassage2).Concat(x.ModulesPassage3))
							where Object.op_Implicit((Object)(object)x)
							select x).Distinct()
						orderby ((Object)x).name
						select x).ToArray(), "Passage", "Modules"));
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)objectScreenshotTaker).StartCoroutine(objectScreenshotTaker.TakeScreenshotsCoroutine((from x in (from x in <levels>5__2.SelectMany((Level x) => x.ModulesDeadEnd1.Concat(x.ModulesDeadEnd2).Concat(x.ModulesDeadEnd3))
							where Object.op_Implicit((Object)(object)x)
							select x).Distinct()
						orderby ((Object)x).name
						select x).ToArray(), "DeadEnd", "Modules"));
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)objectScreenshotTaker).StartCoroutine(objectScreenshotTaker.TakeScreenshotsCoroutine((from x in (from x in <levels>5__2.SelectMany((Level x) => x.ModulesExtraction1.Concat(x.ModulesExtraction2).Concat(x.ModulesExtraction3))
							where Object.op_Implicit((Object)(object)x)
							select x).Distinct()
						orderby ((Object)x).name
						select x).ToArray(), "Extraction", "Modules"));
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -1;
					objectScreenshotTaker.ScreenshotEnd();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <TakeScreenshotsOfValuables>d__18 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ObjectScreenshotTaker <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <TakeScreenshotsOfValuables>d__18(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Expected O, but got Unknown
				int num = <>1__state;
				ObjectScreenshotTaker objectScreenshotTaker = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					objectScreenshotTaker.screenshotType = ScreenshotTypes.Valuables;
					objectScreenshotTaker.ScreenshotStart();
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					List<ValuableObject> source = (from x in (from x in RunManager.instance.levels.SelectMany((Level x) => x.ValuablePresets.SelectMany((LevelValuables p) => p.tiny.Concat(p.small).Concat(p.medium).Concat(p.big)
								.Concat(p.wide)
								.Concat(p.tall)
								.Concat(p.veryTall)))
							select x.GetComponent<ValuableObject>()).Concat(from item in Resources.FindObjectsOfTypeAll<ValuableObject>()
							where ((Object)item).name.StartsWith("Enemy Valuable - ") || ((Object)item).name.StartsWith("Surplus Valuable - ")
							select item)
						where Object.op_Implicit((Object)(object)x) && Object.op_Implicit((Object)(object)((Component)x).gameObject)
						select x).ToList();
					<>2__current = ((MonoBehaviour)objectScreenshotTaker).StartCoroutine(objectScreenshotTaker.TakeScreenshotsCoroutine((from x in source
						orderby ((Object)x).name
						select ((Component)x).gameObject).Distinct().ToArray(), "Valuables", "Valuables"));
					<>1__state = 2;
					return true;
				}
				case 2:
					<>1__state = -1;
					objectScreenshotTaker.ScreenshotEnd();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private readonly string SavePath = "Screenshots";

		internal static ObjectScreenshotTaker instance;

		internal bool isTakingScreenshots;

		private Camera ScreenshotCamera;

		private Light ScreenshotLight;

		private GameObject moduleObject;

		private RenderTexture renderTexture;

		private Texture2D screenshot;

		private Color? ambientLight;

		private ScreenshotTypes screenshotType;

		private void Awake()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)instance))
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			instance = this;
			if ((Object)(object)ScreenshotCamera == (Object)null)
			{
				ScreenshotCamera = ((Component)this).gameObject.AddComponent<Camera>();
				ScreenshotCamera.CopyFrom(Camera.main);
				((Object)ScreenshotCamera).name = "ScreenshotCamera";
				ScreenshotCamera.cullingMask = -4129;
				ScreenshotCamera.farClipPlane = 2000f;
				((Behaviour)ScreenshotCamera).enabled = false;
				ScreenshotCamera.clearFlags = (CameraClearFlags)2;
				ScreenshotCamera.backgroundColor = new Color(0f, 0f, 0f, 0f);
			}
			if ((Object)(object)ScreenshotLight == (Object)null)
			{
				Light spotlight = PlayerAvatar.instance.flashlightController.spotlight;
				GameObject val = new GameObject("ScreenshotLight");
				ScreenshotLight = val.AddComponent<Light>();
				ScreenshotLight.type = spotlight.type;
				ScreenshotLight.color = spotlight.color;
				ScreenshotLight.intensity = spotlight.intensity;
				ScreenshotLight.range = 100f;
				ScreenshotLight.spotAngle = 100f;
				ScreenshotLight.shadows = spotlight.shadows;
				ScreenshotLight.cookie = spotlight.cookie;
				ScreenshotLight.cookieSize = spotlight.cookieSize;
				ScreenshotLight.renderMode = spotlight.renderMode;
				((Behaviour)ScreenshotLight).enabled = false;
			}
			if (!Directory.Exists(SavePath))
			{
				Directory.CreateDirectory(SavePath);
			}
			GameObject gameObject = ((Component)LevelGenerator.Instance.LevelParent.GetComponentInChildren<StartRoom>()).gameObject;
			PhysGrabObject[] array = Object.FindObjectsOfType<PhysGrabObject>();
			for (int i = 0; i < array.Length; i++)
			{
				array[i].DestroyPhysGrabObject();
			}
			Light[] componentsInChildren = ((Component)gameObject.transform).GetComponentsInChildren<Light>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Behaviour)componentsInChildren[i]).enabled = false;
			}
			Renderer[] componentsInChildren2 = ((Component)gameObject.transform).GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				componentsInChildren2[i].enabled = false;
			}
			Canvas[] componentsInChildren3 = ((Component)gameObject.transform.Find("Truck/Truck Run")).GetComponentsInChildren<Canvas>();
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				((Behaviour)componentsInChildren3[i]).enabled = false;
			}
			componentsInChildren = ((Component)PlayerAvatar.instance).GetComponentsInChildren<Light>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				((Behaviour)componentsInChildren[i]).enabled = false;
			}
			componentsInChildren2 = ((Component)PlayerAvatar.instance).GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				componentsInChildren2[i].enabled = false;
			}
		}

		private void OnDestroy()
		{
			PluginLoader.StaticLogger.LogInfo((object)"[ModuleScreenshotTaker] Destroying...");
			if (Object.op_Implicit((Object)(object)ScreenshotLight))
			{
				Object.Destroy((Object)(object)((Component)ScreenshotLight).gameObject);
			}
		}

		private void ScreenshotStart()
		{
			isTakingScreenshots = true;
			PlayerAvatar.instance.flashlightController.hideFlashlight = true;
			PluginLoader.StaticLogger.LogInfo((object)"[ModuleScreenshotTaker] Starting");
		}

		private void ScreenshotEnd()
		{
			if (Object.op_Implicit((Object)(object)ScreenshotLight))
			{
				((Behaviour)ScreenshotLight).enabled = false;
			}
			PlayerAvatar.instance.flashlightController.hideFlashlight = false;
			ambientLight = null;
			EnvironmentDirector.Instance.DarkAdaptationLerp = ((!FlashlightController.Instance.LightActive) ? 0.01f : 0.99f);
			isTakingScreenshots = false;
			PluginLoader.StaticLogger.LogInfo((object)"[ModuleScreenshotTaker] Finished");
			if (Object.op_Implicit((Object)(object)ScreenshotLight))
			{
				Object.Destroy((Object)(object)((Component)ScreenshotLight).gameObject);
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		[IteratorStateMachine(typeof(<TakeScreenshotsOfEnemies>d__15))]
		internal IEnumerator TakeScreenshotsOfEnemies()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TakeScreenshotsOfEnemies>d__15(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<TakeScreenshotsOfItems>d__16))]
		internal IEnumerator TakeScreenshotsOfItems()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TakeScreenshotsOfItems>d__16(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<TakeScreenshotsOfModules>d__17))]
		internal IEnumerator TakeScreenshotsOfModules()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TakeScreenshotsOfModules>d__17(0)
			{
				<>4__this = this
			};
		}

		[IteratorStateMachine(typeof(<TakeScreenshotsOfValuables>d__18))]
		internal IEnumerator TakeScreenshotsOfValuables()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TakeScreenshotsOfValuables>d__18(0)
			{
				<>4__this = this
			};
		}

		private Bounds CalculateBounds(GameObject go, bool useColliders = false)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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 (useColliders)
			{
				Collider[] array = (from r in go.GetComponentsInChildren<Collider>(true)
					where r.enabled && ((Component)r).gameObject.activeInHierarchy && !r.isTrigger
					select r).ToArray();
				if (array.Length != 0)
				{
					Bounds bounds = array[0].bounds;
					for (int i = 1; i < array.Length; i++)
					{
						((Bounds)(ref bounds)).Encapsulate(array[i].bounds);
					}
					return bounds;
				}
			}
			Renderer[] array2 = (from r in go.GetComponentsInChildren<Renderer>(true)
				where r.enabled && ((Component)r).gameObject.activeInHierarchy
				select r).ToArray();
			if (array2.Length != 0)
			{
				Bounds bounds2 = array2[0].bounds;
				for (int j = 1; j < array2.Length; j++)
				{
					((Bounds)(ref bounds2)).Encapsulate(array2[j].bounds);
				}
				return bounds2;
			}
			PluginLoader.StaticLogger.LogWarning((object)("No renderers found for " + ((Object)go).name));
			return new Bounds(go.transform.position, Vector3.one);
		}

		private string GetObjectResourcePathForMP(string ssType, GameObject targetObject)
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected I4, but got Unknown
			if (!SemiFunc.IsMultiplayer())
			{
				return ((Object)targetObject).name;
			}
			switch (ssType)
			{
			case "Enemies":
				return LevelGenerator.Instance.ResourceEnemies + "/" + ((Object)targetObject).name;
			case "Items":
				return "Items/" + ((Object)targetObject).name;
			case "Modules":
				return LevelGenerator.Instance.ResourceParent + "/" + LevelGenerator.Instance.Level.ResourcePath + "/" + LevelGenerator.Instance.ResourceModules + "/" + ((Object)targetObject).name;
			case "Valuables":
			{
				string text = "";
				ValuableObject component = targetObject.GetComponent<ValuableObject>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Type volumeType = component.volumeType;
					text = (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 + "/", 
						_ => "", 
					};
					if (((Object)targetObject).name.StartsWith("Enemy Valuable - ") || ((Object)targetObject).name.StartsWith("Surplus Valuable - "))
					{
						text = "";
					}
				}
				return ValuableDirector.instance.resourcePath + text + ((Object)targetObject).name;
			}
			default:
				return null;
			}
		}

		[IteratorStateMachine(typeof(<TakeScreenshotsCoroutine>d__21))]
		private IEnumerator TakeScreenshotsCoroutine(GameObject[] modules, string category, string ssType)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TakeScreenshotsCoroutine>d__21(0)
			{
				<>4__this = this,
				modules = modules,
				ssType = ssType
			};
		}

		private void TakeScreenshot(string filePath)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			renderTexture = new RenderTexture(1920, 1920, 32, (RenderTextureFormat)0);
			ScreenshotCamera.targetTexture = renderTexture;
			ScreenshotCamera.Render();
			RenderTexture.active = renderTexture;
			screenshot = new Texture2D(((Texture)renderTexture).width, ((Texture)renderTexture).height, (TextureFormat)4, false);
			screenshot.ReadPixels(new Rect(0f, 0f, (float)((Texture)renderTexture).width, (float)((Texture)renderTexture).height), 0, 0);
			screenshot.Apply();
			byte[] bytes = ImageConversion.EncodeToPNG(screenshot);
			File.WriteAllBytes(filePath, bytes);
			ScreenshotCamera.targetTexture = null;
			RenderTexture.active = null;
			Object.Destroy((Object)(object)renderTexture);
			Object.Destroy((Object)(object)screenshot);
		}

		private void LateUpdate()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (isTakingScreenshots && ambientLight.HasValue)
			{
				RenderSettings.ambientLight = ambientLight.Value;
			}
		}
	}
	[BepInPlugin("uk.1a3.lobbyimprovements", "LobbyImprovements", "1.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	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 ConfigEntry<bool> mainMenuOverhaulEnabled;

		internal static bool mainMenuOverhaul;

		internal static ManualLogSource StaticLogger { get; private set; }

		internal static ConfigFile StaticConfig { get; private set; }

		private void Awake()
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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));
				if (playerNamePrefixSelected == null)
				{
					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", true, "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));
			}
			mainMenuOverhaulEnabled = StaticConfig.Bind<bool>("Main Menu", "Improved Layout", false, "Reduces the number of clicks to access some parts of the main menu.");
			if (Chainloader.PluginInfos.ContainsKey("nickklmao.menulib"))
			{
				try
				{
					harmony.PatchAll(typeof(MenuPageV2));
				}
				catch (Exception ex7)
				{
					StaticLogger.LogError((object)("MenuPageV2 Patch Failed: " + ex7));
				}
			}
			else if (mainMenuOverhaulEnabled.Value)
			{
				StaticLogger.LogWarning((object)"The 'Improved Layout' of the main menu requires the MenuLib mod. Please install it if you wish to use that feature.");
			}
			StaticLogger.LogInfo((object)"Patches Loaded");
		}

		private static void SetupTesterOverlay(bool _enabled)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			GameObject val = GameObject.Find("TesterOverlay");
			if (_enabled && (Object)(object)val == (Object)null && !Debug.isDebugBuild)
			{
				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.1.2";
	}
}
namespace LobbyImprovements.Patches
{
	[HarmonyPatch]
	public class ChatCommands
	{
		internal static string defaultTeamName;

		public static LevelPoint LevelPointsGetClosestToLocalPlayer()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar val = ((!SemiFunc.IsSpectating() || !Object.op_Implicit((Object)(object)SpectateCamera.instance.player)) ? PlayerAvatar.instance : SpectateCamera.instance.player);
			if ((Object)(object)val != (Object)null)
			{
				List<LevelPoint> list = SemiFunc.LevelPointsGetAll();
				float num = 999f;
				LevelPoint result = null;
				Vector3 position = ((Component)val).transform.position;
				{
					foreach (LevelPoint item in list)
					{
						float num2 = Vector3.Distance(position, ((Component)item).transform.position);
						if (num2 < num)
						{
							num = num2;
							result = item;
						}
					}
					return result;
				}
			}
			return SemiFunc.LevelPointsGetClosestToPlayer();
		}

		private static bool ExecuteCommand(string _command)
		{
			//IL_0b20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b25: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Invalid comparison between Unknown and I4
			//IL_07f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0808: Unknown result type (might be due to invalid IL or missing references)
			//IL_081f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0830: Unknown result type (might be due to invalid IL or missing references)
			//IL_0835: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Unknown result type (might be due to invalid IL or missing references)
			//IL_085a: Expected I4, but got Unknown
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0982: Unknown result type (might be due to invalid IL or missing references)
			//IL_098b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0955: Unknown result type (might be due to invalid IL or missing references)
			//IL_095e: 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 (!Debug.isDebugBuild)
			{
				switch (text)
				{
				case "/enemy":
				{
					if (!SemiFunc.IsMasterClientOrSingleplayer())
					{
						break;
					}
					string enemyName = string.Join(' ', value).ToLower();
					List<EnemySetup> source4 = (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 val7 = ((IEnumerable<EnemySetup>)source4).FirstOrDefault((Func<EnemySetup, bool>)((EnemySetup x) => Regex.Replace(((Object)x).name, "^Enemy - ", "").ToLower() == enemyName));
					if ((Object)(object)val7 != (Object)null)
					{
						EnemyDirector.instance.debugSpawnClose = true;
						EnemyDirector.instance.debugNoSpawnedPause = true;
						EnemyDirector.instance.debugNoSpawnIdlePause = true;
						EnemyDirector.instance.debugEnemyEnableTime = 999f;
						EnemyDirector.instance.debugEnemyDisableTime = 3f;
						LevelPoint val8 = LevelPointsGetClosestToLocalPlayer();
						foreach (GameObject spawnObject in val7.spawnObjects)
						{
							GameObject val9 = ((GameManager.instance.gameMode != 0) ? PhotonNetwork.InstantiateRoomObject(LevelGenerator.Instance.ResourceEnemies + "/" + ((Object)spawnObject).name, ((Component)val8).transform.position, Quaternion.identity, (byte)0, (object[])null) : Object.Instantiate<GameObject>(spawnObject, ((Component)val8).transform.position, Quaternion.identity));
							EnemyParent component = val9.GetComponent<EnemyParent>();
							if (Object.op_Implicit((Object)(object)component))
							{
								component.SetupDone = true;
								Enemy componentInChildren = val9.GetComponentInChildren<Enemy>();
								if (componentInChildren != null)
								{
									componentInChildren.EnemyTeleported(((Component)val8).transform.position);
								}
								component.firstSpawnPointUsed = true;
							}
						}
						PlayerAvatar.instance.ChatMessageSpeak("Spawned Enemy", PlayerAvatar.instance.isCrouching);
						return true;
					}
					PluginLoader.StaticLogger.LogInfo((object)("Available Enemies: " + string.Join(", ", from x in source4
						select Regex.Replace(((Object)x).name, "^Enemy - ", "").ToLower() into x
						orderby x
						select x)));
					break;
				}
				case "/item":
				{
					if (!SemiFunc.IsMasterClientOrSingleplayer())
					{
						break;
					}
					string itemName = string.Join(' ', value).ToLower();
					List<Item> source2 = (from x in Resources.FindObjectsOfTypeAll<Item>()
						where Object.op_Implicit((Object)(object)x)
						select x).ToList();
					Item val4 = ((IEnumerable<Item>)source2).FirstOrDefault((Func<Item, bool>)((Item x) => Regex.Replace(((Object)x).name, "^Item ", "").ToLower() == itemName));
					if ((Object)(object)val4 != (Object)null)
					{
						LevelPoint val5 = LevelPointsGetClosestToLocalPlayer();
						Vector3 val6 = default(Vector3);
						((Vector3)(ref val6))..ctor(((Component)val5).transform.position.x, ((Component)val5).transform.position.y + 1f, ((Component)val5).transform.position.z);
						if (GameManager.instance.gameMode == 0)
						{
							Object.Instantiate<GameObject>(val4.prefab, val6, ((Component)val5).transform.rotation);
						}
						else
						{
							PhotonNetwork.InstantiateRoomObject("Items/" + ((Object)val4.prefab).name, val6, ((Component)val5).transform.rotation, (byte)0, (object[])null);
						}
						PlayerAvatar.instance.ChatMessageSpeak("Spawned Item", PlayerAvatar.instance.isCrouching);
						return true;
					}
					PluginLoader.StaticLogger.LogInfo((object)("Available Items: " + string.Join(", ", from x in source2
						select Regex.Replace(((Object)x).name, "^Item ", "").ToLower() into x
						orderby x
						select x)));
					break;
				}
				case "/setcash":
				{
					if (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);
						}
						else
						{
							PlayerAvatar.instance.ChatMessageSpeak("Updated Cash Amount", PlayerAvatar.instance.isCrouching);
						}
						return true;
					}
					break;
				}
				case "/setlevel":
				{
					if (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);
						}
						else
						{
							PlayerAvatar.instance.ChatMessageSpeak("Updated Level Number", PlayerAvatar.instance.isCrouching);
						}
						return true;
					}
					break;
				}
				case "/setscene":
					if (SemiFunc.IsMasterClientOrSingleplayer())
					{
						string levelName = string.Join(' ', value).ToLower();
						if (levelName == "recording")
						{
							RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)6);
							return true;
						}
						if (levelName == "shop")
						{
							RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)5);
							return true;
						}
						if (levelName == "random")
						{
							RunManager.instance.ChangeLevel(false, false, (ChangeLevelType)1);
							return true;
						}
						List<Level> source3 = (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" && ((Object)x).name != "Level - Lobby Menu"
							select x).ToList();
						RunManager.instance.debugLevel = ((IEnumerable<Level>)source3).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;
							return true;
						}
						PluginLoader.StaticLogger.LogInfo((object)("Available Levels: " + string.Join(", ", from x in source3.Select((Level x) => Regex.Replace(((Object)x).name, "^Level - ", "").ToLower()).Concat(new <>z__ReadOnlySingleElementList<string>("random"))
							orderby x
							select x)));
					}
					break;
				case "/valuable":
				{
					if (!SemiFunc.IsMasterClientOrSingleplayer())
					{
						break;
					}
					string itemName2 = string.Join(' ', value).ToLower();
					List<ValuableObject> source = Resources.FindObjectsOfTypeAll<Level>().SelectMany((Level l) => from x in l.ValuablePresets.SelectMany((LevelValuables p) => p.tiny.Concat(p.small).Concat(p.medium).Concat(p.big)
							.Concat(p.wide)
							.Concat(p.tall)
							.Concat(p.veryTall))
						select x.GetComponent<ValuableObject>() into x
						where Object.op_Implicit((Object)(object)x)
						select x).Concat(from x in Resources.FindObjectsOfTypeAll<ValuableObject>()
						where ((Object)x).name.StartsWith("Enemy Valuable - ") || ((Object)x).name.StartsWith("Surplus Valuable - ")
						select x)
						.ToList();
					ValuableObject val = ((IEnumerable<ValuableObject>)source).FirstOrDefault((Func<ValuableObject, bool>)((ValuableObject x) => Regex.Replace(((Object)x).name, "^Valuable ", "").ToLower() == itemName2));
					if ((Object)(object)val != (Object)null)
					{
						LevelPoint val2 = LevelPointsGetClosestToLocalPlayer();
						Vector3 val3 = default(Vector3);
						((Vector3)(ref val3))..ctor(((Component)val2).transform.position.x, ((Component)val2).transform.position.y + 1f, ((Component)val2).transform.position.z);
						Type volumeType = val.volumeType;
						string text2 = (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 + "/", 
							_ => "", 
						};
						if (((Object)val).name.StartsWith("Enemy Valuable - ") || ((Object)val).name.StartsWith("Surplus Valuable - "))
						{
							text2 = "";
						}
						((GameManager.instance.gameMode != 0) ? PhotonNetwork.InstantiateRoomObject(ValuableDirector.instance.resourcePath + text2 + ((Object)val).name, val3, ((Component)val2).transform.rotation, (byte)0, (object[])null) : Object.Instantiate<GameObject>(((Component)val).gameObject, val3, ((Component)val2).transform.rotation)).GetComponent<ValuableObject>().DollarValueSetLogic();
						PlayerAvatar.instance.ChatMessageSpeak("Spawned Valuable", PlayerAvatar.instance.isCrouching);
						return true;
					}
					PluginLoader.StaticLogger.LogInfo((object)("Available Valuables: " + string.Join(", ", from x in source
						select Regex.Replace(((Object)x).name, "( |^)Valuable( |$)", "", RegexOptions.IgnoreCase).ToLower() into x
						orderby x
						select x)));
					break;
				}
				}
			}
			if (!(text == "/setname"))
			{
				if (text == "/ss" && SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.RunIsRecording())
				{
					if (!Object.op_Implicit((Object)(object)ObjectScreenshotTaker.instance))
					{
						new GameObject("ObjectScreenshotTaker")
						{
							hideFlags = (HideFlags)61
						}.AddComponent<ObjectScreenshotTaker>();
					}
					switch (string.Join(' ', value).ToLower())
					{
					case "enemies":
						if (!ObjectScreenshotTaker.instance.isTakingScreenshots)
						{
							((MonoBehaviour)ObjectScreenshotTaker.instance).StartCoroutine(ObjectScreenshotTaker.instance.TakeScreenshotsOfEnemies());
							PlayerAvatar.instance.ChatMessageSpeak("Starting Enemy Screenshots", PlayerAvatar.instance.isCrouching);
							return true;
						}
						break;
					case "items":
						if (!ObjectScreenshotTaker.instance.isTakingScreenshots)
						{
							((MonoBehaviour)ObjectScreenshotTaker.instance).StartCoroutine(ObjectScreenshotTaker.instance.TakeScreenshotsOfItems());
							PlayerAvatar.instance.ChatMessageSpeak("Starting Item Screenshots", PlayerAvatar.instance.isCrouching);
							return true;
						}
						break;
					case "modules":
						if (!ObjectScreenshotTaker.instance.isTakingScreenshots)
						{
							((MonoBehaviour)ObjectScreenshotTaker.instance).StartCoroutine(ObjectScreenshotTaker.instance.TakeScreenshotsOfModules());
							PlayerAvatar.instance.ChatMessageSpeak("Starting Module Screenshots", PlayerAvatar.instance.isCrouching);
							return true;
						}
						break;
					case "valuables":
						if (!ObjectScreenshotTaker.instance.isTakingScreenshots)
						{
							((MonoBehaviour)ObjectScreenshotTaker.instance).StartCoroutine(ObjectScreenshotTaker.instance.TakeScreenshotsOfValuables());
							PlayerAvatar.instance.ChatMessageSpeak("Starting Valuable Screenshots", PlayerAvatar.instance.isCrouching);
							return true;
						}
						break;
					}
				}
			}
			else if (SemiFunc.IsMasterClientOrSingleplayer() && !string.IsNullOrWhiteSpace(StatsManager.instance.saveFileCurrent))
			{
				string text3 = string.Join(' ', value).Trim();
				if (!(text3 == StatsManager.instance.teamName))
				{
					if (string.IsNullOrWhiteSpace(text3))
					{
						text3 = defaultTeamName ?? "R.E.P.O.";
					}
					StatsManager.instance.teamName = text3;
					SemiFunc.SaveFileSave();
					PluginLoader.StaticLogger.LogInfo((object)("Updated name of " + StatsManager.instance.saveFileCurrent + " to " + StatsManager.instance.teamName));
					PlayerAvatar.instance.ChatMessageSpeak("Renamed Save File", PlayerAvatar.instance.isCrouching);
					return true;
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(PlayerAvatar), "ChatMessageSend")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool PlayerAvatar_ChatMessageSend(string _message)
		{
			return !ExecuteCommand(_message);
		}

		[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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected I4, but got Unknown
			//IL_017c: 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;
			}
			__instance.PossessionActive();
			if (Object.op_Implicit((Object)(object)__instance.playerAvatar) && __instance.playerAvatar.isDisabled && (__instance.possessBatchQueue.Count > 0 || __instance.currentBatch != null))
			{
				__instance.InterruptCurrentPossessBatch();
			}
			if (SemiFunc.IsMainMenu())
			{
				((SemiUI)ChatUI.instance).Hide();
				return false;
			}
			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;
				return false;
			}
			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 MenuPageV2
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__RefreshLobbies;
		}

		internal static void NewGame_Internal(MenuButton __instance)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			REPOPopupPage repoPage = MenuAPI.CreateREPOPopupPage(__instance.menuButtonPopUp?.headerText, false, true, 1.5f, (Vector2?)Vector2.zero);
			repoPage.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOButton("Private", (Action)delegate
			{
				PublicLobbySaves.publicSavesMenuOpen = false;
				MenuPage parentPage3 = __instance.parentPage;
				object obj2 = ((parentPage3 != null) ? ((Component)parentPage3).GetComponent<MenuPageSaves>() : null);
				if (obj2 == null)
				{
					MenuPage parentPage4 = __instance.parentPage;
					if (parentPage4 == null)
					{
						obj2 = null;
					}
					else
					{
						MenuPage pageUnderThisPage2 = parentPage4.pageUnderThisPage;
						obj2 = ((pageUnderThisPage2 != null) ? ((Component)pageUnderThisPage2).GetComponent<MenuPageSaves>() : null);
					}
				}
				if (obj2 != null)
				{
					((MenuPageSaves)obj2).OnNewGame();
				}
			}, scrollView, Vector2.zero)).rectTransform), 0f, 0f);
			repoPage.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOButton("Public", (Action)delegate
			{
				PublicLobbySaves.publicSavesMenuOpen = true;
				MenuPage parentPage = __instance.parentPage;
				object obj = ((parentPage != null) ? ((Component)parentPage).GetComponent<MenuPageSaves>() : null);
				if (obj == null)
				{
					MenuPage parentPage2 = __instance.parentPage;
					if (parentPage2 == null)
					{
						obj = null;
					}
					else
					{
						MenuPage pageUnderThisPage = parentPage2.pageUnderThisPage;
						obj = ((pageUnderThisPage != null) ? ((Component)pageUnderThisPage).GetComponent<MenuPageSaves>() : null);
					}
				}
				if (obj != null)
				{
					((MenuPageSaves)obj).OnNewGame();
				}
			}, scrollView, Vector2.zero)).rectTransform), 0f, 0f);
			repoPage.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOButton("Back", (Action)delegate
			{
				repoPage.ClosePage(false);
			}, scrollView, Vector2.zero)).rectTransform), 0f, 0f);
			repoPage.OpenPage(false);
		}

		internal static void LoadGame_Internal(MenuButton __instance)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			REPOPopupPage repoPage = MenuAPI.CreateREPOPopupPage(__instance.menuButtonPopUp?.headerText, false, true, 1.5f, (Vector2?)Vector2.zero);
			repoPage.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOButton("Private", (Action)delegate
			{
				PublicLobbySaves.publicSavesMenuOpen = false;
				MenuPage parentPage3 = __instance.parentPage;
				object obj2 = ((parentPage3 != null) ? ((Component)parentPage3).GetComponent<MenuPageSaves>() : null);
				if (obj2 == null)
				{
					MenuPage parentPage4 = __instance.parentPage;
					if (parentPage4 == null)
					{
						obj2 = null;
					}
					else
					{
						MenuPage pageUnderThisPage2 = parentPage4.pageUnderThisPage;
						obj2 = ((pageUnderThisPage2 != null) ? ((Component)pageUnderThisPage2).GetComponent<MenuPageSaves>() : null);
					}
				}
				if (obj2 != null)
				{
					((MenuPageSaves)obj2).OnLoadGame();
				}
			}, scrollView, Vector2.zero)).rectTransform), 0f, 0f);
			repoPage.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOButton("Public", (Action)delegate
			{
				PublicLobbySaves.publicSavesMenuOpen = true;
				MenuPage parentPage = __instance.parentPage;
				object obj = ((parentPage != null) ? ((Component)parentPage).GetComponent<MenuPageSaves>() : null);
				if (obj == null)
				{
					MenuPage parentPage2 = __instance.parentPage;
					if (parentPage2 == null)
					{
						obj = null;
					}
					else
					{
						MenuPage pageUnderThisPage = parentPage2.pageUnderThisPage;
						obj = ((pageUnderThisPage != null) ? ((Component)pageUnderThisPage).GetComponent<MenuPageSaves>() : null);
					}
				}
				if (obj != null)
				{
					((MenuPageSaves)obj).OnLoadGame();
				}
			}, scrollView, Vector2.zero)).rectTransform), 0f, 0f);
			repoPage.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform scrollView) => ((REPOElement)MenuAPI.CreateREPOButton("Back", (Action)delegate
			{
				repoPage.ClosePage(false);
			}, scrollView, Vector2.zero)).rectTransform), 0f, 0f);
			repoPage.OpenPage(false);
		}

		[HarmonyPatch(typeof(MenuPageMain), "Start")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void MenuPageMain_Start(MenuPageMain __instance)
		{
			PluginLoader.mainMenuOverhaul = PluginLoader.mainMenuOverhaulEnabled.Value;
			if (PluginLoader.mainMenuOverhaul)
			{
				Transform obj = ((Component)__instance.rectTransform).transform.Find("Menu Button - Private Game/ButtonText");
				TextMeshProUGUI val = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					((TMP_Text)val).text = "Host Game";
				}
				Transform obj2 = ((Component)__instance.rectTransform).transform.Find("Menu Button - Public Game/ButtonText");
				TextMeshProUGUI val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<TextMeshProUGUI>() : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					((TMP_Text)val2).text = "Join Game";
				}
			}
		}

		[HarmonyPatch(typeof(MenuPageMain), "ButtonEventHostGame")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageMain_ButtonEventHostGame()
		{
			if (!PluginLoader.mainMenuOverhaul)
			{
				return true;
			}
			SemiFunc.MainMenuSetMultiplayer();
			MenuManager.instance.PageCloseAll();
			MenuManager.instance.PageOpen((MenuPageIndex)11, false);
			return false;
		}

		[HarmonyPatch(typeof(MenuPageMain), "ButtonEventPlayRandom")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageMain_ButtonEventPlayRandom()
		{
			if (!PluginLoader.mainMenuOverhaul)
			{
				return true;
			}
			MenuManager.instance.PageCloseAll();
			MenuManager.instance.PageOpen((MenuPageIndex)14, false);
			return false;
		}

		[HarmonyPatch(typeof(MenuManager), "PageOpen")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void MenuManager_PageOpen(MenuManager __instance, MenuPage __result, MenuPageIndex menuPageIndex, bool addedPageOnTop = false)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_0015: Invalid comparison between Unknown and I4
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (!PluginLoader.mainMenuOverhaul)
			{
				return;
			}
			if ((int)menuPageIndex != 11)
			{
				if ((int)menuPageIndex != 14)
				{
					if ((int)menuPageIndex == 16)
					{
						Transform obj = ((Component)__result).transform.Find("Header/Text (TMP)");
						TextMeshProUGUI val = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
						if (Object.op_Implicit((Object)(object)val))
						{
							((TMP_Text)val).text = "Join Game";
						}
						AddRegionMenuButton(((Component)__result).transform, new Vector2(8f, 8f), (Type)1);
					}
				}
				else
				{
					AddRegionMenuButton(((Component)__result).transform, new Vector2(8f, 8f), (Type)1);
				}
			}
			else if (SemiFunc.MainMenuIsMultiplayer())
			{
				AddRegionMenuButton(((Component)__result).transform, new Vector2(520f, 325f), (Type)0);
			}
		}

		private static void AddRegionMenuButton(Transform parent, Vector2 localPosition, Type pageType)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			DataDirector.instance.networkRegion = PlayerPrefs.GetString("PUNSelectedRegion", "");
			ServerSettings.ResetBestRegionCodeInPreferences();
			MenuAPI.CreateREPOButton(GetRegionDisplayName(DataDirector.instance.networkRegion), (Action)delegate
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				MenuManager.instance.PageCloseAll();
				((Component)MenuManager.instance.PageOpen((MenuPageIndex)13, false)).GetComponent<MenuPageRegions>().type = pageType;
			}, parent, localPosition);
		}

		private static string GetRegionDisplayName(string regionCode)
		{
			return (regionCode?.ToUpper() ?? "") switch
			{
				"" => "Best Region", 
				"ASIA" => "Asia", 
				"AU" => "Australia", 
				"CAE" => "Canada East", 
				"CN" => "Chinese Mainland", 
				"EU" => "Europe", 
				"HK" => "Hong Kong", 
				"IN" => "India", 
				"JP" => "Japan", 
				"ZA" => "South Africa", 
				"SA" => "South America", 
				"KR" => "South Korea", 
				"TR" => "Turkey", 
				"UAE" => "United Arab Emirates", 
				"US" => "USA East", 
				"USW" => "USA West", 
				"USSC" => "USA South Central", 
				_ => regionCode?.ToUpper(), 
			};
		}

		private static void RefreshLobbies()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			MenuPageServerList component = ((Component)MenuManager.instance.currentMenuPage).GetComponent<MenuPageServerList>();
			if (!Object.op_Implicit((Object)(object)component) || !component.receivedList || component.searchInProgress)
			{
				return;
			}
			foreach (Transform item in component.serverElementParent)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			component.loadingGraphics.Reset();
			component.roomListSearched.Clear();
			component.receivedList = false;
			component.pageMax = 0;
			component.buttonNext.HideSetInstant();
			component.buttonPrevious.HideSetInstant();
			((MonoBehaviour)component).StartCoroutine(component.GetServerList());
		}

		[HarmonyPatch(typeof(MenuPageServerList), "Start")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void MenuPageServerList_Start(MenuPageServerList __instance)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			if (!PluginLoader.mainMenuOverhaul)
			{
				return;
			}
			Transform val = ((Component)__instance).transform.Find("Panel/Create New");
			object obj;
			if (val == null)
			{
				obj = null;
			}
			else
			{
				Transform obj2 = val.Find("Menu Button - CREATE NEW");
				obj = ((obj2 != null) ? ((Component)obj2).GetComponent<MenuButton>() : null);
			}
			MenuButton val2 = (MenuButton)obj;
			if (Object.op_Implicit((Object)(object)val2))
			{
				((TMP_Text)val2.buttonText).text = "Refresh";
				val2.button.onClick = new ButtonClickedEvent();
				ButtonClickedEvent onClick = val2.button.onClick;
				object obj3 = <>O.<0>__RefreshLobbies;
				if (obj3 == null)
				{
					UnityAction val3 = RefreshLobbies;
					<>O.<0>__RefreshLobbies = val3;
					obj3 = (object)val3;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj3);
				GameObject obj4 = Object.Instantiate<GameObject>(((Component)val).gameObject, val.parent);
				((Object)obj4).name = "Random Server";
				obj4.transform.localPosition = Vector2.op_Implicit(new Vector2(0f, val.localPosition.y));
				MenuButton componentInChildren = obj4.GetComponentInChildren<MenuButton>();
				((TMP_Text)componentInChildren.buttonText).text = "Random";
				componentInChildren.button.onClick = new ButtonClickedEvent();
				componentInChildren.menuButtonPopUp = ((Component)componentInChildren).gameObject.AddComponent<MenuButtonPopUp>();
				componentInChildren.menuButtonPopUp.headerText = "Join Server";
				componentInChildren.menuButtonPopUp.bodyText = "Are you sure you want to join a random server?";
				componentInChildren.menuButtonPopUp.option1Event = new UnityEvent();
				componentInChildren.menuButtonPopUp.option1Event.AddListener(new UnityAction(__instance.ButtonCreateNew));
			}
		}

		[HarmonyPatch(typeof(MenuPageServerList), "OnDestroy")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageServerList_OnDestroy()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)MenuManager.instance))
			{
				return (int)MenuManager.instance.currentMenuPageIndex != 13;
			}
			return true;
		}

		[HarmonyPatch(typeof(MenuPageServerList), "ButtonCreateNew")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageServerList_ButtonCreateNew()
		{
			if (!PluginLoader.mainMenuOverhaul)
			{
				return true;
			}
			RunManager.instance.ResetProgress();
			StatsManager.instance.saveFileCurrent = "";
			GameManager.instance.SetConnectRandom(true);
			GameManager.instance.localTest = false;
			RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)3);
			RunManager.instance.lobbyJoin = true;
			return false;
		}

		[HarmonyPatch(typeof(MenuPageServerList), "ExitPage")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageServerList_ExitPage()
		{
			if (!PluginLoader.mainMenuOverhaul)
			{
				return true;
			}
			MenuManager.instance.PageCloseAll();
			MenuManager.instance.PageOpen((MenuPageIndex)0, false);
			return false;
		}

		[HarmonyPatch(typeof(MenuPagePublicGameChoice), "ExitPage")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPagePublicGameChoice_ExitPage()
		{
			if (!PluginLoader.mainMenuOverhaul)
			{
				return true;
			}
			MenuManager.instance.PageCloseAll();
			MenuManager.instance.PageOpen((MenuPageIndex)0, false);
			return false;
		}

		[HarmonyPatch(typeof(MenuPageRegions), "PickRegion")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		[HarmonyPriority(800)]
		private static bool MenuPageRegions_PickRegion(MenuPageRegions __instance, string _region)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			PlayerPrefs.SetString("PUNSelectedRegion", _region);
			PlayerPrefs.Save();
			if ((int)__instance.type != 0)
			{
				DataDirector.instance.networkRegion = _region;
				MenuManager.instance.PageCloseAll();
				MenuManager.instance.PageOpen((MenuPageIndex)14, false);
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(MenuPageRegions), "ExitPage")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageRegions_ExitPage(MenuPageRegions __instance)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			if (!PluginLoader.mainMenuOverhaul)
			{
				return true;
			}
			MenuManager.instance.PageCloseAll();
			MenuManager.instance.PageOpen((MenuPageIndex)(((int)__instance.type == 1) ? 14 : 11), false);
			return false;
		}

		[HarmonyPatch(typeof(MenuPageRegions), "OnDestroy")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool MenuPageRegions_OnDestroy()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)MenuManager.instance))
			{
				return (int)MenuManager.instance.currentMenuPageIndex != 14;
			}
			return true;
		}
	}
	[HarmonyPatch]
	public class PlayerNamePrefix
	{
		[CompilerGenerated]
		private sealed class <DelayedUpdatePauseMenuSliders>d__15 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public MenuPageEsc __instance;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DelayedUpdatePauseMenuSliders>d__15(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					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;
						}
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <GetPlayerNamePrefixes>d__3 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public string[] steamIds;

			public string logType;

			private bool <includesLocalPlayer>5__2;

			private UnityWebRequest <www>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <GetPlayerNamePrefixes>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<www>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_030f: Expected O, but got Unknown
				//IL_0124: Unknown result type (might be due to invalid IL or missing references)
				//IL_012a: Invalid comparison between Unknown and I4
				//IL_038e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0398: Expected O, but got Unknown
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_022c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0231: Unknown result type (might be due to invalid IL or missing references)
				//IL_02de: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
				SteamId steamId;
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					steamIds = (from x in steamIds
						where Regex.IsMatch(x, "^76[0-9]{15}$")
						orderby x
						select x).ToArray();
					string[] source = steamIds;
					steamId = SteamClient.SteamId;
					<includesLocalPlayer>5__2 = source.Contains<string>(((object)(SteamId)(ref steamId)).ToString());
					string text2 = playerPrefixUrl ?? "";
					if (steamIds.Length != 0)
					{
						text2 = text2 + "?" + string.Join("&", steamIds.Select((string id) => "id=" + id));
					}
					<www>5__3 = UnityWebRequest.Get(text2);
					<>2__current = <www>5__3.SendWebRequest();
					<>1__state = 1;
					return true;
				}
				case 1:
				{
					<>1__state = -1;
					AcceptableValueList<string> val = null;
					if ((int)<www>5__3.result == 1)
					{
						try
						{
							Dictionary<string, List<string>> dictionary = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(<www>5__3.downloadHandler.text);
							if (steamIds.Length != 0)
							{
								string[] array = steamIds;
								foreach (string text in array)
								{
									if (dictionary.TryGetValue(text, out var value))
									{
										playerPrefixData[text] = value;
										PluginLoader.StaticLogger.LogDebug((object)string.Format("[GetPlayerNamePrefixes | {0}] {1} has {2} prefixes: {3}", logType, text, value.Count, string.Join(", ", value)));
									}
									else
									{
										playerPrefixData.Remove(text);
										PluginLoader.StaticLogger.LogDebug((object)("[GetPlayerNamePrefixes | " + logType + "] " + text + " has 0 prefixes"));
									}
								}
							}
							else
							{
								steamId = SteamClient.SteamId;
								if (dictionary.ContainsKey(((object)(SteamId)(ref steamId)).ToString()))
								{
									<includesLocalPlayer>5__2 = true;
								}
								playerPrefixData = dictionary;
								foreach (KeyValuePair<string, List<string>> item in dictionary)
								{
									PluginLoader.StaticLogger.LogDebug((object)string.Format("[GetPlayerNamePrefixes | {0}] {1} has {2} prefixes: {3}", logType, item.Key, item.Value.Count, string.Join(", ", item.Value)));
								}
							}
							if (<includesLocalPlayer>5__2)
							{
								steamId = SteamClient.SteamId;
								val = new AcceptableValueList<string>(GetPrefixDataForSteamId(((object)(SteamId)(ref steamId)).ToString()).Prepend("none").ToArray());
							}
						}
						catch (JsonException val2)
						{
							JsonException val3 = val2;
							PluginLoader.StaticLogger.LogWarning((object)("[GetPlayerNamePrefixes | " + logType + "] Failed to parse prefixes: " + ((Exception)(object)val3).Message));
						}
					}
					else
					{
						PluginLoader.StaticLogger.LogWarning((object)("[GetPlayerNamePrefixes | " + logType + "] Failed to fetch prefixes: " + <www>5__3.error));
					}
					if (<includesLocalPlayer>5__2)
					{
						fetchedLocalPlayer = true;
						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);
							}
						};
					}
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

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

		private static bool fetchedLocalPlayer = false;

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

		[IteratorStateMachine(typeof(<GetPlayerNamePrefixes>d__3))]
		private static IEnumerator GetPlayerNamePrefixes(string[] steamIds, string logType)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GetPlayerNamePrefixes>d__3(0)
			{
				steamIds = steamIds,
				logType = logType
			};
		}

		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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (SteamClient.IsValid && !fetchedLocalPlayer)
			{
				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]
		inter