Decompiled source of PeakItemInsight v0.2.13

BepInEx/plugins/PeakItemInsight/PeakItemInsight.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak.Afflictions;
using PeakItemInsight.Core;
using PeakItemInsight.Detection;
using PeakItemInsight.Diagnostics;
using PeakItemInsight.Providers;
using PeakItemInsight.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.UI.ProceduralImage;

[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("PeakItemInsight")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6c8b12108298924928a12746faf9502da2b04fdc")]
[assembly: AssemblyProduct("PeakItemInsight")]
[assembly: AssemblyTitle("PeakItemInsight")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 PeakItemInsight
{
	[BepInPlugin("dev.rachel.peakiteminsight", "PEAK Item Insight", "0.2.13")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "dev.rachel.peakiteminsight";

		public const string PluginName = "PEAK Item Insight";

		public const string PluginVersion = "0.2.13";

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<float> _hoverDelay;

		private ConfigEntry<bool> _showDebugIds;

		private GameObject? _runtimeObject;

		internal static RuntimeController? Runtime { get; private set; }

		internal static RuntimeController? StaminaRuntime { get; private set; }

		private void Awake()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Expected O, but got Unknown
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Expected O, but got Unknown
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Expected O, but got Unknown
			SessionTrace.Start();
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable hover previews.");
			_hoverDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "HoverDelaySeconds", 0.12f, new ConfigDescription("Delay before a preview appears.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			_showDebugIds = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "ShowDebugIds", false, "Show stable item IDs in the tooltip.");
			PresentationOptions.DescriptionStyle = ((BaseUnityPlugin)this).Config.Bind<DescriptionStyle>("UI", "DescriptionStyle", DescriptionStyle.Minimal, "Inventory description style: Minimal or Detailed. Independent of stamina preview.");
			PresentationOptions.Language = ((BaseUnityPlugin)this).Config.Bind<string>("UI", "Language", "Auto", new ConfigDescription("Display language; Auto follows the game.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[5] { "Auto", "Chinese", "English", "Turkish", "Spanish" }), Array.Empty<object>()));
			PresentationOptions.DetailedBackgroundOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "DetailedBackgroundOpacity", 0.92f, new ConfigDescription("Detailed card background opacity: 0 transparent, 1 opaque. Text and icons are unaffected.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PresentationOptions.MinimalScale = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "MinimalScale", 1f, new ConfigDescription("Minimal display scale.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
			PresentationOptions.MinimalOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "MinimalOffsetX", 0f, "Minimal horizontal offset from inventory.");
			PresentationOptions.MinimalOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "MinimalOffsetY", 0f, "Minimal vertical offset above inventory.");
			PresentationOptions.Animate = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "AnimateRecovery", true, "Pulse recoverable status regions; false uses a steady tint.");
			PresentationOptions.PulseStrength = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "RecoveryStrength", 1f, new ConfigDescription("Recovery overlay opacity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>()));
			PresentationOptions.TextSource = ((BaseUnityPlugin)this).Config.Bind<PreviewMode>("Preview", "InventoryTextSource", PreviewMode.Both, "Inventory text: Hover, Held, Both or Off.");
			PresentationOptions.StaminaSource = ((BaseUnityPlugin)this).Config.Bind<PreviewMode>("Preview", "StaminaPreviewSource", PreviewMode.Both, "Stamina preview: Hover, Held, Both or Off.");
			PresentationOptions.SetupSeen = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "AirportSetupSeen", false, "Airport setup has been shown.");
			Runtime = new RuntimeController();
			Runtime.Initialize(_enabled, _hoverDelay, _showDebugIds, ((BaseUnityPlugin)this).Logger);
			StaminaRuntime = new RuntimeController(textChannel: false);
			StaminaRuntime.Initialize(_enabled, _hoverDelay, _showDebugIds, ((BaseUnityPlugin)this).Logger);
			_runtimeObject = new GameObject("PeakItemInsight.Runtime");
			Object.DontDestroyOnLoad((Object)(object)_runtimeObject);
			_runtimeObject.AddComponent<RuntimeDriver>();
			_runtimeObject.AddComponent<PreviewSettingsDriver>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Persistent Update driver installed.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)("PEAK Item Insight 0.2.13 loaded for PEAK " + Application.version));
		}

		private void OnDestroy()
		{
			SessionTrace.Write("PLUGIN_DESTROY");
			if ((Object)(object)_runtimeObject != (Object)null)
			{
				Object.Destroy((Object)(object)_runtimeObject);
			}
			Runtime?.Dispose();
			Runtime = null;
			StaminaRuntime?.Dispose();
			StaminaRuntime = null;
		}
	}
	internal sealed class RuntimeController
	{
		private readonly bool _textChannel;

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<float> _hoverDelay;

		private ConfigEntry<bool> _showDebugIds;

		private ManualLogSource _log;

		private HoverResolver _hoverResolver;

		private PreviewOrchestrator _orchestrator;

		private MinimalPreviewPanel _minimalPanel;

		private HudGhostOverlay _ghostOverlay;

		private Item? _candidate;

		private Item? _visibleItem;

		private readonly PreviewTargetGate _hoverGate = new PreviewTargetGate();

		private PreviewTargetKey _target;

		private int _scene;

		private int _character;

		private int _gui;

		private string _lastTargetType = "";

		private bool _hasTicked;

		private float _nextErrorLog;

		private float _nextRefresh;

		internal RuntimeController(bool textChannel = true)
		{
			_textChannel = textChannel;
		}

		public void Initialize(ConfigEntry<bool> enabled, ConfigEntry<float> hoverDelay, ConfigEntry<bool> showDebugIds, ManualLogSource log)
		{
			_enabled = enabled;
			_hoverDelay = hoverDelay;
			_showDebugIds = showDebugIds;
			_log = log;
			_hoverResolver = new HoverResolver();
			_orchestrator = new PreviewOrchestrator(new IItemPreviewProvider[4]
			{
				new DirectStatusProvider(),
				new InstanceResourceProvider(),
				new PitonProvider(),
				new PromptProvider()
			}, log);
			_log.LogInfo((object)"Runtime controller initialized.");
		}

		public void Tick()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_002e: 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_0070: 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)
			if (!_hasTicked)
			{
				_hasTicked = true;
				_log.LogInfo((object)"Persistent Update driver tick received.");
			}
			try
			{
				Scene activeScene = SceneManager.GetActiveScene();
				SceneHandle handle = ((Scene)(ref activeScene)).handle;
				int num = (((Object)(object)Character.localCharacter != (Object)null) ? ((Object)Character.localCharacter).GetInstanceID() : 0);
				int num2 = (((Object)(object)GUIManager.instance != (Object)null) ? ((Object)GUIManager.instance).GetInstanceID() : 0);
				if (SceneHandle.op_Implicit(_scene) != handle || _character != num || _gui != num2)
				{
					_scene = SceneHandle.op_Implicit(handle);
					_character = num;
					_gui = num2;
					_hoverGate.Reset();
					_candidate = null;
					_target = default(PreviewTargetKey);
					Hide();
				}
				if (!_enabled.Value || (Object)(object)Character.localCharacter == (Object)null || MainCameraMovement.IsSpectating || Time.timeScale == 0f || ((Object)(object)GUIManager.instance != (Object)null && GUIManager.instance.windowBlockingInput))
				{
					_hoverGate.Reset();
					_candidate = null;
					_target = default(PreviewTargetKey);
					Hide();
					return;
				}
				Item val = _hoverResolver.Resolve();
				Item val2 = HeldResolver.Resolve();
				PreviewTargetKey target = PreviewTargetSelection.Select(((Object)(object)val != (Object)null) ? _hoverResolver.WorldId : ((int?)null), ((Object)(object)val2 != (Object)null) ? new int?(((Object)val2).GetInstanceID()) : ((int?)null), HeldResolver.IsBusy(val2), (_textChannel ? PresentationOptions.TextSource : PresentationOptions.StaminaSource)?.Value ?? PreviewMode.Both);
				Item val3 = ((target.Source == PreviewSource.Hover) ? val : ((target.Source == PreviewSource.Held) ? val2 : null));
				bool flag = _hoverGate.Advance(target, Time.unscaledTime, _hoverDelay.Value);
				if (_hoverGate.Changed || _hoverResolver.CurrentTargetType != _lastTargetType)
				{
					_lastTargetType = _hoverResolver.CurrentTargetType;
					_log.LogInfo((object)("Hover target: " + _lastTargetType + "; resolved item: " + (((Object)(object)val != (Object)null) ? val.itemID.ToString() : "none")));
					SessionTrace.Write("HOVER", string.Format("target={0} world={1} item={2}", _lastTargetType, _hoverResolver.WorldId, ((Object)(object)val != (Object)null) ? val.itemID.ToString() : "none"));
				}
				if (_hoverGate.Changed || (Object)(object)val3 != (Object)(object)_candidate)
				{
					SessionTrace.Write("TARGET", $"from={_target.Source}:{_target.InstanceId} to={target.Source}:{target.InstanceId} heldBusy={HeldResolver.IsBusy(val2)}");
					_candidate = val3;
					_target = target;
					Hide();
				}
				if (!((Object)(object)_candidate == (Object)null) && flag && (!((Object)(object)_candidate == (Object)(object)_visibleItem) || !(Time.unscaledTime < _nextRefresh)))
				{
					ItemPreview itemPreview = _orchestrator.Build(_candidate, _showDebugIds.Value, target.Source == PreviewSource.Hover && _hoverResolver.CurrentTargetType == "FakeItem");
					itemPreview.Source = _target.Source;
					itemPreview.TargetInstanceId = _target.InstanceId;
					EnsureUi();
					if (_textChannel)
					{
						_minimalPanel.Show(itemPreview);
					}
					else
					{
						_ghostOverlay.Show(itemPreview);
					}
					if ((Object)(object)_visibleItem != (Object)(object)_candidate)
					{
						SessionTrace.Write("PREVIEW", $"source={itemPreview.Source} target={itemPreview.TargetInstanceId} item={itemPreview.ItemId} statuses={itemPreview.Statuses.Count} instructions={itemPreview.Instructions.Count}");
						WorldPreviewTrace.Preview(_candidate, itemPreview, _target.InstanceId);
					}
					_visibleItem = _candidate;
					_nextRefresh = Time.unscaledTime + 0.25f;
				}
			}
			catch (Exception ex)
			{
				Hide();
				if (Time.unscaledTime >= _nextErrorLog)
				{
					_nextErrorLog = Time.unscaledTime + 5f;
					_log.LogError((object)$"Hover preview tick failed: {ex}");
					SessionTrace.Write("ERROR", ex.ToString());
				}
			}
		}

		private void EnsureUi()
		{
			if (_textChannel && (Object)(object)_minimalPanel == (Object)null)
			{
				_minimalPanel = MinimalPreviewPanel.Create();
			}
			if (!_textChannel && (Object)(object)_ghostOverlay == (Object)null)
			{
				_ghostOverlay = HudGhostOverlay.Create();
			}
		}

		private void Hide()
		{
			if ((Object)(object)_visibleItem != (Object)null)
			{
				SessionTrace.Write("HIDE");
			}
			_visibleItem = null;
			if ((Object)(object)_minimalPanel != (Object)null)
			{
				_minimalPanel.Hide();
			}
			if ((Object)(object)_ghostOverlay != (Object)null)
			{
				_ghostOverlay.Hide();
			}
		}

		public void Dispose()
		{
			if ((Object)(object)_minimalPanel != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_minimalPanel).gameObject);
			}
			if ((Object)(object)_ghostOverlay != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_ghostOverlay).gameObject);
			}
		}
	}
}
namespace PeakItemInsight.UI
{
	internal sealed class ExtraStaminaOverlay
	{
		private RectTransform? _root;

		private RectTransform? _fill;

		private RectTransform? _gain;

		private RectTransform? _outline;

		private RectTransform? _icon;

		private Image? _infinite;

		private CanvasGroup? _gainPulse;

		private StaminaBar? _bar;

		private readonly Dictionary<Graphic, bool> _suppressed = new Dictionary<Graphic, bool>();

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

		internal bool ExtraVisible
		{
			get
			{
				if ((Object)(object)_gain != (Object)null)
				{
					return ((Component)_gain).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		internal bool InfiniteVisible
		{
			get
			{
				if ((Object)(object)_infinite != (Object)null)
				{
					return ((Component)_infinite).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		internal bool TrackVisible
		{
			get
			{
				if ((Object)(object)_outline != (Object)null)
				{
					return ((Component)_outline).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		internal bool IconVisible
		{
			get
			{
				if ((Object)(object)_icon != (Object)null)
				{
					return ((Component)_icon).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		internal Rect ExtraBounds
		{
			get
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				if (!ExtraVisible)
				{
					return Rect.zero;
				}
				return Bounds(_gain, _bar.fullBar);
			}
		}

		internal Rect RowBounds
		{
			get
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				if (!ExtraVisible)
				{
					return Rect.zero;
				}
				return RowBoundsIn(_bar.fullBar);
			}
		}

		internal Image? OutlineImage
		{
			get
			{
				if (!((Object)(object)_outline != (Object)null))
				{
					return null;
				}
				return ((Component)_outline).GetComponentInChildren<Image>(true);
			}
		}

		internal Image? IconImage
		{
			get
			{
				if (!((Object)(object)_icon != (Object)null))
				{
					return null;
				}
				return ((Component)_icon).GetComponent<Image>();
			}
		}

		public void Render(StaminaBar? bar, ItemPreview preview, Image? healthy, float elapsed)
		{
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: 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_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: 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_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: 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_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: 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_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bar == (Object)null || (Object)(object)bar.fullBar == (Object)null || !((Component)bar.fullBar).gameObject.activeInHierarchy || (Object)(object)healthy == (Object)null)
			{
				Hide();
				return;
			}
			if ((Object)(object)_bar != (Object)(object)bar)
			{
				Dispose();
				_bar = bar;
			}
			float num = Mathf.Clamp01((PresentationOptions.Animation ? HungerPulseMath.Alpha(elapsed) : 0.65f) * PresentationOptions.Strength);
			float num2 = Mathf.Max(0f, preview.ExtraBefore);
			float num3 = Mathf.Max(0f, preview.ExtraAfter);
			float num4 = Mathf.Max(0f, num3 - num2);
			Rect rect;
			if (preview.HasExtraStamina && num4 > 1E-05f && Bind(bar))
			{
				_root.sizeDelta = new Vector2(45f, 45f);
				_root.anchoredPosition = bar.extraBar.anchoredPosition;
				((Component)_root).gameObject.SetActive(true);
				Reveal(_outline);
				Reveal(_icon);
				Reveal(_fill);
				Reveal(_gain);
				float num5 = bar.fullBar.sizeDelta.x;
				if (num5 <= 0f)
				{
					rect = bar.fullBar.rect;
					num5 = ((Rect)(ref rect)).width;
				}
				RectTransform? fill = _fill;
				Vector2 anchorMin = (_gain.anchorMin = bar.extraBarStamina.anchorMin);
				fill.anchorMin = anchorMin;
				RectTransform? fill2 = _fill;
				anchorMin = (_gain.anchorMax = bar.extraBarStamina.anchorMax);
				fill2.anchorMax = anchorMin;
				RectTransform? fill3 = _fill;
				anchorMin = (_gain.pivot = bar.extraBarStamina.pivot);
				fill3.pivot = anchorMin;
				_fill.anchoredPosition = bar.extraBarStamina.anchoredPosition;
				_outline.sizeDelta = new Vector2(Mathf.Max(20f, (((Object)(object)bar.petrifyAffliction != (Object)null && ((Component)bar.petrifyAffliction).gameObject.activeInHierarchy) ? num5 : (num3 * num5)) + 12f), _outline.sizeDelta.y);
				_fill.sizeDelta = new Vector2(num2 * num5, bar.extraBarStamina.sizeDelta.y);
				((Component)_fill).gameObject.SetActive(num2 * num5 > 6.1f);
				_gain.sizeDelta = new Vector2(num4 * num5, bar.extraBarStamina.sizeDelta.y);
				_gain.anchoredPosition = _fill.anchoredPosition + new Vector2(num2 * num5 + (num4 * num5 - num2 * num5) * _fill.pivot.x, 0f);
				_gainPulse.alpha = num;
				Image[] componentsInChildren = ((Component)_gain).GetComponentsInChildren<Image>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].fillAmount = 1f;
				}
				componentsInChildren = ((Component)_fill).GetComponentsInChildren<Image>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].fillAmount = 1f;
				}
				PositionRow(bar, healthy, num2 > 0f);
				if (num2 > 0f)
				{
					Suppress(bar);
				}
				else
				{
					RestoreNative();
				}
			}
			else
			{
				HideExtra();
			}
			if ((Object)(object)_infinite == (Object)null)
			{
				RectTransform component = new GameObject("PeakItemInsight.InfinitePreview", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
				((Transform)component).SetParent((Transform)(object)bar.fullBar, false);
				Vector2 anchorMin = (component.anchorMax = Vector2.zero);
				component.anchorMin = anchorMin;
				component.pivot = new Vector2(0f, 0.5f);
				_infinite = NativeVisualCopy.CopyImage(healthy, component);
			}
			((Component)_infinite).gameObject.SetActive(preview.InfiniteStamina);
			if (preview.InfiniteStamina)
			{
				Rect val = Bounds(((Graphic)healthy).rectTransform, bar.fullBar);
				RectTransform rectTransform = ((Graphic)_infinite).rectTransform;
				float xMin = ((Rect)(ref val)).xMin;
				rect = bar.fullBar.rect;
				float num6 = xMin - ((Rect)(ref rect)).xMin;
				float y = ((Rect)(ref val)).center.y;
				rect = bar.fullBar.rect;
				rectTransform.anchoredPosition = new Vector2(num6, y - ((Rect)(ref rect)).yMin);
				((Graphic)_infinite).rectTransform.sizeDelta = ((Rect)(ref val)).size;
				((Graphic)_infinite).color = Color.Lerp(((Graphic)healthy).color, new Color(0.55f, 0.9f, 1f, 1f), 0.6f) * new Color(1f, 1f, 1f, num);
			}
		}

		private bool Bind(StaminaBar bar)
		{
			if ((Object)(object)_root != (Object)null)
			{
				return true;
			}
			if ((Object)(object)bar.extraBar == (Object)null || (Object)(object)bar.extraBarStamina == (Object)null || (Object)(object)bar.extraBarOutline == (Object)null || (Object)(object)bar.extraStaminaIcon == (Object)null)
			{
				return false;
			}
			_root = NativeVisualCopy.Create(bar.extraBar, ((Transform)bar.extraBar).parent, (Transform?)(object)(((Object)(object)bar.petrifyAffliction != (Object)null) ? bar.petrifyAffliction.rtf : null));
			((Object)_root).name = "PeakItemInsight.NativeExtraPreview";
			((Component)_root).gameObject.SetActive(false);
			_fill = NativeVisualCopy.Find(bar.extraBar, _root, bar.extraBarStamina);
			_outline = NativeVisualCopy.Find(bar.extraBar, _root, bar.extraBarOutline);
			_icon = NativeVisualCopy.Find(bar.extraBar, _root, ((Graphic)bar.extraStaminaIcon).rectTransform);
			if ((Object)(object)_fill == (Object)null || (Object)(object)_outline == (Object)null || (Object)(object)_icon == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_root).gameObject);
				_root = null;
				return false;
			}
			_gain = NativeVisualCopy.Create(bar.extraBarStamina, ((Transform)_fill).parent);
			((Object)_gain).name = "ExtraGain";
			_gainPulse = ((Component)_gain).gameObject.AddComponent<CanvasGroup>();
			((Component)_root).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
			return true;
		}

		private void Suppress(StaminaBar bar)
		{
			Graphic[] componentsInChildren = ((Component)bar.extraBar).GetComponentsInChildren<Graphic>(true);
			foreach (Graphic val in componentsInChildren)
			{
				if (!((Object)(object)bar.petrifyAffliction != (Object)null) || !((Component)val).transform.IsChildOf(((Component)bar.petrifyAffliction).transform))
				{
					if (!_suppressed.ContainsKey(val))
					{
						_suppressed.Add(val, ((Behaviour)val).enabled);
					}
					((Behaviour)val).enabled = false;
				}
			}
		}

		private void HideExtra()
		{
			if ((Object)(object)_root != (Object)null)
			{
				((Component)_root).gameObject.SetActive(false);
			}
			RestoreNative();
		}

		private void RestoreNative()
		{
			foreach (KeyValuePair<Graphic, bool> item in _suppressed)
			{
				if ((Object)(object)item.Key != (Object)null && !((Behaviour)item.Key).enabled)
				{
					((Behaviour)item.Key).enabled = item.Value;
				}
			}
			_suppressed.Clear();
		}

		private void PositionRow(StaminaBar bar, Image healthy, bool hasExtra)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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)
			RectTransform val = (RectTransform)((Transform)_root).parent;
			Rect val2 = Bounds(((Object)(object)bar.staminaBarOutline != (Object)null) ? bar.staminaBarOutline : ((Graphic)healthy).rectTransform, val);
			Rect val3 = RowBoundsIn(val);
			float num = ((Rect)(ref val2)).height * 0.2f;
			float num2 = (hasExtra ? Mathf.Min(0f, ((Rect)(ref val2)).yMin - num - ((Rect)(ref val3)).yMax) : (((Rect)(ref val2)).yMax + num - ((Rect)(ref val3)).yMin));
			RectTransform? root = _root;
			((Transform)root).position = ((Transform)root).position + ((Transform)val).TransformVector(new Vector3(0f, num2, 0f));
		}

		private Rect RowBoundsIn(RectTransform relativeTo)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//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_00ce: Unknown result type (might be due to invalid IL or missing references)
			Rect val = Bounds(_outline, relativeTo);
			Rect val2 = Bounds(_icon, relativeTo);
			Rect val3 = Bounds(_gain, relativeTo);
			return Rect.MinMaxRect(Mathf.Min(new float[3]
			{
				((Rect)(ref val)).xMin,
				((Rect)(ref val2)).xMin,
				((Rect)(ref val3)).xMin
			}), Mathf.Min(new float[3]
			{
				((Rect)(ref val)).yMin,
				((Rect)(ref val2)).yMin,
				((Rect)(ref val3)).yMin
			}), Mathf.Max(new float[3]
			{
				((Rect)(ref val)).xMax,
				((Rect)(ref val2)).xMax,
				((Rect)(ref val3)).xMax
			}), Mathf.Max(new float[3]
			{
				((Rect)(ref val)).yMax,
				((Rect)(ref val2)).yMax,
				((Rect)(ref val3)).yMax
			}));
		}

		private void Reveal(RectTransform node)
		{
			Transform val = (Transform)(object)node;
			while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)_root)
			{
				((Component)val).gameObject.SetActive(true);
				val = val.parent;
			}
		}

		private Rect Bounds(RectTransform source, RectTransform relativeTo)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0062: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			source.GetWorldCorners(_corners);
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(float.PositiveInfinity, float.PositiveInfinity);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(float.NegativeInfinity, float.NegativeInfinity);
			Vector3[] corners = _corners;
			foreach (Vector3 val3 in corners)
			{
				Vector2 val4 = Vector2.op_Implicit(((Transform)relativeTo).InverseTransformPoint(val3));
				val = Vector2.Min(val, val4);
				val2 = Vector2.Max(val2, val4);
			}
			return Rect.MinMaxRect(val.x, val.y, val2.x, val2.y);
		}

		public void Hide()
		{
			HideExtra();
			if ((Object)(object)_infinite != (Object)null)
			{
				((Component)_infinite).gameObject.SetActive(false);
			}
		}

		public void Dispose()
		{
			Hide();
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_root).gameObject);
			}
			if ((Object)(object)_infinite != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_infinite).gameObject);
			}
			_root = (_fill = (_gain = (_outline = (_icon = null))));
			_infinite = null;
			_gainPulse = null;
			_bar = null;
		}
	}
	internal sealed class HudGhostOverlay : MonoBehaviour
	{
		private RectTransform? _source;

		private RectTransform? _segment;

		private Image? _image;

		private ItemPreview? _preview;

		private bool _probe;

		private readonly StatusRecoveryOverlays _recovery = new StatusRecoveryOverlays();

		private readonly StatusIncreaseOverlay _increases = new StatusIncreaseOverlay();

		private readonly ExtraStaminaOverlay _extra = new ExtraStaminaOverlay();

		private readonly Dictionary<STATUSTYPE, HungerRecoveryOverlay> _otherRecoveries = new Dictionary<STATUSTYPE, HungerRecoveryOverlay>();

		private float _pulseStart;

		private float _nextTrace;

		public bool SegmentVisible
		{
			get
			{
				if ((Object)(object)_segment != (Object)null)
				{
					return ((Component)_segment).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		public float SegmentWidth
		{
			get
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				if (!SegmentVisible)
				{
					return 0f;
				}
				Rect rect = _segment.rect;
				return ((Rect)(ref rect)).width;
			}
		}

		public void RenderProbe(RectTransform source, float fullWidth, float before, float after)
		{
			_probe = true;
			Bind(source);
			RenderSegment(fullWidth * before, fullWidth * after);
		}

		public static HudGhostOverlay Create()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			GameObject val = new GameObject("PeakItemInsight.HudGhostOverlay");
			Object.DontDestroyOnLoad((Object)val);
			return val.AddComponent<HudGhostOverlay>();
		}

		public void Show(ItemPreview preview)
		{
			if (_preview == null)
			{
				_pulseStart = Time.unscaledTime;
			}
			_preview = ((preview.Statuses.Count > 0 || preview.HasExtraStamina || preview.InfiniteStamina) ? preview : null);
			if (_preview == null)
			{
				HideSegment();
			}
		}

		public void Hide()
		{
			_preview = null;
			HideSegment();
		}

		private void LateUpdate()
		{
			if (_probe)
			{
				return;
			}
			if (_preview == null)
			{
				HideSegment();
				return;
			}
			try
			{
				RenderRecoveries();
			}
			catch (Exception arg)
			{
				HideSegment();
				if (Time.unscaledTime >= _nextTrace)
				{
					_nextTrace = Time.unscaledTime + 2f;
					SessionTrace.Write("ERROR", $"Recovery pulse: {arg}");
				}
			}
		}

		private unsafe void RenderRecoveries()
		{
			//IL_00a7: 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_00ac: Invalid comparison between Unknown and I4
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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)
			StaminaBar val = (((Object)(object)GUIManager.instance != (Object)null) ? GUIManager.instance.bar : null);
			Image healthy = (((Object)(object)val != (Object)null) ? NativeFill(val.staminaBar, null) : null);
			Image val2 = FindNativeStatus(val, (STATUSTYPE)1);
			Image val3 = FindNativeStatus(val, (STATUSTYPE)0);
			bool flag = _increases.Render(val, _preview, healthy, Time.unscaledTime - _pulseStart);
			if (flag)
			{
				_recovery.Hide();
			}
			else
			{
				_recovery.Render(_preview, healthy, val2, val3, Time.unscaledTime - _pulseStart);
			}
			STATUSTYPE[] previewable = StatusTypes.Previewable;
			for (int i = 0; i < previewable.Length; i++)
			{
				STATUSTYPE val4 = previewable[i];
				if ((int)val4 != 1 && (int)val4 != 0)
				{
					if (!_otherRecoveries.TryGetValue(val4, out HungerRecoveryOverlay value))
					{
						value = (_otherRecoveries[val4] = new HungerRecoveryOverlay(((object)(*(STATUSTYPE*)(&val4))/*cast due to .constrained prefix*/).ToString()));
					}
					if (flag)
					{
						value.Hide();
					}
					else
					{
						RenderRecovery(value, val, healthy, val4);
					}
				}
			}
			_extra.Render(val, _preview, healthy, Time.unscaledTime - _pulseStart);
			if (Time.unscaledTime >= _nextTrace)
			{
				_nextTrace = Time.unscaledTime + 2f;
				if (flag)
				{
					SessionTrace.Write("HUD_PROJECTED_ROW", $"item={_preview.ItemId} source={_preview.Source} hungerWidth={_increases.ProjectedStatusWidth((STATUSTYPE)1):0.##} poisonWidth={_increases.ProjectedStatusWidth((STATUSTYPE)3):0.##} healthyWidth={_increases.HealthyWidth:0.##} phase={_increases.AddedOpacity:0.##}");
				}
				TraceRecovery((STATUSTYPE)1, "HUNGER", val2, healthy, _recovery.Hunger);
				TraceRecovery((STATUSTYPE)0, "INJURY", val3, healthy, _recovery.Injury);
				StatusDelta? statusDelta = StatusRecoveryOverlays.Find(_preview, (STATUSTYPE)3);
				if (statusDelta.HasValue)
				{
					SessionTrace.Write("POISON_PULSE", $"item={_preview.ItemId} source={_preview.Source} before={statusDelta.Value.Before:0.####} after={statusDelta.Value.After:0.####} visible={_increases.Visible} segments={_increases.AddedCount} visibleWidth={_increases.VisibleAddedWidth:0.##} opacity={_increases.AddedOpacity:0.##}");
				}
			}
		}

		private void RenderRecovery(HungerRecoveryOverlay overlay, StaminaBar? bar, Image? healthy, STATUSTYPE type)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			StatusDelta? statusDelta = StatusRecoveryOverlays.Find(_preview, type);
			Image val = FindNativeStatus(bar, type);
			if (statusDelta.HasValue && (Object)(object)val != (Object)null && (Object)(object)healthy != (Object)null)
			{
				overlay.Render(val, healthy, statusDelta.Value.Before, statusDelta.Value.After, Time.unscaledTime - _pulseStart);
			}
			else
			{
				overlay.Hide();
			}
		}

		private static Image? FindNativeStatus(StaminaBar? bar, STATUSTYPE type)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//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)
			if ((int)type == 13 && (Object)(object)bar != (Object)null && (Object)(object)bar.petrifyAffliction != (Object)null)
			{
				return NativeFill(bar.petrifyAffliction.rtf, bar.petrifyAffliction.icon);
			}
			if ((Object)(object)bar != (Object)null && bar.afflictions != null)
			{
				BarAffliction[] afflictions = bar.afflictions;
				foreach (BarAffliction val in afflictions)
				{
					if ((Object)(object)val != (Object)null && !val.isPetrify && val.afflictionType == type)
					{
						return NativeFill(val.rtf, val.icon);
					}
				}
			}
			return null;
		}

		private void TraceRecovery(STATUSTYPE type, string label, Image? source, Image? healthy, HungerRecoveryOverlay overlay)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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)
			StatusDelta? statusDelta = StatusRecoveryOverlays.Find(_preview, type);
			if (statusDelta.HasValue && !(HungerPulseMath.Fraction(statusDelta.Value.Before, statusDelta.Value.After) <= 0f))
			{
				if ((Object)(object)source == (Object)null || (Object)(object)healthy == (Object)null)
				{
					SessionTrace.Write(label + "_PULSE_UNBOUND", $"statusImage={(Object)(object)source != (Object)null} healthyImage={(Object)(object)healthy != (Object)null}");
					return;
				}
				string stage = label + "_PULSE";
				object[] obj = new object[10]
				{
					_preview.Source,
					_preview.TargetInstanceId,
					_preview.ItemId,
					statusDelta.Value.Before,
					statusDelta.Value.After,
					HungerPulseMath.Fraction(statusDelta.Value.Before, statusDelta.Value.After),
					null,
					null,
					null,
					null
				};
				Rect rect = ((Graphic)source).rectTransform.rect;
				obj[6] = ((Rect)(ref rect)).width;
				obj[7] = overlay.Width;
				obj[8] = overlay.Visible;
				obj[9] = overlay.Opacity;
				SessionTrace.Write(stage, string.Format("source={0} target={1} item={2} before={3} after={4} fraction={5} nativeWidth={6} overlayWidth={7} visible={8} alpha={9}", obj));
			}
		}

		internal static Image? NativeFill(RectTransform? rect, Image? icon)
		{
			if ((Object)(object)rect == (Object)null)
			{
				return null;
			}
			Image component = ((Component)rect).GetComponent<Image>();
			if ((Object)(object)component != (Object)null && (Object)(object)component != (Object)(object)icon)
			{
				return component;
			}
			Image[] componentsInChildren = ((Component)rect).GetComponentsInChildren<Image>(true);
			foreach (Image val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)(object)icon && ((Object)(object)icon == (Object)null || !((Component)val).transform.IsChildOf(((Component)icon).transform)) && !IsPreviewChild(((Component)val).transform))
				{
					return val;
				}
			}
			return null;
		}

		private static bool IsPreviewChild(Transform node)
		{
			Transform val = node;
			while ((Object)(object)val != (Object)null)
			{
				if (((Object)val).name.StartsWith("PeakItemInsight"))
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		private void RenderSegment(float currentWidth, float projectedWidth)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//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_0098: 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_00b6: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Abs(projectedWidth - currentWidth);
			if (num < 0.5f)
			{
				HideSegment();
				return;
			}
			float num2 = Mathf.Min(currentWidth, projectedWidth);
			RectTransform? segment = _segment;
			Vector2 anchorMin = (_segment.anchorMax = _source.anchorMin);
			segment.anchorMin = anchorMin;
			_segment.pivot = new Vector2(0f, _source.pivot.y);
			RectTransform? segment2 = _segment;
			float x = _source.anchoredPosition.x;
			Rect rect = _source.rect;
			segment2.anchoredPosition = new Vector2(x - ((Rect)(ref rect)).width * _source.pivot.x + num2, _source.anchoredPosition.y);
			RectTransform? segment3 = _segment;
			rect = _source.rect;
			segment3.sizeDelta = new Vector2(num, ((Rect)(ref rect)).height);
			((Graphic)_image).color = ((projectedWidth > currentWidth) ? new Color(0.35f, 1f, 0.55f, 0.42f) : new Color(1f, 0.34f, 0.25f, 0.48f));
			((Component)_segment).gameObject.SetActive(true);
		}

		private void Bind(RectTransform source)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			if (!((Object)(object)_source == (Object)(object)source) || !((Object)(object)_segment != (Object)null))
			{
				if ((Object)(object)_segment != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)_segment).gameObject);
				}
				_source = source;
				GameObject val = new GameObject("PeakItemInsight.GhostStamina", new Type[3]
				{
					typeof(RectTransform),
					typeof(CanvasRenderer),
					typeof(Image)
				});
				val.transform.SetParent(((Transform)source).parent, false);
				_segment = val.GetComponent<RectTransform>();
				_image = val.GetComponent<Image>();
				((Graphic)_image).raycastTarget = false;
				val.transform.SetSiblingIndex(((Transform)source).GetSiblingIndex() + 1);
				val.SetActive(false);
			}
		}

		private void HideSegment()
		{
			if ((Object)(object)_segment != (Object)null)
			{
				((Component)_segment).gameObject.SetActive(false);
			}
			_recovery.Hide();
			_increases.Hide();
			_extra.Hide();
			foreach (HungerRecoveryOverlay value in _otherRecoveries.Values)
			{
				value.Hide();
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_segment != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_segment).gameObject);
			}
			_recovery.Dispose();
			_increases.Dispose();
			_extra.Dispose();
			foreach (HungerRecoveryOverlay value in _otherRecoveries.Values)
			{
				value.Dispose();
			}
		}
	}
	internal sealed class HungerRecoveryOverlay
	{
		private readonly string _name;

		private Image? _source;

		private RectTransform? _root;

		private RectTransform? _clip;

		private RectTransform? _fill;

		private Image? _maskImage;

		private Image? _green;

		public bool Visible
		{
			get
			{
				if ((Object)(object)_root != (Object)null)
				{
					return ((Component)_root).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		public float Width
		{
			get
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				if (!Visible || !((Object)(object)_clip != (Object)null))
				{
					return 0f;
				}
				Rect rect = _clip.rect;
				return ((Rect)(ref rect)).width;
			}
		}

		public float Opacity
		{
			get
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)_green != (Object)null))
				{
					return 0f;
				}
				return ((Graphic)_green).color.a;
			}
		}

		internal RectTransform? OverlayRect => _root;

		internal RectTransform? ClipRect => _clip;

		public HungerRecoveryOverlay(string name = "Hunger")
		{
			_name = name;
		}

		public void Render(Image source, Image healthy, float before, float after, float elapsed)
		{
			//IL_0039: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			float num = HungerPulseMath.Fraction(before, after);
			if (num <= 0f || !((Behaviour)source).isActiveAndEnabled)
			{
				Hide();
				return;
			}
			Bind(source);
			CopyStyle(source, _maskImage);
			((Graphic)_maskImage).color = Color.white;
			CopyStyle(healthy, _green);
			Color color = ((Graphic)healthy).color;
			color.a = (PresentationOptions.Animation ? HungerPulseMath.Alpha(elapsed) : 0.65f) * PresentationOptions.Strength;
			((Graphic)_green).color = color;
			RectTransform rectTransform = ((Graphic)source).rectTransform;
			RectTransform rectTransform2 = ((Graphic)healthy).rectTransform;
			Rect rect = ((Graphic)healthy).rectTransform.rect;
			float x = ((Transform)rectTransform).InverseTransformPoint(((Transform)rectTransform2).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center))).x;
			rect = ((Graphic)source).rectTransform.rect;
			bool flag = x <= ((Rect)(ref rect)).center.x;
			_clip.anchorMin = new Vector2(flag ? 0f : (1f - num), 0f);
			_clip.anchorMax = new Vector2(flag ? num : 1f, 1f);
			RectTransform? clip = _clip;
			Vector2 offsetMin = (_clip.offsetMax = Vector2.zero);
			clip.offsetMin = offsetMin;
			_fill.anchorMin = new Vector2((float)((!flag) ? 1 : 0), 0f);
			_fill.anchorMax = new Vector2((float)((!flag) ? 1 : 0), 1f);
			_fill.pivot = new Vector2((float)((!flag) ? 1 : 0), 0.5f);
			_fill.anchoredPosition = Vector2.zero;
			RectTransform? fill = _fill;
			rect = ((Graphic)source).rectTransform.rect;
			fill.sizeDelta = new Vector2(((Rect)(ref rect)).width, 0f);
			((Component)_root).gameObject.SetActive(true);
		}

		private void Bind(Image source)
		{
			if (!((Object)(object)_source == (Object)(object)source) || !((Object)(object)_root != (Object)null))
			{
				Dispose();
				_source = source;
				_root = Rect("PeakItemInsight." + _name + "Pulse", ((Component)source).transform);
				_maskImage = ((Component)_root).gameObject.AddComponent<Image>();
				((Graphic)_maskImage).raycastTarget = false;
				((Component)_root).gameObject.AddComponent<Mask>().showMaskGraphic = false;
				_clip = Rect("RecoveryFraction", (Transform)(object)_root);
				((Component)_clip).gameObject.AddComponent<RectMask2D>();
				_fill = Rect("HealthyFill", (Transform)(object)_clip);
				_green = ((Component)_fill).gameObject.AddComponent<Image>();
				((Graphic)_green).raycastTarget = false;
				((Component)_root).gameObject.SetActive(false);
			}
		}

		private static RectTransform Rect(string name, Transform parent)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(LayoutElement)
			});
			val.GetComponent<LayoutElement>().ignoreLayout = true;
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).SetParent(parent, false);
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			Vector2 offsetMin = (component.offsetMax = Vector2.zero);
			component.offsetMin = offsetMin;
			return component;
		}

		private static void CopyStyle(Image source, Image destination)
		{
			//IL_000e: 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)
			destination.sprite = source.overrideSprite;
			destination.type = source.type;
			destination.fillMethod = source.fillMethod;
			destination.fillOrigin = source.fillOrigin;
			destination.fillClockwise = source.fillClockwise;
			destination.fillAmount = source.fillAmount;
			destination.fillCenter = source.fillCenter;
			destination.pixelsPerUnitMultiplier = source.pixelsPerUnitMultiplier;
		}

		public void Hide()
		{
			if ((Object)(object)_root != (Object)null)
			{
				((Component)_root).gameObject.SetActive(false);
			}
		}

		public void Dispose()
		{
			Hide();
			if ((Object)(object)_root != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_root).gameObject);
			}
			_source = null;
			_root = (_clip = (_fill = null));
			_maskImage = (_green = null);
		}
	}
	internal sealed class MinimalPreviewPanel : MonoBehaviour
	{
		private sealed class Row
		{
			public RectTransform Rect;

			public TextMeshProUGUI Text;

			public Image Icon;

			public RawImage ItemIcon;

			public PreviewDeltaArrow Arrow;

			public TextMeshProUGUI Timing;

			public PreviewSymbol Clock;

			public PreviewSymbol Symbol;

			public Shadow Shadow;

			public bool Title;
		}

		private RectTransform _panel;

		private CanvasGroup _group;

		private RoundedCard _background;

		private bool _detailed;

		private readonly List<Row> _rows = new List<Row>();

		private TMP_FontAsset? _font;

		private PreviewSource _source;

		private int _screenWidth;

		private int _screenHeight;

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

		private TMP_FontAsset? _checkedFont;

		private string _checkedLanguage = "";

		private float _layoutScale;

		internal bool HasBackground
		{
			get
			{
				if (IsVisible)
				{
					return ((Behaviour)_background).enabled;
				}
				return false;
			}
		}

		internal int LayoutPasses { get; private set; }

		internal bool IsVisible
		{
			get
			{
				if ((Object)(object)_panel != (Object)null)
				{
					return ((Component)_panel).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		internal string LastTargetName { get; private set; } = "";

		internal string BodyText => string.Join("\n", from r in _rows
			where ((Component)r.Rect).gameObject.activeSelf
			select ((TMP_Text)r.Text).text + (((Component)r.Timing).gameObject.activeSelf ? (" · " + ((TMP_Text)r.Timing).text) : ""));

		internal int VisibleRows => _rows.Count((Row r) => ((Component)r.Rect).gameObject.activeSelf);

		public static MinimalPreviewPanel Create()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_006a: 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_00d4: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("PeakItemInsight.MinimalCanvas", new Type[3]
			{
				typeof(Canvas),
				typeof(CanvasScaler),
				typeof(CanvasGroup)
			});
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas component = val.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.sortingOrder = 75;
			CanvasScaler component2 = val.GetComponent<CanvasScaler>();
			component2.uiScaleMode = (ScaleMode)1;
			component2.referenceResolution = new Vector2(1920f, 1080f);
			component2.matchWidthOrHeight = 0.5f;
			MinimalPreviewPanel minimalPreviewPanel = val.AddComponent<MinimalPreviewPanel>();
			minimalPreviewPanel._group = val.GetComponent<CanvasGroup>();
			minimalPreviewPanel._group.blocksRaycasts = false;
			minimalPreviewPanel._group.interactable = false;
			GameObject val2 = new GameObject("InventoryDescription", new Type[2]
			{
				typeof(RectTransform),
				typeof(RoundedCard)
			});
			minimalPreviewPanel._panel = val2.GetComponent<RectTransform>();
			minimalPreviewPanel._background = val2.GetComponent<RoundedCard>();
			((Graphic)minimalPreviewPanel._background).raycastTarget = false;
			((Graphic)minimalPreviewPanel._background).color = new Color(0.13f, 0.16f, 0.16f, 0.92f);
			((Behaviour)minimalPreviewPanel._background).enabled = false;
			((Transform)minimalPreviewPanel._panel).SetParent(val.transform, false);
			RectTransform panel = minimalPreviewPanel._panel;
			RectTransform panel2 = minimalPreviewPanel._panel;
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(0.5f, 0.5f);
			panel2.anchorMax = val3;
			panel.anchorMin = val3;
			minimalPreviewPanel._panel.pivot = new Vector2(0.5f, 0f);
			minimalPreviewPanel.Hide();
			return minimalPreviewPanel;
		}

		public void Show(ItemPreview preview)
		{
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: 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_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: 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_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			_source = preview.Source;
			LastTargetName = preview.Name;
			ConfigEntry<DescriptionStyle>? descriptionStyle = PresentationOptions.DescriptionStyle;
			_detailed = descriptionStyle != null && descriptionStyle.Value == DescriptionStyle.Detailed;
			((Behaviour)_background).enabled = _detailed;
			if (_detailed)
			{
				ShowDetailed(preview);
				return;
			}
			List<MinimalRow> list = MinimalRows.Build(preview, Labels.Text("清除", "Clear"), Labels.Text("有", "Present"));
			if (list.Count == 0)
			{
				Hide();
				return;
			}
			if (preview.Source == PreviewSource.Hover)
			{
				list.Add(new MinimalRow(preview.Name));
			}
			if (!AdoptFont())
			{
				Hide();
				return;
			}
			for (int i = 0; i < list.Count; i++)
			{
				if (i == _rows.Count)
				{
					_rows.Add(CreateRow());
				}
				Row row = _rows[i];
				MinimalRow data = list[i];
				((Component)row.Rect).gameObject.SetActive(true);
				((Component)row.ItemIcon).gameObject.SetActive(false);
				row.ItemIcon.texture = null;
				row.Title = false;
				((TMP_Text)row.Text).fontStyle = (FontStyles)0;
				((Behaviour)row.Shadow).enabled = false;
				((Component)row.Timing).gameObject.SetActive(false);
				((Component)row.Clock).gameObject.SetActive(false);
				((Component)row.Symbol).gameObject.SetActive(false);
				Image val = NativeIcon(data);
				row.Icon.sprite = (((Object)(object)val != (Object)null) ? val.sprite : null);
				((Graphic)row.Icon).color = (Color)(((Object)(object)val != (Object)null) ? new Color(((Graphic)val).color.r, ((Graphic)val).color.g, ((Graphic)val).color.b, 1f) : Color.white);
				((Component)row.Icon).gameObject.SetActive((Object)(object)row.Icon.sprite != (Object)null);
				Color color = (Color)(((Object)(object)val != (Object)null) ? ((Graphic)row.Icon).color : (data.Lightning ? new Color(0.65f, 1f, 0.15f) : Color.white));
				string text = ((!((Object)(object)row.Icon.sprite == (Object)null)) ? "" : (data.Status.HasValue ? (" " + Labels.Status(data.Status.Value)) : (data.Lightning ? (" " + Labels.ExtraStamina) : "")));
				((TMP_Text)row.Text).text = (data.DisplayText + text).Replace("<", "<").Replace(">", ">");
				((Graphic)row.Text).color = color;
				((Graphic)row.Arrow).color = color;
				((Component)row.Arrow).gameObject.SetActive(data.Direction != 0);
				((Transform)((Graphic)row.Arrow).rectTransform).localRotation = Quaternion.Euler(0f, 0f, (float)((data.Direction < 0) ? 180 : 0));
				if ((Object)(object)_font != (Object)null)
				{
					((TMP_Text)row.Text).font = _font;
				}
			}
			for (int j = list.Count; j < _rows.Count; j++)
			{
				((Component)_rows[j].Rect).gameObject.SetActive(false);
			}
			((Component)_panel).gameObject.SetActive(true);
			LayoutRows();
			Position();
		}

		private void ShowDetailed(ItemPreview preview)
		{
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: 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_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			List<DetailedRow> list = DetailedRows.Build(preview, Labels.Language);
			if (list.Count == 0 || !AdoptFont())
			{
				Hide();
				return;
			}
			bool flag = !IsVisible || _rows.Count((Row r) => ((Component)r.Rect).gameObject.activeSelf) != list.Count || _screenWidth != Screen.width || _screenHeight != Screen.height || _layoutScale != Mathf.Clamp(PresentationOptions.MinimalScale?.Value ?? 1f, 0.5f, 2f);
			for (int num = 0; num < list.Count; num++)
			{
				if (num == _rows.Count)
				{
					_rows.Add(CreateRow());
				}
				Row row = _rows[num];
				DetailedRow detailedRow = list[num];
				Image val = NativeIcon(new MinimalRow("", detailedRow.Status, detailedRow.Lightning));
				string text = ((detailedRow.NamesStatus || (!((Object)(object)val == (Object)null) && !((Object)(object)val.sprite == (Object)null))) ? "" : (detailedRow.Status.HasValue ? (" " + Labels.Status(detailedRow.Status.Value)) : (detailedRow.Lightning ? (" " + Labels.ExtraStamina) : "")));
				flag |= row.Title != detailedRow.Title || ((TMP_Text)row.Text).text != detailedRow.Text + text || ((TMP_Text)row.Timing).text != detailedRow.Timing || (Object)(object)((TMP_Text)row.Text).font != (Object)(object)_font || (Object)(object)((TMP_Text)row.Timing).font != (Object)(object)_font || !((Behaviour)row.Shadow).enabled || (Object)(object)row.Icon.sprite != (Object)(object)(((Object)(object)val != (Object)null) ? val.sprite : null) || (Object)(object)row.ItemIcon.texture != (Object)(object)(detailedRow.Title ? preview.Icon : null) || ((Component)row.Symbol).gameObject.activeSelf != (detailedRow.Buff.HasValue && !detailedRow.Lightning);
				((Component)row.Rect).gameObject.SetActive(true);
				row.Title = detailedRow.Title;
				row.ItemIcon.texture = (detailedRow.Title ? preview.Icon : null);
				((Component)row.ItemIcon).gameObject.SetActive(detailedRow.Title && (Object)(object)preview.Icon != (Object)null);
				if ((Object)(object)row.ItemIcon.texture != (Object)null)
				{
					Texture texture = row.ItemIcon.texture;
					float num2 = (float)texture.width / (float)Mathf.Max(1, texture.height);
					((Graphic)row.ItemIcon).rectTransform.sizeDelta = ((num2 >= 1f) ? new Vector2(38f, 38f / num2) : new Vector2(38f * num2, 38f));
				}
				((Component)row.Arrow).gameObject.SetActive(false);
				Image val2 = NativeIcon(new MinimalRow("", detailedRow.Status, detailedRow.Lightning));
				row.Icon.sprite = (((Object)(object)val2 != (Object)null) ? val2.sprite : null);
				((Graphic)row.Icon).color = (Color)(((Object)(object)val2 != (Object)null) ? new Color(((Graphic)val2).color.r, ((Graphic)val2).color.g, ((Graphic)val2).color.b, 1f) : Color.white);
				((Component)row.Icon).gameObject.SetActive((Object)(object)row.Icon.sprite != (Object)null);
				((Component)row.Symbol).gameObject.SetActive(detailedRow.Buff.HasValue && !detailedRow.Lightning);
				if (detailedRow.Buff.HasValue)
				{
					PreviewSymbolKind previewSymbolKind = ((detailedRow.Buff == BuffKind.Speed) ? PreviewSymbolKind.Shoe : PreviewSymbolKind.Shield);
					if (row.Symbol.Kind != previewSymbolKind)
					{
						row.Symbol.Kind = previewSymbolKind;
						((Graphic)row.Symbol).SetVerticesDirty();
					}
				}
				string text2 = ((detailedRow.NamesStatus || !((Object)(object)row.Icon.sprite == (Object)null)) ? "" : (detailedRow.Status.HasValue ? (" " + Labels.Status(detailedRow.Status.Value)) : (detailedRow.Lightning ? (" " + Labels.ExtraStamina) : "")));
				((TMP_Text)row.Text).text = detailedRow.Text + text2;
				((Graphic)row.Text).color = (detailedRow.Title ? new Color(0.98f, 0.97f, 0.88f) : new Color(0.96f, 0.96f, 0.91f));
				((TMP_Text)row.Text).fontStyle = (FontStyles)(detailedRow.Title ? 1 : 0);
				((Behaviour)row.Shadow).enabled = true;
				((TMP_Text)row.Timing).text = detailedRow.Timing;
				((Component)row.Timing).gameObject.SetActive(detailedRow.Timing.Length > 0);
				((Component)row.Clock).gameObject.SetActive(detailedRow.Timing.Length > 0);
				if ((Object)(object)_font != (Object)null)
				{
					((TMP_Text)row.Text).font = _font;
					((TMP_Text)row.Timing).font = _font;
				}
			}
			for (int num3 = list.Count; num3 < _rows.Count; num3++)
			{
				((Component)_rows[num3].Rect).gameObject.SetActive(false);
			}
			((Component)_panel).gameObject.SetActive(true);
			if (flag)
			{
				LayoutRows();
			}
			Position();
		}

		private Row CreateRow()
		{
			//IL_0018: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: 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_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = new GameObject("Effect", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
			((Transform)component).SetParent((Transform)(object)_panel, false);
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 1f);
			component.anchorMax = val;
			component.anchorMin = val;
			component.pivot = new Vector2(0.5f, 1f);
			TextMeshProUGUI component2 = new GameObject("Value", new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			}).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component2).transform.SetParent((Transform)(object)component, false);
			((Graphic)component2).raycastTarget = false;
			((TMP_Text)component2).fontSize = 28f;
			RectTransform rectTransform = ((TMP_Text)component2).rectTransform;
			RectTransform rectTransform2 = ((TMP_Text)component2).rectTransform;
			((Vector2)(ref val))..ctor(0.5f, 1f);
			rectTransform2.anchorMax = val;
			rectTransform.anchorMin = val;
			((TMP_Text)component2).richText = false;
			((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component2).textWrappingMode = (TextWrappingModes)1;
			Image component3 = new GameObject("NativeStatusIcon", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			}).GetComponent<Image>();
			((Component)component3).transform.SetParent((Transform)(object)component, false);
			((Graphic)component3).raycastTarget = false;
			component3.preserveAspect = true;
			RectTransform rectTransform3 = ((Graphic)component3).rectTransform;
			RectTransform rectTransform4 = ((Graphic)component3).rectTransform;
			((Vector2)(ref val))..ctor(0.5f, 1f);
			rectTransform4.anchorMax = val;
			rectTransform3.anchorMin = val;
			((Graphic)component3).rectTransform.sizeDelta = new Vector2(30f, 30f);
			RawImage component4 = new GameObject("ItemIcon", new Type[2]
			{
				typeof(RectTransform),
				typeof(RawImage)
			}).GetComponent<RawImage>();
			((Component)component4).transform.SetParent((Transform)(object)component, false);
			((Graphic)component4).raycastTarget = false;
			((Graphic)component4).color = Color.white;
			RectTransform rectTransform5 = ((Graphic)component4).rectTransform;
			RectTransform rectTransform6 = ((Graphic)component4).rectTransform;
			((Vector2)(ref val))..ctor(0.5f, 1f);
			rectTransform6.anchorMax = val;
			rectTransform5.anchorMin = val;
			PreviewDeltaArrow component5 = new GameObject("DeltaDirection", new Type[2]
			{
				typeof(RectTransform),
				typeof(PreviewDeltaArrow)
			}).GetComponent<PreviewDeltaArrow>();
			((Component)component5).transform.SetParent((Transform)(object)component, false);
			((Graphic)component5).raycastTarget = false;
			RectTransform rectTransform7 = ((Graphic)component5).rectTransform;
			RectTransform rectTransform8 = ((Graphic)component5).rectTransform;
			((Vector2)(ref val))..ctor(0.5f, 1f);
			rectTransform8.anchorMax = val;
			rectTransform7.anchorMin = val;
			((Graphic)component5).rectTransform.sizeDelta = new Vector2(20f, 18f);
			TextMeshProUGUI component6 = new GameObject("Timing", new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			}).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component6).transform.SetParent((Transform)(object)component, false);
			((Graphic)component6).raycastTarget = false;
			((TMP_Text)component6).richText = false;
			((TMP_Text)component6).textWrappingMode = (TextWrappingModes)1;
			((TMP_Text)component6).alignment = (TextAlignmentOptions)4097;
			((Graphic)component6).color = new Color(0.82f, 0.85f, 0.81f);
			RectTransform rectTransform9 = ((TMP_Text)component6).rectTransform;
			RectTransform rectTransform10 = ((TMP_Text)component6).rectTransform;
			((Vector2)(ref val))..ctor(0.5f, 1f);
			rectTransform10.anchorMax = val;
			rectTransform9.anchorMin = val;
			PreviewSymbol component7 = new GameObject("Clock", new Type[2]
			{
				typeof(RectTransform),
				typeof(PreviewSymbol)
			}).GetComponent<PreviewSymbol>();
			((Component)component7).transform.SetParent((Transform)(object)component, false);
			((Graphic)component7).raycastTarget = false;
			component7.Kind = PreviewSymbolKind.Clock;
			((Graphic)component7).color = ((Graphic)component6).color;
			RectTransform rectTransform11 = ((Graphic)component7).rectTransform;
			RectTransform rectTransform12 = ((Graphic)component7).rectTransform;
			((Vector2)(ref val))..ctor(0.5f, 1f);
			rectTransform12.anchorMax = val;
			rectTransform11.anchorMin = val;
			((Graphic)component7).rectTransform.sizeDelta = new Vector2(20f, 20f);
			PreviewSymbol component8 = new GameObject("BuffIcon", new Type[2]
			{
				typeof(RectTransform),
				typeof(PreviewSymbol)
			}).GetComponent<PreviewSymbol>();
			((Component)component8).transform.SetParent((Transform)(object)component, false);
			((Graphic)component8).raycastTarget = false;
			RectTransform rectTransform13 = ((Graphic)component8).rectTransform;
			RectTransform rectTransform14 = ((Graphic)component8).rectTransform;
			((Vector2)(ref val))..ctor(0.5f, 1f);
			rectTransform14.anchorMax = val;
			rectTransform13.anchorMin = val;
			((Graphic)component8).rectTransform.sizeDelta = new Vector2(26f, 26f);
			Shadow val2 = ((Component)component2).gameObject.AddComponent<Shadow>();
			val2.effectColor = new Color(0f, 0f, 0f, 0.8f);
			val2.effectDistance = new Vector2(1f, -1f);
			return new Row
			{
				Rect = component,
				Text = component2,
				Icon = component3,
				ItemIcon = component4,
				Arrow = component5,
				Timing = component6,
				Clock = component7,
				Symbol = component8,
				Shadow = val2
			};
		}

		private void LayoutRows()
		{
			//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_0071: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: 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_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: 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_034c: 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_038c: Unknown result type (might be due to invalid IL or missing references)
			LayoutPasses++;
			_screenWidth = Screen.width;
			_screenHeight = Screen.height;
			_layoutScale = Mathf.Clamp(PresentationOptions.MinimalScale?.Value ?? 1f, 0.5f, 2f);
			if (_detailed)
			{
				LayoutDetailed();
				return;
			}
			Rect rect = ((RectTransform)((Component)this).transform).rect;
			float num = Mathf.Clamp(PresentationOptions.MinimalScale?.Value ?? 1f, 0.5f, 2f);
			((Transform)_panel).localScale = Vector3.one * num;
			float num2 = Mathf.Min(360f, (((Rect)(ref rect)).width - 32f) / num);
			float num3 = 0f;
			float num4 = 0f;
			for (int num5 = 28; num5 >= 18; num5--)
			{
				num3 = 0f;
				num4 = 0f;
				foreach (Row item in _rows.Where((Row r) => ((Component)r.Rect).gameObject.activeSelf))
				{
					((TMP_Text)item.Text).fontSize = num5;
					((Graphic)item.Icon).rectTransform.sizeDelta = new Vector2(30f, 30f);
					int num6 = (((Component)item.Icon).gameObject.activeSelf ? 38 : 0) + (((Component)item.Arrow).gameObject.activeSelf ? 28 : 0);
					num4 = Mathf.Max(num4, Mathf.Min(num2, ((TMP_Text)item.Text).GetPreferredValues(((TMP_Text)item.Text).text).x + (float)num6 + 4f));
				}
				foreach (Row item2 in _rows.Where((Row r) => ((Component)r.Rect).gameObject.activeSelf))
				{
					int num7 = (((Component)item2.Icon).gameObject.activeSelf ? 38 : 0);
					int num8 = (((Component)item2.Arrow).gameObject.activeSelf ? 28 : 0);
					float num9 = Mathf.Max(1f, num4 - (float)num7 - (float)num8);
					Vector2 preferredValues = ((TMP_Text)item2.Text).GetPreferredValues(((TMP_Text)item2.Text).text, num9, 0f);
					float num10 = Mathf.Max(34f, preferredValues.y + 4f);
					item2.Rect.sizeDelta = new Vector2(num4, num10);
					item2.Rect.anchoredPosition = new Vector2(0f, 0f - num3);
					((TMP_Text)item2.Text).rectTransform.sizeDelta = new Vector2(num9, num10);
					((TMP_Text)item2.Text).alignment = (TextAlignmentOptions)((num7 > 0) ? 4100 : 514);
					((TMP_Text)item2.Text).rectTransform.anchoredPosition = new Vector2((float)((num8 - num7) / 2), (0f - num10) / 2f);
					((Graphic)item2.Icon).rectTransform.anchoredPosition = new Vector2(num4 / 2f - 15f, (0f - num10) / 2f);
					((Graphic)item2.Arrow).rectTransform.anchoredPosition = new Vector2(num4 / 2f - (float)num7 - Mathf.Min(num9, preferredValues.x) - 16f, (0f - num10) / 2f);
					num3 += num10 + 3f;
				}
				if (num3 * num < ((Rect)(ref rect)).height - 160f)
				{
					break;
				}
			}
			_panel.sizeDelta = new Vector2(num4, num3);
		}

		private void LayoutDetailed()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: 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_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = ((RectTransform)((Component)this).transform).rect;
			float num = Mathf.Clamp(PresentationOptions.MinimalScale?.Value ?? 1f, 0.5f, 2f);
			float num2 = Mathf.Min(400f, (((Rect)(ref rect)).width - 32f) / num);
			float num3 = num2 - 32f;
			float num4 = 0f;
			for (int num5 = 24; num5 >= 18; num5--)
			{
				num4 = 16f;
				foreach (Row item in _rows.Where((Row r) => ((Component)r.Rect).gameObject.activeSelf))
				{
					((TMP_Text)item.Text).fontSize = (item.Title ? (num5 + 2) : num5);
					((TMP_Text)item.Timing).fontSize = num5 - 2;
					int num6 = (((Component)item.ItemIcon).gameObject.activeSelf ? 50 : ((((Component)item.Icon).gameObject.activeSelf || ((Component)item.Symbol).gameObject.activeSelf) ? 34 : 0));
					bool activeSelf = ((Component)item.Timing).gameObject.activeSelf;
					float num7 = (activeSelf ? Mathf.Min(num3 * 0.6f, ((TMP_Text)item.Timing).GetPreferredValues(((TMP_Text)item.Timing).text).x + 2f) : 0f);
					float num8 = num3 - (float)num6 - (activeSelf ? (num7 + 30f) : 0f);
					bool flag = activeSelf && ((TMP_Text)item.Text).GetPreferredValues(((TMP_Text)item.Text).text).x > num8;
					if (flag)
					{
						num8 = num3 - (float)num6;
					}
					float num9 = Mathf.Max((float)(((Component)item.ItemIcon).gameObject.activeSelf ? 42 : 30), ((TMP_Text)item.Text).GetPreferredValues(((TMP_Text)item.Text).text, num8, 0f).y + 4f);
					if (flag)
					{
						num7 = num3 - (float)num6 - 26f;
					}
					float num10 = (activeSelf ? Mathf.Max(24f, ((TMP_Text)item.Timing).GetPreferredValues(((TMP_Text)item.Timing).text, num7, 0f).y + 4f) : 0f);
					float num11 = (flag ? (num9 + num10) : Mathf.Max(num9, num10));
					item.Rect.sizeDelta = new Vector2(num3, num11);
					item.Rect.anchoredPosition = new Vector2(0f, 0f - num4);
					((TMP_Text)item.Text).alignment = (TextAlignmentOptions)4097;
					((TMP_Text)item.Text).rectTransform.sizeDelta = new Vector2(num8, num9);
					((TMP_Text)item.Text).rectTransform.anchoredPosition = new Vector2((0f - num3) / 2f + (float)num6 + num8 / 2f, (0f - num9) / 2f);
					((Graphic)item.Icon).rectTransform.anchoredPosition = new Vector2((0f - num3) / 2f + 13f, (0f - num9) / 2f);
					((Graphic)item.Icon).rectTransform.sizeDelta = new Vector2(26f, 26f);
					((Graphic)item.Symbol).rectTransform.anchoredPosition = ((Graphic)item.Icon).rectTransform.anchoredPosition;
					((Graphic)item.ItemIcon).rectTransform.anchoredPosition = new Vector2((0f - num3) / 2f + 19f, (0f - num9) / 2f);
					if (activeSelf)
					{
						float num12 = (flag ? ((0f - num3) / 2f + (float)num6) : (num3 / 2f - num7 - 26f));
						float num13 = (flag ? (0f - num9 - num10 / 2f) : ((0f - num11) / 2f));
						((Graphic)item.Clock).rectTransform.anchoredPosition = new Vector2(num12 + 10f, num13);
						((TMP_Text)item.Timing).rectTransform.sizeDelta = new Vector2(num7, num10);
						((TMP_Text)item.Timing).rectTransform.anchoredPosition = new Vector2(num12 + 26f + num7 / 2f, num13);
					}
					num4 += num11 + (float)(item.Title ? 10 : 6);
				}
				num4 += 10f;
				if (num4 * num <= ((Rect)(ref rect)).height - 160f)
				{
					break;
				}
			}
			((Transform)_panel).localScale = Vector3.one * Mathf.Min(num, Mathf.Max(0.1f, (((Rect)(ref rect)).height - 160f) / num4));
			_panel.sizeDelta = new Vector2(num2, num4);
		}

		private static Image? NativeIcon(MinimalRow data)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			StaminaBar val = (((Object)(object)GUIManager.instance != (Object)null) ? GUIManager.instance.bar : null);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			if (data.Lightning)
			{
				return val.extraStaminaIcon;
			}
			if (!data.Status.HasValue)
			{
				return null;
			}
			if ((int)data.Status.GetValueOrDefault() == 13)
			{
				if (!((Object)(object)val.petrifyAffliction != (Object)null))
				{
					return null;
				}
				return val.petrifyAffliction.icon;
			}
			return val.afflictions?.FirstOrDefault((Func<BarAffliction, bool>)((BarAffliction a) => (Object)(object)a != (Object)null && !a.isPetrify && (STATUSTYPE?)a.afflictionType == data.Status))?.icon;
		}

		private bool AdoptFont()
		{
			FontFallbackSwapper instance = FontFallbackSwapper.instance;
			object font;
			if (!((Object)(object)instance != (Object)null))
			{
				if (!((Object)(object)GUIManager.instance != (Object)null))
				{
					font = null;
				}
				else
				{
					TextMeshProUGUI interactNameText = GUIManager.instance.interactNameText;
					font = ((interactNameText != null) ? ((TMP_Text)interactNameText).font : null);
				}
			}
			else
			{
				font = instance.mainBaseFont;
			}
			_font = (TMP_FontAsset?)font;
			if ((Object)(object)_font == (Object)null)
			{
				return false;
			}
			if ((Object)(object)_checkedFont != (Object)(object)_font || _checkedLanguage != Labels.Language)
			{
				string requiredGlyphs = Labels.RequiredGlyphs;
				foreach (char c in requiredGlyphs)
				{
					if (!_font.HasCharacter(c, true, true))
					{
						return false;
					}
				}
				_checkedFont = _font;
				_checkedLanguage = Labels.Language;
			}
			return true;
		}

		private Rect Bounds(RectTransform rect)
		{
			//IL_001f: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_0090: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] corners = _corners;
			rect.GetWorldCorners(corners);
			Canvas componentInParent = ((Component)rect).GetComponentInParent<Canvas>();
			Camera val = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(float.MaxValue, float.MaxValue);
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(float.MinValue, float.MinValue);
			Vector3[] array = corners;
			Vector2 val6 = default(Vector2);
			foreach (Vector3 val4 in array)
			{
				Vector2 val5 = RectTransformUtility.WorldToScreenPoint(val, val4);
				RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Component)this).transform, val5, (Camera)null, ref val6);
				val2 = Vector2.Min(val2, val6);
				val3 = Vector2.Max(val3, val6);
			}
			return Rect.MinMaxRect(val2.x, val2.y, val3.x, val3.y);
		}

		private void LateUpdate()
		{
			if (IsVisible)
			{
				if (_screenWidth != Screen.width || _screenHeight != Screen.height)
				{
					LayoutRows();
				}
				Position();
			}
		}

		private void Position()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			if (_detailed)
			{
				((Graphic)_background).color = new Color(0.13f, 0.16f, 0.16f, Mathf.Clamp01(PresentationOptions.DetailedBackgroundOpacity?.Value ?? 0.92f));
			}
			GUIManager instance = GUIManager.instance;
			_group.alpha = (((Object)(object)instance != (Object)null && (Object)(object)instance.hudCanvasGroup != (Object)null) ? instance.hudCanvasGroup.alpha : 1f);
			Rect rect = ((RectTransform)((Component)this).transform).rect;
			InventoryItemUI val = ResolveAnchor(instance);
			float num = ((Rect)(ref rect)).xMax - 260f;
			float num2 = ((Rect)(ref rect)).yMin + 190f;
			if ((Object)(object)val != (Object)null)
			{
				Rect val2 = Bounds((RectTransform)(((Object)(object)val.rectTransform != (Object)null) ? ((object)val.rectTransform) : ((object)(RectTransform)((Component)val).transform)));
				num = ((Rect)(ref val2)).center.x;
				num2 = ((Rect)(ref val2)).yMax + 12f;
				if ((Object)(object)val.nameText != (Object)null && ((Behaviour)val.nameText).isActiveAndEnabled && !string.IsNullOrWhiteSpace(((TMP_Text)val.nameText).text))
				{
					num2 = Mathf.Max(num2, TextTop(val.nameText) + 12f);
				}
			}
			num += PresentationOptions.MinimalOffsetX?.Value ?? 0f;
			num2 += PresentationOptions.MinimalOffsetY?.Value ?? 0f;
			Rect rect2 = _panel.rect;
			float num3 = ((Rect)(ref rect2)).width * ((Transform)_panel).localScale.x;
			rect2 = _panel.rect;
			float num4 = ((Rect)(ref rect2)).height * ((Transform)_panel).localScale.y;
			_panel.anchoredPosition = ClampToScreen(rect, new Vector2(num, num2), new Vector2(num3, num4));
		}

		private InventoryItemUI? ResolveAnchor(GUIManager? gui)
		{
			if ((Object)(object)gui == (Object)null)
			{
				return null;
			}
			CharacterItems val = ((!((Object)(object)Character.observedCharacter != (Object)null)) ? null : Character.observedCharacter.refs?.items);
			int? heldSlot = (((Object)(object)val != (Object)null && val.currentSelectedSlot.IsSome) ? new int?(val.currentSelectedSlot.Value) : ((int?)null));
			ItemSlot[] inventory = (((Object)(object)Player.localPlayer != (Object)null) ? Player.localPlayer.itemSlots : null);
			bool temporaryHeld = (Object)(object)gui.temporaryItem != (Object)null && ((Component)gui.temporaryItem).gameObject.activeInHierarchy;
			int num = PreviewAnchor.Select(_source, heldSlot, Empty(0), Empty(1), Empty(2), temporaryHeld);
			if (num == 3)
			{
				return gui.backpack;
			}
			if (num == 4)
			{
				return gui.temporaryItem;
			}
			if (num >= 0 && gui.items != null && num < gui.items.Length)
			{
				return gui.items[num];
			}
			if (_source != PreviewSource.Held || gui.items == null)
			{
				return null;
			}
			return ((IEnumerable<InventoryItemUI>)gui.items).FirstOrDefault((Func<InventoryItemUI, bool>)((InventoryItemUI i) => (Object)(object)i != (Object)null && (Object)(object)i.nameText != (Object)null && ((Behaviour)i.nameText).isActiveAndEnabled));
			bool Empty(int index)
			{
				if (inventory != null && index < inventory.Length && inventory[index] != null)
				{
					return inventory[index].IsEmpty();
				}
				return false;
			}
		}

		internal static Vector2 ClampToScreen(Rect area, Vector2 anchor, Vector2 size)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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)
			return new Vector2(Mathf.Clamp(anchor.x, ((Rect)(ref area)).xMin + size.x / 2f + 16f, ((Rect)(ref area)).xMax - size.x / 2f - 16f), Mathf.Clamp(anchor.y, ((Rect)(ref area)).yMin + 16f, Mathf.Max(((Rect)(ref area)).yMin + 16f, ((Rect)(ref area)).yMax - size.y - 16f)));
		}

		private float TextTop(TextMeshProUGUI text)
		{
			//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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (((TMP_Text)text).havePropertiesChanged)
			{
				((TMP_Text)text).ForceMeshUpdate(false, false);
			}
			Transform transform = ((TMP_Text)text).transform;
			Bounds textBounds = ((TMP_Text)text).textBounds;
			Vector3 val = transform.TransformPoint(((Bounds)(ref textBounds)).max);
			Canvas componentInParent = ((Component)text).GetComponentInParent<Canvas>();
			Vector2 val2 = RectTransformUtility.WorldToScreenPoint(((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null, val);
			Vector2 val3 = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Component)this).transform, val2, (Camera)null, ref val3);
			return val3.y;
		}

		public void Hide()
		{
			_source = PreviewSource.None;
			if ((Object)(object)_panel != (Object)null)
			{
				((Component)_panel).gameObject.SetActive(false);
			}
		}
	}
	internal static class NativeVisualCopy
	{
		internal static RectTransform Create(RectTransform source, Transform parent, Transform? exclude = null)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0037: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			GameObject val = new GameObject(((Object)source).name, new Type[1] { typeof(RectTransform) });
			val.SetActive(false);
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).SetParent(parent, false);
			component.anchorMin = source.anchorMin;
			component.anchorMax = source.anchorMax;
			component.pivot = source.pivot;
			component.sizeDelta = source.sizeDelta;
			component.anchoredPosition = source.anchoredPosition;
			((Transform)component).localRotation = ((Transform)source).localRotation;
			((Transform)component).localScale = ((Transform)source).localScale;
			Image component2 = ((Component)source).GetComponent<Image>();
			if ((Object)(object)component2 != (Object)null)
			{
				CopyImage(component2, component);
			}
			Mask component3 = ((Component)source).GetComponent<Mask>();
			if ((Object)(object)component3 != (Object)null)
			{
				((Component)component).gameObject.AddComponent<Mask>().showMaskGraphic = component3.showMaskGraphic;
			}
			if ((Object)(object)((Component)source).GetComponent<RectMask2D>() != (Object)null)
			{
				((Component)component).gameObject.AddComponent<RectMask2D>();
			}
			foreach (Transform item in (Transform)source)
			{
				Transform val2 = item;
				RectTransform val3 = (RectTransform)(object)((val2 is RectTransform) ? val2 : null);
				if (val3 != null && (Object)(object)val2 != (Object)(object)exclude && !((Object)val2).name.StartsWith("PeakItemInsight"))
				{
					Create(val3, (Transform)(object)component, exclude);
				}
			}
			val.SetActive(((Component)source).gameObject.activeSelf);
			return component;
		}

		internal static Image CopyImage(Image source, RectTransform destination)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			bool activeSelf = ((Component)destination).gameObject.activeSelf;
			((Component)destination).gameObject.SetActive(false);
			Image val