Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of GrimNeedsChainsTK v1.0.69
GrimNeedsChainsTK.dll
Decompiled 4 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("GrimNeedsChainsTK")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Craft 2 Chains from 1 Iron at the Forge")] [assembly: AssemblyFileVersion("1.0.69.0")] [assembly: AssemblyInformationalVersion("1.0.69")] [assembly: AssemblyProduct("GrimNeedsChainsTK")] [assembly: AssemblyTitle("GrimNeedsChainsTK")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.69.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 GrimNeedsChainsTK { [BepInPlugin("com.grim.valheim.grimneedschainstk", "GrimNeedsChainsTK", "1.0.69")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] public static class ObjectDB_CopyOtherDB_Patch { [HarmonyPostfix] public static void Postfix(ObjectDB __instance) { AddChainRecipe(__instance); } } [HarmonyPatch(typeof(Player), "OnSpawned")] public static class Player_OnSpawned_Patch { [HarmonyPostfix] public static void Postfix() { if ((Object)(object)ObjectDB.instance != (Object)null) { AddChainRecipe(ObjectDB.instance); } } } public const string ModGUID = "com.grim.valheim.grimneedschainstk"; public const string ModName = "GrimNeedsChainsTK"; public const string ModVersion = "1.0.69"; private Harmony _harmony; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _harmony = new Harmony("com.grim.valheim.grimneedschainstk"); _harmony.PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; ((BaseUnityPlugin)this).Logger.LogInfo((object)"GrimNeedsChainsTK v1.0.69 loaded."); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if ((Object)(object)ObjectDB.instance != (Object)null) { AddChainRecipe(ObjectDB.instance); } } private static CraftingStation FindForgeStation(ObjectDB db) { if (db.m_recipes != null) { foreach (Recipe recipe in db.m_recipes) { if ((Object)(object)recipe != (Object)null && (Object)(object)recipe.m_craftingStation != (Object)null) { string text = ((Object)recipe.m_craftingStation).name.ToLower(); string text2 = ((recipe.m_craftingStation.m_name != null) ? recipe.m_craftingStation.m_name.ToLower() : ""); if (text.Contains("forge") || text2.Contains("forge")) { return recipe.m_craftingStation; } } } } if ((Object)(object)ZNetScene.instance != (Object)null) { GameObject prefab = ZNetScene.instance.GetPrefab("forge"); if ((Object)(object)prefab != (Object)null) { CraftingStation component = prefab.GetComponent<CraftingStation>(); if ((Object)(object)component != (Object)null) { return component; } } } return null; } private static void AddChainRecipe(ObjectDB db) { //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown if ((Object)(object)db == (Object)null || db.m_items == null || db.m_items.Count == 0) { return; } string recipeName = "Recipe_GrimChain_Forge"; Recipe val = db.m_recipes.Find((Recipe r) => (Object)(object)r != (Object)null && ((Object)r).name == recipeName); if ((Object)(object)val != (Object)null) { if (!((Object)(object)val.m_craftingStation != (Object)null)) { CraftingStation val2 = FindForgeStation(db); if ((Object)(object)val2 != (Object)null) { val.m_craftingStation = val2; } } return; } GameObject itemPrefab = db.GetItemPrefab("Chain"); GameObject itemPrefab2 = db.GetItemPrefab("Iron"); if ((Object)(object)itemPrefab == (Object)null || (Object)(object)itemPrefab2 == (Object)null) { return; } CraftingStation val3 = FindForgeStation(db); if (!((Object)(object)val3 == (Object)null)) { ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); ItemDrop component2 = itemPrefab2.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null)) { Recipe val4 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val4).name = recipeName; val4.m_item = component; val4.m_amount = 2; val4.m_enabled = true; val4.m_craftingStation = val3; val4.m_minStationLevel = 1; Requirement val5 = new Requirement { m_resItem = component2, m_amount = 1, m_amountPerLevel = 0, m_recover = true }; val4.m_resources = (Requirement[])(object)new Requirement[1] { val5 }; db.m_recipes.Add(val4); } } } } }