Decompiled source of GentleDeath v1.0.15

Landoria.GentleDeath.dll

Decompiled 5 days ago
using 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.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Landoria.GentleDeath")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Landoria.GentleDeath")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("CAA46083-A0C5-4FFC-9180-99BE40D8CAA1")]
[assembly: AssemblyFileVersion("1.0.15")]
[assembly: AssemblyInformationalVersion("1.0.15")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.15.31879")]
namespace Landoria.GentleDeath;

internal static class DeathInventory
{
	internal static void CreateTombstone(Player player)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		Inventory inventory = ((Humanoid)player).GetInventory();
		if (inventory.NrOfItems() != 0)
		{
			GameObject obj = Object.Instantiate<GameObject>(player.m_tombstone, ((Character)player).GetCenterPoint(), ((Component)player).transform.rotation);
			Inventory inventory2 = obj.GetComponent<Container>().GetInventory();
			int num = MoveNonEquippableItems(inventory, inventory2);
			SetupTombstone(obj);
			GentleDeathPlugin.Log.LogInfo((object)($"Death inventory split: kept={inventory.NrOfItems()}, " + $"movedToTombstone={num}."));
		}
	}

	private static int MoveNonEquippableItems(Inventory playerInventory, Inventory graveInventory)
	{
		List<ItemData> list = new List<ItemData>(playerInventory.GetAllItems());
		int num = 0;
		foreach (ItemData item in list)
		{
			if (!item.IsEquipable() && MoveItem(playerInventory, graveInventory, item))
			{
				num++;
			}
		}
		return num;
	}

	private static bool MoveItem(Inventory playerInventory, Inventory graveInventory, ItemData item)
	{
		if (!graveInventory.AddItem(item))
		{
			GentleDeathPlugin.Log.LogWarning((object)("The tombstone had no room for " + item.m_shared.m_name + "; the item was kept by the player."));
			return false;
		}
		return playerInventory.RemoveItem(item);
	}

	private static void SetupTombstone(GameObject tombstone)
	{
		PlayerProfile playerProfile = Game.instance.GetPlayerProfile();
		tombstone.GetComponent<TombStone>().Setup(playerProfile.GetName(), playerProfile.GetPlayerID());
	}
}
[BepInPlugin("Landoria.GentleDeath", "Landoria.GentleDeath", "1.0.15")]
public sealed class GentleDeathPlugin : BaseUnityPlugin
{
	private const string PluginGuid = "Landoria.GentleDeath";

	private const string PluginName = "Landoria.GentleDeath";

	private const string PluginVersion = "1.0.15";

	private Harmony _harmony;

	internal static ManualLogSource Log { get; private set; }

	private void Awake()
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"AssemblyVersion: {((object)this).GetType().Assembly.GetName().Version}.");
		_harmony = new Harmony("Landoria.GentleDeath");
		_harmony.PatchAll();
		Log.LogInfo((object)"Landoria.GentleDeath 1.0.15 is loaded.");
	}

	private void OnDestroy()
	{
		ManualLogSource log = Log;
		if (log != null)
		{
			log.LogInfo((object)"Landoria.GentleDeath 1.0.15 is unloaded.");
		}
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		_harmony = null;
		Log = null;
	}
}
[HarmonyPatch(typeof(Player), "CreateTombStone")]
internal static class CreateTombstonePatch
{
	private static bool Prefix(Player __instance)
	{
		DeathInventory.CreateTombstone(__instance);
		return false;
	}
}