Decompiled source of KeepInventory v1.0.0

KeepInventory.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
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: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyVersion("0.0.0.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 KeepInventory
{
	[BepInPlugin("com.lobo1g.keepinventory", "Keep Inventory", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.lobo1g.keepinventory";

		public const string PluginName = "Keep Inventory";

		public const string PluginVersion = "1.0.0";

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> KeepSkills;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Keep your whole inventory (including equipped gear) when you die.");
			KeepSkills = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "KeepSkills", false, "If true, you also lose no skill progress on death.");
			_harmony = new Harmony("com.lobo1g.keepinventory");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Keep Inventory 1.0.0 loaded");
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(Player), "CreateTombStone")]
	internal static class Player_CreateTombStone_Patch
	{
		private static bool Prefix(Player __instance)
		{
			if (!Plugin.Enabled.Value)
			{
				return true;
			}
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Skills), "OnDeath")]
	internal static class Skills_OnDeath_Patch
	{
		private static bool Prefix()
		{
			if (Plugin.Enabled.Value)
			{
				return !Plugin.KeepSkills.Value;
			}
			return true;
		}
	}
}