Decompiled source of ArmorTweaks v1.0.0

ArmorTweaks.dll

Decompiled 5 days 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 BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ArmorTweaks")]
[assembly: AssemblyTitle("ArmorTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ArmorTweaks;

[BepInPlugin("blacks7ar.ArmorTweaks", "ArmorTweaks", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[HarmonyPatch]
	private static class Patch
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(DamageTypes), "ApplyArmor", new Type[]
		{
			typeof(float),
			typeof(float)
		})]
		private static bool ApplyArmor_Prefix(ref float __result, float dmg, float ac)
		{
			if (!_enableMod.Value)
			{
				return true;
			}
			__result = 0.5f * Mathf.Pow(dmg, 2f) / (ac + 0.5f * dmg);
			return false;
		}
	}

	private const string modGUID = "blacks7ar.ArmorTweaks";

	public const string modName = "ArmorTweaks";

	public const string modAuthor = "blacks7ar";

	public const string modVersion = "1.0.0";

	private static readonly Harmony _harmony = new Harmony("blacks7ar.ArmorTweaks");

	private static ConfigEntry<bool> _enableMod;

	public void Awake()
	{
		_enableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Mod", true, "If True, enables the mod patches.");
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		_harmony.PatchAll(executingAssembly);
	}
}