Decompiled source of SharedRecipeFinder v1.0.0

SharedRecipeFinder.dll

Decompiled 9 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ShowItems")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShowItems")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3f1762ee-fcc9-4c00-ba8c-5e5a0fc07927")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SharedRecipeFinder;

[BepInPlugin("vnoisy.sharedrecipefinder.plugin", "SharedRecipeFinder", "1.0.0")]
[BepInProcess("valheim.exe")]
public class MainClass : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Container), "RPC_RequestOpen")]
	public class Container_RPC_RequestOpen_Patch
	{
		public static Color newColor = Color.red;

		public static void Postfix(Container __instance)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			bool flag = false;
			Player localPlayer = Player.m_localPlayer;
			List<ItemData> allItems = __instance.GetInventory().GetAllItems();
			List<Sprite> list = new List<Sprite>();
			foreach (ItemData item in allItems)
			{
				if (((int)item.m_shared.m_itemType == 1 || (int)item.m_shared.m_itemType == 2) && !localPlayer.IsKnownMaterial(item.m_shared.m_name))
				{
					list.Add(item.GetIcon());
					flag = true;
				}
			}
			if (!flag)
			{
				return;
			}
			((Character)localPlayer).Message((MessageType)2, "$msg_newitem", 0, (Sprite)null);
			list = list.Distinct().ToList();
			foreach (Sprite item2 in list)
			{
				MessageHud.instance.QueueUnlockMsg(item2, "$msg_newitem", "");
			}
		}
	}

	private readonly Harmony harmony = new Harmony("vnoisy.sharedrecipefinder.plugin");

	private void Awake()
	{
		harmony.PatchAll();
	}
}