Decompiled source of SharedRecipes v1.0.1

plugins/SharedRecipes.dll

Decompiled 3 weeks ago
using System;
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 System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
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("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SharedRecipes;

[BepInPlugin("bluedom.sharedrecipes", "Shared Recipes", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(NetworkLevelLoader), "UnPauseGameplay")]
	public class NetworkLEvelLoader_UnPauseGameplay
	{
		[HarmonyPostfix]
		public static void UnPauseGameplay(NetworkLevelLoader __instance, string _identifier)
		{
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Log.LogMessage((object)"attempting to get recipes player recipes...");
				IList<string> list = new List<string>();
				for (int i = 0; i < CharacterManager.Instance.PlayerCharacters.Count; i++)
				{
					Character character = CharacterManager.Instance.GetCharacter(CharacterManager.Instance.PlayerCharacters.Values[i]);
					if (Object.op_Implicit((Object)(object)character))
					{
						IList<string> learnedItemUIDs = ((CharacterKnowledge)character.Inventory.RecipeKnowledge).GetLearnedItemUIDs();
						list.Concat(learnedItemUIDs);
					}
				}
				for (int j = 0; j < CharacterManager.Instance.PlayerCharacters.Count; j++)
				{
					foreach (string item in list)
					{
						Recipe val = RecipeManager.Instance.m_recipes[item];
						Character character2 = CharacterManager.Instance.GetCharacter(CharacterManager.Instance.PlayerCharacters.Values[j]);
						if (!character2.Inventory.RecipeKnowledge.IsRecipeLearned(UID.op_Implicit(val.UID)))
						{
							character2.Inventory.RecipeKnowledge.LearnRecipe(val);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogMessage((object)ex.Message);
			}
		}
	}

	[HarmonyPatch(typeof(CharacterRecipeKnowledge), "LearnRecipe")]
	public class CharacterRecipeKnowledge_LearnRecipe
	{
		[HarmonyPostfix]
		public static void LearnRecipe(Recipe _recipe)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < CharacterManager.Instance.PlayerCharacters.Count; i++)
			{
				Character character = CharacterManager.Instance.GetCharacter(CharacterManager.Instance.PlayerCharacters.Values[i]);
				if (!character.Inventory.RecipeKnowledge.IsRecipeLearned(UID.op_Implicit(_recipe.UID)))
				{
					character.Inventory.RecipeKnowledge.LearnRecipe(_recipe);
					Log.LogMessage((object)"learning recipe for all players: ");
					Log.LogMessage((object)_recipe.UID);
				}
			}
		}
	}

	public const string GUID = "bluedom.sharedrecipes";

	public const string NAME = "Shared Recipes";

	public const string VERSION = "1.0.0";

	internal static ManualLogSource Log;

	public static ConfigEntry<bool> ExampleConfig;

	internal void Awake()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogMessage((object)"Hello world from Shared Recipes 1.0.0!");
		new Harmony("bluedom.sharedrecipes").PatchAll();
	}

	internal void Update()
	{
	}
}