using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using AIGraph;
using Agents;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Enemies;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("AutoHackingMinigame")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AutoHackingMinigame")]
[assembly: AssemblyTitle("AutoHackingMinigame")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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 AutoHackingMinigame
{
internal static class Core_Patches
{
private static bool sleeper_nearby;
[HarmonyPatch(typeof(HackingMinigame_TimingGrid), "StartGame")]
[HarmonyPostfix]
private static void StartGame_Postfix(HackingMinigame_TimingGrid __instance)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_004f: 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)
PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
LG_GenericHackable val = new LG_GenericHackable(((Il2CppObjectBase)__instance.m_tool.m_currentHackable).Pointer);
LG_WeakLock val2 = new LG_WeakLock(((Il2CppObjectBase)((Delegate)val.OnHackingMiss).Target).Pointer);
sleeper_nearby = false;
int maxRays = 20;
sleeper_nearby = sleeper_nearby || CheckNodeForNearbySleepers(((Agent)localPlayerAgent).CourseNode, ((Component)val2).transform.position, raycast: false, ref maxRays);
Enumerator<AIG_CoursePortal> enumerator = ((Agent)localPlayerAgent).CourseNode.m_portals.GetEnumerator();
while (enumerator.MoveNext())
{
AIG_CoursePortal current = enumerator.Current;
sleeper_nearby = sleeper_nearby || CheckNodeForNearbySleepers(current.GetOppositeNode(((Agent)localPlayerAgent).CourseNode), ((Component)val2).transform.position, raycast: true, ref maxRays);
}
if (sleeper_nearby)
{
Utils.LogInfo("Auto-hacking disengaged.");
__instance.m_header.SetText("Auto-hacking <color=#C00>disengaged</color>.");
}
else
{
Utils.LogInfo("Auto-hacking engaged.");
__instance.m_header.SetText("Auto-hacking engaged.");
}
}
private static bool CheckNodeForNearbySleepers(AIG_CourseNode node, Vector3 lock_position, bool raycast, ref int maxRays)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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)
Enumerator<EnemyAgent> enumerator = node.m_enemiesInNode.GetEnumerator();
while (enumerator.MoveNext())
{
EnemyAgent current = enumerator.Current;
if ((int)((AgentAI)current.AI).Mode == 1)
{
continue;
}
Vector3 val = current.ListenerPosition - lock_position;
if (((Vector3)(ref val)).magnitude >= 9f)
{
continue;
}
if (raycast)
{
if (maxRays < 1)
{
break;
}
maxRays--;
if (Physics.Linecast(current.ListenerPosition, lock_position, LayerManager.MASK_WORLD))
{
continue;
}
}
return true;
}
return false;
}
[HarmonyPatch(typeof(HackingMinigame_TimingGrid), "UpdateGame")]
[HarmonyPostfix]
private static void UpdateGame_Postfix(HackingMinigame_TimingGrid __instance)
{
if (!sleeper_nearby && __instance.IsInSelectorRadius(__instance.m_movingRow) && !__instance.m_puzzleDone && Clock.Time > __instance.GamePauseTimer)
{
__instance.OnHit();
}
}
}
internal static class Utils
{
private static readonly ManualLogSource logger = Logger.CreateLogSource("Andocas.AutoHackingMinigame");
public static void LogInfo(object o)
{
logger.LogInfo((object)(o.ToString() ?? "No string representation for object"));
}
public static void LogError(object o)
{
logger.LogError((object)(o.ToString() ?? "No string representation for object"));
}
}
internal static class PluginInfo
{
public const string GUID = "Andocas.AutoHackingMinigame";
public const string NAME = "AutoHackingMinigame";
public const string VERSION = "0.1.2";
}
[BepInPlugin("Andocas.AutoHackingMinigame", "AutoHackingMinigame", "0.1.2")]
internal class Plugin : BasePlugin
{
public override void Load()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
Utils.LogInfo("Andocas.AutoHackingMinigame is loading...");
Harmony val = new Harmony("Andocas.AutoHackingMinigame");
val.PatchAll(typeof(Core_Patches));
Utils.LogInfo("Andocas.AutoHackingMinigame is loaded");
}
}
}