using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Configgy;
using HarmonyLib;
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.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("QuickHook")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("QuickHook")]
[assembly: AssemblyTitle("QuickHook")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace QuickHook;
[BepInPlugin("QuickHook.adry.ultrakill", "QuickHook", "1.2.0")]
public class QuickHook : BaseUnityPlugin
{
private ConfigBuilder config;
[Configgable("General", "Enable Mod", 0, "Toggle the QuickHook mod on or off.")]
public static ConfigToggle enableMod = new ConfigToggle(true);
[Configgable("General", "Hook Speed", 0, "Set the hook's launch speed multiplier. (1× = normal, 2× = mod default, up to 10×)")]
public static IntegerSlider hookSpeed = new IntegerSlider(2, 1, 10);
[Configgable("General", "Enemy Hook Pull Speed", 0, "Set the enemy pull speed multiplier. (1× = normal, 2× = mod default, up to 10×)")]
public static IntegerSlider enemyHookPullSpeed = new IntegerSlider(2, 1, 10);
[Configgable("General", "Player Hook Pull Speed", 0, "Set the player pull speed multiplier. (1× = normal, 2× = mod default, up to 10×)")]
public static IntegerSlider playerHookPullSpeed = new IntegerSlider(2, 1, 10);
public static float GetHookSpeedMultiplier()
{
return ((ConfigValueElement<bool>)(object)enableMod).Value ? ((float)((ConfigValueElement<int>)(object)hookSpeed).Value) : 1f;
}
public static float GetEnemyPullSpeed()
{
return ((ConfigValueElement<bool>)(object)enableMod).Value ? (60f * (float)((ConfigValueElement<int>)(object)enemyHookPullSpeed).Value) : 60f;
}
public static float GetPlayerPullSpeed()
{
return ((ConfigValueElement<bool>)(object)enableMod).Value ? (60f * (float)((ConfigValueElement<int>)(object)playerHookPullSpeed).Value) : 60f;
}
private void Awake()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
config = new ConfigBuilder("QuickHook.adry.ultrakill", "QuickHook");
config.BuildAll();
Harmony val = new Harmony("QuickHook.adry.ultrakill");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)("QuickHook mod activated. Enable Mod: " + ((ConfigValueElement<bool>)(object)enableMod).Value));
}
}
[HarmonyPatch(typeof(HookArm), "FixedUpdate")]
public static class HookArm_FixedUpdate_Transpiler
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
foreach (CodeInstruction instr in instructions)
{
if (instr.opcode == OpCodes.Ldc_R4 && instr.operand is float f && Mathf.Approximately(f, 250f))
{
yield return instr;
yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(QuickHook), "GetHookSpeedMultiplier", (Type[])null, (Type[])null));
yield return new CodeInstruction(OpCodes.Mul, (object)null);
}
else
{
yield return instr;
}
}
}
}
[HarmonyPatch(typeof(HookArm), "FixedUpdate")]
public static class HookArm_FixedUpdate_Postfix
{
private static readonly FieldInfo lightTargetField = AccessTools.Field(typeof(HookArm), "lightTarget");
private static readonly FieldInfo enemyRbField = AccessTools.Field(typeof(HookArm), "enemyRigidbody");
private static readonly FieldInfo hookPointField = AccessTools.Field(typeof(HookArm), "hookPoint");
private static void Postfix(HookArm __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
if ((int)__instance.state != 3)
{
return;
}
bool flag = (bool)lightTargetField.GetValue(__instance);
Vector3 val = (Vector3)hookPointField.GetValue(__instance);
Vector3 val3;
if (flag)
{
object? value = enemyRbField.GetValue(__instance);
Rigidbody val2 = (Rigidbody)((value is Rigidbody) ? value : null);
if ((Object)(object)val2 != (Object)null)
{
val3 = ((Component)MonoSingleton<CameraController>.Instance).transform.position - val;
val2.velocity = ((Vector3)(ref val3)).normalized * QuickHook.GetEnemyPullSpeed();
}
}
else if ((Object)(object)MonoSingleton<NewMovement>.Instance != (Object)null)
{
Rigidbody rb = MonoSingleton<NewMovement>.Instance.rb;
val3 = val - ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
rb.velocity = ((Vector3)(ref val3)).normalized * QuickHook.GetPlayerPullSpeed();
}
}
}
[HarmonyPatch(typeof(HookArm), "FixedUpdate")]
public static class HookArm_Returning_Postfix
{
private static readonly FieldInfo returningField = AccessTools.Field(typeof(HookArm), "returning");
private static readonly FieldInfo returnDistanceField = AccessTools.Field(typeof(HookArm), "returnDistance");
private static readonly FieldInfo hookPointField = AccessTools.Field(typeof(HookArm), "hookPoint");
private static void Postfix(HookArm __instance)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Invalid comparison between Unknown and I4
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
bool flag = (bool)returningField.GetValue(__instance);
if ((int)__instance.state == 0 && flag)
{
float num = (float)returnDistanceField.GetValue(__instance);
Transform hand = __instance.hand;
float num2 = 100f + num / 2f;
float num3 = num2 * QuickHook.GetHookSpeedMultiplier();
Vector3 val = (Vector3)hookPointField.GetValue(__instance);
Vector3 val2 = Vector3.MoveTowards(val, hand.position, Time.fixedDeltaTime * num3);
hookPointField.SetValue(__instance, val2);
}
}
}