Decompiled source of CookBook v1.2.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.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using Microsoft.CodeAnalysis;
using On.RoR2;
using RoR2;
using RoR2.ContentManagement;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
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+37f21e6bb05f012f9ea4a79de0c2db06ce23beaa")]
[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]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CookBook
{
	internal static class CraftingExecutionHandler
	{
		[CompilerGenerated]
		private sealed class <CraftChainRoutine>d__8 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public CraftPlanner.RecipeChain chain;

			private CharacterBody <body>5__2;

			private Queue<ChefRecipe> <craftQueue>5__3;

			private PickupIndex <lastPickup>5__4;

			private int <lastQty>5__5;

			private Ingredient[] <>7__wrap5;

			private int <>7__wrap6;

			private Interactor <interactor>5__8;

			private float <initTimeout>5__9;

			private ChefRecipe <step>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <CraftChainRoutine>d__8(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<body>5__2 = null;
				<craftQueue>5__3 = null;
				<>7__wrap5 = null;
				<interactor>5__8 = null;
				<step>5__10 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0551: Unknown result type (might be due to invalid IL or missing references)
				//IL_055b: Expected O, but got Unknown
				//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0409: Expected O, but got Unknown
				//IL_0447: Unknown result type (might be due to invalid IL or missing references)
				//IL_0451: Expected O, but got Unknown
				//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_05cb: Expected O, but got Unknown
				//IL_0140: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				//IL_0279: Unknown result type (might be due to invalid IL or missing references)
				//IL_027e: Unknown result type (might be due to invalid IL or missing references)
				//IL_037d: Unknown result type (might be due to invalid IL or missing references)
				//IL_038c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0391: Unknown result type (might be due to invalid IL or missing references)
				//IL_0396: Unknown result type (might be due to invalid IL or missing references)
				//IL_049e: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a8: Expected O, but got Unknown
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b6: Expected O, but got Unknown
				//IL_0186: Unknown result type (might be due to invalid IL or missing references)
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_018d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Invalid comparison between Unknown and I4
				//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0209: Unknown result type (might be due to invalid IL or missing references)
				//IL_0192: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_030f: Unknown result type (might be due to invalid IL or missing references)
				string stepName;
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					ManualLogSource log = _log;
					Ingredient[] droneCostSparse = chain.DroneCostSparse;
					log.LogInfo((object)$"[Execution] Starting Chain. Scrap Requirements: {((droneCostSparse != null) ? droneCostSparse.Length : 0)}. Recipe Steps: {chain.Steps.Count}");
					LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
					<body>5__2 = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
					if (!Object.op_Implicit((Object)(object)<body>5__2))
					{
						Abort();
						return false;
					}
					if (chain.DroneCostSparse != null && chain.DroneCostSparse.Length != 0)
					{
						_log.LogInfo((object)$"[Chain] Requirements: {chain.DroneCostSparse.Length} scrap types needed.");
						<>7__wrap5 = chain.DroneCostSparse;
						<>7__wrap6 = 0;
						goto IL_0234;
					}
					goto IL_025d;
				}
				case 1:
					<>1__state = -1;
					goto IL_0226;
				case 2:
					<>1__state = -1;
					goto IL_0334;
				case 3:
					<>1__state = -1;
					goto IL_0461;
				case 4:
					<>1__state = -1;
					<>7__wrap6++;
					goto IL_042b;
				case 5:
					<>1__state = -1;
					goto IL_0461;
				case 6:
					<>1__state = -1;
					goto IL_04b8;
				case 7:
					<>1__state = -1;
					goto IL_056b;
				case 8:
					{
						<>1__state = -1;
						goto IL_05db;
					}
					IL_05db:
					<interactor>5__8 = null;
					<step>5__10 = null;
					goto IL_05e9;
					IL_0334:
					CraftingObjectiveTracker.SetObjective("Approach Wandering CHEF", canAbort: true);
					goto IL_0461;
					IL_04b8:
					if (Object.op_Implicit((Object)(object)StateController.ActiveCraftingController) && (((PickupPickerController)StateController.ActiveCraftingController).options == null || ((PickupPickerController)StateController.ActiveCraftingController).options.Length == 0))
					{
						<initTimeout>5__9 -= Time.fixedDeltaTime;
						if (!(<initTimeout>5__9 <= 0f))
						{
							<>2__current = (object)new WaitForFixedUpdate();
							<>1__state = 6;
							return true;
						}
					}
					<step>5__10 = <craftQueue>5__3.Dequeue();
					stepName = GetStepName(<step>5__10);
					CraftingObjectiveTracker.SetObjective("Processing " + stepName + "...", canAbort: true);
					StateController.ActiveCraftingController.ClearAllSlots();
					if (!SubmitIngredients(StateController.ActiveCraftingController, <step>5__10))
					{
						_log.LogWarning((object)("Missing ingredients for " + stepName + ". Aborting."));
						Abort();
						return false;
					}
					goto IL_056b;
					IL_0461:
					if ((Object)(object)StateController.ActiveCraftingController == (Object)null)
					{
						if (!Object.op_Implicit((Object)(object)StateController.TargetCraftingObject) || !Object.op_Implicit((Object)(object)<body>5__2))
						{
							Abort();
							return false;
						}
						float num = <interactor>5__8.maxInteractionDistance + 6f;
						Vector3 val = <body>5__2.corePosition - StateController.TargetCraftingObject.transform.position;
						if (((Vector3)(ref val)).sqrMagnitude > num * num)
						{
							<>2__current = (object)new WaitForSeconds(0.2f);
							<>1__state = 3;
							return true;
						}
						if (Object.op_Implicit((Object)(object)<interactor>5__8))
						{
							<interactor>5__8.AttemptInteraction(StateController.TargetCraftingObject);
						}
						<>7__wrap6 = 0;
						goto IL_042b;
					}
					<initTimeout>5__9 = 1f;
					goto IL_04b8;
					IL_0226:
					<>7__wrap6++;
					goto IL_0234;
					IL_05e9:
					if (<craftQueue>5__3.Count > 0)
					{
						LocalUser firstLocalUser2 = LocalUserManager.GetFirstLocalUser();
						<body>5__2 = ((firstLocalUser2 != null) ? firstLocalUser2.cachedBody : null);
						CharacterBody obj = <body>5__2;
						<interactor>5__8 = ((obj != null) ? ((Component)obj).GetComponent<Interactor>() : null);
						if (<lastPickup>5__4 != PickupIndex.none)
						{
							CraftingObjectiveTracker.SetObjective("Collect " + Language.GetString(PickupCatalog.GetPickupDef(<lastPickup>5__4)?.nameToken ?? "Result"), canAbort: true);
							<>2__current = WaitForPendingPickup(<lastPickup>5__4, <lastQty>5__5);
							<>1__state = 2;
							return true;
						}
						goto IL_0334;
					}
					_log.LogInfo((object)"[ExecutionHandler] Chain Complete.");
					Abort();
					return false;
					IL_025d:
					<craftQueue>5__3 = new Queue<ChefRecipe>(chain.Steps.Reverse());
					<lastPickup>5__4 = PickupIndex.none;
					<lastQty>5__5 = 0;
					goto IL_05e9;
					IL_042b:
					if (<>7__wrap6 < 5 && !((Object)(object)StateController.ActiveCraftingController != (Object)null))
					{
						<>2__current = (object)new WaitForFixedUpdate();
						<>1__state = 4;
						return true;
					}
					if ((Object)(object)StateController.ActiveCraftingController == (Object)null)
					{
						<>2__current = (object)new WaitForSeconds(0.2f);
						<>1__state = 5;
						return true;
					}
					goto IL_0461;
					IL_056b:
					if (!StateController.ActiveCraftingController.AllSlotsFilled())
					{
						<>2__current = (object)new WaitForFixedUpdate();
						<>1__state = 7;
						return true;
					}
					StateController.ActiveCraftingController.ConfirmSelection();
					CraftUI.CloseCraftPanel(StateController.ActiveCraftingController);
					<lastQty>5__5 = <step>5__10.ResultCount;
					<lastPickup>5__4 = GetPickupIndex(<step>5__10);
					if (<craftQueue>5__3.Count > 0)
					{
						<>2__current = (object)new WaitForSeconds(0.2f);
						<>1__state = 8;
						return true;
					}
					goto IL_05db;
					IL_0234:
					if (<>7__wrap6 < <>7__wrap5.Length)
					{
						Ingredient ingredient = <>7__wrap5[<>7__wrap6];
						PickupIndex val2 = ((!ingredient.IsItem) ? PickupCatalog.FindPickupIndex((EquipmentIndex)(ingredient.UnifiedIndex - ItemCatalog.itemCount)) : PickupCatalog.FindPickupIndex((ItemIndex)ingredient.UnifiedIndex));
						PickupDef pickupDef = PickupCatalog.GetPickupDef(val2);
						if (pickupDef != null)
						{
							int ownedCount = GetOwnedCount(pickupDef, <body>5__2);
							if (ownedCount < ingredient.Count)
							{
								int num2 = ingredient.Count - ownedCount;
								string text = "Drone";
								DroneIndex scrapCandidate = InventoryTracker.GetScrapCandidate(ingredient.UnifiedIndex);
								if ((int)scrapCandidate != -1)
								{
									DroneDef droneDef = DroneCatalog.GetDroneDef(scrapCandidate);
									object obj2;
									if (droneDef == null)
									{
										obj2 = null;
									}
									else
									{
										GameObject bodyPrefab = droneDef.bodyPrefab;
										obj2 = ((bodyPrefab != null) ? bodyPrefab.GetComponent<CharacterBody>() : null);
									}
									CharacterBody val3 = (CharacterBody)obj2;
									if (val3 != null)
									{
										text = Language.GetString(val3.baseNameToken);
									}
								}
								string @string = Language.GetString(pickupDef.nameToken);
								CraftingObjectiveTracker.SetObjective("Scrap " + text + " for " + @string, canAbort: true);
								_log.LogInfo((object)$"[Execution] Waiting for {num2}x {@string}...");
								<>2__current = WaitForPendingPickup(val2, num2);
								<>1__state = 1;
								return true;
							}
						}
						goto IL_0226;
					}
					<>7__wrap5 = null;
					_log.LogInfo((object)"[Execution] All scrap requirements met.");
					goto IL_025d;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitForPendingPickup>d__9 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PickupIndex pickupIndex;

			public int expectedGain;

			private CharacterBody <body>5__2;

			private PickupDef <def>5__3;

			private int <targetCount>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitForPendingPickup>d__9(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<body>5__2 = null;
				<def>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Expected O, but got Unknown
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
					LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
					<body>5__2 = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
					if (!Object.op_Implicit((Object)(object)<body>5__2) || !Object.op_Implicit((Object)(object)<body>5__2.inventory))
					{
						return false;
					}
					<def>5__3 = PickupCatalog.GetPickupDef(pickupIndex);
					if (<def>5__3 == null)
					{
						return false;
					}
					<targetCount>5__4 = GetOwnedCount(<def>5__3, <body>5__2) + expectedGain;
				}
				if (GetOwnedCount(<def>5__3, <body>5__2) >= <targetCount>5__4)
				{
					_log.LogInfo((object)("[Chain] Confirmed pickup of " + <def>5__3.internalName + "."));
					return false;
				}
				<>2__current = (object)new WaitForSeconds(0.1f);
				<>1__state = 1;
				return true;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static ManualLogSource _log;

		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)
		{
			Abort();
			_craftingRoutine = _runner.StartCoroutine(CraftChainRoutine(chain));
		}

		public static void Abort()
		{
			if (_craftingRoutine != null)
			{
				_runner.StopCoroutine(_craftingRoutine);
			}
			_craftingRoutine = null;
			CraftingObjectiveTracker.CurrentObjectiveText = string.Empty;
			if (Object.op_Implicit((Object)(object)StateController.ActiveCraftingController))
			{
				CraftUI.CloseCraftPanel(StateController.ActiveCraftingController);
			}
			_log.LogInfo((object)"[ExecutionHandler] Craft aborted.");
		}

		[IteratorStateMachine(typeof(<CraftChainRoutine>d__8))]
		private static IEnumerator CraftChainRoutine(CraftPlanner.RecipeChain chain)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CraftChainRoutine>d__8(0)
			{
				chain = chain
			};
		}

		[IteratorStateMachine(typeof(<WaitForPendingPickup>d__9))]
		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)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForPendingPickup>d__9(0)
			{
				pickupIndex = pickupIndex,
				expectedGain = expectedGain
			};
		}

		private static bool SubmitIngredients(CraftingController controller, ChefRecipe recipe)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0087: 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)
			Option[] options = ((PickupPickerController)controller).options;
			HashSet<PickupIndex> hashSet = new HashSet<PickupIndex>();
			Option[] array = options;
			foreach (Option val in array)
			{
				if (val.available)
				{
					hashSet.Add(val.pickup.pickupIndex);
				}
			}
			Ingredient[] ingredients = recipe.Ingredients;
			for (int i = 0; i < ingredients.Length; i++)
			{
				Ingredient ingredient = ingredients[i];
				PickupIndex val2 = (ingredient.IsItem ? PickupCatalog.FindPickupIndex(ingredient.ItemIndex) : PickupCatalog.FindPickupIndex(ingredient.EquipIndex));
				if (val2 == PickupIndex.none || !hashSet.Contains(val2))
				{
					_log.LogWarning((object)$"[CookBook] Missing ingredient: {val2}");
					return false;
				}
				controller.SendToSlot(val2.value);
			}
			return true;
		}

		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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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)
			{
				return (body.inventory.currentEquipmentIndex == def.equipmentIndex) ? 1 : 0;
			}
			return 0;
		}

		private static string GetStepName(ChefRecipe step)
		{
			if (step.ResultIndex < ItemCatalog.itemCount)
			{
				return Language.GetString(ItemCatalog.GetItemDef((ItemIndex)step.ResultIndex)?.nameToken);
			}
			return Language.GetString(EquipmentCatalog.GetEquipmentDef((EquipmentIndex)(step.ResultIndex - ItemCatalog.itemCount))?.nameToken);
		}

		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));
		}
	}
	internal static class CraftingObjectiveTracker
	{
		private class ChefObjectiveTracker : ObjectiveTracker
		{
			protected override bool IsDirty()
			{
				return base.cachedString != CurrentObjectiveText;
			}

			protected override string GenerateString()
			{
				return CurrentObjectiveText;
			}
		}

		private static string _currentObjectiveText = string.Empty;

		public static string CurrentObjectiveText
		{
			get
			{
				return _currentObjectiveText;
			}
			set
			{
				_currentObjectiveText = value;
			}
		}

		internal static void Init()
		{
			ObjectivePanelController.collectObjectiveSources += OnCollectObjectiveSources;
		}

		internal static void Cleanup()
		{
			ObjectivePanelController.collectObjectiveSources -= OnCollectObjectiveSources;
			_currentObjectiveText = string.Empty;
		}

		private static void OnCollectObjectiveSources(CharacterMaster viewerMaster, List<ObjectiveSourceDescriptor> output)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			if (!((Object)(object)viewerMaster != (Object)(object)((firstLocalUser != null) ? firstLocalUser.cachedMaster : null)) && !string.IsNullOrEmpty(_currentObjectiveText))
			{
				output.Add(new ObjectiveSourceDescriptor
				{
					source = (Object)(object)viewerMaster,
					master = viewerMaster,
					objectiveType = typeof(ChefObjectiveTracker)
				});
			}
		}

		internal static void SetObjective(string message, bool canAbort = false)
		{
			if (string.IsNullOrEmpty(message))
			{
				CurrentObjectiveText = string.Empty;
			}
			else if (canAbort)
			{
				CurrentObjectiveText = message + " <style=cSub>(Hold left alt to Cancel)</style>";
			}
			else
			{
				CurrentObjectiveText = message;
			}
		}
	}
	internal sealed class CraftPlanner
	{
		internal sealed class CraftableEntry
		{
			public int ResultIndex;

			public int ResultCount;

			public int MinDepth;

			public List<RecipeChain> Chains = new List<RecipeChain>();

			public bool IsItem => ResultIndex < ItemCatalog.itemCount;

			public ItemIndex ResultItem
			{
				get
				{
					if (IsItem)
					{
						return (ItemIndex)ResultIndex;
					}
					return (ItemIndex)(-1);
				}
			}

			public EquipmentIndex ResultEquipment
			{
				get
				{
					if (IsItem)
					{
						return (EquipmentIndex)(-1);
					}
					return (EquipmentIndex)(ResultIndex - ItemCatalog.itemCount);
				}
			}
		}

		internal sealed class RecipeChain
		{
			internal IReadOnlyList<ChefRecipe> Steps { get; }

			internal int Depth => Steps.Count;

			internal Ingredient[] PhysicalCostSparse { get; }

			internal Ingredient[] DroneCostSparse { get; }

			internal int ResultIndex => Steps[0].ResultIndex;

			internal int ResultCount => Steps[0].ResultCount;

			internal long CanonicalSignature { get; }

			internal RecipeChain(IEnumerable<ChefRecipe> steps, IEnumerable<Ingredient> phys, IEnumerable<Ingredient> drones)
			{
				Steps = steps.ToArray();
				PhysicalCostSparse = phys.Where((Ingredient i) => i.Count > 0).ToArray();
				DroneCostSparse = drones.Where((Ingredient i) => i.Count > 0).ToArray();
				CanonicalSignature = CalculateCanonicalSignature(Steps);
			}

			internal bool HasProduced(int resultIndex)
			{
				for (int i = 0; i < Steps.Count; i++)
				{
					if (Steps[i].ResultIndex == resultIndex)
					{
						return true;
					}
				}
				return false;
			}

			internal static long CalculateCanonicalSignature(IReadOnlyList<ChefRecipe> chain)
			{
				if (chain == null || chain.Count == 0)
				{
					return 3735928559L;
				}
				List<int> list = chain.Select((ChefRecipe r) => r.GetHashCode()).ToList();
				list.Sort();
				long num = 17L;
				foreach (int item in list)
				{
					num = num * 31 + item;
				}
				return num;
			}

			internal static long CalculateSignatureWithPotentialStep(IReadOnlyList<ChefRecipe> currentSteps, ChefRecipe next)
			{
				List<int> list = currentSteps.Select((ChefRecipe r) => r.GetHashCode()).ToList();
				list.Add(next.GetHashCode());
				list.Sort();
				long num = 17L;
				foreach (int item in list)
				{
					num = num * 31 + item;
				}
				return num;
			}

			internal int GetTotalCostOf(int index)
			{
				int num = 0;
				Ingredient[] physicalCostSparse = PhysicalCostSparse;
				for (int i = 0; i < physicalCostSparse.Length; i++)
				{
					Ingredient ingredient = physicalCostSparse[i];
					if (ingredient.UnifiedIndex == index)
					{
						num += ingredient.Count;
					}
				}
				physicalCostSparse = DroneCostSparse;
				for (int i = 0; i < physicalCostSparse.Length; i++)
				{
					Ingredient ingredient2 = physicalCostSparse[i];
					if (ingredient2.UnifiedIndex == index)
					{
						num += ingredient2.Count;
					}
				}
				return num;
			}
		}

		private readonly IReadOnlyList<ChefRecipe> _recipes;

		private readonly int _itemCount;

		private readonly int _totalDefCount;

		private int _maxDepth;

		private readonly ManualLogSource _log;

		private readonly Dictionary<int, List<ChefRecipe>> _recipesByIngredient = new Dictionary<int, List<ChefRecipe>>();

		private readonly Dictionary<int, int> _physScratch = new Dictionary<int, int>();

		private readonly Dictionary<int, int> _droneScratch = new Dictionary<int, int>();

		public int SourceItemCount { get; }

		internal event Action<List<CraftableEntry>> OnCraftablesUpdated;

		public CraftPlanner(IReadOnlyList<ChefRecipe> recipes, int maxDepth, ManualLogSource log)
		{
			_recipes = recipes ?? throw new ArgumentNullException("recipes");
			_maxDepth = maxDepth;
			_itemCount = ItemCatalog.itemCount;
			_totalDefCount = _itemCount + EquipmentCatalog.equipmentCount;
			_log = log;
			SourceItemCount = ItemCatalog.itemCount;
			BuildRecipeIndex();
		}

		private void BuildRecipeIndex()
		{
			_recipesByIngredient.Clear();
			foreach (ChefRecipe recipe in _recipes)
			{
				Ingredient[] ingredients = recipe.Ingredients;
				for (int i = 0; i < ingredients.Length; i++)
				{
					Ingredient ingredient = ingredients[i];
					if (!_recipesByIngredient.TryGetValue(ingredient.UnifiedIndex, out var value))
					{
						value = new List<ChefRecipe>();
						_recipesByIngredient[ingredient.UnifiedIndex] = value;
					}
					value.Add(recipe);
				}
			}
		}

		internal void SetMaxDepth(int newDepth)
		{
			_maxDepth = Math.Max(0, newDepth);
		}

		public void ComputeCraftable(int[] unifiedStacks)
		{
			if (!StateController.IsChefStage() || unifiedStacks == null || unifiedStacks.Length != _totalDefCount)
			{
				return;
			}
			Stopwatch stopwatch = Stopwatch.StartNew();
			Dictionary<int, List<RecipeChain>> dictionary = new Dictionary<int, List<RecipeChain>>();
			HashSet<long> hashSet = new HashSet<long>();
			Queue<RecipeChain> queue = new Queue<RecipeChain>();
			foreach (ChefRecipe recipe in _recipes)
			{
				if (CanAffordRecipe(unifiedStacks, recipe, null))
				{
					(Ingredient[] phys, Ingredient[] drone) tuple = CalculateSplitCosts(null, recipe);
					Ingredient[] item = tuple.phys;
					Ingredient[] item2 = tuple.drone;
					RecipeChain recipeChain = new RecipeChain(new ChefRecipe[1] { recipe }, item, item2);
					long canonicalSignature = recipeChain.CanonicalSignature;
					if (hashSet.Add(canonicalSignature))
					{
						AddChainToResults(dictionary, queue, recipeChain);
					}
				}
			}
			for (int i = 2; i <= _maxDepth; i++)
			{
				int count = queue.Count;
				if (count == 0)
				{
					break;
				}
				for (int j = 0; j < count; j++)
				{
					RecipeChain recipeChain2 = queue.Dequeue();
					if (!_recipesByIngredient.TryGetValue(recipeChain2.ResultIndex, out var value))
					{
						continue;
					}
					foreach (ChefRecipe item6 in value)
					{
						if (!recipeChain2.HasProduced(item6.ResultIndex) && CanAffordRecipe(unifiedStacks, item6, recipeChain2))
						{
							long item3 = RecipeChain.CalculateSignatureWithPotentialStep(recipeChain2.Steps, item6);
							if (hashSet.Add(item3))
							{
								List<ChefRecipe> steps = recipeChain2.Steps.Concat(new ChefRecipe[1] { item6 }).ToList();
								(Ingredient[] phys, Ingredient[] drone) tuple2 = CalculateSplitCosts(recipeChain2, item6);
								Ingredient[] item4 = tuple2.phys;
								Ingredient[] item5 = tuple2.drone;
								RecipeChain chain = new RecipeChain(steps, item4, item5);
								AddChainToResults(dictionary, queue, chain);
							}
						}
					}
				}
			}
			List<CraftableEntry> list = dictionary.Select((KeyValuePair<int, List<RecipeChain>> kvp) => new CraftableEntry
			{
				ResultIndex = kvp.Key,
				ResultCount = kvp.Value[0].ResultCount,
				MinDepth = kvp.Value.Min((RecipeChain c) => c.Depth),
				Chains = kvp.Value.OrderBy((RecipeChain c) => c.Depth).ToList()
			}).ToList();
			list.Sort(TierManager.CompareCraftableEntries);
			stopwatch.Stop();
			_log.LogInfo((object)$"CraftUI: ComputeCraftable Calculated all chains in {stopwatch.ElapsedMilliseconds}ms");
			this.OnCraftablesUpdated?.Invoke(list);
		}

		private bool CanAffordRecipe(int[] totalStacks, ChefRecipe recipe, RecipeChain existingChain)
		{
			Ingredient[] ingredients = recipe.Ingredients;
			for (int i = 0; i < ingredients.Length; i++)
			{
				Ingredient ingredient = ingredients[i];
				int num = ingredient.Count;
				if (existingChain != null && ingredient.UnifiedIndex == existingChain.ResultIndex)
				{
					num--;
				}
				if (num > 0)
				{
					int num2 = existingChain?.GetTotalCostOf(ingredient.UnifiedIndex) ?? 0;
					if (totalStacks[ingredient.UnifiedIndex] < num2 + num)
					{
						return false;
					}
				}
			}
			return true;
		}

		private (Ingredient[] phys, Ingredient[] drone) CalculateSplitCosts(RecipeChain old, ChefRecipe next)
		{
			_physScratch.Clear();
			_droneScratch.Clear();
			Ingredient[] physicalCostSparse;
			if (old != null)
			{
				physicalCostSparse = old.PhysicalCostSparse;
				for (int i = 0; i < physicalCostSparse.Length; i++)
				{
					Ingredient ingredient = physicalCostSparse[i];
					_physScratch[ingredient.UnifiedIndex] = ingredient.Count;
				}
				physicalCostSparse = old.DroneCostSparse;
				for (int i = 0; i < physicalCostSparse.Length; i++)
				{
					Ingredient ingredient2 = physicalCostSparse[i];
					_droneScratch[ingredient2.UnifiedIndex] = ingredient2.Count;
				}
			}
			physicalCostSparse = next.Ingredients;
			for (int i = 0; i < physicalCostSparse.Length; i++)
			{
				Ingredient ingredient3 = physicalCostSparse[i];
				if (old != null && ingredient3.UnifiedIndex == old.ResultIndex)
				{
					continue;
				}
				int count = ingredient3.Count;
				int physicalCount = InventoryTracker.GetPhysicalCount(ingredient3.UnifiedIndex);
				int value;
				int num = (_physScratch.TryGetValue(ingredient3.UnifiedIndex, out value) ? value : 0);
				int num2 = Math.Max(0, physicalCount - num);
				if (num2 >= count)
				{
					_physScratch[ingredient3.UnifiedIndex] = num + count;
					continue;
				}
				_physScratch[ingredient3.UnifiedIndex] = num + num2;
				int num3 = count - num2;
				if (!_droneScratch.ContainsKey(ingredient3.UnifiedIndex))
				{
					_droneScratch[ingredient3.UnifiedIndex] = 0;
				}
				_droneScratch[ingredient3.UnifiedIndex] += num3;
			}
			return (_physScratch.Select((KeyValuePair<int, int> kvp) => new Ingredient(kvp.Key, kvp.Value)).ToArray(), _droneScratch.Select((KeyValuePair<int, int> kvp) => new Ingredient(kvp.Key, kvp.Value)).ToArray());
		}

		private void AddChainToResults(Dictionary<int, List<RecipeChain>> results, Queue<RecipeChain> queue, RecipeChain chain)
		{
			if (!results.TryGetValue(chain.ResultIndex, out var value))
			{
				value = new List<RecipeChain>();
				results[chain.ResultIndex] = value;
			}
			value.Add(chain);
			queue.Enqueue(chain);
		}
	}
	internal static class CraftUI
	{
		internal sealed class RecipeRowRuntime : MonoBehaviour
		{
			public CraftPlanner.CraftableEntry Entry;

			public RectTransform RowTransform;

			public LayoutElement RowLayoutElement;

			public RectTransform RowTop;

			public Button RowTopButton;

			public TextMeshProUGUI ArrowText;

			public RectTransform DropdownMountPoint;

			public LayoutElement DropdownLayoutElement;

			public Image ResultIcon;

			public TextMeshProUGUI ResultStackText;

			public TextMeshProUGUI ItemLabel;

			public TextMeshProUGUI DepthText;

			public TextMeshProUGUI PathsText;

			public bool IsExpanded;

			public float CollapsedHeight;

			private void OnDestroy()
			{
				if ((Object)(object)RowTopButton != (Object)null)
				{
					((UnityEventBase)RowTopButton.onClick).RemoveAllListeners();
				}
				Entry = null;
				_openRow = null;
			}
		}

		internal sealed class PathRowRuntime : MonoBehaviour
		{
			internal RecipeRowRuntime OwnerRow;

			internal CraftPlanner.RecipeChain Chain;

			internal Image BackgroundImage;

			public RectTransform VisualRect;

			public Button pathButton;

			public EventTrigger buttonEvent;

			private ColorFaderRuntime fader;

			public ScrollRect parentScroll;

			private bool isSelected;

			private bool isHovered;

			private const float FadeDuration = 0.1f;

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

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

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

			private void Awake()
			{
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Expected O, but got Unknown
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Expected O, but got Unknown
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: 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_00ba: Expected O, but got Unknown
				//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)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Expected O, but got Unknown
				if ((Object)(object)pathButton == (Object)null)
				{
					pathButton = ((Component)this).GetComponent<Button>();
				}
				if ((Object)(object)buttonEvent == (Object)null)
				{
					buttonEvent = ((Component)this).GetComponent<EventTrigger>();
				}
				if ((Object)(object)pathButton != (Object)null)
				{
					((UnityEvent)pathButton.onClick).AddListener(new UnityAction(OnClicked));
				}
				if ((Object)(object)parentScroll == (Object)null)
				{
					parentScroll = ((Component)this).GetComponentInParent<ScrollRect>();
				}
				Entry val = new Entry
				{
					eventID = (EventTriggerType)0
				};
				((UnityEvent<BaseEventData>)(object)val.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					OnHighlightChanged(isHighlighted: true);
				});
				buttonEvent.triggers.Add(val);
				Entry val2 = new Entry
				{
					eventID = (EventTriggerType)1
				};
				((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)delegate
				{
					OnHighlightChanged(isHighlighted: false);
				});
				buttonEvent.triggers.Add(val2);
				Entry val3 = new Entry
				{
					eventID = (EventTriggerType)7
				};
				((UnityEvent<BaseEventData>)(object)val3.callback).AddListener((UnityAction<BaseEventData>)delegate(BaseEventData data)
				{
					BubbleScroll(data);
				});
				buttonEvent.triggers.Add(val3);
				if ((Object)(object)VisualRect == (Object)null)
				{
					Transform val4 = ((Component)this).transform.Find("Visuals");
					if ((Object)(object)val4 != (Object)null)
					{
						VisualRect = ((Component)val4).GetComponent<RectTransform>();
					}
				}
				if ((Object)(object)VisualRect != (Object)null)
				{
					if ((Object)(object)BackgroundImage == (Object)null)
					{
						BackgroundImage = ((Component)VisualRect).GetComponent<Image>();
					}
					fader = ((Component)VisualRect).GetComponent<ColorFaderRuntime>();
				}
			}

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

			private void OnDestroy()
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				if ((Object)(object)pathButton != (Object)null)
				{
					((UnityEvent)pathButton.onClick).RemoveListener(new UnityAction(OnClicked));
				}
				if ((Object)(object)buttonEvent != (Object)null)
				{
					buttonEvent.triggers.Clear();
				}
				if ((Object)(object)_currentHoveredPath == (Object)(object)this)
				{
					_currentHoveredPath = null;
				}
				if ((Object)(object)_selectedPathUI == (Object)(object)this)
				{
					_selectedPathUI = null;
				}
				OwnerRow = null;
				Chain = null;
			}

			private void OnClicked()
			{
				OnPathSelected(this);
			}

			private void OnHighlightChanged(bool isHighlighted)
			{
				if (isHighlighted)
				{
					isHovered = true;
					if ((Object)(object)_currentHoveredPath == (Object)(object)this)
					{
						_currentHoveredPath = null;
					}
					AttachReticleTo(VisualRect);
				}
				else
				{
					isHovered = false;
					if (IsReticleAttachedTo((Transform)(object)VisualRect))
					{
						RestoreReticleToSelection();
					}
				}
				UpdateVisuals(instant: false);
			}

			private void BubbleScroll(BaseEventData data)
			{
				if ((Object)(object)parentScroll != (Object)null)
				{
					PointerEventData val = (PointerEventData)(object)((data is PointerEventData) ? data : null);
					if (val != null)
					{
						parentScroll.OnScroll(val);
					}
				}
			}

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

			private void UpdateVisuals(bool instant)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: 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_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)BackgroundImage == (Object)null))
				{
					Color val = (isSelected ? Col_BG_Active : ((!isHovered) ? Col_BG_Normal : Col_BG_Hover));
					if (instant)
					{
						((Graphic)BackgroundImage).color = val;
					}
					else
					{
						fader.CrossFadeColor(val, 0.1f);
					}
				}
			}
		}

		private class NestedScrollRect : ScrollRect
		{
			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);
				}
			}
		}

		private sealed class CraftUIRunner : MonoBehaviour
		{
		}

		private class RecipeDropdownRuntime : MonoBehaviour
		{
			public ScrollRect ScrollRect;

			public RectTransform Content;

			public RectTransform Background;

			public RecipeRowRuntime CurrentOwner;

			public int SelectedPathIndex = -1;

			public void OpenFor(RecipeRowRuntime owner)
			{
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: 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_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_0046: 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)
				CurrentOwner = owner;
				((Component)this).gameObject.SetActive(true);
				((Component)this).transform.SetParent((Transform)(object)owner.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)ScrollRect != (Object)null)
				{
					((Behaviour)ScrollRect).enabled = owner.Entry.Chains.Count > 4;
					ScrollRect.verticalNormalizedPosition = 1f;
				}
				PopulateDropdown(Content, owner);
			}

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

			private void OnDestroy()
			{
				CurrentOwner = null;
			}
		}

		internal sealed class ColorFaderRuntime : MonoBehaviour
		{
			[CompilerGenerated]
			private sealed class <FadeRoutine>d__4 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public ColorFaderRuntime <>4__this;

				public bool ignoreTimeScale;

				public float duration;

				public Color target;

				private Color <start>5__2;

				private float <timer>5__3;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <FadeRoutine>d__4(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//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)
					//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
					//IL_007a: Unknown result type (might be due to invalid IL or missing references)
					//IL_0080: 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)
					int num = <>1__state;
					ColorFaderRuntime colorFaderRuntime = <>4__this;
					switch (num)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<start>5__2 = colorFaderRuntime._targetGraphic.color;
						<timer>5__3 = 0f;
						break;
					case 1:
						<>1__state = -1;
						break;
					}
					if (<timer>5__3 < duration)
					{
						<timer>5__3 += (ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime);
						float num2 = Mathf.Clamp01(<timer>5__3 / duration);
						colorFaderRuntime._targetGraphic.color = Color.Lerp(<start>5__2, target, num2);
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					colorFaderRuntime._targetGraphic.color = target;
					colorFaderRuntime._activeRoutine = null;
					return false;
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			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));
					}
				}
			}

			[IteratorStateMachine(typeof(<FadeRoutine>d__4))]
			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)
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <FadeRoutine>d__4(0)
				{
					<>4__this = this,
					target = target,
					duration = duration,
					ignoreTimeScale = ignoreTimeScale
				};
			}

			private void OnDisable()
			{
				if (_activeRoutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(_activeRoutine);
				}
				_activeRoutine = null;
			}
		}

		private struct RecipeRowUI
		{
			public CraftPlanner.CraftableEntry Entry;

			public GameObject RowGO;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static Action<IReadOnlyList<CraftPlanner.CraftableEntry>> <0>__CraftablesForUIChanged;

			public static UnityAction<string> <1>__OnSearchTextChanged;

			public static UnityAction <2>__OnGlobalCraftButtonClicked;
		}

		[CompilerGenerated]
		private sealed class <PopulateDropdownRoutine>d__104 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public RectTransform contentRoot;

			public RecipeRowRuntime owner;

			private int <builtCount>5__2;

			private List<CraftPlanner.RecipeChain>.Enumerator <>7__wrap2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PopulateDropdownRoutine>d__104(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 2)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>7__wrap2 = default(List<CraftPlanner.RecipeChain>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						foreach (Transform item in (Transform)contentRoot)
						{
							Object.Destroy((Object)(object)((Component)item).gameObject);
						}
						<>2__current = null;
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						if (owner.Entry == null || owner.Entry.Chains == null)
						{
							_activeDropdownRoutine = null;
							return false;
						}
						<builtCount>5__2 = 0;
						<>7__wrap2 = owner.Entry.Chains.GetEnumerator();
						<>1__state = -3;
						break;
					case 2:
						<>1__state = -3;
						break;
					}
					while (<>7__wrap2.MoveNext())
					{
						CraftPlanner.RecipeChain current = <>7__wrap2.Current;
						CreatePathRow(contentRoot, current, owner);
						<builtCount>5__2++;
						if (<builtCount>5__2 % 4 == 0)
						{
							<>2__current = null;
							<>1__state = 2;
							return true;
						}
					}
					<>m__Finally1();
					<>7__wrap2 = default(List<CraftPlanner.RecipeChain>.Enumerator);
					_cachedDropdownOwner = owner;
					_activeDropdownRoutine = null;
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>7__wrap2).Dispose();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <PopulateRoutine>d__102 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public IReadOnlyList<CraftPlanner.CraftableEntry> craftables;

			public Stopwatch sw;

			private VerticalLayoutGroup <vlg>5__2;

			private CanvasGroup <canvasGroup>5__3;

			private ScrollRect <scrollRect>5__4;

			private float <previousScrollPos>5__5;

			private CraftPlanner.CraftableEntry <previousEntry>5__6;

			private CraftPlanner.RecipeChain <chainToRestoreHover>5__7;

			private int <builtCount>5__8;

			private RecipeRowRuntime <rowToRestore>5__9;

			private IEnumerator<CraftPlanner.CraftableEntry> <>7__wrap9;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <PopulateRoutine>d__102(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 2)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<vlg>5__2 = null;
				<canvasGroup>5__3 = null;
				<scrollRect>5__4 = null;
				<previousEntry>5__6 = null;
				<chainToRestoreHover>5__7 = null;
				<rowToRestore>5__9 = null;
				<>7__wrap9 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0461: Unknown result type (might be due to invalid IL or missing references)
				//IL_0468: Expected O, but got Unknown
				//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						<vlg>5__2 = ((Component)_recipeListContent).GetComponent<VerticalLayoutGroup>();
						<canvasGroup>5__3 = ((Component)_recipeListContent).GetComponent<CanvasGroup>();
						<scrollRect>5__4 = ((Component)_recipeListContent).GetComponentInParent<ScrollRect>();
						if (Object.op_Implicit((Object)(object)<canvasGroup>5__3))
						{
							<canvasGroup>5__3.alpha = 0f;
							<canvasGroup>5__3.blocksRaycasts = false;
						}
						if (Object.op_Implicit((Object)(object)<vlg>5__2))
						{
							((Behaviour)<vlg>5__2).enabled = false;
						}
						bool flag = ((Transform)_recipeListContent).childCount > 0;
						<previousScrollPos>5__5 = (((Object)(object)<scrollRect>5__4 != (Object)null && flag) ? <scrollRect>5__4.verticalNormalizedPosition : 1f);
						if ((Object)(object)_selectionReticle != (Object)null)
						{
							((Transform)_selectionReticle).SetParent(_cookbookRoot.transform, false);
							((Component)_selectionReticle).gameObject.SetActive(false);
						}
						if ((Object)(object)_sharedDropdown != (Object)null)
						{
							((Component)_sharedDropdown).transform.SetParent(_cookbookRoot.transform, false);
							((Component)_sharedDropdown).gameObject.SetActive(false);
							_cachedDropdownOwner = null;
							_sharedDropdown.CurrentOwner = null;
						}
						<previousEntry>5__6 = null;
						<chainToRestoreHover>5__7 = null;
						if ((Object)(object)_openRow != (Object)null)
						{
							<previousEntry>5__6 = _openRow.Entry;
							CollapseRow(_openRow);
						}
						if ((Object)(object)_currentHoveredPath != (Object)null)
						{
							<chainToRestoreHover>5__7 = _currentHoveredPath.Chain;
						}
						_openRow = null;
						_selectedAnchor = null;
						_currentHoveredPath = null;
						foreach (Transform item in (Transform)_recipeListContent)
						{
							Object.Destroy((Object)(object)((Component)item).gameObject);
						}
						_recipeRowUIs.Clear();
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					case 1:
						<>1__state = -1;
						if (craftables == null || craftables.Count == 0)
						{
							if (Object.op_Implicit((Object)(object)<vlg>5__2))
							{
								((Behaviour)<vlg>5__2).enabled = true;
							}
							if (Object.op_Implicit((Object)(object)<canvasGroup>5__3))
							{
								<canvasGroup>5__3.alpha = 1f;
								<canvasGroup>5__3.blocksRaycasts = true;
							}
							_activeBuildRoutine = null;
							sw.Stop();
							_log.LogInfo((object)$"CraftUI: PopulateRecipeList (Empty) completed in {sw.ElapsedMilliseconds}ms");
							return false;
						}
						<builtCount>5__8 = 0;
						<rowToRestore>5__9 = null;
						<>7__wrap9 = craftables.GetEnumerator();
						<>1__state = -3;
						goto IL_037f;
					case 2:
						<>1__state = -3;
						goto IL_037f;
					case 3:
						{
							<>1__state = -1;
							break;
						}
						IL_037f:
						while (<>7__wrap9.MoveNext())
						{
							CraftPlanner.CraftableEntry current = <>7__wrap9.Current;
							if (current != null)
							{
								GameObject val = CreateRecipeRow(_recipeListContent, current);
								RecipeRowRuntime component = val.GetComponent<RecipeRowRuntime>();
								_recipeRowUIs.Add(new RecipeRowUI
								{
									Entry = current,
									RowGO = val
								});
								if (<previousEntry>5__6 != null && AreEntriesSame(<previousEntry>5__6, current))
								{
									<rowToRestore>5__9 = component;
								}
								<builtCount>5__8++;
								if (<builtCount>5__8 % 5 == 0)
								{
									<>2__current = null;
									<>1__state = 2;
									return true;
								}
							}
						}
						<>m__Finally1();
						<>7__wrap9 = null;
						if (Object.op_Implicit((Object)(object)<vlg>5__2))
						{
							((Behaviour)<vlg>5__2).enabled = true;
							LayoutRebuilder.ForceRebuildLayoutImmediate(_recipeListContent);
							PixelSnap(_recipeListContent);
						}
						break;
					}
					if (_activeDropdownRoutine != null)
					{
						<>2__current = null;
						<>1__state = 3;
						return true;
					}
					if ((Object)(object)<rowToRestore>5__9 != (Object)null)
					{
						ToggleRecipeRow(<rowToRestore>5__9);
						if ((Object)(object)_sharedDropdown != (Object)null && (Object)(object)_sharedDropdown.CurrentOwner == (Object)(object)<rowToRestore>5__9)
						{
							bool flag2 = _selectedChainData != null;
							bool flag3 = <chainToRestoreHover>5__7 != null;
							foreach (Transform item2 in (Transform)_sharedDropdown.Content)
							{
								Transform val2 = item2;
								if (!flag2 && !flag3)
								{
									break;
								}
								PathRowRuntime component2 = ((Component)val2).GetComponent<PathRowRuntime>();
								if (!((Object)(object)component2 == (Object)null))
								{
									if (flag2 && component2.Chain == _selectedChainData)
									{
										OnPathSelected(component2);
										flag2 = false;
									}
									if (flag3 && component2.Chain == <chainToRestoreHover>5__7)
									{
										_currentHoveredPath = component2;
										AttachReticleTo(component2.VisualRect);
										flag3 = false;
									}
								}
							}
						}
					}
					else
					{
						DeselectCurrentPath();
					}
					if ((Object)(object)<scrollRect>5__4 != (Object)null)
					{
						<scrollRect>5__4.verticalNormalizedPosition = <previousScrollPos>5__5;
					}
					if (Object.op_Implicit((Object)(object)<canvasGroup>5__3))
					{
						<canvasGroup>5__3.alpha = 1f;
						<canvasGroup>5__3.blocksRaycasts = true;
					}
					_activeBuildRoutine = null;
					sw.Stop();
					_log.LogInfo((object)$"CraftUI: PopulateRecipeList (Empty) completed in {sw.ElapsedMilliseconds}ms");
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>7__wrap9 != null)
				{
					<>7__wrap9.Dispose();
				}
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static ManualLogSource _log;

		private static IReadOnlyList<CraftPlanner.CraftableEntry> _lastCraftables;

		private static bool _skeletonBuilt = false;

		private static CraftingController _currentController;

		private static GameObject _cookbookRoot;

		private static RectTransform _recipeListContent;

		private static TMP_InputField _searchInputField;

		private static GameObject _recipeRowTemplate;

		private static GameObject _pathRowTemplate;

		private static GameObject _ingredientSlotTemplate;

		private static GameObject _ResultSlotTemplate;

		private static RecipeRowRuntime _openRow;

		private static CraftUIRunner _runner;

		private static Coroutine _activeBuildRoutine;

		private static Coroutine _activeDropdownRoutine;

		private static RecipeDropdownRuntime _sharedDropdown;

		private static RecipeRowRuntime _cachedDropdownOwner;

		private static RectTransform _selectionReticle;

		private static RectTransform _currentReticleTarget;

		private static RectTransform _selectedAnchor;

		private static PathRowRuntime _currentHoveredPath;

		private static Button _globalCraftButton;

		private static TextMeshProUGUI _globalCraftButtonText;

		private static Image _globalCraftButtonImage;

		private static PathRowRuntime _selectedPathUI;

		private static CraftPlanner.RecipeChain _selectedChainData;

		private static Sprite _solidPointSprite;

		private static Sprite _taperedGradientSprite;

		private static readonly Dictionary<int, Sprite> _iconCache = new Dictionary<int, Sprite>();

		private static readonly Dictionary<DroneIndex, Sprite> _droneIconCache = new Dictionary<DroneIndex, Sprite>();

		private static readonly List<RecipeRowUI> _recipeRowUIs = new List<RecipeRowUI>();

		private static float _panelWidth;

		private static float _panelHeight;

		internal const float CookBookPanelPaddingTopNorm = 0.015974442f;

		internal const float CookBookPanelPaddingBottomNorm = 0.015974442f;

		internal const float CookBookPanelPaddingLeftNorm = 0f;

		internal const float CookBookPanelPaddingRightNorm = 0f;

		internal const float CookBookPanelElementSpacingNorm = 0.015974442f;

		internal const float SearchBarHeightNorm = 0.079872206f;

		internal const float SearchBarBottomBorderThicknessNorm = 0.0001f;

		internal const float RecipeListVerticalPaddingNorm = 0f;

		internal const float RecipeListLeftPaddingNorm = 1f / 55f;

		internal const float RecipeListRightPaddingNorm = 1f / 55f;

		internal const float RecipeListElementSpacingNorm = 0f;

		internal const float RecipeListScrollbarWidthNorm = 0f;

		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 MetaDataElementSpacingNorm = 0.015974442f;

		internal const float DropDownArrowSizeNorm = 0.05111821f;

		internal const float textSizeNorm = 0.038338657f;

		private const float PathsContainerLeftPaddingNorm = 1f / 55f;

		private const float PathsContainerRightPaddingNorm = 1f / 55f;

		private const int PathsContainerMaxVisibleRows = 4;

		private const float PathsContainerSpacingNorm = 0.007987221f;

		private const float PathRowHeightNorm = 0.079872206f;

		private const float PathRowLeftPaddingNorm = 1f / 110f;

		private const float PathRowRightPaddingNorm = 1f / 110f;

		private const float PathRowIngredientSpacingNorm = 1f / 110f;

		private const float IngredientHeightNorm = 0.06709265f;

		private const float _IngredientStackSizeTextHeightPx = 10f;

		private const float _IngredientStackMargin = 2f;

		private const float _ResultStackMargin = 3f;

		private const float FooterHeightNorm = 0.05f;

		internal static void Init(ManualLogSource log)
		{
			_log = log;
			StateController.OnCraftablesForUIChanged += CraftablesForUIChanged;
		}

		internal static void Attach(CraftingController controller)
		{
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			_currentController = controller;
			if ((Object)(object)_cookbookRoot != (Object)null)
			{
				return;
			}
			CraftingPanel val = Object.FindObjectOfType<CraftingPanel>();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			Transform val2 = ((Component)val).transform.Find("MainPanel/Juice/BGContainer");
			RectTransform component = ((Component)val2).GetComponent<RectTransform>();
			object obj;
			if (!Object.op_Implicit((Object)(object)val2))
			{
				obj = null;
			}
			else
			{
				Transform obj2 = val2.Find("BGMain");
				obj = ((obj2 != null) ? ((Component)obj2).GetComponent<RectTransform>() : null);
			}
			RectTransform val3 = (RectTransform)obj;
			Transform obj3 = ((Component)val).transform.Find("MainPanel/Juice/LabelContainer");
			RectTransform val4 = ((obj3 != null) ? ((Component)obj3).GetComponent<RectTransform>() : null);
			Transform obj4 = val2.Find("CraftingContainer/Background");
			RectTransform val5 = ((obj4 != null) ? ((Component)obj4).GetComponent<RectTransform>() : null);
			Transform obj5 = val2.Find("CraftingContainer");
			if (obj5 != null)
			{
				((Component)obj5).GetComponent<RectTransform>();
			}
			Transform obj6 = val2.Find("SubmenuContainer");
			RectTransform val6 = ((obj6 != null) ? ((Component)obj6).GetComponent<RectTransform>() : null);
			Transform obj7 = val2.Find("InventoryContainer");
			RectTransform val7 = ((obj7 != null) ? ((Component)obj7).GetComponent<RectTransform>() : null);
			if (!Object.op_Implicit((Object)(object)val4))
			{
				return;
			}
			((Transform)val4).SetParent((Transform)(object)val3, true);
			float value;
			Rect rect;
			if (!Object.op_Implicit((Object)(object)val7))
			{
				value = 0f;
			}
			else
			{
				rect = val7.rect;
				value = ((Rect)(ref rect)).width;
			}
			float num = RoundToEven(value);
			float value2;
			if (!Object.op_Implicit((Object)(object)val7))
			{
				value2 = 0f;
			}
			else
			{
				rect = val7.rect;
				value2 = ((Rect)(ref rect)).height;
			}
			float num2 = RoundToEven(value2);
			float value3;
			if (!Object.op_Implicit((Object)(object)val5))
			{
				value3 = 0f;
			}
			else
			{
				rect = val5.rect;
				value3 = ((Rect)(ref rect)).width;
			}
			RoundToEven(value3);
			rect = val3.rect;
			float num3 = RoundToEven(((Rect)(ref rect)).width);
			rect = val3.rect;
			RoundToEven(((Rect)(ref rect)).height);
			rect = val4.rect;
			float num4 = RoundToEven(((Rect)(ref rect)).width);
			Image component2 = ((Component)val3).GetComponent<Image>();
			Sprite val8 = (Object.op_Implicit((Object)(object)component2) ? component2.sprite : null);
			float num5 = RoundToEven(Object.op_Implicit((Object)(object)val8) ? val8.pixelsPerUnit : 1f);
			float num6 = RoundToEven(Object.op_Implicit((Object)(object)val8) ? (val8.border.x / num5) : 0f);
			float num7 = RoundToEven(Object.op_Implicit((Object)(object)val8) ? (val8.border.z / num5) : 0f);
			RoundToEven(Object.op_Implicit((Object)(object)val8) ? (val8.border.w / num5) : 0f);
			RoundToEven(Object.op_Implicit((Object)(object)val8) ? (val8.border.y / num5) : 0f);
			float num8 = num6 + num7;
			float num9 = 1.8f;
			float num10 = RoundToEven(num3 * num9);
			float num11 = RoundToEven((num3 - num8 - num4) * 0.5f);
			float num12 = num10 - num8;
			float num13 = num12 - 2f * num11;
			float num14 = RoundToEven(num * 0.88f);
			float num15 = RoundToEven(num2 * 0.9f);
			float num16 = num14;
			float num17 = RoundToEven(Mathf.Clamp(num10 * 0.3f, 260f, num12 - num));
			float num18 = RoundToEven(Mathf.Clamp(num10 * 0.05f, 20f, num11));
			component.SetSizeWithCurrentAnchors((Axis)0, num10);
			val4.SetSizeWithCurrentAnchors((Axis)0, num13);
			val7.SetSizeWithCurrentAnchors((Axis)0, num14);
			val7.SetSizeWithCurrentAnchors((Axis)1, num15);
			val5.SetSizeWithCurrentAnchors((Axis)0, num16);
			AlignLabelVerticallyBetween(val4, val3, val5);
			rect = val5.rect;
			float num19 = RoundToEven(((Rect)(ref rect)).width);
			float num20 = RoundToEven((num12 - (num19 + num18 + num17)) * 0.5f);
			float x = RoundToEven((0f - num12) * 0.5f + num20 + num19 * 0.5f);
			Vector2 anchoredPosition = val5.anchoredPosition;
			anchoredPosition.x = x;
			val5.anchoredPosition = anchoredPosition;
			anchoredPosition = val7.anchoredPosition;
			anchoredPosition.x = x;
			val7.anchoredPosition = anchoredPosition;
			anchoredPosition = val6.anchoredPosition;
			anchoredPosition.x = x;
			val6.anchoredPosition = anchoredPosition;
			Bounds val9 = default(Bounds);
			bool flag = false;
			if (Object.op_Implicit((Object)(object)val5))
			{
				val9 = RectTransformUtility.CalculateRelativeRectTransformBounds(val2, (Transform)(object)val5);
				flag = true;
			}
			if (Object.op_Implicit((Object)(object)val7))
			{
				Bounds val10 = RectTransformUtility.CalculateRelativeRectTransformBounds(val2, (Transform)(object)val7);
				if (flag)
				{
					((Bounds)(ref val9)).Encapsulate(val10);
				}
				else
				{
					val9 = val10;
					flag = true;
				}
			}
			float num21 = RoundToEven(((Bounds)(ref val9)).size.y);
			float num22 = RoundToEven(((Bounds)(ref val9)).center.y);
			_cookbookRoot = CreateUIObject("CookBookPanel", typeof(RectTransform), typeof(CraftUIRunner), typeof(Canvas), typeof(GraphicRaycaster));
			_runner = _cookbookRoot.GetComponent<CraftUIRunner>();
			_cookbookRoot.GetComponent<Canvas>().pixelPerfect = true;
			_cookbookRoot.GetComponent<GraphicRaycaster>();
			RectTransform component3 = _cookbookRoot.GetComponent<RectTransform>();
			_cookbookRoot.transform.SetParent(val2, false);
			component3.anchorMin = new Vector2(1f, 0.5f);
			component3.anchorMax = new Vector2(1f, 0.5f);
			component3.pivot = new Vector2(1f, 0.5f);
			component3.sizeDelta = new Vector2(num17, num21);
			component3.anchoredPosition = new Vector2(0f - num20, num22);
			((Behaviour)((Component)val4).GetComponent<Image>()).enabled = false;
			AddBorder(val4, new Color32((byte)209, (byte)209, (byte)210, byte.MaxValue), 2f, 2f, 6f, 6f);
			_log.LogDebug((object)$"CraftUI.Attach: CookBook panel attached. baseWidth={num3:F1}, newWidth={num10:F1}, cookbookWidth={num17:F1}, invBaseWidth={num:F1}");
			rect = component3.rect;
			_panelWidth = ((Rect)(ref rect)).width;
			rect = component3.rect;
			_panelHeight = ((Rect)(ref rect)).height;
			Stopwatch stopwatch = Stopwatch.StartNew();
			CookBookSkeleton(component3);
			EnsureResultSlotArtTemplates(val);
			EnsureIngredientSlotTemplate();
			BuildRecipeRowTemplate();
			BuildPathRowTemplate();
			BuildSharedDropdown();
			BuildSharedHoverRect();
			stopwatch.Stop();
			_log.LogInfo((object)$"CraftUI: Skeleton & Templates built in {stopwatch.ElapsedMilliseconds}ms");
			if (_lastCraftables != null && _lastCraftables.Count > 0)
			{
				PopulateRecipeList(_lastCraftables);
			}
		}

		internal static void Detach()
		{
			if ((Object)(object)_cookbookRoot != (Object)null)
			{
				Object.Destroy((Object)(object)_cookbookRoot);
				_cookbookRoot = null;
			}
			if ((Object)(object)_globalCraftButton != (Object)null)
			{
				((UnityEventBase)_globalCraftButton.onClick).RemoveAllListeners();
			}
			_recipeRowUIs.Clear();
			_iconCache.Clear();
			_droneIconCache.Clear();
			_currentController = null;
			_skeletonBuilt = false;
			_recipeListContent = null;
			_openRow = null;
			_activeBuildRoutine = null;
			_activeDropdownRoutine = null;
		}

		internal static void CloseCraftPanel(CraftingController specificController = null)
		{
			CraftingController val = (Object.op_Implicit((Object)(object)specificController) ? specificController : _currentController);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			if ((Object)(object)_runner != (Object)null && _activeBuildRoutine != null)
			{
				((MonoBehaviour)_runner).StopCoroutine(_activeBuildRoutine);
				_activeBuildRoutine = null;
			}
			CraftingPanel[] array = Object.FindObjectsOfType<CraftingPanel>();
			foreach (CraftingPanel val2 in array)
			{
				if ((Object)(object)val2.craftingController == (Object)(object)val)
				{
					Object.Destroy((Object)(object)((Component)val2).gameObject);
					Detach();
					break;
				}
			}
		}

		internal static void Shutdown()
		{
			StateController.OnCraftablesForUIChanged -= CraftablesForUIChanged;
			((UnityEventBase)_searchInputField.onValueChanged).RemoveAllListeners();
		}

		internal static void CookBookSkeleton(RectTransform cookbookRoot)
		{
			//IL_003c: 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_0069: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_042d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0501: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_078f: Unknown result type (might be due to invalid IL or missing references)
			//IL_079b: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_080a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0814: Unknown result type (might be due to invalid IL or missing references)
			//IL_08be: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_095c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0968: Unknown result type (might be due to invalid IL or missing references)
			//IL_097e: Unknown result type (might be due to invalid IL or missing references)
			//IL_098a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0996: Unknown result type (might be due to invalid IL or missing references)
			//IL_09db: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e5: Expected O, but got Unknown
			//IL_0731: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_073c: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)cookbookRoot))
			{
				for (int num = ((Transform)cookbookRoot).childCount - 1; num >= 0; num--)
				{
					Object.Destroy((Object)(object)((Component)((Transform)cookbookRoot).GetChild(num)).gameObject);
				}
				AddBorderTapered((RectTransform)_cookbookRoot.transform, new Color32((byte)209, (byte)209, (byte)210, byte.MaxValue), 2f, 2f);
				float num2 = RoundToEven(0.015974442f * _panelHeight);
				float num3 = RoundToEven(0.015974442f * _panelHeight);
				float num4 = RoundToEven(0f * _panelWidth);
				float num5 = RoundToEven(0f * _panelWidth);
				float num6 = RoundToEven(0.015974442f * _panelHeight);
				float num7 = RoundToEven(0.079872206f * _panelHeight);
				float num8 = RoundToEven(0.05f * _panelHeight);
				float num9 = _panelHeight - num2 - num3 - num7 - num8 - num6 * 2f;
				int num10 = Mathf.RoundToInt(0f * _panelHeight);
				if (num9 < 0f)
				{
					num9 = 0f;
				}
				RectTransform component = CreateUIObject("SearchBarContainer", typeof(RectTransform)).GetComponent<RectTransform>();
				((Transform)component).SetParent((Transform)(object)cookbookRoot, false);
				component.anchorMin = new Vector2(0f, 1f);
				component.anchorMax = new Vector2(1f, 1f);
				component.pivot = new Vector2(0.5f, 1f);
				component.sizeDelta = new Vector2(0f, num7);
				component.anchoredPosition = new Vector2(0f, 0f - num2);
				Vector2 offsetMin = component.offsetMin;
				Vector2 offsetMax = component.offsetMax;
				offsetMin.x = num4;
				offsetMax.x = 0f - num5;
				component.offsetMin = offsetMin;
				component.offsetMax = offsetMax;
				GameObject obj = CreateUIObject("SearchInput", typeof(RectTransform), typeof(Image), typeof(TMP_InputField));
				RectTransform component2 = obj.GetComponent<RectTransform>();
				Image component3 = obj.GetComponent<Image>();
				_searchInputField = obj.GetComponent<TMP_InputField>();
				((Transform)component2).SetParent((Transform)(object)component, false);
				component2.anchorMin = Vector2.zero;
				component2.anchorMax = Vector2.one;
				component2.sizeDelta = Vector2.zero;
				component2.anchoredPosition = Vector2.zero;
				((Graphic)component3).color = new Color(0f, 0f, 0f, 0.4f);
				((Graphic)component3).raycastTarget = false;
				RectTransform component4 = CreateUIObject("Text Area", typeof(RectTransform), typeof(RectMask2D)).GetComponent<RectTransform>();
				((Transform)component4).SetParent((Transform)(object)component2, false);
				component4.anchorMin = Vector2.zero;
				component4.anchorMax = Vector2.one;
				component4.offsetMin = Vector2.zero;
				component4.offsetMax = Vector2.zero;
				GameObject obj2 = CreateUIObject("Text", typeof(RectTransform), typeof(TextMeshProUGUI));
				TextMeshProUGUI component5 = obj2.GetComponent<TextMeshProUGUI>();
				RectTransform component6 = obj2.GetComponent<RectTransform>();
				((Transform)component6).SetParent((Transform)(object)component4, false);
				component6.anchorMin = Vector2.zero;
				component6.anchorMax = Vector2.one;
				component6.sizeDelta = Vector2.zero;
				((TMP_Text)component5).fontSize = 20f;
				((TMP_Text)component5).alignment = (TextAlignmentOptions)514;
				((Graphic)component5).color = Color.white;
				GameObject obj3 = CreateUIObject("Placeholder", typeof(RectTransform), typeof(TextMeshProUGUI));
				RectTransform component7 = obj3.GetComponent<RectTransform>();
				TextMeshProUGUI component8 = obj3.GetComponent<TextMeshProUGUI>();
				((Transform)component7).SetParent((Transform)(object)component4, false);
				component7.anchorMin = Vector2.zero;
				component7.anchorMax = Vector2.one;
				component7.sizeDelta = Vector2.zero;
				((TMP_Text)component8).text = "search";
				((TMP_Text)component8).fontSize = 20f;
				((TMP_Text)component8).alignment = (TextAlignmentOptions)514;
				((Graphic)component8).color = new Color(1f, 1f, 1f, 0.5f);
				((Graphic)component8).raycastTarget = false;
				_searchInputField.textViewport = component4;
				_searchInputField.textComponent = (TMP_Text)(object)component5;
				_searchInputField.placeholder = (Graphic)(object)component8;
				((UnityEvent<string>)(object)_searchInputField.onValueChanged).AddListener((UnityAction<string>)OnSearchTextChanged);
				AddBorderTapered(component2, new Color32((byte)209, (byte)209, (byte)210, (byte)200), 0f, Mathf.Max(1f, 0.0001f * _panelHeight));
				RectTransform component9 = CreateUIObject("Footer", typeof(RectTransform)).GetComponent<RectTransform>();
				((Transform)component9).SetParent((Transform)(object)cookbookRoot, false);
				component9.anchorMin = new Vector2(0f, 0f);
				component9.anchorMax = new Vector2(1f, 0f);
				component9.pivot = new Vector2(0.5f, 0f);
				component9.sizeDelta = new Vector2(0f, num8);
				component9.anchoredPosition = new Vector2(0f, num3);
				component9.offsetMin = new Vector2(num4, component9.offsetMin.y);
				component9.offsetMax = new Vector2(0f - num5, component9.offsetMax.y);
				GameObject obj4 = CreateUIObject("GlobalCraftButton", typeof(RectTransform), typeof(Image), typeof(Button));
				RectTransform component10 = obj4.GetComponent<RectTransform>();
				Image component11 = obj4.GetComponent<Image>();
				Button component12 = obj4.GetComponent<Button>();
				((Transform)component10).SetParent((Transform)(object)component9, false);
				component10.anchorMin = Vector2.zero;
				component10.anchorMax = Vector2.one;
				component10.sizeDelta = Vector2.zero;
				((Graphic)component11).color = Color32.op_Implicit(new Color32((byte)40, (byte)40, (byte)40, byte.MaxValue));
				((Graphic)component11).raycastTarget = false;
				((Selectable)component12).interactable = false;
				GameObject obj5 = CreateUIObject("Text", typeof(RectTransform), typeof(TextMeshProUGUI));
				RectTransform component13 = obj5.GetComponent<RectTransform>();
				TextMeshProUGUI component14 = obj5.GetComponent<TextMeshProUGUI>();
				((Transform)component13).SetParent((Transform)(object)component10, false);
				component13.anchorMin = Vector2.zero;
				component13.anchorMax = Vector2.one;
				((TMP_Text)component14).text = "select a recipe";
				((TMP_Text)component14).alignment = (TextAlignmentOptions)514;
				((TMP_Text)component14).fontSize = num8 * 0.5f;
				((Graphic)component14).color = Color32.op_Implicit(new Color32((byte)100, (byte)100, (byte)100, byte.MaxValue));
				_globalCraftButton = component12;
				_globalCraftButtonText = component14;
				_globalCraftButtonImage = component11;
				AddBorder(component9, new Color32((byte)209, (byte)209, (byte)210, (byte)200), 1f, 1f, 1f, 1f);
				ButtonClickedEvent onClick = _globalCraftButton.onClick;
				object obj6 = <>O.<2>__OnGlobalCraftButtonClicked;
				if (obj6 == null)
				{
					UnityAction val = OnGlobalCraftButtonClicked;
					<>O.<2>__OnGlobalCraftButtonClicked = val;
					obj6 = (object)val;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj6);
				GameObject obj7 = CreateUIObject("RecipeListContainer", typeof(RectTransform), typeof(ScrollRect));
				RectTransform component15 = obj7.GetComponent<RectTransform>();
				ScrollRect component16 = obj7.GetComponent<ScrollRect>();
				((Transform)component15).SetParent((Transform)(object)cookbookRoot, false);
				component15.anchorMin = new Vector2(0f, 1f);
				component15.anchorMax = Vector2.one;
				component15.pivot = new Vector2(0.5f, 1f);
				component15.sizeDelta = new Vector2(0f, num9);
				float num11 = num2 + num7 + num6;
				component15.anchoredPosition = new Vector2(0f, 0f - num11);
				component15.offsetMin = new Vector2(num4, component15.offsetMin.y);
				component15.offsetMax = new Vector2(0f - num5, component15.offsetMax.y);
				component16.horizontal = false;
				component16.vertical = true;
				component16.scrollSensitivity = 0.111821085f * _panelHeight * 0.5f;
				component16.movementType = (MovementType)2;
				component16.inertia = true;
				component16.decelerationRate = 0.16f;
				component16.elasticity = 0.1f;
				GameObject obj8 = CreateUIObject("Viewport", typeof(RectTransform), typeof(RectMask2D), typeof(Image));
				RectTransform component17 = obj8.GetComponent<RectTransform>();
				Image component18 = obj8.GetComponent<Image>();
				((Transform)component17).SetParent((Transform)(object)component15, false);
				component17.anchorMin = Vector2.zero;
				component17.anchorMax = Vector2.one;
				component17.sizeDelta = Vector2.zero;
				component16.viewport = component17;
				((Graphic)component18).color = Color.clear;
				((Graphic)component18).raycastTarget = false;
				GameObject obj9 = CreateUIObject("Content", typeof(RectTransform), typeof(VerticalLayoutGroup), typeof(ContentSizeFitter), typeof(CanvasGroup));
				RectTransform component19 = obj9.GetComponent<RectTransform>();
				((Transform)component19).SetParent((Transform)(object)component17, false);
				component19.anchorMin = new Vector2(0f, 1f);
				component19.anchorMax = Vector2.one;
				component19.pivot = new Vector2(0.5f, 1f);
				component19.anchoredPosition = Vector2.zero;
				component19.sizeDelta = Vector2.zero;
				component16.content = component19;
				_recipeListContent = component19;
				VerticalLayoutGroup component20 = obj9.GetComponent<VerticalLayoutGroup>();
				((LayoutGroup)component20).padding = new RectOffset(Mathf.RoundToInt(1f / 55f * _panelWidth), Mathf.RoundToInt(1f / 55f * _panelWidth), num10, num10);
				((HorizontalOrVerticalLayoutGroup)component20).spacing = 0f * _panelHeight;
				((LayoutGroup)component20).childAlignment = (TextAnchor)1;
				((HorizontalOrVerticalLayoutGroup)component20).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)component20).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)component20).childForceExpandHeight = false;
				((HorizontalOrVerticalLayoutGroup)component20).childForceExpandWidth = true;
				ContentSizeFitter component21 = obj9.GetComponent<ContentSizeFitter>();
				component21.verticalFit = (FitMode)2;
				component21.horizontalFit = (FitMode)0;
				_skeletonBuilt = true;
			}
		}

		internal static GameObject CreateRecipeRow(RectTransform parent, CraftPlanner.CraftableEntry entry)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Expected O, but got Unknown
			if ((Object)(object)_recipeRowTemplate == (Object)null)
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(_recipeRowTemplate, (Transform)(object)parent);
			((Object)val).name = "RecipeRow";
			val.SetActive(true);
			RecipeRowRuntime runtime = val.GetComponent<RecipeRowRuntime>();
			if ((Object)(object)runtime == (Object)null)
			{
				_log.LogError((object)"CreateRecipeRow: RecipeRowRuntime component missing on template.");
				return val;
			}
			runtime.Entry = entry;
			runtime.IsExpanded = false;
			if ((Object)(object)runtime.ItemLabel != (Object)null)
			{
				((TMP_Text)runtime.ItemLabel).text = GetEntryDisplayName(entry);
				((Graphic)runtime.ItemLabel).color = GetEntryColor(entry);
			}
			if ((Object)(object)runtime.DepthText != (Object)null)
			{
				((TMP_Text)runtime.DepthText).text = $" Min Depth: {entry.MinDepth}";
			}
			if ((Object)(object)runtime.PathsText != (Object)null)
			{
				((TMP_Text)runtime.PathsText).text = $"Paths: {entry.Chains.Count}";
			}
			if ((Object)(object)runtime.ResultIcon != (Object)null)
			{
				Sprite icon = GetIcon(entry.ResultIndex);
				if ((Object)(object)icon != (Object)null)
				{
					runtime.ResultIcon.sprite = icon;
					((Graphic)runtime.ResultIcon).color = Color.white;
				}
				else
				{
					runtime.ResultIcon.sprite = null;
					((Graphic)runtime.ResultIcon).color = new Color(1f, 1f, 1f, 0.1f);
				}
			}
			if ((Object)(object)runtime.ResultStackText != (Object)null)
			{
				if (entry.ResultCount > 1)
				{
					((TMP_Text)runtime.ResultStackText).text = entry.ResultCount.ToString();
					((Component)runtime.ResultStackText).gameObject.SetActive(true);
				}
				else
				{
					((Component)runtime.ResultStackText).gameObject.SetActive(false);
				}
			}
			if ((Object)(object)runtime.RowTopButton != (Object)null)
			{
				((UnityEventBase)runtime.RowTopButton.onClick).RemoveAllListeners();
				((UnityEvent)runtime.RowTopButton.onClick).AddListener((UnityAction)delegate
				{
					ToggleRecipeRow(runtime);
				});
			}
			if ((Object)(object)runtime.DropdownLayoutElement != (Object)null)
			{
				runtime.DropdownLayoutElement.preferredHeight = 0f;
			}
			return val;
		}

		private static GameObject CreatePathRow(RectTransform parent, CraftPlanner.RecipeChain chain, RecipeRowRuntime owner)
		{
			//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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_pathRowTemplate == (Object)null)
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(_pathRowTemplate, (Transform)(object)parent);
			((Object)val).name = "PathRow";
			val.SetActive(true);
			PathRowRuntime component = val.GetComponent<PathRowRuntime>();
			if ((Object)(object)component != (Object)null)
			{
				component.Init(owner, chain);
			}
			else
			{
				_log.LogError((object)"PathRowTemplate missing PathRowRuntime component.");
			}
			if (chain.PhysicalCostSparse != null)
			{
				Ingredient[] physicalCostSparse = chain.PhysicalCostSparse;
				for (int i = 0; i < physicalCostSparse.Length; i++)
				{
					Ingredient ingredient = physicalCostSparse[i];
					Sprite icon = GetIcon(ingredient.UnifiedIndex);
					if ((Object)(object)icon != (Object)null)
					{
						CreateIngredientSlot((Transform)(object)component.VisualRect, icon, ingredient.Count);
					}
				}
			}
			if (chain.DroneCostSparse != null)
			{
				Ingredient[] physicalCostSparse = chain.DroneCostSparse;
				for (int i = 0; i < physicalCostSparse.Length; i++)
				{
					Ingredient ingredient2 = physicalCostSparse[i];
					DroneIndex scrapCandidate = InventoryTracker.GetScrapCandidate(ingredient2.UnifiedIndex);
					if ((int)scrapCandidate != -1)
					{
						Sprite droneIcon = GetDroneIcon(scrapCandidate);
						if ((Object)(object)droneIcon != (Object)null)
						{
							CreateIngredientSlot((Transform)(object)component.VisualRect, droneIcon, ingredient2.Count);
						}
					}
				}
			}
			return val;
		}

		private static void CreateIngredientSlot(Transform parentRow, Sprite icon, int count)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_ingredientSlotTemplate == (Object)null)
			{
				return;
			}
			GameObject obj = Object.Instantiate<GameObject>(_ingredientSlotTemplate, parentRow);
			((Object)obj).name = "IngredientSlot";
			obj.SetActive(true);
			Transform obj2 = obj.transform.Find("Background/Icon");
			Image val = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null);
			if ((Object)(object)val != (Object)null)
			{
				val.sprite = icon;
				((Graphic)val).raycastTarget = false;
				((Graphic)val).color = Color.white;
			}
			Transform obj3 = obj.transform.Find("Background/StackText");
			TextMeshProUGUI val2 = ((obj3 != null) ? ((Component)obj3).GetComponent<TextMeshProUGUI>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				if (count > 1)
				{
					((Component)val2).gameObject.SetActive(true);
					((TMP_Text)val2).text = count.ToString();
				}
				else
				{
					((Component)val2).gameObject.SetActive(false);
				}
			}
		}

		private static void BuildRecipeRowTemplate()
		{
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0654: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0680: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0737: Unknown result type (might be due to invalid IL or missing references)
			//IL_074d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0763: Unknown result type (might be due to invalid IL or missing references)
			//IL_0777: Unknown result type (might be due to invalid IL or missing references)
			//IL_078a: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e2: Unknown result type