Please disclose if your mod was created primarily 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 AutoDeathPinRemove v1.0.0
AutoDeathPinRemove.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Splatform; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("void")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Valheim mod: creates death pin only on tombstone spawn, removes it when owner loots the tombstone.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AutoDeathPinRemove")] [assembly: AssemblyTitle("AutoDeathPinRemove")] [assembly: AssemblyVersion("1.0.0.0")] namespace AutoDeathPinRemove { [BepInPlugin("com.void.autodeathpinremove", "AutoDeathPinRemove", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.void.autodeathpinremove"; public const string PluginName = "AutoDeathPinRemove"; public const string PluginVersion = "1.0.0"; private Harmony _harmony; private void Awake() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown _harmony = new Harmony("com.void.autodeathpinremove"); _harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"AutoDeathPinRemove v1.0.0 loaded"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } } namespace AutoDeathPinRemove.Patches { [HarmonyPatch(typeof(Minimap), "AddPin")] public static class MinimapAddPinPatch { public static bool AllowDeathPin; private static bool Prefix(PinType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 if ((int)type == 4 && !AllowDeathPin) { return false; } return true; } } internal static class TombStoneHelper { private static readonly FieldInfo NviewField = AccessTools.Field(typeof(TombStone), "m_nview"); private static readonly MethodInfo IsOwnerMethod = AccessTools.Method(typeof(TombStone), "IsOwner", (Type[])null, (Type[])null); private static readonly MethodInfo GetOwnerMethod = AccessTools.Method(typeof(TombStone), "GetOwner", (Type[])null, (Type[])null); public static ZNetView GetNview(TombStone tombstone) { object? obj = NviewField?.GetValue(tombstone); return (ZNetView)((obj is ZNetView) ? obj : null); } public static bool IsOwner(TombStone tombstone) { if (IsOwnerMethod == null) { return false; } return (bool)IsOwnerMethod.Invoke(tombstone, null); } public static long GetOwner(TombStone tombstone) { if (GetOwnerMethod == null) { return 0L; } return (long)GetOwnerMethod.Invoke(tombstone, null); } } [HarmonyPatch(typeof(TombStone), "Setup")] public static class TombStoneSetupPatch { public static readonly Dictionary<ZDOID, PinData> TombstonePins = new Dictionary<ZDOID, PinData>(); private static void Postfix(TombStone __instance, long ownerUID) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null) { return; } long playerID = Game.instance.GetPlayerProfile().GetPlayerID(); if (ownerUID != playerID) { return; } ZNetView nview = TombStoneHelper.GetNview(__instance); if (!((Object)(object)nview == (Object)null) && nview.GetZDO() != null) { Vector3 position = ((Component)__instance).transform.position; string text = $"$hud_mapday {EnvMan.instance.GetDay(ZNet.instance.GetTimeSeconds())}"; MinimapAddPinPatch.AllowDeathPin = true; PinData val = Minimap.instance.AddPin(position, (PinType)4, text, true, false, 0L, default(PlatformUserID)); MinimapAddPinPatch.AllowDeathPin = false; if (val != null) { ZDOID uid = nview.GetZDO().m_uid; TombstonePins[uid] = val; } } } } [HarmonyPatch(typeof(TombStone), "OnTakeAllSuccess")] public static class TombStoneOnTakeAllSuccessPatch { private static void Postfix(TombStone __instance) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Minimap.instance == (Object)null || !TombStoneHelper.IsOwner(__instance)) { return; } ZNetView nview = TombStoneHelper.GetNview(__instance); if (!((Object)(object)nview == (Object)null) && nview.GetZDO() != null) { ZDOID uid = nview.GetZDO().m_uid; if (TombStoneSetupPatch.TombstonePins.TryGetValue(uid, out var value)) { Minimap.instance.RemovePin(value); TombStoneSetupPatch.TombstonePins.Remove(uid); } } } } }