Decompiled source of ResourceScanner v1.0.0

plugins/ResourceScanner/ResourceScanner.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace ResourceScanner;

public class HealthHud : MonoBehaviour
{
	private const float Width = 260f;

	private const float PadX = 14f;

	private const float PadY = 10f;

	private const float BarRowH = 24f;

	private const float CountH = 22f;

	private const float BarW = 160f;

	private const float BarH = 12f;

	private const float Gap = 10f;

	private const float BottomMargin = 14f;

	public static Target Current;

	private RectTransform _panel;

	private CanvasGroup _group;

	private TMP_Text _value;

	private TMP_Text _count;

	private RectTransform _barRoot;

	private List<GuiBar> _bars = new List<GuiBar>();

	private GuiBar _mainBar;

	private Image _fallbackFill;

	private Target _shown;

	private float _lastSeen = -99f;

	private float _nextScan;

	private string _lastLog = "";

	private void Update()
	{
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		if (!Plugin.Enabled.Value || (Object)(object)Hud.instance == (Object)null)
		{
			if ((Object)(object)_group != (Object)null)
			{
				_group.alpha = 0f;
			}
			return;
		}
		if ((Object)(object)_panel == (Object)null)
		{
			try
			{
				Build();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Could not build the health box: " + ex));
				((Behaviour)this).enabled = false;
				return;
			}
		}
		if (Time.time >= _nextScan)
		{
			_nextScan = Time.time + 0.1f;
			Target target = null;
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null && !((Character)localPlayer).IsDead() && !InventoryGui.IsVisible() && !Minimap.IsOpen())
			{
				try
				{
					target = Targets.Find(localPlayer);
				}
				catch (Exception ex2)
				{
					Plugin.Debug("Scan failed: " + ex2.Message);
				}
			}
			Current = target;
			if (target != null)
			{
				_shown = target;
				_lastSeen = Time.time;
				Show(target);
				LogTarget(target);
			}
		}
		bool flag = _shown != null && Time.time - _lastSeen <= Plugin.HideDelay.Value + 0.1f;
		_group.alpha = Mathf.MoveTowards(_group.alpha, flag ? 1f : 0f, Time.deltaTime * (flag ? 8f : 4f));
		if (!flag && _group.alpha <= 0f)
		{
			_shown = null;
		}
		float value = Plugin.Scale.Value;
		((Transform)_panel).localScale = new Vector3(value, value, 1f);
		if (_group.alpha > 0f)
		{
			Position();
		}
	}

	private void Position()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		float value = Plugin.Scale.Value;
		float num = 14f * value + _panel.sizeDelta.y * value + Plugin.PosY.Value;
		_panel.anchoredPosition = new Vector2(Plugin.PosX.Value, num);
	}

	private void LogTarget(Target t)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		if (Plugin.DetailedLog.Value)
		{
			string text = string.Concat(t.Kind, " (", ((Object)((Component)t.Key).gameObject).name, ")", (t.Area >= 0) ? (" piece " + t.Area) : "", ": ", t.Health.ToString("0.#"), " / ", t.Max.ToString("0.#"), (t.Total > 0) ? (", pieces left " + t.Left + "/" + t.Total) : "");
			if (text != _lastLog)
			{
				_lastLog = text;
				Plugin.Log.LogInfo((object)text);
			}
		}
	}

	private void Show(Target t)
	{
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: 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_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		float num = ((t.Max > 0f) ? Mathf.Clamp01(t.Health / t.Max) : 0f);
		bool flag = t.Total > 1;
		((Component)_count).gameObject.SetActive(flag);
		if (flag)
		{
			_count.text = t.Left + "/" + t.Total + " left";
		}
		_value.text = ((Plugin.Format.Value == ValueFormat.Numbers) ? (Mathf.CeilToInt(t.Health) + " / " + Mathf.RoundToInt(t.Max)) : (((t.Health > 0f) ? Mathf.Max(1, Mathf.FloorToInt(num * 100f)) : 0) + "%"));
		Color color = ((num > 0.5f) ? Color.Lerp(new Color(1f, 0.85f, 0.2f), new Color(0.35f, 0.85f, 0.3f), (num - 0.5f) * 2f) : Color.Lerp(new Color(0.9f, 0.2f, 0.15f), new Color(1f, 0.85f, 0.2f), num * 2f));
		if ((Object)(object)_mainBar != (Object)null)
		{
			foreach (GuiBar bar in _bars)
			{
				bar.SetMaxValue(1f);
				bar.SetValue(num);
			}
			_mainBar.SetColor(color);
		}
		else if ((Object)(object)_fallbackFill != (Object)null)
		{
			((Graphic)_fallbackFill).rectTransform.sizeDelta = new Vector2(160f * num, 12f);
			((Graphic)_fallbackFill).color = color;
		}
		Layout(flag);
	}

	private void Layout(bool showCount)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		float num = -10f;
		float num2 = Mathf.Max(30f, _value.preferredWidth);
		float num3 = 170f + num2;
		float num4 = num - 12f;
		_barRoot.anchoredPosition = new Vector2((0f - num3) / 2f + 80f, num4);
		_value.rectTransform.anchoredPosition = new Vector2((0f - num3) / 2f + 160f + 10f, num4);
		num -= 24f;
		if (showCount)
		{
			_count.rectTransform.anchoredPosition = new Vector2(0f, num);
			num -= 22f;
		}
		_panel.sizeDelta = new Vector2(260f, 0f - num + 10f);
	}

	private void Build()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Expected O, but got Unknown
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: 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_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		Transform val = (((Object)(object)Hud.instance.m_rootObject != (Object)null) ? Hud.instance.m_rootObject.transform : ((Component)Hud.instance).transform);
		GameObject val2 = new GameObject("ResourceScanner_Box", new Type[1] { typeof(RectTransform) });
		val2.transform.SetParent(val, false);
		_panel = (RectTransform)val2.transform;
		RectTransform panel = _panel;
		Vector2 anchorMin = (_panel.anchorMax = new Vector2(0.5f, 0f));
		panel.anchorMin = anchorMin;
		_panel.pivot = new Vector2(0.5f, 1f);
		_panel.sizeDelta = new Vector2(260f, 60f);
		_group = val2.AddComponent<CanvasGroup>();
		_group.alpha = 0f;
		_group.blocksRaycasts = false;
		_group.interactable = false;
		string text = CopyInventoryBackground(_panel);
		GameObject val4 = TooltipPrefab();
		TMP_Text val5 = null;
		if ((Object)(object)val4 != (Object)null)
		{
			TMP_Text[] componentsInChildren = val4.GetComponentsInChildren<TMP_Text>(true);
			foreach (TMP_Text val6 in componentsInChildren)
			{
				string text2 = ((Object)((Component)val6).gameObject).name.ToLowerInvariant();
				if (text2.Contains("text") && !text2.Contains("topic"))
				{
					val5 = val6;
					break;
				}
			}
		}
		if ((Object)(object)val5 == (Object)null)
		{
			val5 = (TMP_Text)(object)Hud.instance.m_hoverName;
		}
		BuildBar();
		_value = MakeText("Value", val5, 18f, (TextAlignmentOptions)4097, new Vector2(0f, 0.5f), 120f, 24f);
		_count = MakeText("Count", val5, 16f, (TextAlignmentOptions)258, new Vector2(0.5f, 1f), 232f, 22f);
		((Graphic)_value).color = Color.white;
		Layout(showCount: true);
		Plugin.Debug("Box built. Background: " + text + ", text font: " + (((Object)(object)val5 != (Object)null && (Object)(object)val5.font != (Object)null) ? (((Object)((Component)val5).gameObject).name + "/" + ((Object)val5.font).name) : "none") + ", bar: " + (((Object)(object)_mainBar != (Object)null) ? ("enemy bar (" + _bars.Count + " parts, main " + ((Object)((Component)_mainBar).gameObject).name + ")") : "plain"));
	}

	internal static string CopyInventoryBackground(RectTransform panel)
	{
		//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Expected O, but got Unknown
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Expected O, but got Unknown
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		string text = "";
		RectTransform val = (((Object)(object)InventoryGui.instance != (Object)null) ? InventoryGui.instance.m_player : null);
		if ((Object)(object)val != (Object)null)
		{
			List<Image> list = new List<Image>();
			Image component = ((Component)val).GetComponent<Image>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.sprite != (Object)null)
			{
				list.Add(component);
			}
			for (int i = 0; i < ((Transform)val).childCount; i++)
			{
				Transform child = ((Transform)val).GetChild(i);
				RectTransform val2 = (RectTransform)(object)((child is RectTransform) ? child : null);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				Image component2 = ((Component)val2).GetComponent<Image>();
				if (!((Object)(object)component2 == (Object)null) && !((Object)(object)component2.sprite == (Object)null))
				{
					bool flag = val2.anchorMin.x <= 0.01f && val2.anchorMin.y <= 0.01f && val2.anchorMax.x >= 0.99f && val2.anchorMax.y >= 0.99f;
					if (Plugin.DetailedLog.Value)
					{
						Plugin.Log.LogInfo((object)string.Concat("Inventory window child '", ((Object)val2).name, "' sprite ", ((Object)component2.sprite).name, " type ", component2.type, flag ? string.Concat(" (covers window, offsets ", val2.offsetMin, " ", val2.offsetMax, ")") : ""));
					}
					if (flag)
					{
						list.Add(component2);
					}
				}
			}
			foreach (Image item in list)
			{
				GameObject val3 = new GameObject("Bkg_" + ((Object)((Component)item).gameObject).name, new Type[1] { typeof(RectTransform) });
				val3.transform.SetParent((Transform)(object)panel, false);
				RectTransform val4 = (RectTransform)val3.transform;
				val4.anchorMin = Vector2.zero;
				val4.anchorMax = Vector2.one;
				if ((Object)(object)((Component)item).transform == (Object)(object)val)
				{
					val4.offsetMin = Vector2.zero;
					val4.offsetMax = Vector2.zero;
				}
				else
				{
					RectTransform rectTransform = ((Graphic)item).rectTransform;
					val4.offsetMin = rectTransform.offsetMin;
					val4.offsetMax = rectTransform.offsetMax;
				}
				Image val5 = val3.AddComponent<Image>();
				val5.sprite = item.sprite;
				val5.type = item.type;
				((Graphic)val5).material = ((Graphic)item).material;
				((Graphic)val5).color = ((Graphic)item).color;
				val5.pixelsPerUnitMultiplier = item.pixelsPerUnitMultiplier;
				((Graphic)val5).raycastTarget = false;
				string text2 = text;
				text = text2 + ((text.Length > 0) ? " + " : "") + ((Object)((Component)item).gameObject).name + "/" + ((Object)item.sprite).name;
			}
		}
		if (text.Length > 0)
		{
			return "inventory " + text;
		}
		Image val6 = ((Component)panel).gameObject.AddComponent<Image>();
		((Graphic)val6).color = new Color(0f, 0f, 0f, 0.65f);
		((Graphic)val6).raycastTarget = false;
		return "plain";
	}

	private TMP_Text MakeText(string name, TMP_Text src, float size, TextAlignmentOptions align, Vector2 pivot, float w, float h)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0076: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: 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_00b3: 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_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)
		GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
		val.transform.SetParent((Transform)(object)_panel, false);
		TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)src != (Object)null)
		{
			((TMP_Text)val2).font = src.font;
			((TMP_Text)val2).fontSharedMaterial = src.fontSharedMaterial;
			((Graphic)val2).color = ((Graphic)src).color;
			((TMP_Text)val2).fontStyle = src.fontStyle;
		}
		((TMP_Text)val2).fontSize = size;
		((TMP_Text)val2).alignment = align;
		((TMP_Text)val2).overflowMode = (TextOverflowModes)0;
		((Graphic)val2).raycastTarget = false;
		RectTransform rectTransform = ((TMP_Text)val2).rectTransform;
		Vector2 anchorMin = (rectTransform.anchorMax = new Vector2(0.5f, 1f));
		rectTransform.anchorMin = anchorMin;
		rectTransform.pivot = pivot;
		rectTransform.sizeDelta = new Vector2(w, h);
		return (TMP_Text)(object)val2;
	}

	private void BuildBar()
	{
		//IL_0599: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a0: Expected O, but got Unknown
		//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f6: Expected O, but got Unknown
		//IL_060c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0611: Unknown result type (might be due to invalid IL or missing references)
		//IL_0612: Unknown result type (might be due to invalid IL or missing references)
		//IL_0619: Unknown result type (might be due to invalid IL or missing references)
		//IL_0630: Unknown result type (might be due to invalid IL or missing references)
		//IL_064a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0671: Unknown result type (might be due to invalid IL or missing references)
		//IL_0678: Expected O, but got Unknown
		//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_06df: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f5: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Expected O, but got Unknown
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_0370: Unknown result type (might be due to invalid IL or missing references)
		//IL_048b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
		_bars.Clear();
		_mainBar = null;
		GameObject val = null;
		try
		{
			if ((Object)(object)EnemyHud.instance != (Object)null && (Object)(object)EnemyHud.instance.m_baseHud != (Object)null)
			{
				GuiBar[] componentsInChildren = EnemyHud.instance.m_baseHud.GetComponentsInChildren<GuiBar>(true);
				if (componentsInChildren.Length > 0)
				{
					Transform parent = ((Component)componentsInChildren[0]).transform.parent;
					val = (((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)EnemyHud.instance.m_baseHud.transform) ? ((Component)parent).gameObject : ((Component)componentsInChildren[0]).gameObject);
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Debug("Enemy bar lookup failed: " + ex.Message);
		}
		if ((Object)(object)val != (Object)null)
		{
			Transform transform = val.transform;
			RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			float num;
			if (!((Object)(object)val2 != (Object)null))
			{
				num = 0f;
			}
			else
			{
				Rect rect = val2.rect;
				num = ((Rect)(ref rect)).width;
			}
			float num2 = num;
			float num3;
			if (!((Object)(object)val2 != (Object)null))
			{
				num3 = 0f;
			}
			else
			{
				Rect rect2 = val2.rect;
				num3 = ((Rect)(ref rect2)).height;
			}
			float num4 = num3;
			if (num2 < 1f && (Object)(object)val2 != (Object)null)
			{
				num2 = val2.sizeDelta.x;
				num4 = val2.sizeDelta.y;
			}
			if (num2 >= 1f && num4 >= 1f)
			{
				GameObject val3 = Object.Instantiate<GameObject>(val, (Transform)(object)_panel, false);
				((Object)val3).name = "Bar";
				val3.SetActive(true);
				TMP_Text[] componentsInChildren2 = val3.GetComponentsInChildren<TMP_Text>(true);
				foreach (TMP_Text val4 in componentsInChildren2)
				{
					((Component)val4).gameObject.SetActive(false);
				}
				float num5 = 160f / num2;
				float num6 = 12f / num4;
				RectTransform[] componentsInChildren3 = val3.GetComponentsInChildren<RectTransform>(true);
				foreach (RectTransform val5 in componentsInChildren3)
				{
					if (!((Object)(object)val5 == (Object)(object)val3.transform))
					{
						Vector2 sizeDelta = val5.sizeDelta;
						Vector2 anchoredPosition = val5.anchoredPosition;
						if (Mathf.Approximately(val5.anchorMin.x, val5.anchorMax.x))
						{
							sizeDelta.x *= num5;
							anchoredPosition.x *= num5;
						}
						if (Mathf.Approximately(val5.anchorMin.y, val5.anchorMax.y))
						{
							sizeDelta.y *= num6;
							anchoredPosition.y *= num6;
						}
						val5.sizeDelta = sizeDelta;
						val5.anchoredPosition = anchoredPosition;
					}
				}
				_barRoot = (RectTransform)val3.transform;
				RectTransform barRoot = _barRoot;
				Vector2 anchorMin = (_barRoot.anchorMax = new Vector2(0.5f, 1f));
				barRoot.anchorMin = anchorMin;
				_barRoot.pivot = new Vector2(0.5f, 0.5f);
				_barRoot.sizeDelta = new Vector2(160f, 12f);
				((Transform)_barRoot).localScale = Vector3.one;
				_bars.AddRange(val3.GetComponentsInChildren<GuiBar>(true));
				foreach (GuiBar bar in _bars)
				{
					RectTransform value = Traverse.Create((object)bar).Field<RectTransform>("m_bar").Value;
					if ((Object)(object)value != (Object)null)
					{
						Traverse.Create((object)bar).Field<float>("m_width").Value = value.sizeDelta.x;
					}
				}
				foreach (GuiBar bar2 in _bars)
				{
					if (((Object)((Component)bar2).gameObject).name.ToLowerInvariant().Contains("fast"))
					{
						_mainBar = bar2;
					}
				}
				if ((Object)(object)_mainBar == (Object)null && _bars.Count > 0)
				{
					_mainBar = _bars[_bars.Count - 1];
				}
				if (Plugin.DetailedLog.Value)
				{
					string text = "";
					RectTransform[] componentsInChildren4 = val3.GetComponentsInChildren<RectTransform>(true);
					foreach (RectTransform val7 in componentsInChildren4)
					{
						string text2 = text;
						string[] array = new string[8]
						{
							text2,
							" ",
							((Object)val7).name,
							"[",
							null,
							null,
							null,
							null
						};
						float x = val7.sizeDelta.x;
						array[4] = x.ToString("0");
						array[5] = "x";
						float y = val7.sizeDelta.y;
						array[6] = y.ToString("0");
						array[7] = "]";
						text = string.Concat(array);
					}
					Plugin.Log.LogInfo((object)("Bar copied from '" + ((Object)val).name + "' (" + num2.ToString("0") + "x" + num4.ToString("0") + "):" + text));
				}
				if ((Object)(object)_mainBar != (Object)null)
				{
					return;
				}
				Object.Destroy((Object)(object)val3);
				_bars.Clear();
			}
		}
		GameObject val8 = new GameObject("Bar", new Type[1] { typeof(RectTransform) });
		val8.transform.SetParent((Transform)(object)_panel, false);
		Image val9 = val8.AddComponent<Image>();
		((Graphic)val9).color = new Color(0f, 0f, 0f, 0.6f);
		((Graphic)val9).raycastTarget = false;
		_barRoot = (RectTransform)val8.transform;
		RectTransform barRoot2 = _barRoot;
		Vector2 anchorMin2 = (_barRoot.anchorMax = new Vector2(0.5f, 1f));
		barRoot2.anchorMin = anchorMin2;
		_barRoot.pivot = new Vector2(0.5f, 0.5f);
		_barRoot.sizeDelta = new Vector2(160f, 12f);
		GameObject val11 = new GameObject("Fill", new Type[1] { typeof(RectTransform) });
		val11.transform.SetParent((Transform)(object)_barRoot, false);
		_fallbackFill = val11.AddComponent<Image>();
		((Graphic)_fallbackFill).raycastTarget = false;
		RectTransform rectTransform = ((Graphic)_fallbackFill).rectTransform;
		Vector2 anchorMin3 = (rectTransform.anchorMax = new Vector2(0f, 0.5f));
		rectTransform.anchorMin = anchorMin3;
		rectTransform.pivot = new Vector2(0f, 0.5f);
		rectTransform.sizeDelta = new Vector2(160f, 12f);
	}

	private static GameObject TooltipPrefab()
	{
		try
		{
			UITooltip[] array = Resources.FindObjectsOfTypeAll<UITooltip>();
			foreach (UITooltip val in array)
			{
				GameObject value = Traverse.Create((object)val).Field("m_tooltipPrefab").GetValue<GameObject>();
				if ((Object)(object)value != (Object)null)
				{
					return value;
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Debug("Tooltip lookup failed: " + ex.Message);
		}
		return null;
	}
}
public enum ValueFormat
{
	Percent,
	Numbers
}
[BepInPlugin("felih.ResourceScanner", "Resource Scanner", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public const string GUID = "felih.ResourceScanner";

	public const string NAME = "Resource Scanner";

	public const string VERSION = "1.0.0";

	public static ManualLogSource Log;

	public static ConfigEntry<bool> Enabled;

	public static ConfigEntry<bool> RequireTool;

	public static ConfigEntry<ValueFormat> Format;

	public static ConfigEntry<float> Reach;

	public static ConfigEntry<float> HideDelay;

	public static ConfigEntry<float> PosX;

	public static ConfigEntry<float> PosY;

	public static ConfigEntry<float> Scale;

	public static ConfigEntry<bool> XRay;

	public static ConfigEntry<KeyCode> XRayKey;

	public static ConfigEntry<float> XRayCloseAfter;

	public static ConfigEntry<float> XRaySize;

	public static ConfigEntry<bool> XRayGroundPlane;

	public static ConfigEntry<float> XRayOffsetX;

	public static ConfigEntry<float> XRayOffsetY;

	public static ConfigEntry<bool> DetailedLog;

	private void Awake()
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Expected O, but got Unknown
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Expected O, but got Unknown
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Expected O, but got Unknown
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Expected O, but got Unknown
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "Enabled", true, "Turns the mod on or off.");
		RequireTool = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "RequireTool", true, "Only show the box while holding the right tool: an axe for trees, logs and stumps, a pickaxe for rocks and ores. Nests show with anything in hand.");
		Reach = ((BaseUnityPlugin)this).Config.Bind<float>("1 - General", "Reach", 4f, new ConfigDescription("How far past your character (meters) an object can be.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 15f), new object[0]));
		HideDelay = ((BaseUnityPlugin)this).Config.Bind<float>("1 - General", "HideDelay", 1f, new ConfigDescription("Seconds the box stays after you stop aiming.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[0]));
		Format = ((BaseUnityPlugin)this).Config.Bind<ValueFormat>("2 - Display", "Format", ValueFormat.Percent, "Percent = 62%. Numbers = 1240 / 2000.");
		PosX = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Display", "OffsetX", 0f, "Horizontal offset from the center of the screen.");
		PosY = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Display", "OffsetY", 0f, "Vertical offset from the bottom of the screen (positive = up).");
		Scale = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Display", "Scale", 1f, new ConfigDescription("Size of the box.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), new object[0]));
		XRay = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - X-ray", "Enabled", true, "Press XRayKey with a pickaxe while aiming at an ore deposit or a big rock to open a small window under the minimap with a live 3D view of the whole deposit without the ground, buried pieces included. The piece you aim at is highlighted.");
		XRayKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("3 - X-ray", "XRayKey", (KeyCode)324, "Key or mouse button that opens the window. Mouse1 = right mouse button.");
		XRayCloseAfter = ((BaseUnityPlugin)this).Config.Bind<float>("3 - X-ray", "CloseAfter", 3f, new ConfigDescription("The window closes after this many seconds without aiming at the deposit (or when you put the pickaxe away).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), new object[0]));
		XRaySize = ((BaseUnityPlugin)this).Config.Bind<float>("3 - X-ray", "WindowSize", 220f, new ConfigDescription("Size of the 3D view (applies after restarting the game).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 600f), new object[0]));
		XRayGroundPlane = ((BaseUnityPlugin)this).Config.Bind<bool>("3 - X-ray", "GroundPlane", true, "Draw a see-through plane at ground level, so you can tell what's buried.");
		XRayOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("3 - X-ray", "WindowOffsetX", 0f, "Moves the window sideways (positive = right).");
		XRayOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("3 - X-ray", "WindowOffsetY", 0f, "Moves the window up or down (positive = up).");
		DetailedLog = ((BaseUnityPlugin)this).Config.Bind<bool>("9 - Debug", "DetailedLog", false, "Writes what the box is showing and how it was built to the BepInEx log.");
		GameObject val = new GameObject("ResourceScanner_Manager");
		Object.DontDestroyOnLoad((Object)(object)val);
		val.AddComponent<HealthHud>();
		val.AddComponent<XRay>();
		Log.LogInfo((object)"Resource Scanner 1.0.0 loaded.");
	}

	public static void Debug(string msg)
	{
		if (DetailedLog.Value)
		{
			Log.LogInfo((object)msg);
		}
	}
}
public enum Kind
{
	Tree,
	Log,
	Stump,
	Rock,
	Deposit,
	Nest
}
public class Target
{
	public Kind Kind;

	public Object Key;

	public int Area = -1;

	public float Health;

	public float Max;

	public int Left = -1;

	public int Total = -1;
}
public static class Targets
{
	private static MethodInfo _mr5AreaIndex;

	private static MethodInfo _mrAreaIndex;

	private static MethodInfo _mrHealth;

	private static FieldInfo _mr5Areas;

	private static FieldInfo _mrAreas;

	public static Target Find(Player player)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//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_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: 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)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		Camera main = Camera.main;
		if ((Object)(object)main == (Object)null)
		{
			return null;
		}
		Vector3 position = ((Component)main).transform.position;
		Vector3 forward = ((Component)main).transform.forward;
		float num = Vector3.Distance(position, ((Character)player).GetEyePoint()) + Plugin.Reach.Value;
		bool blocked;
		Target target = First(player, Physics.RaycastAll(position, forward, num, -1, (QueryTriggerInteraction)1), out blocked);
		if (target == null && !blocked)
		{
			target = First(player, Physics.SphereCastAll(position, 0.2f, forward, num, -1, (QueryTriggerInteraction)1), out blocked);
		}
		return target;
	}

	private static Target First(Player player, RaycastHit[] hits, out bool blocked)
	{
		blocked = false;
		Array.Sort(hits, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
		for (int num = 0; num < hits.Length; num++)
		{
			Collider collider = ((RaycastHit)(ref hits[num])).collider;
			if ((Object)(object)collider == (Object)null || ((Component)collider).transform.IsChildOf(((Component)player).transform))
			{
				continue;
			}
			bool known;
			Target target = Read(collider, out known);
			if (known)
			{
				if (target != null && !ToolFits(player, target.Kind))
				{
					target = null;
				}
				blocked = true;
				return target;
			}
			if ((Object)(object)((Component)collider).GetComponentInParent<Heightmap>() != (Object)null || (Object)(object)((Component)collider).GetComponentInParent<WearNTear>() != (Object)null)
			{
				blocked = true;
				return null;
			}
		}
		return null;
	}

	private static bool ToolFits(Player player, Kind kind)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Invalid comparison between Unknown and I4
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Invalid comparison between Unknown and I4
		if (!Plugin.RequireTool.Value || kind == Kind.Nest)
		{
			return true;
		}
		ItemData currentWeapon = ((Humanoid)player).GetCurrentWeapon();
		if (currentWeapon == null)
		{
			return false;
		}
		SkillType skillType = currentWeapon.m_shared.m_skillType;
		if (kind == Kind.Tree || kind == Kind.Log || kind == Kind.Stump)
		{
			return (int)skillType == 7;
		}
		return (int)skillType == 12;
	}

	private static Target Read(Collider c, out bool known)
	{
		known = false;
		MineRock5 componentInParent = ((Component)c).GetComponentInParent<MineRock5>();
		if ((Object)(object)componentInParent != (Object)null)
		{
			known = true;
			return Deposit5(componentInParent, c);
		}
		MineRock componentInParent2 = ((Component)c).GetComponentInParent<MineRock>();
		if ((Object)(object)componentInParent2 != (Object)null)
		{
			known = true;
			return Deposit(componentInParent2, c);
		}
		TreeLog componentInParent3 = ((Component)c).GetComponentInParent<TreeLog>();
		if ((Object)(object)componentInParent3 != (Object)null)
		{
			known = true;
			return Simple((MonoBehaviour)(object)componentInParent3, Kind.Log, componentInParent3.m_health);
		}
		TreeBase componentInParent4 = ((Component)c).GetComponentInParent<TreeBase>();
		if ((Object)(object)componentInParent4 != (Object)null)
		{
			known = true;
			return Simple((MonoBehaviour)(object)componentInParent4, Kind.Tree, componentInParent4.m_health);
		}
		Destructible componentInParent5 = ((Component)c).GetComponentInParent<Destructible>();
		if ((Object)(object)componentInParent5 != (Object)null)
		{
			if (!Classify(componentInParent5, out var kind))
			{
				return null;
			}
			known = true;
			return Simple((MonoBehaviour)(object)componentInParent5, kind, componentInParent5.m_health);
		}
		return null;
	}

	private static bool Classify(Destructible d, out Kind kind)
	{
		kind = Kind.Rock;
		string text = ((Object)((Component)d).gameObject).name.ToLowerInvariant();
		if ((Object)(object)((Component)d).GetComponent<SpawnArea>() != (Object)null || text.Contains("nest") || text.Contains("spawner") || text.Contains("bonepile") || text.Contains("bodypile"))
		{
			kind = Kind.Nest;
			return true;
		}
		if (text.Contains("stub") || text.Contains("stump"))
		{
			kind = Kind.Stump;
			return true;
		}
		if (text.Contains("rock") || text.Contains("deposit") || text.Contains("tin") || text.Contains("ore") || text.Contains("marble") || text.Contains("stone"))
		{
			kind = Kind.Rock;
			return true;
		}
		return false;
	}

	private static float WorldMax(float baseHp)
	{
		if ((Object)(object)Game.instance == (Object)null)
		{
			return baseHp;
		}
		return baseHp + (float)Game.m_worldLevel * baseHp * Game.instance.m_worldLevelMineHPMultiplier;
	}

	private static ZDO Zdo(Component c)
	{
		ZNetView val = c.GetComponent<ZNetView>();
		if ((Object)(object)val == (Object)null)
		{
			val = c.GetComponentInParent<ZNetView>();
		}
		if (!((Object)(object)val != (Object)null) || !val.IsValid())
		{
			return null;
		}
		return val.GetZDO();
	}

	private static Target Simple(MonoBehaviour obj, Kind kind, float baseHp)
	{
		ZDO val = Zdo((Component)(object)obj);
		if (val == null)
		{
			return null;
		}
		float num = WorldMax(baseHp);
		Target target = new Target();
		target.Kind = kind;
		target.Key = (Object)(object)obj;
		target.Max = num;
		target.Health = Mathf.Clamp(val.GetFloat(ZDOVars.s_health, num), 0f, num);
		return target;
	}

	private static Target Deposit5(MineRock5 m5, Collider c)
	{
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Expected O, but got Unknown
		ZDO val = Zdo((Component)(object)m5);
		if (val == null)
		{
			return null;
		}
		if (_mr5AreaIndex == null)
		{
			_mr5AreaIndex = AccessTools.Method(typeof(MineRock5), "GetAreaIndex", new Type[1] { typeof(Collider) }, (Type[])null);
			_mr5Areas = AccessTools.Field(typeof(MineRock5), "m_hitAreas");
		}
		IList list = _mr5Areas.GetValue(m5) as IList;
		int num = (int)_mr5AreaIndex.Invoke(m5, new object[1] { c });
		if (list == null || num < 0)
		{
			return null;
		}
		float num2 = WorldMax(m5.m_health);
		float[] array = new float[list.Count];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = num2;
		}
		string text = val.GetString(ZDOVars.s_health, "");
		if (text.Length > 0)
		{
			ZPackage val2 = new ZPackage(Convert.FromBase64String(text));
			int num3 = val2.ReadInt();
			for (int j = 0; j < num3; j++)
			{
				float num4 = val2.ReadSingle();
				if (j < array.Length)
				{
					array[j] = num4;
				}
			}
		}
		Target target = new Target();
		target.Kind = Kind.Deposit;
		target.Key = (Object)(object)m5;
		target.Area = num;
		target.Max = num2;
		target.Health = ((num < array.Length) ? Mathf.Clamp(array[num], 0f, num2) : num2);
		target.Total = array.Length;
		target.Left = 0;
		for (int k = 0; k < array.Length; k++)
		{
			if (array[k] > 0f)
			{
				target.Left++;
			}
		}
		return target;
	}

	private static Target Deposit(MineRock mr, Collider c)
	{
		ZDO val = Zdo((Component)(object)mr);
		if (val == null)
		{
			return null;
		}
		if (_mrAreaIndex == null)
		{
			_mrAreaIndex = AccessTools.Method(typeof(MineRock), "GetAreaIndex", new Type[1] { typeof(Collider) }, (Type[])null);
			_mrHealth = AccessTools.Method(typeof(MineRock), "GetHealth", (Type[])null, (Type[])null);
			_mrAreas = AccessTools.Field(typeof(MineRock), "m_hitAreas");
		}
		Collider[] array = _mrAreas.GetValue(mr) as Collider[];
		int num = (int)_mrAreaIndex.Invoke(mr, new object[1] { c });
		if (array == null || num < 0)
		{
			return null;
		}
		float num2 = (float)_mrHealth.Invoke(mr, null);
		Target target = new Target();
		target.Kind = Kind.Deposit;
		target.Key = (Object)(object)mr;
		target.Area = num;
		target.Max = num2;
		target.Total = array.Length;
		target.Left = 0;
		for (int i = 0; i < array.Length; i++)
		{
			float num3 = val.GetFloat("Health" + i, num2);
			if (num3 > 0f)
			{
				target.Left++;
			}
			if (i == num)
			{
				target.Health = Mathf.Clamp(num3, 0f, num2);
			}
		}
		return target;
	}
}
public class XRay : MonoBehaviour
{
	private class Piece
	{
		public int Index;

		public Transform T;

		public Mesh Mesh;

		public Material[] Mats;
	}

	private const float BelowMinimap = 40f;

	private const float Pad = 10f;

	private const float CountH = 24f;

	private Object _object;

	private float _lastAim;

	private int _aimed = -1;

	private int _total;

	private readonly List<Piece> _pieces = new List<Piece>();

	private Vector3 _center;

	private float _radius = 1f;

	private float _ground;

	private bool _hasGround;

	private string _lastLog = "";

	private RectTransform _win;

	private RawImage _raw;

	private TMP_Text _count;

	private Camera _cam;

	private Light _light;

	private RenderTexture _rt;

	private int _layer = -1;

	private Mesh _quad;

	private Material _planeMat;

	private Material _aimMat;

	private static FieldInfo _m5Areas;

	private static FieldInfo _haHealth;

	private static FieldInfo _haMesh;

	private static FieldInfo _haRenderer;

	private static FieldInfo _mrAreas;

	private static FieldInfo _mrMeshes;

	private readonly Vector3[] _corners = (Vector3[])(object)new Vector3[4];

	private void Update()
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Invalid comparison between Unknown and I4
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		if (!Plugin.Enabled.Value || !Plugin.XRay.Value)
		{
			Close();
			return;
		}
		Player localPlayer = Player.m_localPlayer;
		ItemData val = (((Object)(object)localPlayer != (Object)null) ? ((Humanoid)localPlayer).GetCurrentWeapon() : null);
		if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || val == null || (int)val.m_shared.m_skillType != 12)
		{
			Close();
			return;
		}
		Target current = HealthHud.Current;
		bool flag = current != null && current.Kind == Kind.Deposit && current.Key != (Object)null;
		if (flag && Input.GetKeyDown(Plugin.XRayKey.Value) && (_object == (Object)null || _object != current.Key))
		{
			Open(current.Key);
		}
		if (_object == (Object)null)
		{
			Close();
			return;
		}
		if (flag && current.Key == _object)
		{
			_lastAim = Time.time;
			_aimed = current.Area;
		}
		else
		{
			_aimed = -1;
		}
		if (Time.time - _lastAim > Plugin.XRayCloseAfter.Value)
		{
			Close();
			return;
		}
		try
		{
			Collect();
			if (_pieces.Count == 0)
			{
				Close();
				return;
			}
			Render();
			_count.text = _pieces.Count + "/" + _total + " left";
			Position();
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("X-ray window failed: " + ex));
			Close();
		}
	}

	private void Open(Object obj)
	{
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: 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)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: 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_012d: 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)
		if (_layer < 0)
		{
			_layer = FreeLayer();
		}
		if (_layer < 0)
		{
			Plugin.Log.LogWarning((object)"No free layer for the X-ray camera; X-ray is off.");
			Plugin.XRay.Value = false;
			return;
		}
		if ((Object)(object)_win == (Object)null)
		{
			BuildWindow();
		}
		if ((Object)(object)_cam == (Object)null)
		{
			BuildCamera();
		}
		_object = obj;
		_lastAim = Time.time;
		Collect();
		if (_pieces.Count == 0)
		{
			_object = null;
			return;
		}
		Bounds val = default(Bounds);
		bool flag = true;
		foreach (Piece piece in _pieces)
		{
			Bounds bounds = piece.Mesh.bounds;
			Vector3 min = ((Bounds)(ref bounds)).min;
			Vector3 max = ((Bounds)(ref bounds)).max;
			for (int i = 0; i < 8; i++)
			{
				Vector3 val2 = piece.T.TransformPoint(new Vector3(((i & 1) == 0) ? min.x : max.x, ((i & 2) == 0) ? min.y : max.y, ((i & 4) == 0) ? min.z : max.z));
				if (flag)
				{
					val = new Bounds(val2, Vector3.zero);
					flag = false;
				}
				else
				{
					((Bounds)(ref val)).Encapsulate(val2);
				}
			}
		}
		_center = ((Bounds)(ref val)).center;
		Vector3 extents = ((Bounds)(ref val)).extents;
		_radius = Mathf.Max(0.5f, ((Vector3)(ref extents)).magnitude);
		float num = 0f;
		_hasGround = (Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(_center, ref num);
		_ground = (_hasGround ? num : 0f);
		((Component)_win).gameObject.SetActive(true);
		((Behaviour)_cam).enabled = true;
		object[] array = new object[17]
		{
			"X-ray window opened on ",
			((Object)((Component)obj).gameObject).name,
			": ",
			_pieces.Count,
			"/",
			_total,
			" pieces, size ",
			null,
			null,
			null,
			null,
			null,
			null,
			null,
			null,
			null,
			null
		};
		float x = ((Bounds)(ref val)).size.x;
		array[7] = x.ToString("0.0");
		array[8] = " x ";
		float y = ((Bounds)(ref val)).size.y;
		array[9] = y.ToString("0.0");
		array[10] = " x ";
		float z = ((Bounds)(ref val)).size.z;
		array[11] = z.ToString("0.0");
		array[12] = " m, ground ";
		array[13] = (_hasGround ? ((_ground - ((Bounds)(ref val)).min.y).ToString("0.0") + " m above the bottom") : "unknown");
		array[14] = ", layer ";
		array[15] = _layer;
		array[16] = ".";
		Plugin.Debug(string.Concat(array));
	}

	private void Close()
	{
		if (!(_object == (Object)null) || (!((Object)(object)_win == (Object)null) && ((Component)_win).gameObject.activeSelf))
		{
			if (_object != (Object)null || (Object)(object)_win != (Object)null)
			{
				Plugin.Debug("X-ray window closed.");
			}
			_object = null;
			_pieces.Clear();
			if ((Object)(object)_win != (Object)null)
			{
				((Component)_win).gameObject.SetActive(false);
			}
			if ((Object)(object)_cam != (Object)null)
			{
				((Behaviour)_cam).enabled = false;
			}
		}
	}

	private static int FreeLayer()
	{
		for (int num = 31; num >= 8; num--)
		{
			if (string.IsNullOrEmpty(LayerMask.LayerToName(num)))
			{
				return num;
			}
		}
		return -1;
	}

	private void Collect()
	{
		_pieces.Clear();
		Object obj = _object;
		MineRock5 val = (MineRock5)(object)((obj is MineRock5) ? obj : null);
		if ((Object)(object)val != (Object)null)
		{
			Collect5(val);
			return;
		}
		Object obj2 = _object;
		MineRock val2 = (MineRock)(object)((obj2 is MineRock) ? obj2 : null);
		if ((Object)(object)val2 != (Object)null)
		{
			CollectOld(val2);
		}
	}

	private void Collect5(MineRock5 m5)
	{
		if (_m5Areas == null)
		{
			_m5Areas = AccessTools.Field(typeof(MineRock5), "m_hitAreas");
			Type nestedType = typeof(MineRock5).GetNestedType("HitArea", BindingFlags.Public | BindingFlags.NonPublic);
			_haHealth = AccessTools.Field(nestedType, "m_health");
			_haMesh = AccessTools.Field(nestedType, "m_meshFilter");
			_haRenderer = AccessTools.Field(nestedType, "m_meshRenderer");
		}
		if (!(_m5Areas.GetValue(m5) is IList list))
		{
			return;
		}
		_total = list.Count;
		for (int i = 0; i < list.Count; i++)
		{
			object obj = list[i];
			if (!((float)_haHealth.GetValue(obj) <= 0f))
			{
				object? value = _haMesh.GetValue(obj);
				MeshFilter mf = (MeshFilter)((value is MeshFilter) ? value : null);
				object? value2 = _haRenderer.GetValue(obj);
				MeshRenderer mr = (MeshRenderer)((value2 is MeshRenderer) ? value2 : null);
				Add(i, mf, mr);
			}
		}
	}

	private void CollectOld(MineRock mr)
	{
		if (_mrAreas == null)
		{
			_mrAreas = AccessTools.Field(typeof(MineRock), "m_hitAreas");
			_mrMeshes = AccessTools.Field(typeof(MineRock), "m_areaMeshes");
		}
		Collider[] array = _mrAreas.GetValue(mr) as Collider[];
		MeshRenderer[][] array2 = _mrMeshes.GetValue(mr) as MeshRenderer[][];
		if (array == null)
		{
			return;
		}
		_total = array.Length;
		for (int i = 0; i < array.Length; i++)
		{
			if (!((Object)(object)array[i] == (Object)null) && ((Component)array[i]).gameObject.activeInHierarchy && array2 != null && i < array2.Length && array2[i] != null)
			{
				MeshRenderer[] array3 = array2[i];
				foreach (MeshRenderer val in array3)
				{
					Add(i, ((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<MeshFilter>() : null, val);
				}
			}
		}
	}

	private void Add(int index, MeshFilter mf, MeshRenderer mr)
	{
		if (!((Object)(object)mf == (Object)null) && !((Object)(object)mf.sharedMesh == (Object)null) && !((Object)(object)mr == (Object)null))
		{
			Piece piece = new Piece();
			piece.Index = index;
			piece.T = ((Component)mf).transform;
			piece.Mesh = mf.sharedMesh;
			piece.Mats = ((Renderer)mr).sharedMaterials;
			if (piece.Mats != null && piece.Mats.Length != 0)
			{
				_pieces.Add(piece);
			}
		}
	}

	private void Render()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: 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)
		//IL_0067: 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_006d: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: 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_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		Transform val = (((Object)(object)Camera.main != (Object)null) ? ((Component)Camera.main).transform : null);
		float num = (((Object)(object)val != (Object)null) ? val.eulerAngles.y : 0f);
		Quaternion val2 = Quaternion.Euler(35f, num, 0f);
		float num2 = _radius * 3f + 5f;
		((Component)_cam).transform.position = _center - val2 * Vector3.forward * num2;
		((Component)_cam).transform.rotation = val2;
		_cam.orthographicSize = _radius * 1.05f;
		_cam.nearClipPlane = 0.1f;
		_cam.farClipPlane = num2 + _radius * 2f + 5f;
		((Component)_light).transform.rotation = val2 * Quaternion.Euler(25f, -35f, 0f);
		foreach (Piece piece in _pieces)
		{
			Matrix4x4 localToWorldMatrix = piece.T.localToWorldMatrix;
			int subMeshCount = piece.Mesh.subMeshCount;
			for (int i = 0; i < subMeshCount; i++)
			{
				Material val3 = piece.Mats[Mathf.Min(i, piece.Mats.Length - 1)];
				if ((Object)(object)val3 != (Object)null)
				{
					Graphics.DrawMesh(piece.Mesh, localToWorldMatrix, val3, _layer, _cam, i);
				}
			}
			if (piece.Index == _aimed)
			{
				for (int j = 0; j < subMeshCount; j++)
				{
					Graphics.DrawMesh(piece.Mesh, localToWorldMatrix, _aimMat, _layer, _cam, j);
				}
			}
		}
		if (Plugin.XRayGroundPlane.Value && _hasGround)
		{
			float num3 = _radius * 2.4f;
			Matrix4x4 val4 = Matrix4x4.TRS(new Vector3(_center.x, _ground, _center.z), Quaternion.identity, new Vector3(num3, 1f, num3));
			Graphics.DrawMesh(_quad, val4, _planeMat, _layer, _cam);
		}
	}

	private void BuildCamera()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Expected O, but got Unknown
		//IL_008b: 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: Expected O, but got Unknown
		//IL_0167: 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_01b5: Expected O, but got Unknown
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Expected O, but got Unknown
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Expected O, but got Unknown
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Expected O, but got Unknown
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Expected O, but got Unknown
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: 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)
		int num = Mathf.RoundToInt(Plugin.XRaySize.Value);
		_rt = new RenderTexture(num, num, 24, (RenderTextureFormat)0);
		((Object)_rt).name = "ResourceScanner_XRay";
		GameObject val = new GameObject("ResourceScanner_XRayCamera");
		Object.DontDestroyOnLoad((Object)(object)val);
		_cam = val.AddComponent<Camera>();
		((Behaviour)_cam).enabled = false;
		_cam.orthographic = true;
		_cam.clearFlags = (CameraClearFlags)2;
		_cam.backgroundColor = new Color(0f, 0f, 0f, 0f);
		_cam.cullingMask = 1 << _layer;
		_cam.targetTexture = _rt;
		_cam.renderingPath = (RenderingPath)1;
		_cam.allowHDR = false;
		_cam.allowMSAA = false;
		_cam.useOcclusionCulling = false;
		_cam.depth = -50f;
		_raw.texture = (Texture)(object)_rt;
		GameObject val2 = new GameObject("ResourceScanner_XRayLight");
		val2.transform.SetParent(val.transform, false);
		_light = val2.AddComponent<Light>();
		_light.type = (LightType)1;
		_light.intensity = 1.1f;
		_light.color = new Color(1f, 0.97f, 0.9f);
		_light.shadows = (LightShadows)0;
		_light.cullingMask = 1 << _layer;
		((Behaviour)_light).enabled = false;
		Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(LightOn));
		Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(LightOff));
		_quad = new Mesh();
		_quad.vertices = (Vector3[])(object)new Vector3[4]
		{
			new Vector3(-0.5f, 0f, -0.5f),
			new Vector3(0.5f, 0f, -0.5f),
			new Vector3(0.5f, 0f, 0.5f),
			new Vector3(-0.5f, 0f, 0.5f)
		};
		_quad.triangles = new int[6] { 0, 2, 1, 0, 3, 2 };
		_quad.RecalculateNormals();
		_quad.RecalculateBounds();
		Shader sh = Shader.Find("Hidden/Internal-Colored");
		_planeMat = Translucent(sh, new Color(0.45f, 0.33f, 0.2f, 0.45f));
		_aimMat = Translucent(sh, new Color(1f, 0.9f, 0.3f, 0.35f));
	}

	private void LightOn(Camera c)
	{
		if ((Object)(object)c == (Object)(object)_cam && (Object)(object)_light != (Object)null)
		{
			((Behaviour)_light).enabled = true;
		}
	}

	private void LightOff(Camera c)
	{
		if ((Object)(object)c == (Object)(object)_cam && (Object)(object)_light != (Object)null)
		{
			((Behaviour)_light).enabled = false;
		}
	}

	private void OnDestroy()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(LightOn));
		Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(LightOff));
	}

	private static Material Translucent(Shader sh, Color c)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		Material val = new Material(sh);
		((Object)val).hideFlags = (HideFlags)61;
		val.SetInt("_SrcBlend", 5);
		val.SetInt("_DstBlend", 10);
		val.SetInt("_Cull", 0);
		val.SetInt("_ZWrite", 0);
		val.SetInt("_ZTest", 4);
		val.renderQueue = 3000;
		val.color = c;
		return val;
	}

	private void BuildWindow()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Expected O, but got Unknown
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: 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_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Expected O, but got Unknown
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Expected O, but got Unknown
		//IL_0254: 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_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		Transform val = (((Object)(object)Hud.instance != (Object)null && (Object)(object)Hud.instance.m_rootObject != (Object)null) ? Hud.instance.m_rootObject.transform : null);
		if ((Object)(object)val == (Object)null)
		{
			throw new Exception("HUD not ready");
		}
		float value = Plugin.XRaySize.Value;
		GameObject val2 = new GameObject("ResourceScanner_XRayWindow", new Type[1] { typeof(RectTransform) });
		val2.transform.SetParent(val, false);
		_win = (RectTransform)val2.transform;
		RectTransform win = _win;
		Vector2 anchorMin = (_win.anchorMax = new Vector2(1f, 1f));
		win.anchorMin = anchorMin;
		_win.pivot = new Vector2(0.5f, 1f);
		_win.sizeDelta = new Vector2(value + 20f, value + 20f + 24f);
		CanvasGroup val4 = val2.AddComponent<CanvasGroup>();
		val4.blocksRaycasts = false;
		val4.interactable = false;
		HealthHud.CopyInventoryBackground(_win);
		GameObject val5 = new GameObject("View", new Type[1] { typeof(RectTransform) });
		val5.transform.SetParent((Transform)(object)_win, false);
		_raw = val5.AddComponent<RawImage>();
		((Graphic)_raw).raycastTarget = false;
		RectTransform rectTransform = ((Graphic)_raw).rectTransform;
		Vector2 anchorMin2 = (rectTransform.anchorMax = new Vector2(0.5f, 1f));
		rectTransform.anchorMin = anchorMin2;
		rectTransform.pivot = new Vector2(0.5f, 1f);
		rectTransform.sizeDelta = new Vector2(value, value);
		rectTransform.anchoredPosition = new Vector2(0f, -10f);
		GameObject val7 = new GameObject("Count", new Type[1] { typeof(RectTransform) });
		val7.transform.SetParent((Transform)(object)_win, false);
		TextMeshProUGUI val8 = val7.AddComponent<TextMeshProUGUI>();
		TMP_Text hoverName = (TMP_Text)(object)Hud.instance.m_hoverName;
		if ((Object)(object)hoverName != (Object)null)
		{
			((TMP_Text)val8).font = hoverName.font;
			((TMP_Text)val8).fontSharedMaterial = hoverName.fontSharedMaterial;
		}
		((TMP_Text)val8).fontSize = 16f;
		((Graphic)val8).color = Color.white;
		((TMP_Text)val8).alignment = (TextAlignmentOptions)514;
		((Graphic)val8).raycastTarget = false;
		RectTransform rectTransform2 = ((TMP_Text)val8).rectTransform;
		Vector2 anchorMin3 = (rectTransform2.anchorMax = new Vector2(0.5f, 0f));
		rectTransform2.anchorMin = anchorMin3;
		rectTransform2.pivot = new Vector2(0.5f, 0f);
		rectTransform2.sizeDelta = new Vector2(value, 24f);
		rectTransform2.anchoredPosition = new Vector2(0f, 5f);
		_count = (TMP_Text)(object)val8;
		val2.SetActive(false);
	}

	private void Position()
	{
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: 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_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: 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_00d6: 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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: 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)
		Transform parent = ((Transform)_win).parent;
		RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(Plugin.XRayOffsetX.Value, Plugin.XRayOffsetY.Value);
		RawImage val3 = (((Object)(object)Minimap.instance != (Object)null) ? Minimap.instance.m_mapImageSmall : null);
		if ((Object)(object)val != (Object)null && (Object)(object)val3 != (Object)null && ((Component)val3).gameObject.activeInHierarchy)
		{
			((Graphic)val3).rectTransform.GetWorldCorners(_corners);
			Vector3 val4 = (_corners[0] + _corners[3]) * 0.5f;
			Vector3 val5 = ((Transform)val).InverseTransformPoint(val4);
			RectTransform win = _win;
			Vector2 anchorMin = (_win.anchorMax = new Vector2(0.5f, 0.5f));
			win.anchorMin = anchorMin;
			((Transform)_win).localPosition = new Vector3(val5.x + val2.x, val5.y - 40f - _win.sizeDelta.y * 0.1f + val2.y, 0f);
		}
		else
		{
			RectTransform win2 = _win;
			Vector2 anchorMin2 = (_win.anchorMax = new Vector2(1f, 1f));
			win2.anchorMin = anchorMin2;
			_win.anchoredPosition = new Vector2((0f - _win.sizeDelta.x) / 2f - 20f + val2.x, -260f + val2.y);
		}
		if (Plugin.DetailedLog.Value)
		{
			string[] array = new string[5] { "X-ray window at ", null, null, null, null };
			float x = ((Transform)_win).localPosition.x;
			array[1] = x.ToString("0");
			array[2] = ", ";
			float y = ((Transform)_win).localPosition.y;
			array[3] = y.ToString("0");
			array[4] = (((Object)(object)val3 != (Object)null && ((Component)val3).gameObject.activeInHierarchy) ? " (under minimap)" : " (no minimap)");
			string text = string.Concat(array);
			if (text != _lastLog)
			{
				_lastLog = text;
				Plugin.Log.LogInfo((object)text);
			}
		}
	}
}