using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.IL2CPP;
using BepInEx.Logging;
using CellMenu;
using ChainedPuzzles;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Interference.Doors;
using Interference.Utils;
using LevelGeneration;
using Player;
using SNetwork;
using TMPro;
using UnhollowerBaseLib;
using UnhollowerRuntimeLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Interference")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Interference")]
[assembly: AssemblyTitle("Interference")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Interference
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("GTFO.InterferencePlugin", "Plugin for Interference", "1.1.0.0")]
[BepInProcess("GTFO.exe")]
public class EntryPoint : BasePlugin
{
public override void Load()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
Logger._Logger = ((BasePlugin)this).Log;
if (!File.Exists(Path.Combine(MTFOUtil.GameDataPath, "PartialData/rundown-interference.json")))
{
((BasePlugin)this).Log.LogFatal((object)"Interference Rundown File is not exist, Unloading Plugin");
((BasePlugin)this).Unload();
}
else
{
ClassInjector.RegisterTypeInIl2Cpp<InteractGlitchManager>();
new Harmony("Interference.Harmony").PatchAll();
((BasePlugin)this).Log.LogMessage((object)"It's in Interference Rundown! Plugin Enabled!");
}
}
}
public static class Logger
{
public static ManualLogSource _Logger;
}
[HarmonyPatch(typeof(CM_PageRundown_New), "TryPlaceRundown")]
internal static class Inject_RundownLoad
{
[HarmonyWrapSafe]
private static void Postfix()
{
if (GameDataBlockBase<RundownDataBlock>.GetBlock(1u) != null)
{
InteractGlitchManager.Init();
}
}
}
[HarmonyPatch(typeof(CM_ExpeditionIcon_New), "SetStatus")]
internal static class Inject_CM_ExpeditionIcon_New
{
[HarmonyWrapSafe]
private static void Postfix(eExpeditionIconStatus status, CM_ExpeditionIcon_New __instance)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Invalid comparison between Unknown and I4
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if ((int)__instance.Tier == 4 && __instance.ExpIndex == 2)
{
((Component)__instance.m_decryptErrorText).gameObject.SetActive(true);
((TMP_Text)__instance.m_decryptErrorText).text = "://ABANDONED AREA; DO NOT INITIATE CAGE DROP";
__instance.SetBorderColor(Color.red);
}
else if ((int)status == 5)
{
((TMP_Text)__instance.m_decryptErrorText).text = "://err: PROPER EQUIPMENT REQUIRED";
}
}
}
}
namespace Interference.Utils
{
internal static class MTFOUtil
{
public const string MTFOGUID = "com.dak.MTFO";
public static string GameDataPath { get; private set; }
public static string CustomPath { get; private set; }
public static bool HasCustomContent { get; private set; }
public static bool IsLoaded { get; private set; }
static MTFOUtil()
{
GameDataPath = string.Empty;
CustomPath = string.Empty;
HasCustomContent = false;
IsLoaded = false;
if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("com.dak.MTFO", out var info))
{
return;
}
try
{
Type obj = (AppDomain.CurrentDomain.GetAssemblies().First((Assembly a) => !a.IsDynamic && a.Location == info.Location) ?? throw new Exception("Assembly is Missing!")).GetTypes().First((Type t) => t.Name == "ConfigManager") ?? throw new Exception("Unable to Find ConfigManager Class");
FieldInfo field = obj.GetField("GameDataPath", BindingFlags.Static | BindingFlags.Public);
FieldInfo field2 = obj.GetField("CustomPath", BindingFlags.Static | BindingFlags.Public);
FieldInfo? field3 = obj.GetField("HasCustomContent", BindingFlags.Static | BindingFlags.Public);
if ((object)field == null)
{
throw new Exception("Unable to Find Field: GameDataPath");
}
if ((object)field2 == null)
{
throw new Exception("Unable to Find Field: CustomPath");
}
if ((object)field3 == null)
{
throw new Exception("Unable to Find Field: HasCustomContent");
}
GameDataPath = (string)field.GetValue(null);
CustomPath = (string)field2.GetValue(null);
HasCustomContent = (bool)field3.GetValue(null);
IsLoaded = true;
}
catch (Exception arg)
{
Console.WriteLine($"Exception thrown while reading path from Data Dumper (MTFO):\n{arg}");
}
}
}
}
namespace Interference.Scans
{
[HarmonyPatch(typeof(ChainedPuzzleManager), "OnAssetsLoaded")]
internal class Inject_ChainedPuzzleManager
{
private static void Postfix(ChainedPuzzleManager __instance)
{
uint[] array = new uint[5] { 10u, 11u, 12u, 6u, 8u };
foreach (uint num in array)
{
CP_PlayerScanner component = __instance.m_puzzleComponentPrefabs[num].GetComponent<CP_PlayerScanner>();
float num2 = ((Il2CppArrayBase<float>)(object)component.m_scanSpeeds)[3];
((Il2CppArrayBase<float>)(object)component.m_scanSpeeds)[0] = num2;
((Il2CppArrayBase<float>)(object)component.m_scanSpeeds)[1] = num2;
((Il2CppArrayBase<float>)(object)component.m_scanSpeeds)[2] = num2;
((Il2CppArrayBase<float>)(object)component.m_scanSpeeds)[3] = num2;
}
}
}
[HarmonyPatch(typeof(CP_Cluster_Core), "Setup")]
internal class Inject_CP_Cluster
{
private static void Prefix(ref bool revealWithHoloPath, ref bool useRandomPosition, CP_Cluster_Core __instance)
{
if (__instance.m_distanceBetween < 0f)
{
__instance.m_distanceBetween = 0f - __instance.m_distanceBetween;
revealWithHoloPath = true;
useRandomPosition = true;
}
else
{
revealWithHoloPath = true;
useRandomPosition = false;
}
}
}
}
namespace Interference.Objectives
{
[HarmonyPatch(typeof(LG_HSUActivator_Core))]
internal static class Inject_Activator
{
public static LG_HSUActivator_Core CurrentActivator;
[HarmonyPrefix]
[HarmonyPatch("Setup")]
private static void Pre_Setup(LG_HSUActivator_Core __instance)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
CurrentActivator = __instance;
if (((GameDataBlockBase<WardenObjectiveDataBlock>)(object)WardenObjectiveManager.ActiveWardenObjective(__instance.SpawnNode.LayerType)).name.Contains("[Activator_Teleporter]"))
{
__instance.m_publicName = "QTD" + __instance.m_publicName[3..];
__instance.m_showItemComingOut = true;
Transform itemComingOutAlign = __instance.m_itemComingOutAlign;
itemComingOutAlign.localPosition += new Vector3(0f, 5000f, 0f);
}
}
[HarmonyPostfix]
[HarmonyPatch("OnStateChange")]
private static void Post_StatusChanged(pHSUActivatorState newState, LG_HSUActivator_Core __instance)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
if ((int)newState.status == 2 && ((GameDataBlockBase<WardenObjectiveDataBlock>)(object)WardenObjectiveManager.ActiveWardenObjective(__instance.SpawnNode.LayerType)).name.Contains("[Activator_Teleporter]"))
{
__instance.m_linkedItemGoingIn.m_itemCuller.EnableRendering(false);
}
}
}
[HarmonyPatch(typeof(ElevatorCargoCage), "SpawnObjectiveItemsInLandingArea")]
internal class Inject_ElevatorCargo
{
private const int BEACON_COUNT = 1;
private static void Postfix(ElevatorCargoCage __instance)
{
//IL_00a5: 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_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
if (!((GameDataBlockBase<WardenObjectiveDataBlock>)(object)WardenObjectiveManager.ActiveWardenObjective((LG_LayerType)0)).name.Contains("[FogBeacon]"))
{
return;
}
uint persistentID = ((GameDataBlockBase<ItemDataBlock>)(object)GameDataBlockBase<ItemDataBlock>.GetBlock("Carry_FogBeacon[ConstantFog]")).persistentID;
int num = ((Il2CppArrayBase<Transform>)(object)__instance.m_itemsToMoveToCargo)?.Length ?? 0;
int num2 = num + 1;
Transform[] array = (Transform[])(object)new Transform[num2];
if (num2 > 1)
{
((Il2CppArrayBase<Transform>)(object)__instance.m_itemsToMoveToCargo).CopyTo(array, 0);
}
__instance.m_itemsToMoveToCargo = Il2CppReferenceArray<Transform>.op_Implicit(array);
iCarryItemWithGlobalState val4 = default(iCarryItemWithGlobalState);
byte byteId = default(byte);
for (int i = num; i < array.Length; i++)
{
LG_PickupItem val = LG_PickupItem.SpawnGenericPickupItem(ElevatorShaftLanding.CargoAlign);
val.SpawnNode = Builder.GetElevatorArea().m_courseNode;
val.SetupAsBigPickupItem(Random.Range(0, int.MaxValue), persistentID, false);
FogRepeller_Sphere fogRepSmall = new GameObject("FogInstance_Beacon_SmallLayer").AddComponent<FogRepeller_Sphere>();
fogRepSmall.InfiniteDuration = false;
fogRepSmall.LifeDuration = 99999f;
fogRepSmall.GrowDuration = 6f;
fogRepSmall.ShrinkDuration = 19f;
fogRepSmall.Range = 8f;
fogRepSmall.Offset = Vector3.zero;
FogRepeller_Sphere fogRepBig = new GameObject("FogInstance_Beacon_BigLayer").AddComponent<FogRepeller_Sphere>();
fogRepBig.InfiniteDuration = true;
fogRepBig.GrowDuration = 12f;
fogRepBig.ShrinkDuration = 10f;
fogRepBig.Range = 20f;
fogRepBig.Offset = Vector3.zero;
FogRepeller_Sphere val2 = new GameObject("FogInstance_Beacon_Fake").AddComponent<FogRepeller_Sphere>();
val2.InfiniteDuration = false;
val2.LifeDuration = 99999f;
val2.GrowDuration = 99999f;
val2.ShrinkDuration = 99999f;
val2.Range = 1f;
HeavyFogRepellerPickup val3 = ((Il2CppObjectBase)((Component)val.m_root).GetComponentInChildren<CarryItemPickup_Core>()).Cast<HeavyFogRepellerPickup>();
if (CarryItemWithGlobalStateManager.TryCreateItemInstance((eCarryItemWithGlobalStateType)0, val.m_root, ref val4, ref byteId))
{
pItemData_Custom customData = ((ItemInLevel)val3).GetCustomData();
customData.byteId = byteId;
((ItemInLevel)val3).SetCustomData(customData, true);
}
HeavyFogRepellerGlobalState val5 = ((Il2CppObjectBase)val4).Cast<HeavyFogRepellerGlobalState>();
((Component)fogRepSmall).transform.SetParent(((Component)val5).transform, false);
((Component)fogRepBig).transform.SetParent(((Component)val5).transform, false);
val5.m_repellerSphere = val2;
val5.CallbackOnStateChange += Action<pCarryItemWithGlobalState_State, pCarryItemWithGlobalState_State, bool>.op_Implicit((Action<pCarryItemWithGlobalState_State, pCarryItemWithGlobalState_State, bool>)delegate(pCarryItemWithGlobalState_State oldState, pCarryItemWithGlobalState_State newState, bool isRecall)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Invalid comparison between Unknown and I4
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
eHeavyFogRepellerStatus val6 = (eHeavyFogRepellerStatus)newState.status;
if ((int)val6 != 1)
{
if ((int)val6 == 2)
{
FogRepeller_Sphere obj = fogRepSmall;
if (obj != null)
{
obj.StopRepelling();
}
FogRepeller_Sphere obj2 = fogRepBig;
if (obj2 != null)
{
obj2.StartRepelling();
}
}
}
else
{
FogRepeller_Sphere obj3 = fogRepSmall;
if (obj3 != null)
{
obj3.StartRepelling();
}
FogRepeller_Sphere obj4 = fogRepBig;
if (obj4 != null)
{
obj4.StopRepelling();
}
}
if (isRecall)
{
FogRepeller_Sphere obj5 = fogRepSmall;
if (obj5 != null)
{
obj5.KillRepellerInstantly();
}
FogRepeller_Sphere obj6 = fogRepBig;
if (obj6 != null)
{
obj6.KillRepellerInstantly();
}
}
});
((Il2CppArrayBase<Transform>)(object)__instance.m_itemsToMoveToCargo)[i] = ((Component)val).transform;
}
ElevatorRide.Current.m_cargoCageInUse = true;
}
}
[HarmonyPatch(typeof(LG_PowerGeneratorCluster))]
internal class Inject_GenCluster
{
[HarmonyPostfix]
[HarmonyPatch("OnBuildDone")]
private static void Post_Setup(LG_PowerGeneratorCluster __instance)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Invalid comparison between Unknown and I4
WardenObjectiveDataBlock objective = WardenObjectiveManager.ActiveWardenObjective(__instance.SpawnNode.LayerType);
if ((int)objective.Type != 9 || !WardenObjectiveManager.HasValidWaveSettings(objective.WavesOnActivate))
{
return;
}
foreach (LG_PowerGenerator_Core item in (Il2CppArrayBase<LG_PowerGenerator_Core>)(object)__instance.m_generators)
{
item.OnSyncStatusChanged += Action<ePowerGeneratorStatus>.op_Implicit((Action<ePowerGeneratorStatus>)delegate(ePowerGeneratorStatus status)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
if ((int)status == 0 && !((IEnumerable<LG_PowerGenerator_Core>)__instance.m_generators).Any((LG_PowerGenerator_Core x) => !x.ObjectiveItemSolved) && !((Object)__instance).name.Contains("EndSeqTriggered"))
{
if (SNet.IsMaster)
{
WardenObjectiveManager.TriggerEnemyWaves(objective.WavesOnActivate, __instance.SpawnNode, (SurvivalWaveSpawnType)0, 0f);
}
LG_PowerGeneratorCluster obj = __instance;
((Object)obj).name = ((Object)obj).name + "EndSeqTriggered";
}
});
}
__instance.m_chainedPuzzleMidObjective.OnPuzzleSolved += Action.op_Implicit((Action)delegate
{
WardenObjectiveManager.StopAllWardenObjectiveEnemyWaves();
});
}
}
[HarmonyPatch(typeof(EnvironmentStateManager), "OnFactoryBuildDone")]
internal static class Inject_LightJob
{
private static void Postfix()
{
if (((GameDataBlockBase<WardenObjectiveDataBlock>)(object)WardenObjectiveManager.ActiveWardenObjective((LG_LayerType)0)).name.Contains("[NoLightOnStart]") && SNet.IsMaster)
{
EnvironmentStateManager.AttemptSetExpeditionLightMode(false);
}
}
}
[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnStateChange", new Type[]
{
typeof(pReactorState),
typeof(pReactorState),
typeof(bool)
})]
internal static class Inject_Reactor
{
private static void Postfix(pReactorState newState, LG_WardenObjective_Reactor __instance)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if ((int)newState.status == 1 && ((GameDataBlockBase<WardenObjectiveDataBlock>)(object)WardenObjectiveManager.ActiveWardenObjective(__instance.SpawnNode.LayerType)).name.Contains("[LightOffOnFinish]") && SNet.IsMaster)
{
EnvironmentStateManager.AttemptSetExpeditionLightMode(false);
__instance.m_lightCollection.SetMode(false);
}
}
}
[HarmonyPatch(typeof(LG_WardenObjective_Reactor), "OnTerminalStartupSequenceVerify")]
internal static class Inject_Reactor_Fog
{
private static void Prefix(LG_WardenObjective_Reactor __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Invalid comparison between Unknown and I4
WardenObjectiveDataBlock val = WardenObjectiveManager.ActiveWardenObjective(__instance.SpawnNode.LayerType);
if ((int)val.Type != 1)
{
return;
}
List<GeneralFogDataStep> centralPowerGenClustser_FogDataSteps = val.CentralPowerGenClustser_FogDataSteps;
if (centralPowerGenClustser_FogDataSteps != null && centralPowerGenClustser_FogDataSteps.Count > 0)
{
int num = __instance.m_currentWaveCount - 1;
if (num < centralPowerGenClustser_FogDataSteps.Count)
{
EnvironmentStateManager.AttemptStartFogTransition(centralPowerGenClustser_FogDataSteps[num].m_fogDataId, centralPowerGenClustser_FogDataSteps[num].m_transitionToTime);
}
}
}
}
}
namespace Interference.Doors
{
[HarmonyPatch(typeof(Interact_Timed), "OnSelectedChange")]
internal class Inject_Interact_Timed
{
private static void Postfix(Interact_Timed __instance, bool selected)
{
if (selected)
{
if (!((Object)(object)__instance == (Object)null))
{
if (__instance.InteractionMessage.Contains("[SHUFFLE_TYPE1]"))
{
InteractGlitchManager.Current.Enabled = true;
InteractGlitchManager.Current.Mode = GlitchMode.Style1;
GuiManager.InteractionLayer.InteractPromptVisible = false;
}
if (__instance.InteractionMessage.Contains("[SHUFFLE_TYPE2]"))
{
InteractGlitchManager.Current.Enabled = true;
InteractGlitchManager.Current.Mode = GlitchMode.Style2;
GuiManager.InteractionLayer.InteractPromptVisible = false;
}
}
}
else
{
InteractGlitchManager.Current.Enabled = false;
}
}
}
public class InteractGlitchManager : MonoBehaviour
{
private const string HEX_CHARPOOL = "0123456789ABCDEF";
private const string NUMBER_CHARPOOL = "0123456789";
private const string ERR_CHARPOOL = "$#/-01";
public Random Random = new Random();
public GlitchMode Mode;
public bool Enabled;
private float _Timer;
private readonly StringBuilder _StrBuilder = new StringBuilder();
public static InteractGlitchManager Current { get; private set; }
public InteractGlitchManager(IntPtr ptr)
: base(ptr)
{
}
public static void Init()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
if (!((Object)(object)Current != (Object)null))
{
GameObject val = new GameObject("CONST_InteractGlitchManager");
Object.DontDestroyOnLoad((Object)val);
Current = val.AddComponent<InteractGlitchManager>();
}
}
private void Update()
{
if (Enabled && !(_Timer > Clock.Time) && GuiManager.InteractionLayer != null)
{
if (Mode == GlitchMode.Style1)
{
GuiManager.InteractionLayer.SetInteractPrompt(GetFormat1(), "Hold '" + InputMapper.GetBindingName((InputAction)6) + "'", (ePUIMessageStyle)0);
GuiManager.InteractionLayer.InteractPromptVisible = true;
_Timer = Clock.Time + 0.05f;
}
else if (Mode == GlitchMode.Style2)
{
string format = GetFormat2("Start Security Scan Sequence ");
string format2 = GetFormat2("[WARNING: Class ://UNKNOWN! Alarm DETECTED]");
GuiManager.InteractionLayer.SetInteractPrompt(format + "<color=red>" + format2 + "</color>", "Hold '" + InputMapper.GetBindingName((InputAction)6) + "'", (ePUIMessageStyle)0);
GuiManager.InteractionLayer.InteractPromptVisible = true;
_Timer = Clock.Time + 0.075f;
}
}
}
private string GetFormat1()
{
return "<color=red>://Decryption E_RR at: [" + GetRandomHex() + GetRandomHex() + "-" + GetRandomHex() + GetRandomHex() + "-" + GetRandomHex() + GetRandomHex() + "-" + GetRandomHex() + GetRandomHex() + "]</color>";
}
private string GetFormat2(string baseMessage)
{
_StrBuilder.Clear();
foreach (char c in baseMessage)
{
if (Random.NextDouble() > 0.009999999776482582 || c == ':')
{
_StrBuilder.Append(c);
}
else
{
_StrBuilder.Append("$#/-01"[Random.Next(0, "$#/-01".Length)]);
}
}
return _StrBuilder.ToString();
}
private string GetRandomHex()
{
return string.Format("{0}{1}", "0123456789ABCDEF"[Random.Next(0, "0123456789ABCDEF".Length)], "0123456789ABCDEF"[Random.Next(0, "0123456789ABCDEF".Length)]);
}
}
public enum GlitchMode
{
None,
Style1,
Style2
}
}