Decompiled source of FreeKnownRecipesMod v1.0.5

FreeKnownRecipesMod.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FreeKnownRecipesMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FreeKnownRecipesMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("970e4468-7249-41ad-a189-4817befc968b")]
[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 FreeKnownRecipesMod;

[BepInPlugin("com.yourname.myfreerecipemod", "Free Known Recipes", "1.0.4")]
public class MyFreeRecipesMod : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Requirement), "GetAmount")]
	public static class Requirement_GetAmount_Patch
	{
		public static void Postfix(ref int __result)
		{
			if (ModEnabled.Value)
			{
				__result = 0;
			}
		}
	}

	[HarmonyPatch(typeof(Player), "HaveRequirements", new Type[]
	{
		typeof(Piece),
		typeof(RequirementMode)
	})]
	public static class Player_HaveRequirements_Patch
	{
		public static bool Prefix(RequirementMode mode, ref bool __result)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			if (ModEnabled.Value && (int)mode == 0)
			{
				__result = true;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Player), "PlacePiece")]
	public static class Player_PlacePiece_Patch
	{
		public static void Prefix()
		{
			if (ModEnabled.Value)
			{
				_isPlacingPiece = true;
			}
		}

		public static void Postfix()
		{
			_isPlacingPiece = false;
		}
	}

	[HarmonyPatch(typeof(Player), "NoCostCheat")]
	public static class Player_NoCostCheat_Patch
	{
		public static void Postfix(ref bool __result)
		{
			if (ModEnabled.Value && _isPlacingPiece)
			{
				__result = true;
			}
		}
	}

	public static ConfigEntry<bool> ModEnabled;

	public static ConfigEntry<KeyboardShortcut> ToggleKey;

	private Harmony _harmony;

	private static bool _isPlacingPiece;

	private void Awake()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Expected O, but got Unknown
		ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable/disable free crafting, building, and upgrading.");
		ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ToggleKey", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Key to toggle the mod on/off.");
		_harmony = new Harmony("com.yourname.myfreerecipemod");
		_harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Free Known Recipes (Elegant Version) is loaded!");
	}

	private void Update()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		KeyboardShortcut value = ToggleKey.Value;
		if (((KeyboardShortcut)(ref value)).IsDown())
		{
			ModEnabled.Value = !ModEnabled.Value;
			string text = (ModEnabled.Value ? "ENABLED" : "DISABLED");
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)2, "Free Known Recipes: " + text, 0, (Sprite)null, false, true);
			}
		}
	}
}