Decompiled source of NoFallDamage v1.0.0

NoFallDamage.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NoFallDamage")]
[assembly: AssemblyDescription("A mod to nullify fall damage on lethal company")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Billy.exe")]
[assembly: AssemblyProduct("NoFallDamage")]
[assembly: AssemblyCopyright("Copyright © Billy.exe 2023")]
[assembly: AssemblyTrademark("Billy.exe")]
[assembly: ComVisible(true)]
[assembly: Guid("133dc415-747a-43c0-9686-0ecad40ede78")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NoFallDamage
{
	internal interface IPatchable
	{
	}
	[BepInPlugin("Billy.exe__NoFallDamageMod", "NoFallDamageMod", "1.0.0")]
	public class NoFallDamagePatch : BaseUnityPlugin, IPatchable
	{
		private const string modGUID = "Billy.exe__NoFallDamageMod";

		private const string modName = "NoFallDamageMod";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Billy.exe__NoFallDamageMod");

		private static NoFallDamagePatch Instance;

		public static ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			mls = Logger.CreateLogSource("Billy.exe__NoFallDamageMod");
			Type interfaceType = typeof(IPatchable);
			IEnumerable<Type> enumerable = from p in AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly s) => s.GetTypes())
				where interfaceType.IsAssignableFrom(p) && !p.IsInterface
				select p;
			mls.LogInfo((object)"NoFallDamage loading");
			foreach (Type item in enumerable)
			{
				mls.LogInfo((object)("loading " + item.Name));
				harmony.PatchAll(item);
			}
			mls.LogInfo((object)"NoFallDamage fully loaded");
		}
	}
}
namespace NoFallDamage.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB), "DamagePlayer")]
	internal class PlayerControllerB_DamagePlayer : IPatchable
	{
		[HarmonyPrefix]
		public static void Prefix([HarmonyArgument("damageNumber")] ref int damageNumber, [HarmonyArgument("causeOfDeath")] ref CauseOfDeath causeOfDeath, [HarmonyArgument("fallDamage")] ref bool fallDamage)
		{
			if (((int)causeOfDeath == 2) | fallDamage)
			{
				NoFallDamagePatch.mls.LogMessage((object)"damage nullified");
				damageNumber = 0;
				fallDamage = false;
			}
		}

		[HarmonyPostfix]
		public static void Postix(PlayerControllerB __instance, [HarmonyArgument("damageNumber")] ref int damageNumber, [HarmonyArgument("causeOfDeath")] ref CauseOfDeath causeOfDeath, [HarmonyArgument("fallDamage")] ref bool fallDamage)
		{
			if (((int)causeOfDeath == 2) | fallDamage)
			{
				__instance.PlayQuickSpecialAnimation(0f);
			}
		}
	}
}