using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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 = "")]
[assembly: AssemblyCompany("UltrakillLookAtEnemy")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("UltrakillLookAtEnemy")]
[assembly: AssemblyTitle("UltrakillLookAtEnemy")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace UltrakillLookAtEnemy
{
[BepInPlugin("com.fidel.ultrakill.lookat", "LookAtEnemy", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
try
{
new Harmony("com.fidel.ultrakill.lookat").PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"LookAtEnemy: Unified Patch Applied.");
}
catch (Exception arg)
{
((BaseUnityPlugin)this).Logger.LogError((object)$"LookAtEnemy: Harmony patch failed: {arg}");
}
}
}
[HarmonyPatch(typeof(CameraController), "LateUpdate")]
public class LookAtEnemyUnifiedPatch
{
private const float heightOffset = 2f;
private const float scanInterval = 0.1f;
private static bool isEnabled = true;
private static float nextScanTime = 0f;
private static Transform? currentTarget = null;
[HarmonyPostfix]
private static void Postfix(CameraController __instance)
{
//IL_024b: Unknown result type (might be due to invalid IL or missing references)
//IL_0250: 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_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0278: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: 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_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown((KeyCode)287))
{
isEnabled = !isEnabled;
if (!isEnabled)
{
currentTarget = null;
}
}
if (!isEnabled)
{
return;
}
if (Time.time >= nextScanTime)
{
nextScanTime = Time.time + 0.1f;
float num = 150f;
Transform val = null;
EnemyIdentifier[] array = Object.FindObjectsOfType<EnemyIdentifier>();
EnemyIdentifier[] array2 = array;
foreach (EnemyIdentifier val2 in array2)
{
if (!((Object)(object)val2 == (Object)null) && ((Component)val2).gameObject.activeInHierarchy && !((Object)((Component)val2).gameObject).name.ToLower().Contains("idol") && !val2.dead && !(val2.health <= 0f))
{
float num2 = Vector3.Distance(((Component)__instance).transform.position, ((Component)val2).transform.position);
if (num2 < num)
{
num = num2;
val = ((Component)val2).transform;
}
}
}
Coin[] array3 = Object.FindObjectsOfType<Coin>();
Coin[] array4 = array3;
foreach (Coin val3 in array4)
{
if (!((Object)(object)val3 == (Object)null) && ((Component)val3).gameObject.activeInHierarchy)
{
float num3 = Vector3.Distance(((Component)__instance).transform.position, ((Component)val3).transform.position);
if (num3 < num)
{
num = num3;
val = ((Component)val3).transform;
}
}
}
currentTarget = val;
}
if (!((Object)(object)currentTarget != (Object)null) || !((Component)currentTarget).gameObject.activeInHierarchy)
{
return;
}
EnemyIdentifier component = ((Component)currentTarget).GetComponent<EnemyIdentifier>();
if ((Object)(object)component != (Object)null && (component.dead || component.health <= 0f))
{
currentTarget = null;
return;
}
Vector3 val4 = currentTarget.position + Vector3.up * 2f;
Vector3 val5 = val4 - ((Component)__instance).transform.position;
Vector3 normalized = ((Vector3)(ref val5)).normalized;
float num4 = (0f - Mathf.Asin(normalized.y)) * 57.29578f;
float num5 = Mathf.Atan2(normalized.x, normalized.z) * 57.29578f;
__instance.rotationX = num4;
__instance.rotationY = num5;
((Component)__instance).transform.rotation = Quaternion.Euler(num4, num5, 0f);
if ((Object)(object)MonoSingleton<NewMovement>.Instance != (Object)null)
{
((Component)MonoSingleton<NewMovement>.Instance).transform.rotation = Quaternion.Euler(0f, num5, 0f);
}
}
}
}