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 CellMenu;
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;
private static bool intercepting_noises;
[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_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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)
Enumerator<EnemyAgent> enumerator = node.m_enemiesInNode.GetEnumerator();
bool flag = default(bool);
bool flag2 = default(bool);
while (enumerator.MoveNext())
{
EnemyAgent current = enumerator.Current;
if (!current.AI.IsHibernating(ref flag, ref flag2) || flag2)
{
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(Debug), "LogError", new Type[] { typeof(Object) })]
[HarmonyPrefix]
private static void LogError_Prefix(ref bool __runOriginal, ref Object message)
{
if (intercepting_noises && message.ToString() == "ERROR : OnNoiseDetected : IMPLEMENT SUPPORT FOR Investigate")
{
sleeper_nearby = true;
__runOriginal = 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 ManualLogSource logger = Logger.CreateLogSource("AutoHackingMinigame");
public static void LogInfo(string text)
{
logger.LogInfo((object)text);
}
public static void LogInfo(object o)
{
LogInfo(o.ToString() ?? "No string representation for object");
}
public static void LogError(string text)
{
logger.LogError((object)text);
}
public static void LogError(object o)
{
LogError(o.ToString() ?? "No string representation for object");
}
public static void SendChatMessage(string text)
{
LogInfo("SendChatMessage: " + text);
string text2 = "<color=yellow>";
int num = 50 - text2.Length;
while (text.Length > num)
{
PlayerChatManager.WantToSentTextMessage(PlayerManager.GetLocalPlayerAgent(), text2 + text.Substring(0, num).Trim(), (PlayerAgent)null);
text = text.Substring(num).Trim();
}
PlayerChatManager.WantToSentTextMessage(PlayerManager.GetLocalPlayerAgent(), text2 + text, (PlayerAgent)null);
}
public static void SendLocalMessage(string text)
{
LogInfo("SendLocalMessage: " + text);
GuiManager.PlayerLayer.m_gameEventLog.AddLogItem("<color=yellow>" + text, (eGameEventChatLogType)2);
CM_PageLoadout.Current.m_gameEventLog.AddLogItem("<color=yellow>" + text, (eGameEventChatLogType)2);
}
}
[BepInPlugin("AutoHackingMinigame", "AutoHackingMinigame", "0.1.1")]
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("AutoHackingMinigame is loading...");
Harmony val = new Harmony("AutoHackingMinigame");
val.PatchAll(typeof(Core_Patches));
Utils.LogInfo("AutoHackingMinigame is loaded");
}
}
}