Decompiled source of NearTheDeath v2.0.0

NearTheDeath.dll

Decompiled a month ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LethalTesting")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalTesting")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5ef657c5-4648-4348-9c7c-efd93a7928d4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NearTheDeath;

[BepInPlugin("ohsjol.NearTheDeath", "Near The Death", "1.0.1")]
[ContentWarningPlugin("Near The Death", "1.0.1", true)]
public class NearTheDeath : BaseUnityPlugin
{
	private readonly Harmony _harmony = new Harmony("ohsjol.NearTheDeath");

	private void Awake()
	{
		_harmony.PatchAll();
	}
}
[HarmonyPatch(typeof(PlayerController), "Movement")]
public static class PlayerController_Movement_Patch
{
	private static readonly FieldInfo playerDataField = AccessTools.Field(typeof(PlayerController), "player");

	private static readonly FieldInfo standForceField = AccessTools.Field(typeof(PlayerController), "standForce");

	private static void Prefix(PlayerController __instance)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		Player val = (Player)playerDataField.GetValue(__instance);
		PlayerData data = val.data;
		float health = data.health;
		float movementSlowFactor = data.movementSlowFactor;
		float movementSlowFactor2 = CalculateMovementSlowFactor(health, movementSlowFactor);
		float num = CalculateForce(health);
		data.movementSlowFactor = movementSlowFactor2;
		standForceField.SetValue(__instance, num);
	}

	private static float CalculateMovementSlowFactor(float health, float movementSlowFactor)
	{
		if (health >= 80f)
		{
			return 1f;
		}
		if (health >= 60f)
		{
			return 0.9f;
		}
		if (health >= 40f)
		{
			return 0.8f;
		}
		if (health >= 25f)
		{
			return 0.6f;
		}
		return 0.5f;
	}

	private static float CalculateForce(float health)
	{
		if (health >= 80f)
		{
			return 25f;
		}
		if (health >= 60f)
		{
			return 20f;
		}
		if (health >= 40f)
		{
			return 10f;
		}
		if (health >= 25f)
		{
			return 5f;
		}
		return 0.5f;
	}
}