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 SurtlingCoreCraft v1.0.0
SurtlingCoreCraft.dll
Decompiled 3 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [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 SurtlingCoreCraft { [BepInPlugin("saymonn.SurtlingCoreCraft", "SurtlingCoreCraft", "1.0.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class ZNetSceneAwakePatch { private static void Postfix() { AddRecipes(); } } [HarmonyPatch(typeof(Player), "OnSpawned")] private static class PlayerSpawnedAddPatch { [HarmonyPriority(800)] private static void Prefix() { ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance != (Object)null && !instance.m_recipes.Exists((Recipe r) => (Object)(object)r != (Object)null && ((Object)r).name.StartsWith("Recipe_SurtlingCoreCraft_"))) { AddRecipes(); } } } private static ConfigEntry<bool> modEnabled; private static ConfigEntry<bool> atArtisanTable; private static ConfigEntry<bool> atBlackForge; private static ConfigEntry<int> minStationLevel; private static ConfigEntry<int> craftAmount; private static ConfigEntry<string> item1; private static ConfigEntry<string> item2; private static ConfigEntry<string> item3; private static ConfigEntry<int> amount1; private static ConfigEntry<int> amount2; private static ConfigEntry<int> amount3; private const string RecipePrefix = "Recipe_SurtlingCoreCraft_"; private void Awake() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch. Takes effect on the next world load."); atArtisanTable = ((BaseUnityPlugin)this).Config.Bind<bool>("Stations", "ArtisanTable", true, "Allow crafting at the Artisan Table."); atBlackForge = ((BaseUnityPlugin)this).Config.Bind<bool>("Stations", "BlackForge", true, "Allow crafting at the Black Forge."); minStationLevel = ((BaseUnityPlugin)this).Config.Bind<int>("Stations", "MinStationLevel", 1, new ConfigDescription("Minimum station level needed (1 = any level).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>())); craftAmount = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "CraftAmount", 1, new ConfigDescription("How many Surtling Cores one craft gives.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), Array.Empty<object>())); item1 = ((BaseUnityPlugin)this).Config.Bind<string>("Recipe", "Ingredient1", "BlackMetal", "Prefab name of ingredient 1 (empty = unused)."); amount1 = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "Ingredient1Amount", 1, new ConfigDescription("Amount of ingredient 1.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 200), Array.Empty<object>())); item2 = ((BaseUnityPlugin)this).Config.Bind<string>("Recipe", "Ingredient2", "Coal", "Prefab name of ingredient 2 (empty = unused)."); amount2 = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "Ingredient2Amount", 4, new ConfigDescription("Amount of ingredient 2.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 200), Array.Empty<object>())); item3 = ((BaseUnityPlugin)this).Config.Bind<string>("Recipe", "Ingredient3", "Resin", "Prefab name of ingredient 3 (empty = unused)."); amount3 = ((BaseUnityPlugin)this).Config.Bind<int>("Recipe", "Ingredient3Amount", 1, new ConfigDescription("Amount of ingredient 3.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 200), Array.Empty<object>())); new Harmony("saymonn.SurtlingCoreCraft").PatchAll(); } private static void AddRecipes() { //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown ObjectDB instance = ObjectDB.instance; ZNetScene instance2 = ZNetScene.instance; if ((Object)(object)instance == (Object)null || (Object)(object)instance2 == (Object)null) { return; } instance.m_recipes.RemoveAll((Recipe r) => (Object)(object)r != (Object)null && ((Object)r).name.StartsWith("Recipe_SurtlingCoreCraft_")); if (!modEnabled.Value) { return; } GameObject itemPrefab = instance.GetItemPrefab("SurtlingCore"); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)"[SurtlingCoreCraft] SurtlingCore item not found."); return; } List<Requirement> list = new List<Requirement>(); string[] array = new string[3] { item1.Value, item2.Value, item3.Value }; int[] array2 = new int[3] { amount1.Value, amount2.Value, amount3.Value }; for (int num = 0; num < 3; num++) { string text = array[num]; int amount = array2[num]; if (!string.IsNullOrWhiteSpace(text)) { GameObject itemPrefab2 = instance.GetItemPrefab(text.Trim()); ItemDrop val2 = ((itemPrefab2 != null) ? itemPrefab2.GetComponent<ItemDrop>() : null); if ((Object)(object)val2 == (Object)null) { Debug.LogWarning((object)("[SurtlingCoreCraft] Ingredient not found: " + text)); continue; } list.Add(new Requirement { m_resItem = val2, m_amount = amount, m_amountPerLevel = 0, m_recover = true }); } } if (list.Count != 0) { if (atArtisanTable.Value) { Add(instance, val, list, FindStation(instance2, "$piece_artisanstation"), "Artisan"); } if (atBlackForge.Value) { Add(instance, val, list, FindStation(instance2, "$piece_blackforge"), "BlackForge"); } } } private static void Add(ObjectDB db, ItemDrop core, List<Requirement> reqs, CraftingStation station, string tag) { if ((Object)(object)station == (Object)null) { Debug.LogWarning((object)("[SurtlingCoreCraft] Station not found: " + tag)); return; } Recipe val = ScriptableObject.CreateInstance<Recipe>(); ((Object)val).name = "Recipe_SurtlingCoreCraft_" + tag; val.m_item = core; val.m_amount = craftAmount.Value; val.m_craftingStation = station; val.m_minStationLevel = minStationLevel.Value; val.m_enabled = true; val.m_resources = reqs.ToArray(); db.m_recipes.Add(val); } private static CraftingStation FindStation(ZNetScene scene, string nameKey) { foreach (GameObject prefab in scene.m_prefabs) { CraftingStation val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<CraftingStation>() : null); if ((Object)(object)val != (Object)null && val.m_name == nameKey) { return val; } } return null; } } }