Decompiled source of ContainersUnlockRecipes v1.0.0

plugins\ContainersUnlockRecipes.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ContainersUnlockRecipes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ContainersUnlockRecipes")]
[assembly: AssemblyTitle("ContainersUnlockRecipes")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 ContainersUnlockRecipes
{
	[BepInPlugin("com.krill.containers_unlock_recipes", "Containers Unlock Recipes", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("com.krill.containers_unlock_recipes");
			_harmony.PatchAll();
			Log.LogInfo((object)"Containers Unlock Recipes loaded.");
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Show")]
	internal static class Patch_InventoryGui_Show
	{
		private static void Postfix(Container container)
		{
			if ((Object)(object)container == (Object)null)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			Inventory inventory = container.GetInventory();
			if (inventory == null)
			{
				return;
			}
			List<ItemData> allItems = inventory.GetAllItems();
			int num = 0;
			foreach (ItemData item in allItems)
			{
				if (!localPlayer.IsKnownMaterial(item.m_shared.m_name))
				{
					localPlayer.AddKnownItem(item);
					num++;
				}
			}
			if (num > 0)
			{
				Plugin.Log.LogInfo((object)$"Unlocked {num} new material(s) from container '{container.m_name}'.");
			}
		}
	}
	internal static class PluginInfo
	{
		public const string GUID = "com.krill.containers_unlock_recipes";

		public const string Name = "Containers Unlock Recipes";

		public const string Version = "1.0.0";
	}
}