Decompiled source of Learn All Recipes v1.1.0

UnlockRecipes.dll

Decompiled 2 months ago
using System.Diagnostics;
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("UnlockRecipes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UnlockRecipes")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7040bc4b-f45c-4e96-ae7b-366e81ef1168")]
[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 LearnAllRecipesMod;

[BepInPlugin("com.yourname.learnallrecipes", "Learn All Recipes", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
	private static Plugin _instance;

	private Recipe[] _allRecipes = (Recipe[])(object)new Recipe[0];

	private bool _recipesCached = false;

	private string[] _recipeNames = new string[0];

	private void Awake()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		_instance = this;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Learn All Recipes Mod loaded!");
		Harmony val = new Harmony("com.yourname.learnallrecipes");
		val.PatchAll();
	}

	private void LoadRecipes()
	{
		_allRecipes = Resources.FindObjectsOfTypeAll<Recipe>();
		_recipeNames = new string[_allRecipes.Length];
		for (int i = 0; i < _allRecipes.Length; i++)
		{
			string[] recipeNames = _recipeNames;
			int num = i;
			Recipe obj = _allRecipes[i];
			recipeNames[num] = ((obj != null) ? obj.Name : null) ?? "(null)";
		}
		_recipesCached = true;
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"[LearnAllRecipesMod] Loaded {_allRecipes.Length} recipes.");
	}

	private void UnlockAll(Character character)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		LoadRecipes();
		object obj;
		if (character == null)
		{
			obj = null;
		}
		else
		{
			CharacterInventory inventory = character.Inventory;
			obj = ((inventory != null) ? inventory.RecipeKnowledge : null);
		}
		if ((Object)obj == (Object)null)
		{
			return;
		}
		int num = 0;
		Recipe[] allRecipes = _allRecipes;
		foreach (Recipe val in allRecipes)
		{
			if ((Object)(object)val != (Object)null && !character.Inventory.RecipeKnowledge.IsRecipeLearned(UID.op_Implicit(val.UID)))
			{
				character.Inventory.RecipeKnowledge.LearnRecipe(val);
				num++;
			}
		}
		if ((Object)(object)character.CharacterUI != (Object)null)
		{
			character.CharacterUI.ShowInfoNotification($"Learned {num} new recipes!");
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"[LearnAllRecipesMod] Unlocked {num} recipes.");
	}

	private void OnGUI()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		int num = 200;
		int num2 = 40;
		int num3 = Screen.width / 2 - num / 2;
		int num4 = 10;
		if (GUI.Button(new Rect((float)num3, (float)(num4 + num2 + 5), (float)num, (float)num2), "Unlock All Recipes"))
		{
			CharacterManager instance = CharacterManager.Instance;
			Character val = ((instance != null) ? instance.GetFirstLocalCharacter() : null);
			if ((Object)(object)val != (Object)null)
			{
				UnlockAll(val);
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[LearnAllRecipesMod] Could not find local player.");
			}
		}
	}
}