Decompiled source of CookBook v1.4.0

CookBook.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CookBook;
using HG;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.UI;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Items;
using RoR2.UI;
using RoR2.UI.SkinControllers;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.TextCore;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CookBook")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1f8f89c89dda86f02a3771011e911aa3898bcb02")]
[assembly: AssemblyProduct("CookBook")]
[assembly: AssemblyTitle("CookBook")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
internal static class RecipeFilter
{
	public enum RecipeFilterCategory
	{
		All,
		Damage,
		Healing,
		Utility
	}

	private static readonly Dictionary<RecipeFilterCategory, ItemTag> CategoryToTag = new Dictionary<RecipeFilterCategory, ItemTag>
	{
		{
			RecipeFilterCategory.Damage,
			(ItemTag)1
		},
		{
			RecipeFilterCategory.Healing,
			(ItemTag)2
		},
		{
			RecipeFilterCategory.Utility,
			(ItemTag)3
		}
	};

	public static void ApplyFiltersToUI(List<CraftUI.RecipeRowUI> rows, string searchTerm, RecipeFilterCategory category)
	{
		if (rows == null)
		{
			return;
		}
		string text = searchTerm?.Trim().ToLowerInvariant();
		foreach (CraftUI.RecipeRowUI row in rows)
		{
			if (!((Object)(object)row.RowGO == (Object)null))
			{
				bool flag = string.IsNullOrEmpty(text) || EntryMatchesSearch(row.Entry, text);
				bool flag2 = EntryMatchesFilter(row.Entry, category);
				row.RowGO.SetActive(flag && flag2);
			}
		}
	}

	public static RecipeFilterCategory Next(RecipeFilterCategory category)
	{
		int num = (int)(category + 1);
		if (num <= 3)
		{
			return (RecipeFilterCategory)num;
		}
		return RecipeFilterCategory.All;
	}

	public static string GetLabel(RecipeFilterCategory category)
	{
		return category switch
		{
			RecipeFilterCategory.Damage => "<size=150%><sprite name=\"icon\"></size> DMG", 
			RecipeFilterCategory.Healing => "<size=150%><sprite name=\"icon\"></size> HEAL", 
			RecipeFilterCategory.Utility => "<size=150%><sprite name=\"icon\"></size> UTIL", 
			_ => "ALL", 
		};
	}

	private static bool EntryMatchesFilter(CraftPlanner.CraftableEntry entry, RecipeFilterCategory category)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		if (entry == null)
		{
			return false;
		}
		if (category == RecipeFilterCategory.All)
		{
			return true;
		}
		int resultIndex = entry.ResultIndex;
		if (resultIndex < 0)
		{
			return false;
		}
		if (resultIndex >= ItemCatalog.itemCount)
		{
			return true;
		}
		ItemDef itemDef = ItemCatalog.GetItemDef((ItemIndex)resultIndex);
		if ((Object)(object)itemDef != (Object)null)
		{
			return itemDef.ContainsTag(CategoryToTag[category]);
		}
		return false;
	}

	private static bool EntryMatchesSearch(CraftPlanner.CraftableEntry entry, string term)
	{
		if (string.IsNullOrEmpty(term))
		{
			return true;
		}
		if (entry == null)
		{
			return false;
		}
		string entryDisplayName = CraftUI.GetEntryDisplayName(entry);
		if (!string.IsNullOrEmpty(entryDisplayName))
		{
			return entryDisplayName.IndexOf(term, StringComparison.OrdinalIgnoreCase) >= 0;
		}
		return false;
	}

	public static void PatchVanillaNRE(orig_FilterAvailableOptions orig, CraftingController self)
	{
		NetworkUIPromptController component = ((Component)self).GetComponent<NetworkUIPromptController>();
		if (!((Object)(object)component == (Object)null) && !((Object)(object)component.currentParticipantMaster == (Object)null))
		{
			orig.Invoke(self);
		}
	}
}
namespace CookBook
{
	internal static class ChatNetworkHandler
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_AddMessage_string <0>__OnAddMessage;

			public static hook_OnProcessed <1>__OnUserChatMessageProcessed;
		}

		private const string NetPrefix = "CB_NET:";

		private static ManualLogSource _log;

		private static bool _enabled;

		private static readonly Dictionary<uint, float> _pendingAcks = new Dictionary<uint, float>();

		private const float AckTimeout = 2f;

		internal static event Action<NetworkUser, string, int, int> OnIncomingObjective;

		internal static void Init(ManualLogSource log)
		{
			//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_002f: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			_log = log;
			if (!_enabled)
			{
				_enabled = true;
				object obj = <>O.<0>__OnAddMessage;
				if (obj == null)
				{
					hook_AddMessage_string val = OnAddMessage;
					<>O.<0>__OnAddMessage = val;
					obj = (object)val;
				}
				Chat.AddMessage_string += (hook_AddMessage_string)obj;
				object obj2 = <>O.<1>__OnUserChatMessageProcessed;
				if (obj2 == null)
				{
					hook_OnProcessed val2 = OnUserChatMessageProcessed;
					<>O.<1>__OnUserChatMessageProcessed = val2;
					obj2 = (object)val2;
				}
				UserChatMessage.OnProcessed += (hook_OnProcessed)obj2;
			}
		}

		internal static void ShutDown()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_003e: 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_0049: Expected O, but got Unknown
			if (_enabled)
			{
				_enabled = false;
				object obj = <>O.<0>__OnAddMessage;
				if (obj == null)
				{
					hook_AddMessage_string val = OnAddMessage;
					<>O.<0>__OnAddMessage = val;
					obj = (object)val;
				}
				Chat.AddMessage_string -= (hook_AddMessage_string)obj;
				object obj2 = <>O.<1>__OnUserChatMessageProcessed;
				if (obj2 == null)
				{
					hook_OnProcessed val2 = OnUserChatMessageProcessed;
					<>O.<1>__OnUserChatMessageProcessed = val2;
					obj2 = (object)val2;
				}
				UserChatMessage.OnProcessed -= (hook_OnProcessed)obj2;
			}
		}

		private static void OnUserChatMessageProcessed(orig_OnProcessed orig, UserChatMessage self)
		{
			if (self.text == null || !self.text.Contains("CB_NET:"))
			{
				orig.Invoke(self);
			}
		}

		public static void SendObjectiveRequest(NetworkUser target, string command, int unifiedIdx, int quantity)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_00c9: 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)
			if (_enabled && !((Object)(object)target == (Object)null))
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					object[] obj = new object[6] { "CB_NET:", null, null, null, null, null };
					NetworkInstanceId netId = ((NetworkBehaviour)val).netId;
					obj[1] = ((NetworkInstanceId)(ref netId)).Value;
					netId = ((NetworkBehaviour)target).netId;
					obj[2] = ((NetworkInstanceId)(ref netId)).Value;
					obj[3] = command;
					obj[4] = unifiedIdx;
					obj[5] = quantity;
					string text = string.Format("{0}{1}:{2}:{3}:{4}:{5}", obj);
					DebugLog.Trace(_log, "[Net Out] Sending packet to " + target.userName + ": " + text);
					Console.instance.SubmitCmd(val, "say \"" + text + "\"", false);
					Dictionary<uint, float> pendingAcks = _pendingAcks;
					netId = ((NetworkBehaviour)target).netId;
					pendingAcks[((NetworkInstanceId)(ref netId)).Value] = Time.time;
					((MonoBehaviour)RoR2Application.instance).StopCoroutine("CheckAckTimeout");
					((MonoBehaviour)RoR2Application.instance).StartCoroutine(CheckAckTimeout(target, command, unifiedIdx, quantity));
				}
			}
		}

		private static IEnumerator CheckAckTimeout(NetworkUser target, string command, int idx, int qty)
		{
			yield return (object)new WaitForSeconds(2f);
			Dictionary<uint, float> pendingAcks = _pendingAcks;
			NetworkInstanceId netId = ((NetworkBehaviour)target).netId;
			if (pendingAcks.ContainsKey(((NetworkInstanceId)(ref netId)).Value))
			{
				Dictionary<uint, float> pendingAcks2 = _pendingAcks;
				netId = ((NetworkBehaviour)target).netId;
				pendingAcks2.Remove(((NetworkInstanceId)(ref netId)).Value);
				DebugLog.Trace(_log, "[Net] No ACK from " + target.userName + ". Falling back to raw text.");
				SendRawTextFallback(target, command, idx, qty);
			}
		}

		private static void SendRawTextFallback(NetworkUser target, string command, int unifiedIdx, int qty)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (!Object.op_Implicit((Object)(object)((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null)) || (Object)(object)target == (Object)null)
			{
				return;
			}
			string text = "Unknown Item";
			string text2 = "ffffff";
			if (unifiedIdx < ItemCatalog.itemCount)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef((ItemIndex)unifiedIdx);
				if ((Object)(object)itemDef != (Object)null)
				{
					text = Language.currentLanguage.GetLocalizedStringByToken(itemDef.nameToken);
					ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(itemDef.tier);
					ColorCatalog.GetColor(itemTierDef.colorIndex);
					if ((Object)(object)itemTierDef != (Object)null)
					{
						text2 = ColorCatalog.GetColorHexString(itemTierDef.colorIndex);
					}
				}
			}
			else
			{
				EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef((EquipmentIndex)(unifiedIdx - ItemCatalog.itemCount));
				if ((Object)(object)equipmentDef != (Object)null)
				{
					text = Language.currentLanguage.GetLocalizedStringByToken(equipmentDef.nameToken);
					text2 = ColorCatalog.GetColorHexString(equipmentDef.colorIndex);
				}
			}
			string text3 = ((command == "CRAFT") ? ("<color=#d299ff>[CookBook]</color> @" + target.userName + ", could you craft <color=#" + text2 + ">" + text + "</color>?") : $"<color=#d299ff>[CookBook]</color> @{target.userName}, I'm looking for ({qty}) <color=#{text2}>{text}</color>!");
			SimpleChatMessage val = new SimpleChatMessage();
			val.baseToken = "{0}";
			val.paramTokens = new string[1] { text3 };
			Chat.SendBroadcastChat((ChatMessageBase)(object)val);
		}

		private static void SendAck(uint senderID, string originalCmd)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
			object[] obj = new object[4] { "CB_NET:", null, null, null };
			NetworkInstanceId netId = ((NetworkBehaviour)val).netId;
			obj[1] = ((NetworkInstanceId)(ref netId)).Value;
			obj[2] = senderID;
			obj[3] = originalCmd;
			string text = string.Format("{0}{1}:{2}:ACK:{3}:0", obj);
			Console.instance.SubmitCmd(val, "say \"" + text + "\"", false);
		}

		public static void SendGlobalAbort()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (_enabled)
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					NetworkInstanceId netId = ((NetworkBehaviour)val).netId;
					string text = string.Format("{0}{1}:0:ABORT:0:0", "CB_NET:", ((NetworkInstanceId)(ref netId)).Value);
					DebugLog.Trace(_log, "[Net Out] Sending Global Abort: " + text);
					Console.instance.SubmitCmd(val, "say \"" + text + "\"", false);
				}
			}
		}

		public static void SendObjectiveSuccess(NetworkUser target, int unifiedIdx)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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)
			if (_enabled && !((Object)(object)target == (Object)null))
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					object[] obj = new object[4] { "CB_NET:", null, null, null };
					NetworkInstanceId netId = ((NetworkBehaviour)val).netId;
					obj[1] = ((NetworkInstanceId)(ref netId)).Value;
					netId = ((NetworkBehaviour)target).netId;
					obj[2] = ((NetworkInstanceId)(ref netId)).Value;
					obj[3] = unifiedIdx;
					string text = string.Format("{0}{1}:{2}:SUCCESS:{3}:0", obj);
					DebugLog.Trace(_log, $"[Net Out] Sending Success signal to {target.userName} for item {unifiedIdx}");
					Console.instance.SubmitCmd(val, "say \"" + text + "\"", false);
				}
			}
		}

		private static void OnAddMessage(orig_AddMessage_string orig, string message)
		{
			if (_enabled && message.Contains("CB_NET:"))
			{
				int num = message.IndexOf("CB_NET:");
				ParseAndProcess(message.Substring(num + "CB_NET:".Length));
			}
			else
			{
				orig.Invoke(message);
			}
		}

		private static void ParseAndProcess(string data)
		{
			//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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = data;
				int num = data.IndexOf('<');
				if (num != -1)
				{
					text = data.Substring(0, num);
				}
				string[] array = text.Split(':');
				if (array.Length < 5 || !uint.TryParse(array[0], out var senderID) || !uint.TryParse(array[1], out var result))
				{
					return;
				}
				string text2 = array[2].ToUpper();
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				NetworkUser val = ((firstLocalUser != null) ? firstLocalUser.currentNetworkUser : null);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				NetworkInstanceId netId;
				if (text2 == "ACK")
				{
					uint num2 = result;
					netId = ((NetworkBehaviour)val).netId;
					if (num2 == ((NetworkInstanceId)(ref netId)).Value)
					{
						DebugLog.Trace(_log, $"[Net In] ACK received from {senderID}. Request confirmed.");
						_pendingAcks.Remove(senderID);
						return;
					}
				}
				if (result != 0)
				{
					netId = ((NetworkBehaviour)val).netId;
					if (((NetworkInstanceId)(ref netId)).Value != result)
					{
						return;
					}
				}
				if (text2 != "ACK")
				{
					SendAck(senderID, text2);
				}
				int result3;
				int result4;
				if (text2 == "ABORT")
				{
					DebugLog.Trace(_log, $"[Net In] Global Abort received from Sender {senderID}");
					ObjectiveTracker.ClearObjectivesFromSender(senderID);
				}
				else if (text2 == "SUCCESS")
				{
					if (int.TryParse(array[3], out var result2))
					{
						ObjectiveTracker.ClearSpecificRequest(senderID, result2);
					}
				}
				else if (int.TryParse(array[3], out result3) && int.TryParse(array[4], out result4))
				{
					NetworkUser arg = ((IEnumerable<NetworkUser>)NetworkUser.readOnlyInstancesList).FirstOrDefault((Func<NetworkUser, bool>)delegate(NetworkUser u)
					{
						//IL_0001: Unknown result type (might be due to invalid IL or missing references)
						//IL_0006: Unknown result type (might be due to invalid IL or missing references)
						NetworkInstanceId netId2 = ((NetworkBehaviour)u).netId;
						return ((NetworkInstanceId)(ref netId2)).Value == senderID;
					});
					ChatNetworkHandler.OnIncomingObjective?.Invoke(arg, text2, result3, result4);
				}
			}
			catch (Exception ex)
			{
				_log.LogError((object)("[Net] Parse Error: " + ex.Message));
			}
		}
	}
	internal sealed class RecipeRowRuntime : MonoBehaviour
	{
		internal CraftUI Panel;

		internal CraftPlanner.CraftableEntry Entry;

		public RecipeRowView View;

		public bool IsExpanded;

		public float CollapsedHeight;

		private void OnDestroy()
		{
			if ((Object)(object)View != (Object)null && (Object)(object)View.RowTopButton != (Object)null)
			{
				((UnityEventBase)((Button)View.RowTopButton).onClick).RemoveAllListeners();
				View.RowTopButton.HighlightChanged = null;
			}
			Entry = null;
			Panel?.NotifyRecipeRowDestroyed(this);
		}
	}
	internal sealed class PathRowRuntime : MonoBehaviour
	{
		internal CraftUI Panel;

		internal RecipeRowRuntime OwnerRow;

		internal CraftPlanner.RecipeChain Chain;

		public PathRowView View;

		internal readonly List<(GameObject Template, SlotView Slot)> Slots = new List<(GameObject, SlotView)>();

		internal bool isSelected;

		internal bool isHovered;

		internal const float FadeDuration = 0.1f;

		internal static readonly Color Col_BG_Normal = Color32.op_Implicit(new Color32((byte)26, (byte)26, (byte)26, (byte)50));

		internal static readonly Color Col_BG_Active = Color32.op_Implicit(new Color32((byte)206, (byte)198, (byte)143, byte.MaxValue));

		internal static readonly Color Col_BG_Hover = Color32.op_Implicit(new Color32((byte)206, (byte)198, (byte)143, (byte)75));

		private void Awake()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			if ((Object)(object)View != (Object)null && (Object)(object)View.PathButton != (Object)null)
			{
				((UnityEvent)((Button)View.PathButton).onClick).AddListener(new UnityAction(OnClicked));
				View.PathButton.HighlightChanged = OnHighlightChanged;
			}
		}

		internal void Init(RecipeRowRuntime owner, CraftPlanner.RecipeChain chain)
		{
			OwnerRow = owner;
			Chain = chain;
			isSelected = false;
			isHovered = false;
			UpdateVisuals(instant: true);
		}

		private void OnDestroy()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			if ((Object)(object)View != (Object)null && (Object)(object)View.PathButton != (Object)null)
			{
				((UnityEvent)((Button)View.PathButton).onClick).RemoveListener(new UnityAction(OnClicked));
				View.PathButton.HighlightChanged = null;
			}
			Panel?.NotifyPathRowDestroyed(this);
			OwnerRow = null;
			Chain = null;
		}

		internal void OnClicked()
		{
			Panel.OnPathSelected(this);
		}

		internal void OnHighlightChanged(bool isHighlighted)
		{
			if (isHighlighted)
			{
				isHovered = true;
				Panel._currentHoveredPath = this;
				Panel.AttachReticleTo(View.VisualRect);
			}
			else
			{
				isHovered = false;
				if (Panel.IsReticleAttachedTo((Transform)(object)View.VisualRect))
				{
					Panel.RestoreReticleToSelection();
				}
			}
			UpdateVisuals(instant: false);
		}

		public void SetSelected(bool selected)
		{
			if (isSelected != selected)
			{
				isSelected = selected;
				if (isSelected)
				{
					Panel.AttachReticleTo(View.VisualRect);
				}
				UpdateVisuals(instant: false);
			}
		}

		private void UpdateVisuals(bool instant)
		{
			//IL_0040: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)View == (Object)null) && !((Object)(object)View.BackgroundImage == (Object)null))
			{
				Color val = (isSelected ? Col_BG_Active : (isHovered ? Col_BG_Hover : Col_BG_Normal));
				if (instant || (Object)(object)View.Fader == (Object)null)
				{
					((Graphic)View.BackgroundImage).color = val;
				}
				else
				{
					View.Fader.CrossFadeColor(val, 0.1f, true);
				}
			}
		}
	}
	internal sealed class CraftUIRunner : MonoBehaviour
	{
	}
	internal sealed class ScoreboardStripHook : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
	{
		internal ScoreboardStrip Strip;

		public void OnPointerClick(PointerEventData eventData)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if ((int)eventData.button == 0)
			{
				CraftUI.Scoreboard.ToggleStrip(Strip);
			}
		}
	}
	internal sealed class ScoreboardCloseHook : MonoBehaviour
	{
		private void OnDisable()
		{
			CraftUI.Scoreboard.Collapse();
		}
	}
	internal sealed class RowSnapScroll : MonoBehaviour
	{
		internal ScrollRect Scroll;

		internal float PadTop;

		private float _settled;

		private void LateUpdate()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			RectTransform content = Scroll.content;
			float y = content.anchoredPosition.y;
			if (Mathf.Abs(y - _settled) < 0.5f)
			{
				return;
			}
			bool flag = y > _settled;
			Rect rect = content.rect;
			float height = ((Rect)(ref rect)).height;
			rect = Scroll.viewport.rect;
			float num = Mathf.Max(0f, height - ((Rect)(ref rect)).height);
			float num2 = (flag ? num : 0f);
			foreach (RectTransform item in (Transform)content)
			{
				RectTransform val = item;
				if (((Component)val).gameObject.activeSelf)
				{
					float y2 = ((Transform)val).localPosition.y;
					rect = val.rect;
					float num3 = 0f - (y2 + ((Rect)(ref rect)).yMax) - PadTop;
					if (flag && num3 > _settled + 0.5f && num3 >= y - 0.5f && num3 < num2)
					{
						num2 = num3;
					}
					if (!flag && num3 < _settled - 0.5f && num3 <= y + 0.5f && num3 > num2)
					{
						num2 = num3;
					}
				}
			}
			num2 = Mathf.Clamp(num2, 0f, num);
			Scroll.StopMovement();
			content.anchoredPosition = new Vector2(content.anchoredPosition.x, num2);
			_settled = num2;
		}
	}
	internal sealed class ScoreboardPanelFollow : MonoBehaviour
	{
		internal RectTransform Target;

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

		private void LateUpdate()
		{
			Sync();
		}

		internal void Sync()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//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_005a: 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_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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0089: 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_0095: 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_00a3: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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)
			if (Object.op_Implicit((Object)(object)Target) && ((Component)Target).gameObject.activeInHierarchy)
			{
				RectTransform val = (RectTransform)((Component)this).transform;
				RectTransform val2 = (RectTransform)((Transform)val).parent;
				Target.GetWorldCorners(_corners);
				Vector3 val3 = ((Transform)val2).InverseTransformPoint(_corners[0]);
				Vector3 val4 = ((Transform)val2).InverseTransformPoint(_corners[2]);
				float x = val3.x;
				Rect rect = val2.rect;
				float num = x - ((Rect)(ref rect)).center.x;
				float y = val3.y;
				rect = val2.rect;
				val.anchoredPosition3D = new Vector3(num, y - ((Rect)(ref rect)).center.y, val3.z);
				val.sizeDelta = Vector2.op_Implicit(val4 - val3);
			}
		}
	}
	internal class RecipeDropdownRuntime : MonoBehaviour
	{
		internal CraftUI Panel;

		public DropdownView View;

		public RecipeRowRuntime CurrentOwner;

		public int SelectedPathIndex = -1;

		public void OpenFor(RecipeRowRuntime owner)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0041: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			CurrentOwner = owner;
			((Component)this).gameObject.SetActive(true);
			((Component)this).transform.SetParent((Transform)(object)owner.View.DropdownMountPoint, false);
			RectTransform val = (RectTransform)((Component)this).transform;
			val.anchorMin = Vector2.zero;
			val.anchorMax = Vector2.one;
			val.offsetMin = Vector2.zero;
			val.offsetMax = Vector2.zero;
			if ((Object)(object)View.ScrollRect != (Object)null)
			{
				((Behaviour)View.ScrollRect).enabled = owner.Entry.Chains.Count > 4;
				((ScrollRect)View.ScrollRect).verticalNormalizedPosition = 1f;
			}
			Panel.PopulateDropdown(View.Content, owner);
		}

		public void Close()
		{
			if (Panel._activeDropdownRoutine != null && (Object)(object)Panel._runner != (Object)null)
			{
				((MonoBehaviour)Panel._runner).StopCoroutine(Panel._activeDropdownRoutine);
				Panel._activeDropdownRoutine = null;
			}
			if (!((Object)(object)CurrentOwner == (Object)null))
			{
				SelectedPathIndex = -1;
				((Component)this).transform.SetParent(Panel._cookbookRoot.transform, false);
				((Component)this).gameObject.SetActive(false);
				CurrentOwner = null;
			}
		}

		private void OnDestroy()
		{
			CurrentOwner = null;
		}
	}
	internal static class CraftingExecutionHandler
	{
		private static ManualLogSource _log;

		private static ObjectiveTracker.ObjectiveToken _currentObjective;

		private static Coroutine _craftingRoutine;

		private static MonoBehaviour _runner;

		public static bool IsAutoCrafting => _craftingRoutine != null;

		internal static void Init(ManualLogSource log, MonoBehaviour runner)
		{
			_log = log;
			_runner = runner;
		}

		public static void ExecuteChain(CraftPlanner.RecipeChain chain, int repeatCount)
		{
			if (CookBook.isDebugMode)
			{
				DumpChain(chain, repeatCount);
			}
			Abort(closeUi: false);
			_craftingRoutine = _runner.StartCoroutine(CraftChainRoutine(chain, repeatCount));
		}

		private static void Cleanup(bool closeUi = false)
		{
			_craftingRoutine = null;
			StateController.BatchMode = false;
			CompleteCurrentObjective();
			if (closeUi && Object.op_Implicit((Object)(object)StateController.ActiveCraftingController))
			{
				CraftUI.Crafting.CloseCraftPanel(StateController.ActiveCraftingController);
			}
		}

		public static void Abort(bool closeUi = true)
		{
			if ((Object)(object)_runner != (Object)null && _craftingRoutine != null)
			{
				_runner.StopCoroutine(_craftingRoutine);
			}
			Cleanup(closeUi);
		}

		private static IEnumerator CraftChainRoutine(CraftPlanner.RecipeChain chain, int repeatCount)
		{
			CompleteCurrentObjective();
			StateController.BatchMode = false;
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterBody body = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
			LocalUser firstLocalUser2 = LocalUserManager.GetFirstLocalUser();
			if (firstLocalUser2 != null)
			{
				_ = firstLocalUser2.currentNetworkUser;
			}
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
			if (chain.DroneCostSparse != null)
			{
				CraftPlanner.DroneRequirement[] droneCostSparse = chain.DroneCostSparse;
				for (int i = 0; i < droneCostSparse.Length; i++)
				{
					CraftPlanner.DroneRequirement droneRequirement = droneCostSparse[i];
					if (!dictionary.ContainsKey(droneRequirement.ScrapIndex))
					{
						dictionary[droneRequirement.ScrapIndex] = 0;
					}
					dictionary[droneRequirement.ScrapIndex] += droneRequirement.Count;
				}
			}
			Dictionary<int, int> startCounts = new Dictionary<int, int>();
			Dictionary<int, int> currentProgress = new Dictionary<int, int>();
			if (chain.DroneCostSparse != null && chain.DroneCostSparse.Length != 0)
			{
				LocalUser firstLocalUser3 = LocalUserManager.GetFirstLocalUser();
				NetworkUser localUser = ((firstLocalUser3 != null) ? firstLocalUser3.currentNetworkUser : null);
				CraftPlanner.DroneRequirement[] droneCostSparse2 = chain.DroneCostSparse;
				for (int j = 0; j < droneCostSparse2.Length; j++)
				{
					CraftPlanner.DroneRequirement req = droneCostSparse2[j];
					if (!startCounts.ContainsKey(req.ScrapIndex))
					{
						PickupIndex pickupIndexFromUnified = GetPickupIndexFromUnified(req.ScrapIndex);
						startCounts[req.ScrapIndex] = GetOwnedCount(PickupCatalog.GetPickupDef(pickupIndexFromUnified), body);
						currentProgress[req.ScrapIndex] = 0;
					}
					currentProgress[req.ScrapIndex] += req.Count;
					int inventoryGoal = startCounts[req.ScrapIndex] + currentProgress[req.ScrapIndex];
					string droneName = GetDroneName(req.DroneIdx);
					if ((Object)(object)req.Owner == (Object)null || (Object)(object)req.Owner == (Object)(object)localUser)
					{
						yield return HandleAcquisition(GetPickupIndexFromUnified(req.ScrapIndex), inventoryGoal, "Scrap " + droneName + " for");
						continue;
					}
					ChatNetworkHandler.SendObjectiveRequest(req.Owner, "SCRAP", req.ScrapIndex, req.Count);
					string text = req.Owner?.userName ?? "Teammate";
					yield return HandleAcquisition(GetPickupIndexFromUnified(req.ScrapIndex), inventoryGoal, "Wait for " + text + " to scrap " + droneName + " for");
					ChatNetworkHandler.SendObjectiveSuccess(req.Owner, req.ScrapIndex);
				}
			}
			if (chain.AlliedTradeSparse != null && chain.AlliedTradeSparse.Length != 0)
			{
				CraftPlanner.TradeRequirement[] alliedTradeSparse = chain.AlliedTradeSparse;
				for (int j = 0; j < alliedTradeSparse.Length; j++)
				{
					CraftPlanner.TradeRequirement req2 = alliedTradeSparse[j];
					PickupIndex pickupIndexFromUnified2 = GetPickupIndexFromUnified(req2.UnifiedIndex);
					int inventoryGoal2 = GetOwnedCount(PickupCatalog.GetPickupDef(pickupIndexFromUnified2), body) + req2.TradesRequired;
					ChatNetworkHandler.SendObjectiveRequest(req2.Donor, "TRADE", req2.UnifiedIndex, req2.TradesRequired);
					string text2 = req2.Donor?.userName ?? "Ally";
					yield return HandleAcquisition(pickupIndexFromUnified2, inventoryGoal2, "Wait for " + text2 + " to trade");
					ChatNetworkHandler.SendObjectiveSuccess(req2.Donor, req2.UnifiedIndex);
				}
			}
			Queue<ChefRecipe> craftQueue = new Queue<ChefRecipe>();
			List<ChefRecipe> list = chain.Steps.Where((ChefRecipe s) => !(s is CraftPlanner.TradeRecipe)).ToList();
			for (int num = 0; num < repeatCount; num++)
			{
				foreach (ChefRecipe item in list)
				{
					craftQueue.Enqueue(item);
				}
			}
			PickupIndex lastPickup = PickupIndex.none;
			int lastQty = 0;
			int totalSteps = craftQueue.Count;
			int completedSteps = 0;
			StateController.BatchMode = true;
			while (craftQueue.Count > 0)
			{
				KeyboardShortcut value = CookBook.AbortKey.Value;
				if (((KeyboardShortcut)(ref value)).IsPressed())
				{
					Abort();
					yield break;
				}
				LocalUser firstLocalUser4 = LocalUserManager.GetFirstLocalUser();
				body = ((firstLocalUser4 != null) ? firstLocalUser4.cachedBody : null);
				if (!Object.op_Implicit((Object)(object)body))
				{
					Abort();
					yield break;
				}
				ChefRecipe step = craftQueue.Peek();
				string stepName = GetStepName(step);
				if (lastPickup != PickupIndex.none)
				{
					SetObjectiveText("Collect " + Language.GetString(PickupCatalog.GetPickupDef(lastPickup)?.nameToken ?? "Result"));
					yield return WaitForPendingPickup(lastPickup, lastQty);
					CompleteCurrentObjective();
					lastPickup = PickupIndex.none;
				}
				if (step != null)
				{
					value = CookBook.AbortKey.Value;
					if (((KeyboardShortcut)(ref value)).IsPressed())
					{
						Abort();
						yield break;
					}
					yield return EnsureIfEquipment(body, step.IngA, stepName);
					value = CookBook.AbortKey.Value;
					if (((KeyboardShortcut)(ref value)).IsPressed())
					{
						Abort();
						yield break;
					}
					if (step.HasB)
					{
						yield return EnsureIfEquipment(body, step.IngB, stepName);
						value = CookBook.AbortKey.Value;
						if (((KeyboardShortcut)(ref value)).IsPressed())
						{
							Abort();
							yield break;
						}
					}
				}
				if ((Object)(object)StateController.ActiveCraftingController == (Object)null)
				{
					yield return EnsureCraftingControllerOpen();
				}
				CraftingController controller = StateController.ActiveCraftingController;
				if (!Object.op_Implicit((Object)(object)controller))
				{
					Cleanup(closeUi: true);
					yield break;
				}
				List<PickupIndex> desired = ResolveStepIngredients(step);
				yield return SubmitIngredientsClientSafe(controller, desired);
				if ((Object)(object)controller != (Object)null && controller.AllSlotsFilled() && IngredientsMatchMultiset(controller.ingredients, ResolveStepIngredients(step)))
				{
					DebugLog.Trace(_log, "[Execution] " + stepName + " verified. Confirming craft...");
					craftQueue.Dequeue();
					completedSteps++;
					lastQty = step.ResultCount;
					lastPickup = (IsUsedLater(craftQueue, step.ResultIndex) ? GetPickupIndex(step) : PickupIndex.none);
					NetworkUIPromptController prompt = ((Component)controller).GetComponent<NetworkUIPromptController>();
					if (!Object.op_Implicit((Object)(object)prompt) || (Object)(object)prompt.currentParticipantMaster == (Object)null)
					{
						_log.LogWarning((object)"[Execution] Not confirming: participant master is null.");
						yield break;
					}
					controller.ConfirmSelection();
					yield return (object)new WaitForEndOfFrame();
					CraftUI.Crafting.CloseCraftPanel(controller);
					float releaseBudget = 3f;
					while (releaseBudget > 0f && Object.op_Implicit((Object)(object)prompt) && !((Object)(object)prompt.currentParticipantMaster == (Object)null))
					{
						releaseBudget -= Time.unscaledDeltaTime;
						yield return null;
					}
					if (Object.op_Implicit((Object)(object)prompt) && (Object)(object)prompt.currentParticipantMaster != (Object)null)
					{
						_log.LogWarning((object)"[Execution] Timed out waiting for prompt participant release. Aborting chain.");
						Cleanup(closeUi: true);
						yield break;
					}
					yield return (object)new WaitForSeconds(0.1f);
				}
				else if (Object.op_Implicit((Object)(object)StateController.ActiveCraftingController))
				{
					CraftUI.Crafting.CloseCraftPanel(StateController.ActiveCraftingController);
				}
			}
			DebugLog.Trace(_log, $"[ExecutionHandler] Finished {completedSteps}/{totalSteps} steps.");
			Cleanup(closeUi: true);
		}

		private static IEnumerator EnsureIfEquipment(CharacterBody body, int unifiedIndex, string stepName)
		{
			KeyboardShortcut value = CookBook.AbortKey.Value;
			if (((KeyboardShortcut)(ref value)).IsPressed())
			{
				yield break;
			}
			int itemCount = ItemCatalog.itemCount;
			if (unifiedIndex < itemCount)
			{
				yield break;
			}
			int num = unifiedIndex - itemCount;
			if ((uint)num < (uint)EquipmentCatalog.equipmentCount)
			{
				EquipmentIndex val = (EquipmentIndex)num;
				if ((int)val != -1)
				{
					SetObjectiveText("Preparing " + stepName + "...");
					yield return EnsureEquipmentIsActive(body, val);
				}
			}
		}

		private static bool IsCraftingSessionReady(CraftingController c)
		{
			if (!Object.op_Implicit((Object)(object)c))
			{
				return false;
			}
			NetworkUIPromptController component = ((Component)c).GetComponent<NetworkUIPromptController>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return false;
			}
			if ((Object)(object)component.currentParticipantMaster == (Object)null)
			{
				return false;
			}
			if (!component.isDisplaying)
			{
				return false;
			}
			CraftingPanel[] array = Object.FindObjectsOfType<CraftingPanel>();
			for (int i = 0; i < array.Length; i++)
			{
				if (Object.op_Implicit((Object)(object)array[i]) && (Object)(object)array[i].craftingController == (Object)(object)c)
				{
					return true;
				}
			}
			return false;
		}

		private static IEnumerator EnsureCraftingControllerOpen()
		{
			float t = 0f;
			while (!IsCraftingSessionReady(StateController.ActiveCraftingController))
			{
				KeyboardShortcut value = CookBook.AbortKey.Value;
				if (((KeyboardShortcut)(ref value)).IsPressed())
				{
					Abort();
					break;
				}
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
				Interactor val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<Interactor>() : null);
				if (!Object.op_Implicit((Object)(object)StateController.TargetCraftingObject) && Object.op_Implicit((Object)(object)val))
				{
					StateController.TargetCraftingObject = TryResolveChefStationObject(val);
				}
				if (!Object.op_Implicit((Object)(object)StateController.TargetCraftingObject) || !Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2))
				{
					_log.LogWarning((object)"[Execution] Lost target/body/interactor while trying to open crafting UI. Aborting.");
					Abort();
					break;
				}
				SetObjectiveText("Approach Wandering CHEF");
				float num = val2.maxInteractionDistance + 6f;
				Vector3 val3 = val.corePosition - StateController.TargetCraftingObject.transform.position;
				if (((Vector3)(ref val3)).sqrMagnitude <= num * num)
				{
					val2.AttemptInteraction(StateController.TargetCraftingObject);
				}
				t += Time.unscaledDeltaTime;
				if (t >= 12f)
				{
					_log.LogWarning((object)"[Execution] Timed out opening crafting UI.");
					Abort();
					break;
				}
				yield return (object)new WaitForSecondsRealtime(0.2f);
			}
		}

		private static List<PickupIndex> ResolveStepIngredients(ChefRecipe step)
		{
			if (step == null)
			{
				return new List<PickupIndex>(0);
			}
			int capacity = Mathf.Max(0, (int)step.CountA) + Mathf.Max(0, (int)step.CountB);
			List<PickupIndex> list = new List<PickupIndex>(capacity);
			int itemCount = ItemCatalog.itemCount;
			AddMany(step.IngA, Mathf.Max(0, (int)step.CountA));
			if (step.HasB)
			{
				AddMany(step.IngB, Mathf.Max(0, (int)step.CountB));
			}
			return list;
			void AddMany(int unifiedIndex, int count)
			{
				//IL_000a: 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)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: 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_0044: 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)
				if (count > 0 && unifiedIndex >= 0)
				{
					PickupIndex val = PickupIndex.none;
					if (unifiedIndex < itemCount)
					{
						val = PickupCatalog.FindPickupIndex((ItemIndex)unifiedIndex);
					}
					else
					{
						int num = unifiedIndex - itemCount;
						if ((uint)num < (uint)EquipmentCatalog.equipmentCount)
						{
							val = PickupCatalog.FindPickupIndex((EquipmentIndex)num);
						}
					}
					if (((PickupIndex)(ref val)).isValid && !(val == PickupIndex.none))
					{
						for (int i = 0; i < count; i++)
						{
							list.Add(val);
						}
					}
				}
			}
		}

		private static bool TryFindChoiceIndex(CraftingController c, PickupIndex desired, out int choiceIndex)
		{
			//IL_001f: 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)
			choiceIndex = -1;
			Option[] options = ((PickupPickerController)c).options;
			if (options == null)
			{
				return false;
			}
			for (int i = 0; i < options.Length; i++)
			{
				if (options[i].pickup.pickupIndex == desired)
				{
					choiceIndex = i;
					return true;
				}
			}
			return false;
		}

		private static bool IsChoiceIndexStillValid(CraftingController c, int idx, PickupIndex desired)
		{
			//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_001c: 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_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_002f: Unknown result type (might be due to invalid IL or missing references)
			Option[] options = ((PickupPickerController)c).options;
			if (options == null)
			{
				return false;
			}
			if ((uint)idx >= (uint)options.Length)
			{
				return false;
			}
			Option val = options[idx];
			if (val.available)
			{
				return val.pickup.pickupIndex == desired;
			}
			return false;
		}

		private static void SubmitChoiceToCraftingController(CraftingController c, int choiceIndex)
		{
			NetworkUIPromptController component = ((Component)c).GetComponent<NetworkUIPromptController>();
			if (Object.op_Implicit((Object)(object)component))
			{
				NetworkWriter val = component.BeginMessageToServer();
				if (val != null)
				{
					val.Write((byte)0);
					val.Write(choiceIndex);
					component.FinishMessageToServer(val);
				}
			}
		}

		private static IEnumerator SubmitIngredientsClientSafe(CraftingController controller, List<PickupIndex> desired)
		{
			if (!Object.op_Implicit((Object)(object)controller) || desired == null)
			{
				yield break;
			}
			NetworkUIPromptController prompt = ((Component)controller).GetComponent<NetworkUIPromptController>();
			float t = 2f;
			while (t > 0f && (!Object.op_Implicit((Object)(object)controller) || !Object.op_Implicit((Object)(object)prompt) || (Object)(object)prompt.currentParticipantMaster == (Object)null))
			{
				t -= Time.unscaledDeltaTime;
				yield return null;
			}
			if (!Object.op_Implicit((Object)(object)controller) || !Object.op_Implicit((Object)(object)prompt) || (Object)(object)prompt.currentParticipantMaster == (Object)null)
			{
				_log.LogError((object)"[Crafting] Participant Master not ready. Station not synced.");
				yield break;
			}
			if (desired.Count != controller.ingredientCount)
			{
				_log.LogWarning((object)$"[Crafting] Ingredient count mismatch. step needs {desired.Count}, controller has {controller.ingredientCount} slots.");
				yield break;
			}
			for (int i = 0; i < controller.ingredientCount; i++)
			{
				if (controller.ingredients != null && i < controller.ingredients.Length && controller.ingredients[i] != PickupIndex.none)
				{
					controller.ClearSlot(i);
				}
			}
			float clearBudget = 1f;
			while (clearBudget > 0f)
			{
				if (!Object.op_Implicit((Object)(object)controller))
				{
					yield break;
				}
				PickupIndex[] ingredients = controller.ingredients;
				if (ingredients != null)
				{
					bool flag = false;
					for (int j = 0; j < ingredients.Length; j++)
					{
						if (ingredients[j] != PickupIndex.none)
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						break;
					}
				}
				clearBudget -= Time.unscaledDeltaTime;
				yield return null;
			}
			for (int k = 0; k < desired.Count; k++)
			{
				if (!Object.op_Implicit((Object)(object)controller))
				{
					yield break;
				}
				PickupIndex want = desired[k];
				bool inserted = false;
				float insertBudget = 2f;
				while (!inserted && insertBudget > 0f)
				{
					if (!Object.op_Implicit((Object)(object)controller))
					{
						yield break;
					}
					if (controller.AllSlotsFilled() && !IngredientsMatchMultiset(controller.ingredients, desired))
					{
						_log.LogWarning((object)"[Crafting] Station became full with wrong ingredients. Aborting insert to avoid accidental confirm.");
						yield break;
					}
					Option[] options = ((PickupPickerController)controller).options;
					if (options == null || options.Length == 0)
					{
						insertBudget -= Time.unscaledDeltaTime;
						yield return null;
						continue;
					}
					if (!TryFindChoiceIndex(controller, want, out var choiceIndex) || !IsChoiceIndexStillValid(controller, choiceIndex, want))
					{
						insertBudget -= Time.unscaledDeltaTime;
						yield return null;
						continue;
					}
					Option val = ((PickupPickerController)controller).options[choiceIndex];
					DebugLog.Trace(_log, $"[Crafting] Pick want={want} choiceIndex={choiceIndex} optPickup={val.pickup.pickupIndex} available={val.available}");
					int filledBefore = CountFilled(controller.ingredients);
					int wantCountBefore = CountOf(controller.ingredients, want);
					SubmitChoiceToCraftingController(controller, choiceIndex);
					yield return (object)new WaitForSecondsRealtime(0.1f);
					float progressBudget = 1f;
					bool progressed = false;
					while (progressBudget > 0f)
					{
						if (!Object.op_Implicit((Object)(object)controller))
						{
							yield break;
						}
						PickupIndex[] ingredients2 = controller.ingredients;
						if (CountFilled(ingredients2) >= filledBefore + 1 && CountOf(ingredients2, want) > wantCountBefore)
						{
							progressed = true;
							break;
						}
						progressBudget -= Time.unscaledDeltaTime;
						yield return null;
					}
					if (!progressed)
					{
						DebugLog.Trace(_log, $"[Crafting] No fill-progress observed for {want}, retrying...");
						insertBudget -= 0.25f;
						continue;
					}
					float settleBudget = 0.75f;
					while (settleBudget > 0f)
					{
						if (!Object.op_Implicit((Object)(object)controller))
						{
							yield break;
						}
						if (IngredientsMatchPrefixMultiset(controller.ingredients, desired, k + 1))
						{
							inserted = true;
							break;
						}
						settleBudget -= Time.unscaledDeltaTime;
						yield return null;
					}
					if (!inserted)
					{
						DebugLog.Trace(_log, $"[Crafting] Change observed but state did not settle for {want}, retrying...");
						insertBudget -= 0.25f;
					}
				}
				if (!inserted)
				{
					_log.LogWarning((object)$"[Crafting] Failed to insert ingredient {k + 1}/{desired.Count}: {want}");
					yield break;
				}
			}
			float syncBudget = 2f;
			while (syncBudget > 0f)
			{
				if (!Object.op_Implicit((Object)(object)controller) || IngredientsMatchMultiset(controller.ingredients, desired))
				{
					yield break;
				}
				syncBudget -= Time.unscaledDeltaTime;
				yield return null;
			}
			_log.LogWarning((object)"[Crafting] Timed out waiting for ingredient sync.");
		}

		private static bool IngredientsMatchPrefixMultiset(PickupIndex[] current, List<PickupIndex> desired, int insertedCount)
		{
			//IL_0014: 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_0053: 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)
			if (current == null || desired == null)
			{
				return false;
			}
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
			for (int i = 0; i < insertedCount; i++)
			{
				int value = desired[i].value;
				dictionary.TryGetValue(value, out var value2);
				dictionary[value] = value2 + 1;
			}
			Dictionary<int, int> dictionary2 = new Dictionary<int, int>();
			foreach (PickupIndex val in current)
			{
				if (!(val == PickupIndex.none))
				{
					int value3 = val.value;
					dictionary2.TryGetValue(value3, out var value4);
					dictionary2[value3] = value4 + 1;
				}
			}
			if (dictionary2.Count != dictionary.Count)
			{
				return false;
			}
			foreach (KeyValuePair<int, int> item in dictionary)
			{
				if (!dictionary2.TryGetValue(item.Key, out var value5))
				{
					return false;
				}
				if (value5 != item.Value)
				{
					return false;
				}
			}
			return true;
		}

		private static bool IngredientsMatchMultiset(PickupIndex[] actualSlots, List<PickupIndex> desired)
		{
			//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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (actualSlots == null)
			{
				return false;
			}
			if (actualSlots.Length != desired.Count)
			{
				return false;
			}
			Dictionary<PickupIndex, int> dictionary = new Dictionary<PickupIndex, int>();
			Dictionary<PickupIndex, int> dictionary2 = new Dictionary<PickupIndex, int>();
			foreach (PickupIndex val in actualSlots)
			{
				if (val == PickupIndex.none)
				{
					return false;
				}
				dictionary[val] = ((!dictionary.TryGetValue(val, out var value)) ? 1 : (value + 1));
			}
			for (int j = 0; j < desired.Count; j++)
			{
				PickupIndex key = desired[j];
				dictionary2[key] = ((!dictionary2.TryGetValue(key, out var value2)) ? 1 : (value2 + 1));
			}
			if (dictionary.Count != dictionary2.Count)
			{
				return false;
			}
			foreach (KeyValuePair<PickupIndex, int> item in dictionary)
			{
				if (!dictionary2.TryGetValue(item.Key, out var value3))
				{
					return false;
				}
				if (value3 != item.Value)
				{
					return false;
				}
			}
			return true;
		}

		private static int CountFilled(PickupIndex[] slots)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (slots == null)
			{
				return 0;
			}
			int num = 0;
			for (int i = 0; i < slots.Length; i++)
			{
				if (slots[i] != PickupIndex.none)
				{
					num++;
				}
			}
			return num;
		}

		private static int CountOf(PickupIndex[] slots, PickupIndex p)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (slots == null)
			{
				return 0;
			}
			int num = 0;
			for (int i = 0; i < slots.Length; i++)
			{
				if (slots[i] == p)
				{
					num++;
				}
			}
			return num;
		}

		private static IEnumerator EnsureEquipmentIsActive(CharacterBody body, EquipmentIndex target)
		{
			//IL_000e: 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)
			Inventory inv = body.inventory;
			if (!Object.op_Implicit((Object)(object)inv) || (int)target == -1)
			{
				yield break;
			}
			int activeEquipmentSlot = inv.activeEquipmentSlot;
			int equipmentSlotCount = inv.GetEquipmentSlotCount();
			int accessibleEquipmentSetCount = inv.accessibleEquipmentSetCount;
			int targetSlot = -1;
			int targetSet = -1;
			for (int i = 0; i < equipmentSlotCount; i++)
			{
				for (int j = 0; j < accessibleEquipmentSetCount; j++)
				{
					EquipmentLocation val = new EquipmentLocation
					{
						slot = (uint)i,
						set = (uint)j
					};
					if (inv.GetEquipment(ref val).equipmentIndex == target)
					{
						targetSlot = i;
						targetSet = j;
						break;
					}
				}
				if (targetSlot != -1)
				{
					break;
				}
			}
			if (targetSlot == -1)
			{
				yield break;
			}
			if (targetSlot != activeEquipmentSlot)
			{
				GenericSkill skill = body.skillLocator?.special;
				if (Object.op_Implicit((Object)(object)skill))
				{
					if (Object.op_Implicit((Object)(object)StateController.ActiveCraftingController))
					{
						CraftUI.Crafting.CloseCraftPanel(StateController.ActiveCraftingController);
					}
					while (!skill.CanExecute())
					{
						yield return (object)new WaitForSeconds(0.1f);
					}
					DebugLog.Trace(_log, $"[Execution] Retooling to Slot {targetSlot}.");
					skill.ExecuteIfReady();
					float timeout = 1f;
					while (inv.activeEquipmentSlot != targetSlot && timeout > 0f)
					{
						timeout -= 0.1f;
						yield return (object)new WaitForSeconds(0.1f);
					}
				}
			}
			int activeEquipmentSetInSlot = (int)inv.GetActiveEquipmentSetInSlot((uint)inv.activeEquipmentSlot);
			int accessibleEquipmentSetCount2 = inv.accessibleEquipmentSetCount;
			if (targetSet != activeEquipmentSetInSlot)
			{
				if (Object.op_Implicit((Object)(object)StateController.ActiveCraftingController))
				{
					CraftUI.Crafting.CloseCraftPanel(StateController.ActiveCraftingController);
				}
				int num = (targetSet - activeEquipmentSetInSlot + accessibleEquipmentSetCount2) % accessibleEquipmentSetCount2;
				DebugLog.Trace(_log, $"[Execution] Cycling sets ({num} clicks) for {target}.");
				for (int k = 0; k < num; k++)
				{
					inv.CallCmdSwitchToNextEquipmentInSet();
				}
				float timeout = 2f;
				while (inv.GetActiveEquipmentSetInSlot((uint)inv.activeEquipmentSlot) != (uint)targetSet && timeout > 0f)
				{
					timeout -= 0.1f;
					yield return (object)new WaitForSeconds(0.1f);
				}
			}
		}

		private static GameObject TryResolveChefStationObject(CharacterBody body)
		{
			//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)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (!Object.op_Implicit((Object)(object)body))
			{
				return null;
			}
			MealPrepController[] array = Object.FindObjectsOfType<MealPrepController>();
			if (array == null || array.Length == 0)
			{
				return null;
			}
			MealPrepController val = null;
			float num = float.PositiveInfinity;
			Vector3 corePosition = body.corePosition;
			MealPrepController[] array2 = array;
			foreach (MealPrepController val2 in array2)
			{
				if (Object.op_Implicit((Object)(object)val2))
				{
					Vector3 val3 = ((Component)val2).transform.position - corePosition;
					float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						val = val2;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			IInteractable componentInChildren = ((Component)val).GetComponentInChildren<IInteractable>();
			Component val4 = (Component)(object)((componentInChildren is Component) ? componentInChildren : null);
			if (!Object.op_Implicit((Object)(object)val4))
			{
				return ((Component)val).gameObject;
			}
			return val4.gameObject;
		}

		private static IEnumerator HandleAcquisition(PickupIndex pi, int inventoryGoal, string actionPrefix)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterBody body = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
			PickupDef def = PickupCatalog.GetPickupDef(pi);
			if (!Object.op_Implicit((Object)(object)body) || def == null)
			{
				yield break;
			}
			string itemName = Language.GetString(def.nameToken);
			while (true)
			{
				int ownedCount = GetOwnedCount(def, body);
				int num = inventoryGoal - ownedCount;
				if (num <= 0)
				{
					break;
				}
				SetObjectiveText($"{actionPrefix} {itemName} <style=cSub>(Need {num})</style>");
				yield return (object)new WaitForSeconds(0.1f);
			}
			CompleteCurrentObjective();
		}

		private static bool IsUsedLater(Queue<ChefRecipe> craftQueue, int unifiedIndex)
		{
			foreach (ChefRecipe item in craftQueue)
			{
				if (item != null && (item.IngA == unifiedIndex || (item.HasB && item.IngB == unifiedIndex)))
				{
					return true;
				}
			}
			return false;
		}

		private static IEnumerator WaitForPendingPickup(PickupIndex pickupIndex, int expectedGain)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterBody body = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory))
			{
				yield break;
			}
			PickupDef def = PickupCatalog.GetPickupDef(pickupIndex);
			if (def != null)
			{
				int targetCount = GetOwnedCount(def, body) + expectedGain;
				while (GetOwnedCount(def, body) < targetCount)
				{
					yield return (object)new WaitForSeconds(0.1f);
				}
				DebugLog.Trace(_log, "[Chain] Confirmed pickup of " + def.internalName + ".");
			}
		}

		private static int GetOwnedCount(PickupDef def, CharacterBody body)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_0067: 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)
			if ((int)def.itemIndex != -1)
			{
				return body.inventory.GetItemCountPermanent(def.itemIndex);
			}
			if ((int)def.equipmentIndex != -1)
			{
				Inventory inventory = body.inventory;
				int equipmentSlotCount = inventory.GetEquipmentSlotCount();
				int accessibleEquipmentSetCount = inventory.accessibleEquipmentSetCount;
				for (int i = 0; i < equipmentSlotCount; i++)
				{
					for (int j = 0; j < accessibleEquipmentSetCount; j++)
					{
						EquipmentLocation val = new EquipmentLocation
						{
							slot = (uint)i,
							set = (uint)j
						};
						if (inventory.GetEquipment(ref val).equipmentIndex == def.equipmentIndex)
						{
							return 1;
						}
					}
				}
			}
			return 0;
		}

		private static string GetStepName(ChefRecipe step)
		{
			string text = ((step.ResultIndex < ItemCatalog.itemCount) ? Language.GetString(ItemCatalog.GetItemDef((ItemIndex)step.ResultIndex)?.nameToken) : Language.GetString(EquipmentCatalog.GetEquipmentDef((EquipmentIndex)(step.ResultIndex - ItemCatalog.itemCount))?.nameToken));
			if (step is CraftPlanner.TradeRecipe)
			{
				return "<style=cIsUtility>Trade: " + text + "</style>";
			}
			return text;
		}

		private static PickupIndex GetPickupIndex(ChefRecipe step)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (step.ResultIndex < ItemCatalog.itemCount)
			{
				return PickupCatalog.FindPickupIndex((ItemIndex)step.ResultIndex);
			}
			return PickupCatalog.FindPickupIndex((EquipmentIndex)(step.ResultIndex - ItemCatalog.itemCount));
		}

		private static string GetDroneName(DroneIndex droneIdx)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			if ((int)droneIdx != -1)
			{
				GameObject val = DroneCatalog.GetDroneDef(droneIdx)?.bodyPrefab;
				if (Object.op_Implicit((Object)(object)val))
				{
					CharacterBody component = val.GetComponent<CharacterBody>();
					if (component != null)
					{
						return Language.GetString(component.baseNameToken);
					}
				}
			}
			return "Drone";
		}

		private static PickupIndex GetPickupIndexFromUnified(int unifiedIndex)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			if (unifiedIndex < ItemCatalog.itemCount)
			{
				return PickupCatalog.FindPickupIndex((ItemIndex)unifiedIndex);
			}
			return PickupCatalog.FindPickupIndex((EquipmentIndex)(unifiedIndex - ItemCatalog.itemCount));
		}

		private static void SetObjectiveText(string text)
		{
			if ((Object)(object)_currentObjective == (Object)null)
			{
				_currentObjective = ObjectiveTracker.CreateObjective(text);
			}
			else
			{
				_currentObjective.UpdateText(text);
			}
		}

		private static void CompleteCurrentObjective()
		{
			if ((Object)(object)_currentObjective != (Object)null)
			{
				_currentObjective.Complete();
				_currentObjective = null;
			}
		}

		private static void DumpChain(CraftPlanner.RecipeChain chain, int repeatCount)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			DebugLog.Trace(_log, "┌──────────────────────────────────────────────────────────┐");
			DebugLog.Trace(_log, $"│ CHAIN EXECUTION: {GetItemName(chain.ResultIndex)} (x{repeatCount})");
			DebugLog.Trace(_log, "├───────────────────────────────────────────────────────────");
			if (chain.DroneCostSparse.Length != 0)
			{
				DebugLog.Trace(_log, "│ [Resources] Drones Needed:");
				CraftPlanner.DroneRequirement[] droneCostSparse = chain.DroneCostSparse;
				for (int i = 0; i < droneCostSparse.Length; i++)
				{
					CraftPlanner.DroneRequirement droneRequirement = droneCostSparse[i];
					DebugLog.Trace(_log, "│   - " + GetDroneName(droneRequirement.DroneIdx) + " -> 1x " + GetItemName(droneRequirement.ScrapIndex));
				}
			}
			if (chain.AlliedTradeSparse.Length != 0)
			{
				DebugLog.Trace(_log, "│ [Resources] Allied Trades:");
				CraftPlanner.TradeRequirement[] alliedTradeSparse = chain.AlliedTradeSparse;
				for (int i = 0; i < alliedTradeSparse.Length; i++)
				{
					CraftPlanner.TradeRequirement tradeRequirement = alliedTradeSparse[i];
					DebugLog.Trace(_log, string.Format("│   - {0}: {1}x {2}", tradeRequirement.Donor?.userName ?? "Ally", tradeRequirement.TradesRequired, GetItemName(tradeRequirement.UnifiedIndex)));
				}
			}
			DebugLog.Trace(_log, "│ [Workflow] Sequence:");
			List<ChefRecipe> list = chain.Steps.Where((ChefRecipe s) => !(s is CraftPlanner.TradeRecipe)).ToList();
			for (int num = 0; num < list.Count; num++)
			{
				ChefRecipe chefRecipe = list[num];
				string text = FormatStepIngredients(chefRecipe);
				DebugLog.Trace(_log, $"│   Step {num + 1}: [{text}] —> {chefRecipe.ResultCount}x {GetItemName(chefRecipe.ResultIndex)}");
			}
			DebugLog.Trace(_log, "└─────────────────────────────────────────────────────────┘");
		}

		private static string FormatStepIngredients(ChefRecipe step)
		{
			if (step == null)
			{
				return string.Empty;
			}
			List<string> list = new List<string>(2);
			int num = Mathf.Max(0, (int)step.CountA);
			if (num > 0 && step.IngA >= 0)
			{
				list.Add($"{num}x {GetItemName(step.IngA)}");
			}
			int num2 = Mathf.Max(0, (int)step.CountB);
			if (step.HasB && num2 > 0 && step.IngB >= 0)
			{
				list.Add($"{num2}x {GetItemName(step.IngB)}");
			}
			return string.Join(", ", list);
		}

		private static string GetItemName(int unifiedIndex)
		{
			if (unifiedIndex < ItemCatalog.itemCount)
			{
				return Language.GetString(ItemCatalog.GetItemDef((ItemIndex)unifiedIndex)?.nameToken ?? "Unknown Item");
			}
			return Language.GetString(EquipmentCatalog.GetEquipmentDef((EquipmentIndex)(unifiedIndex - ItemCatalog.itemCount))?.nameToken ?? "Unknown Equip");
		}
	}
	internal sealed class CraftUI
	{
		internal struct ButtonParts
		{
			public HGButton Button;

			public TextMeshProUGUI Label;

			public Image Image;

			public bool IsCanon;
		}

		internal struct RecipeRowUI
		{
			public CraftPlanner.CraftableEntry Entry;

			public GameObject RowGO;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__OnScoreboardOpen;
		}

		private static readonly Type[] _keepTypes = new Type[13]
		{
			typeof(Graphic),
			typeof(Selectable),
			typeof(MPEventSystemLocator),
			typeof(LayoutElement),
			typeof(LayoutGroup),
			typeof(ContentSizeFitter),
			typeof(RectMask2D),
			typeof(Mask),
			typeof(BaseMeshEffect),
			typeof(CanvasGroup),
			typeof(Canvas),
			typeof(GraphicRaycaster),
			typeof(ButtonSkinController)
		};

		private static readonly AssetReferenceT<Sprite> HatchingTileRef = new AssetReferenceT<Sprite>("5966ada566cc9ac4e88882edffcb4578");

		private static Sprite _hatchSprite;

		internal float _panelHeight;

		internal const float RowTopHeightNorm = 0.111821085f;

		internal const float RowTopTopPaddingNorm = 0.007987221f;

		internal const float RowTopBottomPaddingNorm = 0.007987221f;

		internal const float RowTopElementSpacingNorm = 1f / 55f;

		internal const float MetaDataColumnWidthNorm = 14f / 55f;

		internal const float DropDownArrowSizeNorm = 0.05111821f;

		internal const int PathsContainerMaxVisibleRows = 4;

		internal const float PathsContainerSpacingNorm = 0.007987221f;

		internal const float PathRowHeightNorm = 0.079872206f;

		internal const float IngredientHeightNorm = 0.06709265f;

		internal const float ButtonFrameInsetPx = 6f;

		private readonly List<Selectable> _navOrder = new List<Selectable>();

		private const double BuildBudgetMs = 4.0;

		internal static readonly CraftUI Scoreboard = new CraftUI
		{
			_cutDown = true
		};

		private static readonly AssetReferenceGameObject WokPanelRef = new AssetReferenceGameObject("f503de92590d0ee40bae54e7a7d969c8");

		private static CraftingPanel _wokPanel;

		private const float ListBottomMargin = 10f;

		private const float RefreshDelay = 1f;

		private const float SearchGap = 8f;

		internal bool _cutDown;

		private ScoreboardStrip _expandedStrip;

		private CharacterMaster _filledMaster;

		private GameObject _inspectPanel;

		private RectTransform _spacer;

		private Coroutine _refreshRoutine;

		private bool _paused;

		private ButtonParts _pinButton;

		private RecipeRowRuntime _pinRow;

		internal static readonly CraftUI Crafting = new CraftUI();

		internal bool _skeletonBuilt;

		internal CraftingController _currentController;

		internal InventorySnapshot _snap;

		internal bool _hasSnap;

		internal GameObject _cookbookRoot;

		internal GameObject _panelHolder;

		internal MPEventSystemProvider _eventSystemProvider;

		internal Vector2 _builtSize;

		internal ReticleClip _reticleClip;

		internal RectTransform _recipeListContent;

		internal TMP_InputField _searchInputField;

		internal GameObject _recipeRowTemplate;

		internal GameObject _pathRowTemplate;

		internal GameObject _ingredientSlotTemplate;

		internal GameObject _droneSlotTemplate;

		internal GameObject _tradeSlotTemplate;

		internal GameObject _ResultSlotTemplate;

		internal Coroutine _activeBuildRoutine;

		internal Coroutine _activeDropdownRoutine;

		internal RectTransform _selectionReticle;

		internal RectTransform _currentReticleTarget;

		internal RectTransform _selectedAnchor;

		internal HGButton _globalCraftButton;

		internal TextMeshProUGUI _globalCraftButtonText;

		internal Image _globalCraftButtonImage;

		internal bool _globalCraftButtonIsCanon;

		internal CraftPlanner.RecipeChain _selectedChainData;

		internal TMP_InputField _repeatInputField;

		internal HGButton _repeatMinusButton;

		internal HGButton _repeatPlusButton;

		internal HGButton _categoryButton;

		internal CraftingPanel _craftingPanel;

		internal HGButton _vanillaButtonTemplate;

		internal UILayerKey _vanillaTopLayer;

		internal static Sprite _solidPointSprite;

		internal readonly List<RecipeRowUI> _recipeRowUIs = new List<RecipeRowUI>();

		internal MethodInfo _onIngredientsChangedMethod;

		internal RecipeRowRuntime _openRow;

		internal RecipeFilter.RecipeFilterCategory _category;

		internal CraftUIRunner _runner;

		internal RecipeDropdownRuntime _sharedDropdown;

		internal RecipeRowRuntime _cachedDropdownOwner;

		internal RecipeRowRuntime _emptyRow;

		internal readonly Dictionary<GameObject, Stack<SlotView>> _slotPools = new Dictionary<GameObject, Stack<SlotView>>();

		internal Transform _slotPoolRoot;

		internal PathRowRuntime _currentHoveredPath;

		internal PathRowRuntime _selectedPathUI;

		internal static ManualLogSource _log;

		private bool ViewingSelf
		{
			get
			{
				if (Object.op_Implicit((Object)(object)_filledMaster))
				{
					CharacterMaster filledMaster = _filledMaster;
					LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
					return (Object)(object)filledMaster == (Object)(object)((firstLocalUser != null) ? firstLocalUser.cachedMaster : null);
				}
				return false;
			}
		}

		internal IReadOnlyList<CraftPlanner.CraftableEntry> LastCraftables { get; private set; }

		internal static HGButton FindVanillaButtonTemplate(CraftingPanel craftingPanel)
		{
			if (!Object.op_Implicit((Object)(object)craftingPanel))
			{
				return null;
			}
			HGButton[] componentsInChildren = ((Component)craftingPanel).GetComponentsInChildren<HGButton>(true);
			foreach (HGButton val in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)val) && !((Object)(object)val == (Object)(object)craftingPanel.confirmButton) && (!Object.op_Implicit((Object)(object)craftingPanel.inventoryContainer) || !((Component)val).transform.IsChildOf((Transform)(object)craftingPanel.inventoryContainer)) && (!Object.op_Implicit((Object)(object)craftingPanel.ingredientContainer) || !((Component)val).transform.IsChildOf((Transform)(object)craftingPanel.ingredientContainer)) && Object.op_Implicit((Object)(object)((Selectable)val).targetGraphic) && Object.op_Implicit((Object)(object)((Component)val).GetComponentInChildren<TextMeshProUGUI>(true)))
				{
					return val;
				}
			}
			MPButton confirmButton = craftingPanel.confirmButton;
			return (HGButton)(object)((confirmButton is HGButton) ? confirmButton : null);
		}

		internal ButtonParts CreateCanonButton(string name, RectTransform parent, string text)
		{
			if (Object.op_Implicit((Object)(object)_vanillaButtonTemplate))
			{
				ButtonParts result = CloneVanillaButton(name, parent, text);
				if (Object.op_Implicit((Object)(object)result.Button))
				{
					return result;
				}
			}
			return CreateFlatButton(name, parent, text);
		}

		internal ButtonParts CloneVanillaButton(string name, RectTransform parent, string text)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateUIObject("ButtonStaging", typeof(RectTransform));
			val.SetActive(false);
			val.transform.SetParent((Transform)(object)parent, false);
			GameObject val2 = Object.Instantiate<GameObject>(((Component)_vanillaButtonTemplate).gameObject, val.transform, false);
			((Object)val2).name = name;
			StripForeignBehaviours(val2);
			HGButton component = val2.GetComponent<HGButton>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)((Selectable)component).targetGraphic))
			{
				Object.Destroy((Object)(object)val);
				_log.LogError((object)("CraftUI: cloned button '" + name + "' missing HGButton/targetGraphic, using flat fallback."));
				return default(ButtonParts);
			}
			((Button)component).onClick = new ButtonClickedEvent();
			component.updateTextOnHover = false;
			component.hoverLanguageTextMeshController = null;
			((MPButton)component).requiredTopLayer = _vanillaTopLayer;
			((Selectable)component).interactable = true;
			ButtonSkinController component2 = val2.GetComponent<ButtonSkinController>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.useRecommendedButtonWidth = false;
				component2.useRecommendedButtonHeight = false;
			}
			TextMeshProUGUI componentInChildren = val2.GetComponentInChildren<TextMeshProUGUI>(true);
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				((TMP_Text)componentInChildren).text = text;
				((TMP_Text)componentInChildren).enableWordWrapping = false;
				((TMP_Text)componentInChildren).overflowMode = (TextOverflowModes)1;
				((TMP_Text)componentInChildren).enableAutoSizing = true;
				((TMP_Text)componentInChildren).fontSizeMax = ((TMP_Text)componentInChildren).fontSize;
				((TMP_Text)componentInChildren).fontSizeMin = 8f;
				((TMP_Text)componentInChildren).margin = new Vector4(0f, 6f, 0f, 6f);
			}
			RectTransform val3 = (RectTransform)val2.transform;
			((Transform)val3).SetParent((Transform)(object)parent, false);
			((Transform)val3).localScale = Vector3.one;
			((Transform)val3).localRotation = Quaternion.identity;
			LayoutElement component3 = val2.GetComponent<LayoutElement>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				component3.ignoreLayout = true;
			}
			val2.AddComponent<DeselectOnPointerExit>();
			Object.Destroy((Object)(object)val);
			return new ButtonParts
			{
				Button = component,
				Label = componentInChildren,
				Image = (Image)/*isinst with value type is only supported in some contexts*/,
				IsCanon = true
			};
		}

		internal static void StripForeignBehaviours(GameObject root)
		{
			List<string> list = new List<string>();
			bool flag = true;
			while (flag)
			{
				flag = false;
				MonoBehaviour[] componentsInChildren = root.GetComponentsInChildren<MonoBehaviour>(true);
				foreach (MonoBehaviour val in componentsInChildren)
				{
					if (!Object.op_Implicit((Object)(object)val))
					{
						continue;
					}
					Type type = ((object)val).GetType();
					bool flag2 = false;
					Type[] keepTypes = _keepTypes;
					for (int j = 0; j < keepTypes.Length; j++)
					{
						if (keepTypes[j].IsAssignableFrom(type))
						{
							flag2 = true;
							break;
						}
					}
					if (!flag2)
					{
						try
						{
							Object.DestroyImmediate((Object)(object)val);
							list.Add(type.Name);
							flag = true;
						}
						catch
						{
						}
					}
				}
			}
			if (list.Count > 0)
			{
				DebugLog.Trace(_log, "CraftUI: stripped from button clone: " + string.Join(", ", list));
			}
		}

		internal ButtonParts CreateFlatButton(string name, RectTransform parent, string text)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			GameObject val = CreateUIObject(name, typeof(RectTransform));
			val.SetActive(false);
			val.transform.SetParent((Transform)(object)parent, false);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = Color32.op_Implicit(new Color32((byte)40, (byte)40, (byte)40, byte.MaxValue));
			HGButton val3 = val.AddComponent<HGButton>();
			((Selectable)val3).targetGraphic = (Graphic)(object)val2;
			((MPButton)val3).requiredTopLayer = _vanillaTopLayer;
			val.AddComponent<DeselectOnPointerExit>();
			TextMeshProUGUI component = ((Component)CreateInternal("Text", val.transform, typeof(TextMeshProUGUI))).GetComponent<TextMeshProUGUI>();
			((TMP_Text)component).text = text;
			((TMP_Text)component).alignment = (TextAlignmentOptions)514;
			((Graphic)component).color = Color.white;
			((Graphic)component).raycastTarget = false;
			AddBorder((RectTransform)val.transform, new Color32((byte)209, (byte)209, (byte)210, (byte)200), 1f, 1f, 1f, 1f);
			val.SetActive(true);
			return new ButtonParts
			{
				Button = val3,
				Label = component,
				Image = val2,
				IsCanon = false
			};
		}

		internal ButtonParts CreateSlotButton(string name, RectTransform slot, string text)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			ButtonParts result = CreateCanonButton(name, slot, text);
			RectTransform val = (RectTransform)((Component)result.Button).transform;
			val.anchorMin = Vector2.zero;
			val.anchorMax = Vector2.one;
			val.pivot = new Vector2(0.5f, 0.5f);
			val.offsetMin = Vector2.zero;
			val.offsetMax = Vector2.zero;
			return result;
		}

		internal static Sprite GetHatchSprite()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_hatchSprite))
			{
				_hatchSprite = Addressables.LoadAssetAsync<Sprite>(((AssetReference)HatchingTileRef).RuntimeKey).WaitForCompletion();
			}
			return _hatchSprite;
		}

		internal static string GetEntryDisplayName(CraftPlanner.CraftableEntry entry)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (entry == null)
			{
				return "Unknown Result";
			}
			if (entry.IsItem)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef(entry.ResultItem);
				if (!((Object)(object)itemDef != (Object)null))
				{
					return $"bad Item {entry.ResultIndex}";
				}
				return Language.GetString(itemDef.nameToken);
			}
			EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(entry.ResultEquipment);
			if (!((Object)(object)equipmentDef != (Object)null))
			{
				return $"bad Equipment {entry.ResultIndex}";
			}
			return Language.GetString(equipmentDef.nameToken);
		}

		internal static bool TryGetIcon(int unifiedIndex, out AssetReferenceT<Sprite> reference, out Sprite direct)
		{
			if (unifiedIndex < ItemCatalog.itemCount)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef((ItemIndex)unifiedIndex);
				if ((Object)(object)itemDef != (Object)null)
				{
					return PickIconSource(itemDef.pickupIconSpriteReference, itemDef.pickupIconSprite, out reference, out direct);
				}
			}
			else
			{
				EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef((EquipmentIndex)(unifiedIndex - ItemCatalog.itemCount));
				if ((Object)(object)equipmentDef != (Object)null)
				{
					return PickIconSource(equipmentDef.pickupIconSpriteReference, equipmentDef.pickupIconSprite, out reference, out direct);
				}
			}
			reference = null;
			direct = null;
			return false;
		}

		internal static bool TryGetDroneIcon(DroneIndex droneIndex, out AssetReferenceT<Sprite> reference, out Sprite direct)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			DroneDef droneDef = DroneCatalog.GetDroneDef(droneIndex);
			if ((Object)(object)droneDef != (Object)null)
			{
				return PickIconSource(droneDef.iconSpriteReference, droneDef.iconSprite, out reference, out direct);
			}
			reference = null;
			direct = null;
			return false;
		}

		private static bool PickIconSource(AssetReferenceT<Sprite> address, Sprite sprite, out AssetReferenceT<Sprite> reference, out Sprite direct)
		{
			direct = sprite;
			reference = (((Object)(object)direct == (Object)null && address != null && ((AssetReference)address).RuntimeKeyIsValid()) ? address : null);
			if (!((Object)(object)direct != (Object)null))
			{
				return reference != null;
			}
			return true;
		}

		internal static void SetSlotTooltip(SlotView slot, int unifiedIdx)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_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_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)
			TooltipProvider val = (Object.op_Implicit((Object)(object)slot) ? ((Component)slot).GetComponent<TooltipProvider>() : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			val.titleColor = Color.clear;
			if (unifiedIdx < 0)
			{
				return;
			}
			if (unifiedIdx < ItemCatalog.itemCount)
			{
				ItemDef itemDef = ItemCatalog.GetItemDef((ItemIndex)unifiedIdx);
				if (Object.op_Implicit((Object)(object)itemDef))
				{
					val.titleToken = itemDef.nameToken;
					val.bodyToken = itemDef.pickupToken;
					val.titleColor = Color32.op_Implicit(ColorCatalog.GetColor(itemDef.darkColorIndex));
					val.bodyColor = new Color(0.6f, 0.6f, 0.6f, 1f);
				}
			}
			else
			{
				EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef((EquipmentIndex)(unifiedIdx - ItemCatalog.itemCount));
				if (Object.op_Implicit((Object)(object)equipmentDef))
				{
					val.titleToken = equipmentDef.nameToken;
					val.bodyToken = equipmentDef.pickupToken;
					val.titleColor = Color32.op_Implicit(ColorCatalog.GetColor(equipmentDef.colorIndex));
					val.bodyColor = Color.gray;
				}
			}
		}

		internal static void SetDroneTooltip(SlotView slot, DroneIndex droneIdx)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			TooltipProvider val = (Object.op_Implicit((Object)(object)slot) ? ((Component)slot).GetComponent<TooltipProvider>() : null);
			DroneDef droneDef = DroneCatalog.GetDroneDef(droneIdx);
			if (Object.op_Implicit((Object)(object)val))
			{
				val.titleColor = (Object.op_Implicit((Object)(object)droneDef) ? Color32.op_Implicit(ColorCatalog.GetColor(droneDef.color)) : Color.clear);
				val.titleToken = (Object.op_Implicit((Object)(object)droneDef) ? droneDef.nameToken : null);
				val.bodyToken = (Object.op_Implicit((Object)(object)droneDef) ? droneDef.pickupToken : null);
				val.bodyColor = Color.gray;
			}
		}

		internal static Color GetEntryColor(CraftPlanner.CraftableEntry entry)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			PickupIndex val = PickupIndex.none;
			val = ((!entry.IsItem) ? PickupCatalog.FindPickupIndex(entry.ResultEquipment) : PickupCatalog.FindPickupIndex(entry.ResultItem));
			if (!((PickupIndex)(ref val)).isValid)
			{
				return Color.white;
			}
			return PickupCatalog.GetPickupDef(val)?.baseColor ?? Color.white;
		}

		internal static bool AreEntriesSame(CraftPlanner.CraftableEntry a, CraftPlanner.CraftableEntry b)
		{
			if (a == null || b == null)
			{
				return false;
			}
			if (a.ResultIndex == b.ResultIndex)
			{
				return a.ResultCount == b.ResultCount;
			}
			return false;
		}

		internal static bool AreChainsSame(CraftPlanner.RecipeChain a, CraftPlanner.RecipeChain b)
		{
			if (a == null || b == null)
			{
				return false;
			}
			if (a == b)
			{
				return true;
			}
			if (a.Depth != b.Depth || a.ResultCount != b.ResultCount)
			{
				return false;
			}
			IReadOnlyList<ChefRecipe> steps = a.Steps;
			IReadOnlyList<ChefRecipe> steps2 = b.Steps;
			for (int i = 0; i < steps.Count; i++)
			{
				if (steps[i] != steps2[i])
				{
					return false;
				}
			}
			if (AreCostsSame(a.PhysicalCostSparse, b.PhysicalCostSparse) && AreCostsSame(a.DroneCostSparse, b.DroneCostSparse))
			{
				return AreCostsSame(a.AlliedTradeSparse, b.AlliedTradeSparse);
			}
			return false;
		}

		private static bool AreCostsSame<T>(T[] a, T[] b)
		{
			int num = ((a != null) ? a.Length : 0);
			if (num != ((b != null) ? b.Length : 0))
			{
				return false;
			}
			for (int i = 0; i < num; i++)
			{
				if (!EqualityComparer<T>.Default.Equals(a[i], b[i]))
				{
					return false;
				}
			}
			return true;
		}

		internal void OnRepeatInputEndEdit(string val)
		{
			int result;
			InventorySnapshot snap;
			if (_selectedChainData == null)
			{
				_repeatInputField.text = string.Empty;
			}
			else if (int.TryParse(val, out result) && TryGetSnapshot(out snap))
			{
				int maxAffordable = _selectedChainData.GetMaxAffordable(snap);
				if (result > maxAffordable)
				{
					_repeatInputField.text = maxAffordable + " (max)";
				}
				else if (result < 1)
				{
					_repeatInputField.text = "1";
				}
			}
		}

		internal int ParseRepeatCount()
		{
			string text = (Object.op_Implicit((Object)(object)_repeatInputField) ? _repeatInputField.text : null);
			if (string.IsNullOrEmpty(text))
			{
				return 1;
			}
			int num = 0;
			int num2 = 0;
			while (num2 < text.Length && char.IsDigit(text[num2]) && num < 100000)
			{
				num = num * 10 + (text[num2++] - 48);
			}
			if (num2 != 0)
			{
				return num;
			}
			return 1;
		}

		internal void StepRepeatCount(int delta)
		{
			if (_selectedChainData != null && Object.op_Implicit((Object)(object)_repeatInputField) && TryGetSnapshot(out var snap))
			{
				int maxAffordable = _selectedChainData.GetMaxAffordable(snap);
				if (maxAffordable > 0)
				{
					int num = Mathf.Clamp(ParseRepeatCount() + delta, 1, maxAffordable);
					_repeatInputField.text = ((num >= maxAffordable) ? $"{maxAffordable} (max)" : num.ToString());
				}
			}
		}

		internal void OnPathSelected(PathRowRuntime clickedPath)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if (clickedPath.Chain == null)
			{
				return;
			}
			_currentHoveredPath = clickedPath;
			if ((Object)(object)_selectedPathUI == (Object)(object)clickedPath)
			{
				DeselectCurrentPath();
				return;
			}
			if ((Object)(object)_selectedPathUI != (Object)null)
			{
				_selectedPathUI.SetSelected(selected: false);
			}
			_selectedPathUI = clickedPath;
			_selectedPathUI.SetSelected(selected: true);
			_selectedChainData = clickedPath.Chain;
			_selectedAnchor = clickedPath.View.VisualRect;
			AttachReticleTo(_selectedAnchor);
			if (Object.op_Implicit((Object)(object)_globalCraftButton))
			{
				((Selectable)_globalCraftButton).interactable = true;
				if (!_globalCraftButtonIsCanon)
				{
					((Graphic)_globalCraftButtonImage).color = Color32.op_Implicit(new Color32((byte)206, (byte)198, (byte)143, byte.MaxValue));
					((Graphic)_globalCraftButtonText).color = Color32.op_Implicit(new Color32((byte)26, (byte)22, (byte)22, byte.MaxValue));
				}
				((TMP_Text)_globalCraftButtonText).text = "Combine";
			}
			RebuildNavigation();
			if (TryGetSnapshot(out var _))
			{
				int maxAffordable = clickedPath.Chain.GetMaxAffordable(_snap);
				_repeatInputField.text = "1";
				Graphic placeholder = _repeatInputField.placeholder;
				TextMeshProUGUI val = (TextMeshProUGUI)(object)((placeholder is TextMeshProUGUI) ? placeholder : null);
				if (val != null)
				{
					((TMP_Text)val).text = $"max {maxAffordable}";
				}
			}
		}

		internal void OnGlobalCraftButtonClicked()
		{
			if (StateController.IsAutoCrafting || _selectedChainData == null)
			{
				return;
			}
			int num = ParseRepeatCount();
			if (TryGetSnapshot(out var _))
			{
				int maxAffordable = _selectedChainData.GetMaxAffordable(_snap);
				if (maxAffordable > 0)
				{
					int count = Mathf.Clamp(num, 1, maxAffordable);
					StateController.RequestCraft(_selectedChainData, count);
				}
			}
		}

		internal void CraftablesForUIChanged(IReadOnlyList<CraftPlanner.CraftableEntry> craftables, InventorySnapshot snap)
		{
			_snap = snap;
			LastCraftables = craftables;
			if (_skeletonBuilt)
			{
				PopulateRecipeList(LastCraftables);
			}
		}

		internal void ToggleRecipeRow(RecipeRowRuntime runtime)
		{
			if ((Object)(object)runtime == (Object)null)
			{
				return;
			}
			if ((Object)(object)_openRow == (Object)(object)runtime)
			{
				CollapseRow(runtime);
				_openRow = null;
				RebuildNavigation();
				return;
			}
			if ((Object)(object)_openRow != (Object)null)
			{
				CollapseRow(_openRow);
			}
			ExpandRow(runtime);
			_openRow = runtime;
			RebuildNavigation();
		}

		internal void ExpandRow(RecipeRowRuntime runtime)
		{
			if (runtime.Entry == null || runtime.Entry.Chains == null)
			{
				return;
			}
			RecipeRowView view = runtime.View;
			int num = runtime.Entry.Chains.Count;
			if (num == 0 && runtime.Entry.ProgressRecipe != null)
			{
				num = 1;
			}
			if (num != 0)
			{
				float num2 = RoundToEven(0.079872206f * _panelHeight);
				float num3 = RoundToEven(0.007987221f * _panelHeight);
				int num4 = Mathf.Min(num, 4);
				float num5 = (float)num4 * num2 + (float)num4 * num3 + num3;
				if ((Object)(object)view.DropdownLayoutElement != (Object)null)
				{
					view.DropdownLayoutElement.preferredHeight = num5;
				}
				else
				{
					DebugLog.Trace(_log, "DropDownLayoutElement was null, cant expand row.");
				}
				if ((Object)(object)view.RowLayoutElement != (Object)null)
				{
					view.RowLayoutElement.preferredHeight = runtime.CollapsedHeight + num5;
				}
				else
				{
					DebugLog.Trace(_log, "RowLayoutElement was null, cant expand row.");
				}
				if ((Object)(object)_sharedDropdown != (Object)null)
				{
					_sharedDropdown.OpenFor(runtime);
				}
			}
			runtime.IsExpanded = true;
			LayoutRebuilder.ForceRebuildLayoutImmediate(view.RowTransform);
			PixelSnap(view.RowTransform);
			PixelSnap(view.RowTop);
			SetArrowExpanded(view, expanded: true);
		}

		internal void CollapseRow(RecipeRowRuntime runtime)
		{
			RecipeRowView view = runtime.View;
			if ((Object)(object)_sharedDropdown != (Object)null && (Object)(object)_sharedDropdown.CurrentOwner == (Object)(object)runtime)
			{
				if (_activeDropdownRoutine != null)
				{
					((MonoBehaviour)_runner).StopCoroutine(_activeDropdownRoutine);
					_activeDropdownRoutine = null;
				}
				if ((Object)(object)_selectionReticle != (Object)null && ((Transform)_selectionReticle).IsChildOf(((Component)_sharedDropdown).transform))
				{
					((Transform)_selectionReticle).SetParent(_cookbookRoot.transform, false);
					((Component)_selectionReticle).gameObject.SetActive(false);
				}
				((Component)_sharedDropdown).gameObject.SetActive(false);
			}
			if ((Object)(object)_selectedPathUI != (Object)null && (Object)(object)_selectedPathUI.OwnerRow == (Object)(object)runtime)
			{
				DeselectCurrentPath();
			}
			if ((Object)(object)view.DropdownLayoutElement != (Object)null)
			{
				view.DropdownLayoutElement.preferredHeight = 0f;
			}
			else
			{
				DebugLog.Trace(_log, "DropDownLayoutElement was null, cant retract row.");
			}
			if ((Object)(object)view.RowLayoutElement != (Object)null)
			{
				view.RowLayoutElement.preferredHeight = runtime.CollapsedHeight;
			}
			else
			{
				DebugLog.Trace(_log, "RowLayoutElement was null, cant retract row.");
			}
			runtime.IsExpanded = false;
			LayoutRebuilder.ForceRebuildLayoutImmediate(view.RowTransform);
			PixelSnap(view.RowTransform);
			PixelSnap(view.RowTop);
			SetArrowExpanded(view, expanded: false);
		}

		internal static void SetArrowExpanded(RecipeRowView view, bool expanded)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)view.ArrowText == (Object)null))
			{
				((Transform)((TMP_Text)view.ArrowText).rectTransform).localRotation = (expanded ? Quaternion.Euler(0f, 0f, -90f) : Quaternion.identity);
			}
		}

		internal void DeselectCurrentPath()
		{
			//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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_selectedPathUI != (Object)null)
			{
				_sele

CookBook.UI.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CookBook.UI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1f8f89c89dda86f02a3771011e911aa3898bcb02")]
[assembly: AssemblyProduct("CookBook.UI")]
[assembly: AssemblyTitle("CookBook.UI")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CookBook;

public sealed class ColorFaderRuntime : MonoBehaviour
{
	private Graphic _targetGraphic;

	private Coroutine _activeRoutine;

	private void Awake()
	{
		_targetGraphic = ((Component)this).GetComponent<Graphic>();
	}

	public void CrossFadeColor(Color targetColor, float duration, bool ignoreTimeScale = true)
	{
		//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_0052: 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)
		if ((Object)(object)_targetGraphic == (Object)null)
		{
			return;
		}
		if (_activeRoutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(_activeRoutine);
		}
		if (!(_targetGraphic.color == targetColor))
		{
			if (duration <= 0f || !((Component)this).gameObject.activeInHierarchy)
			{
				_targetGraphic.color = targetColor;
			}
			else
			{
				_activeRoutine = ((MonoBehaviour)this).StartCoroutine(FadeRoutine(targetColor, duration, ignoreTimeScale));
			}
		}
	}

	private IEnumerator FadeRoutine(Color target, float duration, bool ignoreTimeScale)
	{
		//IL_000e: 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)
		Color start = _targetGraphic.color;
		float timer = 0f;
		while (timer < duration)
		{
			timer += (ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime);
			float num = Mathf.Clamp01(timer / duration);
			_targetGraphic.color = Color.Lerp(start, target, num);
			yield return null;
		}
		_targetGraphic.color = target;
		_activeRoutine = null;
	}

	private void OnDisable()
	{
		if (_activeRoutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(_activeRoutine);
		}
		_activeRoutine = null;
	}
}
public sealed class CookBookButton : HGButton
{
	public Action<bool> HighlightChanged;

	private bool _lit;

	protected override void DoStateTransition(SelectionState state, bool instant)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Invalid comparison between Unknown and I4
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Invalid comparison between Unknown and I4
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Invalid comparison between Unknown and I4
		((HGButton)this).DoStateTransition(state, instant);
		bool flag = (int)state == 1 || (int)state == 3 || (int)state == 2;
		if (flag != _lit)
		{
			_lit = flag;
			HighlightChanged?.Invoke(flag);
		}
	}
}
[RequireComponent(typeof(MPEventSystemLocator))]
public sealed class DeselectOnPointerExit : MonoBehaviour, IPointerExitHandler, IEventSystemHandler
{
	private MPEventSystemLocator _loc;

	private void Awake()
	{
		_loc = ((Component)this).GetComponent<MPEventSystemLocator>();
	}

	public void OnPointerExit(PointerEventData eventData)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		MPEventSystem val = (Object.op_Implicit((Object)(object)_loc) ? _loc.eventSystem : null);
		if (Object.op_Implicit((Object)(object)val) && (int)val.currentInputSource == 0 && (Object)(object)((EventSystem)val).currentSelectedGameObject == (Object)(object)((Component)this).gameObject)
		{
			((EventSystem)val).SetSelectedGameObject((GameObject)null);
		}
	}
}
public sealed class DropdownView : MonoBehaviour
{
	public NestedScrollRect ScrollRect;

	public RectTransform Content;
}
public class NestedScrollRect : ScrollRect
{
	[OptionalRef]
	public ScrollRect ParentScroll;

	public override void OnScroll(PointerEventData data)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		if (!((UIBehaviour)this).IsActive())
		{
			return;
		}
		Rect rect = ((ScrollRect)this).content.rect;
		float height = ((Rect)(ref rect)).height;
		rect = ((ScrollRect)this).viewport.rect;
		if (!(height > ((Rect)(ref rect)).height))
		{
			if (Object.op_Implicit((Object)(object)ParentScroll))
			{
				ParentScroll.OnScroll(data);
			}
			return;
		}
		float y = data.scrollDelta.y;
		float verticalNormalizedPosition = ((ScrollRect)this).verticalNormalizedPosition;
		if (Object.op_Implicit((Object)(object)ParentScroll) && ((y > 0f && verticalNormalizedPosition >= 0.999f) || (y < 0f && verticalNormalizedPosition <= 0.001f)))
		{
			ParentScroll.OnScroll(data);
		}
		else
		{
			((ScrollRect)this).OnScroll(data);
		}
	}
}
[AttributeUsage(AttributeTargets.Field)]
public sealed class OptionalRefAttribute : Attribute
{
}
public sealed class PanelView : MonoBehaviour
{
	public TMP_InputField SearchInput;

	public RectTransform CategorySlot;

	public RectTransform ListContent;

	public RectTransform CraftSlot;

	public RectTransform MinusSlot;

	public TMP_InputField RepeatInput;

	public RectTransform PlusSlot;
}
public sealed class PathRowView : MonoBehaviour
{
	public CookBookButton PathButton;

	public RectTransform VisualRect;

	public Image BackgroundImage;

	public ColorFaderRuntime Fader;
}
public sealed class PixelBorder : MonoBehaviour
{
	public float Top;

	public float Bottom;

	public float Left;

	public float Right;

	[OptionalRef]
	public RectTransform TopBar;

	[OptionalRef]
	public RectTransform BottomBar;

	[OptionalRef]
	public RectTransform LeftBar;

	[OptionalRef]
	public RectTransform RightBar;

	private void OnEnable()
	{
		Refit();
	}

	private void OnTransformParentChanged()
	{
		Refit();
	}

	public void Refit()
	{
		float num = UnitsPerPixel();
		SetHeight(TopBar, Mathf.Round(Top) * num);
		SetHeight(BottomBar, Mathf.Round(Bottom) * num);
		SetWidth(LeftBar, Mathf.Round(Left) * num);
		SetWidth(RightBar, Mathf.Round(Right) * num);
	}

	private float UnitsPerPixel()
	{
		//IL_0028: 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)
		Canvas componentInParent = ((Component)this).GetComponentInParent<Canvas>();
		if (!Object.op_Implicit((Object)(object)componentInParent))
		{
			return 1f;
		}
		Canvas rootCanvas = componentInParent.rootCanvas;
		float num = rootCanvas.scaleFactor * (((Component)this).transform.lossyScale.y / ((Component)rootCanvas).transform.lossyScale.y);
		if (!(num > 0f))
		{
			return 1f;
		}
		return 1f / num;
	}

	private static void SetHeight(RectTransform bar, float height)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)bar))
		{
			bar.sizeDelta = new Vector2(0f, height);
		}
	}

	private static void SetWidth(RectTransform bar, float width)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)bar))
		{
			bar.sizeDelta = new Vector2(width, 0f);
		}
	}
}
public sealed class RecipeRowView : MonoBehaviour
{
	public RectTransform RowTransform;

	public LayoutElement RowLayoutElement;

	public RectTransform RowTop;

	public CookBookButton RowTopButton;

	public TextMeshProUGUI ArrowText;

	public RectTransform DropdownMountPoint;

	public LayoutElement DropdownLayoutElement;

	public SlotView ResultSlot;

	public TextMeshProUGUI ItemLabel;

	public TextMeshProUGUI DepthText;

	public TextMeshProUGUI PathsText;
}
[RequireComponent(typeof(RectMask2D))]
public sealed class ReticleClip : MonoBehaviour
{
	public RectTransform Frame;

	private readonly List<RectMask2D> _masks = new List<RectMask2D>();

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

	public void SetTarget(RectTransform target)
	{
		((Component)target).GetComponentsInParent<RectMask2D>(false, _masks);
	}

	private void LateUpdate()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Expected O, but got Unknown
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: 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_0047: 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_0056: 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_0077: 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_0083: 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_008b: 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_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_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		RectTransform val = (RectTransform)((Component)this).transform.parent;
		RectTransform val2 = (RectTransform)((Component)this).transform;
		Rect rect = val.rect;
		Rect a = rect;
		foreach (RectMask2D mask in _masks)
		{
			if (Object.op_Implicit((Object)(object)mask))
			{
				a = Intersect(a, LocalRect(val, mask.rectTransform));
			}
		}
		Vector2 val3 = ((Rect)(ref a)).min - ((Rect)(ref rect)).min;
		if (val2.anchoredPosition != val3 || val2.sizeDelta != ((Rect)(ref a)).size)
		{
			val2.anchoredPosition = val3;
			val2.sizeDelta = ((Rect)(ref a)).size;
		}
		Vector2 val4 = ((Rect)(ref rect)).min - ((Rect)(ref a)).min;
		if (Object.op_Implicit((Object)(object)Frame) && (Frame.anchoredPosition != val4 || Frame.sizeDelta != ((Rect)(ref rect)).size))
		{
			Frame.anchoredPosition = val4;
			Frame.sizeDelta = ((Rect)(ref rect)).size;
		}
	}

	private Rect LocalRect(RectTransform space, RectTransform other)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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)
		other.GetWorldCorners(_corners);
		Vector2 val = Vector2.op_Implicit(((Transform)space).InverseTransformPoint(_corners[0]));
		Vector2 val2 = Vector2.op_Implicit(((Transform)space).InverseTransformPoint(_corners[2]));
		return Rect.MinMaxRect(val.x, val.y, val2.x, val2.y);
	}

	private static Rect Intersect(Rect a, Rect b)
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Max(((Rect)(ref a)).xMin, ((Rect)(ref b)).xMin);
		float num2 = Mathf.Max(((Rect)(ref a)).yMin, ((Rect)(ref b)).yMin);
		float num3 = Mathf.Max(num, Mathf.Min(((Rect)(ref a)).xMax, ((Rect)(ref b)).xMax));
		float num4 = Mathf.Max(num2, Mathf.Min(((Rect)(ref a)).yMax, ((Rect)(ref b)).yMax));
		return Rect.MinMaxRect(num, num2, num3, num4);
	}
}
public sealed class ReticleView : MonoBehaviour
{
	public ReticleClip Clip;
}
[RequireComponent(typeof(MPEventSystemLocator))]
public sealed class ScrollFollowSelection : MonoBehaviour
{
	public ScrollRect Scroll;

	private MPEventSystemLocator _loc;

	private GameObject _last;

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

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

	private void Awake()
	{
		_loc = ((Component)this).GetComponent<MPEventSystemLocator>();
	}

	private void LateUpdate()
	{
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Invalid comparison between Unknown and I4
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: 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)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: 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)
		MPEventSystem val = (Object.op_Implicit((Object)(object)_loc) ? _loc.eventSystem : null);
		GameObject val2 = (Object.op_Implicit((Object)(object)val) ? ((EventSystem)val).currentSelectedGameObject : null);
		if ((Object)(object)val2 == (Object)(object)_last)
		{
			return;
		}
		_last = val2;
		if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)Scroll) && Object.op_Implicit((Object)(object)Scroll.content) && val2.transform.IsChildOf((Transform)(object)Scroll.content) && (int)val.currentInputSource == 1)
		{
			object obj = (Object.op_Implicit((Object)(object)Scroll.viewport) ? ((object)Scroll.viewport) : ((object)(RectTransform)((Component)Scroll).transform));
			((RectTransform)val2.transform).GetWorldCorners(_tc);
			((RectTransform)obj).GetWorldCorners(_vc);
			float num = _tc[1].y - _vc[1].y;
			float num2 = _tc[0].y - _vc[0].y;
			float num3 = ((num > 0f) ? num : ((num2 < 0f) ? num2 : 0f));
			if (num3 != 0f)
			{
				Vector3 val3 = ((Transform)Scroll.content).parent.InverseTransformVector(new Vector3(0f, num3, 0f));
				Scroll.StopMovement();
				Vector2 anchoredPosition = Scroll.content.anchoredPosition;
				anchoredPosition.y -= val3.y;
				Scroll.content.anchoredPosition = anchoredPosition;
			}
		}
	}
}
public sealed class SlotView : MonoBehaviour
{
	public Image Icon;

	public AsyncImage IconLoader;

	public TextMeshProUGUI StackText;
}
public static class UIBundleInfo
{
	public const string FileName = "cookbookui";

	public const string PrefabFolder = "Assets/UI";

	public const float PanelWidth = 554f;

	public const float PanelHeight = 624f;

	public static readonly (string Name, Type View)[] Prefabs = new(string, Type)[9]
	{
		("ResultSlot", typeof(SlotView)),
		("PhysicalSlot", typeof(SlotView)),
		("DroneSlot", typeof(SlotView)),
		("TradeSlot", typeof(SlotView)),
		("PathRow", typeof(PathRowView)),
		("Dropdown", typeof(DropdownView)),
		("RecipeRow", typeof(RecipeRowView)),
		("Reticle", typeof(ReticleView)),
		("Panel", typeof(PanelView))
	};
}
public static class ViewValidator
{
	public static List<string> Validate(GameObject root, Type rootView)
	{
		List<string> list = new List<string>();
		if (!Object.op_Implicit((Object)(object)root))
		{
			list.Add("prefab is null");
			return list;
		}
		if (rootView != null && !Object.op_Implicit((Object)(object)root.GetComponent(rootView)))
		{
			list.Add(((Object)root).name + ": no " + rootView.Name + " on root");
		}
		int num = LayerMask.NameToLayer("UI");
		Transform[] componentsInChildren = root.GetComponentsInChildren<Transform>(true);
		foreach (Transform obj in componentsInChildren)
		{
			string text = PathOf(obj, root.transform);
			if (((Component)obj).gameObject.layer != num)
			{
				list.Add(text + ": not on the UI layer");
			}
			Component[] components = ((Component)obj).GetComponents<Component>();
			foreach (Component val in components)
			{
				if ((Object)(object)val == (Object)null)
				{
					list.Add(text + ": missing script");
				}
				else if (!(((object)val).GetType().Assembly != typeof(ViewValidator).Assembly))
				{
					CheckRefs(val, text, list);
				}
			}
		}
		return list;
	}

	private static void CheckRefs(Component comp, string path, List<string> errors)
	{
		FieldInfo[] fields = ((object)comp).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public);
		foreach (FieldInfo fieldInfo in fields)
		{
			if (typeof(Object).IsAssignableFrom(fieldInfo.FieldType) && !(fieldInfo.DeclaringType.Assembly != typeof(ViewValidator).Assembly) && !fieldInfo.IsDefined(typeof(OptionalRefAttribute), inherit: false) && !Object.op_Implicit((Object)/*isinst with value type is only supported in some contexts*/))
			{
				errors.Add(path + ": " + ((object)comp).GetType().Name + "." + fieldInfo.Name + " not set");
			}
		}
	}

	private static string PathOf(Transform tr, Transform root)
	{
		string text = ((Object)tr).name;
		while ((Object)(object)tr != (Object)(object)root && (Object)(object)tr.parent != (Object)null)
		{
			tr = tr.parent;
			text = ((Object)tr).name + "/" + text;
		}
		return text;
	}
}