Decompiled source of SecDoorTerminalInterface v1.0.7

plugins/SecDoorTerminalInterface.dll

Decompiled 3 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AIGraph;
using Agents;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using ChainedPuzzles;
using GTFO.API;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using SecDoorTerminalInterface.Inject;
using TMPro;
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("SecDoorTerminalInterface")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+git6952937-master")]
[assembly: AssemblyProduct("SecDoorTerminalInterface")]
[assembly: AssemblyTitle("SecDoorTerminalInterface")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SecDoorTerminalInterface
{
	internal static class Assets
	{
		public static GameObject SecDoorTerminalPrefab;

		public static void Init()
		{
			SecDoorTerminalPrefab = AssetAPI.GetLoadedAsset<GameObject>("Assets/Modding/SecDoorTerminal/Terminal_SecDoor.prefab");
		}
	}
	public struct CommandDescriptor
	{
		public TERM_Command Type;

		public string Command;

		public string Description;

		public TERM_CommandRule Rule;
	}
	public enum CPSolvedBehaviour
	{
		OpenDoor,
		AddOpenCommand,
		Nothing
	}
	[BepInPlugin("SecDoorTerminalInterface", "SecDoorTerminalInterface", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class EntryPoint : BasePlugin
	{
		private Harmony _Harmony;

		public override void Load()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			AssetAPI.OnAssetBundlesLoaded += AssetAPI_OnAssetBundlesLoaded;
			_Harmony = new Harmony("SecDoorTerminalInterface.Harmony");
			_Harmony.PatchAll();
		}

		private void AssetAPI_OnAssetBundlesLoaded()
		{
			Assets.Init();
		}
	}
	internal static class Logger
	{
		private static readonly ManualLogSource _Logger;

		static Logger()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			_Logger = new ManualLogSource("SecDoorTerminalInterface");
			Logger.Sources.Add((ILogSource)(object)_Logger);
		}

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
		{
			_Logger.LogInfo(handler);
		}

		public static void Info(string str)
		{
			_Logger.LogMessage((object)str);
		}

		public static void Info(object data)
		{
			_Logger.LogMessage((object)Format(data));
		}

		public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
		{
			_Logger.LogDebug(handler);
		}

		public static void Debug(string str)
		{
			_Logger.LogDebug((object)str);
		}

		public static void Debug(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}

		public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
		{
			_Logger.LogError(handler);
		}

		public static void Error(string str)
		{
			_Logger.LogError((object)str);
		}

		public static void Error(object data)
		{
			_Logger.LogError((object)Format(data));
		}

		public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
		{
			_Logger.LogFatal(handler);
		}

		public static void Fatal(string str)
		{
			_Logger.LogFatal((object)str);
		}

		public static void Fatal(object data)
		{
			_Logger.LogFatal((object)Format(data));
		}

		public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
		{
			_Logger.LogWarning(handler);
		}

		public static void Warn(string str)
		{
			_Logger.LogWarning((object)str);
		}

		public static void Warn(object data)
		{
			_Logger.LogWarning((object)Format(data));
		}

		[Conditional("DEBUG")]
		public static void DebugOnly(object data)
		{
		}
	}
	public sealed class SecDoorTerminal
	{
		public const TERM_Command COMMAND_OPEN = 255;

		public const TERM_Command COMMAND_OVERRIDE = 254;

		private LocalizedText _GCTextHolder;

		private Vector3 _SavedIntOpenDoorPos;

		private Vector3 _SavedIntUseKeyPos;

		private Vector3 _SavedIntCustomMessagePos;

		private Vector3 _SavedIntHackPos;

		private SDT_StateBehaviour _StateBehaviour;

		private static readonly Vector3 BEGONE = Vector3.one * 10000f;

		public string OpenCommandName { get; set; } = "OPEN_LINKED";


		public string OpenCommandDescription { get; set; } = "Open the linked security door";


		public LG_SecurityDoor LinkedDoor { get; private set; }

		public LG_SecurityDoor_Locks LinkedDoorLocks { get; private set; }

		public LG_ComputerTerminal ComputerTerminal { get; private set; }

		public LG_ComputerTerminalCommandInterpreter CmdProcessor { get; private set; }

		public Interact_ComputerTerminal Interaction { get; private set; }

		public TextMeshPro IdleText { get; private set; }

		public SpriteRenderer IdleIcon { get; private set; }

		public AIG_CourseNode SpawnNode => ComputerTerminal.m_terminalItem.SpawnNode;

		public bool IsTerminalActive { get; private set; } = true;


		public CPSolvedBehaviour BioscanScanSolvedBehaviour { get; set; } = CPSolvedBehaviour.AddOpenCommand;


		public SDT_StateBehaviour StateBehaviour
		{
			get
			{
				return _StateBehaviour;
			}
			set
			{
				_StateBehaviour?.SetContext(null);
				_StateBehaviour = value;
				_StateBehaviour?.SetContext(this);
			}
		}

		public event Action<TERM_Command, string, string, string> OnCmdUsed;

		private void Setup_CommandModule()
		{
			Inject_Terminal_ReceiveCmd.OnCmdUsed_LevelInstanced += OnReceiveCommand;
		}

		private void OnReceiveCommand(LG_ComputerTerminalCommandInterpreter interpreter, TERM_Command cmd, string inputLine, string param1, string param2)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (interpreter.m_terminal.m_syncID == ComputerTerminal.m_syncID)
			{
				this.OnCmdUsed?.Invoke(cmd, inputLine, param1, param2);
			}
		}

		public void AddCommand(CommandDescriptor descriptor, Action<LG_ComputerTerminalCommandInterpreter> onCommandUsed = null)
		{
			//IL_0027: 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)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (CmdProcessor.HasRegisteredCommand(descriptor.Type))
			{
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Command Type: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<TERM_Command>(descriptor.Type);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is Already Added!!");
				}
				Logger.Error(val);
				return;
			}
			_GCTextHolder = new LocalizedText
			{
				UntranslatedText = descriptor.Description,
				Id = 0u
			};
			CmdProcessor.AddCommand(descriptor.Type, descriptor.Command, _GCTextHolder, descriptor.Rule);
			OnCmdUsed += delegate(TERM_Command cmdType, string cmdStr, string param1, string param2)
			{
				//IL_0000: 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)
				if (cmdType == descriptor.Type)
				{
					onCommandUsed?.Invoke(CmdProcessor);
				}
			};
		}

		public void AddOverrideCommand(string cmd, string helpText, Action<LG_ComputerTerminalCommandInterpreter> onCommandUsed = null)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			CommandDescriptor commandDescriptor = default(CommandDescriptor);
			commandDescriptor.Type = (TERM_Command)254;
			commandDescriptor.Command = cmd;
			commandDescriptor.Description = helpText;
			commandDescriptor.Rule = (TERM_CommandRule)1;
			CommandDescriptor descriptor = commandDescriptor;
			AddCommand(descriptor, delegate(LG_ComputerTerminalCommandInterpreter interpreter)
			{
				onCommandUsed?.Invoke(CmdProcessor);
				interpreter.AddOutput((TerminalLineType)0, "Desired Action: <color=orange>OVERRIDE</color>", 0.5f, (TerminalSoundType)0, (TerminalSoundType)0);
				interpreter.AddOutput((TerminalLineType)4, "Decrypting Authorize ID..", 0.85f, (TerminalSoundType)0, (TerminalSoundType)0);
				interpreter.AddOutput((TerminalLineType)2, "Sending..", 1.2f, (TerminalSoundType)0, (TerminalSoundType)0);
				interpreter.AddOutput((TerminalLineType)5, "<color=orange>OVERRIDE</color> Action sent!", 0.65f, (TerminalSoundType)0, (TerminalSoundType)0);
				SetEndOfQueue(delegate
				{
					if (SNet.IsMaster)
					{
						LinkedDoorLocks.m_intOpenDoor.OnInteractionTriggered.Invoke(PlayerManager.GetLocalPlayerAgent());
					}
				});
			});
		}

		public void AddOpenCommand(string cmd, string helpText, Action<LG_ComputerTerminalCommandInterpreter> onCommandUsed = null)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			CommandDescriptor commandDescriptor = default(CommandDescriptor);
			commandDescriptor.Type = (TERM_Command)255;
			commandDescriptor.Command = cmd;
			commandDescriptor.Description = helpText;
			commandDescriptor.Rule = (TERM_CommandRule)1;
			CommandDescriptor descriptor = commandDescriptor;
			AddCommand(descriptor, delegate(LG_ComputerTerminalCommandInterpreter interpreter)
			{
				onCommandUsed?.Invoke(interpreter);
				interpreter.AddOutput((TerminalLineType)0, "Desired Action: <color=orange>OPEN</color>", 0.5f, (TerminalSoundType)0, (TerminalSoundType)0);
				interpreter.AddOutput((TerminalLineType)4, "Decrypting Authorize ID..", 0.85f, (TerminalSoundType)0, (TerminalSoundType)0);
				interpreter.AddOutput((TerminalLineType)2, "Sending..", 1.2f, (TerminalSoundType)0, (TerminalSoundType)0);
				interpreter.AddOutput((TerminalLineType)5, "<color=orange>OVERRIDE</color> Action sent!", 0.65f, (TerminalSoundType)0, (TerminalSoundType)0);
				SetEndOfQueue(delegate
				{
					if (SNet.IsMaster)
					{
						LinkedDoorLocks.m_intOpenDoor.OnInteractionTriggered.Invoke(PlayerManager.GetLocalPlayerAgent());
					}
				});
			});
		}

		public void SetEndOfQueue(Action onEndOfQueue)
		{
			CmdProcessor.OnEndOfQueue = Action.op_Implicit(onEndOfQueue);
		}

		private void Setup()
		{
			Setup_GraphicModule();
			Setup_DoorInteractModule();
			Setup_DoorStateModule();
			Setup_CommandModule();
		}

		public void SetTerminalActive(bool active)
		{
			IsTerminalActive = active;
			((Behaviour)ComputerTerminal).enabled = active;
			Interact_ComputerTerminal componentInChildren = ((Component)ComputerTerminal).GetComponentInChildren<Interact_ComputerTerminal>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((Behaviour)componentInChildren).enabled = active;
				((Interact_Base)componentInChildren).SetActive(active);
			}
			if (!active)
			{
				PlayerAgent localInteractionSource = ComputerTerminal.m_localInteractionSource;
				if ((Object)(object)localInteractionSource != (Object)null && localInteractionSource.FPItemHolder.InTerminalTrigger)
				{
					ComputerTerminal.ExitFPSView();
				}
				if (SNet.IsMaster)
				{
					ComputerTerminal.ChangeState((TERM_State)0);
				}
			}
		}

		public void SetSpawnNode(AIG_CourseNode node)
		{
			ComputerTerminal.m_terminalItem.SpawnNode = node;
		}

		public void SetLocationTextToSpawnZone()
		{
			SetLocationText(SpawnNode.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7));
		}

		public void SetLocationText(string text)
		{
			ComputerTerminal.m_terminalItem.FloorItemLocation = text;
		}

		private SecDoorTerminal()
		{
		}

		public void SetOpenInteractActive(bool active)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Interact_Timed intOpenDoor = LinkedDoorLocks.m_intOpenDoor;
			((Component)intOpenDoor).transform.position = (active ? _SavedIntOpenDoorPos : BEGONE);
			((Interact_Base)intOpenDoor).SetActive(active);
		}

		public void SetUseKeyInteractActive(bool active)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Interact_RequireKeyItem intUseKeyItem = LinkedDoorLocks.m_intUseKeyItem;
			((Component)intUseKeyItem).transform.position = (active ? _SavedIntUseKeyPos : BEGONE);
			((Interact_Base)intUseKeyItem).SetActive(active);
		}

		public void SetHackingInteractActive(bool active)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Interact_Hack intHack = LinkedDoorLocks.m_intHack;
			((Component)intHack).transform.position = (active ? _SavedIntHackPos : BEGONE);
			((Interact_Base)intHack).SetActive(active);
		}

		public void SetCustomMessageActive(bool active)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Interact_MessageOnScreen intCustomMessage = LinkedDoorLocks.m_intCustomMessage;
			((Component)intCustomMessage).transform.position = (active ? _SavedIntCustomMessagePos : BEGONE);
			((Interact_Base)intCustomMessage).SetActive(active);
		}

		public void OpenOrStartChainPuzzle()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			ChainedPuzzleInstance chainedPuzzleToSolve = LinkedDoorLocks.ChainedPuzzleToSolve;
			if ((Object)(object)chainedPuzzleToSolve != (Object)null && !chainedPuzzleToSolve.IsSolved)
			{
				LinkedDoor.m_sync.AttemptDoorInteraction((eDoorInteractionType)4, 0f, 0f, default(Vector3), (Agent)null);
			}
			else
			{
				LinkedDoor.m_sync.AttemptDoorInteraction((eDoorInteractionType)0, 0f, 0f, default(Vector3), (Agent)null);
			}
		}

		public void ForceOpenDoor(float delay)
		{
			if (delay > 0f)
			{
				CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(OpenDoorWithDelay(delay)), (Action)null);
			}
			else
			{
				ForceOpenDoor();
			}
		}

		private IEnumerator OpenDoorWithDelay(float delay)
		{
			yield return (object)new WaitForSeconds(delay);
			LinkedDoor.m_sync.AttemptDoorInteraction((eDoorInteractionType)0, 0f, 0f, default(Vector3), (Agent)null);
		}

		public void ForceOpenDoor()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			LinkedDoor.m_sync.AttemptDoorInteraction((eDoorInteractionType)0, 0f, 0f, default(Vector3), (Agent)null);
		}

		private void Setup_DoorInteractModule()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			_SavedIntOpenDoorPos = ((Component)LinkedDoorLocks.m_intOpenDoor).transform.position;
			_SavedIntUseKeyPos = ((Component)LinkedDoorLocks.m_intUseKeyItem).transform.position;
			_SavedIntCustomMessagePos = ((Component)LinkedDoorLocks.m_intCustomMessage).transform.position;
			_SavedIntHackPos = ((Component)LinkedDoorLocks.m_intHack).transform.position;
		}

		private void Setup_DoorStateModule()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			StateBehaviour = new SDT_StateBehaviour();
			LinkedDoor.m_sync.OnDoorStateChange += Action<pDoorState, bool>.op_Implicit((Action<pDoorState, bool>)OnStateChange);
			LinkedDoorLocks.OnChainedPuzzleSolved += Action.op_Implicit((Action)OnChainedPuzzleSolved);
			OnStateChange(LinkedDoor.m_sync.GetCurrentSyncState(), isRecall: false);
		}

		private void OnChainedPuzzleSolved()
		{
			switch (BioscanScanSolvedBehaviour)
			{
			case CPSolvedBehaviour.OpenDoor:
				if (SNet.IsMaster)
				{
					ForceOpenDoor(0.25f);
				}
				break;
			case CPSolvedBehaviour.AddOpenCommand:
				CmdProcessor.AddOutput((TerminalLineType)5, "Bioscan Sequence Completed - <color=orange>" + OpenCommandName + "</color> Command is now accessible!", 0f, (TerminalSoundType)0, (TerminalSoundType)0);
				AddOpenCommand(OpenCommandName, OpenCommandDescription);
				break;
			}
		}

		private void OnStateChange(pDoorState state, bool isRecall)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			if (StateBehaviour != null)
			{
				ActiveEnemyWaveData activeEnemyWaveData = LinkedDoor.ActiveEnemyWaveData;
				bool isBloodyDoor = activeEnemyWaveData != null && activeEnemyWaveData.HasActiveEnemyWave;
				SecDoorState secDoorState = default(SecDoorState);
				secDoorState.Status = state.status;
				secDoorState.State = state;
				secDoorState.IsBloodyDoor = isBloodyDoor;
				SecDoorState state2 = secDoorState;
				StateBehaviour.UpdateInteractionState(state2, isRecall);
				StateBehaviour.UpdateGraphicState(state2, isRecall);
			}
		}

		private void Setup_GraphicModule()
		{
			CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(ForceScreenOffOnDeactive()), (Action)null);
		}

		private IEnumerator ForceScreenOffOnDeactive()
		{
			while (true)
			{
				if (IsTerminalActive)
				{
					((Behaviour)ComputerTerminal.m_text).enabled = true;
				}
				else
				{
					((Behaviour)ComputerTerminal.m_text).enabled = false;
					ComputerTerminal.m_loginScreen.SetActive(true);
					ComputerTerminal.m_interfaceScreen.SetActive(true);
				}
				yield return null;
			}
		}

		public void SetIdleIconColor(Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			IdleIcon.color = color;
		}

		public void SetIdleText(string text)
		{
			((TMP_Text)IdleText).text = text;
		}

		public void SetIdleTextFontSize(float size)
		{
			((TMP_Text)IdleText).fontSize = size;
		}

		public static SecDoorTerminal Place(LG_SecurityDoor secDoor, TerminalStartStateData startData = null, TerminalPlacementData placementData = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			if ((int)secDoor.m_securityDoorType != 0)
			{
				return null;
			}
			Transform val = CustomExtensions.FindChildRecursive(((Component)secDoor).transform, "InteractionInterface", true);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			((Component)val).gameObject.SetActiveRecursively(false);
			((Component)val).gameObject.SetActive(true);
			GameObject obj = Object.Instantiate<GameObject>(Assets.SecDoorTerminalPrefab, val);
			obj.transform.localPosition = (((int)secDoor.Gate.Type == 0) ? new Vector3(0f, -0.006f, 0f) : new Vector3(0f, -0.026f, 0f));
			obj.transform.localRotation = Quaternion.identity;
			obj.transform.localScale = Vector3.one;
			iTerminalItem componentInChildren = obj.GetComponentInChildren<iTerminalItem>();
			if (componentInChildren != null && TryGetSecDoorSpawnedNode(secDoor, out var spawnedNode))
			{
				componentInChildren.SpawnNode = spawnedNode;
			}
			LG_ComputerTerminal component = obj.GetComponent<LG_ComputerTerminal>();
			component.Setup(startData, placementData);
			MeshFilter[] array = Il2CppArrayBase<MeshFilter>.op_Implicit(((Component)secDoor).GetComponentsInChildren<MeshFilter>(true));
			foreach (MeshFilter val2 in array)
			{
				if (!((Object)(object)val2.sharedMesh == (Object)null))
				{
					string name = ((Object)val2.sharedMesh).name;
					if (!string.IsNullOrEmpty(name) && name.Equals("g_security_door_display"))
					{
						Transform transform = ((Component)val2).gameObject.transform;
						transform.localPosition += BEGONE;
					}
				}
			}
			SecDoorTerminal secDoorTerminal = new SecDoorTerminal();
			secDoorTerminal.LinkedDoor = secDoor;
			secDoorTerminal.LinkedDoorLocks = ((Il2CppObjectBase)secDoor.m_locks).Cast<LG_SecurityDoor_Locks>();
			secDoorTerminal.ComputerTerminal = component;
			secDoorTerminal.CmdProcessor = component.m_command;
			secDoorTerminal.Interaction = ((Component)component).GetComponentInChildren<Interact_ComputerTerminal>(true);
			secDoorTerminal.IdleIcon = component.m_loginScreen.GetComponent<SpriteRenderer>();
			secDoorTerminal.IdleText = component.m_loginScreen.GetComponentInChildren<TextMeshPro>();
			secDoorTerminal.Setup();
			return secDoorTerminal;
		}

		private static bool TryGetSecDoorSpawnedNode(LG_SecurityDoor secDoor, out AIG_CourseNode spawnedNode)
		{
			if ((Object)(object)secDoor == (Object)null)
			{
				spawnedNode = null;
				return false;
			}
			if ((Object)(object)secDoor.Gate == (Object)null)
			{
				spawnedNode = null;
				return false;
			}
			if ((Object)(object)((LG_ZoneExpander)secDoor.Gate).m_linksFrom == (Object)null)
			{
				spawnedNode = null;
				return false;
			}
			spawnedNode = ((LG_ZoneExpander)secDoor.Gate).m_linksFrom.m_courseNode;
			return spawnedNode != null;
		}
	}
	public class SDT_StateBehaviour
	{
		public SecDoorTerminal Context { get; private set; }

		internal void SetContext(SecDoorTerminal secDoorTerminal)
		{
			Context = secDoorTerminal;
		}

		public virtual void UpdateInteractionState(SecDoorState state, bool isRecall)
		{
			//IL_0001: 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_0051: Expected I4, but got Unknown
			eDoorStatus status = state.Status;
			switch ((int)status)
			{
			case 0:
			case 1:
			case 2:
			case 4:
			case 5:
			case 7:
			case 9:
			case 12:
			case 13:
			case 14:
				Context.SetTerminalActive(active: true);
				Context.SetOpenInteractActive(active: false);
				Context.SetHackingInteractActive(active: false);
				Context.SetUseKeyInteractActive(active: false);
				Context.SetCustomMessageActive(active: false);
				break;
			case 3:
				Context.SetTerminalActive(active: false);
				Context.SetOpenInteractActive(active: false);
				Context.SetHackingInteractActive(active: false);
				Context.SetUseKeyInteractActive(active: true);
				Context.SetCustomMessageActive(active: false);
				break;
			case 6:
			case 15:
				Context.SetTerminalActive(active: false);
				Context.SetOpenInteractActive(active: false);
				Context.SetHackingInteractActive(active: false);
				Context.SetUseKeyInteractActive(active: false);
				Context.SetCustomMessageActive(active: true);
				break;
			case 8:
			case 10:
			case 11:
			case 16:
				Context.SetTerminalActive(active: false);
				Context.SetOpenInteractActive(active: false);
				Context.SetHackingInteractActive(active: false);
				Context.SetUseKeyInteractActive(active: false);
				Context.SetCustomMessageActive(active: false);
				break;
			}
		}

		public virtual void UpdateGraphicState(SecDoorState state, bool isRecall)
		{
			//IL_0001: 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: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected I4, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			eDoorStatus status = state.Status;
			string text;
			Color? val;
			switch (status - 1)
			{
			case 14:
				text = "::<color=orange>Bulkhead Override</color> Required::";
				val = Color.yellow;
				break;
			case 2:
				text = "::<color=orange>Keycard</color> Required::";
				val = Color.red;
				break;
			case 4:
				text = "<color=orange>BIOSCAN Protocol</color> pending...";
				val = Color.cyan;
				break;
			case 3:
				text = "<color=orange>BIOSCAN Protocol</color> pending...";
				val = Color.red;
				break;
			case 5:
				text = "BOOT ERR://Power Level - <color=red>LOW</color>";
				val = ColorExt.Hex("#FFA500");
				break;
			case 6:
				text = "<color=orange>LOCKDOWN Protocol</color> engaged!";
				val = Color.red;
				break;
			case 7:
				if (Context.LinkedDoorLocks.ChainedPuzzleToSolve.Data.TriggerAlarmOnActivate)
				{
					text = "<color=red>BIOSCAN Protocol</color> processing!";
					val = Color.red;
				}
				else
				{
					text = "<color=blue>BIOSCAN Protocol</color> processing!";
					val = Color.cyan;
				}
				break;
			case 9:
			case 15:
				text = "::DOOR OVERRIDING::";
				val = Color.cyan;
				break;
			case 0:
				text = "::DOOR LOCKING::";
				val = Color.cyan;
				break;
			default:
				text = "Waiting...";
				val = Color.green;
				break;
			}
			if (val.HasValue)
			{
				Context.SetIdleIconColor(val.Value);
			}
			if (text != null)
			{
				Context.SetIdleText(text);
			}
		}
	}
	public struct SecDoorState
	{
		public eDoorStatus Status;

		public pDoorState State;

		public bool IsBloodyDoor;
	}
	[GeneratedCode("VersionInfoGenerator", "2.1.3+git35c0c2a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "SecDoorTerminalInterface";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = "git6952937-master";

		public const string SemVer = "1.0.0+git6952937-master";

		public const string GitRevShort = "6952937";

		public const string GitRevLong = "69529374dcbe6b589a13bfc0c363675c5cd3e803";

		public const string GitBranch = "master";

		public const string GitTag = null;

		public const int GitCommitsSinceTag = 0;

		public const bool GitIsDirty = false;
	}
}
namespace SecDoorTerminalInterface.Inject
{
	[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "ReceiveCommand")]
	internal class Inject_Terminal_ReceiveCmd
	{
		public static event Action<LG_ComputerTerminalCommandInterpreter, TERM_Command, string, string, string> OnCmdUsed_LevelInstanced;

		static Inject_Terminal_ReceiveCmd()
		{
			LevelAPI.OnLevelCleanup += delegate
			{
				Inject_Terminal_ReceiveCmd.OnCmdUsed_LevelInstanced = null;
			};
		}

		private static void Prefix(LG_ComputerTerminalCommandInterpreter __instance, TERM_Command cmd, string inputLine, string param1, string param2)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Inject_Terminal_ReceiveCmd.OnCmdUsed_LevelInstanced?.Invoke(__instance, cmd, inputLine, param1, param2);
		}
	}
}