Decompiled source of NoFallDamage v1.1.1

NoFallDamage.dll

Decompiled a month 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 Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyCompany("NoFallDamage")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Your damages don't fall now!")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("NoFallDamage")]
[assembly: AssemblyTitle("NoFallDamage")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace NoFallDamage
{
	[BepInPlugin("com.Zahirgamer444.NoFallDamage", "NoFallDamage", "1.0.0")]
	public class NoFallDamage : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(CharacterMovement), "CheckFallDamage")]
		public class Patch_NoFallDamage
		{
			[HarmonyPrefix]
			public static bool CheckFallDamage(CharacterMovement __instance)
			{
				if (__instance.FallTime() > __instance.fallDamageTime)
				{
					float num = Mathf.Max(__instance.FallFactor(3f, 1.5f), 0.05f);
					float num2 = num;
					num = Mathf.Min(num, __instance.MaxVelDmg());
					float num3 = num / num2;
					if (num >= 0.025f)
					{
						Character componentInParent = ((Component)__instance).GetComponentInParent<Character>();
						if ((Object)(object)componentInParent != (Object)null && componentInParent.IsLocal)
						{
							Character.localCharacter = componentInParent;
							if (PassOutOnFall.Value)
							{
								Debug.Log((object)"[NoFallDamage] Fall damage canceled. Pass out due to falling.");
								componentInParent.PassOutInstantly();
							}
							else
							{
								Debug.Log((object)"[NoFallDamage] Fall damage canceled.");
							}
						}
						return false;
					}
				}
				return false;
			}
		}

		public static ConfigEntry<bool> PassOutOnFall;

		public const string PLUGIN_GUID = "com.Zahirgamer444.NoFallDamage";

		public const string PLUGIN_NAME = "NoFallDamage";

		public const string PLUGIN_VERSION = "1.0.0";

		private void Awake()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.Zahirgamer444.NoFallDamage is loaded! Yay");
			PassOutOnFall = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PassOut", false, "If true, you will pass out for a brief moment when you would've taken fall damage.");
			Harmony val = new Harmony("com.Zahirgamer444.NoFallDamage");
			val.PatchAll(Assembly.GetExecutingAssembly());
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "NoFallDamage";

		public const string PLUGIN_NAME = "NoFallDamage";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}