using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DoubleJump")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DoubleJump")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bda7da75-cb77-4768-a62f-746147108ee0")]
[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 DoubleJump;
[BepInPlugin("com.peak.kr.DoubleJump", "DoubleJump", "1.0.0")]
public class ModBehaviour : BaseUnityPlugin
{
[HarmonyPatch(typeof(CharacterMovement))]
public class CharacterMovement_path
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start_Postfix(CharacterMovement __instance)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
FieldInfo field = typeof(CharacterMovement).GetField("character", BindingFlags.Instance | BindingFlags.NonPublic);
Character val = (Character)field.GetValue(__instance);
if (val.IsLocal)
{
character = val;
}
}
[HarmonyPatch("TryToJump")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> TryToJump_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
List<CodeInstruction> list = instructions.ToList();
int num = -1;
for (int num2 = list.Count - 1; num2 >= 0; num2--)
{
if (list[num2].opcode == OpCodes.Ret)
{
num = num2;
break;
}
}
if (num != -1)
{
list.Insert(num, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ModBehaviour), "reset_jump_time", (Type[])null, (Type[])null)));
}
return list;
}
}
[HarmonyPatch(typeof(CharacterClimbing))]
public class CharacterClimbing_path
{
[HarmonyPatch("TryToStartWallClimb")]
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> TryToStartWallClimb_Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Expected O, but got Unknown
List<CodeInstruction> list = instructions.ToList();
int num = -1;
for (int num2 = list.Count - 1; num2 >= 0; num2--)
{
if (list[num2].opcode == OpCodes.Ret)
{
num = num2;
break;
}
}
if (num != -1)
{
list.Insert(num, new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ModBehaviour), "reset_jump_time", (Type[])null, (Type[])null)));
}
return list;
}
}
private Harmony harmony;
internal static ManualLogSource Log;
private static ConfigEntry<int> JumpTime;
private static ConfigEntry<float> JumpReturn;
private static ConfigEntry<float> FastJumpReturn;
private static int double_jump;
private static Character character;
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
harmony = new Harmony("com.peak.kr.DoubleJump");
harmony.PatchAll();
JumpTime = ((BaseUnityPlugin)this).Config.Bind<int>("PEAK_MultiFun", "JumpTimes", 2, "Maximum number of jumps");
JumpReturn = ((BaseUnityPlugin)this).Config.Bind<float>("PEAK_MultiFun", "JumpReturn", 0.05f, "Jump Stamina Compensation");
FastJumpReturn = ((BaseUnityPlugin)this).Config.Bind<float>("PEAK_MultiFun", "FastJumpReturn", 0.15f, "Accelerated Jump Stamina Compensation");
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"DoubleJump enble");
}
private void OnDestroy()
{
harmony.UnpatchSelf();
}
private void Update()
{
if (double_jump < JumpTime.Value - 1 && (Object)(object)character != (Object)null && Input.GetKeyDown((KeyCode)32))
{
if (Input.GetKey((KeyCode)304))
{
CharacterData data = character.data;
data.currentStamina += FastJumpReturn.Value;
}
else
{
CharacterData data2 = character.data;
data2.currentStamina += JumpReturn.Value;
}
double_jump++;
character.refs.view.RPC("JumpRpc", (RpcTarget)0, new object[1] { false });
}
}
private static void reset_jump_time()
{
double_jump = 0;
}
}