using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Agents;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
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")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoInterruptions")]
[assembly: AssemblyTitle("NoInterruptions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 NoInterruptions
{
[HarmonyPatch]
internal static class InteractionPatch
{
private static Interact_Timed? _cachedPack;
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)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Invalid comparison between Unknown and I4
if ((Object)(object)_cachedPack == (Object)null)
{
ItemEquippable wieldedItem = ((PlayerAgent)__instance.m_owner).Inventory.WieldedItem;
if (wieldedItem != null && (int)wieldedItem.AmmoType == 3)
{
_cachedPack = (Interact_Timed?)(object)((Il2CppObjectBase)((PlayerAgent)__instance.m_owner).Inventory.WieldedItem).TryCast<ResourcePackFirstPerson>().m_interactApplyResource;
}
}
if ((Object)(object)_cachedPack != (Object)null && _cachedPack.TimerIsActive)
{
_cachedInteract = null;
PlayerInteraction.CameraRayInteractionEnabled = false;
PlayerInteraction.SphereCheckInteractionEnabled = false;
PlayerInteraction.LadderInteractionEnabled = false;
return;
}
IInteractable bestSelectedInteract = __instance.m_bestSelectedInteract;
_cachedInteract = ((bestSelectedInteract != null) ? ((Il2CppObjectBase)bestSelectedInteract).TryCast<Interact_Timed>() : null);
if ((Object)(object)_cachedInteract != (Object)null)
{
ItemEquippable wieldedItem2 = ((PlayerAgent)__instance.m_owner).Inventory.WieldedItem;
if (wieldedItem2 != null && wieldedItem2.AllowPlayerInteraction && InteractIsActive(__instance))
{
PlayerInteraction.CameraRayInteractionEnabled = false;
PlayerInteraction.SphereCheckInteractionEnabled = false;
PlayerInteraction.LadderInteractionEnabled = false;
return;
}
}
_cachedInteract = null;
PlayerInteraction.CameraRayInteractionEnabled = true;
PlayerInteraction.SphereCheckInteractionEnabled = true;
PlayerInteraction.LadderInteractionEnabled = true;
}
[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<Collider>())
{
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;
}
}
[BepInPlugin("NoInterruptions", "NoInterruptions", "0.1.1")]
public class Plugin : BasePlugin
{
public class NoInterruptions : MonoBehaviour
{
[CompilerGenerated]
private sealed class <TermWatcher>d__9 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
private List<LG_ComputerTerminal>.Enumerator <>7__wrap1;
object? IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object? IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TermWatcher>d__9(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
}
private bool MoveNext()
{
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Expected O, but got Unknown
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Expected O, but got Unknown
//IL_006b: 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)
//IL_007b: Invalid comparison between Unknown and I4
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Invalid comparison between Unknown and I4
//IL_00b9: 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)
try
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_002b;
case 1:
<>1__state = -3;
goto IL_0152;
case 2:
<>1__state = -1;
goto IL_002b;
case 3:
{
<>1__state = -1;
break;
}
IL_002b:
<>7__wrap1 = terminals.GetEnumerator();
<>1__state = -3;
goto IL_0152;
IL_0152:
while (<>7__wrap1.MoveNext())
{
LG_ComputerTerminal current = <>7__wrap1.Current;
if ((Object)(object)current == (Object)null)
{
continue;
}
if (SNet.IsMaster && (int)current.CurrentStateName != 0 && (int)FocusStateManager.CurrentState != 5 && (int)FocusStateManager.CurrentState != 6)
{
bool flag = false;
Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
while (enumerator.MoveNext())
{
PlayerAgent current2 = enumerator.Current;
if (((Agent)current2).Alive && Vector3.Distance(((Component)current2).gameObject.transform.position, ((Component)current).gameObject.transform.position) < 2f)
{
flag = true;
}
}
if (!flag)
{
current.ChangeState((TERM_State)0);
Debug.Log(Object.op_Implicit($"NoInterruptions - terminal {current.SyncID} has been reset to state Sleeping"));
}
}
<>2__current = (object)new WaitForSeconds(0.2f);
<>1__state = 1;
return true;
}
<>m__Finally1();
<>7__wrap1 = default(List<LG_ComputerTerminal>.Enumerator);
<>2__current = (object)new WaitForSeconds(5f);
<>1__state = 2;
return true;
}
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
((IDisposable)this).Dispose();
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
((IDisposable)<>7__wrap1).Dispose();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private float debugtime;
private static PlayerAgent? plr;
private bool initialized;
private Interact_Base? target;
private Interact_Base? oldtarget;
private IInteractable? targetinter;
private IInteractable? oldinter;
private static List<LG_ComputerTerminal> terminals = new List<LG_ComputerTerminal>();
public void Begin()
{
terminals.Clear();
foreach (LG_ComputerTerminal item in Object.FindObjectsOfType<LG_ComputerTerminal>())
{
terminals.Add(item);
}
plr = PlayerManager.GetLocalPlayerAgent();
initialized = true;
CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(TermWatcher()), (Action)null);
}
private static IEnumerator TermWatcher()
{
try
{
int num = default(int);
List<LG_ComputerTerminal>.Enumerator enumerator = default(List<LG_ComputerTerminal>.Enumerator);
switch (num)
{
case 0:
case 2:
enumerator = terminals.GetEnumerator();
break;
case 1:
break;
case 3:
goto end_IL_0000;
default:
yield break;
}
while (enumerator.MoveNext())
{
LG_ComputerTerminal current = enumerator.Current;
if ((Object)(object)current == (Object)null)
{
continue;
}
if (SNet.IsMaster && (int)current.CurrentStateName != 0 && (int)FocusStateManager.CurrentState != 5 && (int)FocusStateManager.CurrentState != 6)
{
bool flag = false;
Enumerator<PlayerAgent> enumerator2 = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
while (enumerator2.MoveNext())
{
PlayerAgent current2 = enumerator2.Current;
if (((Agent)current2).Alive && Vector3.Distance(((Component)current2).gameObject.transform.position, ((Component)current).gameObject.transform.position) < 2f)
{
flag = true;
}
}
if (!flag)
{
current.ChangeState((TERM_State)0);
Debug.Log(Object.op_Implicit($"NoInterruptions - terminal {current.SyncID} has been reset to state Sleeping"));
}
}
new WaitForSeconds(0.2f);
/*Error near IL_01b4: Unexpected return in MoveNext()*/;
}
((<TermWatcher>d__9)/*Error near IL_0162: stateMachine*/).<>m__Finally1();
new WaitForSeconds(5f);
/*Error near IL_01b4: Unexpected return in MoveNext()*/;
end_IL_0000:;
}
catch
{
//try-fault
((IDisposable)/*Error near IL_01a4: stateMachine*/).Dispose();
throw;
}
((IDisposable)/*Error near IL_01ab: stateMachine*/).Dispose();
/*Error near IL_01b4: Unexpected return in MoveNext()*/;
}
}
public override void Load()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("gargle").PatchAll();
ClassInjector.RegisterTypeInIl2Cpp<NoInterruptions>();
Debug.Log(Object.op_Implicit("NoInterruptions - zombie hand sticking out of a dead game's grave"));
LG_Factory.OnFactoryBuildDone += Action.op_Implicit((Action)((BasePlugin)this).AddComponent<NoInterruptions>().Begin);
}
}
[GeneratedCode("VersionInfoGenerator", "2.0.0+git50a4b1a-master")]
[CompilerGenerated]
internal static class VersionInfo
{
public const string RootNamespace = "NoInterruptions";
public const string Version = "1.0.0";
public const string VersionPrerelease = null;
public const string VersionMetadata = null;
public const string SemVer = "1.0.0";
public const string GitRevShort = null;
public const string GitRevLong = null;
public const string GitBranch = null;
public const string GitTag = null;
public const bool GitIsDirty = false;
}
}