Decompiled source of DoubleSidedDoors v0.7.0

GTFODoubleSidedDoors.dll

Decompiled 17 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using AIGraph;
using Agents;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using ChainedPuzzles;
using DoubleSidedDoors.Module;
using DoubleSidedDoors.Utils;
using GTFO.API;
using GTFO.API.Utilities;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using MTFO.API;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("GTFODoubleSidedDoors")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+479f3aa00e16057f144367ba21d92ef0164b7386")]
[assembly: AssemblyProduct("GTFODoubleSidedDoors")]
[assembly: AssemblyTitle("GTFODoubleSidedDoors")]
[assembly: AssemblyVersion("1.0.0.0")]
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 DoubleSidedDoors
{
	internal static class DSDLogger
	{
		private static readonly ManualLogSource _logger = Logger.CreateLogSource("DoubleSidedDoors");

		public static void Log(string str)
		{
			_logger.Log((LogLevel)8, (object)str);
		}

		public static void Warn(string str)
		{
			_logger.Log((LogLevel)4, (object)str);
		}

		public static void Error(string str)
		{
			_logger.Log((LogLevel)2, (object)str);
		}

		public static void Debug(string str, bool force = false)
		{
			if (ConfigManager.Debug || force)
			{
				_logger.Log((LogLevel)32, (object)str);
			}
		}
	}
	[BepInPlugin("Amor.DoubleSidedDoors", "DoubleSidedDoors", "0.7.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class EntryPoint : BasePlugin
	{
		public const string GUID = "Amor.DoubleSidedDoors";

		public const string NAME = "DoubleSidedDoors";

		public const string VERSION = "0.7.0";

		public override void Load()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("randomuserhi.DoubleSidedDoors"))
			{
				DSDLogger.Error("OG DoubleSidedDoors present!\nTo prevent potential problems: Please either create a fresh profile or find and delete the old .dll");
				return;
			}
			DSDLogger.Log("Plugin is loaded!");
			new Harmony("Amor.DoubleSidedDoors").PatchAll();
			DSDLogger.Log("Debug is " + (ConfigManager.Debug ? "Enabled" : "Disabled"));
		}
	}
}
namespace DoubleSidedDoors.Utils
{
	internal static class ConfigManager
	{
		private static readonly ConfigFile _configFile;

		private static readonly ConfigEntry<bool> _debug;

		private static readonly string CustomPath;

		public static bool Debug
		{
			get
			{
				return _debug.Value;
			}
			set
			{
				_debug.Value = value;
			}
		}

		static ConfigManager()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Expected O, but got Unknown
			CustomPath = Path.Combine(MTFOPathAPI.CustomPath, "DoubleSidedDoors");
			_configFile = new ConfigFile(Path.Combine(Paths.ConfigPath, "DoubleSidedDoors.cfg"), true);
			_debug = _configFile.Bind<bool>("Debug", "enable", false, "Force enables all debugging messages in the console.");
			DirectoryInfo directoryInfo = Directory.CreateDirectory(CustomPath);
			FileInfo[] files = directoryInfo.GetFiles();
			DSDLogger.Debug("Searching: " + directoryInfo.FullName, force: true);
			FileInfo[] array = files;
			foreach (FileInfo fileInfo in array)
			{
				DSDLogger.Debug("Found: " + fileInfo.FullName, force: true);
				string extension = fileInfo.Extension;
				bool flag = extension.Equals(".json", StringComparison.InvariantCultureIgnoreCase);
				bool flag2 = extension.Equals(".jsonc", StringComparison.InvariantCultureIgnoreCase);
				if (flag || flag2)
				{
					LayoutConfig layoutConfig = JSON.Deserialize<LayoutConfig>(File.ReadAllText(fileInfo.FullName));
					layoutConfig.Filepath = fileInfo.FullName;
					if (!SharedDoorData.DSDData.TryAdd(layoutConfig.MainLevelLayout, layoutConfig))
					{
						DSDLogger.Error($"Duplicated ID found!: {fileInfo.Name}, {layoutConfig.MainLevelLayout}");
					}
				}
			}
			if (PartialDataUtil.HasPData)
			{
				LiveEditListener val = LiveEdit.CreateListener(CustomPath, "*.json", false);
				val.FileChanged += new LiveEditEventHandler(FileChanged);
				val.FileCreated += new LiveEditEventHandler(FileChanged);
				val.FileDeleted += new LiveEditEventHandler(FileDeleted);
			}
		}

		private static void FileChanged(LiveEditEventArgs e)
		{
			LiveEditEventArgs e2 = e;
			DSDLogger.Warn("[LiveEdit] File changed: " + e2.FullPath);
			LiveEdit.TryReadFileContent(e2.FullPath, (Action<string>)delegate(string content)
			{
				LayoutConfig layoutConfig = JSON.Deserialize<LayoutConfig>(content);
				layoutConfig.Filepath = e2.FullPath;
				SharedDoorData.DSDData[layoutConfig.MainLevelLayout] = layoutConfig;
			});
		}

		private static void FileDeleted(LiveEditEventArgs e)
		{
			LiveEditEventArgs e2 = e;
			DSDLogger.Warn("[LiveEdit] File deleted: " + e2.FullPath);
			foreach (KeyValuePair<uint, LayoutConfig> item in SharedDoorData.DSDData.Where<KeyValuePair<uint, LayoutConfig>>((KeyValuePair<uint, LayoutConfig> d) => d.Value.Filepath == e2.FullPath))
			{
				SharedDoorData.DSDData.Remove(item.Key);
			}
		}
	}
	internal static class JSON
	{
		private static readonly JsonSerializerOptions _setting;

		static JSON()
		{
			_setting = new JsonSerializerOptions
			{
				ReadCommentHandling = JsonCommentHandling.Skip,
				IncludeFields = false,
				PropertyNameCaseInsensitive = true,
				WriteIndented = true,
				IgnoreReadOnlyProperties = true
			};
			_setting.Converters.Add(new LocaleTextConverter());
			_setting.Converters.Add(new JsonStringEnumConverter());
			if (PartialDataUtil.HasPData)
			{
				_setting.Converters.Add(PartialDataUtil.PersistentIDConverter);
				DSDLogger.Log("PartialData support found! You are based.");
			}
		}

		public static T Deserialize<T>(string json)
		{
			return JsonSerializer.Deserialize<T>(json, _setting);
		}

		public static object Deserialize(Type type, string json)
		{
			return JsonSerializer.Deserialize(json, type, _setting);
		}

		public static string Serialize(object value, Type type)
		{
			return JsonSerializer.Serialize(value, type, _setting);
		}
	}
	[JsonConverter(typeof(LocaleTextConverter))]
	public struct LocaleText
	{
		public uint ID;

		public string RawText;

		public static readonly LocaleText Empty = new LocaleText(string.Empty);

		public string Translated => (ID == 0) ? RawText : Text.Get(ID);

		public LocaleText(LocalizedText baseText)
		{
			if (baseText.HasTranslation)
			{
				RawText = string.Empty;
				ID = baseText.Id;
			}
			else
			{
				RawText = baseText.UntranslatedText;
				ID = 0u;
			}
		}

		public LocaleText(string text)
		{
			RawText = text;
			ID = 0u;
		}

		public LocaleText(uint id)
		{
			RawText = string.Empty;
			ID = id;
		}

		public LocalizedText ToLocalizedText()
		{
			//IL_0029: 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_0036: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			return (ID == 0) ? new LocalizedText
			{
				Id = 0u,
				UntranslatedText = RawText
			} : new LocalizedText
			{
				Id = ID,
				UntranslatedText = string.Empty
			};
		}

		public override string ToString()
		{
			return Translated;
		}

		public static explicit operator LocaleText(LocalizedText localizedText)
		{
			return new LocaleText(localizedText);
		}

		public static explicit operator LocaleText(string text)
		{
			return new LocaleText(text);
		}

		public static implicit operator LocalizedText(LocaleText localeText)
		{
			return localeText.ToLocalizedText();
		}

		public static implicit operator string(LocaleText localeText)
		{
			return localeText.Translated;
		}
	}
	public class LocaleTextConverter : JsonConverter<LocaleText>
	{
		public override bool HandleNull => true;

		public override LocaleText Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
		{
			return reader.TokenType switch
			{
				JsonTokenType.String => new LocaleText(reader.GetString()), 
				JsonTokenType.Number => new LocaleText(reader.GetUInt32()), 
				JsonTokenType.Null => LocaleText.Empty, 
				_ => throw new JsonException($"[LocaleTextJson] Type: {reader.TokenType} is not implemented!"), 
			};
		}

		public override void Write(Utf8JsonWriter writer, LocaleText value, JsonSerializerOptions options)
		{
			if (value.ID != 0)
			{
				writer.WriteNumberValue(value.ID);
			}
			else
			{
				writer.WriteStringValue(value.RawText);
			}
		}
	}
	internal static class PartialDataUtil
	{
		public const string PLUGIN_GUID = "MTFO.Extension.PartialBlocks";

		public static readonly bool HasPData;

		public static JsonConverter? PersistentIDConverter { get; private set; }

		static PartialDataUtil()
		{
			HasPData = false;
			PersistentIDConverter = null;
			if (!((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value))
			{
				return;
			}
			try
			{
				Assembly assembly = ((value == null) ? null : value.Instance?.GetType()?.Assembly) ?? throw new Exception("Assembly is missing!");
				Type[] types = assembly.GetTypes();
				Type type = types.First((Type t) => t.Name == "PersistentIDConverter") ?? throw new Exception("Unable to find PersistentIDConverter class");
				PersistentIDConverter = (JsonConverter)Activator.CreateInstance(type);
				HasPData = true;
			}
			catch (Exception value2)
			{
				DSDLogger.Error($"Exception thrown while reading data from MTFO_Extension_PartialData:\n{value2}");
			}
		}
	}
}
namespace DoubleSidedDoors.Module
{
	public sealed class LayoutConfig
	{
		[JsonIgnore]
		public string Filepath { get; set; } = string.Empty;


		public uint MainLevelLayout { get; set; }

		public DSDCustomization[] Doors { get; set; } = Array.Empty<DSDCustomization>();

	}
	public sealed class DSDCustomization : GlobalIndexBase
	{
		public enum DSDType : byte
		{
			Flipped,
			DoubleHandleOnly,
			OverrideOnly,
			DoubleSided,
			FlippedDoubleSided
		}

		public DSDType Type { get; set; } = DSDType.Flipped;


		public HashSet<HashSet<int>> BindToPlayer { get; set; } = new HashSet<HashSet<int>>();


		public LocaleText FrontHandleText { get; set; } = LocaleText.Empty;


		public LocaleText RearHandleText { get; set; } = (LocaleText)"<color=red>BI-DIRECTIONAL ACCESS DISABLED</color>";


		public DoorTriggerOverride TriggerOverride { get; set; } = new DoorTriggerOverride();


		public eDoorStatus GraphicStateOverride { get; set; } = (eDoorStatus)0;


		[JsonIgnore]
		public DoorIdentifier Identifier { get; set; } = new DoorIdentifier();


		public bool Flipped => Type.ToString().Contains("Flipped");

		public bool DoubleHandle => Type.ToString().Contains("Double");
	}
	public sealed class DoorTriggerOverride : GlobalIndexBase
	{
		public enum LinkedTriggerType : byte
		{
			None,
			Source,
			Target,
			Both
		}

		public bool OpenOnTarget { get; set; } = false;


		public LinkedTriggerType LinkTriggerTo { get; set; } = LinkedTriggerType.None;


		[JsonIgnore]
		public LG_SecurityDoor LinkedDoor { get; set; } = new LG_SecurityDoor();

	}
	public sealed class DoorIdentifier
	{
		public LG_SecurityDoor SecDoor { get; private set; } = new LG_SecurityDoor();


		public GameObject? RearGateInteract { get; private set; } = new GameObject();


		public LG_Area AreaGateLinksTo { get; private set; } = new LG_Area();


		public int SecDoorInstanceID { get; private set; }

		public int DoorTransformInstanceID { get; private set; }

		public int GateInstanceID { get; private set; }

		public int TerminalItemInstanceID { get; private set; }

		public void Initialize(LG_SecurityDoor door, LG_Gate gate, GameObject? rearInteract)
		{
			SecDoor = door;
			RearGateInteract = rearInteract;
			AreaGateLinksTo = ((LG_ZoneExpander)gate).m_linksTo;
			SecDoorInstanceID = ((Object)door).GetInstanceID();
			DoorTransformInstanceID = ((Object)((Component)door).transform).GetInstanceID();
			GateInstanceID = ((Object)gate).GetInstanceID();
			TerminalItemInstanceID = ((Object)((Il2CppObjectBase)door.m_terminalItem).Cast<LG_GenericTerminalItem>()).GetInstanceID();
		}
	}
	public class GlobalIndexBase
	{
		public GlobalZoneIndex Global => new GlobalZoneIndex(DimensionIndex, Layer, LocalIndex);

		public LG_LayerType Layer { get; set; } = (LG_LayerType)0;


		public eDimensionIndex DimensionIndex { get; set; } = (eDimensionIndex)0;


		public eLocalZoneIndex LocalIndex { get; set; } = (eLocalZoneIndex)0;


		public string PrintGlobal()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			return $"(Dimension: {DimensionIndex}, Layer: {Layer}, LocalIndex: {LocalIndex})";
		}
	}
	public static class SharedDoorData
	{
		public static Dictionary<uint, LayoutConfig> DSDData { get; set; } = new Dictionary<uint, LayoutConfig>();


		public static DSDCustomization[] Current { get; set; } = Array.Empty<DSDCustomization>();


		public static bool OnDoorSync { get; set; } = false;


		public static GlobalZoneIndex GetGlobalIndexFrom(LG_Gate gate)
		{
			//IL_0003: 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_001b: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_0054: 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)
			GlobalZoneIndex result = default(GlobalZoneIndex);
			result.Dimension = ((LG_ZoneExpander)gate).m_linksTo.m_zone.DimensionIndex;
			result.Layer = ((LG_ZoneExpander)gate).m_linksTo.m_zone.Layer.m_type;
			result.Zone = ((LG_ZoneExpander)gate).m_linksTo.m_zone.LocalIndex;
			return result;
		}

		public static bool TryGetCurrentCustomConfig(Func<DoorIdentifier, int> property, int id, [NotNullWhen(true)] out DSDCustomization? custom)
		{
			Func<DoorIdentifier, int> property2 = property;
			custom = Current.FirstOrDefault((DSDCustomization cfg) => property2(cfg.Identifier) == id);
			return custom != null;
		}

		public static bool TryGetDoorFromGlobalIndex(GlobalZoneIndex global, [NotNullWhen(true)] out LG_SecurityDoor? door)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			LG_Zone val = default(LG_Zone);
			if (Builder.CurrentFloor.TryGetZoneByLocalIndex(global.Dimension, global.Layer, global.Zone, ref val))
			{
				object obj;
				if (val == null)
				{
					obj = null;
				}
				else
				{
					LG_Gate sourceGate = val.m_sourceGate;
					if (sourceGate == null)
					{
						obj = null;
					}
					else
					{
						iLG_Door_Core spawnedDoor = sourceGate.SpawnedDoor;
						obj = ((spawnedDoor != null) ? ((Il2CppObjectBase)spawnedDoor).TryCast<LG_SecurityDoor>() : null);
					}
				}
				door = (LG_SecurityDoor?)obj;
				return (Object)(object)door != (Object)null;
			}
			door = null;
			return false;
		}

		public static void OverrideIntText(LG_SecurityDoor_Locks locks)
		{
			if (TryGetCurrentCustomConfig((DoorIdentifier cfg) => cfg.SecDoorInstanceID, ((Object)locks.m_door).GetInstanceID(), out DSDCustomization custom) && !((string)custom.FrontHandleText == (string)LocaleText.Empty))
			{
				string text = Regex.Replace(custom.FrontHandleText.ToString(), "\\[DOOR_(\\d+)_\\d+_\\d+\\]", delegate(Match m)
				{
					//IL_0049: Unknown result type (might be due to invalid IL or missing references)
					int num = int.Parse(m.Groups[1].Value);
					int num2 = int.Parse(m.Groups[2].Value);
					int num3 = int.Parse(m.Groups[3].Value);
					LG_SecurityDoor door;
					return (!TryGetDoorFromGlobalIndex(new GlobalZoneIndex(num, num2, num3), out door)) ? $"[DSD - DEBUG] DOOR({num}_{num2}_{num3}) not found" : $"SEC_DOOR_{door.m_serialNumber}";
				});
				locks.m_intOpenDoor.InteractionMessage = text;
				((Interact_Timed)locks.m_intUseKeyItem).InteractionMessage = text;
				((Interact_Timed)locks.m_intHack).InteractionMessage = text;
				locks.m_intCustomMessage.m_message = text;
			}
		}
	}
}
namespace DoubleSidedDoors.Module.Patches
{
	[HarmonyPatch]
	internal static class Patch_FromElevatorSpawn
	{
		[HarmonyPatch(typeof(SurvivalWave), "GetScoredSpawnPoint_FromElevator")]
		[HarmonyPrefix]
		private static bool GetScoredSpawnPoint_FromElevator(SurvivalWave __instance, ref ScoredSpawnPoint __result)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00ab: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			AIG_CourseNode startCourseNode = __instance.m_courseNode.m_dimension.GetStartCourseNode();
			AIG_CourseNode val = null;
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				if (IsTargetReachable(startCourseNode, current.m_courseNode))
				{
					val = current.m_courseNode;
					break;
				}
			}
			if (val == null)
			{
				return true;
			}
			Vector3 val2 = startCourseNode.Position - val.Position;
			Vector3 normalized = ((Vector3)(ref val2)).normalized;
			normalized.y = 0f;
			List<ScoredSpawnPoint> availableSpawnPointsBetweenElevatorAndNode = __instance.GetAvailableSpawnPointsBetweenElevatorAndNode(val, 20);
			ScoredSpawnPoint val3 = new ScoredSpawnPoint
			{
				totalCost = float.MinValue
			};
			Vector3 position = val.Position;
			float num = 1f;
			float num2 = 4f - num;
			Enumerator<ScoredSpawnPoint> enumerator2 = availableSpawnPointsBetweenElevatorAndNode.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				ScoredSpawnPoint current2 = enumerator2.Current;
				Vector3 val4 = current2.firstCoursePortal.Position - position;
				val4.y = 0f;
				((Vector3)(ref val4)).Normalize();
				current2.m_dir = val4;
				current2.totalCost = Mathf.Clamp01(Vector3.Dot(val4, normalized));
				if (current2.pathHeat > num - 0.01f)
				{
					current2.totalCost += 1f + (1f - Mathf.Clamp(current2.pathHeat - num, 0f, num2) / num2);
				}
				if (val3 == null)
				{
					val3 = current2;
				}
				else if (current2.totalCost > val3.totalCost)
				{
					val3 = current2;
				}
			}
			ScoredSpawnPoint val5 = val3;
			if (val5.courseNode == null)
			{
				AIG_CourseNode val7 = (val5.courseNode = val);
			}
			__result = val3;
			return false;
		}

		private static bool IsTargetReachable(AIG_CourseNode source, AIG_CourseNode target)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Invalid comparison between Unknown and I4
			if (source == null || target == null)
			{
				return false;
			}
			if (source.NodeID == target.NodeID)
			{
				return true;
			}
			AIG_SearchID.IncrementSearchID();
			ushort searchID = AIG_SearchID.SearchID;
			Queue<AIG_CourseNode> queue = new Queue<AIG_CourseNode>();
			queue.Enqueue(source);
			while (queue.Count > 0)
			{
				AIG_CourseNode val = queue.Dequeue();
				((AIG_CourseGraphMember)val).m_searchID = searchID;
				Enumerator<AIG_CoursePortal> enumerator = val.m_portals.GetEnumerator();
				while (enumerator.MoveNext())
				{
					AIG_CoursePortal current = enumerator.Current;
					LG_Gate gate = current.Gate;
					object obj;
					if (gate == null)
					{
						obj = null;
					}
					else
					{
						iLG_Door_Core spawnedDoor = gate.SpawnedDoor;
						obj = ((spawnedDoor != null) ? ((Il2CppObjectBase)spawnedDoor).TryCast<LG_SecurityDoor>() : null);
					}
					LG_SecurityDoor val2 = (LG_SecurityDoor)obj;
					if ((Object)(object)val2 != (Object)null && (int)val2.LastStatus != 10 && (int)val2.LastStatus != 16)
					{
						continue;
					}
					AIG_CourseNode oppositeNode = current.GetOppositeNode(val);
					if (((AIG_CourseGraphMember)oppositeNode).m_searchID != searchID)
					{
						if (oppositeNode.NodeID == target.NodeID)
						{
							return true;
						}
						queue.Enqueue(oppositeNode);
					}
				}
			}
			return false;
		}
	}
	[HarmonyPatch]
	internal static class Patch_LevelBehavior
	{
		[HarmonyPatch(typeof(ElevatorRide), "StartElevatorRide")]
		[HarmonyPostfix]
		private static void StartElevatorRide()
		{
			uint levelLayoutData = RundownManager.ActiveExpedition.LevelLayoutData;
			SharedDoorData.Current = (SharedDoorData.DSDData.TryGetValue(levelLayoutData, out LayoutConfig value) ? value.Doors : Array.Empty<DSDCustomization>());
			LevelAPI.OnBuildDone += SetupLinkedDoors;
		}

		private static void SetupLinkedDoors()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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)
			DSDCustomization[] current = SharedDoorData.Current;
			foreach (DSDCustomization dSDCustomization in current)
			{
				if (!SharedDoorData.TryGetDoorFromGlobalIndex(dSDCustomization.TriggerOverride.Global, out LG_SecurityDoor door))
				{
					continue;
				}
				bool flag = dSDCustomization.TriggerOverride.LinkTriggerTo == DoorTriggerOverride.LinkedTriggerType.Source;
				LG_SecurityDoor sourceDoor = (LG_SecurityDoor)(flag ? ((object)dSDCustomization.Identifier.SecDoor) : ((object)door));
				LG_SecurityDoor targetDoor = (LG_SecurityDoor)(flag ? ((object)door) : ((object)dSDCustomization.Identifier.SecDoor));
				if (dSDCustomization.TriggerOverride.LinkTriggerTo == DoorTriggerOverride.LinkedTriggerType.Source || dSDCustomization.TriggerOverride.LinkTriggerTo == DoorTriggerOverride.LinkedTriggerType.Target)
				{
					pDoorState activeState = new pDoorState
					{
						status = (eDoorStatus)8
					};
					LG_SecurityDoor_Locks locks = ((Il2CppObjectBase)targetDoor.m_locks).Cast<LG_SecurityDoor_Locks>();
					sourceDoor.m_locks.OnPlayerActivateChainedPuzzle += Action.op_Implicit((Action)delegate
					{
						//IL_0012: Unknown result type (might be due to invalid IL or missing references)
						//IL_002f: Unknown result type (might be due to invalid IL or missing references)
						targetDoor.m_graphics.OnDoorState(activeState, false);
						targetDoor.m_anim.OnDoorState(activeState, false);
						((Interact_Base)locks.m_intUseKeyItem).SetActive(false);
						((Interact_Base)locks.m_intOpenDoor).SetActive(false);
						((Interact_Base)locks.m_intHack).SetActive(false);
						((Interact_Base)locks.m_intCustomMessage).SetActive(false);
					});
					targetDoor.m_locks.OnPlayerActivateChainedPuzzle += Action.op_Implicit((Action)delegate
					{
						//IL_001e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0024: Unknown result type (might be due to invalid IL or missing references)
						//IL_003d: Unknown result type (might be due to invalid IL or missing references)
						//IL_005a: Unknown result type (might be due to invalid IL or missing references)
						sourceDoor.m_sync.AttemptDoorInteraction((eDoorInteractionType)4, 0f, 0f, default(Vector3), (Agent)null);
						targetDoor.m_graphics.OnDoorState(activeState, false);
						targetDoor.m_anim.OnDoorState(activeState, false);
						((Interact_Base)locks.m_intUseKeyItem).SetActive(false);
						((Interact_Base)locks.m_intOpenDoor).SetActive(false);
						((Interact_Base)locks.m_intHack).SetActive(false);
						((Interact_Base)locks.m_intCustomMessage).SetActive(false);
					});
					sourceDoor.m_locks.OnChainedPuzzleSolved += Action.op_Implicit((Action)delegate
					{
						//IL_0003: Unknown result type (might be due to invalid IL or missing references)
						//IL_000d: 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_0013: Unknown result type (might be due to invalid IL or missing references)
						//IL_001f: 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_0045: 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)
						//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
						//IL_0096: Unknown result type (might be due to invalid IL or missing references)
						pDoorState val = default(pDoorState);
						val.status = (eDoorStatus)9;
						pDoorState val2 = val;
						targetDoor.m_graphics.OnDoorState(val2, false);
						targetDoor.m_anim.OnDoorState(val2, false);
						targetDoor.m_locks.OnDoorState(val2, false);
						pChainedPuzzleState state = targetDoor.m_locks.ChainedPuzzleToSolve.m_stateReplicator.State;
						state.isSolved = true;
						state.isActive = false;
						if (SNet.IsMaster)
						{
							targetDoor.m_locks.ChainedPuzzleToSolve.m_stateReplicator.State = state;
						}
						targetDoor.m_sync.SetStateUnsynced(val2);
					});
				}
				else if (dSDCustomization.TriggerOverride.LinkTriggerTo == DoorTriggerOverride.LinkedTriggerType.Both)
				{
					sourceDoor.m_locks.OnPlayerActivateChainedPuzzle += Action.op_Implicit((Action)delegate
					{
						//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)
						targetDoor.m_sync.AttemptDoorInteraction((eDoorInteractionType)4, 0f, 0f, default(Vector3), (Agent)null);
					});
					targetDoor.m_locks.OnPlayerActivateChainedPuzzle += Action.op_Implicit((Action)delegate
					{
						//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)
						sourceDoor.m_sync.AttemptDoorInteraction((eDoorInteractionType)4, 0f, 0f, default(Vector3), (Agent)null);
					});
				}
				if (dSDCustomization.TriggerOverride.OpenOnTarget)
				{
					sourceDoor.m_anim.OnDoorIsOpen += Action.op_Implicit((Action)delegate
					{
						//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)
						targetDoor.m_sync.AttemptDoorInteraction((eDoorInteractionType)0, 0f, 0f, default(Vector3), (Agent)null);
					});
					targetDoor.m_anim.OnDoorIsOpen += Action.op_Implicit((Action)delegate
					{
						//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)
						sourceDoor.m_sync.AttemptDoorInteraction((eDoorInteractionType)0, 0f, 0f, default(Vector3), (Agent)null);
					});
				}
				dSDCustomization.TriggerOverride.LinkedDoor = door;
			}
		}

		[HarmonyPatch(typeof(WardenObjectiveManager), "CheckExpeditionFailed")]
		[HarmonyPostfix]
		private static void CheckExpeditionFailed(ref bool __result)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			if (__result)
			{
				return;
			}
			DSDCustomization[] current = SharedDoorData.Current;
			foreach (DSDCustomization dSDCustomization in current)
			{
				foreach (HashSet<int> item in dSDCustomization.BindToPlayer)
				{
					if (AllPlayersAreDownIn(item, out IEnumerable<string> deadPlayerNames) && (int)dSDCustomization.Identifier.SecDoor.LastStatus != 10)
					{
						DSDLogger.Warn(string.Join(" + ", deadPlayerNames) + " were downed while bound to unopened door -> ending run!");
						__result = true;
						return;
					}
				}
			}
		}

		private static bool AllPlayersAreDownIn(HashSet<int> set, out IEnumerable<string> deadPlayerNames)
		{
			deadPlayerNames = set.Where(PlayerIsDown).Select(DeadPlayerNames);
			List<PlayerAgent> list = (from player in set.Select(GetPlayerFrom)
				where (Object)(object)player != (Object)null
				select player).ToList();
			if (list.Count < 1)
			{
				return set.All(PlayerIsDown);
			}
			return list.All((PlayerAgent player) => !((Agent)player).Alive);
		}

		private static string DeadPlayerNames(int slot)
		{
			PlayerAgent? playerFrom = GetPlayerFrom(slot);
			return ((playerFrom != null) ? playerFrom.PlayerName : null) ?? "Someone??";
		}

		private static bool PlayerIsDown(int slot)
		{
			PlayerAgent? playerFrom = GetPlayerFrom(slot);
			return playerFrom != null && !((Agent)playerFrom).Alive;
		}

		private static PlayerAgent? GetPlayerFrom(int slot)
		{
			return PlayerManager.Current.GetPlayerAgentInSlot(slot);
		}
	}
	[HarmonyPatch]
	internal static class Patch_SecurityDoor
	{
		[HarmonyPatch(typeof(LG_SecurityDoor), "Setup")]
		[HarmonyPostfix]
		private static void SecDoor_Setup(LG_SecurityDoor __instance, LG_Gate gate)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Invalid comparison between Unknown and I4
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			LG_Gate gate2 = gate;
			if ((int)__instance.m_securityDoorType > 0)
			{
				return;
			}
			DSDCustomization dSDCustomization = SharedDoorData.Current.FirstOrDefault(delegate(DSDCustomization cfg)
			{
				//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_000f: Unknown result type (might be due to invalid IL or missing references)
				GlobalZoneIndex global = cfg.Global;
				return ((object)(GlobalZoneIndex)(ref global)).Equals((object?)SharedDoorData.GetGlobalIndexFrom(gate2));
			});
			if (dSDCustomization == null)
			{
				return;
			}
			Transform val = ((Component)__instance).transform.Find("crossing");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (dSDCustomization.Flipped)
			{
				val.localRotation *= Quaternion.Euler(0f, 180f, 0f);
			}
			GameObject val2 = null;
			if (dSDCustomization.DoubleHandle)
			{
				Transform val3 = ((Component)__instance.m_doorBladeCuller).transform.Find("securityDoor_8x4_tech/bottomDoor/g_securityDoor_bottomDoor_capback") ?? ((Component)__instance.m_doorBladeCuller).transform.Find("securityDoor_4x4_tech (1)/rightDoor/g_securityDoor_bottomDoor_capback001");
				if ((Object)(object)val3 == (Object)null)
				{
					return;
				}
				((Component)val3).gameObject.SetActive(false);
				Transform val4 = ((Component)__instance.m_doorBladeCuller).transform.Find("securityDoor_8x4_tech/bottomDoor/InteractionInterface") ?? ((Component)__instance.m_doorBladeCuller).transform.Find("securityDoor_4x4_tech (1)/rightDoor/InteractionInterface");
				if ((Object)(object)val4 == (Object)null)
				{
					return;
				}
				bool flag = (Object)(object)((Component)__instance.m_doorBladeCuller).transform.Find("securityDoor_4x4_tech (1)") != (Object)null;
				GameObject val5 = Object.Instantiate<GameObject>(((Component)val4).gameObject, val4.parent);
				val5.transform.localRotation = val4.localRotation * Quaternion.Euler(180f, 180f, 0f);
				val5.transform.localPosition = val4.localPosition + (flag ? new Vector3(0f, 0.28f, 0f) : new Vector3(0f, 0f, -0.25f));
				Transform val6 = ((Component)__instance).transform.Find("crossing/Interaction_Message");
				if ((Object)(object)val6 == (Object)null)
				{
					return;
				}
				val2 = Object.Instantiate<GameObject>(((Component)val6).gameObject, val6.parent);
				val2.transform.position = val5.transform.position;
				Interact_MessageOnScreen component = val2.GetComponent<Interact_MessageOnScreen>();
				component.MessageType = (eMessageOnScreenType)1;
				component.m_message = dSDCustomization.RearHandleText.ToString();
				val2.SetActive(true);
				((Interact_Base)component).SetActive(true);
			}
			dSDCustomization.Identifier.Initialize(__instance, gate2, val2);
			DSDLogger.Debug($"SEC_DOOR_{__instance.m_serialNumber} setup as {dSDCustomization.Type}.\n{dSDCustomization.PrintGlobal()}\n");
		}

		[HarmonyPatch(typeof(LG_SecurityDoor_Locks), "SetupAsLockedNoKey")]
		[HarmonyPostfix]
		private static void SetupInteractText_LockedNoKey(LG_SecurityDoor_Locks __instance)
		{
			SharedDoorData.OverrideIntText(__instance);
		}
	}
	[HarmonyPatch]
	internal static class Patch_SecurityDoorMisc
	{
		[HarmonyPatch(typeof(LG_SecurityDoor), "SetNavInfo")]
		[HarmonyPrefix]
		private static bool SecDoor_NavInfo(LG_SecurityDoor __instance, string infoFwd, string infoBwd, List<string> infoFwdClean, List<string> infoBwdClean)
		{
			if (!SharedDoorData.TryGetCurrentCustomConfig((DoorIdentifier cfg) => cfg.SecDoorInstanceID, ((Object)__instance).GetInstanceID(), out DSDCustomization _))
			{
				return true;
			}
			__instance.m_graphics.SetNavInfoFwd(infoBwd);
			__instance.m_graphics.SetNavInfoBwd(infoFwd);
			__instance.m_terminalNavInfoForward = infoBwdClean;
			__instance.m_terminalNavInfoBackward = infoFwdClean;
			return false;
		}

		[HarmonyPatch(typeof(ChainedPuzzleManager), "CreatePuzzleInstance", new Type[]
		{
			typeof(ChainedPuzzleDataBlock),
			typeof(LG_Area),
			typeof(LG_Area),
			typeof(Vector3),
			typeof(Transform),
			typeof(bool)
		})]
		[HarmonyPrefix]
		private static void CreateChainedPuzzle(ref LG_Area sourceArea, ref LG_Area targetArea, Transform parent)
		{
			if (SharedDoorData.TryGetCurrentCustomConfig((DoorIdentifier cfg) => cfg.DoorTransformInstanceID, ((Object)parent).GetInstanceID(), out DSDCustomization custom) && custom.Flipped)
			{
				LG_Area val = sourceArea;
				LG_Area val2 = targetArea;
				targetArea = val;
				sourceArea = val2;
			}
		}

		[HarmonyPatch(typeof(LG_ZoneExpander), "GetOppositeArea")]
		[HarmonyPrefix]
		private static bool GetOppositeArea(LG_ZoneExpander __instance, ref LG_Area __result, LG_Area area)
		{
			if (SharedDoorData.OnDoorSync)
			{
				LG_Gate gate = __instance.GetGate();
				if ((Object)(object)gate != (Object)null && SharedDoorData.TryGetCurrentCustomConfig((DoorIdentifier cfg) => cfg.GateInstanceID, ((Object)gate).GetInstanceID(), out DSDCustomization custom) && custom.Flipped)
				{
					__result = area;
					return false;
				}
			}
			return true;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		private static void SetSpawnNode(LG_GenericTerminalItem __instance)
		{
			if (SharedDoorData.TryGetCurrentCustomConfig((DoorIdentifier cfg) => cfg.TerminalItemInstanceID, ((Object)__instance).GetInstanceID(), out DSDCustomization custom) && custom.Flipped)
			{
				LG_Area areaGateLinksTo = custom.Identifier.AreaGateLinksTo;
				__instance.FloorItemLocation = areaGateLinksTo.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7);
				__instance.m_spawnNode = areaGateLinksTo.m_courseNode;
			}
		}
	}
	[HarmonyPatch]
	internal static class Patch_SecurityDoorSync
	{
		private static readonly string[] _SecDisplayGraphics = new string[4] { "Security_Display_ScanActive", "Security_Display_Locked", "Security_Display_LockedAlarm", "Security_Display_UnLocked" };

		[HarmonyPatch(typeof(LG_Door_Graphics), "OnDoorState")]
		[HarmonyPrefix]
		private static void Graphic_OnDoorState(LG_Door_Graphics __instance, ref pDoorState state)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_0096: Invalid comparison between Unknown and I4
			LG_SecurityDoor val = ((Il2CppObjectBase)__instance.m_core).TryCast<LG_SecurityDoor>();
			if ((Object)(object)val == (Object)null || !SharedDoorData.TryGetCurrentCustomConfig((DoorIdentifier cfg) => cfg.SecDoorInstanceID, ((Object)val).GetInstanceID(), out DSDCustomization custom) || (int)custom.GraphicStateOverride == 0 || !((object)(eDoorStatus)(ref state.status)).ToString().Contains("Closed_LockedWith") || (int)(state.status = custom.GraphicStateOverride) != 11)
			{
				return;
			}
			string[] secDisplayGraphics = _SecDisplayGraphics;
			foreach (string text in secDisplayGraphics)
			{
				Transform val2 = ((Component)val.m_doorBladeCuller).transform.Find("securityDoor_8x4_tech/bottomDoor/" + text) ?? ((Component)val.m_doorBladeCuller).transform.Find("securityDoor_4x4_tech/rightDoor/" + text);
				if (val2 != null)
				{
					((Component)val2).gameObject.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(LG_SecurityDoor_Locks), "OnDoorState")]
		[HarmonyPostfix]
		private static void InteractText_OnDoorState(LG_SecurityDoor_Locks __instance, pDoorState state)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			if ((int)state.status != 9)
			{
				SharedDoorData.OverrideIntText(__instance);
			}
		}

		[HarmonyPatch(typeof(LG_SecurityDoor), "OnSyncDoorStatusChange")]
		[HarmonyPrefix]
		private static bool Prefix_OnSyncDoorStatusChange(LG_SecurityDoor __instance, pDoorState state)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0049: 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_0051: Invalid comparison between Unknown and I4
			//IL_0074: 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
			SharedDoorData.OnDoorSync = true;
			if (!SharedDoorData.TryGetCurrentCustomConfig((DoorIdentifier cfg) => cfg.SecDoorInstanceID, ((Object)__instance).GetInstanceID(), out DSDCustomization custom))
			{
				return true;
			}
			if ((int)state.status == 10 || (int)state.status == 16)
			{
				GameObject? rearGateInteract = custom.Identifier.RearGateInteract;
				if (rearGateInteract != null)
				{
					rearGateInteract.SetActive(false);
				}
			}
			return (int)state.status != 8 || custom.TriggerOverride.LinkTriggerTo != DoorTriggerOverride.LinkedTriggerType.Target;
		}

		[HarmonyPatch(typeof(LG_SecurityDoor), "OnSyncDoorStatusChange")]
		[HarmonyPostfix]
		private static void Postfix_OnSyncDoorStatusChange()
		{
			SharedDoorData.OnDoorSync = false;
		}
	}
}