Decompiled source of LobbyName v1.0.1

LobbyName.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("LobbyName")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("LobbyName")]
[assembly: AssemblyTitle("LobbyName")]
[assembly: AssemblyVersion("1.0.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 LobbyName
{
	[BepInPlugin("purtzel_hd.lobbyname", "LobbyName", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal const float PositionY = -27f;

		internal const float BoxWidth = 840f;

		internal const float BoxHeight = 144f;

		internal const float LineWidth = 145f;

		internal const float LineThickness = 2f;

		internal const int TitleFontSize = 16;

		internal const int NameFontSize = 18;

		internal const float NameSpacing = 5f;

		internal const int FadeInMs = 180;

		internal const int SlideInMs = 180;

		internal const int FadeOutMs = 0;

		internal const int SlideOutMs = 0;

		internal const int DimStrength = 87;

		internal const int DimIn = 20;

		internal const int DimOut = 20;

		internal const int ShadowStrength = 100;

		internal const bool SlideAfterLoading = false;

		internal const int DelayAfterLoading = 0;

		internal static ConfigEntry<bool> CopyToClipboard;

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			CopyToClipboard = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Copy To Clipboard", true, "true = the lobby name is copied to your clipboard when you join a lobby, false = nothing is copied");
			GameObject val = new GameObject("LobbyName");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<LobbyNameController>();
			Log.LogInfo((object)"LobbyName loaded.");
		}
	}
	internal class LobbyNameController : MonoBehaviour
	{
		private enum Mode
		{
			Hidden,
			Normal,
			PopupDim,
			ModsDim
		}

		private string _room;

		private string _lobbyName;

		private string _host;

		private float _nextCheck;

		private Type _escType;

		private bool _escLookupDone;

		private FieldInfo _escInstance;

		private FieldInfo _escMenuPage;

		private FieldInfo _pageState;

		private float _nextFallbackSearch;

		private Behaviour _fallbackObj;

		private Mode _mode;

		private bool _escErrorLogged;

		private float _dim;

		private float _fade;

		private float _slide;

		private static string _serverNameKey;

		private FieldInfo _mmInstance;

		private FieldInfo _mmCurrentPage;

		private FieldInfo _mmAllPages;

		private FieldInfo _popUpAnimation;

		private FieldInfo _onTopOfOther;

		private FieldInfo _pageRect;

		private FieldInfo _pageOriginal;

		private Component _escPage;

		private Type _menuLibPage;

		private bool _levelLookupDone;

		private FieldInfo _gdInstance;

		private FieldInfo _gdState;

		private FieldInfo _lgInstance;

		private FieldInfo _lgGenerated;

		private FieldInfo _loadingInstance;

		private FieldInfo _loadingFade;

		private FieldInfo _fadeOverlayInstance;

		private FieldInfo _fadeOverlayImage;

		private static PropertyInfo _graphicColor;

		private float _readySince = -1f;

		private bool _justLoaded;

		private static readonly Color Orange = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)0, byte.MaxValue));

		private static readonly Color Grey = Color32.op_Implicit(new Color32((byte)138, (byte)142, (byte)160, byte.MaxValue));

		private GUIStyle _labelStyle;

		private GUIStyle _nameStyle;

		private GUIStyle _unknownStyle;

		private GUIStyle _shadowStyle;

		private GUIStyle _shadowNameStyle;

		private Texture2D _lineTex;

		private static readonly (float dx, float dy, float w)[] ShadowSpots = new(float, float, float)[5]
		{
			(2f, 2f, 0.55f),
			(1f, 2f, 0.25f),
			(2f, 1f, 0.25f),
			(3f, 3f, 0.3f),
			(1f, 1f, 0.2f)
		};

		private void LateUpdate()
		{
			try
			{
				_mode = GetMode();
			}
			catch (Exception ex)
			{
				_mode = Mode.Hidden;
				if (!_escErrorLogged)
				{
					_escErrorLogged = true;
					Plugin.Log.LogError((object)ex);
				}
			}
			float unscaledDeltaTime = Time.unscaledDeltaTime;
			if (_room == null)
			{
				_fade = 0f;
				_slide = 0f;
				_dim = 0f;
				return;
			}
			bool flag = _mode != Mode.Hidden;
			if (_justLoaded && LevelReadyNow())
			{
				_justLoaded = false;
				if (flag)
				{
					_fade = 1f;
					_slide = 1f;
				}
			}
			if (flag && _mode == Mode.Normal && TryEscProgress(out var progress))
			{
				float num = 1f - Mathf.Pow(1f - progress, 1f / 3f);
				if (num > _slide)
				{
					_slide = num;
				}
				if (num > _fade)
				{
					_fade = num;
				}
			}
			else
			{
				_fade = Step(_fade, flag, flag ? 180 : 0, unscaledDeltaTime);
				_slide = Step(_slide, flag, flag ? 180 : 0, unscaledDeltaTime);
			}
			if (_mode == Mode.PopupDim || _mode == Mode.ModsDim)
			{
				_dim = Step(_dim, up: true, 20, unscaledDeltaTime);
			}
			else if (_mode == Mode.Normal)
			{
				_dim = Step(_dim, up: false, 20, unscaledDeltaTime);
			}
			else if (_fade <= 0f && _slide <= 0f)
			{
				_dim = 0f;
			}
		}

		private bool TryEscProgress(out float progress)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			progress = 0f;
			Component escPage = _escPage;
			if ((Object)(object)escPage == (Object)null || _pageState == null || _pageRect == null || _pageOriginal == null)
			{
				return false;
			}
			switch (Convert.ToInt32(_pageState.GetValue(escPage)))
			{
			case 1:
			case 4:
				progress = 1f;
				return true;
			default:
				return false;
			case 0:
			{
				object obj = _mmInstance?.GetValue(null);
				if (obj != null && _mmAllPages?.GetValue(obj) is IList list && !list.Contains(escPage))
				{
					return true;
				}
				object? value = _pageRect.GetValue(escPage);
				RectTransform val = (RectTransform)((value is RectTransform) ? value : null);
				if (val == null || (Object)(object)val == (Object)null)
				{
					return false;
				}
				Vector2 val2 = (Vector2)_pageOriginal.GetValue(escPage);
				Rect rect = val.rect;
				float height = ((Rect)(ref rect)).height;
				if (height < 1f)
				{
					progress = 1f;
					return true;
				}
				float num = Vector2.Distance(Vector2.op_Implicit(((Transform)val).localPosition), val2);
				progress = Mathf.Clamp01(1f - num / height);
				return true;
			}
			}
		}

		private static float Step(float t, bool up, int ms, float dt)
		{
			if (ms <= 0)
			{
				if (!up)
				{
					return 0f;
				}
				return 1f;
			}
			float num = dt * 1000f / (float)ms;
			return Mathf.Clamp01(up ? (t + num) : (t - num));
		}

		private static float Ease(float t)
		{
			return 1f - (1f - t) * (1f - t) * (1f - t);
		}

		private void Update()
		{
			if (Time.realtimeSinceStartup < _nextCheck)
			{
				return;
			}
			_nextCheck = Time.realtimeSinceStartup + 0.25f;
			try
			{
				if (!PhotonNetwork.InRoom)
				{
					_room = null;
					_lobbyName = null;
					_host = null;
					return;
				}
				Room currentRoom = PhotonNetwork.CurrentRoom;
				if (currentRoom != null && currentRoom.Name != _room)
				{
					_room = currentRoom.Name;
					string text = FindLobbyName(currentRoom);
					if (string.IsNullOrWhiteSpace(text))
					{
						_lobbyName = "Private Lobby";
					}
					else
					{
						_lobbyName = text;
						CopyToClipboard(_lobbyName);
					}
				}
				Player masterClient = PhotonNetwork.MasterClient;
				_host = ((masterClient != null) ? masterClient.NickName : null);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)ex);
			}
		}

		private void CopyToClipboard(string name)
		{
			if (!Plugin.CopyToClipboard.Value || string.IsNullOrWhiteSpace(name))
			{
				return;
			}
			try
			{
				GUIUtility.systemCopyBuffer = name;
				Plugin.Log.LogInfo((object)("Lobby name copied: " + name));
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Copying to the clipboard failed: " + ex.Message));
			}
		}

		private static string ServerNameKey()
		{
			if (_serverNameKey != null)
			{
				return _serverNameKey;
			}
			_serverNameKey = "server_name";
			try
			{
				if (((from a in AppDomain.CurrentDomain.GetAssemblies()
					select a.GetType("DataDirector", throwOnError: false)).FirstOrDefault((Type t) => t != null)?.GetField("SERVER_NAME_PROP_KEY", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))?.GetValue(null) is string text && !string.IsNullOrWhiteSpace(text))
				{
					_serverNameKey = text;
				}
			}
			catch
			{
			}
			return _serverNameKey;
		}

		private static string FindLobbyName(Room room)
		{
			string text = null;
			try
			{
				string text2 = ServerNameKey();
				Hashtable customProperties = ((RoomInfo)room).CustomProperties;
				if (customProperties != null && ((Dictionary<object, object>)(object)customProperties).ContainsKey((object)text2))
				{
					text = customProperties[(object)text2]?.ToString()?.Trim();
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Reading the lobby name failed: " + ex.Message));
			}
			Plugin.Log.LogInfo((object)(string.IsNullOrWhiteSpace(text) ? ("Joined room " + room.Name + ": private lobby (no name)") : ("Joined room " + room.Name + ": \"" + text + "\"")));
			if (!string.IsNullOrWhiteSpace(text))
			{
				return text;
			}
			return null;
		}

		private Mode GetMode()
		{
			_escPage = null;
			if (!_escLookupDone)
			{
				_escLookupDone = true;
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				_escType = assemblies.Select((Assembly a) => a.GetType("MenuPageEsc", throwOnError: false)).FirstOrDefault((Type t) => t != null);
				_escInstance = _escType?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				_escMenuPage = _escType?.GetField("menuPage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_pageState = _escMenuPage?.FieldType.GetField("currentPageState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_popUpAnimation = _escMenuPage?.FieldType.GetField("popUpAnimation", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_pageRect = _escMenuPage?.FieldType.GetField("rectTransform", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_pageOriginal = _escMenuPage?.FieldType.GetField("originalPosition", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_onTopOfOther = _escMenuPage?.FieldType.GetField("pageIsOnTopOfOtherPage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				Type type = assemblies.Select((Assembly a) => a.GetType("MenuManager", throwOnError: false)).FirstOrDefault((Type t) => t != null);
				_mmInstance = type?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				_mmCurrentPage = type?.GetField("currentMenuPage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_mmAllPages = type?.GetField("allPages", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_menuLibPage = assemblies.Select((Assembly a) => a.GetType("MenuLib.MonoBehaviors.REPOPopupPage", throwOnError: false)).FirstOrDefault((Type t) => t != null);
				Plugin.Log.LogInfo((object)($"Esc menu found: {_escType != null}, page state: {_pageState != null}, " + $"menu manager: {_mmCurrentPage != null}, MenuLib: {_menuLibPage != null}"));
			}
			if (_escType == null)
			{
				return Mode.Hidden;
			}
			if (!LevelReady())
			{
				return Mode.Hidden;
			}
			if (_escInstance == null || _escMenuPage == null || _pageState == null)
			{
				if (Time.realtimeSinceStartup >= _nextFallbackSearch)
				{
					_nextFallbackSearch = Time.realtimeSinceStartup + 0.25f;
					ref Behaviour fallbackObj = ref _fallbackObj;
					Object obj = Object.FindAnyObjectByType(_escType);
					fallbackObj = (Behaviour)(object)((obj is Behaviour) ? obj : null);
				}
				if (!((Object)(object)_fallbackObj != (Object)null) || !_fallbackObj.isActiveAndEnabled)
				{
					return Mode.Hidden;
				}
				return Mode.Normal;
			}
			object? value = _escInstance.GetValue(null);
			Behaviour val = (Behaviour)((value is Behaviour) ? value : null);
			if ((Object)(object)val == (Object)null || !val.isActiveAndEnabled)
			{
				return Mode.Hidden;
			}
			ref Component escPage = ref _escPage;
			object? value2 = _escMenuPage.GetValue(val);
			Component val2 = (escPage = (Component)((value2 is Component) ? value2 : null));
			if ((Object)(object)val2 == (Object)null)
			{
				return Mode.Normal;
			}
			int num = Convert.ToInt32(_pageState.GetValue(val2));
			if (num == 2 || num == 5)
			{
				return Mode.Hidden;
			}
			Component val3 = null;
			object obj2 = _mmInstance?.GetValue(null);
			if (obj2 != null)
			{
				object? obj3 = _mmCurrentPage?.GetValue(obj2);
				val3 = (Component)((obj3 is Component) ? obj3 : null);
			}
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3 != (Object)(object)val2)
			{
				if (_menuLibPage != null && ((Object)(object)val3.GetComponent(_menuLibPage) != (Object)null || (Object)(object)val3.GetComponentInParent(_menuLibPage) != (Object)null))
				{
					return Mode.ModsDim;
				}
				if (IsPopup(val3))
				{
					return Mode.PopupDim;
				}
				return Mode.Hidden;
			}
			if (_mmAllPages != null && obj2 != null && _mmAllPages.GetValue(obj2) is IList list)
			{
				foreach (object item in list)
				{
					Component val4 = (Component)((item is Component) ? item : null);
					if (!((Object)(object)val4 == (Object)null) && !((Object)(object)val4 == (Object)(object)val2) && IsPopup(val4))
					{
						return Mode.PopupDim;
					}
				}
			}
			return Mode.Normal;
		}

		private bool InLevel()
		{
			Assembly[] asms;
			if (!_levelLookupDone)
			{
				_levelLookupDone = true;
				asms = AppDomain.CurrentDomain.GetAssemblies();
				Type type = T("GameDirector");
				_gdInstance = type?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				_gdState = type?.GetField("currentState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				Type type2 = T("LevelGenerator");
				_lgInstance = type2?.GetField("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				_lgGenerated = type2?.GetField("Generated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				Type type3 = T("LoadingUI");
				_loadingInstance = type3?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				_loadingFade = type3?.GetField("fadeImage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				Type type4 = T("FadeOverlay");
				_fadeOverlayInstance = type4?.GetField("Instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				_fadeOverlayImage = type4?.GetField("Image", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				Plugin.Log.LogInfo((object)$"Level check found: {_gdState != null && _lgGenerated != null}, loading screen: {_loadingInstance != null}");
			}
			try
			{
				object obj = _gdInstance?.GetValue(null);
				if (obj != null && _gdState != null && Convert.ToInt32(_gdState.GetValue(obj)) != 2)
				{
					return false;
				}
				object? obj2 = _lgInstance?.GetValue(null);
				Object val = (Object)((obj2 is Object) ? obj2 : null);
				if (val != (Object)null)
				{
					object obj3 = _lgGenerated?.GetValue(val);
					if (obj3 is bool && !(bool)obj3)
					{
						return false;
					}
				}
				object? obj4 = _loadingInstance?.GetValue(null);
				Component val2 = (Component)((obj4 is Component) ? obj4 : null);
				if ((Object)(object)val2 != (Object)null && val2.gameObject.activeInHierarchy)
				{
					return false;
				}
				if ((Object)(object)val2 != (Object)null && Covering(_loadingFade?.GetValue(val2)))
				{
					return false;
				}
				object obj5 = _fadeOverlayInstance?.GetValue(null);
				if (obj5 != null && Covering(_fadeOverlayImage?.GetValue(obj5)))
				{
					return false;
				}
				return true;
			}
			catch
			{
				return true;
			}
			Type T(string n)
			{
				return asms.Select((Assembly a) => a.GetType(n, throwOnError: false)).FirstOrDefault((Type t) => t != null);
			}
		}

		private static bool Covering(object img)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			Behaviour val = (Behaviour)((img is Behaviour) ? img : null);
			if (val == null || (Object)(object)val == (Object)null)
			{
				return false;
			}
			if (!val.enabled || !((Component)val).gameObject.activeInHierarchy)
			{
				return false;
			}
			if (_graphicColor == null)
			{
				_graphicColor = ((object)val).GetType().GetProperty("color", BindingFlags.Instance | BindingFlags.Public);
			}
			if (_graphicColor?.GetValue(val) is Color val2)
			{
				return val2.a > 0.05f;
			}
			return false;
		}

		private bool LevelReadyNow()
		{
			if (_readySince >= 0f)
			{
				return (Time.realtimeSinceStartup - _readySince) * 1000f >= 0f;
			}
			return false;
		}

		private bool LevelReady()
		{
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (!InLevel())
			{
				_readySince = -1f;
				_justLoaded = true;
				return false;
			}
			if (_readySince < 0f)
			{
				_readySince = realtimeSinceStartup;
			}
			if ((realtimeSinceStartup - _readySince) * 1000f < 0f)
			{
				_justLoaded = true;
				return false;
			}
			return true;
		}

		private bool IsPopup(Component p)
		{
			object obj = _popUpAnimation?.GetValue(p);
			bool flag = default(bool);
			int num;
			if (obj is bool)
			{
				flag = (bool)obj;
				num = 1;
			}
			else
			{
				num = 0;
			}
			int num2 = num & (flag ? 1 : 0);
			obj = _onTopOfOther?.GetValue(p);
			bool flag2 = default(bool);
			int num3;
			if (obj is bool)
			{
				flag2 = (bool)obj;
				num3 = 1;
			}
			else
			{
				num3 = 0;
			}
			bool flag3 = (byte)((uint)num3 & (flag2 ? 1u : 0u)) != 0;
			if (num2 == 0 && !flag3)
			{
				return false;
			}
			if (!p.gameObject.activeInHierarchy)
			{
				return false;
			}
			int num4 = Convert.ToInt32(_pageState.GetValue(p));
			if (num4 != 2)
			{
				return num4 != 5;
			}
			return false;
		}

		private void Styles()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0050: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_0088: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			if (_labelStyle == null)
			{
				_labelStyle = new GUIStyle(GUI.skin.label)
				{
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					richText = true,
					wordWrap = false,
					clipping = (TextClipping)1,
					padding = new RectOffset(0, 0, 0, 0)
				};
				_labelStyle.normal.textColor = Color.white;
				_nameStyle = new GUIStyle(_labelStyle)
				{
					richText = false
				};
				_nameStyle.normal.textColor = Color.white;
				_unknownStyle = new GUIStyle(_labelStyle)
				{
					richText = true
				};
				_shadowStyle = new GUIStyle(_labelStyle)
				{
					richText = false
				};
				_shadowStyle.normal.textColor = Color.black;
				_shadowNameStyle = new GUIStyle(_shadowStyle);
				_lineTex = new Texture2D(1, 1)
				{
					hideFlags = (HideFlags)61
				};
				_lineTex.SetPixel(0, 0, Color.white);
				_lineTex.Apply();
			}
		}

		private void OnGUI()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Expected O, but got Unknown
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Expected O, but got Unknown
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Expected O, but got Unknown
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			if (_room == null || (_fade <= 0f && _slide <= 0f) || (int)Event.current.type != 7)
			{
				return;
			}
			Styles();
			float num = Mathf.Clamp((float)Screen.height / 1080f, 0.5f, 4f);
			GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num, num, 1f));
			float num2 = (float)Screen.width / num;
			float num3 = -127f * (1f - Ease(_slide));
			float num4 = Ease(_fade);
			float num5 = Mathf.Min(840f, num2 - 20f);
			float num6 = 144f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor((num2 - num5) / 2f, -27f + num3, num5, num6);
			float num7 = 1f - 0.87f * Ease(_dim);
			GUIContent val2 = new GUIContent("Lobby<color=#" + Hex(Orange, num7, num4) + ">Name</color>");
			int num8 = 16;
			_labelStyle.fontSize = num8;
			float y = _labelStyle.CalcSize(val2).y;
			float num9 = 2f;
			float num10 = Mathf.Min(145f, ((Rect)(ref val)).width - 6f);
			float num11 = ((num10 > 0f) ? num9 : 0f);
			float num12 = ((Rect)(ref val)).width - 28f;
			GUIStyle val3;
			GUIContent val4;
			if (!string.IsNullOrEmpty(_lobbyName))
			{
				val3 = _nameStyle;
				val3.fontSize = 18;
				val4 = new GUIContent(Shorten(val3, _lobbyName, num12));
			}
			else
			{
				string text = (string.IsNullOrEmpty(_host) ? "" : ("<color=#" + Hex(Grey, num7, num4) + "><b>  ·  </b>Host: " + _host.Replace("<", "‹").Replace(">", "›") + "</color>"));
				val4 = new GUIContent("Name unknown" + text);
				val3 = _unknownStyle;
				val3.fontSize = Mathf.Max(8, Mathf.RoundToInt(15.3f));
			}
			float y2 = val3.CalcSize(val4).y;
			float num13 = (float)num8 * 0.3f;
			float num14 = 5f;
			float num15 = y + num13 + num11 + num14 + y2;
			float num16 = ((Rect)(ref val)).y + (((Rect)(ref val)).height - num15) / 2f;
			Rect val5 = default(Rect);
			((Rect)(ref val5))..ctor(((Rect)(ref val)).x, num16, ((Rect)(ref val)).width, y);
			num16 += y + num13;
			Rect val6 = default(Rect);
			((Rect)(ref val6))..ctor(((Rect)(ref val)).x + (((Rect)(ref val)).width - num10) / 2f, num16, num10, num9);
			num16 += num11 + num14;
			Rect val7 = default(Rect);
			((Rect)(ref val7))..ctor(((Rect)(ref val)).x + 14f, num16, num12, y2);
			float num17 = 1f * num4;
			if (num17 > 0f)
			{
				_shadowStyle.fontSize = num8;
				GUIContent val8 = new GUIContent("LobbyName");
				_shadowNameStyle.fontSize = val3.fontSize;
				GUIContent val9 = new GUIContent(val3.richText ? StripTags(val4.text) : val4.text);
				(float, float, float)[] shadowSpots = ShadowSpots;
				for (int i = 0; i < shadowSpots.Length; i++)
				{
					(float, float, float) tuple = shadowSpots[i];
					float item = tuple.Item1;
					float item2 = tuple.Item2;
					float item3 = tuple.Item3;
					GUI.color = new Color(1f, 1f, 1f, num17 * item3);
					GUI.Label(Move(val5, item, item2), val8, _shadowStyle);
					GUI.Label(Move(val7, item, item2), val9, _shadowNameStyle);
					if (num10 > 0f)
					{
						GUI.color = new Color(0f, 0f, 0f, num17 * item3);
						GUI.DrawTexture(Move(val6, item, item2), (Texture)(object)_lineTex);
					}
				}
			}
			Color color = default(Color);
			((Color)(ref color))..ctor(num7, num7, num7, num4);
			GUI.color = color;
			GUI.Label(val5, val2, _labelStyle);
			if (num10 > 0f)
			{
				GUI.color = new Color(Orange.r * num7, Orange.g * num7, Orange.b * num7, num4);
				GUI.DrawTexture(val6, (Texture)(object)_lineTex);
				GUI.color = color;
			}
			GUI.Label(val7, val4, val3);
			GUI.color = Color.white;
		}

		private static Rect Move(Rect r, float dx, float dy)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref r)).x + dx, ((Rect)(ref r)).y + dy, ((Rect)(ref r)).width, ((Rect)(ref r)).height);
		}

		private static string StripTags(string t)
		{
			return Regex.Replace(t ?? "", "<.*?>", "");
		}

		private static string Hex(Color c, float k, float alpha)
		{
			//IL_0000: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			return ColorUtility.ToHtmlStringRGBA(new Color(c.r * k, c.g * k, c.b * k, alpha));
		}

		private static string Shorten(GUIStyle style, string text, float width)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (style.CalcSize(new GUIContent(text)).x <= width)
			{
				return text;
			}
			int num = text.Length;
			while (num > 1 && style.CalcSize(new GUIContent(text.Substring(0, num).TrimEnd() + "…")).x > width)
			{
				num--;
			}
			return text.Substring(0, num).TrimEnd() + "…";
		}
	}
}