Decompiled source of InstaDeath v2.0.0

InstaDeath.dll

Decompiled 5 hours ago
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using PluginConfig.API;
using PluginConfig.API.Fields;
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(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("InstaDeath")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InstaDeath")]
[assembly: AssemblyTitle("InstaDeath")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Instadeath;

[BepInPlugin("com.zord.instadeath", "InstaDeath", "2.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class InstaDeath : BaseUnityPlugin
{
	private enum RESTARTING_TYPE
	{
		Disabled,
		Checkpoint,
		RestartMission
	}

	private static PluginConfigurator config;

	private static EnumField<RESTARTING_TYPE> restartingType;

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("zord.instadeath").PatchAll(typeof(InstaDeath));
		config = PluginConfigurator.Create("InstaDeath", "com.zord.instadeath");
		restartingType = new EnumField<RESTARTING_TYPE>(config.rootPanel, "Restarting Type", "instadeath_restarting_type", RESTARTING_TYPE.Checkpoint);
		restartingType.SetEnumDisplayName(RESTARTING_TYPE.RestartMission, "Restart Mission");
		config.SetIconWithURL("file://" + Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) + "\\icon.png");
	}

	[HarmonyPatch(typeof(NewMovement), "GetHurt")]
	[HarmonyPostfix]
	private static void GetHurtPatch()
	{
		if (!MonoSingleton<NewMovement>.Instance.dead || restartingType.value == RESTARTING_TYPE.Disabled)
		{
			return;
		}
		OptionsMenuToManager val = Object.FindObjectOfType<OptionsMenuToManager>();
		if (!((Object)(object)val == (Object)null))
		{
			switch (restartingType.value)
			{
			case RESTARTING_TYPE.RestartMission:
				val.RestartMissionNoConfirm();
				break;
			case RESTARTING_TYPE.Checkpoint:
				val.RestartCheckpoint();
				break;
			}
		}
	}
}