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 v2.1.1
TrophyEater.dll
Decompiled 5 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", "2.1.1")] 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 = "2.1.1"; 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_088c: Unknown result type (might be due to invalid IL or missing references) //IL_0896: Expected O, but got Unknown //IL_08d6: Unknown result type (might be due to invalid IL or missing references) //IL_08e0: Expected O, but got Unknown //IL_0841: Unknown result type (might be due to invalid IL or missing references) //IL_084b: 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", 100f }, { "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; 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-- } })); } ConfigEntry<float> points = ((BaseUnityPlugin)this).Config.Bind<float>(item.Key, text + "_Points", num2, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Order = num-- } })); ConfigEntry<SkillChoice> 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) { bool flag = Localization.instance.GetSelectedLanguage() == "French"; string format = ""; if (flag) { 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(Humanoid), "UseItem")] public static class UseTrophyPatch { private static bool Prefix(Humanoid __instance, Inventory inventory, ItemData item, bool fromInventoryGui) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00f2: Unknown result type (might be due to invalid IL or missing references) if (!fromInventoryGui) { return true; } Player val = (Player)(object)((__instance is Player) ? __instance : null); if ((Object)(object)val == (Object)null || (Object)(object)item?.m_dropPrefab == (Object)null || !TrophyEaterPlugin.TrophyConfigs.ContainsKey(((Object)item.m_dropPrefab).name)) { return true; } string name = ((Object)item.m_dropPrefab).name; if (TrophyEaterPlugin.BossItems.Contains(name) && !TrophyEaterPlugin.EnableBossCategory.Value) { return true; } if (TrophyEaterPlugin.BossSummoningItems.Contains(name) && !TrophyEaterPlugin.EnableBossSummoningCategory.Value) { return true; } TrophyEaterPlugin.TrophySettings trophySettings = TrophyEaterPlugin.TrophyConfigs[name]; bool flag = false; if (trophySettings.Points.Value > 0f) { SkillType skillType = TrophyEaterPlugin.GetSkillType(trophySettings.Skill.Value); ((Character)val).RaiseSkill(skillType, trophySettings.Points.Value); ((Character)val).Message((MessageType)2, TrophyEaterPlugin.GetTranslation("MessageSkill", trophySettings.Points.Value, skillType), 0, (Sprite)null, false); flag = true; } if (trophySettings.Duration != null && trophySettings.Duration.Value > 0f && TrophyEaterPlugin.ItemToPower.TryGetValue(name, out var seName)) { StatusEffect val2 = ((IEnumerable<StatusEffect>)ObjectDB.instance.m_StatusEffects).FirstOrDefault((Func<StatusEffect, bool>)((StatusEffect se) => ((Object)se).name == seName)); if ((Object)(object)val2 != (Object)null) { StatusEffect val3 = Object.Instantiate<StatusEffect>(val2); val3.m_ttl = trophySettings.Duration.Value; ((Character)val).GetSEMan().AddStatusEffect(val3, true, 0, 0f, (short)(-1)); flag = true; } } if (flag) { ZSyncAnimation value = Traverse.Create((object)val).Field("m_zanim").GetValue<ZSyncAnimation>(); if ((Object)(object)value != (Object)null) { value.SetTrigger("consume"); } inventory.RemoveOneItem(item); return false; } return true; } } [HarmonyPatch] public static class TooltipPatch { private static MethodBase TargetMethod() { Type typeFromHandle = typeof(ItemData); IEnumerable<MethodInfo> source = from m in typeFromHandle.GetMethods(BindingFlags.Instance | BindingFlags.Public) where m.Name == "GetTooltip" select m; return source.FirstOrDefault(); } 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); } } } } }