using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Sodalite.ModPanel;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("NGA")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Persistent player progression! Raid, stash loot, and deploy with seemless scene/loadout saving.")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("NGA.FallDamage")]
[assembly: AssemblyTitle("BepInEx Plugin Title")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace NGA
{
[BepInPlugin("NGA.FallDamage", "FallDamage", "0.0.1")]
[BepInDependency("nrgill28.Sodalite", "1.4.1")]
[BepInProcess("h3vr.exe")]
public class FallDamage : BaseUnityPlugin
{
[HarmonyPatch(typeof(FVRMovementManager))]
[HarmonyPatch("Update")]
public class FVRMovementManagerFU : MonoBehaviour
{
public static float lastFallSpeed;
public static float minTimestamp;
private static void Prefix(FVRMovementManager __instance)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
if (CheckSkip() || !EnableFallDamage.Value)
{
return;
}
float startingHealth = GM.CurrentPlayerBody.m_startingHealth;
float value = LowFallsSpeed.Value;
float value2 = DeathFallsSpeed.Value;
float y = __instance.GetFilteredVel().y;
float num = Math.Abs(lastFallSpeed);
if (lastFallSpeed < 0f && num > value && Math.Abs(y) < 0.05f)
{
if (num < value2)
{
float value3 = MinFallDamagePerc.Value;
float num2 = (num - value) / Math.Abs(value2 - value);
float num3 = value3 * (1f + num2);
float num4 = startingHealth * num3 / 100f;
if (GM.CurrentPlayerBody.Health - num4 <= 0f)
{
Logger.LogWarning((object)("Took MAX FALL DAMAGE! speed: " + num + " damage: " + num4));
GM.CurrentPlayerBody.Health = 1f;
}
else
{
Logger.LogWarning((object)("Took FALL DAMAGE! speed: " + num + " damage: " + num4));
FVRPlayerBody currentPlayerBody = GM.CurrentPlayerBody;
currentPlayerBody.Health -= num4;
}
}
else
{
Logger.LogWarning((object)("Died to FALL DAMAGE! speed: " + num));
GM.CurrentPlayerBody.Health = 0f;
GM.CurrentPlayerBody.KillPlayer(true);
}
}
float time = Time.time;
if (y < lastFallSpeed || time - minTimestamp > 0.06f)
{
lastFallSpeed = y;
minTimestamp = Time.time;
}
}
}
private static ConfigEntry<bool> GameEnabled;
private static ConfigEntry<bool> EnableFallDamage;
private static ConfigEntry<float> LowFallsSpeed;
private static ConfigEntry<float> DeathFallsSpeed;
private static ConfigEntry<float> MinFallDamagePerc;
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Harmony val = new Harmony("NGA.FallDamage");
Logger.LogMessage((object)"New harmony");
SetUpConfigFields();
Logger.LogMessage((object)"Setted the fields");
val.PatchAll();
Logger.LogMessage((object)"Hello, world! Sent from NGA.FallDamage 0.0.1");
}
private void SetUpConfigFields()
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Expected O, but got Unknown
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Expected O, but got Unknown
GameEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Overall", "ON/OFF", true, "Completely enable/disable mod");
EnableFallDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("Fall Damage", "ON/OFF", true, "Enable armswinger with twinstick");
LowFallsSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Fall Damage", "Minimum Impact Speed Damage.", 8.75f, new ConfigDescription("At what height do you begin taking damage. 8.7m/s is like 4 meters.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0f, 100f, 0.25f), new object[0]));
DeathFallsSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Fall Damage", "Death Impact Speed Threshold.", 17f, new ConfigDescription("17m/s is like 15 meters. Anything below wont kill you, at worst leave you at 1 health", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0f, 100f, 0.25f), new object[0]));
MinFallDamagePerc = ((BaseUnityPlugin)this).Config.Bind<float>("Fall Damage", "Minimum Fall Damage percent", 8.5f, new ConfigDescription("Minimum damage dealt as a percent of max health, you will take on minimum. Scales with height relative to death height.", (AcceptableValueBase)new AcceptableValueFloatRangeStep(0f, 100f, 0.25f), new object[0]));
}
private static bool CheckSkip()
{
return !GameEnabled.Value;
}
}
}