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 JonekTrollMeatMod v1.2.0
Jonek_TrollMeatMod/JonekMods_TrollMeat.dll
Decompiled a day agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; 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("JonekMods_TrollMeat")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("JonekMods_TrollMeat")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ed77de49-0e25-48ed-bde3-3fa888549246")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace JonekMods.TrollMeat; [BepInPlugin("pl.jonek.trollmeat", "Jonek - Troll Meat", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class TrollMeatMod : BaseUnityPlugin { public const string ModGuid = "pl.jonek.trollmeat"; public const string ModName = "Jonek - Troll Meat"; public const string ModVersion = "1.2.0"; private const string RawPrefab = "Jonek_TrollMeat_Raw"; private const string CookedPrefab = "Jonek_TrollMeat_Cooked"; private const string SoupPrefab = "Jonek_TrollMeat_Soup"; private bool soupRegistered; private AssetBundle modelBundle; private GameObject rawVisual; private GameObject cookedVisual; private GameObject soupVisual; private bool itemsRegistered; private bool trollDropRegistered; private ConfigEntry<int> minDrop; private ConfigEntry<int> maxDrop; private ConfigEntry<float> dropChance; private ConfigEntry<float> cookSeconds; private void Awake() { minDrop = ((BaseUnityPlugin)this).Config.Bind<int>("Drop", "Minimum", 2, "Minimalna ilosc miesa z trolla."); maxDrop = ((BaseUnityPlugin)this).Config.Bind<int>("Drop", "Maximum", 4, "Maksymalna ilosc miesa z trolla."); dropChance = ((BaseUnityPlugin)this).Config.Bind<float>("Drop", "Chance", 1f, "Szansa na drop od 0 do 1."); cookSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Cooking", "Seconds", 25f, "Czas pieczenia w sekundach."); LoadVisuals(); PrefabManager.OnVanillaPrefabsAvailable += RegisterItems; CreatureManager.OnVanillaCreaturesAvailable += AddTrollDrop; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Troll Meat: plugin zaladowany; czekam na prefaby gry."); } private void RegisterSoup() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown if (soupRegistered) { return; } try { CustomItem val = new CustomItem("Jonek_TrollMeat_Soup", "CarrotSoup"); SharedData shared = val.ItemDrop.m_itemData.m_shared; shared.m_name = "Troll meat soup"; shared.m_description = "Dense trol soup, providing +40Hp, +30 stamina for 25 minutes."; shared.m_itemType = (ItemType)2; shared.m_food = 40f; shared.m_foodStamina = 30f; shared.m_foodBurnTime = 1500f; shared.m_maxStackSize = 10; SetIcon(shared, "troll_meat_soup.png"); InstallVisuals(val.ItemPrefab, soupVisual, "soup"); if (!ItemManager.Instance.AddItem(val)) { throw new Exception("Nie udało się zarejestrować zupki."); } RecipeConfig val2 = new RecipeConfig { Name = "Recipe_Jonek_TrollMeat_Soup", Item = "Jonek_TrollMeat_Soup", Amount = 1, CraftingStation = "piece_cauldron", MinStationLevel = 1 }; val2.AddRequirement("Jonek_TrollMeat_Raw", 2, 0); val2.AddRequirement("Carrot", 3, 0); val2.AddRequirement("Dandelion", 2, 0); val2.AddRequirement("Thistle", 1, 0); ItemManager.Instance.AddRecipe(new CustomRecipe(val2)); soupRegistered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Zupka z trolla i przepis zarejestrowane!"); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Błąd rejestracji zupki: " + ex)); } } private void RegisterItems() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown if (itemsRegistered) { return; } try { CustomItem val = new CustomItem("Jonek_TrollMeat_Raw", "DeerMeat"); ConfigureRawMeat(val); InstallVisuals(val.ItemPrefab, rawVisual, "raw"); if (!ItemManager.Instance.AddItem(val)) { throw new Exception("Jotunn odrzucil surowe mieso."); } CustomItem val2 = new CustomItem("Jonek_TrollMeat_Cooked", "CookedDeerMeat"); ConfigureCookedMeat(val2); InstallVisuals(val2.ItemPrefab, cookedVisual, "cooked"); if (!ItemManager.Instance.AddItem(val2)) { throw new Exception("Jotunn odrzucil pieczone mieso."); } ItemManager.Instance.AddItemConversion(new CustomItemConversion((ConversionConfig)new CookingConversionConfig { FromItem = "Jonek_TrollMeat_Raw", ToItem = "Jonek_TrollMeat_Cooked", Station = CookingStations.CookingStation, CookTime = Mathf.Max(1f, cookSeconds.Value) })); itemsRegistered = true; PrefabManager.OnVanillaPrefabsAvailable -= RegisterItems; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Troll Meat: zarejestrowano surowe/pieczone mieso i przepis na drewniany rozno."); AddTrollDrop(); RegisterSoup(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Troll Meat: blad rejestracji przedmiotow: " + ex)); } } private void LoadVisuals() { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string text = Path.Combine(directoryName, "trollmeatassets"); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Brak " + text + "; pozostawiam modele jelenia.")); return; } try { modelBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)modelBundle == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("AssetBundle nie zostal wczytany: " + text)); return; } rawVisual = modelBundle.LoadAsset<GameObject>("TrollMeatRawVisual"); cookedVisual = modelBundle.LoadAsset<GameObject>("TrollMeatCookedVisual"); soupVisual = modelBundle.LoadAsset<GameObject>("TrollMeatSoupVisual"); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Bundle: raw=" + ((Object)(object)rawVisual != (Object)null) + ", cooked=" + ((Object)(object)cookedVisual != (Object)null) + ", soup=" + ((Object)(object)soupVisual != (Object)null))); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Blad wczytywania modeli: " + ex)); } } private void InstallVisuals(GameObject itemPrefab, GameObject visual, string label) { if ((Object)(object)visual == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Brak nowego modelu " + label + "; zostawiam stary.")); return; } Transform val = FindChildRecursive(itemPrefab.transform, "model"); if ((Object)(object)val != (Object)null) { ReplaceRenderersIn(val, visual, label + " / swiat"); } else if ((Object)(object)itemPrefab.GetComponent<MeshRenderer>() != (Object)null) { ReplaceRenderersIn(itemPrefab.transform, visual, label + " / swiat (root)"); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Nie odnaleziono 'model' dla " + label + ". Wypisuje hierarchie; nie zmieniam starego modelu.")); PrintHierarchy(itemPrefab.transform, ""); } Transform val2 = FindChildRecursive(itemPrefab.transform, "attach"); if ((Object)(object)val2 != (Object)null) { if ((Object)(object)val2 != (Object)(object)val) { ReplaceRenderersIn(val2, visual, label + " / rozen"); } } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Brak 'attach' dla " + label + ": sprawdz pieczenie na drewnianym roznie.")); } } private void ReplaceRenderersIn(Transform destination, GameObject visual, string label) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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) MeshRenderer[] componentsInChildren = ((Component)destination).GetComponentsInChildren<MeshRenderer>(true); MeshRenderer[] array = componentsInChildren; foreach (MeshRenderer val in array) { ((Renderer)val).enabled = false; } SkinnedMeshRenderer[] componentsInChildren2 = ((Component)destination).GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer[] array2 = componentsInChildren2; foreach (SkinnedMeshRenderer val2 in array2) { ((Renderer)val2).enabled = false; } GameObject val3 = Object.Instantiate<GameObject>(visual, destination, false); ((Object)val3).name = "JonekTrollMeat_Visual"; val3.transform.localPosition = Vector3.zero; val3.transform.localRotation = Quaternion.identity; float num = 0.3f; val3.transform.localScale = Vector3.one * num; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Model: " + label + " | Skala lokalna: " + ((object)val3.transform.localScale/*cast due to .constrained prefix*/).ToString() + " | Skala globalna: " + ((object)val3.transform.lossyScale/*cast due to .constrained prefix*/).ToString() + " | Skala rodzica: " + ((object)destination.lossyScale/*cast due to .constrained prefix*/).ToString())); } private Transform FindChildRecursive(Transform root, string name) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown foreach (Transform item in root) { Transform val = item; if (string.Equals(((Object)val).name, name, StringComparison.OrdinalIgnoreCase)) { return val; } Transform val2 = FindChildRecursive(val, name); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } private void PrintHierarchy(Transform root, string prefix) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)(prefix + ((Object)root).name)); foreach (Transform item in root) { Transform root2 = item; PrintHierarchy(root2, prefix + " "); } } private void ConfigureRawMeat(CustomItem raw) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) SharedData shared = raw.ItemDrop.m_itemData.m_shared; shared.m_name = "Raw troll meat"; shared.m_description = "Needs to be cooked. So you can eat it."; shared.m_itemType = (ItemType)1; shared.m_food = 0f; shared.m_foodStamina = 0f; shared.m_maxStackSize = 20; SetIcon(shared, "troll_meat_raw.png"); } private void ConfigureCookedMeat(CustomItem cooked) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) SharedData shared = cooked.ItemDrop.m_itemData.m_shared; shared.m_name = "Cooked troll meat"; shared.m_description = "Yummy and strong!"; shared.m_itemType = (ItemType)2; shared.m_food = 30f; shared.m_foodStamina = 20f; shared.m_foodBurnTime = 1200f; shared.m_maxStackSize = 20; SetIcon(shared, "troll_meat_cooked.png"); } private void SetIcon(SharedData data, string fileName) { string directoryName = Path.GetDirectoryName(typeof(TrollMeatMod).Assembly.Location); string text = Path.Combine(directoryName, "Assets", fileName); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Nie znaleziono ikony: " + text + "; pozostawiam ikone z Valheima.")); return; } Sprite val = AssetUtils.LoadSpriteFromFile(text); if ((Object)(object)val != (Object)null) { data.m_icons = (Sprite[])(object)new Sprite[1] { val }; } } private void AddTrollDrop() { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown if (trollDropRegistered) { return; } try { GameObject creaturePrefab = CreatureManager.Instance.GetCreaturePrefab("Troll"); GameObject meatPrefab = PrefabManager.Instance.GetPrefab("Jonek_TrollMeat_Raw"); if ((Object)(object)creaturePrefab == (Object)null || (Object)(object)meatPrefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Brak prefabu Troll lub miesa; ponowie przy nastepnym wywolaniu."); return; } CharacterDrop component = creaturePrefab.GetComponent<CharacterDrop>(); if ((Object)(object)component == (Object)null) { throw new Exception("Troll nie ma CharacterDrop."); } if (!component.m_drops.Exists((Drop drop) => (Object)(object)drop.m_prefab == (Object)(object)meatPrefab || ((Object)(object)drop.m_prefab != (Object)null && ((Object)drop.m_prefab).name == "Jonek_TrollMeat_Raw"))) { int num = Mathf.Max(1, minDrop.Value); int amountMax = Mathf.Max(num, maxDrop.Value); component.m_drops.Add(new Drop { m_prefab = meatPrefab, m_amountMin = num, m_amountMax = amountMax, m_chance = Mathf.Clamp01(dropChance.Value), m_levelMultiplier = false, m_onePerPlayer = false }); } trollDropRegistered = true; CreatureManager.OnVanillaCreaturesAvailable -= AddTrollDrop; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Troll Meat: drop trolla zarejestrowany."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Troll Meat: blad dodania dropu trolla: " + ex)); } } }