using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Assets.Scripts.Actors.Enemies;
using Assets.Scripts.Inventory__Items__Pickups.Weapons;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TargetToggleMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TargetToggleMod")]
[assembly: AssemblyTitle("TargetToggleMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 TargetToggleMod
{
internal static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.tuusuario.targettoggle";
public const string PLUGIN_NAME = "TargetToggle";
public const string PLUGIN_VERSION = "1.0.0";
}
[BepInPlugin("com.tuusuario.targettoggle", "TargetToggle", "1.0.0")]
[BepInProcess("Megabonk.exe")]
public class TargetTogglePlugin : BasePlugin
{
[HarmonyPatch(typeof(EnemyTargeting), "GetTargetedEnemy")]
public static class PatchGetTargetedEnemy
{
public static bool Prefix(Il2CppReferenceArray<Collider> colliders, int count, Vector3 pos, bool useVision, GameObject exceptObject, ref Enemy __result)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (IsSmartAim)
{
return true;
}
__result = EnemyTargeting.GetClosestEnemy(colliders, count, pos, useVision, exceptObject);
return false;
}
}
public class TargetToggleHUD : MonoBehaviour
{
private float _notifyAlpha = 0f;
private const float FADE_DURATION = 2.5f;
private GameObject _hudObject;
public TargetToggleHUD(IntPtr ptr)
: base(ptr)
{
}
private void Start()
{
CreateHUD();
}
private void CreateHUD()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: 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_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: 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_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
_hudObject = new GameObject("TargetToggleHUD");
Object.DontDestroyOnLoad((Object)(object)_hudObject);
Canvas val = _hudObject.AddComponent<Canvas>();
val.renderMode = (RenderMode)0;
val.sortingOrder = 100;
_hudObject.AddComponent<CanvasScaler>();
_hudObject.AddComponent<GraphicRaycaster>();
GameObject val2 = new GameObject("Panel");
val2.transform.SetParent(_hudObject.transform, false);
RectTransform val3 = val2.AddComponent<RectTransform>();
val3.anchorMin = new Vector2(1f, 0f);
val3.anchorMax = new Vector2(1f, 0f);
val3.pivot = new Vector2(1f, 0f);
val3.anchoredPosition = new Vector2(-16f, 16f);
val3.sizeDelta = new Vector2(220f, 38f);
Image val4 = val2.AddComponent<Image>();
((Graphic)val4).color = new Color(0f, 0f, 0f, 0.55f);
GameObject val5 = new GameObject("Label");
val5.transform.SetParent(val2.transform, false);
RectTransform val6 = val5.AddComponent<RectTransform>();
val6.anchorMin = Vector2.zero;
val6.anchorMax = Vector2.one;
val6.offsetMin = new Vector2(8f, 0f);
val6.offsetMax = new Vector2(-8f, 0f);
_hudText = val5.AddComponent<Text>();
_hudText.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
_hudText.fontSize = 15;
_hudText.alignment = (TextAnchor)4;
((Graphic)_hudText).color = Color.white;
_hudText.text = "TARGET: " + GetModeName();
}
private void Update()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(Instance.ToggleKey.Value))
{
ToggleMode();
_notifyAlpha = 1f;
}
if (_notifyAlpha > 0f)
{
_notifyAlpha -= Time.deltaTime / 2.5f;
if ((Object)(object)_hudText != (Object)null)
{
((Graphic)_hudText).color = new Color(1f + _notifyAlpha * 0.8f, 1f + _notifyAlpha * 0.8f, 1f, 1f);
}
}
else if ((Object)(object)_hudText != (Object)null)
{
((Graphic)_hudText).color = Color.white;
}
}
}
private Harmony _harmony;
private static Text _hudText;
public static TargetTogglePlugin Instance { get; private set; }
public ConfigEntry<KeyCode> ToggleKey { get; private set; }
public static bool IsSmartAim { get; private set; }
public override void Load()
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
ToggleKey = ((BasePlugin)this).Config.Bind<KeyCode>("Hotkeys", "ToggleTargetingMode", (KeyCode)116, "Tecla para alternar entre Closest Enemy y Smart Aim.");
_harmony = new Harmony("com.tuusuario.targettoggle");
_harmony.PatchAll();
((BasePlugin)this).AddComponent<TargetToggleHUD>();
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(73, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TargetToggleMod] Cargado! Presioná [");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<KeyCode>(ToggleKey.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] para cambiar el modo de targeting.");
}
log.LogInfo(val);
}
public static void ToggleMode()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
IsSmartAim = !IsSmartAim;
UpdateHUD();
ManualLogSource log = ((BasePlugin)Instance).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[TargetToggleMod] Modo cambiado a: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(GetModeName());
}
log.LogInfo(val);
}
public static string GetModeName()
{
return IsSmartAim ? "Smart Aim" : "Closest Enemy";
}
private static void UpdateHUD()
{
if ((Object)(object)_hudText != (Object)null)
{
_hudText.text = "TARGET: " + GetModeName();
}
}
}
}