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 CombatOwner v1.0.0
CombatOwner.dll
Decompiled 2 years agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("CombatOwner")] [assembly: AssemblyDescription("https://valheim.thunderstore.io/package/Smoothbrain/CombatOwner")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CombatOwner")] [assembly: AssemblyCopyright("Copyright © 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("150BFDAF-FF35-4302-B7CC-BEDCE69118D5")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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] [Microsoft.CodeAnalysis.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 CombatOwner { [BepInPlugin("org.bepinex.plugins.combatowner", "Combat Owner", "1.0.0")] [BepInIncompatibility("org.bepinex.plugins.valheim_plus")] public class CombatOwner : BaseUnityPlugin { [HarmonyPatch(typeof(MonsterAI), "SetTarget")] private static class SwitchOwnerToTarget { private static void Postfix(MonsterAI __instance, Character attacker) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((attacker is Player) ? attacker : null); if (val != null && (Object)(object)val != (Object)(object)Player.m_localPlayer) { ZDO zDO = ((BaseAI)__instance).m_nview.GetZDO(); ZDOID zDOID = attacker.GetZDOID(); zDO.SetOwner(((ZDOID)(ref zDOID)).UserID); ((BaseAI)__instance).m_nview.InvokeRPC("CombatOwner Transfer Owner", new object[1] { __instance }); } } } [HarmonyPatch(typeof(MonsterAI), "Awake")] private static class AddRPCs { private static void Postfix(MonsterAI __instance) { MonsterAI __instance2 = __instance; ((BaseAI)__instance2).m_nview.Register("CombatOwner Transfer Owner", (Action<long>)delegate { GetOwnership(__instance2); }); } private static void GetOwnership(MonsterAI creature) { ((BaseAI)creature).m_nview.ClaimOwnership(); creature.SetTarget((Character)(object)Player.m_localPlayer); } } private const string ModName = "Combat Owner"; private const string ModVersion = "1.0.0"; private const string ModGUID = "org.bepinex.plugins.combatowner"; public void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Assembly executingAssembly = Assembly.GetExecutingAssembly(); new Harmony("org.bepinex.plugins.combatowner").PatchAll(executingAssembly); } } }