Decompiled source of WeakPointOverpenetration v1.0.0

WeakPointOverpenetration.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("WeakPointOverpenetration")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WeakPointOverpenetration")]
[assembly: AssemblyTitle("WeakPointOverpenetration")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WeakPointOverpenetration;

[BepInPlugin("WeakPointOverpenetration", "Weak Point Overpenetration", "1.0.0")]
public class Plugin : BasePlugin
{
	public const string GUID = "WeakPointOverpenetration";

	internal static ManualLogSource L;

	public override void Load()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		L = ((BasePlugin)this).Log;
		try
		{
			Harmony val = new Harmony("WeakPointOverpenetration");
			val.PatchAll(typeof(LimbBasePatch));
			val.PatchAll(typeof(LimbCustomPatch));
			L.LogInfo((object)"[WPO] v1.0.0 loaded (no config, always active).");
		}
		catch (Exception ex)
		{
			L.LogError((object)("[WPO] patch failed: " + ex.Message));
		}
	}
}
internal static class OverpenetrationCore
{
	internal static bool Compute(Dam_EnemyDamageLimb limb, ref float result, float dam, float precisionMulti)
	{
		try
		{
			result = dam * Mathf.Max(1f, limb.m_weakspotDamageMulti * precisionMulti) * limb.m_armorDamageMulti;
			return false;
		}
		catch (Exception ex)
		{
			Plugin.L.LogWarning((object)("[WPO] compute failed: " + ex.Message));
			return true;
		}
	}
}
[HarmonyPatch(typeof(Dam_EnemyDamageLimb), "ApplyWeakspotAndArmorModifiers")]
internal static class LimbBasePatch
{
	[HarmonyPrefix]
	private static bool Prefix(Dam_EnemyDamageLimb __instance, ref float __result, float dam, float precisionMulti)
	{
		return OverpenetrationCore.Compute(__instance, ref __result, dam, precisionMulti);
	}
}
[HarmonyPatch(typeof(Dam_EnemyDamageLimb_Custom), "ApplyWeakspotAndArmorModifiers")]
internal static class LimbCustomPatch
{
	[HarmonyPrefix]
	private static bool Prefix(Dam_EnemyDamageLimb_Custom __instance, ref float __result, float dam, float precisionMulti)
	{
		return OverpenetrationCore.Compute((Dam_EnemyDamageLimb)(object)__instance, ref __result, dam, precisionMulti);
	}
}