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 TamedAnimalDrops v0.1.0
plugins/TamedAnimalDrops/TamedAnimalDrops.dll
Decompiled 17 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("TamedAnimalDrops")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("TamedAnimalDrops")] [assembly: AssemblyTitle("TamedAnimalDrops")] [assembly: AssemblyVersion("0.1.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 TamedAnimalDrops { public static class DropFloor { public const int Minimum = 2; private static readonly HashSet<string> Resources = new HashSet<string>(StringComparer.Ordinal) { "RawMeat", "DeerMeat", "WolfMeat", "LoxMeat", "HareMeat", "ChickenMeat", "AsksvinMeat", "SerpentMeat", "VoltureMeat", "BjornMeat", "MooseMeat", "LeatherScraps", "DeerHide", "WolfPelt", "LoxPelt", "ScaleHide", "AskHide", "BjornHide", "rae_HorseMeat", "rae_HorseHide", "BOH_RawHare_Meat", "BOH_BrownHare_Hide", "BOH_GreyHare_Hide", "BOH_WhiteHare_Hide", "GrizzlyBearPelt_TW", "RazorbackLeather_TW", "RottenPelt_TW", "BoneMawSerpentMeat" }; public static bool Applies(bool tamed, bool juvenile, bool player, bool boss, bool dropsEnabled) { return tamed && !juvenile && !player && !boss && dropsEnabled; } public static bool IsResource(string prefab, float chance, int maximum, bool onePerPlayer) { if (prefab != null && Resources.Contains(prefab) && chance > 0f && maximum > 0) { return !onePerPlayer; } return false; } public static List<KeyValuePair<T, int>> Apply<T>(IEnumerable<T> eligible, IList<KeyValuePair<T, int>> original) where T : class { if (original == null) { throw new ArgumentNullException("original"); } List<KeyValuePair<T, int>> list = new List<KeyValuePair<T, int>>(original); HashSet<T> hashSet = new HashSet<T>(); foreach (T item in eligible) { if (item == null || !hashSet.Add(item)) { continue; } long num = 0L; int num2 = -1; for (int i = 0; i < list.Count; i++) { if (EqualityComparer<T>.Default.Equals(list[i].Key, item)) { if (num2 < 0) { num2 = i; } num += Math.Max(0, list[i].Value); } } if (num > int.MaxValue) { continue; } KeyValuePair<T, int> keyValuePair = new KeyValuePair<T, int>(item, Math.Max(2, (int)num)); if (num2 < 0) { list.Add(keyValuePair); continue; } list[num2] = keyValuePair; for (int num3 = list.Count - 1; num3 > num2; num3--) { if (EqualityComparer<T>.Default.Equals(list[num3].Key, item)) { list.RemoveAt(num3); } } } return list; } } public static class HookContract { public const string ImpactfulGuid = "MidnightsFX.ImpactfulSkills"; public const string EpicLootGuid = "randyknapp.mods.epicloot"; public static HarmonyMethod FloorPatch(MethodInfo method) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown HarmonyMethod val = new HarmonyMethod(method); val.priority = 800; val.before = new string[2] { "MidnightsFX.ImpactfulSkills", "randyknapp.mods.epicloot" }; return val; } } [BepInPlugin("vercadi.TamedAnimalDrops", "Tamed Animal Drops", "0.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "vercadi.TamedAnimalDrops"; public const string Version = "0.1.0"; private Harmony harmony; private static ManualLogSource log; private static bool reportedError; private void Awake() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown log = ((BaseUnityPlugin)this).Logger; try { MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(CharacterDrop), "GenerateDropList", Type.EmptyTypes, (Type[])null); FieldInfo fieldInfo = AccessTools.Field(typeof(CharacterDrop), "m_dropsEnabled"); if (methodInfo == null || methodInfo.ReturnType != typeof(List<KeyValuePair<GameObject, int>>) || fieldInfo == null || fieldInfo.FieldType != typeof(bool)) { throw new NotSupportedException("CharacterDrop contract changed; floor was not installed."); } harmony = new Harmony("vercadi.TamedAnimalDrops"); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, HookContract.FloorPatch(AccessTools.DeclaredMethod(typeof(Plugin), "ApplyFloor", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ((BaseUnityPlugin)this).Logger.LogInfo((object)"ACTIVE: adult tame meat/hide minimum 2; normal larger drops retained; applied before ImpactfulSkills."); } catch (Exception ex) { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } ((BaseUnityPlugin)this).Logger.LogError((object)("Tamed animal drop floor inactive: " + ex)); } } public static void ApplyFloor(CharacterDrop __instance, bool ___m_dropsEnabled, ref List<KeyValuePair<GameObject, int>> __result) { try { if (!Object.op_Implicit((Object)(object)__instance) || __result == null) { return; } Character component = ((Component)__instance).GetComponent<Character>(); if (!Object.op_Implicit((Object)(object)component) || !DropFloor.Applies(component.IsTamed(), (Object)(object)((Component)__instance).GetComponent<Growup>() != (Object)null, component is Player, component.IsBoss(), ___m_dropsEnabled)) { return; } List<GameObject> list = new List<GameObject>(); foreach (Drop drop in __instance.m_drops) { if (drop != null && Object.op_Implicit((Object)(object)drop.m_prefab) && DropFloor.IsResource(((Object)drop.m_prefab).name, drop.m_chance, drop.m_amountMax, drop.m_onePerPlayer)) { list.Add(drop.m_prefab); } } if (list.Count > 0) { __result = DropFloor.Apply(list, __result); } } catch (Exception ex) { if (!reportedError) { reportedError = true; ManualLogSource obj = log; if (obj != null) { obj.LogError((object)("Could not apply tamed drop minimum; original drop list retained: " + ex)); } } } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } }