Decompiled source of SurvivableDismemberment v1.1.0

SurvivableDismemberment.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using HBMF.ModMenu;
using HarmonyLib;
using Il2Cpp;
using MelonLoader;
using MelonLoader.Preferences;
using SurvivableDismemberment;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(Mod), "SurvivableDismemberment", "1.1.0", "korbykob", null)]
[assembly: MelonGame("GexagonVR", "Hard Bullet")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SurvivableDismemberment")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SurvivableDismemberment")]
[assembly: AssemblyTitle("SurvivableDismemberment")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SurvivableDismemberment;

[HarmonyPatch]
public class Mod : MelonMod
{
	private static readonly List<DamageSender> senders = new List<DamageSender>();

	private static MelonPreferences_Entry<bool> enabled;

	public override void OnInitializeMelon()
	{
		enabled = MelonPreferences.CreateCategory("SurvivableDismemberment").CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		Menu.CreateCategory("SURVIVABLE DISMEMBERMENT").CreateBool("ENABLE", enabled.Value, (Action<bool>)delegate(bool value)
		{
			enabled.Value = value;
		});
	}

	[HarmonyPatch(typeof(DetachableLimbSender), "CheckDetachConditions", new Type[] { typeof(SlicingData) })]
	[HarmonyPostfix]
	public static void Check(ref bool __result, DetachableLimbSender __instance)
	{
		if (enabled.Value & __result)
		{
			senders.Add(((Component)__instance).GetComponent<DamageSender>());
		}
	}

	[HarmonyPatch(typeof(DamageSender), "TakeDamage", new Type[] { typeof(Damage) })]
	[HarmonyPrefix]
	public static bool Survive(DamageSender __instance)
	{
		if (senders.Contains(__instance))
		{
			senders.Remove(__instance);
			return false;
		}
		return true;
	}
}