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 TrophyEater v1.0.0
TrophyEater.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("TrophyEater")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("TrophyEater")] [assembly: AssemblyTitle("TrophyEater")] [assembly: AssemblyVersion("1.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 TrophyEater { public class ConfigurationManagerAttributes { public int? Order; } [BepInPlugin("Harchytek.TrophyEater", "TrophyEater", "1.0.0")] public class TrophyEaterPlugin : BaseUnityPlugin { public enum SkillChoice { Random, Axes, Blocking, Bows, Clubs, Crossbows, Knives, Polearms, Spears, Swords, Unarmed, BloodMagic, ElementalMagic, Pickaxes, WoodCutting, Farming, Fishing, Crafting, Cooking, Dodge, Jump, Ride, Run, Sneak, Swim } public class TrophySettings { public ConfigEntry<float> Points; public ConfigEntry<SkillChoice> Skill; public ConfigEntry<float> Duration; } public const string ModGUID = "Harchytek.TrophyEater"; public const string ModName = "TrophyEater"; public const string ModVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("Harchytek.TrophyEater"); public static Dictionary<string, TrophySettings> TrophyConfigs = new Dictionary<string, TrophySettings>(); public static ConfigEntry<bool> EnableBossCategory; public static ConfigEntry<bool> EnableBossSummoningCategory; public static readonly string[] BossItems = new string[7] { "TrophyEikthyr", "TrophyTheElder", "TrophyBonemass", "TrophyDragonQueen", "TrophyGoblinKing", "TrophySeekerQueen", "TrophyFader" }; public static readonly string[] BossSummoningItems = new string[7] { "TrophyDeer", "AncientSeed", "WitheredBone", "DragonEgg", "GoblinTotem", "DvergrKeyFragment", "BellFragment" }; public static Dictionary<string, string> ItemToPower = new Dictionary<string, string> { { "TrophyEikthyr", "GP_Eikthyr" }, { "TrophyTheElder", "GP_TheElder" }, { "TrophyBonemass", "GP_Bonemass" }, { "TrophyDragonQueen", "GP_Moder" }, { "TrophyGoblinKing", "GP_Yagluth" }, { "TrophySeekerQueen", "GP_Queen" }, { "TrophyFader", "GP_Fader" }, { "TrophyDeer", "GP_Eikthyr" }, { "AncientSeed", "GP_TheElder" }, { "WitheredBone", "GP_Bonemass" }, { "DragonEgg", "GP_Moder" }, { "GoblinTotem", "GP_Yagluth" }, { "DvergrKeyFragment", "GP_Queen" }, { "BellFragment", "GP_Fader" } }; public static Dictionary<string, string> PowerTranslations = new Dictionary<string, string> { { "GP_Eikthyr", "Eikthyr" }, { "GP_TheElder", "The Elder" }, { "GP_Bonemass", "Bonemass" }, { "GP_Moder", "Moder" }, { "GP_Yagluth", "Yagluth" }, { "GP_Queen", "The Queen" }, { "GP_Fader", "Fader" } }; private void Awake() { SetupTrophies(); harmony.PatchAll(); } private void SetupTrophies() { //IL_071c: Unknown result type (might be due to invalid IL or missing references) //IL_0726: Expected O, but got Unknown //IL_0775: Unknown result type (might be due to invalid IL or missing references) //IL_077f: Expected O, but got Unknown //IL_0929: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Expected O, but got Unknown //IL_0973: Unknown result type (might be due to invalid IL or missing references) //IL_097d: Expected O, but got Unknown //IL_0844: Unknown result type (might be due to invalid IL or missing references) //IL_084e: Expected O, but got Unknown //IL_088f: Unknown result type (might be due to invalid IL or missing references) //IL_0899: Expected O, but got Unknown //IL_08d9: Unknown result type (might be due to invalid IL or missing references) //IL_08e3: Expected O, but got Unknown int num = 10000; Dictionary<string, float> dictionary = new Dictionary<string, float> { { "TrophyBoar", 4f }, { "TrophyDeer", 8f }, { "TrophyNeck", 10f }, { "TrophySerpent", 150f }, { "TrophyEikthyr", 100f }, { "TrophyGreydwarf", 5f }, { "TrophyGreydwarfBrute", 25f }, { "TrophyGreydwarfShaman", 15f }, { "TrophySkeletonPoison", 25f }, { "TrophySkeleton", 10f }, { "TrophyGhost", 20f }, { "TrophyFrostTroll", 30f }, { "TrophyBjorn", 40f }, { "TrophySkeletonHildir", 100f }, { "TrophyTheElder", 200f }, { "TrophyAbomination", 150f }, { "TrophyBlob", 20f }, { "TrophyDraugr", 20f }, { "TrophyDraugrElite", 30f }, { "TrophyLeech", 25f }, { "TrophySurtling", 25f }, { "TrophyWraith", 30f }, { "TrophyKvastur", 60f }, { "TrophyBonemass", 300f }, { "TrophyCultist", 50f }, { "TrophyHatchling", 40f }, { "TrophyFenring", 40f }, { "TrophySGolem", 50f }, { "TrophyUlv", 50f }, { "TrophyWolf", 35f }, { "TrophyCultist_Hildir", 300f }, { "TrophyDragonQueen", 400f }, { "TrophyDeathsquito", 80f }, { "TrophyGoblin", 50f }, { "TrophyGoblinBrute", 70f }, { "TrophyGoblinShaman", 50f }, { "TrophyGrowth", 50f }, { "TrophyLox", 100f }, { "TrophyBjornUndead", 150f }, { "TrophyGoblinBruteBrosShaman", 400f }, { "TrophyGoblinBruteBrosBrute", 400f }, { "TrophyGoblinKing", 500f }, { "TrophyDvergr", 300f }, { "TrophyHare", 50f }, { "TrophyGjall", 100f }, { "TrophySeeker", 80f }, { "TrophySeekerBrute", 110f }, { "TrophyTick", 70f }, { "TrophySeekerQueen", 600f }, { "TrophyAsksvin", 120f }, { "TrophyBonemawSerpent", 250f }, { "TrophyFallenValkyrie", 200f }, { "TrophyCharredArcher", 110f }, { "TrophyMorgen", 200f }, { "TrophyVolture", 80f }, { "TrophyCharredMage", 120f }, { "TrophyCharredMelee", 300f }, { "TrophyFader", 700f }, { "AncientSeed", 25f }, { "WitheredBone", 30f }, { "DragonEgg", 100f }, { "GoblinTotem", 70f }, { "DvergrKeyFragment", 100f }, { "BellFragment", 120f } }; Dictionary<string, float> dictionary2 = new Dictionary<string, float> { { "TrophyDeer", 120f }, { "AncientSeed", 120f }, { "WitheredBone", 120f }, { "DragonEgg", 300f }, { "GoblinTotem", 120f }, { "DvergrKeyFragment", 120f }, { "BellFragment", 120f } }; Dictionary<string, string[]> dictionary3 = new Dictionary<string, string[]>(); dictionary3.Add("Meadows", new string[3] { "TrophyBoar", "TrophyNeck", "TrophySerpent" }); dictionary3.Add("BlackForest", new string[9] { "TrophyGreydwarf", "TrophyGreydwarfBrute", "TrophyGreydwarfShaman", "TrophySkeletonPoison", "TrophySkeleton", "TrophyGhost", "TrophyFrostTroll", "TrophyBjorn", "TrophySkeletonHildir" }); dictionary3.Add("Swamp", new string[8] { "TrophyAbomination", "TrophyBlob", "TrophyDraugr", "TrophyDraugrElite", "TrophyLeech", "TrophySurtling", "TrophyWraith", "TrophyKvastur" }); dictionary3.Add("Mountains", new string[7] { "TrophyCultist", "TrophyHatchling", "TrophyFenring", "TrophySGolem", "TrophyUlv", "TrophyWolf", "TrophyCultist_Hildir" }); dictionary3.Add("Plains", new string[9] { "TrophyDeathsquito", "TrophyGoblin", "TrophyGoblinBrute", "TrophyGoblinShaman", "TrophyGrowth", "TrophyLox", "TrophyBjornUndead", "TrophyGoblinBruteBrosShaman", "TrophyGoblinBruteBrosBrute" }); dictionary3.Add("Mistlands", new string[6] { "TrophyDvergr", "TrophyHare", "TrophyGjall", "TrophySeeker", "TrophySeekerBrute", "TrophyTick" }); dictionary3.Add("Ashlands", new string[8] { "TrophyAsksvin", "TrophyBonemawSerpent", "TrophyFallenValkyrie", "TrophyCharredArcher", "TrophyMorgen", "TrophyVolture", "TrophyCharredMage", "TrophyCharredMelee" }); dictionary3.Add("Bosses", BossItems); dictionary3.Add("Boss Summoning", BossSummoningItems); Dictionary<string, string[]> dictionary4 = dictionary3; foreach (KeyValuePair<string, string[]> item in dictionary4) { if (item.Key == "Bosses") { EnableBossCategory = ((BaseUnityPlugin)this).Config.Bind<bool>("Bosses", "Enable Bosses Category", true, new ConfigDescription("Enable or disable the entire Bosses category.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = num-- } })); } else if (item.Key == "Boss Summoning") { EnableBossSummoningCategory = ((BaseUnityPlugin)this).Config.Bind<bool>("Boss Summoning", "Enable Boss Summoning Category", true, new ConfigDescription("Enable or disable the entire Boss Summoning category.", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = num-- } })); } string[] value = item.Value; foreach (string text in value) { float num2 = (dictionary.ContainsKey(text) ? dictionary[text] : 1f); bool flag = item.Key == "Bosses" || dictionary2.ContainsKey(text); ConfigEntry<float> duration = null; ConfigEntry<float> points; ConfigEntry<SkillChoice> skill; if (flag) { float num3 = ((item.Key == "Bosses") ? 300f : dictionary2[text]); duration = ((BaseUnityPlugin)this).Config.Bind<float>(item.Key, text + "_Duration", num3, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = num-- } })); points = ((BaseUnityPlugin)this).Config.Bind<float>(item.Key, text + "_Points", num2, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = num-- } })); skill = ((BaseUnityPlugin)this).Config.Bind<SkillChoice>(item.Key, text + "_Skill", SkillChoice.Random, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = num-- } })); } else { points = ((BaseUnityPlugin)this).Config.Bind<float>(item.Key, text + "_Points", num2, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = num-- } })); skill = ((BaseUnityPlugin)this).Config.Bind<SkillChoice>(item.Key, text + "_Skill", SkillChoice.Random, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = num-- } })); } TrophyConfigs[text] = new TrophySettings { Points = points, Skill = skill, Duration = duration }; } } } public static SkillType GetSkillType(SkillChoice choice) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (choice == SkillChoice.Random) { SkillType[] array = (from SkillType s in Enum.GetValues(typeof(SkillType)) where (int)s > 0 && (int)s < 999 select s).ToArray(); return array[Random.Range(0, array.Length)]; } if (!Enum.TryParse<SkillType>(choice.ToString(), out SkillType result)) { return (SkillType)1; } return result; } public static string GetTranslation(string key, params object[] args) { string selectedLanguage = Localization.instance.GetSelectedLanguage(); string format = ""; if (selectedLanguage == "French") { switch (key) { case "TooltipPoints": format = "\nAjoute <color=orange>{0}</color> points pour <color=orange>{1}</color> skill."; break; case "TooltipPower": format = "\nAccorde le buff <color=orange>{0}</color> pour <color=orange>{1}</color> sec."; break; case "MessageSkill": format = "Vous augmentez {0} points de compétence pour {1}"; break; } } else { switch (key) { case "TooltipPoints": format = "\nAdds <color=orange>{0}</color> points to <color=orange>{1}</color> skill."; break; case "TooltipPower": format = "\nGrants <color=orange>{0}</color> power for <color=orange>{1}</color> sec."; break; case "MessageSkill": format = "You increase {0} skill points to {1}"; break; } } return string.Format(format, args); } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class MakeConsumablePatch { private static void Postfix(ObjectDB __instance) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) ItemDrop val = default(ItemDrop); foreach (KeyValuePair<string, TrophyEaterPlugin.TrophySettings> trophyConfig in TrophyEaterPlugin.TrophyConfigs) { string key = trophyConfig.Key; if ((TrophyEaterPlugin.BossItems.Contains(key) && !TrophyEaterPlugin.EnableBossCategory.Value) || (TrophyEaterPlugin.BossSummoningItems.Contains(key) && !TrophyEaterPlugin.EnableBossSummoningCategory.Value)) { continue; } TrophyEaterPlugin.TrophySettings value = trophyConfig.Value; bool flag = value.Points.Value > 0f; bool flag2 = value.Duration != null && value.Duration.Value > 0f; if (flag || flag2) { GameObject itemPrefab = __instance.GetItemPrefab(key); if (itemPrefab != null && itemPrefab.TryGetComponent<ItemDrop>(ref val)) { val.m_itemData.m_shared.m_itemType = (ItemType)2; val.m_itemData.m_shared.m_food = 0f; } } } } } [HarmonyPatch] public static class TooltipPatch { [HarmonyTargetMethod] private static MethodBase TargetMethod() { return typeof(ItemData).GetMethods().First((MethodInfo m) => m.Name == "GetTooltip" && m.GetParameters().Length >= 1); } private static void Postfix(ItemData __instance, ref string __result) { if ((Object)(object)__instance?.m_dropPrefab == (Object)null || !TrophyEaterPlugin.TrophyConfigs.ContainsKey(((Object)__instance.m_dropPrefab).name)) { return; } string name = ((Object)__instance.m_dropPrefab).name; if ((!TrophyEaterPlugin.BossItems.Contains(name) || TrophyEaterPlugin.EnableBossCategory.Value) && (!TrophyEaterPlugin.BossSummoningItems.Contains(name) || TrophyEaterPlugin.EnableBossSummoningCategory.Value)) { TrophyEaterPlugin.TrophySettings trophySettings = TrophyEaterPlugin.TrophyConfigs[name]; if (trophySettings.Points.Value > 0f) { __result += TrophyEaterPlugin.GetTranslation("TooltipPoints", trophySettings.Points.Value, trophySettings.Skill.Value); } if (trophySettings.Duration != null && trophySettings.Duration.Value > 0f && TrophyEaterPlugin.ItemToPower.TryGetValue(name, out var value)) { string text = (TrophyEaterPlugin.PowerTranslations.ContainsKey(value) ? TrophyEaterPlugin.PowerTranslations[value] : value); __result += TrophyEaterPlugin.GetTranslation("TooltipPower", text, trophySettings.Duration.Value); } } } } [HarmonyPatch(typeof(Player), "ConsumeItem")] public static class ConsumePatch { private static void Postfix(Player __instance, ItemData item, ref bool __result) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) if (!__result || (Object)(object)item?.m_dropPrefab == (Object)null || !TrophyEaterPlugin.TrophyConfigs.ContainsKey(((Object)item.m_dropPrefab).name)) { return; } string name = ((Object)item.m_dropPrefab).name; if ((TrophyEaterPlugin.BossItems.Contains(name) && !TrophyEaterPlugin.EnableBossCategory.Value) || (TrophyEaterPlugin.BossSummoningItems.Contains(name) && !TrophyEaterPlugin.EnableBossSummoningCategory.Value)) { return; } TrophyEaterPlugin.TrophySettings trophySettings = TrophyEaterPlugin.TrophyConfigs[name]; if (trophySettings.Points.Value > 0f) { SkillType skillType = TrophyEaterPlugin.GetSkillType(trophySettings.Skill.Value); ((Character)__instance).RaiseSkill(skillType, trophySettings.Points.Value); string translation = TrophyEaterPlugin.GetTranslation("MessageSkill", trophySettings.Points.Value, skillType); ((Character)__instance).Message((MessageType)2, translation, 0, (Sprite)null); } if (trophySettings.Duration == null || !(trophySettings.Duration.Value > 0f)) { return; } if (TrophyEaterPlugin.ItemToPower.TryGetValue(name, out var seName)) { StatusEffect val = ((IEnumerable<StatusEffect>)ObjectDB.instance.m_StatusEffects).FirstOrDefault((Func<StatusEffect, bool>)((StatusEffect se) => ((Object)se).name == seName)); if ((Object)(object)val != (Object)null) { StatusEffect val2 = Object.Instantiate<StatusEffect>(val); val2.m_ttl = trophySettings.Duration.Value; ((Character)__instance).GetSEMan().AddStatusEffect(val2, true, 0, 0f); } } } } }