using System;
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 AIGraph;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using ChainedPuzzles;
using EOSExt.SecurityDoorTerminal.Definition;
using ExtraObjectiveSetup;
using ExtraObjectiveSetup.BaseClasses;
using ExtraObjectiveSetup.BaseClasses.CustomTerminalDefinition;
using ExtraObjectiveSetup.ExtendedWardenEvents;
using ExtraObjectiveSetup.Utils;
using GTFO.API;
using GTFO.API.Extensions;
using GameData;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
using SecDoorTerminalInterface;
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("Inas07.EOSExt.SecurityDoorTerminal")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Inas07.EOSExt.SecurityDoorTerminal")]
[assembly: AssemblyTitle("Inas07.EOSExt.SecurityDoorTerminal")]
[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 EOSExt.SecurityDoorTerminal
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Inas.EOSExt.SecurityDoorTerminal", "EOSExt.SecurityDoorTerminal", "1.0.0")]
public class EntryPoint : BasePlugin
{
public const string AUTHOR = "Inas";
public const string PLUGIN_NAME = "EOSExt.SecurityDoorTerminal";
public const string VERSION = "1.0.0";
public override void Load()
{
SetupManagers();
EOSLogger.Log("ExtraObjectiveSetup.SecurityDoorTerminal loaded.");
}
private void SetupManagers()
{
((ZoneDefinitionManager<SecurityDoorTerminalDefinition>)SecurityDoorTerminalManager.Current).Init();
}
}
public sealed class SecurityDoorTerminalManager : ZoneDefinitionManager<SecurityDoorTerminalDefinition>
{
private enum SDTWardenEvents
{
ADD_OVERRIDE_COMMAND = 1000
}
private const string OVERRIDE_COMMAND = "ACCESS_OVERRIDE";
private List<(SecDoorTerminal sdt, SecurityDoorTerminalDefinition def)> levelSDTs = new List<(SecDoorTerminal, SecurityDoorTerminalDefinition)>();
public static SecurityDoorTerminalManager Current { get; private set; }
protected override string DEFINITION_NAME => "SecDoorTerminal";
public bool TryGetZoneEntranceSecDoor(LG_Zone zone, out LG_SecurityDoor door)
{
if ((Object)(object)zone == (Object)null)
{
door = null;
return false;
}
if ((Object)(object)zone.m_sourceGate == (Object)null)
{
door = null;
return false;
}
if (zone.m_sourceGate.SpawnedDoor == null)
{
door = null;
return false;
}
door = ((Il2CppObjectBase)zone.m_sourceGate.SpawnedDoor).TryCast<LG_SecurityDoor>();
return (Object)(object)door != (Object)null;
}
protected override void AddDefinitions(ZoneDefinitionsForLevel<SecurityDoorTerminalDefinition> definitions)
{
base.Sort(definitions);
base.AddDefinitions(definitions);
}
private void AddOverrideCommandWithAlarmText(SecDoorTerminal sdt)
{
if (sdt.CmdProcessor.HasRegisteredCommand((TERM_Command)254))
{
return;
}
string text = "<color=orange>" + Text.Get(841u) + "</color>";
if ((Object)(object)sdt.LinkedDoorLocks.ChainedPuzzleToSolve != (Object)null && sdt.LinkedDoorLocks.ChainedPuzzleToSolve.Data.TriggerAlarmOnActivate)
{
string format = Text.Get(840u);
ChainedPuzzleInstance chainedPuzzleToSolve = sdt.LinkedDoorLocks.ChainedPuzzleToSolve;
text = "<color=orange>" + string.Format(format, (chainedPuzzleToSolve != null) ? chainedPuzzleToSolve.Data.PublicAlarmName : null) + "</color>";
int num = text.IndexOf('[');
if (num >= 0 && num < text.Length)
{
text = text.Insert(num, "\n");
}
}
sdt.AddOverrideCommand("ACCESS_OVERRIDE", text, (Action<LG_ComputerTerminalCommandInterpreter>)null);
}
private void BuildSDT_UniqueCommands(SecDoorTerminal sdt, SecurityDoorTerminalDefinition def)
{
def.TerminalSettings.UniqueCommands.ForEach(delegate(CustomCommand cmd)
{
EOSTerminalUtils.AddUniqueCommand(sdt.ComputerTerminal, cmd);
});
}
private void BuildLevelSDTs_UniqueCommands()
{
levelSDTs.ForEach(delegate((SecDoorTerminal sdt, SecurityDoorTerminalDefinition def) tp)
{
BuildSDT_UniqueCommands(tp.sdt, tp.def);
});
}
private void BuildLevelSDTs_Passwords()
{
levelSDTs.ForEach(delegate((SecDoorTerminal sdt, SecurityDoorTerminalDefinition def) tp)
{
EOSTerminalUtils.BuildPassword(tp.sdt.ComputerTerminal, tp.def.TerminalSettings.PasswordData);
});
}
private void WardenEvent_AddOverrideCommand(WardenObjectiveEventData e)
{
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: 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_0052: 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)
int num = levelSDTs.FindIndex(delegate((SecDoorTerminal sdt, SecurityDoorTerminalDefinition def) tp)
{
//IL_0021: 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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: 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_0057: Unknown result type (might be due to invalid IL or missing references)
AIG_CourseNode courseNode = ((LG_ZoneExpander)tp.sdt.LinkedDoor.Gate).m_linksTo.m_courseNode;
return courseNode.m_dimension.DimensionIndex == e.DimensionIndex && courseNode.LayerType == e.Layer && courseNode.m_zone.LocalIndex == e.LocalIndex;
});
if (num == -1)
{
EOSLogger.Error($"SDT_AddOverrideCommand: SDT not found on door to {(e.DimensionIndex, e.Layer, e.LocalIndex)}");
}
else
{
SecDoorTerminal item = levelSDTs[num].sdt;
AddOverrideCommandWithAlarmText(item);
EOSLogger.Debug($"SDT_AddOverrideCommand: added for SDT {(e.DimensionIndex, e.Layer, e.LocalIndex)}");
}
}
private SecDoorTerminal BuildSDT_Instantiation(SecurityDoorTerminalDefinition def)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_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_0038: 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)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Expected O, but got Unknown
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Expected I4, but got Unknown
var (val, val2, val3) = ((GlobalZoneIndex)def).GlobalZoneIndexTuple();
LG_Zone val4 = default(LG_Zone);
if (!Builder.CurrentFloor.TryGetZoneByLocalIndex(val, val2, val3, ref val4) || (Object)(object)val4 == (Object)null)
{
EOSLogger.Error($"SecDoorTerminal: Cannot find target zone {((GlobalZoneIndex)def).GlobalZoneIndexTuple()}");
return null;
}
if (!TryGetZoneEntranceSecDoor(val4, out var door) || (Object)(object)door == (Object)null)
{
EOSLogger.Error($"SecDoorTerminal: Cannot find spawned sec-door for zone {((GlobalZoneIndex)def).GlobalZoneIndexTuple()}");
return null;
}
SecDoorTerminal sdt = SecDoorTerminal.Place(door, new TerminalStartStateData
{
StartingState = (TERM_State)0
}, (TerminalPlacementData)null);
sdt.BioscanScanSolvedBehaviour = def.StateSettings.OnPuzzleSolved;
if (sdt == null)
{
EOSLogger.Error("Build failed: Can only attach SDT to regular security door");
return null;
}
((LG_ZoneExpander)val4.m_sourceGate).m_linksFrom.m_zone.TerminalsSpawnedInZone.Add(sdt.ComputerTerminal);
sdt.BioscanScanSolvedBehaviour = def.StateSettings.OnPuzzleSolved;
def.TerminalSettings.LocalLogFiles.ForEach(delegate(TerminalLogFileData log)
{
sdt.ComputerTerminal.AddLocalLog(log, true);
});
eDoorStatus status = sdt.LinkedDoor.m_sync.GetCurrentSyncState().status;
switch (status - 1)
{
case 2:
if (def.StateSettings.LockedStateSetting.AccessibleWhenLocked)
{
sdt.LinkedDoorLocks.m_gateKeyItemNeeded.keyPickupCore.m_interact.OnPickedUpByPlayer += Action<PlayerAgent>.op_Implicit((Action<PlayerAgent>)delegate
{
sdt.SetTerminalActive(false);
});
sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenLocked);
List<string> list4 = new List<string> { string.Format("<color=orange>" + Text.Get(849u) + "</color>", sdt.LinkedDoorLocks.m_gateKeyItemNeeded.PublicName) };
sdt.ComputerTerminal.m_command.AddOutput(ListExtensions.ToIl2Cpp<string>(list4));
}
break;
case 5:
sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenLocked);
if (def.StateSettings.LockedStateSetting.AccessibleWhenLocked)
{
List<string> list2 = new List<string> { string.Format("<color=orange>" + Text.Get(842u) + "</color>", sdt.LinkedDoorLocks.m_powerGeneratorNeeded.PublicName) };
sdt.ComputerTerminal.m_command.AddOutput(ListExtensions.ToIl2Cpp<string>(list2));
}
break;
case 14:
sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenLocked);
if (def.StateSettings.LockedStateSetting.AccessibleWhenLocked)
{
List<string> list = new List<string> { string.Format("<color=orange>" + Text.Get(843u) + "</color>", sdt.LinkedDoorLocks.m_bulkheadDCNeeded.PublicName) };
sdt.ComputerTerminal.m_command.AddOutput(ListExtensions.ToIl2Cpp<string>(list));
}
break;
case 6:
sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenLocked);
if (def.StateSettings.LockedStateSetting.AccessibleWhenLocked)
{
List<string> list3 = new List<string> { sdt.LinkedDoorLocks.m_intCustomMessage.m_message };
sdt.ComputerTerminal.m_command.AddOutput(ListExtensions.ToIl2Cpp<string>(list3));
}
else
{
sdt.SetCustomMessageActive(true);
}
break;
case 0:
case 3:
case 4:
case 8:
if (def.StateSettings.OverrideCommandAccessibility != OverrideCmdAccess.ADDED_BY_WARDEN_EVENT)
{
AddOverrideCommandWithAlarmText(sdt);
}
sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenUnlocked);
break;
}
sdt.LinkedDoor.m_sync.OnDoorStateChange += Action<pDoorState, bool>.op_Implicit((Action<pDoorState, bool>)delegate(pDoorState state, bool isDropin)
{
//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_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_0043: Expected I4, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Invalid comparison between Unknown and I4
eDoorStatus status3 = state.status;
switch (status3 - 3)
{
case 0:
case 3:
case 4:
case 12:
sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenLocked);
if ((int)state.status == 7)
{
sdt.SetCustomMessageActive(true);
}
break;
case 1:
case 2:
case 6:
sdt.SetTerminalActive(def.StateSettings.LockedStateSetting.AccessibleWhenUnlocked);
break;
case 5:
case 7:
case 8:
case 9:
case 10:
case 11:
break;
}
});
switch (def.StateSettings.OverrideCommandAccessibility)
{
case OverrideCmdAccess.ALWAYS:
AddOverrideCommandWithAlarmText(sdt);
break;
case OverrideCmdAccess.ON_UNLOCK:
sdt.LinkedDoor.m_sync.OnDoorStateChange += Action<pDoorState, bool>.op_Implicit((Action<pDoorState, bool>)delegate(pDoorState state, bool isDropin)
{
//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_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_000b: Invalid comparison between Unknown and I4
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Invalid comparison between Unknown and I4
eDoorStatus status2 = state.status;
if (status2 - 4 <= 1 || (int)status2 == 9)
{
AddOverrideCommandWithAlarmText(sdt);
}
});
break;
}
return sdt;
}
public override void Init()
{
base.Init();
}
private void BuildLevelSDTs_Instantiation()
{
if (!base.definitions.ContainsKey(RundownManager.ActiveExpedition.LevelLayoutData))
{
return;
}
foreach (SecurityDoorTerminalDefinition definition in base.definitions[RundownManager.ActiveExpedition.LevelLayoutData].Definitions)
{
SecDoorTerminal item = BuildSDT_Instantiation(definition);
levelSDTs.Add((item, definition));
}
}
private void OnLevelCleanup()
{
levelSDTs.Clear();
}
private SecurityDoorTerminalManager()
{
EOSWardenEventManager.Current.AddEventDefinition(SDTWardenEvents.ADD_OVERRIDE_COMMAND.ToString(), 1000u, (Action<WardenObjectiveEventData>)WardenEvent_AddOverrideCommand);
BatchBuildManager.Current.Add_OnBatchDone((BatchName)75, (Action)BuildLevelSDTs_Instantiation);
BatchBuildManager.Current.Add_OnBatchDone((BatchName)76, (Action)BuildLevelSDTs_Passwords);
LevelAPI.OnBuildDone += BuildLevelSDTs_UniqueCommands;
LevelAPI.OnLevelCleanup += OnLevelCleanup;
}
static SecurityDoorTerminalManager()
{
Current = new SecurityDoorTerminalManager();
}
}
}
namespace EOSExt.SecurityDoorTerminal.Definition
{
public enum OverrideCmdAccess
{
ALWAYS,
ON_UNLOCK,
ADDED_BY_WARDEN_EVENT
}
public class SDTStateSetting_Locked
{
public bool AccessibleWhenLocked { get; set; }
public bool AccessibleWhenUnlocked { get; set; } = true;
}
public class SDTStateSetting
{
public SDTStateSetting_Locked LockedStateSetting { get; set; } = new SDTStateSetting_Locked();
public OverrideCmdAccess OverrideCommandAccessibility { get; set; } = OverrideCmdAccess.ON_UNLOCK;
public CPSolvedBehaviour OnPuzzleSolved { get; set; } = (CPSolvedBehaviour)1;
}
public class SecurityDoorTerminalDefinition : GlobalZoneIndex
{
public SDTStateSetting StateSettings { get; set; } = new SDTStateSetting();
public TerminalDefinition TerminalSettings { get; set; } = new TerminalDefinition();
}
}