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 BozachokSafeDeath v1.0.2
SafeDeath.dll
Decompiled 2 weeks agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("SafeDeath")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("SafeDeath")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("55a5b305-c345-4d4e-a1bb-39e4643fffef")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")] [assembly: AssemblyVersion("1.0.0.0")] namespace SafeDeath; [BepInProcess("valheim.exe")] [BepInPlugin("juliandeclercq.SafeDeath", "Safe Death", "1.2.1")] public class SafeDeath : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "CreateTombStone")] private static class CreateTombStonePatch { private static bool Prefix(Player __instance, out Inventory __state) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (_itemLoss.Value) { __state = null; return true; } Inventory inventory = ((Humanoid)__instance).GetInventory(); Inventory val = new Inventory("SavedInventory", (Sprite)null, inventory.GetWidth(), inventory.GetHeight()); val.MoveAll(inventory); __state = val; return false; } private static void Postfix(Player __instance, Inventory __state) { if (!_itemLoss.Value) { ((Humanoid)__instance).GetInventory().MoveAll(__state); } } } [HarmonyPatch(typeof(Player), "HardDeath")] private static class HardDeathPatch { private static bool Prefix(ref bool __result) { if (_skillLoss.Value) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(Player), "OnDeath")] private static class OnDeathPatch { private static void Prefix(Player __instance, List<Food> ___m_foods, out List<Food> __state) { __state = new List<Food>(___m_foods); } private static void Postfix(Player __instance, ref List<Food> ___m_foods, List<Food> __state) { if (!_foodLoss.Value) { ___m_foods = __state; } } } private static ConfigEntry<bool> _skillLoss; private static ConfigEntry<bool> _foodLoss; private static ConfigEntry<bool> _itemLoss; private void Awake() { _skillLoss = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Skill loss", false, "Lose skill / skill progression on death"); _foodLoss = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Food loss", false, "Lose food on death"); _itemLoss = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Item loss", false, "Lose items on death"); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } private void Update() { } private static void LogInventory(Inventory inventory, string name) { Debug.Log((object)$"{name} inventory item count: {inventory.GetAllItems().Count}"); foreach (ItemData allItem in inventory.GetAllItems()) { Debug.Log((object)(name + " item: " + allItem.m_shared.m_name)); } } }