Decompiled source of FoodSorting v1.0.1

FoodSorting.dll

Decompiled 4 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FoodSorting")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FoodSorting")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d42527f5-8915-4a40-905d-8d0290701c5c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CookingStationSorting;

[BepInPlugin("shalopay.FoodSorting", "FoodSorting", "1.0.0")]
[BepInProcess("valheim.exe")]
public class CookingStationSorting : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "GetAvailableRecipes")]
	private class AvailableRecipesPatch
	{
		private static void Postfix(ref List<Recipe> available)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			ManualLogSource val = new ManualLogSource("FoodSorting");
			Logger.Sources.Add((ILogSource)(object)val);
			available.Sort(delegate(Recipe a, Recipe b)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Invalid comparison between Unknown and I4
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Invalid comparison between Unknown and I4
				bool flag = (int)a.m_item.m_itemData.m_shared.m_itemType == 2;
				bool flag2 = (int)b.m_item.m_itemData.m_shared.m_itemType == 2;
				if (flag != flag2)
				{
					return flag2 ? 1 : (-1);
				}
				float value = a.m_item.m_itemData.m_shared.m_food + a.m_item.m_itemData.m_shared.m_foodStamina + a.m_item.m_itemData.m_shared.m_foodEitr;
				return (b.m_item.m_itemData.m_shared.m_food + b.m_item.m_itemData.m_shared.m_foodStamina + b.m_item.m_itemData.m_shared.m_foodEitr).CompareTo(value);
			});
			val.LogInfo((object)"Succesfully patched recipes order!");
		}
	}

	private readonly Harmony harmony = new Harmony("shalopay.FoodSorting");

	private void Awake()
	{
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"FoodSorting plugin has started!");
	}
}