using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Configgy;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Sandbox;
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")]
[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 QuickHook
{
[BepInPlugin("QuickHook.adry.ultrakill", "QuickHook", "1.0.3")]
public class QuickHook : BaseUnityPlugin
{
[HarmonyPatch(typeof(HookArm))]
public class HookArmPatch
{
private static bool isCallingFromPrefix;
[HarmonyPatch("FixedUpdate")]
[HarmonyPrefix]
public static bool FixedUpdatePrefix(HookArm __instance)
{
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Expected O, but got Unknown
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Invalid comparison between Unknown and I4
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_029a: Unknown result type (might be due to invalid IL or missing references)
//IL_029f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
if (!((ConfigValueElement<bool>)(object)modEnabled).GetValue())
{
return true;
}
if (isCallingFromPrefix)
{
isCallingFromPrefix = false;
return true;
}
FieldInfo fieldInfo = AccessTools.Field(typeof(HookArm), "state");
FieldInfo fieldInfo2 = AccessTools.Field(typeof(HookArm), "throwDirection");
FieldInfo fieldInfo3 = AccessTools.Field(typeof(HookArm), "hookPoint");
FieldInfo fieldInfo4 = AccessTools.Field(typeof(HookArm), "enviroMask");
FieldInfo fieldInfo5 = AccessTools.Field(typeof(HookArm), "clinkSparks");
FieldInfo fieldInfo6 = AccessTools.Field(typeof(HookArm), "enemyMask");
HookState val = (HookState)fieldInfo.GetValue(__instance);
Vector3 val2 = (Vector3)fieldInfo2.GetValue(__instance);
Vector3 val3 = (Vector3)fieldInfo3.GetValue(__instance);
LayerMask val4 = (LayerMask)fieldInfo4.GetValue(__instance);
LayerMask val5 = (LayerMask)fieldInfo6.GetValue(__instance);
GameObject val6 = (GameObject)fieldInfo5.GetValue(__instance);
if ((int)val == 1)
{
float num = 250f * Time.fixedDeltaTime * hookThrowSpeedMultiplier;
RaycastHit val7 = default(RaycastHit);
if (Physics.Raycast(val3, val2, ref val7, num, LayerMask.op_Implicit(val4), (QueryTriggerInteraction)1))
{
Breakable component = ((Component)((RaycastHit)(ref val7)).transform).GetComponent<Breakable>();
if ((Object)(object)component != (Object)null && component.weak && !component.precisionOnly)
{
component.Break();
}
SandboxProp component2 = ((Component)((RaycastHit)(ref val7)).transform).gameObject.GetComponent<SandboxProp>();
if ((Object)(object)component2 != (Object)null && Object.op_Implicit((Object)(object)((SandboxSpawnableInstance)component2).rigidbody))
{
((SandboxSpawnableInstance)component2).rigidbody.AddForceAtPosition(((Component)__instance).transform.forward * -100f, ((RaycastHit)(ref val7)).point, (ForceMode)2);
}
else if ((Object)(object)val6 != (Object)null)
{
Object.Instantiate<GameObject>(val6, ((RaycastHit)(ref val7)).point, Quaternion.LookRotation(((RaycastHit)(ref val7)).normal));
}
val3 = ((RaycastHit)(ref val7)).point;
__instance.StopThrow(0f, false);
}
else
{
RaycastHit val8 = default(RaycastHit);
if (Physics.Raycast(val3, val2, ref val8, num, LayerMask.op_Implicit(val5), (QueryTriggerInteraction)2))
{
val3 = ((RaycastHit)(ref val8)).point;
fieldInfo3.SetValue(__instance, ((RaycastHit)(ref val8)).point);
isCallingFromPrefix = true;
typeof(HookArm).GetMethod("FixedUpdate", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, null);
return false;
}
val3 += val2 * num;
}
fieldInfo3.SetValue(__instance, val3);
RaycastHit[] value = (RaycastHit[])(object)new RaycastHit[0];
typeof(HookArm).GetField("tempRaycastHits", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(__instance, value);
}
return true;
}
[HarmonyPatch("FixedUpdate")]
[HarmonyPostfix]
public static void FixedUpdatePostfix(HookArm __instance)
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Expected O, but got Unknown
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Expected O, but got Unknown
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Invalid comparison between Unknown and I4
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
if (!((ConfigValueElement<bool>)(object)modEnabled).GetValue())
{
return;
}
FieldInfo fieldInfo = AccessTools.Field(typeof(HookArm), "state");
FieldInfo fieldInfo2 = AccessTools.Field(typeof(HookArm), "lightTarget");
FieldInfo fieldInfo3 = AccessTools.Field(typeof(HookArm), "enemyRigidbody");
FieldInfo fieldInfo4 = AccessTools.Field(typeof(HookArm), "caughtTransform");
FieldInfo fieldInfo5 = AccessTools.Field(typeof(HookArm), "caughtPoint");
FieldInfo fieldInfo6 = AccessTools.Field(typeof(HookArm), "hookPoint");
HookState val = (HookState)fieldInfo.GetValue(__instance);
bool flag = (bool)fieldInfo2.GetValue(__instance);
Rigidbody val2 = (Rigidbody)fieldInfo3.GetValue(__instance);
Transform val3 = (Transform)fieldInfo4.GetValue(__instance);
Vector3 val4 = (Vector3)fieldInfo5.GetValue(__instance);
Vector3 val5 = (Vector3)fieldInfo6.GetValue(__instance);
if ((int)val != 3)
{
return;
}
Vector3 val6;
if (flag)
{
if (Object.op_Implicit((Object)(object)val2))
{
val6 = ((Component)MonoSingleton<CameraController>.Instance).transform.position - val5;
val2.velocity = ((Vector3)(ref val6)).normalized * 60f * lightEnemyPullSpeedMultiplier;
}
return;
}
val5 = val3.position + val4;
fieldInfo6.SetValue(__instance, val5);
__instance.beingPulled = true;
if (!MonoSingleton<NewMovement>.Instance.boost || MonoSingleton<NewMovement>.Instance.sliding)
{
Rigidbody rb = MonoSingleton<NewMovement>.Instance.rb;
val6 = val5 - ((Component)MonoSingleton<NewMovement>.Instance).transform.position;
rb.velocity = ((Vector3)(ref val6)).normalized * 60f * playerPullSpeedMultiplier;
}
}
}
public static float hookThrowSpeedMultiplier = 2f;
public static float lightEnemyPullSpeedMultiplier = 2f;
public static float playerPullSpeedMultiplier = 2f;
private ConfigBuilder config;
[Configgable("General", "Enable Mod", 0, "Enables or disables the QuickHook mod.")]
private static ConfigToggle modEnabled = new ConfigToggle(true);
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(Assembly.GetExecutingAssembly());
((BaseUnityPlugin)this).Logger.LogInfo((object)"QuickHook mod is loaded!");
}
}
}