Decompiled source of FallDamage v1.0.0

FallDamage.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 AGoodNameLib;
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("MyFirstBoplPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MyFirstBoplPlugin")]
[assembly: AssemblyTitle("MyFirstBoplPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 MyFirstBoplPlugin
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "MyFirstBoplPlugin";

		public const string PLUGIN_NAME = "MyFirstBoplPlugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace FallDamage
{
	[BepInPlugin("com.SashaAnt.FallDamage", "FallDamage", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ConfigFile config;

		internal static ConfigEntry<int> FallDamage;

		public PlayerPhysics PlayerVelocity;

		private void Awake()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin FallDamage is loaded!");
			config = ((BaseUnityPlugin)this).Config;
			FallDamage = config.Bind<int>("Settings", "Fall Damage", -30, new ConfigDescription("When the player's y velocity is lower than this number, the player will get damage on impact with an object", (AcceptableValueBase)null, Array.Empty<object>()));
			Harmony val = new Harmony("FallDamage");
			val.PatchAll(typeof(Patches));
		}

		private void Update()
		{
		}
	}
	public class Patches
	{
		private static bool toofast;

		private static bool oldtoofast;

		private static bool groundedfirsttime = true;

		private static int FallDamageConfig = Plugin.FallDamage.Value;

		[HarmonyPatch(typeof(PlayerBody), "UpdateSim")]
		[HarmonyPostfix]
		public static void PlayerBodyUpdateSim(PlayerBody __instance)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (__instance.physics.IsGrounded())
			{
				if (groundedfirsttime)
				{
					groundedfirsttime = false;
				}
				if (toofast && !groundedfirsttime)
				{
					player.do_kill_player(__instance, player.id_from_player_body(__instance), (CauseOfDeath)1);
				}
			}
			if (__instance.Velocity.y < (long)FallDamageConfig)
			{
				toofast = true;
				Debug.Log((object)__instance.Velocity.y);
			}
			else
			{
				toofast = false;
			}
			oldtoofast = toofast;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "FallDamage";

		public const string PLUGIN_NAME = "FallDamage";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}