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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ForgivingFalls_Revamped")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+04375554df8747ac8ece258273e1574b38d9fae5")]
[assembly: AssemblyProduct("ForgivingFalls Revamped")]
[assembly: AssemblyTitle("ForgivingFalls_Revamped")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 ForgivingFallsRevamped
{
[HarmonyPatch(typeof(CharacterClimbing), "StartClimbRpc")]
public class CharacterClimbing_StartClimbRpc
{
private static readonly FieldRef<CharacterClimbing, Character> CharacterOf = AccessTools.FieldRefAccess<CharacterClimbing, Character>("character");
public static void Postfix(CharacterClimbing __instance)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
Character val = CharacterOf.Invoke(__instance);
if ((Object)(object)val == (Object)null)
{
Plugin.Logger.LogWarning((object)"CharacterClimbing.character was null; leaving the grab alone.");
return;
}
CharacterData data = val.data;
if ((Object)(object)data == (Object)null)
{
Plugin.Logger.LogWarning((object)"Character.data was null; leaving the grab alone.");
return;
}
float num = Mathf.Abs(Plugin.MaxAttachSlide.Value);
Vector2 playerSlide = __instance.playerSlide;
if (playerSlide.y < 0f - num)
{
playerSlide.y = 0f - num;
__instance.playerSlide = playerSlide;
}
float num2 = Mathf.Max(0f, Plugin.MaxOutOfStaminaClimbTime.Value);
if (data.outOfStaminaClimbingFor > num2)
{
data.outOfStaminaClimbingFor = num2;
}
if (Plugin.ResetFallTimerOnAttach.Value)
{
data.sinceGrounded = 0f;
}
}
}
[BepInPlugin("ForgivingFalls_Revamped", "ForgivingFalls Revamped", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
internal static ConfigEntry<float> MaxAttachSlide;
internal static ConfigEntry<float> MaxOutOfStaminaClimbTime;
internal static ConfigEntry<bool> ResetFallTimerOnAttach;
private void Awake()
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
MaxAttachSlide = ((BaseUnityPlugin)this).Config.Bind<float>("Falls", "MaxAttachSlide", 15f, "Largest downward slide the game may hand you for grabbing a wall. PEAK starts dealing fall damage once the slide passes about 17.9, so 15 keeps a grab survivable while leaving the vanilla slide curve untouched below that. Use 5 for the 1.0.x feel, or 0 to remove the slide outright.");
MaxOutOfStaminaClimbTime = ((BaseUnityPlugin)this).Config.Bind<float>("Falls", "MaxOutOfStaminaClimbTime", 0.5f, "Cap in seconds on the out-of-stamina climb timer after a grab. PEAK squares this timer to ramp up the slide that peels you off the wall, so a lower cap buys a longer hang. Raise it past the game's own limit to leave the timer alone.");
ResetFallTimerOnAttach = ((BaseUnityPlugin)this).Config.Bind<bool>("Falls", "ResetFallTimerOnAttach", true, "Count a grab as the end of the fall, so the landing afterwards is not charged for the airtime before it. PEAK already does this on every climbing tick while you still have stamina; this extends it to grabs made on empty.");
new Harmony("ForgivingFalls_Revamped").PatchAll();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "ForgivingFalls_Revamped";
public const string PLUGIN_NAME = "ForgivingFalls Revamped";
public const string PLUGIN_VERSION = "1.1.0";
}
}