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 Wolfs Eat Bear Meat v1.1.3
plugins/A2.WolfsEatBearMeat.dll
Decompiled a month agousing System; using System.Diagnostics; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using A2.WolfsEatBearMeat.Reflection; using BepInEx; using HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Wolfs Eat Bear Meat")] [assembly: AssemblyDescription("A mod that allows wolves to consume bear meat.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Wolfs Eat Bear Meat")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("907f97dd-ab52-db58-fe97-d73d3d1e1d50")] [assembly: AssemblyFileVersion("1.1.3.0")] [assembly: AssemblyVersion("1.1.3.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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; } } } internal static class PluginInfo { public const string PluginGUID = "A2.WolfsEatBearMeat"; public const string PluginName = "Wolfs Eat Bear Meat"; public const string PluginDescription = "A mod that allows wolves to consume bear meat."; public const string PluginSemanticVersion = "1.1.3"; public const string PluginFullVersion = "1.1.3.0"; } namespace A2.WolfsEatBearMeat { [BepInPlugin("A2.WolfsEatBearMeat", "Wolfs Eat Bear Meat", "1.1.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class Plugin : BaseUnityPlugin { private static readonly Harmony _harmony = new Harmony("A2.WolfsEatBearMeat"); private static bool _isPatched = false; public void Awake() { _isPatched = true; _harmony.PatchAll(); } public void OnDestroy() { if (_isPatched) { _harmony.UnpatchSelf(); } } } } namespace A2.WolfsEatBearMeat.Reflection { internal static class ReflectionCompiler<TInstance> { public static Func<TInstance, TField> CompileFieldGetter<TField>(string fieldName) { if (fieldName == null) { throw new ArgumentNullException("fieldName"); } FieldInfo field = typeof(TInstance).GetField(fieldName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? throw new ArgumentException("Field " + fieldName + " does not exist."); ParameterExpression parameterExpression = Expression.Parameter(typeof(TInstance), string.Empty); MemberExpression memberExpression = Expression.Field(parameterExpression, field); Expression body = memberExpression; if (!typeof(TInstance).IsValueType) { ConstantExpression right = Expression.Constant(null, typeof(TInstance)); BinaryExpression test = Expression.Equal(parameterExpression, right); DefaultExpression ifTrue = Expression.Default(typeof(TField)); body = Expression.Condition(test, ifTrue, memberExpression); } return Expression.Lambda<Func<TInstance, TField>>(body, new ParameterExpression[1] { parameterExpression }).Compile(); } } } namespace A2.WolfsEatBearMeat.Patches { public static class MonsterAIPatch { [HarmonyPatch(typeof(MonsterAI), "CanConsume")] public static class CanConsume { private static readonly Func<MonsterAI, Character> get_MonsterAI_m_character = ReflectionCompiler<MonsterAI>.CompileFieldGetter<Character>("m_character"); private static readonly Func<Character, string> get_Character_m_name = ReflectionCompiler<Character>.CompileFieldGetter<string>("m_name"); private static readonly Func<ItemData, SharedData> get_ItemData_m_shared = ReflectionCompiler<ItemData>.CompileFieldGetter<SharedData>("m_shared"); private static readonly Func<SharedData, string> get_SharedData_m_name = ReflectionCompiler<SharedData>.CompileFieldGetter<string>("m_name"); public static void Postfix(ref bool __result, MonsterAI __instance, ItemData item) { if (!__result && !(get_Character_m_name(get_MonsterAI_m_character(__instance)) != "$enemy_wolf") && !(get_SharedData_m_name(get_ItemData_m_shared(item)) != "$item_bjorn_meat")) { __result = true; } } } } }