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 ClaimPickup v1.0.2
Cjayride.ClaimPickup.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; 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: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyCompany("Cjayride.ClaimPickup")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+b2a87d3e7bbd589c5eb8bfc1d5c6b68770f1ca95")] [assembly: AssemblyProduct("Cjayride.ClaimPickup")] [assembly: AssemblyTitle("Cjayride.ClaimPickup")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [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 Cjayride.ClaimPickup { [BepInPlugin("cjayride.ClaimPickup", "Claim Pickup", "1.0.2")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "cjayride.ClaimPickup"; public const string PluginName = "Claim Pickup"; public const string PluginVersion = "1.0.2"; public static ConfigEntry<float> NearbyMeters; private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) NearbyMeters = ((BaseUnityPlugin)this).Config.Bind<float>("General", "NearbyMeters", 5f, new ConfigDescription("Skip the claim when another player is this close, so stacked combat does not duplicate a drop. Solo honey and plants still claim.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 16f), Array.Empty<object>())); new Harmony("cjayride.ClaimPickup").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Ground loot, plants, and beehives claim ownership on your client before pickup, unless another player is already close."); } } internal static class Claim { public static void Take(Component thing, ZNetView view, Humanoid character) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)thing == (Object)null) && !((Object)(object)character == (Object)null) && !((Object)(object)view == (Object)null) && view.IsValid() && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)character != (Object)(object)Player.m_localPlayer) && !view.IsOwner() && !((Object)(object)thing.GetComponentInParent<Ship>() != (Object)null) && !((Object)(object)thing.GetComponentInParent<Vagon>() != (Object)null) && !OtherPlayerNearby(thing.transform.position)) { view.ClaimOwnership(); } } private static bool OtherPlayerNearby(Vector3 pos) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) List<Player> allPlayers = Player.GetAllPlayers(); if (allPlayers == null) { return false; } float num = ((Plugin.NearbyMeters != null) ? Plugin.NearbyMeters.Value : 5f); float num2 = num * num; for (int i = 0; i < allPlayers.Count; i++) { Player val = allPlayers[i]; if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)Player.m_localPlayer)) { Vector3 val2 = ((Component)val).transform.position - pos; if (((Vector3)(ref val2)).sqrMagnitude <= num2) { return true; } } } return false; } } [HarmonyPatch(typeof(ItemDrop), "Pickup")] internal static class ClaimItemDrop { private static void Prefix(ItemDrop __instance, Humanoid character) { if (!((Object)(object)__instance == (Object)null)) { Claim.Take((Component)(object)__instance, __instance.m_nview, character); } } } [HarmonyPatch(typeof(ItemDrop), "CanPickup")] internal static class ClaimBeforeAutoPickup { private static void Prefix(ItemDrop __instance) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null)) { Claim.Take((Component)(object)__instance, __instance.m_nview, (Humanoid)(object)Player.m_localPlayer); } } } [HarmonyPatch(typeof(ItemDrop), "RequestOwn")] internal static class ClaimInsteadOfRequest { private static bool Prefix(ItemDrop __instance) { if ((Object)(object)__instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null) { return true; } if ((Object)(object)__instance.m_nview != (Object)null && __instance.m_nview.IsOwner()) { return true; } Claim.Take((Component)(object)__instance, __instance.m_nview, (Humanoid)(object)Player.m_localPlayer); if (!((Object)(object)__instance.m_nview == (Object)null)) { return !__instance.m_nview.IsOwner(); } return true; } } [HarmonyPatch(typeof(Pickable), "Interact")] internal static class ClaimPickable { private static void Prefix(Pickable __instance, Humanoid character) { if (!((Object)(object)__instance == (Object)null)) { Claim.Take((Component)(object)__instance, __instance.m_nview, character); } } } [HarmonyPatch(typeof(Beehive), "Interact")] internal static class ClaimBeehive { private static void Prefix(Beehive __instance, Humanoid character) { if (!((Object)(object)__instance == (Object)null)) { Claim.Take((Component)(object)__instance, __instance.m_nview, character); } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }