Decompiled source of KeepInventory v1.0.0

KeepInventory.dll

Decompiled 11 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("KeepInventory")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Keep Inventory On Death")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("KeepInventory")]
[assembly: AssemblyTitle("KeepInventory")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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("wkRaphael.KeepInventory", "KeepInventory", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch]
		public class KeepInventory
		{
			[HarmonyPatch(typeof(PlayerCharacter), "Die")]
			private static bool Prefix(PlayerCharacter __instance)
			{
				if (!((Component)((Component)__instance).transform).CompareTag("D"))
				{
					__instance.IsDead = true;
					((Component)((Component)__instance).transform).tag = "D";
					PlayerWeapons.code.HolsterCurrentWeapon();
					((Component)__instance.deathEffect).gameObject.SetActive(true);
					__instance.deathEffect.Play("death effect");
					((Collider)FPSRigidBodyWalker.code.characterController).enabled = false;
					Global.code.CloseAllUI(false);
					FPSPlayer.code.Die();
					Global.code.uiDeath.Open();
					if (__instance.DifficultyBalancer > 0)
					{
						__instance.DifficultyBalancer = 0;
					}
					FPSRigidBodyWalker.code.climbing = false;
					__instance.ResetVehicle();
					if (((Component)Global.code.uiInventory).gameObject.activeSelf)
					{
						Global.code.uiInventory.Close(true, true);
					}
					__instance.DifficultyBalancer = Mathf.Clamp(__instance.DifficultyBalancer, 0, 3);
				}
				return false;
			}
		}

		private readonly Harmony harmony = new Harmony("wkRaphael.KeepInventory");

		private void Awake()
		{
			harmony.PatchAll();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "KeepInventory";

		public const string PLUGIN_NAME = "KeepInventory";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}