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 BackpackTombstone v1.0.1
Cjayride.BackpackTombstone.dll
Decompiled 8 hours agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyCompany("Cjayride.BackpackTombstone")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("Cjayride.BackpackTombstone")] [assembly: AssemblyTitle("Cjayride.BackpackTombstone")] [assembly: AssemblyVersion("1.0.1.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 Cjayride.BackpackTombstone { [BepInPlugin("cjayride.BackpackTombstone", "Backpack Tombstone", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "cjayride.BackpackTombstone"; public const string PluginName = "Backpack Tombstone"; public const string PluginVersion = "1.0.1"; private void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("cjayride.BackpackTombstone").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Adventure Backpacks will not dump their contents on the ground when you die. The tombstone keeps the backpack."); } } [HarmonyPatch(typeof(Player), "OnDeath")] internal static class DeathScope { internal static int Depth; private static void Prefix(Player __instance) { if ((Object)(object)__instance != (Object)null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer) { Depth++; } } private static void Postfix(Player __instance) { if ((Object)(object)__instance != (Object)null && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && Depth > 0) { Depth--; } } } [HarmonyPatch] internal static class SkipYardSaleOnDeath { private static bool Prepare() { return TargetMethod() != null; } private static MethodBase TargetMethod() { return AccessTools.Method("AdventureBackpacks.Assets.Backpacks:PerformYardSale", (Type[])null, (Type[])null); } private static bool Prefix(ItemData itemData, int numberItems, ref bool __result) { if (numberItems != 0) { return true; } if (DeathScope.Depth <= 0 && !InTombstone(itemData)) { return true; } __result = true; return false; } private static bool InTombstone(ItemData item) { if (item == null) { return false; } Container[] array = Object.FindObjectsByType<Container>((FindObjectsInactive)0, (FindObjectsSortMode)0); foreach (Container val in array) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).GetComponent<TombStone>() == (Object)null)) { Inventory inventory = val.GetInventory(); if (inventory != null && inventory.ContainsItem(item)) { return true; } } } return false; } } }