Decompiled source of ProduceMoreIL2CPP v1.0.4

Mods\ProduceMoreIL2CPP.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Il2CppFishNet;
using Il2CppFishNet.Connection;
using Il2CppFishNet.Object;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.AvatarFramework.Equipping;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Employees;
using Il2CppScheduleOne.EntityFramework;
using Il2CppScheduleOne.GameTime;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Management;
using Il2CppScheduleOne.Money;
using Il2CppScheduleOne.NPCs;
using Il2CppScheduleOne.NPCs.Behaviour;
using Il2CppScheduleOne.ObjectScripts;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.Product;
using Il2CppScheduleOne.Product.Packaging;
using Il2CppScheduleOne.StationFramework;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.Items;
using Il2CppScheduleOne.UI.Management;
using Il2CppScheduleOne.UI.Phone.Delivery;
using Il2CppScheduleOne.UI.Shop;
using Il2CppScheduleOne.UI.Stations;
using Il2CppScheduleOne.UI.Stations.Drying_rack;
using Il2CppScheduleOne.Variables;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using ProduceMore;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(ProduceMoreMod), "ProduceMore", "1.0.4", "lasersquid", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ProduceMoreIL2CPP")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+0153bc16a6ecb78fb342f6b3a02138db77a90c97")]
[assembly: AssemblyProduct("ProduceMoreIL2CPP")]
[assembly: AssemblyTitle("ProduceMoreIL2CPP")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.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 ProduceMore
{
	public class ProduceMoreMod : MelonMod
	{
		public IEqualityComparer<Object> unityComparer;

		public HashSet<GridItem> processedStationCapacities;

		public HashSet<GridItem> processedStationSpeeds;

		public HashSet<GridItem> processedStationTimes;

		public HashSet<ItemDefinition> processedItemDefs;

		public HashSet<StationRecipe> processedRecipes;

		public Dictionary<string, int> originalStackLimits;

		public Dictionary<string, int> originalStationCapacities;

		public Dictionary<string, int> originalStationTimes;

		public Dictionary<StationRecipe, int> originalRecipeTimes;

		public HashSet<NPC> registeredEmployees;

		private bool needsReset = false;

		public ModSettings settings;

		public const string settingsFileName = "ProduceMoreSettings.json";

		public string settingsFilePath = Path.Combine(MelonEnvironment.UserDataDirectory, "ProduceMoreSettings.json");

		public Harmony harmony = new Harmony("com.lasersquid.producemore");

		public ProduceMoreMod()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			unityComparer = new UnityObjectComparer();
			processedStationCapacities = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer);
			processedStationSpeeds = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer);
			processedStationTimes = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer);
			processedItemDefs = new HashSet<ItemDefinition>((IEqualityComparer<ItemDefinition>?)unityComparer);
			processedRecipes = new HashSet<StationRecipe>((IEqualityComparer<StationRecipe>?)unityComparer);
			originalStackLimits = new Dictionary<string, int>();
			originalStationCapacities = new Dictionary<string, int>();
			originalStationTimes = new Dictionary<string, int>();
			originalRecipeTimes = new Dictionary<StationRecipe, int>((IEqualityComparer<StationRecipe>?)unityComparer);
			registeredEmployees = new HashSet<NPC>((IEqualityComparer<NPC>?)unityComparer);
		}

		public override void OnInitializeMelon()
		{
			LoadSettings();
			SaveSettings();
			SetMod();
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			if (sceneName.ToLower().Contains("main") || sceneName.ToLower().Contains("tutorial"))
			{
				needsReset = true;
			}
			if (sceneName.ToLower().Contains("menu") && needsReset)
			{
				((MelonBase)this).LoggerInstance.Msg("Menu loaded, resetting state.");
				ResetState();
			}
		}

		private void ResetState()
		{
			RestoreDefaults();
			processedStationCapacities = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer);
			processedStationSpeeds = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer);
			processedStationTimes = new HashSet<GridItem>((IEqualityComparer<GridItem>?)unityComparer);
			processedItemDefs = new HashSet<ItemDefinition>((IEqualityComparer<ItemDefinition>?)unityComparer);
			processedRecipes = new HashSet<StationRecipe>((IEqualityComparer<StationRecipe>?)unityComparer);
			needsReset = false;
		}

		private void LoadSettings()
		{
			((MelonBase)this).LoggerInstance.Msg("Loading settings from " + settingsFilePath);
			settings = ModSettings.LoadSettings(settingsFilePath);
			if (ModSettings.UpdateSettings(settings) || !File.Exists(settingsFilePath))
			{
				SaveSettings();
			}
		}

		private void SaveSettings()
		{
			if (settings != null)
			{
				settings.SaveSettings(settingsFilePath);
			}
		}

		private List<Type> GetPatchTypes()
		{
			return (from t in Assembly.GetExecutingAssembly().GetTypes()
				where t.Name.EndsWith("Patches")
				select t).ToList();
		}

		private void SetMod()
		{
			foreach (Type patchType in GetPatchTypes())
			{
				MethodInfo method = patchType.GetMethod("SetMod", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
				method.Invoke(null, new object[1] { this });
			}
		}

		public void RestoreDefaults()
		{
			foreach (Type patchType in GetPatchTypes())
			{
				try
				{
					MethodInfo method = patchType.GetMethod("RestoreDefaults", BindingFlags.Static | BindingFlags.Public);
					method.Invoke(null, null);
				}
				catch (Exception ex)
				{
					((MelonBase)this).LoggerInstance.Warning($"Couldn't restore defaults for class {patchType.Name}: {ex.GetType().Name} - {ex.Message}");
					((MelonBase)this).LoggerInstance.Warning("Source: " + ex.Source);
					((MelonBase)this).LoggerInstance.Warning(ex.StackTrace ?? "");
				}
			}
		}
	}
	public class ModSettings
	{
		public Dictionary<string, int> stackSizes = new Dictionary<string, int>();

		public Dictionary<string, int> stackOverrides = new Dictionary<string, int>();

		public Dictionary<string, float> stationSpeeds = new Dictionary<string, float>();

		public Dictionary<string, int> stationCapacities = new Dictionary<string, int>();

		public bool enableStationAnimationAcceleration;

		public float employeeWalkAcceleration;

		public const string CurrentVersion = "1.0.4";

		public string version;

		private static bool VersionGreaterThan(string version, string other)
		{
			if (other == null)
			{
				return true;
			}
			string[] array = version.Split(new char[1] { '.' });
			int num = Convert.ToInt32(array[0]);
			int num2 = Convert.ToInt32(array[1]);
			int num3 = Convert.ToInt32(array[2]);
			string[] array2 = other.Split(new char[1] { '.' });
			int num4 = Convert.ToInt32(array2[0]);
			int num5 = Convert.ToInt32(array2[1]);
			int num6 = Convert.ToInt32(array2[2]);
			if (num > num4)
			{
				return true;
			}
			if (num == num4 && num2 > num5)
			{
				return true;
			}
			if (num == num4 && num2 == num5 && num3 > num6)
			{
				return true;
			}
			return false;
		}

		public static bool UpdateSettings(ModSettings settings)
		{
			bool result = false;
			if (VersionGreaterThan("1.0.2", settings.version))
			{
				settings.stationSpeeds.Add("BrickPress", 1f);
				settings.stationSpeeds.Add("MixingStationMk2", 1f);
				settings.stationCapacities.Add("MixingStationMk2", 20);
				settings.stackOverrides.Add("Acid", 10);
				settings.stackOverrides.Add("Phosphorus", 10);
				settings.stackOverrides.Add("Low-Quality Pseudo", 10);
				settings.stackOverrides.Add("Pseudo", 10);
				settings.stackOverrides.Add("High-Quality Pseudo", 10);
				settings.enableStationAnimationAcceleration = false;
				settings.employeeWalkAcceleration = 1f;
				settings.version = "1.0.2";
				result = true;
				MelonLogger.Msg("Updated settings to v1.0.2");
			}
			if (VersionGreaterThan("1.0.3", settings.version))
			{
				int num = 10;
				if (settings.stackSizes.ContainsKey("Growing"))
				{
					num = settings.stackSizes["Growing"];
					settings.stackSizes.Remove("Growing");
				}
				else
				{
					num = 10;
				}
				settings.stackSizes.TryAdd("Agriculture", num);
				settings.stackSizes.TryAdd("Storage", 10);
				settings.version = "1.0.3";
				result = true;
				MelonLogger.Msg("Updated settings to v1.0.3");
			}
			if (VersionGreaterThan("1.0.4", settings.version))
			{
				settings.version = "1.0.4";
				result = true;
				MelonLogger.Msg("Updated settings to v1.0.4");
			}
			return result;
		}

		public static ModSettings LoadSettings(string jsonPath)
		{
			if (File.Exists(jsonPath))
			{
				string text = File.ReadAllText(jsonPath);
				ModSettings modSettings = JsonConvert.DeserializeObject<ModSettings>(text);
				ModSettings modSettings2 = new ModSettings();
				foreach (KeyValuePair<string, int> stackSize in modSettings2.stackSizes)
				{
					if (!modSettings.stackSizes.ContainsKey(stackSize.Key))
					{
						modSettings.stackSizes.Add(stackSize.Key, stackSize.Value);
					}
				}
				foreach (KeyValuePair<string, float> stationSpeed in modSettings2.stationSpeeds)
				{
					if (!modSettings.stationSpeeds.ContainsKey(stationSpeed.Key))
					{
						modSettings.stationSpeeds.Add(stationSpeed.Key, stationSpeed.Value);
					}
				}
				foreach (KeyValuePair<string, int> stationCapacity in modSettings2.stationCapacities)
				{
					if (!modSettings.stationCapacities.ContainsKey(stationCapacity.Key))
					{
						modSettings.stationCapacities.Add(stationCapacity.Key, stationCapacity.Value);
					}
				}
				foreach (KeyValuePair<string, int> stackOverride in modSettings2.stackOverrides)
				{
					if (!modSettings.stackOverrides.ContainsKey(stackOverride.Key))
					{
						modSettings.stackOverrides.Add(stackOverride.Key, stackOverride.Value);
					}
				}
				List<string> list = new List<string>();
				foreach (KeyValuePair<string, int> stackSize2 in modSettings.stackSizes)
				{
					if (!modSettings2.stackSizes.ContainsKey(stackSize2.Key))
					{
						list.Add(stackSize2.Key);
					}
					if (stackSize2.Value <= 0)
					{
						MelonLogger.Msg("Settings file had stacklimit <= 0 for " + stackSize2.Key + ", resetting to 1");
						modSettings.stackSizes[stackSize2.Key] = 1;
					}
				}
				foreach (string item in list)
				{
					modSettings.stackSizes.Remove(item);
				}
				List<string> list2 = new List<string>();
				foreach (KeyValuePair<string, float> stationSpeed2 in modSettings.stationSpeeds)
				{
					if (!modSettings2.stationSpeeds.ContainsKey(stationSpeed2.Key))
					{
						list2.Add(stationSpeed2.Key);
					}
					if (stationSpeed2.Value < float.MinValue)
					{
						MelonLogger.Msg("Settings file had speed <= 0 for " + stationSpeed2.Key + ", resetting to 0.0001");
						modSettings.stationSpeeds[stationSpeed2.Key] = 0.0001f;
					}
				}
				foreach (string item2 in list2)
				{
					modSettings.stationSpeeds.Remove(item2);
				}
				list2.Clear();
				foreach (KeyValuePair<string, int> stationCapacity2 in modSettings.stationCapacities)
				{
					if (!modSettings2.stationCapacities.ContainsKey(stationCapacity2.Key))
					{
						list2.Add(stationCapacity2.Key);
					}
					if (stationCapacity2.Value <= 0)
					{
						MelonLogger.Msg("Settings file had capacity <= 0 for " + stationCapacity2.Key + ", resetting to 1");
						modSettings.stationSpeeds[stationCapacity2.Key] = 1f;
					}
				}
				foreach (string item3 in list2)
				{
					modSettings.stationCapacities.Remove(item3);
				}
				list2.Clear();
				foreach (KeyValuePair<string, int> stackOverride2 in modSettings.stackOverrides)
				{
					if (stackOverride2.Value <= 0)
					{
						modSettings.stackOverrides[stackOverride2.Key] = 1;
						MelonLogger.Msg("Stack override for " + stackOverride2.Key + " <= 0; setting to 1");
					}
				}
				foreach (string item4 in list2)
				{
					modSettings.stackOverrides.Remove(item4);
				}
				return modSettings;
			}
			return new ModSettings();
		}

		public void SaveSettings(string jsonPath)
		{
			File.WriteAllText(jsonPath, ToString());
		}

		public override string ToString()
		{
			return JsonConvert.SerializeObject((object)this, (Formatting)1);
		}

		public void PrintSettings()
		{
			MelonLogger.Msg("Settings:");
			MelonLogger.Msg($"{this}");
		}

		public ModSettings()
		{
			stackSizes.Add("Agriculture", 10);
			stackSizes.Add("Cash", 1000);
			stackSizes.Add("Clothing", 1);
			stackSizes.Add("Consumable", 20);
			stackSizes.Add("Decoration", 1);
			stackSizes.Add("Equipment", 10);
			stackSizes.Add("Furniture", 10);
			stackSizes.Add("Ingredient", 20);
			stackSizes.Add("Lighting", 10);
			stackSizes.Add("Packaging", 20);
			stackSizes.Add("Product", 20);
			stackSizes.Add("Storage", 10);
			stackSizes.Add("Tools", 1);
			stationSpeeds.Add("LabOven", 1f);
			stationSpeeds.Add("Cauldron", 1f);
			stationSpeeds.Add("BrickPress", 1f);
			stationSpeeds.Add("ChemistryStation", 1f);
			stationSpeeds.Add("DryingRack", 1f);
			stationSpeeds.Add("MixingStation", 1f);
			stationSpeeds.Add("MixingStationMk2", 1f);
			stationSpeeds.Add("PackagingStation", 1f);
			stationSpeeds.Add("Pot", 1f);
			stationCapacities.Add("DryingRack", 20);
			stationCapacities.Add("MixingStation", 10);
			stationCapacities.Add("MixingStationMk2", 20);
			stationCapacities.Add("PackagingStation", 20);
			stackOverrides.Add("Acid", 10);
			stackOverrides.Add("Phosphorus", 10);
			stackOverrides.Add("Low-Quality Pseudo", 10);
			stackOverrides.Add("Pseudo", 10);
			stackOverrides.Add("High-Quality Pseudo", 10);
			enableStationAnimationAcceleration = false;
			employeeWalkAcceleration = 1f;
			version = "1.0.4";
		}

		public int GetStackLimit(ItemInstance item)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			int value = 10;
			if (!stackOverrides.TryGetValue(item.Name, out value))
			{
				EItemCategory value2 = ((!(item.Definition.Name == "Speed Grow")) ? item.Category : ((EItemCategory)2));
				if (!stackSizes.TryGetValue(((object)(EItemCategory)(ref value2)).ToString(), out value))
				{
					MelonLogger.Msg($"Couldn't find stack size for item {item.Name} with category {value2}");
				}
			}
			return value;
		}

		public int GetStackLimit(ItemDefinition itemDef)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			int value = 10;
			if (!stackOverrides.TryGetValue(itemDef.Name, out value))
			{
				EItemCategory value2 = ((!(itemDef.Name == "Speed Grow")) ? itemDef.Category : ((EItemCategory)2));
				if (!stackSizes.TryGetValue(((object)(EItemCategory)(ref value2)).ToString(), out value))
				{
					MelonLogger.Msg($"Couldn't find stack size for item {itemDef.Name} with category {value2}");
				}
			}
			return value;
		}

		public int GetStackLimit(string itemName, EItemCategory category)
		{
			//IL_0033: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			int value = 10;
			if (!stackOverrides.TryGetValue(itemName, out value))
			{
				EItemCategory value2 = ((!(itemName == "Speed Grow")) ? category : ((EItemCategory)2));
				if (!stackSizes.TryGetValue(((object)(EItemCategory)(ref value2)).ToString(), out value))
				{
					MelonLogger.Msg($"Couldn't find stack size for item {itemName} with category {value2}");
				}
			}
			return value;
		}

		public int GetStackLimit(EItemCategory category)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			int value = 10;
			if (!stackSizes.TryGetValue(((object)(EItemCategory)(ref category)).ToString(), out value))
			{
				MelonLogger.Msg($"Couldn't find stack size for category {category}");
			}
			return value;
		}

		public int GetLargestStackLimit()
		{
			int num = 0;
			foreach (int value in stackSizes.Values)
			{
				if (value > num)
				{
					num = value;
				}
			}
			foreach (int value2 in stackOverrides.Values)
			{
				if (value2 > num)
				{
					num = value2;
				}
			}
			return num;
		}

		public int GetStationCapacity(string station)
		{
			int value = 10;
			if (!stationCapacities.TryGetValue(station, out value))
			{
				MelonLogger.Msg("Couldn't find station capacity for " + station);
			}
			return value;
		}

		public float GetStationSpeed(string station)
		{
			float value = 1f;
			if (!stationSpeeds.TryGetValue(station, out value))
			{
				MelonLogger.Msg("Couldn't find station speed for " + station);
			}
			return value;
		}
	}
	public class UnityObjectComparer : IEqualityComparer<Object>
	{
		public bool Equals(Object a, Object b)
		{
			return a.GetInstanceID() == b.GetInstanceID();
		}

		public int GetHashCode(Object item)
		{
			return item.GetInstanceID();
		}
	}
	public class Sched1PatchesBase
	{
		protected static ProduceMoreMod Mod;

		public static object GetField(Type type, string fieldName, object target)
		{
			return AccessTools.Property(type, fieldName).GetValue(target);
		}

		public static void SetField(Type type, string fieldName, object target, object value)
		{
			AccessTools.Property(type, fieldName).SetValue(target, value);
		}

		public static object GetProperty(Type type, string fieldName, object target)
		{
			return AccessTools.Property(type, fieldName).GetValue(target);
		}

		public static void SetProperty(Type type, string fieldName, object target, object value)
		{
			AccessTools.Property(type, fieldName).SetValue(target, value);
		}

		public static object CallMethod(Type type, string methodName, object target, object[] args)
		{
			return AccessTools.Method(type, methodName, (Type[])null, (Type[])null).Invoke(target, args);
		}

		public static void SetMod(ProduceMoreMod mod)
		{
			Mod = mod;
		}

		public static T CastTo<T>(object o) where T : class
		{
			if (!(o is T result))
			{
				return null;
			}
			return result;
		}

		public static bool Is<T>(object o)
		{
			return o is T;
		}

		public static T CastTo<T>(Object o) where T : Il2CppObjectBase
		{
			return ((Il2CppObjectBase)o).TryCast<T>();
		}

		public static bool Is<T>(Object o) where T : Il2CppObjectBase
		{
			return ((Il2CppObjectBase)o).TryCast<T>() != null;
		}

		public static void Log(string message)
		{
			((MelonBase)Mod).LoggerInstance.Msg(message);
		}

		public static void Warn(string message)
		{
			((MelonBase)Mod).LoggerInstance.Warning(message);
		}

		public static void RestoreDefaults()
		{
			throw new NotImplementedException();
		}
	}
	[HarmonyPatch]
	public class ItemCapacityPatches : Sched1PatchesBase
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		public static void StackLimitPrefix(ItemInstance __instance)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if (!Sched1PatchesBase.Mod.processedItemDefs.Contains(__instance.Definition) && __instance.Definition.Name.ToLower() != "cash")
			{
				EItemCategory val = ((!(__instance.Definition.Name == "Speed Grow")) ? __instance.Definition.Category : ((EItemCategory)2));
				if (!Sched1PatchesBase.Mod.originalStackLimits.ContainsKey(((object)(EItemCategory)(ref val)).ToString()))
				{
					Sched1PatchesBase.Mod.originalStackLimits[((object)(EItemCategory)(ref val)).ToString()] = __instance.Definition.StackLimit;
				}
				int num = Sched1PatchesBase.Mod.settings.GetStackLimit(__instance);
				if (num == 0)
				{
					num = 10;
				}
				__instance.Definition.StackLimit = num;
				Sched1PatchesBase.Mod.processedItemDefs.Add(__instance.Definition);
			}
		}

		[HarmonyPatch(typeof(ListingEntry), "Initialize")]
		[HarmonyPrefix]
		public static void InitializePrefix(ShopListing match)
		{
			//IL_0071: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			if (match != null && !Sched1PatchesBase.Mod.processedItemDefs.Contains((ItemDefinition)(object)match.Item) && ((ItemDefinition)match.Item).Name.ToLower() != "cash")
			{
				EItemCategory val = ((!(((ItemDefinition)match.Item).Name == "Speed Grow")) ? ((ItemDefinition)match.Item).Category : ((EItemCategory)2));
				if (!Sched1PatchesBase.Mod.originalStackLimits.ContainsKey(((object)(EItemCategory)(ref val)).ToString()))
				{
					Sched1PatchesBase.Mod.originalStackLimits[((object)(EItemCategory)(ref val)).ToString()] = ((ItemDefinition)match.Item).StackLimit;
				}
				int stackLimit = Sched1PatchesBase.Mod.settings.GetStackLimit((ItemDefinition)(object)match.Item);
				((ItemDefinition)match.Item).StackLimit = stackLimit;
				Sched1PatchesBase.Mod.processedItemDefs.Add((ItemDefinition)(object)match.Item);
			}
		}

		[HarmonyPatch(typeof(ItemSlot), "GetCapacityForItem")]
		[HarmonyPostfix]
		public static void GetCapacityForItemPostfix(ItemSlot __instance, ref int __result, ItemInstance item, bool checkPlayerFilters)
		{
			if (!__instance.DoesItemMatchHardFilters(item))
			{
				__result = 0;
			}
			else if (checkPlayerFilters && !__instance.DoesItemMatchPlayerFilters(item))
			{
				__result = 0;
			}
			else if (__instance.ItemInstance == null || __instance.ItemInstance.CanStackWith(item, false))
			{
				__result = Sched1PatchesBase.Mod.settings.GetStackLimit(item) - __instance.Quantity;
			}
			else
			{
				__result = 0;
			}
		}

		public new static void RestoreDefaults()
		{
			//IL_0046: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				foreach (ItemDefinition processedItemDef in Sched1PatchesBase.Mod.processedItemDefs)
				{
					if (processedItemDef.Name.ToLower() != "cash")
					{
						Dictionary<string, int> originalStackLimits = Sched1PatchesBase.Mod.originalStackLimits;
						EItemCategory category = processedItemDef.Category;
						if (!originalStackLimits.ContainsKey(((object)(EItemCategory)(ref category)).ToString()))
						{
							processedItemDef.StackLimit = new ModSettings().GetStackLimit(processedItemDef);
							continue;
						}
						Dictionary<string, int> originalStackLimits2 = Sched1PatchesBase.Mod.originalStackLimits;
						category = processedItemDef.Category;
						processedItemDef.StackLimit = originalStackLimits2[((object)(EItemCategory)(ref category)).ToString()];
					}
				}
			}
			catch (Exception ex)
			{
				Sched1PatchesBase.Warn($"Couldn't restore defaults for {MethodBase.GetCurrentMethod().DeclaringType.Name}: {ex.GetType().Name} - {ex.Message}");
				Sched1PatchesBase.Warn("Source: " + ex.Source);
				Sched1PatchesBase.Warn(ex.StackTrace ?? "");
			}
		}
	}
	[HarmonyPatch]
	public class RegistryPatches : Sched1PatchesBase
	{
		[HarmonyTargetMethod]
		public static MethodBase TargetMethod()
		{
			List<MethodInfo> declaredMethods = AccessTools.GetDeclaredMethods(typeof(Registry));
			foreach (MethodInfo item in declaredMethods)
			{
				if (item.Name == "GetItem" && item.ReturnType == typeof(ItemDefinition))
				{
					return item;
				}
			}
			return null;
		}

		[HarmonyPatch]
		[HarmonyPostfix]
		public static void GetItemPostfix(ref ItemDefinition __result)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__result == (Object)null) && !Sched1PatchesBase.Mod.processedItemDefs.Contains(__result) && __result.Name.ToLower() != "cash")
			{
				EItemCategory val = ((!(__result.Name == "Speed Grow")) ? __result.Category : ((EItemCategory)2));
				if (!Sched1PatchesBase.Mod.originalStackLimits.ContainsKey(((object)(EItemCategory)(ref val)).ToString()))
				{
					Sched1PatchesBase.Mod.originalStackLimits[((object)(EItemCategory)(ref val)).ToString()] = __result.StackLimit;
				}
				int num = Sched1PatchesBase.Mod.settings.GetStackLimit(__result);
				if (num == 0)
				{
					num = 10;
				}
				__result.StackLimit = num;
				Sched1PatchesBase.Mod.processedItemDefs.Add(__result);
			}
		}

		public new static void RestoreDefaults()
		{
		}
	}
	[HarmonyPatch]
	public class ShopPatches : Sched1PatchesBase
	{
		[HarmonyPatch(typeof(ShopAmountSelector), "OnValueChanged")]
		[HarmonyPrefix]
		public static bool OnValueChangedPrefix(ShopAmountSelector __instance, string value)
		{
			if (int.TryParse(value, out var result))
			{
				Sched1PatchesBase.SetProperty(typeof(ShopAmountSelector), "SelectedAmount", __instance, Mathf.Clamp(result, 1, 999999));
				__instance.InputField.SetTextWithoutNotify(__instance.SelectedAmount.ToString());
				return false;
			}
			Sched1PatchesBase.SetProperty(typeof(ShopAmountSelector), "SelectedAmount", __instance, 1);
			__instance.InputField.SetTextWithoutNotify(string.Empty);
			return false;
		}

		[HarmonyPatch(typeof(ShopAmountSelector), "OnSubmitted")]
		[HarmonyPrefix]
		public static bool OnSubmittedPrefix(ShopAmountSelector __instance, string value)
		{
			if (!__instance.IsOpen)
			{
				return false;
			}
			Sched1PatchesBase.CallMethod(typeof(ShopAmountSelector), "OnValueChanged", __instance, new object[1] { value });
			if (__instance.onSubmitted != null)
			{
				__instance.onSubmitted.Invoke(__instance.SelectedAmount);
			}
			__instance.Close();
			return false;
		}

		[HarmonyPatch(typeof(ShopAmountSelector), "Open")]
		[HarmonyPrefix]
		public static void OpenPrefix(ShopAmountSelector __instance)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.InputField.characterLimit != 6)
			{
				__instance.InputField.characterLimit = 6;
				TMP_InputField inputField = __instance.InputField;
				inputField.pointSize -= 2f;
				Rect rect = __instance.Container.rect;
				float num = ((Rect)(ref rect)).width * 1.5f;
				__instance.Container.SetSizeWithCurrentAnchors((Axis)0, num);
			}
		}

		[HarmonyPatch(typeof(CartEntry), "Initialize")]
		[HarmonyPrefix]
		public static bool CartEntryInitializePrefix(CartEntry __instance, Cart cart, ShopListing listing, int quantity)
		{
			Sched1PatchesBase.SetProperty(typeof(CartEntry), "Cart", __instance, cart);
			Sched1PatchesBase.SetProperty(typeof(CartEntry), "Listing", __instance, listing);
			Sched1PatchesBase.SetProperty(typeof(CartEntry), "Quantity", __instance, quantity);
			((UnityEvent)__instance.IncrementButton.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)(Action)delegate
			{
				Sched1PatchesBase.CallMethod(typeof(CartEntry), "ChangeAmount", __instance, new object[1] { 1 });
			}));
			((UnityEvent)__instance.DecrementButton.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)(Action)delegate
			{
				Sched1PatchesBase.CallMethod(typeof(CartEntry), "ChangeAmount", __instance, new object[1] { -1 });
			}));
			((UnityEvent)__instance.RemoveButton.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)(Action)delegate
			{
				Sched1PatchesBase.CallMethod(typeof(CartEntry), "ChangeAmount", __instance, new object[1] { -999999 });
			}));
			Sched1PatchesBase.CallMethod(typeof(CartEntry), "UpdateTitle", __instance, Array.Empty<object>());
			Sched1PatchesBase.CallMethod(typeof(CartEntry), "UpdatePrice", __instance, Array.Empty<object>());
			return false;
		}

		[HarmonyPatch(typeof(ListingEntry), "Initialize")]
		[HarmonyPrefix]
		public static bool ListingEntryInitializePrefix(ListingEntry __instance, ShopListing match)
		{
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			Sched1PatchesBase.SetProperty(typeof(ListingEntry), "MatchingListing", __instance, match);
			__instance.Icon.sprite = ((ItemDefinition)__instance.MatchingListing.Item).Icon;
			__instance.ItemNameLabel.text = ((ItemDefinition)__instance.MatchingListing.Item).Name;
			__instance.ItemPriceLabel.text = MoneyManager.FormatAmount(__instance.MatchingListing.Price, false, false);
			((UnityEvent<string>)(object)__instance.QuantityInput.onSubmit).AddListener(DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)(Action<string>)delegate(string value)
			{
				Sched1PatchesBase.CallMethod(typeof(ListingEntry), "OnQuantityInputSubmitted", __instance, new object[1] { value });
			}));
			((UnityEvent<string>)(object)__instance.QuantityInput.onEndEdit).AddListener(DelegateSupport.ConvertDelegate<UnityAction<string>>((Delegate)(Action<string>)delegate
			{
				Sched1PatchesBase.CallMethod(typeof(ListingEntry), "ValidateInput", __instance, Array.Empty<object>());
			}));
			((UnityEvent)__instance.IncrementButton.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)(Action)delegate
			{
				Sched1PatchesBase.CallMethod(typeof(ListingEntry), "ChangeQuantity", __instance, new object[1] { 1 });
			}));
			((UnityEvent)__instance.DecrementButton.onClick).AddListener(DelegateSupport.ConvertDelegate<UnityAction>((Delegate)(Action)delegate
			{
				Sched1PatchesBase.CallMethod(typeof(ListingEntry), "ChangeQuantity", __instance, new object[1] { -1 });
			}));
			__instance.QuantityInput.SetTextWithoutNotify(__instance.SelectedQuantity.ToString());
			__instance.RefreshLocked();
			if (__instance.QuantityInput.characterLimit != 6)
			{
				__instance.QuantityInput.characterLimit = 6;
				__instance.QuantityInput.textComponent.fontSize = 16;
				Sched1PatchesBase.CastTo<RectTransform>((Object)(object)((Component)__instance.QuantityInput).transform).sizeDelta = new Vector2(80f, 40f);
			}
			return false;
		}

		[HarmonyPatch(typeof(ListingEntry), "SetQuantity")]
		[HarmonyPrefix]
		public static bool SetQuantityPrefix(ListingEntry __instance, int quant, bool notify)
		{
			if (!__instance.MatchingListing.Item.IsPurchasable)
			{
				quant = 0;
			}
			Sched1PatchesBase.SetProperty(typeof(ListingEntry), "SelectedQuantity", __instance, Mathf.Clamp(quant, 0, 999999));
			__instance.QuantityInput.SetTextWithoutNotify(__instance.SelectedQuantity.ToString());
			if (notify && __instance.onQuantityChanged != null)
			{
				__instance.onQuantityChanged.Invoke();
			}
			return false;
		}

		[HarmonyPatch(typeof(ListingEntry), "OnQuantityInputSubmitted")]
		[HarmonyPrefix]
		public static bool OnQuantityInputSubmittedPrefix(ListingEntry __instance, string value)
		{
			if (int.TryParse(value, out var result))
			{
				__instance.SetQuantity(result, true);
				return false;
			}
			__instance.SetQuantity(0, true);
			return false;
		}

		[HarmonyPatch(typeof(ListingEntry), "ChangeQuantity")]
		[HarmonyPrefix]
		public static bool ChangeQuantityPrefix(ListingEntry __instance, int change)
		{
			__instance.SetQuantity(__instance.SelectedQuantity + change, true);
			return false;
		}

		[HarmonyPatch(typeof(ListingEntry), "ValidateInput")]
		[HarmonyPrefix]
		public static bool ValidateInputPrefix(ListingEntry __instance)
		{
			Sched1PatchesBase.CallMethod(typeof(ListingEntry), "OnQuantityInputSubmitted", __instance, new object[1] { __instance.QuantityInput.text });
			return false;
		}

		public new static void RestoreDefaults()
		{
		}
	}
	[HarmonyPatch]
	public class DryingRackPatches : Sched1PatchesBase
	{
		[CompilerGenerated]
		private sealed class <BeginActionCoroutine>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public StartDryingRackBehaviour behaviour;

			private float <stationSpeed>5__1;

			private int <itemCount>5__2;

			private int <num>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_006b: Expected O, but got Unknown
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<stationSpeed>5__1 = (Sched1PatchesBase.Mod.settings.enableStationAnimationAcceleration ? Sched1PatchesBase.Mod.settings.GetStationSpeed("DryingRack") : 1f);
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					behaviour.Rack.InputSlot.ItemInstance.GetCopy(1);
					<itemCount>5__2 = 0;
					break;
				case 2:
					<>1__state = -1;
					<num>5__3 = <itemCount>5__2;
					<itemCount>5__2 = <num>5__3 + 1;
					break;
				}
				if ((Object)(object)behaviour.Rack != (Object)null && behaviour.Rack.InputSlot.Quantity > <itemCount>5__2 && behaviour.Rack.GetTotalDryingItems() + <itemCount>5__2 < behaviour.Rack.ItemCapacity)
				{
					((Behaviour)behaviour).Npc.Avatar.Anim.SetTrigger("GrabItem");
					<>2__current = (object)new WaitForSeconds(1f / <stationSpeed>5__1);
					<>1__state = 2;
					return true;
				}
				if (InstanceFinder.IsServer)
				{
					behaviour.Rack.StartOperation();
				}
				Sched1PatchesBase.SetProperty(typeof(StartDryingRackBehaviour), "WorkInProgress", behaviour, false);
				Sched1PatchesBase.SetField(typeof(StartDryingRackBehaviour), "workRoutine", behaviour, 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();
			}
		}

		[HarmonyPatch(typeof(StartDryingRackBehaviour), "IsRackReady")]
		[HarmonyPrefix]
		public static void IsRackReadyPrefix(DryingRack rack, ref bool __result)
		{
			if (!Sched1PatchesBase.Mod.processedStationCapacities.Contains((GridItem)(object)rack))
			{
				if (!Sched1PatchesBase.Mod.originalStationCapacities.ContainsKey("DryingRack"))
				{
					Sched1PatchesBase.Mod.originalStationCapacities["DryingRack"] = rack.ItemCapacity;
				}
				rack.ItemCapacity = Sched1PatchesBase.Mod.settings.GetStationCapacity("DryingRack");
				Sched1PatchesBase.Mod.processedStationCapacities.Add((GridItem)(object)rack);
			}
		}

		[HarmonyPatch(typeof(DryingRack), "CanStartOperation")]
		[HarmonyPrefix]
		public static bool CanStartOperationPrefix(DryingRack __instance, ref bool __result)
		{
			if (!Sched1PatchesBase.Mod.processedStationCapacities.Contains((GridItem)(object)__instance))
			{
				if (!Sched1PatchesBase.Mod.originalStationCapacities.ContainsKey("DryingRack"))
				{
					Sched1PatchesBase.Mod.originalStationCapacities["DryingRack"] = __instance.ItemCapacity;
				}
				__instance.ItemCapacity = Sched1PatchesBase.Mod.settings.GetStationCapacity("DryingRack");
				Sched1PatchesBase.Mod.processedStationCapacities.Add((GridItem)(object)__instance);
			}
			__result = __instance.GetTotalDryingItems() < __instance.ItemCapacity && __instance.InputSlot.Quantity != 0 && !__instance.InputSlot.IsLocked && !__instance.InputSlot.IsRemovalLocked;
			return false;
		}

		[HarmonyPatch(typeof(DryingOperationUI), "UpdatePosition")]
		[HarmonyPrefix]
		public static bool UpdatePositionPrefix(DryingOperationUI __instance)
		{
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			if (!Sched1PatchesBase.Mod.originalStationTimes.ContainsKey("DryingRack"))
			{
				Sched1PatchesBase.Mod.originalStationTimes["DryingRack"] = DryingRack.DRY_MINS_PER_TIER;
			}
			float num = (Sched1PatchesBase.Mod.settings.enableStationAnimationAcceleration ? ((float)Sched1PatchesBase.Mod.originalStationTimes["DryingRack"] / Sched1PatchesBase.Mod.settings.GetStationSpeed("DryingRack")) : ((float)Sched1PatchesBase.Mod.originalStationTimes["DryingRack"]));
			float num2 = Mathf.Clamp01((float)__instance.AssignedOperation.Time / num);
			int num3 = Mathf.Clamp((int)num - __instance.AssignedOperation.Time, 0, (int)num);
			int num4 = num3 / 60;
			int num5 = num3 % 60;
			__instance.Tooltip.text = num4 + "h " + num5 + "m until next tier";
			float num6 = -62.5f;
			float num7 = 0f - num6;
			__instance.Rect.anchoredPosition = new Vector2(Mathf.Lerp(num6, num7, num2), 0f);
			return false;
		}

		[HarmonyPatch(typeof(DryingOperation), "GetQuality")]
		[HarmonyPostfix]
		public static void GetQualityPostfix(DryingOperation __instance, ref EQuality __result)
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected I4, but got Unknown
			//IL_0077: 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: Expected I4, but got Unknown
			if (!Sched1PatchesBase.Mod.originalStationTimes.ContainsKey("DryingRack"))
			{
				Sched1PatchesBase.Mod.originalStationTimes["DryingRack"] = DryingRack.DRY_MINS_PER_TIER;
			}
			int num = (int)((float)Sched1PatchesBase.Mod.originalStationTimes["DryingRack"] / Sched1PatchesBase.Mod.settings.GetStationSpeed("DryingRack"));
			if (__instance.Time >= num)
			{
				__result = (EQuality)(__instance.StartQuality + 1);
			}
			__result = (EQuality)(int)__instance.StartQuality;
		}

		[HarmonyPatch(typeof(DryingRack), "MinPass")]
		[HarmonyPrefix]
		public static bool MinPassPrefix(DryingRack __instance)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Invalid comparison between Unknown and I4
			if (!Sched1PatchesBase.Mod.originalStationTimes.ContainsKey("DryingRack"))
			{
				Sched1PatchesBase.Mod.originalStationTimes["DryingRack"] = DryingRack.DRY_MINS_PER_TIER;
			}
			if ((Object)(object)__instance == (Object)null)
			{
				return false;
			}
			foreach (DryingOperation item in __instance.DryingOperations.ToArray())
			{
				int time = item.Time;
				item.Time = time + 1;
				if (!((float)item.Time >= (float)Sched1PatchesBase.Mod.originalStationTimes["DryingRack"] / Sched1PatchesBase.Mod.settings.GetStationSpeed("DryingRack")))
				{
					continue;
				}
				if ((int)item.StartQuality >= 3)
				{
					if (InstanceFinder.IsServer && __instance.GetOutputCapacityForOperation(item, (EQuality)4) >= item.Quantity)
					{
						__instance.TryEndOperation(__instance.DryingOperations.IndexOf(item), false, (EQuality)4, Random.Range(int.MinValue, int.MaxValue));
					}
				}
				else
				{
					item.IncreaseQuality();
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(StartDryingRackBehaviour), "RpcLogic___BeginAction_2166136261")]
		[HarmonyPrefix]
		public static bool Rpc_BeginActionPrefix(StartDryingRackBehaviour __instance)
		{
			//IL_005a: 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_0091: Expected O, but got Unknown
			if (__instance.WorkInProgress)
			{
				return false;
			}
			if ((Object)(object)__instance.Rack == (Object)null)
			{
				return false;
			}
			Sched1PatchesBase.SetProperty(typeof(StartDryingRackBehaviour), "WorkInProgress", __instance, true);
			((Behaviour)__instance).Npc.Movement.FacePoint(__instance.Rack.uiPoint.position, 0.5f);
			object obj = MelonCoroutines.Start(BeginActionCoroutine(__instance));
			Sched1PatchesBase.SetField(typeof(StartDryingRackBehaviour), "workRoutine", __instance, (object)(Coroutine)obj);
			return false;
		}

		[IteratorStateMachine(typeof(<BeginActionCoroutine>d__6))]
		private static IEnumerator BeginActionCoroutine(StartDryingRackBehaviour behaviour)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <BeginActionCoroutine>d__6(0)
			{
				behaviour = behaviour
			};
		}

		[HarmonyPatch(typeof(StartDryingRackBehaviour), "StopCauldron")]
		[HarmonyPrefix]
		public static bool StopCauldronPrefix(StartDryingRackBehaviour __instance)
		{
			object field = Sched1PatchesBase.GetField(typeof(StartDryingRackBehaviour), "workRoutine", __instance);
			if (field != null)
			{
				MelonCoroutines.Stop(field);
				Sched1PatchesBase.SetField(typeof(StartDryingRackBehaviour), "workRoutine", __instance, null);
			}
			Sched1PatchesBase.SetProperty(typeof(StartDryingRackBehaviour), "WorkInProgress", __instance, false);
			return false;
		}

		public new static void RestoreDefaults()
		{
			try
			{
				foreach (GridItem processedStationCapacity in Sched1PatchesBase.Mod.processedStationCapacities)
				{
					DryingRack val = Sched1PatchesBase.CastTo<DryingRack>((Object)(object)processedStationCapacity);
					if ((Object)(object)val != (Object)null)
					{
						if (!Sched1PatchesBase.Mod.originalStationCapacities.ContainsKey("DryingRack"))
						{
							val.ItemCapacity = 20;
						}
						else
						{
							val.ItemCapacity = Sched1PatchesBase.Mod.originalStationCapacities["DryingRack"];
						}
					}
				}
			}
			catch (Exception ex)
			{
				Sched1PatchesBase.Warn($"Couldn't restore defaults for {MethodBase.GetCurrentMethod().DeclaringType.Name}: {ex.GetType().Name} - {ex.Message}");
				Sched1PatchesBase.Warn("Source: " + ex.Source);
				Sched1PatchesBase.Warn(ex.StackTrace ?? "");
			}
		}
	}
	[HarmonyPatch]
	public class LabOvenPatches : Sched1PatchesBase
	{
		[CompilerGenerated]
		private sealed class <FinishCookCoroutine>d__7 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public FinishLabOvenBehaviour behaviour;

			private float <stationSpeed>5__1;

			private ItemInstance <productItem>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0217: Unknown result type (might be due to invalid IL or missing references)
				//IL_0221: Expected O, but got Unknown
				//IL_0259: Unknown result type (might be due to invalid IL or missing references)
				//IL_0263: Expected O, but got Unknown
				//IL_0298: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a2: Expected O, but got Unknown
				//IL_0321: Unknown result type (might be due to invalid IL or missing references)
				//IL_032b: Expected O, but got Unknown
				//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c5: Expected O, but got Unknown
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e8: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<stationSpeed>5__1 = (Sched1PatchesBase.Mod.settings.enableStationAnimationAcceleration ? Sched1PatchesBase.Mod.settings.GetStationSpeed("LabOven") : 1f);
					behaviour.targetOven.SetNPCUser(((NetworkBehaviour)((Behaviour)behaviour).Npc).NetworkObject);
					((Behaviour)behaviour).Npc.Movement.FacePoint(((Component)behaviour.targetOven).transform.position, 0.5f);
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!(bool)Sched1PatchesBase.CallMethod(typeof(FinishLabOvenBehaviour), "CanActionStart", behaviour, Array.Empty<object>()))
					{
						Sched1PatchesBase.CallMethod(typeof(FinishLabOvenBehaviour), "StopAction", behaviour, Array.Empty<object>());
						((Behaviour)behaviour).End_Networked((NetworkConnection)null);
						return false;
					}
					((Behaviour)behaviour).Npc.SetEquippable_Networked((NetworkConnection)null, "Avatar/Equippables/Hammer");
					behaviour.targetOven.Door.SetPosition(1f / <stationSpeed>5__1);
					behaviour.targetOven.WireTray.SetPosition(1f / <stationSpeed>5__1);
					<>2__current = (object)new WaitForSeconds(0.5f / <stationSpeed>5__1);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					behaviour.targetOven.SquareTray.SetParent(((Component)behaviour.targetOven).transform);
					behaviour.targetOven.RemoveTrayAnimation.Play();
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					behaviour.targetOven.Door.SetPosition(0f);
					<>2__current = (object)new WaitForSeconds(1f / <stationSpeed>5__1);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					((Behaviour)behaviour).Npc.SetAnimationBool_Networked((NetworkConnection)null, "UseHammer", true);
					<>2__current = (object)new WaitForSeconds(10f / <stationSpeed>5__1);
					<>1__state = 5;
					return true;
				case 5:
					<>1__state = -1;
					((Behaviour)behaviour).Npc.SetAnimationBool_Networked((NetworkConnection)null, "UseHammer", false);
					behaviour.targetOven.Shatter(behaviour.targetOven.CurrentOperation.Cookable.ProductQuantity, ((Component)behaviour.targetOven.CurrentOperation.Cookable.ProductShardPrefab).gameObject);
					<>2__current = (object)new WaitForSeconds(1f / <stationSpeed>5__1);
					<>1__state = 6;
					return true;
				case 6:
					<>1__state = -1;
					<productItem>5__2 = behaviour.targetOven.CurrentOperation.GetProductItem(behaviour.targetOven.CurrentOperation.Cookable.ProductQuantity * behaviour.targetOven.CurrentOperation.IngredientQuantity);
					behaviour.targetOven.OutputSlot.AddItem(<productItem>5__2, false);
					behaviour.targetOven.SendCookOperation((OvenCookOperation)null);
					Sched1PatchesBase.CallMethod(typeof(FinishLabOvenBehaviour), "StopAction", behaviour, Array.Empty<object>());
					((Behaviour)behaviour).End_Networked((NetworkConnection)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();
			}
		}

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

			private object <>2__current;

			public StartLabOvenBehaviour behaviour;

			private float <stationSpeed>5__1;

			private ItemInstance <itemInstance>5__2;

			private int <num>5__3;

			private string <id>5__4;

			private EQuality <ingredientQuality>5__5;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<itemInstance>5__2 = null;
				<id>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ca: Expected O, but got Unknown
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_020c: Expected O, but got Unknown
				//IL_0177: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Expected O, but got Unknown
				//IL_0295: Unknown result type (might be due to invalid IL or missing references)
				//IL_029b: Invalid comparison between Unknown and I4
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Expected O, but got Unknown
				//IL_0304: 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_035a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0364: Expected O, but got Unknown
				//IL_0327: Unknown result type (might be due to invalid IL or missing references)
				//IL_032c: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<stationSpeed>5__1 = (Sched1PatchesBase.Mod.settings.enableStationAnimationAcceleration ? Sched1PatchesBase.Mod.settings.GetStationSpeed("LabOven") : 1f);
					behaviour.targetOven.SetNPCUser(((NetworkBehaviour)((Behaviour)behaviour).Npc).NetworkObject);
					((Behaviour)behaviour).Npc.Movement.FacePoint(((Component)behaviour.targetOven).transform.position, 0.5f);
					<>2__current = (object)new WaitForSeconds(0.5f / <stationSpeed>5__1);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!(bool)Sched1PatchesBase.CallMethod(typeof(StartLabOvenBehaviour), "CanCookStart", behaviour, Array.Empty<object>()))
					{
						Sched1PatchesBase.CallMethod(typeof(StartLabOvenBehaviour), "StopCook", behaviour, Array.Empty<object>());
						((Behaviour)behaviour).End_Networked((NetworkConnection)null);
						return false;
					}
					behaviour.targetOven.Door.SetPosition(1f / <stationSpeed>5__1);
					<>2__current = (object)new WaitForSeconds(0.5f / <stationSpeed>5__1);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					behaviour.targetOven.WireTray.SetPosition(1f / <stationSpeed>5__1);
					<>2__current = (object)new WaitForSeconds(5f / <stationSpeed>5__1);
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					behaviour.targetOven.Door.SetPosition(0f);
					<>2__current = (object)new WaitForSeconds(1f / <stationSpeed>5__1);
					<>1__state = 4;
					return true;
				case 4:
					<>1__state = -1;
					<itemInstance>5__2 = behaviour.targetOven.IngredientSlot.ItemInstance;
					if (<itemInstance>5__2 == null)
					{
						Sched1PatchesBase.CallMethod(typeof(StartLabOvenBehaviour), "StopCook", behaviour, Array.Empty<object>());
						((Behaviour)behaviour).End_Networked((NetworkConnection)null);
						return false;
					}
					<num>5__3 = 1;
					if ((int)Sched1PatchesBase.CastTo<StorableItemDefinition>((Object)(object)<itemInstance>5__2.Definition).StationItem.GetModule<CookableModule>().CookType == 1)
					{
						<num>5__3 = Mathf.Min(behaviour.targetOven.IngredientSlot.Quantity, 10);
					}
					<itemInstance>5__2.ChangeQuantity(-<num>5__3);
					<id>5__4 = ((ItemDefinition)Sched1PatchesBase.CastTo<StorableItemDefinition>((Object)(object)<itemInstance>5__2.Definition).StationItem.GetModule<CookableModule>().Product).ID;
					<ingredientQuality>5__5 = (EQuality)2;
					if (Sched1PatchesBase.Is<QualityItemInstance>((Object)(object)<itemInstance>5__2))
					{
						<ingredientQuality>5__5 = Sched1PatchesBase.CastTo<QualityItemInstance>((Object)(object)<itemInstance>5__2).Quality;
					}
					behaviour.targetOven.SendCookOperation(new OvenCookOperation(<itemInstance>5__2.ID, <ingredientQuality>5__5, <num>5__3, <id>5__4));
					Sched1PatchesBase.CallMethod(typeof(StartLabOvenBehaviour), "StopCook", behaviour, Array.Empty<object>());
					((Behaviour)behaviour).End_Networked((NetworkConnection)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();
			}
		}

		[HarmonyPatch(typeof(OvenCookOperation), "GetCookDuration")]
		[HarmonyPostfix]
		public static void GetCookDurationPostfix(OvenCookOperation __instance, ref int __result)
		{
			if (!Sched1PatchesBase.Mod.originalStationTimes.ContainsKey("LabOven"))
			{
				Sched1PatchesBase.Mod.originalStationTimes["LabOven"] = __instance.Ingredient.StationItem.GetModule<CookableModule>().CookTime;
			}
			__result = (int)((float)Sched1PatchesBase.Mod.originalStationTimes["LabOven"] / Sched1PatchesBase.Mod.settings.GetStationSpeed("LabOven"));
		}

		[HarmonyPatch(typeof(OvenCookOperation), "IsReady")]
		[HarmonyPostfix]
		public static void IsReadyPostfix(OvenCookOperation __instance, ref bool __result)
		{
			__result = __instance.CookProgress >= __instance.GetCookDuration();
		}

		[HarmonyPatch(typeof(LabOvenCanvas), "DoesOvenOutputHaveSpace")]
		[HarmonyPostfix]
		public static void DoesOvenOutputHaveSpacePostfix(LabOvenCanvas __instance, ref bool __result)
		{
			ItemInstance defaultInstance = ((ItemDefinition)__instance.Oven.CurrentOperation.Product).GetDefaultInstance(1);
			ItemInstance itemInstance = __instance.Oven.OutputSlot.ItemInstance;
			int num = 0;
			if (!__instance.Oven.OutputSlot.DoesItemMatchHardFilters(defaultInstance))
			{
				num = 0;
			}
			else if (itemInstance == null)
			{
				num = Sched1PatchesBase.Mod.settings.GetStackLimit(defaultInstance);
			}
			else if (defaultInstance.CanStackWith(itemInstance.Definition.GetDefaultInstance(1), false))
			{
				num = Sched1PatchesBase.Mod.settings.GetStackLimit(defaultInstance) - itemInstance.Quantity;
			}
			int productQuantity = __instance.Oven.CurrentOperation.Cookable.ProductQuantity;
			__result = num >= productQuantity;
		}

		[HarmonyPatch(typeof(StartLabOvenBehaviour), "RpcLogic___StartCook_2166136261")]
		[HarmonyPrefix]
		public static bool Rpc_StartCookPrefix(StartLabOvenBehaviour __instance)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			try
			{
				if (Sched1PatchesBase.GetField(typeof(StartLabOvenBehaviour), "cookRoutine", __instance) != null || (Object)(object)__instance.targetOven == (Object)null)
				{
					return false;
				}
				object obj = MelonCoroutines.Start(StartCookCoroutine(__instance));
				Sched1PatchesBase.SetField(typeof(StartLabOvenBehaviour), "cookRoutine", __instance, (object)(Coroutine)obj);
			}
			catch (Exception ex)
			{
				Sched1PatchesBase.Warn("Failed to set cookroutine: " + ex.GetType().Name + " - " + ex.Message);
				Sched1PatchesBase.Warn("Source: " + ex.Source);
				Sched1PatchesBase.Warn(ex.StackTrace ?? "");
			}
			return false;
		}

		[IteratorStateMachine(typeof(<StartCookCoroutine>d__4))]
		private static IEnumerator StartCookCoroutine(StartLabOvenBehaviour behaviour)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <StartCookCoroutine>d__4(0)
			{
				behaviour = behaviour
			};
		}

		[HarmonyPatch(typeof(StartLabOvenBehaviour), "StopCook")]
		[HarmonyPrefix]
		public static bool StopCookPrefix(StartLabOvenBehaviour __instance)
		{
			if ((Object)(object)__instance.targetOven != (Object)null)
			{
				__instance.targetOven.SetNPCUser((NetworkObject)null);
			}
			object field = Sched1PatchesBase.GetField(typeof(StartLabOvenBehaviour), "cookRoutine", __instance);
			if (field != null)
			{
				MelonCoroutines.Stop(field);
				Sched1PatchesBase.SetField(typeof(StartLabOvenBehaviour), "cookRoutine", __instance, null);
			}
			return false;
		}

		[HarmonyPatch(typeof(FinishLabOvenBehaviour), "RpcLogic___StartAction_2166136261")]
		[HarmonyPrefix]
		public static bool Rpc_StartFinishCookPrefix(FinishLabOvenBehaviour __instance)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			if (Sched1PatchesBase.GetField(typeof(FinishLabOvenBehaviour), "actionRoutine", __instance) != null)
			{
				return false;
			}
			if ((Object)(object)__instance.targetOven == (Object)null)
			{
				return false;
			}
			object obj = MelonCoroutines.Start(FinishCookCoroutine(__instance));
			Sched1PatchesBase.SetField(typeof(FinishLabOvenBehaviour), "actionRoutine", __instance, (object)(Coroutine)obj);
			return false;
		}

		[IteratorStateMachine(typeof(<FinishCookCoroutine>d__7))]
		private static IEnumerator FinishCookCoroutine(FinishLabOvenBehaviour behaviour)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <FinishCookCoroutine>d__7(0)
			{
				behaviour = behaviour
			};
		}

		[HarmonyPatch(typeof(FinishLabOvenBehaviour), "StopAction")]
		[HarmonyPrefix]
		public static bool StopActionPrefix(FinishLabOvenBehaviour __instance)
		{
			__instance.targetOven.SetNPCUser((NetworkObject)null);
			((Behaviour)__instance).Npc.SetEquippable_Networked((NetworkConnection)null, string.Empty);
			((Behaviour)__instance).Npc.SetAnimationBool_Networked((NetworkConnection)null, "UseHammer", false);
			object field = Sched1PatchesBase.GetField(typeof(FinishLabOvenBehaviour), "actionRoutine", __instance);
			if (field != null)
			{
				MelonCoroutines.Stop(field);
				Sched1PatchesBase.SetField(typeof(FinishLabOvenBehaviour), "actionRoutine", __instance, null);
			}
			return false;
		}

		public new static void RestoreDefaults()
		{
		}
	}
	[HarmonyPatch]
	public class MixingStationPatches : Sched1PatchesBase
	{
		[CompilerGenerated]
		private sealed class <StartMixCoroutine>d__8 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public StartMixingStationBehaviour behaviour;

			private float <stationSpeed>5__1;

			private QualityItemInstance <product>5__2;

			private ItemInstance <mixer>5__3;

			private int <mixQuantity>5__4;

			private float <mixTime>5__5;

			private int <i>5__6;

			private MixOperation <operation>5__7;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<product>5__2 = null;
				<mixer>5__3 = null;
				<operation>5__7 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Expected O, but got Unknown
				//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0207: Expected O, but got Unknown
				//IL_029c: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02bc: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if (!Sched1PatchesBase.Mod.settings.enableStationAnimationAcceleration)
					{
						<stationSpeed>5__1 = 1f;
					}
					else if (Sched1PatchesBase.Is<MixingStationMk2>((Object)(object)behaviour.targetStation))
					{
						<stationSpeed>5__1 = Sched1PatchesBase.Mod.settings.GetStationSpeed("MixingStationMk2");
					}
					else
					{
						<stationSpeed>5__1 = Sched1PatchesBase.Mod.settings.GetStationSpeed("MixingStation");
					}
					((Behaviour)behaviour).Npc.Movement.FacePoint(((Component)behaviour.targetStation).transform.position, 0.5f);
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!(bool)Sched1PatchesBase.CallMethod(typeof(StartMixingStationBehaviour), "CanCookStart", behaviour, Array.Empty<object>()))
					{
						Sched1PatchesBase.CallMethod(typeof(StartMixingStationBehaviour), "StopCook", behaviour, Array.Empty<object>());
						((Behaviour)behaviour).End_Networked((NetworkConnection)null);
						return false;
					}
					behaviour.targetStation.SetNPCUser(((NetworkBehaviour)((Behaviour)behaviour).Npc).NetworkObject);
					((Behaviour)behaviour).Npc.SetAnimationBool_Networked((NetworkConnection)null, "UseChemistryStation", true);
					<product>5__2 = Sched1PatchesBase.CastTo<QualityItemInstance>((Object)(object)behaviour.targetStation.ProductSlot.ItemInstance);
					<mixer>5__3 = behaviour.targetStation.MixerSlot.ItemInstance;
					<mixQuantity>5__4 = behaviour.targetStation.GetMixQuantity();
					<mixTime>5__5 = (float)<mixQuantity>5__4 / <stationSpeed>5__1;
					<i>5__6 = 0;
					break;
				case 2:
				{
					<>1__state = -1;
					int num = <i>5__6 + 1;
					<i>5__6 = num;
					break;
				}
				}
				if ((float)<i>5__6 < <mixTime>5__5)
				{
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				}
				if (InstanceFinder.IsServer)
				{
					behaviour.targetStation.ProductSlot.ChangeQuantity(-<mixQuantity>5__4, false);
					behaviour.targetStation.MixerSlot.ChangeQuantity(-<mixQuantity>5__4, false);
					<operation>5__7 = new MixOperation(((ItemInstance)<product>5__2).ID, <product>5__2.Quality, <mixer>5__3.ID, <mixQuantity>5__4);
					behaviour.targetStation.SendMixingOperation(<operation>5__7, 0);
					<operation>5__7 = null;
				}
				Sched1PatchesBase.CallMethod(typeof(StartMixingStationBehaviour), "StopCook", behaviour, Array.Empty<object>());
				((Behaviour)behaviour).End_Networked((NetworkConnection)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();
			}
		}

		[HarmonyPatch(typeof(MixingStation), "GetMixQuantity")]
		[HarmonyPrefix]
		public static bool GetMixQuantityPrefix(MixingStation __instance, ref int __result)
		{
			if (!Sched1PatchesBase.Mod.processedStationCapacities.Contains((GridItem)(object)__instance))
			{
				if (Sched1PatchesBase.Is<MixingStationMk2>((Object)(object)__instance))
				{
					if (!Sched1PatchesBase.Mod.originalStationCapacities.ContainsKey("MixingStationMk2"))
					{
						Sched1PatchesBase.Mod.originalStationCapacities["MixingStationMk2"] = __instance.MaxMixQuantity;
					}
					__instance.MaxMixQuantity = Sched1PatchesBase.Mod.settings.GetStationCapacity("MixingStationMk2");
				}
				else
				{
					if (!Sched1PatchesBase.Mod.originalStationCapacities.ContainsKey("MixingStation"))
					{
						Sched1PatchesBase.Mod.originalStationCapacities["MixingStation"] = __instance.MaxMixQuantity;
					}
					__instance.MaxMixQuantity = Sched1PatchesBase.Mod.settings.GetStationCapacity("MixingStation");
				}
				Sched1PatchesBase.Mod.processedStationCapacities.Add((GridItem)(object)__instance);
			}
			if ((Object)(object)__instance.GetProduct() == (Object)null || (Object)(object)__instance.GetMixer() == (Object)null)
			{
				__result = 0;
				return false;
			}
			__result = Mathf.Min(Mathf.Min(__instance.ProductSlot.Quantity, __instance.MixerSlot.Quantity), __instance.MaxMixQuantity);
			return false;
		}

		[HarmonyPatch(typeof(MixingStation), "CanStartMix")]
		[HarmonyPostfix]
		public static void CanStartMixPostfix(MixingStation __instance, ref bool __result)
		{
			__result = __instance.GetMixQuantity() > 0 && __instance.OutputSlot.Quantity == 0;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		public static void IsMixingDonePostfix(MixingStation __instance, ref bool __result)
		{
			__result = __instance.CurrentMixOperation != null && __instance.CurrentMixTime >= __instance.GetMixTimeForCurrentOperation();
		}

		[HarmonyPatch(typeof(MixingStation), "GetMixTimeForCurrentOperation")]
		[HarmonyPrefix]
		public static bool GetMixTimePrefix(MixingStation __instance, ref int __result)
		{
			if (!Sched1PatchesBase.Mod.processedStationSpeeds.Contains((GridItem)(object)__instance))
			{
				if (Sched1PatchesBase.Is<MixingStationMk2>((Object)(object)__instance))
				{
					if (!Sched1PatchesBase.Mod.originalStationTimes.ContainsKey("MixingStationMk2"))
					{
						Sched1PatchesBase.Mod.originalStationTimes["MixingStationMk2"] = 3;
					}
					__instance.MixTimePerItem = (int)Mathf.Max((float)Sched1PatchesBase.Mod.originalStationTimes["MixingStationMk2"] / Sched1PatchesBase.Mod.settings.GetStationSpeed("MixingStationMk2"), 1f);
				}
				else
				{
					if (!Sched1PatchesBase.Mod.originalStationTimes.ContainsKey("MixingStation"))
					{
						Sched1PatchesBase.Mod.originalStationTimes["MixingStation"] = 15;
					}
					__instance.MixTimePerItem = (int)Mathf.Max((float)Sched1PatchesBase.Mod.originalStationTimes["MixingStation"] / Sched1PatchesBase.Mod.settings.GetStationSpeed("MixingStation"), 1f);
				}
				Sched1PatchesBase.Mod.processedStationSpeeds.Add((GridItem)(object)__instance);
			}
			float stationSpeed;
			int num;
			if (Sched1PatchesBase.Is<MixingStationMk2>((Object)(object)__instance))
			{
				stationSpeed = Sched1PatchesBase.Mod.settings.GetStationSpeed("MixingStationMk2");
				num = Sched1PatchesBase.Mod.originalStationTimes["MixingStationMk2"];
			}
			else
			{
				stationSpeed = Sched1PatchesBase.Mod.settings.GetStationSpeed("MixingStation");
				num = Sched1PatchesBase.Mod.originalStationTimes["MixingStation"];
			}
			float num2 = (float)num / stationSpeed;
			if (__instance.CurrentMixOperation == null)
			{
				__result = 0;
				return false;
			}
			__result = (int)Mathf.Max(num2 * (float)__instance.CurrentMixOperation.Quantity, 1f);
			return false;
		}

		[HarmonyPatch(typeof(Chemist), "GetMixStationsReadyToMove")]
		[HarmonyPrefix]
		public static bool GetMixStationsReadyToMovePrefix(Chemist __instance, ref List<MixingStation> __result)
		{
			List<MixingStation> val = new List<MixingStation>();
			Enumerator<MixingStation> enumerator = Sched1PatchesBase.CastTo<ChemistConfiguration>(Sched1PatchesBase.GetProperty(typeof(Chemist), "configuration", __instance)).MixStations.GetEnumerator();
			while (enumerator.MoveNext())
			{
				MixingStation current = enumerator.Current;
				ItemSlot outputSlot = current.OutputSlot;
				BuildableItem selectedObject = Sched1PatchesBase.CastTo<MixingStationConfiguration>((Object)(object)current.Configuration).Destination.SelectedObject;
				if (outputSlot.Quantity == 0 || !((Employee)__instance).MoveItemBehaviour.IsTransitRouteValid(Sched1PatchesBase.CastTo<MixingStationConfiguration>((Object)(object)current.Configuration).DestinationRoute, outputSlot.ItemInstance.ID))
				{
					continue;
				}
				if (Sched1PatchesBase.Is<PackagingStation>((Object)(object)selectedObject))
				{
					PackagingStation val2 = Sched1PatchesBase.CastTo<PackagingStation>((Object)(object)selectedObject);
					int stackLimit = Sched1PatchesBase.Mod.settings.GetStackLimit(val2.InputSlots[0].ItemInstance);
					if (stackLimit - val2.InputSlots[0].Quantity > stackLimit / 2)
					{
						val.Add(current);
					}
				}
				else
				{
					val.Add(current);
				}
			}
			__result = val;
			return false;
		}

		[HarmonyPatch(typeof(StartMixingStationBehaviour), "StartCook")]
		[HarmonyPrefix]
		public static void StartCookPrefix(StartMixingStationBehaviour __instance)
		{
			if (Sched1PatchesBase.Mod.processedStationCapacities.Contains((GridItem)(object)__instance.targetStation))
			{
				return;
			}
			if (Sched1PatchesBase.Is<MixingStationMk2>((Object)(object)__instance))
			{
				if (!Sched1PatchesBase.Mod.originalStationCapacities.ContainsKey("MixingStationMk2"))
				{
					Sched1PatchesBase.Mod.originalStationCapacities["MixingStationMk2"] = __instance.targetStation.MaxMixQuantity;
				}
				__instance.targetStation.MaxMixQuantity = Sched1PatchesBase.Mod.settings.GetStationCapacity("MixingStationMk2");
			}
			else
			{
				if (!Sched1PatchesBase.Mod.originalStationCapacities.ContainsKey("MixingStation"))
				{
					Sched1PatchesBase.Mod.originalStationCapacities["MixingStation"] = __instance.targetStation.MaxMixQuantity;
				}
				__instance.targetStation.MaxMixQuantity = Sched1PatchesBase.Mod.settings.GetStationCapacity("MixingStation");
			}
			Sched1PatchesBase.Mod.processedStationCapacities.Add((GridItem)(object)__instance.targetStation);
		}

		[HarmonyPatch(typeof(MixingStation), "MinPass")]
		[HarmonyPrefix]
		public static bool MinPassPrefix(MixingStation __instance)
		{
			if (__instance.CurrentMixOperation != null || __instance.OutputSlot.Quantity > 0)
			{
				int num = 0;
				if (__instance.CurrentMixOperation != null)
				{
					int currentMixTime = __instance.CurrentMixTime;
					int currentMixTime2 = __instance.CurrentMixTime;
					Sched1PatchesBase.SetProperty(typeof(MixingStation), "CurrentMixTime", __instance, currentMixTime2 + 1);
					num = __instance.GetMixTimeForCurrentOperation();
					if (__instance.CurrentMixTime >= num && currentMixTime < num && InstanceFinder.IsServer)
					{
						NetworkSingleton<VariableDatabase>.Instance.SetVariableValue("Mixing_Operations_Completed", (NetworkSingleton<VariableDatabase>.Instance.GetValue<float>("Mixing_Operations_Completed") + 1f).ToString(), true);
						__instance.MixingDone_Networked();
					}
				}
				if ((Object)(object)__instance.Clock != (Object)null)
				{
					__instance.Clock.SetScreenLit(true);
					__instance.Clock.DisplayMinutes(Mathf.Max(num - __instance.CurrentMixTime, 0));
				}
				if ((Object)(object)__instance.Light != (Object)null)
				{
					if (__instance.IsMixingDone)
					{
						__instance.Light.isOn = NetworkSingleton<TimeManager>.Instance.DailyMinTotal % 2 == 0;
						return false;
					}
					__instance.Light.isOn = true;
					return false;
				}
			}
			else
			{
				if ((Object)(object)__instance.Clock != (Object)null)
				{
					__instance.Clock.SetScreenLit(false);
					__instance.Clock.DisplayText(string.Empty);
				}
				if ((Object)(object)__instance.Light != (Object)null && __instance.IsMixingDone)
				{
					__instance.Light.isOn = false;
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(StartMixingStationBehaviour), "RpcLogic___StartCook_2166136261")]
		[HarmonyPrefix]
		public static bool Rpc_StartCookPrefix(StartMixingStationBehaviour __instance)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			if (Sched1PatchesBase.GetField(typeof(StartMixingStationBehaviour), "startRoutine", __instance) != null)
			{
				return false;
			}
			if ((Object)(object)__instance.targetStation == (Object)null)
			{
				return false;
			}
			object obj = MelonCoroutines.Start(StartMixCoroutine(__instance));
			Sched1PatchesBase.SetField(typeof(StartMixingStationBehaviour), "startRoutine", __instance, (object)(Coroutine)obj);
			return false;
		}

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

		[HarmonyPatch(typeof(StartMixingStationBehaviour), "StopCook")]
		[HarmonyPrefix]
		public static bool StopCookPrefix(StartMixingStationBehaviour __instance)
		{
			if ((Object)(object)__instance.targetStation != (Object)null)
			{
				__instance.targetStation.SetNPCUser((NetworkObject)null);
			}
			((Behaviour)__instance).Npc.SetAnimationBool_Networked((NetworkConnection)null, "UseChemistryStation", false);
			object field = Sched1PatchesBase.GetField(typeof(StartMixingStationBehaviour), "startRoutine", __instance);
			if (field != null)
			{
				MelonCoroutines.Stop(field);
				Sched1PatchesBase.SetField(typeof(StartMixingStationBehaviour), "startRoutine", __instance, null);
			}
			return false;
		}

		public new static void RestoreDefaults()
		{
			try
			{
				foreach (GridItem processedStationCapacity in Sched1PatchesBase.Mod.processedStationCapacities)
				{
					MixingStation val = Sched1PatchesBase.CastTo<MixingStation>((Object)(object)processedStationCapacity);
					if (!((Object)(object)val != (Object)null))
					{
						continue;
					}
					if (Sched1PatchesBase.Is<MixingStationMk2>((Object)(object)val))
					{
						if (!Sched1PatchesBase.Mod.originalStationCapacities.ContainsKey("MixingStationMk2"))
						{
							val.MaxMixQuantity = 20;
						}
						else
						{
							val.MaxMixQuantity = Sched1PatchesBase.Mod.originalStationCapacities["MixingStationMk2"];
						}
					}
					else if (!Sched1PatchesBase.Mod.originalStationCapacities.ContainsKey("MixingStation"))
					{
						val.MaxMixQuantity = 10;
					}
					else
					{
						val.MaxMixQuantity = Sched1PatchesBase.Mod.originalStationCapacities["MixingStation"];
					}
				}
				foreach (GridItem processedStationTime in Sched1PatchesBase.Mod.processedStationTimes)
				{
					MixingStation val2 = Sched1PatchesBase.CastTo<MixingStation>((Object)(object)processedStationTime);
					if (!Sched1PatchesBase.Mod.processedStationTimes.Contains(processedStationTime))
					{
						continue;
					}
					if (Sched1PatchesBase.Is<MixingStationMk2>((Object)(object)val2))
					{
						if (!Sched1PatchesBase.Mod.originalStationTimes.ContainsKey("MixingStationMk2"))
						{
							val2.MixTimePerItem = 3;
						}
						else
						{
							val2.MixTimePerItem = Sched1PatchesBase.Mod.originalStationTimes["MixingStationMk2"];
						}
					}
					else if (!Sched1PatchesBase.Mod.originalStationTimes.ContainsKey("MixingStation"))
					{
						val2.MixTimePerItem = 15;
					}
					else
					{
						val2.MixTimePerItem = Sched1PatchesBase.Mod.originalStationTimes["MixingStation"];
					}
				}
			}
			catch (Exception ex)
			{
				Sched1PatchesBase.Warn($"Couldn't restore defaults for {MethodBase.GetCurrentMethod().DeclaringType.Name}: {ex.GetType().Name} - {ex.Message}");
				Sched1PatchesBase.Warn("Source: " + ex.Source);
				Sched1PatchesBase.Warn(ex.StackTrace ?? "");
			}
		}

		[HarmonyPatch(typeof(MixingStationUIElement), "Initialize")]
		[HarmonyPrefix]
		public static void InitializeUIPrefix(MixingStation station)
		{
			int num = (Sched1PatchesBase.Is<MixingStationMk2>((Object)(object)station) ? Sched1PatchesBase.Mod.settings.GetStationCapacity("MixingStationMk2") : Sched1PatchesBase.Mod.settings.GetStationCapacity("MixingStation"));
			Sched1PatchesBase.CastTo<MixingStationConfiguration>((Object)(object)station.Configuration).StartThrehold.Configure(1f, (float)num, true);
		}
	}
	[HarmonyPatch]
	public class BrickPressPatches : Sched1PatchesBase
	{
		[CompilerGenerated]
		private sealed class <PackagingCoroutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public BrickPressBehaviour behaviour;

			private float <stationSpeed>5__1;

			private float <packageTime>5__2;

			private ProductItemInstance <product>5__3;

			private float <i>5__4;

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

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

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

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

			private bool MoveNext()
			{
				//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d8: Expected O, but got Unknown
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Expected O, but got Unknown
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Expected O, but got Unknown
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<stationSpeed>5__1 = (Sched1PatchesBase.Mod.settings.enableStationAnimationAcceleration ? Sched1PatchesBase.Mod.settings.GetStationSpeed("BrickPress") : 1f);
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Behaviour)behaviour).Npc.Avatar.Anim.SetBool("UsePackagingStation", true);
					<packageTime>5__2 = 15f / (Sched1PatchesBase.CastTo<Packager>((Object)(object)((Behaviour)behaviour).Npc).PackagingSpeedMultiplier * <stationSpeed>5__1);
					<i>5__4 = 0f;
					goto IL_0144;
				case 2:
					<>1__state = -1;
					<i>5__4 += Time.deltaTime;
					goto IL_0144;
				case 3:
					<>1__state = -1;
					((Behaviour)behaviour).Npc.Avatar.Anim.SetTrigger("GrabItem");
					behaviour.Press.PlayPressAnim();
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 4;
					return true;
				case 4:
					{
						<>1__state = -1;
						if (InstanceFinder.IsServer && behaviour.Press.HasSufficientProduct(ref <product>5__3))
						{
							behaviour.Press.CompletePress(<product>5__3);
						}
						Sched1PatchesBase.SetProperty(typeof(BrickPressBehaviour), "PackagingInProgress", behaviour, false);
						Sched1PatchesBase.SetField(typeof(BrickPressBehaviour), "packagingRoutine", behaviour, null);
						return false;
					}
					IL_0144:
					if (<i>5__4 < <packageTime>5__2)
					{
						((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(behaviour.Press.uiPoint.position, 0, false);
						<>2__current = (object)new WaitForEndOfFrame();
						<>1__state = 2;
						return true;
					}
					((Behaviour)behaviour).Npc.Avatar.Anim.SetBool("UsePackagingStation", false);
					<>2__current = (object)new WaitForSeconds(0.2f);
					<>1__state = 3;
					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();
			}
		}

		[HarmonyPatch(typeof(BrickPressBehaviour), "RpcLogic___BeginPackaging_2166136261")]
		[HarmonyPrefix]
		public static bool Rpc_BeginPackagingPrefix(BrickPressBehaviour __instance)
		{
			//IL_005a: 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_0091: Expected O, but got Unknown
			if (__instance.PackagingInProgress)
			{
				return false;
			}
			if ((Object)(object)__instance.Press == (Object)null)
			{
				return false;
			}
			Sched1PatchesBase.SetProperty(typeof(BrickPressBehaviour), "PackagingInProgress", __instance, true);
			((Behaviour)__instance).Npc.Movement.FaceDirection(__instance.Press.StandPoint.forward, 0.5f);
			object obj = MelonCoroutines.Start(PackagingCoroutine(__instance));
			Sched1PatchesBase.SetField(typeof(BrickPressBehaviour), "packagingRoutine", __instance, (object)(Coroutine)obj);
			return false;
		}

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

		public new static void RestoreDefaults()
		{
		}
	}
	[HarmonyPatch]
	public class CauldronPatches : Sched1PatchesBase
	{
		[CompilerGenerated]
		private sealed class <BeginCauldronCoroutine>d__5 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public StartCauldronBehaviour behaviour;

			private float <packageTime>5__1;

			private float <i>5__2;

			private EQuality <quality>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Expected O, but got Unknown
				//IL_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Behaviour)behaviour).Npc.Avatar.Anim.SetBool("UseChemistryStation", true);
					<packageTime>5__1 = 15f / Sched1PatchesBase.Mod.settings.GetStationSpeed("Cauldron");
					<i>5__2 = 0f;
					break;
				case 2:
					<>1__state = -1;
					<i>5__2 += Time.deltaTime;
					break;
				}
				if (<i>5__2 < <packageTime>5__1)
				{
					((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(behaviour.Station.LinkOrigin.position, 0, false);
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 2;
					return true;
				}
				((Behaviour)behaviour).Npc.Avatar.Anim.SetBool("UseChemistryStation", false);
				if (InstanceFinder.IsServer)
				{
					<quality>5__3 = behaviour.Station.RemoveIngredients();
					behaviour.Station.StartCookOperation((NetworkConnection)null, behaviour.Station.CookTime, <quality>5__3);
				}
				Sched1PatchesBase.SetProperty(typeof(StartCauldronBehaviour), "WorkInProgress", behaviour, false);
				Sched1PatchesBase.SetField(typeof(StartCauldronBehaviour), "workRoutine", behaviour, 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();
			}
		}

		[HarmonyPatch(typeof(Cauldron), "UpdateIngredientVisuals")]
		[HarmonyPrefix]
		public static bool UpdateIngredientVisualsPatch(Cauldron __instance)
		{
			int stackLimit = Sched1PatchesBase.Mod.settings.GetStackLimit("Coca Leaf", (EItemCategory)2);
			ItemInstance val = default(ItemInstance);
			int num = default(int);
			ItemInstance val2 = default(ItemInstance);
			int num2 = default(int);
			__instance.GetMainInputs(ref val, ref num, ref val2, ref num2);
			if (val != null)
			{
				__instance.PrimaryTub.Configure((EContents)1, (float)num / (float)stackLimit);
			}
			else
			{
				__instance.PrimaryTub.Configure((EContents)0, 0f);
			}
			if (val2 != null)
			{
				__instance.SecondaryTub.Configure((EContents)1, (float)num2 / (float)stackLimit);
				return false;
			}
			__instance.SecondaryTub.Configure((EContents)0, 0f);
			return false;
		}

		[HarmonyPatch(typeof(Cauldron), "StartCookOperation")]
		[HarmonyPrefix]
		public static void StartCookOperationPrefix(Cauldron __instance, ref int remainingCookTime)
		{
			if (!Sched1PatchesBase.Mod.processedStationTimes.Contains((GridItem)(object)__instance))
			{
				if (!Sched1PatchesBase.Mod.originalStationTimes.ContainsKey("Cauldron"))
				{
					Sched1PatchesBase.Mod.originalStationTimes["Cauldron"] = __instance.CookTime;
				}
				int cookTime = (int)((float)Sched1PatchesBase.Mod.originalStationTimes["Cauldron"] / Sched1PatchesBase.Mod.settings.GetStationSpeed("Cauldron"));
				__instance.CookTime = cookTime;
				Sched1PatchesBase.Mod.processedStationTimes.Add((GridItem)(object)__instance);
			}
			remainingCookTime = (int)((float)Sched1PatchesBase.Mod.originalStationTimes["Cauldron"] / Sched1PatchesBase.Mod.settings.GetStationSpeed("Cauldron"));
		}

		[HarmonyPatch(typeof(Cauldron), "HasOutputSpace")]
		[HarmonyPostfix]
		public static void HasOutputSpacePostfix(Cauldron __instance, ref bool __result)
		{
			__result = Sched1PatchesBase.Mod.settings.GetStackLimit((ItemDefinition)(object)__instance.CocaineBaseDefinition) >= 10;
		}

		[HarmonyPatch(typeof(Cauldron), "GetState")]
		[HarmonyPostfix]
		public static void GetStatePostfix(Cauldron __instance, ref EState __result)
		{
			if ((bool)Sched1PatchesBase.GetProperty(typeof(Cauldron), "isCooking", __instance))
			{
				__result = (EState)2;
			}
			else if (!__instance.HasIngredients())
			{
				__result = (EState)0;
			}
			else if (!__instance.HasOutputSpace())
			{
				__result = (EState)3;
			}
			else
			{
				__result = (EState)1;
			}
		}

		[HarmonyPatch(typeof(StartCauldronBehaviour), "RpcLogic___BeginCauldron_2166136261")]
		[HarmonyPrefix]
		public static bool Rpc_BeginCauldronPrefix(StartCauldronBehaviour __instance)
		{
			//IL_005a: 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_0091: Expected O, but got Unknown
			if (__instance.WorkInProgress)
			{
				return false;
			}
			if ((Object)(object)__instance.Station == (Object)null)
			{
				return false;
			}
			Sched1PatchesBase.SetProperty(typeof(StartCauldronBehaviour), "WorkInProgress", __instance, true);
			((Behaviour)__instance).Npc.Movement.FaceDirection(__instance.Station.StandPoint.forward, 0.5f);
			object obj = MelonCoroutines.Start(BeginCauldronCoroutine(__instance));
			Sched1PatchesBase.SetField(typeof(StartCauldronBehaviour), "workRoutine", __instance, (object)(Coroutine)obj);
			return false;
		}

		[IteratorStateMachine(typeof(<BeginCauldronCoroutine>d__5))]
		private static IEnumerator BeginCauldronCoroutine(StartCauldronBehaviour behaviour)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <BeginCauldronCoroutine>d__5(0)
			{
				behaviour = behaviour
			};
		}

		[HarmonyPatch(typeof(StartCauldronBehaviour), "StopCauldron")]
		[HarmonyPrefix]
		public static bool StopCauldronPrefix(StartCauldronBehaviour __instance)
		{
			object field = Sched1PatchesBase.GetField(typeof(StartCauldronBehaviour), "workRoutine", __instance);
			if (field != null)
			{
				MelonCoroutines.Stop(field);
				Sched1PatchesBase.SetField(typeof(StartCauldronBehaviour), "workRoutine", __instance, null);
			}
			if (InstanceFinder.IsServer && (Object)(object)__instance.Station != (Object)null && (Object)(object)__instance.Station.NPCUserObject == (Object)(object)((NetworkBehaviour)((Behaviour)__instance).Npc).NetworkObject)
			{
				__instance.Station.SetNPCUser((NetworkObject)null);
			}
			Sched1PatchesBase.SetProperty(typeof(StartCauldronBehaviour), "WorkInProgress", __instance, false);
			return false;
		}

		public new static void RestoreDefaults()
		{
			try
			{
				foreach (GridItem processedStationTime in Sched1PatchesBase.Mod.processedStationTimes)
				{
					Cauldron val = Sched1PatchesBase.CastTo<Cauldron>((Object)(object)processedStationTime);
					if ((Object)(object)val != (Object)null)
					{
						if (!Sched1PatchesBase.Mod.originalStationTimes.ContainsKey("Cauldron"))
						{
							val.CookTime = 360;
							val.RemainingCookTime = Mathf.Min(360, val.RemainingCookTime);
						}
						else
						{
							val.CookTime = Mathf.Min(Sched1PatchesBase.Mod.originalStationTimes["Cauldron"], val.CookTime);
							val.RemainingCookTime = Mathf.Min(Sched1PatchesBase.Mod.originalStationTimes["Cauldron"], val.RemainingCookTime);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Sched1PatchesBase.Warn($"Couldn't restore defaults for {MethodBase.GetCurrentMethod().DeclaringType.Name}: {ex.GetType().Name} - {ex.Message}");
				Sched1PatchesBase.Warn("Source: " + ex.Source);
				Sched1PatchesBase.Warn(ex.StackTrace ?? "");
			}
		}
	}
	[HarmonyPatch]
	public class PackagingStationPatches : Sched1PatchesBase
	{
		[CompilerGenerated]
		private sealed class <BeginPackagingCoroutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PackagingStationBehaviour behaviour;

			private ProductItemInstance <packagedInstance>5__1;

			private int <outputSpace>5__2;

			private int <productPerPackage>5__3;

			private int <availableToPackage>5__4;

			private int <numPackages>5__5;

			private float <packageTime>5__6;

			private float <i>5__7;

			private float <value>5__8;

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

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

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

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

			private bool MoveNext()
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fe: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForEndOfFrame();
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					((Behaviour)behaviour).Npc.Avatar.Anim.SetBool("UsePackagingStation", true);
					<packagedInstance>5__1 = Sched1PatchesBase.CastTo<ProductItemInstance>((Object)(object)behaviour.Station.ProductSlot.ItemInstance.GetCopy(1));
					<packagedInstance>5__1.SetPackaging(Sched1PatchesBase.CastTo<PackagingDefinition>((Object)(object)behaviour.Station.PackagingSlot.ItemInstance.Definition));
					<outputSpace>5__2 = behaviour.Station.OutputSlot.GetCapacityForItem((ItemInstance)(object)<packagedInstance>5__1, false);
					<productPerPackage>5__3 = Sched1PatchesBase.CastTo<PackagingDefinition>((Object)(object)behaviour.Station.PackagingSlot.ItemInstance.Definition).Quantity;
					<availableToPackage>5__4 = Mathf.Min(behaviour.Station.ProductSlot.Quantity, behaviour.Station.PackagingSlot.Quantity);
					<numPackages>5__5 = Mathf.Min(<availableToPackage>5__4 / <productPerPackage>5__3, <outputSpace>5__2);
					<packageTime>5__6 = (float)<numPackages>5__5 * 5f / (Sched1PatchesBase.CastTo<Packager>((Object)(object)((Behaviour)behaviour).Npc).PackagingSpeedMultiplier * behaviour.Station.PackagerEmployeeSpeedMultiplier * Sched1PatchesBase.Mod.settings.stationSpeeds["PackagingStation"]);
					<i>5__7 = 0f;
					break;
				case 2:
					<>1__state = -1;
					<i>5__7++;
					break;
				}
				if (<i>5__7 < <packageTime>5__6)
				{
					((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(behaviour.Station.Container.position, 0, false);
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				}
				if (InstanceFinder.IsServer)
				{
					<value>5__8 = NetworkSingleton<VariableDatabase>.Instance.GetValue<float>("PackagedProductCount");
					NetworkSingleton<VariableDatabase>.Instance.SetVariableValue("PackagedProductCount", (<value>5__8 + (float)(<numPackages>5__5 * <productPerPackage>5__3)).ToString(), true);
					if (behaviour.Station.OutputSlot.ItemInstance == null)
					{
						behaviour.Station.OutputSlot.SetStoredItem((ItemInstance)(object)<packagedInstance>5__1, false);
						behaviour.Station.OutputSlot.SetQuantity(<numPackages>5__5, false);
					}
					else
					{
						behaviour.Station.OutputSlot.ChangeQuantity(<numPackages>5__5, false);
						((ItemInstance)<packagedInstance>5__1).SetQuantity(0);
					}
					behaviour.Station.PackagingSlot.ChangeQuantity(-<numPackages>5__5, false);
					behaviour.Station.ProductSlot.ChangeQuantity(-<numPackages>5__5 * <productPerPackage>5__3, false);
				}
				((Behaviour)behaviour).Npc.Avatar.Anim.SetBool("UsePackagingStation", false);
				Sched1PatchesBase.SetProperty(typeof(PackagingStationBehaviour), "PackagingInProgress", behaviour, false);
				Sched1PatchesBase.SetField(typeof(PackagingStationBehaviour), "packagingRoutine", behaviour, 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();
			}
		}

		[HarmonyPatch(typeof(PackagingStationBehaviour), "RpcLogic___BeginPackaging_2166136261")]
		[HarmonyPrefix]
		public static bool RpcLogic_BeginPackagingPrefix(PackagingStationBehaviour __instance)
		{
			//IL_0053: 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_008a: Expected O, but got Unknown
			if (__instance.PackagingInProgress || (Object)(object)__instance.Station == (Object)null)
			{
				return false;
			}
			Sched1PatchesBase.SetProperty(typeof(PackagingStationBehaviour), "PackagingInProgress", __instance, true);
			((Behaviour)__instance).Npc.Movement.FaceDirection(__instance.Station.StandPoint.forward, 0.5f);
			object obj = MelonCoroutines.Start(BeginPackagingCoroutine(__instance));
			Sched1PatchesBase.SetField(typeof(PackagingStationBehaviour), "packagingRoutine", __instance, (object)(Coroutine)obj);
			return false;
		}

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

		[HarmonyPatch(typeof(PackagingStationBehaviour), "StopPackaging")]
		[HarmonyPrefix]
		public static bool StopPackagingPrefix(PackagingStationBehaviour __instance)
		{
			object field = Sched1PatchesBase.GetField(typeof(PackagingStationBehaviour), "packagingRoutine", __instance);
			if (field != null)
			{
				MelonCoroutines.Stop(field);
				Sched1PatchesBase.SetField(typeof(PackagingStationBehaviour), "packagingRoutine", __instance, null);
			}
			((Behaviour)__instance).Npc.Avatar.Anim.SetBool("UsePackagingStation", false);
			if (InstanceFinder.IsServer && (Object)(object)__instance.Station != (Object)null && (Object)(object)__instance.Station.NPCUserObject == (Object)(object)((NetworkBehaviour)((Behaviour)__instance).Npc).NetworkObject)
			{
				__instance.Station.SetNPCUser((NetworkObject)null);
			}
			Sched1PatchesBase.SetProperty(typeof(PackagingStationBehaviour), "PackagingInProgress", __instance, false);
			return false;
		}

		public new static void RestoreDefaults()
		{
		}
	}
	[HarmonyPatch]
	public class PotPatches : Sched1PatchesBase
	{
		[CompilerGenerated]
		private sealed class <PerformActionCoroutine>d__2 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PotActionBehaviour behaviour;

			private float <stationSpeed>5__1;

			private string <actionAnimation>5__2;

			private AvatarEquippable <actionEquippable>5__3;

			private float <waitTime>5__4;

			private float <i>5__5;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Invalid comparison between Unknown and I4
				//IL_026b: 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_0283: Expected O, but got Unknown
				//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0222: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<stationSpeed>5__1 = (Sched1PatchesBase.Mod.settings.enableStationAnimationAcceleration ? Sched1PatchesBase.Mod.settings.GetStationSpeed("Pot") : 1f);
					behaviour.AssignedPot.SetNPCUser(((NetworkBehaviour)Sched1PatchesBase.CastTo<Botanist>(Sched1PatchesBase.GetField(typeof(PotActionBehaviour), "botanist", behaviour))).NetworkObject);
					((Behaviour)behaviour).Npc.Movement.FacePoint(((Component)behaviour.AssignedPot).transform.position, 0.5f);
					<actionAnimation>5__2 = (string)Sched1PatchesBase.CallMethod(typeof(PotActionBehaviour), "GetActionAnimation", behaviour, new object[1] { behaviour.CurrentActionType });
					if (<actionAnimation>5__2 != string.Empty)
					{
						Sched1PatchesBase.SetField(typeof(PotActionBehaviour), "currentActionAnimation", behaviour, <actionAnimation>5__2);
						((Behaviour)behaviour).Npc.SetAnimationBool_Networked((NetworkConnection)null, <actionAnimation>5__2, true);
					}
					if ((int)behaviour.CurrentActionType == 2 && !((Behaviour)behaviour).Npc.Avatar.Anim.IsCrouched)
					{
						((Behaviour)behaviour).Npc.SetCrouched_Networked(true);
					}
					<actionEquippable>5__3 = Sched1PatchesBase.CastTo<AvatarEquippable>(Sched1PatchesBase.CallMethod(typeof(PotActionBehaviour), "GetActionEquippable", behaviour, new object[1] { behaviour.CurrentActionType }));
					if ((Object)(object)<actionEquippable>5__3 != (Object)null)
					{
						Sched1PatchesBase.SetField(typeof(PotActionBehaviour), "currentActionEquippable", behaviour, ((Behaviour)behaviour).Npc.SetEquippable_Networked_Return((NetworkConnection)null, <actionEquippable>5__3.AssetPath));
					}
					<waitTime>5__4 = behaviour.GetWaitTime(behaviour.CurrentActionType) / <stationSpeed>5__1;
					<i>5__5 = 0f;
					break;
				case 1:
					<>1__state = -1;
					<i>5__5 += Time.deltaTime;
					break;
				}
				if (<i>5__5 < <waitTime>5__4)
				{
					((Behaviour)behaviour).Npc.Avatar.LookController.OverrideLookTarget(((Component)behaviour.AssignedPot).transform.position, 0, false);
					<>2__current = (object)new WaitForEndO