Decompiled source of OneClickCrafting v1.2.5

BepInEx/plugins/OneClickCrafting.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OneClickCrafting")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OneClickCrafting")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0082065B-72A9-4638-88F3-1A0ABE86AA6B")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public static class AnvilMechineAutoMake
{
	[CompilerGenerated]
	private sealed class <DelayedCraft>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlockAnvil machine;

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

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

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

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

		private bool MoveNext()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				machine.CraftItemServerRpc(default(ServerRpcParams));
				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();
		}
	}

	public static bool start(RecipeSO recipe, List<BlockAnvil> blockAnvils, UIManager uiManagerInstance)
	{
		PlayerInventory component = ((Component)NetworkManager.Singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
		for (int num = blockAnvils.Count - 1; num >= 0; num--)
		{
			BlockAnvil val = blockAnvils[num];
			if (!((Object)val).name.Contains("Clone"))
			{
				blockAnvils.RemoveAt(num);
			}
			List<Item> itemsInTrigger = GameManager.Instance.GetItemsInTrigger(val.inputTrigger);
			if (itemsInTrigger.Count > 0)
			{
				blockAnvils.RemoveAt(num);
			}
		}
		Block val2 = null;
		if (blockAnvils != null && blockAnvils.Count > 0)
		{
			foreach (RecipeSO recipe2 in blockAnvils[0].recipes)
			{
				if (recipe2.output.id == recipe.output.id)
				{
					if (blockAnvils.Count == 0)
					{
						uiManagerInstance.ShowBankruptcyWarningDialog("找不到空闲的机器,请检查机器是否将成品取出(doesn't find a machine, please check whether the machine has taken the finished product)");
						return true;
					}
					val2 = (Block)(object)CheckRecipe.GetMachine<BlockAnvil>(component, recipe, blockAnvils, blockAnvils[0].recipes);
				}
			}
		}
		if ((Object)(object)val2 != (Object)null)
		{
			BlockAnvil val3 = (BlockAnvil)(object)((val2 is BlockAnvil) ? val2 : null);
			if (!CheckRecipe.CheckAndConsumeIngredients(recipe, component, uiManagerInstance))
			{
				return false;
			}
			BoxCollider inputTrigger = val3.inputTrigger;
			CheckRecipe.SpawnItemsForRecipe(recipe, inputTrigger);
			((MonoBehaviour)uiManagerInstance).StartCoroutine(DelayedCraft(val3));
			return true;
		}
		return false;
	}

	[IteratorStateMachine(typeof(<DelayedCraft>d__1))]
	private static IEnumerator DelayedCraft(BlockAnvil machine)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedCraft>d__1(0)
		{
			machine = machine
		};
	}
}
public static class CheckRecipe
{
	public static bool CheckAndConsumeIngredients(RecipeSO recipe, PlayerInventory bag, UIManager uiManager)
	{
		//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_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: 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_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: 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_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		Dictionary<long, int> dictionary = new Dictionary<long, int>();
		Dictionary<long, int> dictionary2 = new Dictionary<long, int>();
		foreach (Ingredient ingredient in recipe.ingredients)
		{
			if (dictionary.ContainsKey(ingredient.itemSO.id))
			{
				dictionary[ingredient.itemSO.id] += ingredient.amount * ingredient.itemSO.amount;
				dictionary2[ingredient.itemSO.id] += ingredient.amount * ingredient.itemSO.amount;
			}
			else
			{
				dictionary.Add(ingredient.itemSO.id, ingredient.amount * ingredient.itemSO.amount);
				dictionary2.Add(ingredient.itemSO.id, ingredient.amount * ingredient.itemSO.amount);
			}
		}
		foreach (InventorySlot slot in bag.slots)
		{
			if (dictionary.ContainsKey(slot.itemId))
			{
				int num = dictionary[slot.itemId];
				if (num > slot.amount)
				{
					dictionary[slot.itemId] -= slot.amount;
				}
				else if (num <= slot.amount)
				{
					dictionary.Remove(slot.itemId);
				}
			}
		}
		if (dictionary.Count == 0)
		{
			for (int num2 = dictionary2.Count - 1; num2 >= 0; num2--)
			{
				KeyValuePair<long, int> keyValuePair = dictionary2.ElementAt(num2);
				for (int i = 0; i < bag.slots.Count; i++)
				{
					InventorySlot val = bag.slots[i];
					if (val.itemId == keyValuePair.Key)
					{
						if (val.amount <= keyValuePair.Value)
						{
							dictionary2[keyValuePair.Key] -= val.amount;
							bag.slots[i] = new InventorySlot
							{
								itemId = -1L,
								amount = -1,
								cost = -1,
								dayCounter = -1
							};
							keyValuePair = dictionary2.ElementAt(num2);
						}
						else if (val.amount > keyValuePair.Value)
						{
							dictionary2.Remove(keyValuePair.Key);
							bag.slots[i] = new InventorySlot
							{
								itemId = val.itemId,
								amount = val.amount - keyValuePair.Value,
								cost = val.cost,
								dayCounter = val.dayCounter
							};
							keyValuePair = default(KeyValuePair<long, int>);
						}
					}
				}
			}
			return true;
		}
		string text = "背包材料不足,缺少的食材为:\n";
		for (int j = 0; j < dictionary.Count; j++)
		{
			ItemSO itemById = GameManager.Instance.GetItemById(dictionary.Keys.ElementAt(j));
			string localizedString = LocalizationSettings.StringDatabase.GetLocalizedString(TableReference.op_Implicit("Translations"), TableEntryReference.op_Implicit(itemById.itemName), (Locale)null, (FallbackBehavior)0, Array.Empty<object>());
			text += $"{localizedString} x{dictionary.Values.ElementAt(j) / itemById.amount}  ";
		}
		uiManager.ShowBankruptcyWarningDialog(text);
		return false;
	}

	public static void SpawnItemsForRecipe(RecipeSO recipe, BoxCollider inputTrigger)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: 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)
		Bounds bounds = ((Collider)inputTrigger).bounds;
		Vector3 center = ((Bounds)(ref bounds)).center;
		foreach (Ingredient ingredient in recipe.ingredients)
		{
			for (int i = 0; i < ingredient.amount; i++)
			{
				GameManager.Instance.SpawnItemAtPositionServerRpc(ingredient.itemSO.id, center, false, ingredient.itemSO.amount, ingredient.itemSO.basePrice * ingredient.amount, 0);
			}
		}
	}

	public static T GetMachine<T>(PlayerInventory bag, RecipeSO recipe, List<T> machines, List<RecipeSO> machinesRecipe) where T : Block
	{
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		bool flag = false;
		float num = 0f;
		T result = default(T);
		foreach (T machine in machines)
		{
			foreach (RecipeSO item in machinesRecipe)
			{
				if (((Object)item).name.Equals(((Object)recipe).name))
				{
					float num2 = Vector3.Distance(((Component)(object)machine).transform.position, ((Component)bag).transform.position);
					if (!flag || num2 < num)
					{
						flag = true;
						result = machine;
						num = num2;
					}
				}
			}
		}
		return result;
	}
}
public static class CheeseMechineAutoMake
{
	[CompilerGenerated]
	private sealed class <DelayedCraft>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlockCheeseMachine machine;

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

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

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

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

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				machine.StartServerRpc();
				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();
		}
	}

	public static bool start(RecipeSO recipe, List<BlockCheeseMachine> cheeseMachines, UIManager uiManagerInstance)
	{
		PlayerInventory component = ((Component)NetworkManager.Singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
		List<long> list = new List<long>();
		for (int num = cheeseMachines.Count - 1; num >= 0; num--)
		{
			BlockCheeseMachine val = cheeseMachines[num];
			if (!((Object)val).name.Contains("Clone"))
			{
				cheeseMachines.RemoveAt(num);
			}
			else
			{
				if (list.Count == 0)
				{
					foreach (RecipeSO recipe2 in val.recipes)
					{
						list.Add(recipe2.output.id);
					}
				}
				FieldInfo fieldInfo = AccessTools.Field(typeof(BlockCheeseMachine), "currentOutput");
				NetworkVariable<long> val2 = (NetworkVariable<long>)fieldInfo.GetValue(val);
				if (val2.Value != -1)
				{
					cheeseMachines.RemoveAt(num);
				}
				List<Item> itemsInTrigger = GameManager.Instance.GetItemsInTrigger(val.inputTrigger);
				if (itemsInTrigger.Count > 0)
				{
					cheeseMachines.RemoveAt(num);
				}
			}
		}
		Block val3 = null;
		if (cheeseMachines != null && cheeseMachines.Count > 0)
		{
			foreach (RecipeSO recipe3 in cheeseMachines[0].recipes)
			{
				if (recipe3.output.id == recipe.output.id)
				{
					val3 = (Block)(object)CheckRecipe.GetMachine<BlockCheeseMachine>(component, recipe, cheeseMachines, cheeseMachines[0].recipes);
				}
			}
		}
		else if ((Object)(object)val3 == (Object)null && list.Contains(recipe.output.id))
		{
			uiManagerInstance.ShowBankruptcyWarningDialog("找不到空闲的机器,请检查机器是否将成品取出(doesn't find a machine, please check whether the machine has taken the finished product)");
			return true;
		}
		if ((Object)(object)val3 != (Object)null)
		{
			BlockCheeseMachine val4 = (BlockCheeseMachine)(object)((val3 is BlockCheeseMachine) ? val3 : null);
			if (!CheckRecipe.CheckAndConsumeIngredients(recipe, component, uiManagerInstance))
			{
				return false;
			}
			BoxCollider inputTrigger = val4.inputTrigger;
			CheckRecipe.SpawnItemsForRecipe(recipe, inputTrigger);
			((MonoBehaviour)uiManagerInstance).StartCoroutine(DelayedCraft(val4));
			return true;
		}
		return false;
	}

	[IteratorStateMachine(typeof(<DelayedCraft>d__1))]
	private static IEnumerator DelayedCraft(BlockCheeseMachine machine)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedCraft>d__1(0)
		{
			machine = machine
		};
	}
}
public static class JamMechineAutoMake
{
	[CompilerGenerated]
	private sealed class <DelayedCraft>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlockJamMachine machine;

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

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

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

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

		private bool MoveNext()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				machine.CraftItemServerRpc(default(ServerRpcParams));
				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();
		}
	}

	public static bool start(RecipeSO recipe, List<BlockJamMachine> blockJamMachines, UIManager uiManagerInstance)
	{
		PlayerInventory component = ((Component)NetworkManager.Singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
		List<long> list = new List<long>();
		for (int num = blockJamMachines.Count - 1; num >= 0; num--)
		{
			BlockJamMachine val = blockJamMachines[num];
			if (!((Object)val).name.Contains("Clone"))
			{
				blockJamMachines.RemoveAt(num);
			}
			else
			{
				if (list.Count == 0)
				{
					foreach (RecipeSO recipe2 in val.recipes)
					{
						list.Add(recipe2.output.id);
					}
				}
				FieldInfo fieldInfo = AccessTools.Field(typeof(BlockJamMachine), "isPreparing");
				NetworkVariable<bool> val2 = (NetworkVariable<bool>)fieldInfo.GetValue(val);
				if (val2.Value)
				{
					blockJamMachines.RemoveAt(num);
				}
				List<Item> itemsInTrigger = GameManager.Instance.GetItemsInTrigger(val.inputTrigger);
				if (itemsInTrigger.Count > 0)
				{
					blockJamMachines.RemoveAt(num);
				}
			}
		}
		Block val3 = null;
		if (blockJamMachines != null && blockJamMachines.Count > 0)
		{
			foreach (RecipeSO recipe3 in blockJamMachines[0].recipes)
			{
				if (recipe3.output.id == recipe.output.id)
				{
					val3 = (Block)(object)CheckRecipe.GetMachine<BlockJamMachine>(component, recipe, blockJamMachines, blockJamMachines[0].recipes);
				}
			}
		}
		else if ((Object)(object)val3 == (Object)null && list.Contains(recipe.output.id))
		{
			uiManagerInstance.ShowBankruptcyWarningDialog("找不到空闲的机器,请检查机器是否将成品取出(doesn't find a machine, please check whether the machine has taken the finished product)");
			return true;
		}
		if ((Object)(object)val3 != (Object)null)
		{
			BlockJamMachine val4 = (BlockJamMachine)(object)((val3 is BlockJamMachine) ? val3 : null);
			if (!CheckRecipe.CheckAndConsumeIngredients(recipe, component, uiManagerInstance))
			{
				return false;
			}
			BoxCollider inputTrigger = val4.inputTrigger;
			CheckRecipe.SpawnItemsForRecipe(recipe, inputTrigger);
			((MonoBehaviour)uiManagerInstance).StartCoroutine(DelayedCraft(val4));
			return true;
		}
		return false;
	}

	[IteratorStateMachine(typeof(<DelayedCraft>d__1))]
	private static IEnumerator DelayedCraft(BlockJamMachine machine)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedCraft>d__1(0)
		{
			machine = machine
		};
	}
}
public static class MaceratorMechineAutoMake
{
	[CompilerGenerated]
	private sealed class <DelayedCraft>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlockAlcoholMachine machine;

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

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

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

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

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				machine.StartServerRpc();
				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();
		}
	}

	public static bool start(RecipeSO recipe, List<BlockAlcoholMachine> blockAlcoholMachines, UIManager uiManagerInstance)
	{
		PlayerInventory component = ((Component)NetworkManager.Singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
		List<long> list = new List<long>();
		for (int num = blockAlcoholMachines.Count - 1; num >= 0; num--)
		{
			BlockAlcoholMachine val = blockAlcoholMachines[num];
			if (!((Object)val).name.Contains("Clone"))
			{
				blockAlcoholMachines.RemoveAt(num);
			}
			else
			{
				if (list.Count == 0)
				{
					foreach (RecipeSO recipe2 in val.recipes)
					{
						list.Add(recipe2.output.id);
					}
				}
				FieldInfo fieldInfo = AccessTools.Field(typeof(BlockAlcoholMachine), "currentOutput");
				NetworkVariable<long> val2 = (NetworkVariable<long>)fieldInfo.GetValue(val);
				if (val2.Value != -1)
				{
					blockAlcoholMachines.RemoveAt(num);
				}
				List<Item> itemsInTrigger = GameManager.Instance.GetItemsInTrigger(val.inputTrigger);
				if (itemsInTrigger.Count > 0)
				{
					blockAlcoholMachines.RemoveAt(num);
				}
			}
		}
		Block val3 = null;
		if (blockAlcoholMachines != null && blockAlcoholMachines.Count > 0)
		{
			foreach (RecipeSO recipe3 in blockAlcoholMachines[0].recipes)
			{
				if (recipe3.output.id == recipe.output.id)
				{
					val3 = (Block)(object)CheckRecipe.GetMachine<BlockAlcoholMachine>(component, recipe, blockAlcoholMachines, blockAlcoholMachines[0].recipes);
				}
			}
		}
		else if ((Object)(object)val3 == (Object)null && list.Contains(recipe.output.id))
		{
			uiManagerInstance.ShowBankruptcyWarningDialog("找不到空闲的机器,请检查机器是否将成品取出(doesn't find a machine, please check whether the machine has taken the finished product)");
			return true;
		}
		if ((Object)(object)val3 != (Object)null)
		{
			BlockAlcoholMachine val4 = (BlockAlcoholMachine)(object)((val3 is BlockAlcoholMachine) ? val3 : null);
			if (!CheckRecipe.CheckAndConsumeIngredients(recipe, component, uiManagerInstance))
			{
				return false;
			}
			BoxCollider inputTrigger = val4.inputTrigger;
			CheckRecipe.SpawnItemsForRecipe(recipe, inputTrigger);
			((MonoBehaviour)uiManagerInstance).StartCoroutine(DelayedCraft(val4));
			return true;
		}
		return false;
	}

	[IteratorStateMachine(typeof(<DelayedCraft>d__1))]
	private static IEnumerator DelayedCraft(BlockAlcoholMachine machine)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedCraft>d__1(0)
		{
			machine = machine
		};
	}
}
public static class MeatCutterMechineAutoMake
{
	[CompilerGenerated]
	private sealed class <DelayedCraft>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlockMeatCutter machine;

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

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

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

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

		private bool MoveNext()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				machine.CraftItemServerRpc(default(ServerRpcParams));
				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();
		}
	}

	public static bool start(RecipeSO recipe, List<BlockMeatCutter> blockMeatCutters, UIManager uiManagerInstance)
	{
		PlayerInventory component = ((Component)NetworkManager.Singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
		for (int num = blockMeatCutters.Count - 1; num >= 0; num--)
		{
			BlockMeatCutter val = blockMeatCutters[num];
			if (!((Object)val).name.Contains("Clone"))
			{
				blockMeatCutters.RemoveAt(num);
			}
			List<Item> itemsInTrigger = GameManager.Instance.GetItemsInTrigger(val.inputTrigger);
			if (itemsInTrigger.Count > 0)
			{
				blockMeatCutters.RemoveAt(num);
			}
		}
		Block val2 = null;
		if (blockMeatCutters != null && blockMeatCutters.Count > 0)
		{
			foreach (RecipeSO recipe2 in blockMeatCutters[0].recipes)
			{
				if (recipe2.output.id == recipe.output.id)
				{
					if (blockMeatCutters.Count == 0)
					{
						uiManagerInstance.ShowBankruptcyWarningDialog("找不到空闲的机器,请检查机器是否将成品取出(doesn't find a machine, please check whether the machine has taken the finished product)");
						return true;
					}
					val2 = (Block)(object)CheckRecipe.GetMachine<BlockMeatCutter>(component, recipe, blockMeatCutters, blockMeatCutters[0].recipes);
				}
			}
		}
		if ((Object)(object)val2 != (Object)null)
		{
			BlockMeatCutter val3 = (BlockMeatCutter)(object)((val2 is BlockMeatCutter) ? val2 : null);
			if (!CheckRecipe.CheckAndConsumeIngredients(recipe, component, uiManagerInstance))
			{
				return false;
			}
			BoxCollider inputTrigger = val3.inputTrigger;
			CheckRecipe.SpawnItemsForRecipe(recipe, inputTrigger);
			((MonoBehaviour)uiManagerInstance).StartCoroutine(DelayedCraft(val3));
			return true;
		}
		return false;
	}

	[IteratorStateMachine(typeof(<DelayedCraft>d__1))]
	private static IEnumerator DelayedCraft(BlockMeatCutter machine)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedCraft>d__1(0)
		{
			machine = machine
		};
	}
}
public static class MeltingMechineAutoMake
{
	[CompilerGenerated]
	private sealed class <DelayedCraft>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlockMeltingMachine machine;

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

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

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

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

		private bool MoveNext()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				machine.CraftItemServerRpc(default(ServerRpcParams));
				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();
		}
	}

	public static bool start(RecipeSO recipe, List<BlockMeltingMachine> blockMeltingMachines, UIManager uiManagerInstance)
	{
		PlayerInventory component = ((Component)NetworkManager.Singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
		List<long> list = new List<long>();
		for (int num = blockMeltingMachines.Count - 1; num >= 0; num--)
		{
			BlockMeltingMachine val = blockMeltingMachines[num];
			if (!((Object)val).name.Contains("Clone"))
			{
				blockMeltingMachines.RemoveAt(num);
			}
			else
			{
				if (list.Count == 0)
				{
					foreach (RecipeSO recipe2 in val.recipes)
					{
						list.Add(recipe2.output.id);
					}
				}
				blockMeltingMachines[num].bakingTime = 1.5f;
				FieldInfo fieldInfo = AccessTools.Field(typeof(BlockMeltingMachine), "isCooking");
				NetworkVariable<bool> val2 = (NetworkVariable<bool>)fieldInfo.GetValue(val);
				if (val2.Value)
				{
					blockMeltingMachines.RemoveAt(num);
				}
				List<Item> itemsInTrigger = GameManager.Instance.GetItemsInTrigger(val.inputTrigger);
				if (itemsInTrigger.Count > 0)
				{
					blockMeltingMachines.RemoveAt(num);
				}
			}
		}
		Block val3 = null;
		if (blockMeltingMachines != null && blockMeltingMachines.Count > 0)
		{
			foreach (RecipeSO recipe3 in blockMeltingMachines[0].recipes)
			{
				if (recipe3.output.id == recipe.output.id)
				{
					val3 = (Block)(object)CheckRecipe.GetMachine<BlockMeltingMachine>(component, recipe, blockMeltingMachines, blockMeltingMachines[0].recipes);
				}
			}
		}
		else if ((Object)(object)val3 == (Object)null && list.Contains(recipe.output.id))
		{
			uiManagerInstance.ShowBankruptcyWarningDialog("找不到空闲的机器,请检查机器是否将成品取出(doesn't find a machine, please check whether the machine has taken the finished product)");
			return true;
		}
		if ((Object)(object)val3 != (Object)null)
		{
			BlockMeltingMachine val4 = (BlockMeltingMachine)(object)((val3 is BlockMeltingMachine) ? val3 : null);
			if (!CheckRecipe.CheckAndConsumeIngredients(recipe, component, uiManagerInstance))
			{
				return false;
			}
			BoxCollider inputTrigger = val4.inputTrigger;
			CheckRecipe.SpawnItemsForRecipe(recipe, inputTrigger);
			((MonoBehaviour)uiManagerInstance).StartCoroutine(DelayedCraft(val4));
			return true;
		}
		return false;
	}

	[IteratorStateMachine(typeof(<DelayedCraft>d__1))]
	private static IEnumerator DelayedCraft(BlockMeltingMachine machine)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedCraft>d__1(0)
		{
			machine = machine
		};
	}
}
public static class OvenMechineAutoMake
{
	[CompilerGenerated]
	private sealed class <DelayedCraft>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlockOven machine;

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

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

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

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

		private bool MoveNext()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				machine.CraftItemServerRpc(default(ServerRpcParams));
				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();
		}
	}

	public static bool start(RecipeSO recipe, List<BlockOven> blockOvens, UIManager uiManagerInstance)
	{
		PlayerInventory component = ((Component)NetworkManager.Singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
		List<long> list = new List<long>();
		for (int num = blockOvens.Count - 1; num >= 0; num--)
		{
			BlockOven val = blockOvens[num];
			if (!((Object)val).name.Contains("Clone"))
			{
				blockOvens.RemoveAt(num);
			}
			else
			{
				if (list.Count == 0)
				{
					foreach (RecipeSO recipe2 in val.recipes)
					{
						list.Add(recipe2.output.id);
					}
				}
				FieldInfo fieldInfo = AccessTools.Field(typeof(BlockOven), "isCooking");
				NetworkVariable<bool> val2 = (NetworkVariable<bool>)fieldInfo.GetValue(val);
				if (val2.Value)
				{
					blockOvens.RemoveAt(num);
				}
				List<Item> itemsInTrigger = GameManager.Instance.GetItemsInTrigger(val.inputTrigger);
				if (itemsInTrigger.Count > 0)
				{
					blockOvens.RemoveAt(num);
				}
			}
		}
		Block val3 = null;
		if (blockOvens != null && blockOvens.Count > 0)
		{
			foreach (RecipeSO recipe3 in blockOvens[0].recipes)
			{
				if (recipe3.output.id == recipe.output.id)
				{
					val3 = (Block)(object)CheckRecipe.GetMachine<BlockOven>(component, recipe, blockOvens, blockOvens[0].recipes);
				}
			}
		}
		else if ((Object)(object)val3 == (Object)null && list.Contains(recipe.output.id))
		{
			uiManagerInstance.ShowBankruptcyWarningDialog("找不到空闲的机器,请检查机器是否将成品取出(doesn't find a machine, please check whether the machine has taken the finished product)");
			return true;
		}
		if ((Object)(object)val3 != (Object)null)
		{
			BlockOven val4 = (BlockOven)(object)((val3 is BlockOven) ? val3 : null);
			if (!CheckRecipe.CheckAndConsumeIngredients(recipe, component, uiManagerInstance))
			{
				return false;
			}
			BoxCollider inputTrigger = val4.inputTrigger;
			CheckRecipe.SpawnItemsForRecipe(recipe, inputTrigger);
			((MonoBehaviour)uiManagerInstance).StartCoroutine(DelayedCraft(val4));
			return true;
		}
		return false;
	}

	[IteratorStateMachine(typeof(<DelayedCraft>d__1))]
	private static IEnumerator DelayedCraft(BlockOven machine)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedCraft>d__1(0)
		{
			machine = machine
		};
	}
}
public static class PotionMechineAutoMake
{
	[CompilerGenerated]
	private sealed class <DelayedCraft>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlockPotionBoiler machine;

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

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

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

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

		private bool MoveNext()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				machine.CraftItemServerRpc(default(ServerRpcParams));
				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();
		}
	}

	public static bool start(RecipeSO recipe, List<BlockPotionBoiler> blockPotionBoilers, UIManager uiManagerInstance)
	{
		PlayerInventory component = ((Component)NetworkManager.Singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
		List<long> list = new List<long>();
		for (int num = blockPotionBoilers.Count - 1; num >= 0; num--)
		{
			BlockPotionBoiler val = blockPotionBoilers[num];
			if (!((Object)val).name.Contains("Clone"))
			{
				blockPotionBoilers.RemoveAt(num);
			}
			else
			{
				if (list.Count == 0)
				{
					foreach (RecipeSO recipe2 in val.recipes)
					{
						list.Add(recipe2.output.id);
					}
				}
				FieldInfo fieldInfo = AccessTools.Field(typeof(BlockPotionBoiler), "isCooking");
				NetworkVariable<bool> val2 = (NetworkVariable<bool>)fieldInfo.GetValue(val);
				if (val2.Value)
				{
					blockPotionBoilers.RemoveAt(num);
				}
				List<Item> itemsInTrigger = GameManager.Instance.GetItemsInTrigger(val.inputTrigger);
				if (itemsInTrigger.Count > 0)
				{
					blockPotionBoilers.RemoveAt(num);
				}
			}
		}
		Block val3 = null;
		if (blockPotionBoilers != null && blockPotionBoilers.Count > 0)
		{
			foreach (RecipeSO recipe3 in blockPotionBoilers[0].recipes)
			{
				if (recipe3.output.id == recipe.output.id)
				{
					val3 = (Block)(object)CheckRecipe.GetMachine<BlockPotionBoiler>(component, recipe, blockPotionBoilers, blockPotionBoilers[0].recipes);
				}
			}
		}
		else if ((Object)(object)val3 == (Object)null && list.Contains(recipe.output.id))
		{
			uiManagerInstance.ShowBankruptcyWarningDialog("找不到空闲的机器,请检查机器是否将成品取出(doesn't find a machine, please check whether the machine has taken the finished product)");
			return true;
		}
		if ((Object)(object)val3 != (Object)null)
		{
			BlockPotionBoiler val4 = (BlockPotionBoiler)(object)((val3 is BlockPotionBoiler) ? val3 : null);
			if (!CheckRecipe.CheckAndConsumeIngredients(recipe, component, uiManagerInstance))
			{
				return false;
			}
			BoxCollider inputTrigger = val4.inputTrigger;
			CheckRecipe.SpawnItemsForRecipe(recipe, inputTrigger);
			((MonoBehaviour)uiManagerInstance).StartCoroutine(DelayedCraft(val4));
			return true;
		}
		return false;
	}

	[IteratorStateMachine(typeof(<DelayedCraft>d__1))]
	private static IEnumerator DelayedCraft(BlockPotionBoiler machine)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedCraft>d__1(0)
		{
			machine = machine
		};
	}
}
[BepInPlugin("com.lan.OneClickCrafting", "一键制作", "1.2.5")]
public class OneClickCraftPlugin : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("com.lan.OneClickCrafting");
		val.PatchAll();
		Debug.LogWarning((object)"一键制作物品 --她说缝上都不给我");
	}
}
public static class RecipePanelState
{
	public static List<RecipeSO> CurrentRecipes { get; set; }

	public static int CurrentIndex { get; set; }

	public static UIManager CurrentUIManager { get; set; }
}
[HarmonyPatch(typeof(UIManager), "OpenRecipesPanel")]
public class Patch_OpenRecipesPanel_Prefix
{
	[HarmonyPrefix]
	private static void Prefix(UIManager __instance, List<RecipeSO> recipes)
	{
		if ((Object)(object)__instance == (Object)null || recipes == null)
		{
			RecipePanelState.CurrentRecipes = null;
			RecipePanelState.CurrentIndex = 0;
			RecipePanelState.CurrentUIManager = null;
		}
		else
		{
			RecipePanelState.CurrentRecipes = new List<RecipeSO>(recipes);
			RecipePanelState.CurrentIndex = 0;
			RecipePanelState.CurrentUIManager = __instance;
		}
	}
}
[HarmonyPatch(typeof(ListButton), "BuildButton")]
public class Patch_ListButton_BuildButton_Postfix
{
	private const string ButtonName = "OneClickCraftButton";

	[HarmonyPostfix]
	private static void Postfix(ListButton __instance)
	{
		GameObject gameObject = ((Component)__instance).gameObject;
		if (RecipePanelState.CurrentRecipes != null && !((Object)(object)RecipePanelState.CurrentUIManager == (Object)null) && RecipePanelState.CurrentIndex < RecipePanelState.CurrentRecipes.Count)
		{
			RecipeSO recipe = RecipePanelState.CurrentRecipes[RecipePanelState.CurrentIndex];
			UIManager currentUIManager = RecipePanelState.CurrentUIManager;
			Transform val = gameObject.transform.Find("OneClickCraftButton");
			if ((Object)(object)val != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)((Component)val).gameObject);
			}
			AddOneClickButton(gameObject, recipe, currentUIManager);
			RecipePanelState.CurrentIndex++;
		}
	}

	private static void AddOneClickButton(GameObject listButtonObj, RecipeSO recipe, UIManager uiManagerInstance)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Expected O, but got Unknown
		//IL_0168: 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)
		GameObject val = new GameObject("OneClickCraftButton");
		val.transform.SetParent(listButtonObj.transform, false);
		val.transform.localPosition = new Vector3(250f, 20f, 0f);
		Button val2 = val.AddComponent<Button>();
		ColorBlock colors = ((Selectable)val2).colors;
		((ColorBlock)(ref colors)).normalColor = new Color(0.2f, 0.8f, 0.2f, 1f);
		((ColorBlock)(ref colors)).highlightedColor = new Color(0.3f, 0.9f, 0.3f, 1f);
		((ColorBlock)(ref colors)).pressedColor = new Color(0.1f, 0.7f, 0.1f, 1f);
		((Selectable)val2).colors = colors;
		((Selectable)val2).transition = (Transition)1;
		((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
		{
			TryCraftRecipe(recipe, uiManagerInstance);
		});
		Text val3 = val.AddComponent<Text>();
		val3.text = "一键制作";
		val3.fontSize = 14;
		val3.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
		if ((Object)(object)val3.font == (Object)null)
		{
			val3.font = Font.CreateDynamicFontFromOSFont("Arial", 14);
			if ((Object)(object)val3.font == (Object)null)
			{
				Debug.LogError((object)"无法加载 Arial 字体!");
			}
		}
		((Graphic)val3).color = Color.white;
		val3.alignment = (TextAnchor)4;
		RectTransform component = val.GetComponent<RectTransform>();
		component.sizeDelta = new Vector2(80f, 30f);
	}

	private static void TryCraftRecipe(RecipeSO recipe, UIManager uiManagerInstance)
	{
		uiManagerInstance.CloseTopPanel();
		List<BlockJamMachine> blockJamMachines = Resources.FindObjectsOfTypeAll<BlockJamMachine>().ToList();
		if (JamMechineAutoMake.start(recipe, blockJamMachines, uiManagerInstance))
		{
			return;
		}
		List<BlockCheeseMachine> cheeseMachines = Resources.FindObjectsOfTypeAll<BlockCheeseMachine>().ToList();
		if (CheeseMechineAutoMake.start(recipe, cheeseMachines, uiManagerInstance))
		{
			return;
		}
		List<BlockSpiceMachine> spiceMachines = Resources.FindObjectsOfTypeAll<BlockSpiceMachine>().ToList();
		if (SpiceMechineAutoMake.start(recipe, spiceMachines, uiManagerInstance))
		{
			return;
		}
		List<BlockPotionBoiler> blockPotionBoilers = Resources.FindObjectsOfTypeAll<BlockPotionBoiler>().ToList();
		if (PotionMechineAutoMake.start(recipe, blockPotionBoilers, uiManagerInstance))
		{
			return;
		}
		List<BlockOven> blockOvens = Resources.FindObjectsOfTypeAll<BlockOven>().ToList();
		if (OvenMechineAutoMake.start(recipe, blockOvens, uiManagerInstance))
		{
			return;
		}
		List<BlockAlcoholMachine> blockAlcoholMachines = Resources.FindObjectsOfTypeAll<BlockAlcoholMachine>().ToList();
		if (MaceratorMechineAutoMake.start(recipe, blockAlcoholMachines, uiManagerInstance))
		{
			return;
		}
		List<BlockMeatCutter> blockMeatCutters = Resources.FindObjectsOfTypeAll<BlockMeatCutter>().ToList();
		if (MeatCutterMechineAutoMake.start(recipe, blockMeatCutters, uiManagerInstance))
		{
			return;
		}
		List<BlockAnvil> blockAnvils = Resources.FindObjectsOfTypeAll<BlockAnvil>().ToList();
		if (!AnvilMechineAutoMake.start(recipe, blockAnvils, uiManagerInstance))
		{
			List<BlockMeltingMachine> blockMeltingMachines = Resources.FindObjectsOfTypeAll<BlockMeltingMachine>().ToList();
			if (!MeltingMechineAutoMake.start(recipe, blockMeltingMachines, uiManagerInstance))
			{
			}
		}
	}
}
public static class SpiceMechineAutoMake
{
	[CompilerGenerated]
	private sealed class <DelayedCraft>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlockSpiceMachine machine;

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

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

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

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

		private bool MoveNext()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				machine.CraftItemServerRpc(default(ServerRpcParams));
				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();
		}
	}

	public static bool start(RecipeSO recipe, List<BlockSpiceMachine> spiceMachines, UIManager uiManagerInstance)
	{
		PlayerInventory component = ((Component)NetworkManager.Singleton.LocalClient.PlayerObject).GetComponent<PlayerInventory>();
		List<long> list = new List<long>();
		for (int num = spiceMachines.Count - 1; num >= 0; num--)
		{
			BlockSpiceMachine val = spiceMachines[num];
			if (!((Object)val).name.Contains("Clone"))
			{
				spiceMachines.RemoveAt(num);
			}
			else
			{
				if (list.Count == 0)
				{
					foreach (RecipeSO recipe2 in val.recipes)
					{
						list.Add(recipe2.output.id);
					}
				}
				FieldInfo fieldInfo = AccessTools.Field(typeof(BlockSpiceMachine), "isCooking");
				NetworkVariable<bool> val2 = (NetworkVariable<bool>)fieldInfo.GetValue(val);
				if (val2.Value)
				{
					spiceMachines.RemoveAt(num);
				}
				List<Item> itemsInTrigger = GameManager.Instance.GetItemsInTrigger(val.inputTrigger);
				if (itemsInTrigger.Count > 0)
				{
					spiceMachines.RemoveAt(num);
				}
			}
		}
		Block val3 = null;
		if (spiceMachines != null && spiceMachines.Count > 0)
		{
			foreach (RecipeSO recipe3 in spiceMachines[0].recipes)
			{
				if (recipe3.output.id == recipe.output.id)
				{
					val3 = (Block)(object)CheckRecipe.GetMachine<BlockSpiceMachine>(component, recipe, spiceMachines, spiceMachines[0].recipes);
				}
			}
		}
		else if ((Object)(object)val3 == (Object)null && list.Contains(recipe.output.id))
		{
			uiManagerInstance.ShowBankruptcyWarningDialog("找不到空闲的机器,请检查机器是否将成品取出(doesn't find a machine, please check whether the machine has taken the finished product)");
			return true;
		}
		if ((Object)(object)val3 != (Object)null)
		{
			BlockSpiceMachine val4 = (BlockSpiceMachine)(object)((val3 is BlockSpiceMachine) ? val3 : null);
			if (!CheckRecipe.CheckAndConsumeIngredients(recipe, component, uiManagerInstance))
			{
				return false;
			}
			BoxCollider inputTrigger = val4.inputTrigger;
			CheckRecipe.SpawnItemsForRecipe(recipe, inputTrigger);
			((MonoBehaviour)uiManagerInstance).StartCoroutine(DelayedCraft(val4));
			return true;
		}
		return false;
	}

	[IteratorStateMachine(typeof(<DelayedCraft>d__1))]
	private static IEnumerator DelayedCraft(BlockSpiceMachine machine)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedCraft>d__1(0)
		{
			machine = machine
		};
	}
}