Decompiled source of RoR2ItemOverlay v1.0.1

RoR2ItemOverlay.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using Microsoft.CodeAnalysis;
using RoR2;
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("RoR2ItemOverlay")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RoR2ItemOverlay")]
[assembly: AssemblyTitle("RoR2ItemOverlay")]
[assembly: AssemblyVersion("1.0.0.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 RoR2ItemOverlay
{
	[BepInPlugin("local.ror2helper.itemoverlay", "RoR2 Helper Item Overlay", "1.0.1")]
	public class ItemOverlayPlugin : BaseUnityPlugin
	{
		private class Entry
		{
			public string Category;

			public string Name;

			public string Description;

			public string Tier;

			public string ColorHex;
		}

		private class Info
		{
			public string Name;

			public string Category;

			public string Description;

			public string Status;

			public string TierLabel;

			public Color TierColor = Color.white;

			public Color Color = Color.white;

			public Vector3 WorldPos;
		}

		private class Cand
		{
			public int Rank;

			public string Name;

			public PickupIndex Idx;
		}

		public const string PluginGuid = "local.ror2helper.itemoverlay";

		public const string PluginName = "RoR2 Helper Item Overlay";

		public const string PluginVersion = "1.0.1";

		private static readonly Dictionary<string, Entry> Data = new Dictionary<string, Entry>();

		private const BindingFlags BF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private ConfigEntry<KeyCode> toggleKey;

		private ConfigEntry<float> range;

		private ConfigEntry<float> lookAngle;

		private ConfigEntry<float> uiScale;

		private ConfigEntry<bool> showOwned;

		private ConfigEntry<bool> preferAppText;

		private ConfigEntry<bool> debugLog;

		private ConfigEntry<string> ignoreNames;

		private bool overlayOn = true;

		private Info current;

		private Info shown;

		private float alpha;

		private float nextScan;

		private GUIStyle titleStyle;

		private GUIStyle bodyStyle;

		private GUIStyle smallStyle;

		private int styleHeight;

		private Texture2D bgTex;

		private static readonly Dictionary<string, KeyValuePair<string, string>> TierInfo = new Dictionary<string, KeyValuePair<string, string>>
		{
			{
				"safe",
				new KeyValuePair<string, string>("Safest", "#3ddc84")
			},
			{
				"quest",
				new KeyValuePair<string, string>("Questionable", "#ffc933")
			},
			{
				"dang",
				new KeyValuePair<string, string>("Dangerous", "#ff5a5f")
			},
			{
				"heresy",
				new KeyValuePair<string, string>("Heresy set", "#4da3ff")
			}
		};

		private readonly HashSet<string> logged = new HashSet<string>();

		private static readonly Dictionary<string, string> StyleColors = new Dictionary<string, string>
		{
			{ "cIsDamage", "#E5483A" },
			{ "cIsHealing", "#82CC5F" },
			{ "cIsUtility", "#8CB4FF" },
			{ "cIsHealth", "#82CC5F" },
			{ "cDeath", "#C23A3A" },
			{ "cStack", "#A8A8A8" },
			{ "cUserSetting", "#E0C070" },
			{ "cEvent", "#E0C070" },
			{ "cShrine", "#B9A2FF" },
			{ "cWorldEvent", "#E0C070" },
			{ "cSub", "#A8A8A8" },
			{ "cKeywordName", "#E0C070" }
		};

		private void Awake()
		{
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)288, "Press to turn the overlay on/off.");
			range = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ViewDistance", 12f, "How close (meters) you must be to the item. (1.0.0 used 6.)");
			ignoreNames = ((BaseUnityPlugin)this).Config.Bind<string>("General", "IgnoredObjectNames", "cleansing,pool", "Comma-separated words. Anything whose object or interactable name contains one of them never shows a panel (this hides the Cleansing Pool's Pearl).");
			lookAngle = ((BaseUnityPlugin)this).Config.Bind<float>("General", "LookAngle", 14f, "How closely (degrees) you must be looking at the item.");
			uiScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "UIScale", 1f, "Overlay size multiplier.");
			showOwned = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowOwnedCount", true, "Show how many of the item you already have.");
			preferAppText = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PreferHelperAppText", true, "Use the text from your helper app when available (otherwise the game's own text).");
			debugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "LogPickups", true, "Write pickup detection details to the BepInEx log (for troubleshooting).");
			LoadData();
			bgTex = new Texture2D(1, 1);
			bgTex.SetPixel(0, 0, new Color(0.05f, 0.06f, 0.08f, 0.88f));
			bgTex.Apply();
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded " + Data.Count + " helper-app entries."));
		}

		private void LoadData()
		{
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("items.tsv");
			if (stream == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"items.tsv not embedded; using in-game text only.");
				return;
			}
			using StreamReader streamReader = new StreamReader(stream, Encoding.UTF8);
			string text;
			while ((text = streamReader.ReadLine()) != null)
			{
				string[] array = text.Split('\t');
				if (array.Length >= 3)
				{
					Entry entry = new Entry
					{
						Category = array[0],
						Name = array[1],
						Description = array[2],
						Tier = ((array.Length > 3) ? array[3] : ""),
						ColorHex = ((array.Length > 4) ? array[4] : "")
					};
					if (Data.TryGetValue(Normalize(array[1]), out var value) && string.IsNullOrEmpty(entry.Tier))
					{
						entry.Tier = value.Tier;
					}
					Data[Normalize(array[1])] = entry;
					if (array[1].StartsWith("Hex of ", StringComparison.OrdinalIgnoreCase))
					{
						Data[Normalize(array[1].Substring(7))] = entry;
					}
				}
			}
		}

		private static string Normalize(string s)
		{
			StringBuilder stringBuilder = new StringBuilder();
			string text = s ?? "";
			foreach (char c in text)
			{
				if (char.IsLetterOrDigit(c))
				{
					stringBuilder.Append(char.ToLowerInvariant(c));
				}
			}
			return stringBuilder.ToString();
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(toggleKey.Value))
			{
				overlayOn = !overlayOn;
			}
			if (Time.unscaledTime >= nextScan)
			{
				nextScan = Time.unscaledTime + 0.1f;
				try
				{
					Scan();
				}
				catch (Exception ex)
				{
					current = null;
					((BaseUnityPlugin)this).Logger.LogError((object)ex);
				}
			}
			if (current != null)
			{
				shown = current;
			}
			float num = ((overlayOn && current != null) ? 1f : 0f);
			alpha = Mathf.MoveTowards(alpha, num, Time.unscaledDeltaTime * 8f);
		}

		private void Scan()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Invalid comparison between Unknown and I4
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Invalid comparison between Unknown and I4
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			current = null;
			if ((Object)(object)Run.instance == (Object)null)
			{
				return;
			}
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser == null || (Object)(object)firstLocalUser.cameraRigController == (Object)null || (Object)(object)firstLocalUser.cachedBody == (Object)null)
			{
				return;
			}
			Camera sceneCam = firstLocalUser.cameraRigController.sceneCam;
			if ((Object)(object)sceneCam == (Object)null)
			{
				return;
			}
			CharacterBody cachedBody = firstLocalUser.cachedBody;
			Vector3 position = ((Component)sceneCam).transform.position;
			Vector3 forward = ((Component)sceneCam).transform.forward;
			Vector3 corePosition = cachedBody.corePosition;
			float num = lookAngle.Value;
			Component val = null;
			PickupIndex val2 = PickupIndex.none;
			List<Component> list = new List<Component>();
			list.AddRange((IEnumerable<Component>)(object)Object.FindObjectsOfType<GenericPickupController>());
			list.AddRange((IEnumerable<Component>)(object)Object.FindObjectsOfType<ShopTerminalBehavior>());
			foreach (Component item in list)
			{
				if ((Object)(object)item == (Object)null)
				{
					continue;
				}
				Vector3 position2 = item.transform.position;
				if (!(Vector3.Distance(corePosition, position2) > range.Value))
				{
					float num2 = Vector3.Angle(forward, position2 - position);
					if (!(num2 > num) && !IsIgnored(item) && !IsHidden(item) && GetUsableIndex(item, out var found))
					{
						num = num2;
						val = item;
						val2 = found;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			PickupDef pickupDef = PickupCatalog.GetPickupDef(val2);
			string s = Language.GetString(pickupDef.nameToken);
			Data.TryGetValue(Normalize(StripTags(s)), out var value);
			Info info = new Info
			{
				Name = StripTags(s),
				Color = pickupDef.baseColor,
				WorldPos = val.transform.position
			};
			string text = null;
			string text2 = null;
			if ((int)pickupDef.itemIndex != -1)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
				if ((Object)(object)itemDef != (Object)null)
				{
					text = TokenText(itemDef.descriptionToken) ?? TokenText(itemDef.pickupToken);
					text2 = "Item";
					if (showOwned.Value && (Object)(object)cachedBody.inventory != (Object)null)
					{
						int itemCount = cachedBody.inventory.GetItemCount(pickupDef.itemIndex);
						info.Status = ((itemCount > 0) ? ("You have x" + itemCount) : "You don't have this yet");
					}
				}
			}
			else if ((int)pickupDef.equipmentIndex != -1)
			{
				EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
				if ((Object)(object)equipmentDef != (Object)null)
				{
					text = TokenText(equipmentDef.descriptionToken) ?? TokenText(equipmentDef.pickupToken);
					text2 = "Equipment";
					if (showOwned.Value && (Object)(object)cachedBody.inventory != (Object)null && cachedBody.inventory.currentEquipmentIndex == pickupDef.equipmentIndex)
					{
						info.Status = "Currently equipped";
					}
				}
			}
			info.Category = ((value != null) ? value.Category : (text2 ?? "Pickup"));
			if (value != null)
			{
				Color color = default(Color);
				if (ColorUtility.TryParseHtmlString(value.ColorHex, ref color))
				{
					info.Color = color;
				}
				if (TierInfo.TryGetValue(value.Tier ?? "", out var value2))
				{
					info.TierLabel = value2.Key;
					ColorUtility.TryParseHtmlString(value2.Value, ref info.TierColor);
				}
			}
			if (value != null && preferAppText.Value)
			{
				info.Description = Escape(value.Description);
			}
			else
			{
				info.Description = ConvertStyles(text ?? ((value != null) ? value.Description : ""));
			}
			current = info;
		}

		private bool IsIgnored(Component c)
		{
			string[] array = ignoreNames.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
			if (array.Length == 0)
			{
				return false;
			}
			List<string> list = new List<string>();
			int num = 0;
			Transform val = c.transform;
			while ((Object)(object)val != (Object)null && num < 4)
			{
				list.Add(((Object)val).name);
				val = val.parent;
				num++;
			}
			PurchaseInteraction componentInParent = c.GetComponentInParent<PurchaseInteraction>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				string text = Member(componentInParent, "displayNameToken") as string;
				if (!string.IsNullOrEmpty(text))
				{
					list.Add(text);
					list.Add(Language.GetString(text));
				}
			}
			string[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				string text2 = array2[i].Trim();
				if (text2.Length == 0)
				{
					continue;
				}
				foreach (string item in list)
				{
					if (item != null && item.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						if (debugLog.Value && logged.Add("ignored|" + item))
						{
							((BaseUnityPlugin)this).Logger.LogInfo((object)("[pickup] ignored '" + item + "' (matched '" + text2 + "')"));
						}
						return true;
					}
				}
			}
			return false;
		}

		private static bool IsHidden(Component c)
		{
			string[] array = new string[2] { "hidden", "pickupIndexIsHidden" };
			foreach (string name in array)
			{
				object obj = Member(c, name);
				if (obj is bool && (bool)obj)
				{
					return true;
				}
			}
			return false;
		}

		private static int RankOf(string member)
		{
			if (member == "pickup")
			{
				return 0;
			}
			if (member == "pickupIndex")
			{
				return 1;
			}
			return 3;
		}

		private static IEnumerable<KeyValuePair<string, object>> AllMembers(object o)
		{
			Type t = o.GetType();
			while (t != null && t != typeof(object) && t != typeof(Object) && t != typeof(Component) && t != typeof(Behaviour) && t != typeof(MonoBehaviour))
			{
				FieldInfo[] fields = t.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					object value = null;
					try
					{
						value = fieldInfo.GetValue(o);
					}
					catch
					{
					}
					yield return new KeyValuePair<string, object>(fieldInfo.Name, value);
				}
				PropertyInfo[] properties = t.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (PropertyInfo propertyInfo in properties)
				{
					if (propertyInfo.CanRead && propertyInfo.GetIndexParameters().Length == 0)
					{
						object value2 = null;
						try
						{
							value2 = propertyInfo.GetValue(o, null);
						}
						catch
						{
						}
						yield return new KeyValuePair<string, object>(propertyInfo.Name, value2);
					}
				}
				t = t.BaseType;
			}
		}

		private bool GetUsableIndex(Component c, out PickupIndex found)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			found = PickupIndex.none;
			List<Cand> list = new List<Cand>();
			foreach (KeyValuePair<string, object> item2 in AllMembers(c))
			{
				if (ToIndex(item2.Value, out var idx))
				{
					list.Add(new Cand
					{
						Rank = RankOf(item2.Key),
						Name = item2.Key,
						Idx = idx
					});
				}
			}
			MethodInfo method = ((object)c).GetType().GetMethod("CurrentPickupIndex", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
			if (method != null)
			{
				try
				{
					if (ToIndex(method.Invoke(c, null), out var idx2))
					{
						list.Add(new Cand
						{
							Rank = 2,
							Name = "CurrentPickupIndex()",
							Idx = idx2
						});
					}
				}
				catch
				{
				}
			}
			list.Sort((Cand x, Cand y) => x.Rank.CompareTo(y.Rank));
			string name = ((object)c).GetType().Name;
			bool flag = false;
			foreach (Cand item3 in list)
			{
				PickupDef pickupDef = PickupCatalog.GetPickupDef(item3.Idx);
				string text = ((pickupDef != null) ? Language.GetString(pickupDef.nameToken) : null);
				bool flag2 = pickupDef != null && !string.IsNullOrEmpty(text) && text != "???" && text != pickupDef.nameToken;
				if (debugLog.Value)
				{
					string item = name + "|" + item3.Name + "|" + ((pickupDef != null) ? pickupDef.internalName : "null") + "|" + flag2;
					if (logged.Add(item))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("[pickup] " + name + "." + item3.Name + " -> " + ((pickupDef != null) ? pickupDef.internalName : "null") + " name='" + text + "' usable=" + flag2));
					}
				}
				if (flag2 && !flag)
				{
					found = item3.Idx;
					flag = true;
					if (!debugLog.Value)
					{
						break;
					}
				}
			}
			if (debugLog.Value && list.Count == 0 && logged.Add(name + "|none"))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[pickup] " + name + " has no pickup values I can read"));
			}
			return flag;
		}

		private static bool ToIndex(object v, out PickupIndex idx)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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)
			idx = PickupIndex.none;
			if (v == null)
			{
				return false;
			}
			if (v is PickupIndex)
			{
				idx = (PickupIndex)v;
				return true;
			}
			object obj = Member(v, "pickupIndex");
			if (obj is PickupIndex)
			{
				idx = (PickupIndex)obj;
				return true;
			}
			return false;
		}

		private static object Member(object o, string name)
		{
			if (o == null)
			{
				return null;
			}
			Type type = o.GetType();
			FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (field != null)
			{
				return field.GetValue(o);
			}
			PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null && property.GetIndexParameters().Length == 0)
			{
				return property.GetValue(o, null);
			}
			return null;
		}

		private static string TokenText(string token)
		{
			if (string.IsNullOrEmpty(token))
			{
				return null;
			}
			string text = Language.GetString(token);
			if (!string.IsNullOrEmpty(text) && !(text == token))
			{
				return text;
			}
			return null;
		}

		private static string StripTags(string s)
		{
			return Regex.Replace(s ?? "", "<[^>]+>", "");
		}

		private static string Escape(string s)
		{
			return (s ?? "").Replace("<", "<\u200b");
		}

		private static string ConvertStyles(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return "";
			}
			s = Regex.Replace(s, "<sprite[^>]*>", "");
			s = Regex.Replace(s, "<style=([A-Za-z0-9_]+)>", (Match m) => "<color=" + (StyleColors.TryGetValue(m.Groups[1].Value, out var value) ? value : "#FFFFFF") + ">");
			return s.Replace("</style>", "</color>");
		}

		private void EnsureStyles()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			if (titleStyle == null || styleHeight != Screen.height)
			{
				styleHeight = Screen.height;
				int num = Mathf.Max(12, Mathf.RoundToInt((float)Screen.height / 52f * uiScale.Value));
				titleStyle = new GUIStyle(GUI.skin.label)
				{
					richText = true,
					wordWrap = true,
					fontSize = Mathf.RoundToInt((float)num * 1.25f),
					fontStyle = (FontStyle)1
				};
				bodyStyle = new GUIStyle(GUI.skin.label)
				{
					richText = true,
					wordWrap = true,
					fontSize = num
				};
				smallStyle = new GUIStyle(GUI.skin.label)
				{
					richText = true,
					wordWrap = true,
					fontSize = Mathf.RoundToInt((float)num * 0.85f)
				};
				GUIStyleState normal = titleStyle.normal;
				GUIStyleState normal2 = bodyStyle.normal;
				Color val = (smallStyle.normal.textColor = Color.white);
				Color textColor = (normal2.textColor = val);
				normal.textColor = textColor;
			}
		}

		private void OnGUI()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Expected O, but got Unknown
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Expected O, but got Unknown
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: 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_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			if (alpha <= 0.01f || shown == null)
			{
				return;
			}
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser == null || (Object)(object)firstLocalUser.cameraRigController == (Object)null)
			{
				return;
			}
			Camera sceneCam = firstLocalUser.cameraRigController.sceneCam;
			if ((Object)(object)sceneCam == (Object)null)
			{
				return;
			}
			Vector3 val = sceneCam.WorldToScreenPoint(shown.WorldPos + Vector3.up * 0.5f);
			if (!(val.z <= 0f))
			{
				EnsureStyles();
				float num = (float)Screen.height * 0.012f;
				float num2 = (float)Screen.height * 0.4f * uiScale.Value;
				string text = ColorUtility.ToHtmlStringRGB(shown.Color);
				GUIContent val2 = new GUIContent("<color=#" + text + ">" + shown.Name + "</color>");
				string text2 = "<color=#" + text + ">" + shown.Category + "</color>";
				if (shown.TierLabel != null)
				{
					text2 = text2 + "  •  <b><color=#" + ColorUtility.ToHtmlStringRGB(shown.TierColor) + ">" + shown.TierLabel + "</color></b>";
				}
				if (shown.Status != null)
				{
					text2 = text2 + "  •  " + shown.Status;
				}
				GUIContent val3 = new GUIContent(text2);
				GUIContent val4 = new GUIContent(shown.Description);
				float num3 = num2 - num * 2f;
				float num4 = titleStyle.CalcHeight(val2, num3);
				float num5 = smallStyle.CalcHeight(val3, num3);
				float num6 = bodyStyle.CalcHeight(val4, num3);
				float num7 = num * 2f + num4 + num5 + num6 + num * 0.5f;
				float num8 = (float)Screen.height * 0.07f;
				float num9 = val.x + num8;
				if (num9 + num2 > (float)Screen.width - 8f)
				{
					num9 = val.x - num8 - num2;
				}
				float num10 = Mathf.Clamp((float)Screen.height - val.y - num7 * 0.5f, 8f, (float)Screen.height - num7 - 8f);
				Color color = GUI.color;
				GUI.color = new Color(1f, 1f, 1f, alpha);
				GUI.DrawTexture(new Rect(num9, num10, num2, num7), (Texture)(object)bgTex);
				GUI.color = new Color(shown.Color.r, shown.Color.g, shown.Color.b, alpha);
				GUI.DrawTexture(new Rect(num9, num10, Mathf.Max(3f, num * 0.35f), num7), (Texture)(object)Texture2D.whiteTexture);
				GUI.color = new Color(1f, 1f, 1f, alpha);
				float num11 = num9 + num;
				float num12 = num10 + num;
				GUI.Label(new Rect(num11, num12, num3, num4), val2, titleStyle);
				num12 += num4;
				GUI.Label(new Rect(num11, num12, num3, num5), val3, smallStyle);
				num12 += num5;
				GUI.Label(new Rect(num11, num12, num3, num6), val4, bodyStyle);
				GUI.color = color;
			}
		}
	}
}