using System; using System.Collections; using System.Collections.Generic; 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 BepInEx.Unity.IL2CPP.Utils.Collections; using GTFO.API; using Gear; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppSystem; using LevelGeneration; using Microsoft.CodeAnalysis; using NoInterruptions.Patches; using Player; using SNetwork; using StateMachines; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("NoInterruptions")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5f457a1c7c54fe13407228a12ee19b1d629d0ae1")] [assembly: AssemblyProduct("NoInterruptions")] [assembly: AssemblyTitle("NoInterruptions")] [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 NoInterruptions { [BepInPlugin("NoInterruptions", "NoInterruptions", "0.1.10")] [BepInDependency(/*Could not decode attribute arguments.*/)] internal sealed class EntryPoint : BasePlugin { public const string MODNAME = "NoInterruptions"; public override void Load() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) LevelAPI.OnLevelCleanup += CommandPatch.OnCleanup; new Harmony("NoInterruptions").PatchAll(); ((BasePlugin)this).Log.LogMessage((object)"Loaded NoInterruptions"); } } internal static class Logger { private static ManualLogSource logger = Logger.CreateLogSource("NoInterruptions"); public static void Log(string format, params object[] args) { Log(string.Format(format, args)); } public static void Log(string str) { if (logger != null) { logger.Log((LogLevel)8, (object)str); } } public static void Warning(string format, params object[] args) { Warning(string.Format(format, args)); } public static void Warning(string str) { if (logger != null) { logger.Log((LogLevel)4, (object)str); } } public static void Error(string format, params object[] args) { Error(string.Format(format, args)); } public static void Error(string str) { if (logger != null) { logger.Log((LogLevel)2, (object)str); } } public static void Debug(string format, params object[] args) { Debug(string.Format(format, args)); } public static void Debug(string str) { if (logger != null) { logger.Log((LogLevel)32, (object)str); } } } } namespace NoInterruptions.Patches { [HarmonyPatch] internal static class CommandPatch { private static readonly Dictionary> _queuedCommands = new Dictionary>(); public static void OnCleanup() { _queuedCommands.Clear(); } [HarmonyPatch(typeof(LG_ComputerTerminalManager), "DoTerminalCommandValidation")] [HarmonyPrefix] private static bool Pre_Validation(LG_ComputerTerminalCommandInterpreter __instance, pTerminalCommand data) { if (!LG_ComputerTerminalManager.Current.m_terminals.ContainsKey(data.ID)) { return false; } uint iD = data.ID; if (!_queuedCommands.TryGetValue(iD, out Queue value)) { _queuedCommands.Add(iD, value = new Queue()); } value.Enqueue(data); return false; } [HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "UpdateTerminalScreen")] [HarmonyPostfix] private static void Post_Update(LG_ComputerTerminalCommandInterpreter __instance) { if (!SNet.IsMaster || __instance.OnEndOfQueue != null) { return; } uint syncID = __instance.m_terminal.SyncID; if (_queuedCommands.TryGetValue(syncID, out Queue value)) { pTerminalCommand val = value.Dequeue(); if (value.Count == 0) { _queuedCommands.Remove(syncID); } LG_ComputerTerminalManager.Current.m_sendTerminalCommand.Do(val); } } [HarmonyPatch(typeof(LG_TERM_Ping), "Ping")] [HarmonyPostfix] private static void Post_Ping(LG_TERM_Ping __instance) { LG_ComputerTerminal terminal = ((LG_TERM_Base)__instance).m_terminal; if ((Object)(object)(terminal.m_localInteractionSource ?? terminal.m_syncedInteractionSource) == (Object)null) { terminal.ChangeState((TERM_State)1); } } } [HarmonyPatch] internal static class InteractionPatch { private static Interact_Timed? _cachedPack; private static (Interact_Timed drop, Interact_Timed insert)? _cachedPickup; private static Interact_Timed? _cachedInteract; private static RaycastHit _rayHitInfo; [HarmonyPatch(typeof(Interact_Timed), "CheckSoundPlayer")] [HarmonyWrapSafe] [HarmonyPrefix] private static bool Post_CheckSoundPlayer(Interact_Timed __instance) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (__instance.m_sound == null && (Object)(object)((Component)__instance).transform == (Object)null) { __instance.m_sound = new CellSoundPlayer(((Component)PlayerManager.GetLocalPlayerAgent()).transform.position); return false; } return true; } [HarmonyPatch(typeof(PlayerInteraction), "FixedUpdate")] [HarmonyPrefix] private static void Pre_FixedUpdate(PlayerInteraction __instance) { PlayerInventoryBase inventory = ((PlayerAgent)__instance.m_owner).Inventory; if (IsPackOverriding(inventory) || IsPickupOverriding(inventory)) { _cachedInteract = null; SetInteractionEnabled(enabled: false); return; } IInteractable bestSelectedInteract = __instance.m_bestSelectedInteract; _cachedInteract = ((bestSelectedInteract != null) ? ((Il2CppObjectBase)bestSelectedInteract).TryCast() : null); if ((Object)(object)_cachedInteract != (Object)null) { ItemEquippable wieldedItem = inventory.WieldedItem; if (wieldedItem != null && wieldedItem.AllowPlayerInteraction && InteractIsActive(__instance)) { SetInteractionEnabled(enabled: false); return; } } _cachedInteract = null; SetInteractionEnabled(enabled: true); } private static bool IsPackOverriding(PlayerInventoryBase inventory) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)inventory.WieldedSlot != 4) { _cachedPack = null; return false; } if ((Object)(object)_cachedPack == (Object)null) { _cachedPack = (Interact_Timed?)(object)((Il2CppObjectBase)inventory.WieldedItem).Cast().m_interactApplyResource; } if ((Object)(object)_cachedPack != (Object)null && _cachedPack.TimerIsActive) { return true; } return false; } private static bool IsPickupOverriding(PlayerInventoryBase inventory) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)inventory.WieldedSlot != 8) { _cachedPickup = null; return false; } if (!_cachedPickup.HasValue) { CarryItemEquippableFirstPerson val = ((Il2CppObjectBase)inventory.WieldedItem).Cast(); _cachedPickup = ((Interact_Timed)(object)val.m_interactDropItem, (Interact_Timed)(object)val.m_interactInsertItem); } if (_cachedPickup.HasValue) { var (val2, val3) = _cachedPickup.Value; if (val2.TimerIsActive || val3.TimerIsActive) { return true; } } return false; } private static void SetInteractionEnabled(bool enabled) { PlayerInteraction.CameraRayInteractionEnabled = enabled; PlayerInteraction.SphereCheckInteractionEnabled = enabled; PlayerInteraction.LadderInteractionEnabled = enabled; } [HarmonyPatch(typeof(PlayerInteraction), "FixedUpdate")] [HarmonyPostfix] private static void Post_FixedUpdate(PlayerInteraction __instance) { __instance.m_bestInteractInCurrentSearch = (Interact_Base)(object)_cachedInteract; } private static bool InteractIsActive(PlayerInteraction __instance) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_cachedInteract == (Object)null || !_cachedInteract.TimerIsActive) { return false; } if (!((Interact_Base)_cachedInteract).IsActive || !((Interact_Base)_cachedInteract).PlayerCanInteract((PlayerAgent)(object)__instance.m_owner)) { return false; } Vector3 camPos = __instance.m_owner.CamPos; float num = __instance.m_searchRadius + Mathf.Min(Mathf.Abs(((Agent)__instance.m_owner).TargetLookDir.y), 0.5f); float num2 = num * num; bool flag = false; foreach (Collider componentsInChild in ((Component)_cachedInteract).gameObject.GetComponentsInChildren()) { if (Vector3.SqrMagnitude(((Component)componentsInChild).transform.position - camPos) <= num2) { flag = true; break; } } Vector3 position = ((Component)_cachedInteract).transform.position; Vector3 val = position - camPos; if (val.y < 2f) { val.y = 0f; } if (((Vector3)(ref val)).sqrMagnitude <= __instance.m_proximityRadius * __instance.m_proximityRadius) { __instance.AddToProximity((Interact_Base)(object)_cachedInteract); } else { __instance.RemoveFromProximity((Interact_Base)(object)_cachedInteract); } if (!flag) { return false; } FPSCamera fPSCamera = ((PlayerAgent)__instance.m_owner).FPSCamera; if ((Object)(object)fPSCamera.CameraRayObject == (Object)(object)((Component)_cachedInteract).gameObject) { return true; } if (Physics.Raycast(fPSCamera.m_camRay, ref _rayHitInfo, num, LayerManager.MASK_PLAYER_INTERACT_SPHERE) && (Object)(object)((Component)((RaycastHit)(ref _rayHitInfo)).collider).gameObject == (Object)(object)((Component)_cachedInteract).gameObject) { return true; } if (((Interact_Base)_cachedInteract).OnlyActiveWhenLookingStraightAt) { return false; } Vector3 val2 = ((CameraController)fPSCamera).m_camera.WorldToScreenPoint(position); if (val2.z <= 0f || !GuiManager.IsOnScreen(val2)) { return false; } if (((Interact_Base)_cachedInteract).RequireCollisionCheck && Physics.Raycast(camPos, ((Vector3)(ref val)).normalized, ref _rayHitInfo, ((Vector3)(ref val)).magnitude, LayerManager.MASK_PLAYER_INTERACT_SPHERE)) { return (Object)(object)((Component)((RaycastHit)(ref _rayHitInfo)).collider).gameObject == (Object)(object)((Component)_cachedInteract).gameObject; } return true; } } [HarmonyPatch(typeof(ResourcePackPickup))] internal static class PickupPatches { [HarmonyPatch("OnSyncStateChange")] [HarmonyWrapSafe] [HarmonyPrefix] private static void FixDroppedPackArea(ResourcePackPickup __instance, ePickupItemStatus status, ref pPickupPlacement placement) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) AIG_CourseNode val = default(AIG_CourseNode); if ((int)status == 0 && ((pCourseNode)(ref placement.node)).TryGet(ref val)) { __instance.m_terminalItem.SpawnNode = val; __instance.m_terminalItem.FloorItemLocation = val.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7); } } } [HarmonyPatch(typeof(LG_ComputerTerminal))] internal static class TerminalPatch { private static float _inputTime; [HarmonyPatch("SyncChangeState")] [HarmonyPostfix] private static void Postfix_EnterInteracting(LG_ComputerTerminal __instance) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)__instance.CurrentStateName == 2) { CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(DelayedFixState(__instance)), (Action)null); } } private static IEnumerator DelayedFixState(LG_ComputerTerminal terminal) { float endTime = Clock.Time + 0.5f; yield return null; while (Clock.Time < endTime) { if ((int)terminal.CurrentStateName != 2) { yield break; } yield return null; } while ((int)terminal.CurrentStateName == 2) { AttemptFixState(terminal); yield return null; } } private static void AttemptFixState(LG_ComputerTerminal terminal) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) PlayerAgent val = terminal.m_localInteractionSource ?? terminal.m_syncedInteractionSource; if ((Object)(object)val == (Object)null) { terminal.ChangeState((TERM_State)1); } else { if ((int)val.Locomotion.m_currentStateEnum == 9) { return; } if (!((Agent)val).IsLocallyOwned) { Vector3 val2 = ((Component)val).transform.position - val.Sync.m_locomotionData.Pos; if (!(((Vector3)(ref val2)).sqrMagnitude > 0.0001f)) { return; } } PlayerAgent localInteractionSource = (terminal.m_syncedInteractionSource = null); terminal.m_localInteractionSource = localInteractionSource; terminal.ChangeState((TERM_State)1); } } [HarmonyPatch("EnterFPSView")] [HarmonyPrefix] private static void Prefix_EnterFPSView(LG_ComputerTerminal __instance) { if ((Object)(object)__instance.m_localInteractionSource != (Object)null) { _inputTime = Clock.Time + 0.5f; } } [HarmonyPatch(typeof(LG_TERM_PlayerInteracting), "Enter")] [HarmonyPostfix] private static void Postfix_EnterPlayerInteracting(LG_TERM_PlayerInteracting __instance) { __instance.m_inputTimer = _inputTime; } [HarmonyPatch("ExitFPSView")] [HarmonyPostfix] private static void Postfix_ExitFPSView(LG_ComputerTerminal __instance) { if ((Object)(object)__instance.m_localInteractionSource != (Object)null) { LG_TERM_PlayerInteracting val = ((Il2CppObjectBase)((StateMachine)(object)__instance).GetState(2)).Cast(); val.m_inputTimer = Clock.Time + 0.5f; if (val.m_lastSyncString != __instance.m_currentLine) { LG_ComputerTerminalManager.WantToSendTerminalString(__instance.SyncID, __instance.m_currentLine); val.m_lastSyncString = __instance.m_currentLine; } } } } }