using System.Diagnostics;
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;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TripleJump")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TripleJump")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f2d15718-154f-464b-8e71-fae314f107f9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TripleJump;
[BepInPlugin("Digi.TripleJump", "MultiJump", "1.0.0.0")]
public class TripleJumpModBase : BaseUnityPlugin
{
[HarmonyPatch(typeof(PlayerControllerB))]
public static class PlayerControllerBPatch
{
private static int jumpCount;
private const int maxJumps = 3;
[HarmonyPatch("Jump_performed")]
[HarmonyPrefix]
public static bool Jump_performed_Prefix(PlayerControllerB __instance, CallbackContext context)
{
if (__instance.thisController.isGrounded && jumpCount > 0)
{
jumpCount = 0;
}
if (jumpCount < 3)
{
PerformCustomJump(__instance);
jumpCount++;
return false;
}
return true;
}
private static bool CanJump(PlayerControllerB instance)
{
return instance.thisController.isGrounded || jumpCount < 3;
}
private static void PerformCustomJump(PlayerControllerB instance)
{
FieldInfo field = typeof(PlayerControllerB).GetField("playerSlidingTimer", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field2 = typeof(PlayerControllerB).GetField("isJumping", BindingFlags.Instance | BindingFlags.NonPublic);
FieldInfo field3 = typeof(PlayerControllerB).GetField("jumpCoroutine", BindingFlags.Instance | BindingFlags.NonPublic);
if (field != null)
{
field.SetValue(instance, 0f);
}
if (field2 != null)
{
field2.SetValue(instance, true);
}
object? obj = field3?.GetValue(instance);
Coroutine val = (Coroutine)((obj is Coroutine) ? obj : null);
if (val != null)
{
((MonoBehaviour)instance).StopCoroutine(val);
}
Coroutine value = ((MonoBehaviour)instance).StartCoroutine("PlayerJump");
if (field3 != null)
{
field3.SetValue(instance, value);
}
instance.sprintMeter = Mathf.Clamp(instance.sprintMeter - 0.08f, 0f, 1f);
if ((Object)(object)instance.movementAudio != (Object)null && (Object)(object)StartOfRound.Instance?.playerJumpSFX != (Object)null)
{
instance.movementAudio.PlayOneShot(StartOfRound.Instance.playerJumpSFX);
}
}
[HarmonyPatch(typeof(PlayerControllerB), "ResetFallGravity")]
[HarmonyPrefix]
public static void ResetFallGravity_Prefix(PlayerControllerB instance)
{
jumpCount = 0;
}
}
private const string modGUID = "Digi.TripleJump";
private const string modName = "MultiJump";
private const string modVersion = "1.0.0.0";
private readonly Harmony harmony = new Harmony("Digi.TripleJump");
private static TripleJumpModBase Instance;
internal ManualLogSource mls;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Digi.TripleJump");
mls.LogInfo((object)"MultiJump loading...");
harmony.PatchAll(typeof(PlayerControllerBPatch));
mls.LogInfo((object)"MultiJump loaded successfully.");
}
}