Decompiled source of Quixotic v1.2.4

Plugins/Quixotic/DoubleSidedDoors.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Text.RegularExpressions;
using AIGraph;
using API;
using Agents;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using ChainedPuzzles;
using DoubleSidedDoors.BepInEx;
using DoubleSidedDoors.Patches;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using MTFO.API;
using Microsoft.CodeAnalysis;
using Player;
using UnityEngine;
using UnityEngine.Analytics;

[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("DoubleSidedDoors")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+76539a66fae8702cc9087365273644ce33224c06")]
[assembly: AssemblyProduct("DoubleSidedDoors")]
[assembly: AssemblyTitle("DoubleSidedDoors")]
[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 API
{
	[HarmonyPatch(typeof(GameDataInit))]
	internal class GameDataInit_Patches
	{
		[HarmonyPatch("Initialize")]
		[HarmonyWrapSafe]
		[HarmonyPostfix]
		public static void Initialize_Postfix()
		{
			Analytics.enabled = false;
		}
	}
	internal static class APILogger
	{
		private static readonly ManualLogSource logger;

		static APILogger()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			logger = new ManualLogSource("Rand-API");
			Logger.Sources.Add((ILogSource)(object)logger);
		}

		private static string Format(string module, object msg)
		{
			return $"[{module}]: {msg}";
		}

		public static void Info(string module, object data)
		{
			logger.LogMessage((object)Format(module, data));
		}

		public static void Verbose(string module, object data)
		{
			logger.LogDebug((object)Format(module, data));
		}

		public static void Log(object data)
		{
			logger.LogDebug((object)Format("DoubleSidedDoors", data));
		}

		public static void Debug(object data, bool force = false)
		{
			if (ConfigManager.Debug || force)
			{
				Log(data);
			}
		}

		public static void Warn(object data)
		{
			logger.LogWarning((object)Format("DoubleSidedDoors", data));
		}

		public static void Error(object data)
		{
			logger.LogError((object)Format("DoubleSidedDoors", data));
		}
	}
}
namespace DoubleSidedDoors
{
	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
			};
		}

		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);
		}
	}
	public sealed class LayoutConfig
	{
		public uint LevelLayoutID { get; set; }

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


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


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


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


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


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

	}
	public sealed class BindDoorToPlayer
	{
		public int Slot { get; set; }

		public DoorIdentifier? Door { get; set; }
	}
	public sealed class DoorIdentifier
	{
		public int To { get; set; }

		public int From { get; set; } = -1;


		public string Text { get; set; } = "<color=red>BI-DIRECTIONAL ACCESS DISABLED</color>";


		public string State { get; set; } = "";

	}
	public sealed class DoorMessageOverride
	{
		public DoorIdentifier? Door { get; set; }

		public string Message { get; set; } = string.Empty;

	}
	public sealed class DoorTriggerOverride
	{
		public DoorIdentifier? Door { get; set; }

		public DoorIdentifier? Target { get; set; }

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

	}
}
namespace DoubleSidedDoors.Patches
{
	[HarmonyPatch]
	internal static class Spawn
	{
		public static Dictionary<uint, LayoutConfig> data = new Dictionary<uint, LayoutConfig>();

		public static Dictionary<int, Dictionary<int, LG_SecurityDoor>> doors = new Dictionary<int, Dictionary<int, LG_SecurityDoor>>();

		private static HashSet<int> reversedSecDoors = new HashSet<int>();

		private static Dictionary<int, GameObject> reversedGates = new Dictionary<int, GameObject>();

		private static Dictionary<int, LG_Area> reversedGenericTerminalItem = new Dictionary<int, LG_Area>();

		private static bool onDoorSync = false;

		private static Dictionary<int, HashSet<LG_SecurityDoor>> boundDoors = new Dictionary<int, HashSet<LG_SecurityDoor>>();

		private static bool IsTargetReachable(AIG_CourseNode source, AIG_CourseNode target)
		{
			//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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Invalid comparison between Unknown and I4
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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)
					{
						DefaultInterpolatedStringHandler defaultInterpolatedStringHandler = new DefaultInterpolatedStringHandler(16, 2);
						defaultInterpolatedStringHandler.AppendLiteral("SecurityDoor ");
						defaultInterpolatedStringHandler.AppendFormatted(val2.m_serialNumber);
						defaultInterpolatedStringHandler.AppendLiteral(" - ");
						eDoorStatus lastStatus = val2.LastStatus;
						defaultInterpolatedStringHandler.AppendFormatted(((object)(eDoorStatus)(ref lastStatus)).ToString());
						APILogger.Debug(defaultInterpolatedStringHandler.ToStringAndClear());
						if ((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(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_00de: 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_00e5: 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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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;
			for (int i = 0; i < availableSpawnPointsBetweenElevatorAndNode.Count; i++)
			{
				ScoredSpawnPoint val4 = availableSpawnPointsBetweenElevatorAndNode[i];
				Vector3 val5 = val4.firstCoursePortal.Position - position;
				val5.y = 0f;
				((Vector3)(ref val5)).Normalize();
				val4.m_dir = val5;
				val4.totalCost = Mathf.Clamp01(Vector3.Dot(val5, normalized));
				if (val4.pathHeat > num - 0.01f)
				{
					val4.totalCost += 1f + (1f - Mathf.Clamp(val4.pathHeat - num, 0f, num2) / num2);
				}
				if (val3 == null)
				{
					val3 = val4;
				}
				else if (val4.totalCost > val3.totalCost)
				{
					val3 = val4;
				}
			}
			if (val3.courseNode == null)
			{
				val3.courseNode = val;
			}
			__result = val3;
			return false;
		}

		[HarmonyPatch(typeof(LG_SecurityDoor), "Setup")]
		[HarmonyPostfix]
		private static void SecurityDoor_Setup(LG_SecurityDoor __instance, LG_Gate gate)
		{
			int alias = ((LG_ZoneExpander)gate).m_linksFrom.m_zone.Alias;
			int alias2 = ((LG_ZoneExpander)gate).m_linksTo.m_zone.Alias;
			if (!doors.ContainsKey(alias))
			{
				doors.Add(alias, new Dictionary<int, LG_SecurityDoor>());
			}
			doors[alias].Add(alias2, __instance);
		}

		private static uint GetLayoutIdOfZone(LG_Zone zone)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected I4, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Dimension dimension = zone.Dimension;
			if (dimension.IsMainDimension)
			{
				LG_LayerType type = zone.Layer.m_type;
				ExpeditionInTierData activeExpedition = RundownManager.ActiveExpedition;
				return (int)type switch
				{
					0 => activeExpedition.LevelLayoutData, 
					1 => activeExpedition.SecondaryLayout, 
					2 => activeExpedition.ThirdLayout, 
					_ => throw new NotSupportedException($"LayerType: {type} is not supported!"), 
				};
			}
			return dimension.DimensionData.LevelLayoutData;
		}

		private static bool reverse(uint layerId, int fromAlias, int toAlias)
		{
			bool flag = false;
			if (data.ContainsKey(layerId))
			{
				flag = data[layerId].Doors.Any((DoorIdentifier d) => d.To == toAlias && (d.From == -1 || d.From == fromAlias));
			}
			APILogger.Debug($"layerId: {layerId}, fromAlias: {fromAlias}, toAlias: {toAlias} -> {(flag ? "reversed" : "not reversed")}");
			return flag;
		}

		private static bool doubleHandle(uint layerId, int fromAlias, int toAlias)
		{
			bool flag = false;
			if (data.ContainsKey(layerId))
			{
				flag = data[layerId].AddHandle.Any((DoorIdentifier d) => d.To == toAlias && (d.From == -1 || d.From == fromAlias));
			}
			APILogger.Debug($"layerId: {layerId}, fromAlias: {fromAlias}, toAlias: {toAlias} -> {(flag ? "doubleHandle" : "not doubleHandle")}");
			return flag;
		}

		private static bool graphic(uint layerId, int fromAlias, int toAlias)
		{
			bool flag = false;
			if (data.ContainsKey(layerId))
			{
				flag = data[layerId].DoorLockedGraphicOverrides.Any((DoorIdentifier d) => d.To == toAlias && (d.From == -1 || d.From == fromAlias));
			}
			APILogger.Debug($"layerId: {layerId}, fromAlias: {fromAlias}, toAlias: {toAlias} -> {(flag ? "override handle light" : "leave handle light")}");
			return flag;
		}

		private static bool overrideMessage(uint layerId, int fromAlias, int toAlias)
		{
			bool flag = false;
			if (data.ContainsKey(layerId))
			{
				flag = data[layerId].DoorMessageOverrides.Any((DoorMessageOverride d) => d.Door != null && d.Door.To == toAlias && (d.Door.From == -1 || d.Door.From == fromAlias));
			}
			APILogger.Debug($"layerId: {layerId}, fromAlias: {fromAlias}, toAlias: {toAlias} -> {(flag ? "override message" : "not overridden")}");
			return flag;
		}

		private static bool overrideTrigger(uint layerId, int fromAlias, int toAlias)
		{
			bool flag = false;
			if (data.ContainsKey(layerId))
			{
				flag = data[layerId].DoorOverrideTrigger.Any((DoorTriggerOverride d) => d.Door != null && d.Door.To == toAlias && (d.Door.From == -1 || d.Door.From == fromAlias));
			}
			APILogger.Debug($"layerId: {layerId}, fromAlias: {fromAlias}, toAlias: {toAlias} -> {(flag ? "override trigger" : "not trigger")}");
			return flag;
		}

		private static bool overrideTriggerOG(uint layerId, int fromAlias, int toAlias)
		{
			bool flag = false;
			if (data.ContainsKey(layerId))
			{
				flag = data[layerId].DoorOverrideTrigger.Any((DoorTriggerOverride d) => d.Target != null && d.Target.To == toAlias && (d.Target.From == -1 || d.Target.From == fromAlias));
			}
			APILogger.Debug($"layerId: {layerId}, fromAlias: {fromAlias}, toAlias: {toAlias} -> {(flag ? "OG trigger" : "not OG trigger")}");
			return flag;
		}

		[HarmonyPatch(typeof(LG_SecurityDoor), "OnSyncDoorStatusChange")]
		[HarmonyPrefix]
		private static void OnSyncDoorStatusChangeOG(LG_SecurityDoor __instance, pDoorState state)
		{
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Invalid comparison between Unknown and I4
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Invalid comparison between Unknown and I4
			//IL_01df: 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_01e7: Invalid comparison between Unknown and I4
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Invalid comparison between Unknown and I4
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Invalid comparison between Unknown and I4
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Invalid comparison between Unknown and I4
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Invalid comparison between Unknown and I4
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			uint layoutIdOfZone = GetLayoutIdOfZone(((LG_ZoneExpander)__instance.Gate).m_linksFrom.m_zone);
			int fromAlias = ((LG_ZoneExpander)__instance.Gate).m_linksFrom.m_zone.Alias;
			int toAlias = ((LG_ZoneExpander)__instance.Gate).m_linksTo.m_zone.Alias;
			if (!overrideTriggerOG(layoutIdOfZone, fromAlias, toAlias))
			{
				return;
			}
			DoorTriggerOverride doorTriggerOverride = data[layoutIdOfZone].DoorOverrideTrigger.First((DoorTriggerOverride d) => d.Target != null && d.Target.To == toAlias && (d.Target.From == -1 || d.Target.From == fromAlias));
			if (!doorTriggerOverride.OpenOnTarget)
			{
				if ((int)state.status == 8 && doorTriggerOverride.Door != null && (doorTriggerOverride.Door.From != fromAlias || doorTriggerOverride.Door.To != toAlias) && doors.ContainsKey(doorTriggerOverride.Door.From) && doors[doorTriggerOverride.Door.From].ContainsKey(doorTriggerOverride.Door.To))
				{
					LG_SecurityDoor linkedDoor = doors[doorTriggerOverride.Door.From][doorTriggerOverride.Door.To];
					linkedDoor.m_sync.AttemptDoorInteraction((eDoorInteractionType)4, 0f, 0f, default(Vector3), (Agent)null);
					__instance.m_locks.OnChainedPuzzleSolved += Action.op_Implicit((Action)delegate
					{
						//IL_001a: 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_0029: Unknown result type (might be due to invalid IL or missing references)
						//IL_002a: 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_0049: 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_0081: Unknown result type (might be due to invalid IL or missing references)
						//IL_0087: Unknown result type (might be due to invalid IL or missing references)
						linkedDoor.m_locks.ChainedPuzzleToSolve.AttemptInteract((eChainedPuzzleInteraction)1);
						pDoorState val5 = default(pDoorState);
						val5.status = (eDoorStatus)9;
						pDoorState val6 = val5;
						linkedDoor.m_graphics.OnDoorState(val6, false);
						linkedDoor.m_anim.OnDoorState(val6, false);
						linkedDoor.m_locks.OnDoorState(val6, false);
						((Il2CppObjectBase)linkedDoor.m_sync).Cast<LG_Door_Sync>().AttemptDoorInteraction((eDoorInteractionType)5, 0f, 0f, default(Vector3), (Agent)null);
					});
				}
			}
			else if (((int)state.status == 10 || (int)state.status == 9 || (int)state.status == 8) && doorTriggerOverride.Door != null && (doorTriggerOverride.Door.From != fromAlias || doorTriggerOverride.Door.To != toAlias) && doors.ContainsKey(doorTriggerOverride.Door.From) && doors[doorTriggerOverride.Door.From].ContainsKey(doorTriggerOverride.Door.To))
			{
				LG_SecurityDoor val = doors[doorTriggerOverride.Door.From][doorTriggerOverride.Door.To];
				if ((int)state.status == 10)
				{
					val.m_sync.AttemptDoorInteraction((eDoorInteractionType)0, 0f, 0f, default(Vector3), (Agent)null);
				}
				else if ((int)state.status == 9)
				{
					pDoorState val2 = default(pDoorState);
					val2.status = (eDoorStatus)9;
					pDoorState val3 = val2;
					val.m_graphics.OnDoorState(val3, false);
					val.m_anim.OnDoorState(val3, false);
				}
				else if ((int)state.status == 8)
				{
					pDoorState val2 = default(pDoorState);
					val2.status = (eDoorStatus)8;
					pDoorState val4 = val2;
					val.m_graphics.OnDoorState(val4, false);
					val.m_anim.OnDoorState(val4, false);
				}
			}
		}

		[HarmonyPatch(typeof(LG_Door_Graphics), "OnDoorState")]
		[HarmonyPrefix]
		private static void Graphic_OnDoorState(LG_Door_Graphics __instance, ref pDoorState state)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Invalid comparison between Unknown and I4
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Invalid comparison between Unknown and I4
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Invalid comparison between Unknown and I4
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Invalid comparison between Unknown and I4
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Invalid comparison between Unknown and I4
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0134: Invalid comparison between Unknown and I4
			LG_SecurityDoor val = ((Il2CppObjectBase)__instance.m_core).TryCast<LG_SecurityDoor>();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			uint layoutIdOfZone = GetLayoutIdOfZone(((LG_ZoneExpander)val.Gate).m_linksFrom.m_zone);
			int fromAlias = ((LG_ZoneExpander)val.Gate).m_linksFrom.m_zone.Alias;
			int toAlias = ((LG_ZoneExpander)val.Gate).m_linksTo.m_zone.Alias;
			if (!graphic(layoutIdOfZone, fromAlias, toAlias) || ((int)state.status != 5 && (int)state.status != 4 && (int)state.status != 7 && (int)state.status != 6 && (int)state.status != 15 && (int)state.status != 3))
			{
				return;
			}
			DoorIdentifier doorIdentifier = data[layoutIdOfZone].DoorLockedGraphicOverrides.First((DoorIdentifier d) => d.To == toAlias && (d.From == -1 || d.From == fromAlias));
			if (!(doorIdentifier.State != string.Empty) || !Enum.TryParse<eDoorStatus>(doorIdentifier.State, ignoreCase: true, out eDoorStatus result))
			{
				return;
			}
			state.status = result;
			if ((int)result == 11)
			{
				Transform val2 = ((Component)val.m_doorBladeCuller).transform.Find("securityDoor_8x4_tech/bottomDoor/Security_Display_ScanActive");
				if ((Object)(object)val2 == (Object)null)
				{
					((Component)val.m_doorBladeCuller).transform.Find("securityDoor_4x4_tech/rightDoor/Security_Display_ScanActive");
				}
				if ((Object)(object)val2 != (Object)null)
				{
					((Component)val2).gameObject.SetActive(false);
				}
				Transform val3 = ((Component)val.m_doorBladeCuller).transform.Find("securityDoor_8x4_tech/bottomDoor/Security_Display_Locked");
				if ((Object)(object)val3 == (Object)null)
				{
					((Component)val.m_doorBladeCuller).transform.Find("securityDoor_4x4_tech/rightDoor/Security_Display_Locked");
				}
				if ((Object)(object)val3 != (Object)null)
				{
					((Component)val3).gameObject.SetActive(false);
				}
				Transform val4 = ((Component)val.m_doorBladeCuller).transform.Find("securityDoor_8x4_tech/bottomDoor/Security_Display_LockedAlarm");
				if ((Object)(object)val4 == (Object)null)
				{
					((Component)val.m_doorBladeCuller).transform.Find("securityDoor_4x4_tech/rightDoor/Security_Display_LockedAlarm");
				}
				if ((Object)(object)val4 != (Object)null)
				{
					((Component)val4).gameObject.SetActive(false);
				}
				Transform val5 = ((Component)val.m_doorBladeCuller).transform.Find("securityDoor_8x4_tech/bottomDoor/Security_Display_UnLocked");
				if ((Object)(object)val5 == (Object)null)
				{
					((Component)val.m_doorBladeCuller).transform.Find("securityDoor_4x4_tech/rightDoor/Security_Display_UnLocked");
				}
				if ((Object)(object)val5 != (Object)null)
				{
					((Component)val5).gameObject.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(LG_SecurityDoor), "OnSyncDoorStatusChange")]
		[HarmonyPrefix]
		private static bool OnSyncDoorStatusChange(LG_SecurityDoor __instance, pDoorState state)
		{
			//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
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			uint layoutIdOfZone = GetLayoutIdOfZone(((LG_ZoneExpander)__instance.Gate).m_linksFrom.m_zone);
			int fromAlias = ((LG_ZoneExpander)__instance.Gate).m_linksFrom.m_zone.Alias;
			int toAlias = ((LG_ZoneExpander)__instance.Gate).m_linksTo.m_zone.Alias;
			if (!overrideTrigger(layoutIdOfZone, fromAlias, toAlias))
			{
				return true;
			}
			if ((int)state.status != 8)
			{
				return true;
			}
			DoorTriggerOverride doorTriggerOverride = data[layoutIdOfZone].DoorOverrideTrigger.First((DoorTriggerOverride d) => d.Door != null && d.Door.To == toAlias && (d.Door.From == -1 || d.Door.From == fromAlias));
			if (doorTriggerOverride.Target != null && (doorTriggerOverride.Target.From != fromAlias || doorTriggerOverride.Target.To != toAlias) && doors.ContainsKey(doorTriggerOverride.Target.From) && doors[doorTriggerOverride.Target.From].ContainsKey(doorTriggerOverride.Target.To))
			{
				__instance.m_graphics.OnDoorState(state, false);
				__instance.m_anim.OnDoorState(state, false);
				LG_SecurityDoor_Locks val = ((Il2CppObjectBase)__instance.m_locks).Cast<LG_SecurityDoor_Locks>();
				((Interact_Base)val.m_intUseKeyItem).SetActive(false);
				((Interact_Base)val.m_intOpenDoor).SetActive(false);
				((Interact_Base)val.m_intHack).SetActive(false);
				((Interact_Base)val.m_intCustomMessage).SetActive(false);
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(LG_SecurityDoor), "OnSyncDoorStatusChange")]
		[HarmonyPrefix]
		private static void OnSyncDoorStatusChange_Reverse(LG_SecurityDoor __instance, pDoorState state)
		{
			//IL_0056: 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)
			//IL_005e: Invalid comparison between Unknown and I4
			uint layoutIdOfZone = GetLayoutIdOfZone(((LG_ZoneExpander)__instance.Gate).m_linksFrom.m_zone);
			int alias = ((LG_ZoneExpander)__instance.Gate).m_linksFrom.m_zone.Alias;
			int alias2 = ((LG_ZoneExpander)__instance.Gate).m_linksTo.m_zone.Alias;
			if (reverse(layoutIdOfZone, alias, alias2) && (int)state.status == 10)
			{
				int instanceID = ((Object)__instance.Gate).GetInstanceID();
				if (reversedGates.ContainsKey(instanceID))
				{
					reversedGates[instanceID].SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(LG_Door_Sync), "AttemptInteract")]
		[HarmonyPrefix]
		private static void AttemptInteract(LG_Door_Sync __instance, pDoorInteraction interaction)
		{
			//IL_0091: 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_0098: Invalid comparison between Unknown and I4
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			LG_SecurityDoor val = ((Il2CppObjectBase)__instance.m_core).TryCast<LG_SecurityDoor>();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			uint layoutIdOfZone = GetLayoutIdOfZone(((LG_ZoneExpander)val.Gate).m_linksFrom.m_zone);
			int fromAlias = ((LG_ZoneExpander)val.Gate).m_linksFrom.m_zone.Alias;
			int toAlias = ((LG_ZoneExpander)val.Gate).m_linksTo.m_zone.Alias;
			if (overrideTrigger(layoutIdOfZone, fromAlias, toAlias) && (int)interaction.type == 4)
			{
				DoorTriggerOverride doorTriggerOverride = data[layoutIdOfZone].DoorOverrideTrigger.First((DoorTriggerOverride d) => d.Door != null && d.Door.To == toAlias && (d.Door.From == -1 || d.Door.From == fromAlias));
				if (doorTriggerOverride.Target != null && (doorTriggerOverride.Target.From != fromAlias || doorTriggerOverride.Target.To != toAlias) && doors.ContainsKey(doorTriggerOverride.Target.From) && doors[doorTriggerOverride.Target.From].ContainsKey(doorTriggerOverride.Target.To))
				{
					LG_SecurityDoor val2 = doors[doorTriggerOverride.Target.From][doorTriggerOverride.Target.To];
					val2.m_sync.AttemptDoorInteraction((eDoorInteractionType)4, 0f, 0f, default(Vector3), (Agent)null);
				}
			}
		}

		[HarmonyPatch(typeof(ElevatorRide), "StartElevatorRide")]
		[HarmonyPostfix]
		private static void StartElevatorRide()
		{
			reversedSecDoors.Clear();
			reversedGates.Clear();
			reversedGenericTerminalItem.Clear();
			doors.Clear();
			boundDoors.Clear();
		}

		[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(ChainedPuzzleDataBlock data, ref LG_Area sourceArea, ref LG_Area targetArea, Vector3 sourcePos, Transform parent, bool overrideUseStaticBioscanPoints)
		{
			if (reversedSecDoors.Contains(((Object)parent).GetInstanceID()))
			{
				LG_Area val = sourceArea;
				sourceArea = targetArea;
				targetArea = val;
			}
		}

		[HarmonyPatch(typeof(LG_SecurityDoor), "OnSyncDoorStatusChange")]
		[HarmonyPrefix]
		private static void Prefix_OnSyncDoorStatusChange()
		{
			onDoorSync = true;
		}

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

		[HarmonyPatch(typeof(LG_SecurityDoor_Locks), "OnDoorState")]
		[HarmonyPostfix]
		private static void Postfix_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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			eDoorStatus status = state.status;
			eDoorStatus val = status;
			if ((int)val != 9)
			{
				_overrideText(__instance);
			}
		}

		[HarmonyPatch(typeof(LG_SecurityDoor_Locks), "SetupAsLockedNoKey")]
		[HarmonyPostfix]
		private static void Postfix_OnDoorState(LG_SecurityDoor_Locks __instance)
		{
			_overrideText(__instance);
		}

		private static void _overrideText(LG_SecurityDoor_Locks __instance)
		{
			uint layoutIdOfZone = GetLayoutIdOfZone(((LG_ZoneExpander)__instance.m_door.Gate).m_linksFrom.m_zone);
			int fromAlias = ((LG_ZoneExpander)__instance.m_door.Gate).m_linksFrom.m_zone.Alias;
			int toAlias = ((LG_ZoneExpander)__instance.m_door.Gate).m_linksTo.m_zone.Alias;
			if (overrideMessage(layoutIdOfZone, fromAlias, toAlias))
			{
				DoorMessageOverride doorMessageOverride = data[layoutIdOfZone].DoorMessageOverrides.First((DoorMessageOverride d) => d.Door != null && d.Door.To == toAlias && (d.Door.From == -1 || d.Door.From == fromAlias));
				string text = Regex.Replace(doorMessageOverride.Message, "\\[DOOR\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*\\)\\]", delegate(Match m)
				{
					int num = int.Parse(m.Groups[1].Value);
					int num2 = int.Parse(m.Groups[2].Value);
					return (doors.ContainsKey(num) && doors[num].ContainsKey(num2)) ? $"SEC_DOOR_{doors[num][num2].m_serialNumber}" : $"DEBUG_FROM({num})_TO({num2})";
				});
				__instance.m_intOpenDoor.InteractionMessage = text;
				((Interact_Timed)__instance.m_intUseKeyItem).InteractionMessage = text;
				((Interact_Timed)__instance.m_intHack).InteractionMessage = text;
				__instance.m_intCustomMessage.m_message = text;
			}
		}

		[HarmonyPatch(typeof(LG_ZoneExpander), "GetOppositeArea")]
		[HarmonyPrefix]
		private static bool GetOppositeArea(LG_ZoneExpander __instance, ref LG_Area __result, LG_Area area)
		{
			if (onDoorSync)
			{
				LG_Gate gate = __instance.GetGate();
				if ((Object)(object)gate == (Object)null)
				{
					return true;
				}
				if (reversedGates.ContainsKey(((Object)gate).GetInstanceID()))
				{
					__result = area;
					return false;
				}
			}
			return true;
		}

		[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 (!reverse(GetLayoutIdOfZone(((LG_ZoneExpander)__instance.Gate).m_linksFrom.m_zone), ((LG_ZoneExpander)__instance.Gate).m_linksFrom.m_zone.Alias, ((LG_ZoneExpander)__instance.Gate).m_linksTo.m_zone.Alias))
			{
				return true;
			}
			__instance.m_graphics.SetNavInfoFwd(infoBwd);
			__instance.m_graphics.SetNavInfoBwd(infoFwd);
			__instance.m_terminalNavInfoForward = infoBwdClean;
			__instance.m_terminalNavInfoBackward = infoFwdClean;
			return false;
		}

		[HarmonyPatch(typeof(WardenObjectiveManager), "CheckExpeditionFailed")]
		[HarmonyPostfix]
		private static void CheckExpeditionFailed(WardenObjectiveManager __instance, ref bool __result)
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Invalid comparison between Unknown and I4
			if (__result)
			{
				return;
			}
			for (int i = 0; i < PlayerManager.PlayerAgentsInLevel.Count; i++)
			{
				PlayerAgent val = PlayerManager.PlayerAgentsInLevel[i];
				if (((Agent)val).Alive || !boundDoors.ContainsKey(val.PlayerSlotIndex))
				{
					continue;
				}
				bool flag = true;
				foreach (LG_SecurityDoor item in boundDoors[val.PlayerSlotIndex])
				{
					APILogger.Debug($"{val.PlayerSlotIndex} -> {((LG_ZoneExpander)item.Gate).m_linksTo.m_zone.Alias} {item.LastStatus}");
					if ((int)item.LastStatus != 10)
					{
						flag = false;
						break;
					}
				}
				if (!flag)
				{
					APILogger.Debug($"{val.PlayerSlotIndex} -> end run");
					__result = true;
					break;
				}
			}
		}

		private static bool bind(uint layerId, int fromAlias, int toAlias, out List<int> slots)
		{
			slots = new List<int>();
			bool flag = false;
			if (data.ContainsKey(layerId))
			{
				BindDoorToPlayer[] bindDoorToPlayer = data[layerId].BindDoorToPlayer;
				foreach (BindDoorToPlayer bindDoorToPlayer2 in bindDoorToPlayer)
				{
					DoorIdentifier door = bindDoorToPlayer2.Door;
					if (door != null && door.To == toAlias && (door.From == -1 || door.From == fromAlias))
					{
						slots.Add(bindDoorToPlayer2.Slot);
						flag = true;
					}
				}
			}
			APILogger.Debug($"layerId: {layerId}, fromAlias: {fromAlias}, toAlias: {toAlias} -> {(flag ? "bound" : "not bound")}");
			return flag;
		}

		[HarmonyPatch(typeof(LG_SecurityDoor), "Setup")]
		[HarmonyPostfix]
		private static void SecDoor_Setup(LG_SecurityDoor __instance, LG_Gate gate)
		{
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: 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_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			LG_Gate gate2 = gate;
			if (bind(GetLayoutIdOfZone(((LG_ZoneExpander)gate2).m_linksFrom.m_zone), ((LG_ZoneExpander)gate2).m_linksFrom.m_zone.Alias, ((LG_ZoneExpander)gate2).m_linksTo.m_zone.Alias, out List<int> slots))
			{
				foreach (int item in slots)
				{
					if (!boundDoors.ContainsKey(item))
					{
						boundDoors.Add(item, new HashSet<LG_SecurityDoor>());
					}
					boundDoors[item].Add(__instance);
				}
			}
			bool flag = reverse(GetLayoutIdOfZone(((LG_ZoneExpander)gate2).m_linksFrom.m_zone), ((LG_ZoneExpander)gate2).m_linksFrom.m_zone.Alias, ((LG_ZoneExpander)gate2).m_linksTo.m_zone.Alias);
			bool flag2 = doubleHandle(GetLayoutIdOfZone(((LG_ZoneExpander)gate2).m_linksFrom.m_zone), ((LG_ZoneExpander)gate2).m_linksFrom.m_zone.Alias, ((LG_ZoneExpander)gate2).m_linksTo.m_zone.Alias);
			if (!flag && !flag2)
			{
				return;
			}
			Transform val = ((Component)__instance).transform.Find("crossing");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (flag)
			{
				val.localRotation *= Quaternion.Euler(0f, 180f, 0f);
			}
			Transform val2 = ((Component)__instance.m_doorBladeCuller).transform.Find("securityDoor_8x4_tech/bottomDoor/g_securityDoor_bottomDoor_capback");
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = ((Component)__instance.m_doorBladeCuller).transform.Find("securityDoor_4x4_tech (1)/rightDoor/g_securityDoor_bottomDoor_capback001");
				if ((Object)(object)val2 == (Object)null)
				{
					return;
				}
			}
			((Component)val2).gameObject.SetActive(false);
			Transform val3 = ((Component)__instance.m_doorBladeCuller).transform.Find("securityDoor_8x4_tech/bottomDoor/InteractionInterface");
			bool flag3 = false;
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = ((Component)__instance.m_doorBladeCuller).transform.Find("securityDoor_4x4_tech (1)/rightDoor/InteractionInterface");
				flag3 = true;
				if ((Object)(object)val3 == (Object)null)
				{
					return;
				}
			}
			GameObject val4 = Object.Instantiate<GameObject>(((Component)val3).gameObject, val3.parent);
			val4.transform.localRotation = val3.localRotation * Quaternion.Euler(180f, 180f, 0f);
			if (flag3)
			{
				val4.transform.localPosition = val3.localPosition + new Vector3(0f, 0.28f, 0f);
			}
			else
			{
				val4.transform.localPosition = val3.localPosition + new Vector3(0f, 0f, -0.25f);
			}
			Transform val5 = ((Component)__instance).transform.Find("crossing/Interaction_Message");
			if ((Object)(object)val5 == (Object)null)
			{
				return;
			}
			GameObject val6 = Object.Instantiate<GameObject>(((Component)val5).gameObject, val5.parent);
			val6.transform.position = val4.transform.position;
			Interact_MessageOnScreen component = val6.GetComponent<Interact_MessageOnScreen>();
			component.MessageType = (eMessageOnScreenType)1;
			if (flag)
			{
				component.m_message = data[GetLayoutIdOfZone(((LG_ZoneExpander)gate2).m_linksFrom.m_zone)].Doors.First((DoorIdentifier d) => d.To == ((LG_ZoneExpander)gate2).m_linksTo.m_zone.Alias && (d.From == -1 || d.From == ((LG_ZoneExpander)gate2).m_linksFrom.m_zone.Alias)).Text;
			}
			else if (flag2)
			{
				component.m_message = data[GetLayoutIdOfZone(((LG_ZoneExpander)gate2).m_linksFrom.m_zone)].AddHandle.First((DoorIdentifier d) => d.To == ((LG_ZoneExpander)gate2).m_linksTo.m_zone.Alias && (d.From == -1 || d.From == ((LG_ZoneExpander)gate2).m_linksFrom.m_zone.Alias)).Text;
			}
			else
			{
				component.m_message = "@randomuserhi YOU DON FUCKED UP!";
			}
			val6.SetActive(true);
			((Interact_Base)component).SetActive(true);
			reversedSecDoors.Add(((Object)((Component)__instance).transform).GetInstanceID());
			reversedGates.Add(((Object)gate2).GetInstanceID(), val6);
			reversedGenericTerminalItem.Add(((Object)((Il2CppObjectBase)__instance.m_terminalItem).Cast<LG_GenericTerminalItem>()).GetInstanceID(), ((LG_ZoneExpander)gate2).m_linksTo);
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPostfix]
		private static void Postfix_Set_SpawnNode(LG_GenericTerminalItem __instance)
		{
			int instanceID = ((Object)__instance).GetInstanceID();
			if (reversedGenericTerminalItem.ContainsKey(instanceID))
			{
				LG_Area val = reversedGenericTerminalItem[instanceID];
				__instance.FloorItemLocation = val.m_zone.NavInfo.GetFormattedText((LG_NavInfoFormat)7);
				__instance.m_spawnNode = val.m_courseNode;
			}
		}
	}
}
namespace DoubleSidedDoors.BepInEx
{
	public static class Module
	{
		public const string GUID = "randomuserhi.DoubleSidedDoors";

		public const string Name = "DoubleSidedDoors";

		public const string Version = "0.0.1";
	}
	public static class ConfigManager
	{
		public static ConfigFile configFile;

		private static ConfigEntry<bool> debug;

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

		static ConfigManager()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			string text = Path.Combine(Paths.ConfigPath, "DoubleSidedDoors.cfg");
			configFile = new ConfigFile(text, true);
			debug = configFile.Bind<bool>("Debug", "enable", false, "Enables debug messages when true.");
			DirectoryInfo directoryInfo = Directory.CreateDirectory(Path.Combine(MTFOPathAPI.CustomPath, "DoubleSidedDoors"));
			FileInfo[] files = directoryInfo.GetFiles();
			APILogger.Debug("Searching: " + directoryInfo.FullName, force: true);
			FileInfo[] array = files;
			foreach (FileInfo fileInfo in array)
			{
				APILogger.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));
					if (Spawn.data.ContainsKey(layoutConfig.LevelLayoutID))
					{
						APILogger.Error($"Duplicated ID found!: {fileInfo.Name}, {layoutConfig.LevelLayoutID}");
					}
					else
					{
						Spawn.data.Add(layoutConfig.LevelLayoutID, layoutConfig);
					}
				}
			}
		}
	}
	[BepInPlugin("randomuserhi.DoubleSidedDoors", "DoubleSidedDoors", "0.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BasePlugin
	{
		private static Harmony? harmony;

		public override void Load()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			APILogger.Log("Plugin is loaded!");
			harmony = new Harmony("randomuserhi.DoubleSidedDoors");
			harmony.PatchAll();
			APILogger.Log("Debug is " + (ConfigManager.Debug ? "Enabled" : "Disabled"));
		}
	}
}

Plugins/Quixotic/Inas07.ThermalSights.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json.Serialization;
using AssetShards;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using ChainedPuzzles;
using ExtraObjectiveSetup.BaseClasses;
using ExtraObjectiveSetup.Expedition.Gears;
using ExtraObjectiveSetup.Utils;
using FirstPersonItem;
using GTFO.API;
using GTFO.API.Utilities;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using ThermalSights.Definition;
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.ThermalSights")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Inas07.ThermalSights")]
[assembly: AssemblyTitle("Inas07.ThermalSights")]
[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 ThermalSights
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Inas.ThermalSights", "ThermalSights", "1.0.0")]
	public class EntryPoint : BasePlugin
	{
		public const string AUTHOR = "Inas";

		public const string PLUGIN_NAME = "ThermalSights";

		public const string VERSION = "1.0.0";

		private Harmony m_Harmony;

		public override void Load()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			SetupManagers();
			m_Harmony = new Harmony("ThermalSights");
			m_Harmony.PatchAll();
			EOSLogger.Log("ThermalSights loaded.");
		}

		private void SetupManagers()
		{
			AssetShardManager.OnStartupAssetsLoaded += Action.op_Implicit((Action)delegate
			{
				((GenericDefinitionManager<TSADefinition>)TSAManager.Current).Init();
			});
		}
	}
	public class TSAManager : GenericDefinitionManager<TSADefinition>
	{
		public class PuzzleVisualWrapper
		{
			public GameObject GO { get; set; }

			public Renderer Renderer { get; set; }

			public float Intensity { get; set; }

			public float BehindWallIntensity { get; set; }

			public void SetIntensity(float t)
			{
				if (GO.active)
				{
					if (Intensity > 0f)
					{
						Renderer.material.SetFloat("_Intensity", Intensity * t);
					}
					if (BehindWallIntensity > 0f)
					{
						Renderer.material.SetFloat("_BehindWallIntensity", BehindWallIntensity * t);
					}
				}
			}
		}

		private const bool OUTPUT_THERMAL_SHADER_SETTINGS_ON_WIELD = false;

		public static TSAManager Current { get; }

		protected override string DEFINITION_NAME => "ThermalSight";

		private Dictionary<uint, Renderer[]> InLevelGearThermals { get; } = new Dictionary<uint, Renderer[]>();


		private HashSet<uint> ModifiedInLevelGearThermals { get; } = new HashSet<uint>();


		private HashSet<uint> ThermalOfflineGears { get; } = new HashSet<uint>();


		public uint CurrentGearPID { get; private set; }

		private List<PuzzleVisualWrapper> PuzzleVisuals { get; } = new List<PuzzleVisualWrapper>();


		protected override void FileChanged(LiveEditEventArgs e)
		{
			base.FileChanged(e);
			InitThermalOfflineGears();
			CleanupInLevelGearThermals(keepCurrentGear: true);
			TrySetThermalSightRenderer(CurrentGearPID);
		}

		public override void Init()
		{
			InitThermalOfflineGears();
		}

		private void InitThermalOfflineGears()
		{
			ThermalOfflineGears.Clear();
			foreach (PlayerOfflineGearDataBlock allBlock in GameDataBlockBase<PlayerOfflineGearDataBlock>.GetAllBlocks())
			{
				if (((GameDataBlockBase<PlayerOfflineGearDataBlock>)(object)allBlock).name.ToLowerInvariant().EndsWith("_t"))
				{
					ThermalOfflineGears.Add(((GameDataBlockBase<PlayerOfflineGearDataBlock>)(object)allBlock).persistentID);
				}
			}
			EOSLogger.Debug($"Found OfflineGear with thermal sight, count: {ThermalOfflineGears.Count}");
		}

		private bool TryGetInLevelGearThermalRenderersFromItem(ItemEquippable item, uint gearPID, out Renderer[] renderers)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			renderers = null;
			if (item.GearIDRange == null)
			{
				return false;
			}
			if (gearPID == 0)
			{
				gearPID = ExpeditionGearManager.GetOfflineGearPID(item.GearIDRange);
			}
			if (gearPID == 0 || !IsGearWithThermal(gearPID))
			{
				return false;
			}
			bool flag = false;
			if (!InLevelGearThermals.ContainsKey(gearPID))
			{
				flag = true;
			}
			else
			{
				try
				{
					_ = ((Component)InLevelGearThermals[gearPID][0]).gameObject.transform.position;
					flag = false;
				}
				catch
				{
					ModifiedInLevelGearThermals.Remove(gearPID);
					flag = true;
				}
			}
			if (flag)
			{
				renderers = (from x in ((IEnumerable<Renderer>)((Component)item).GetComponentsInChildren<Renderer>(true))?.Where((Renderer x) => (Object)(object)x.sharedMaterial != (Object)null && (Object)(object)x.sharedMaterial.shader != (Object)null)
					where ((Object)x.sharedMaterial.shader).name.ToLower().Contains("Thermal".ToLower())
					select x).ToArray() ?? null;
				if (renderers != null)
				{
					if (renderers.Length != 1)
					{
						EOSLogger.Warning(((Item)item).PublicName + " contains more than 1 thermal renderers!");
					}
					InLevelGearThermals[gearPID] = renderers;
					return true;
				}
				EOSLogger.Debug(((Item)item).PublicName + ": thermal renderer not found");
				return false;
			}
			renderers = InLevelGearThermals[gearPID];
			return true;
		}

		internal bool TrySetThermalSightRenderer(uint gearPID = 0u)
		{
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Expected O, but got Unknown
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			if (gearPID == 0)
			{
				gearPID = CurrentGearPID;
			}
			if (!IsGearWithThermal(gearPID))
			{
				return false;
			}
			if (ModifiedInLevelGearThermals.Contains(gearPID))
			{
				return true;
			}
			if (base.definitions.TryGetValue(gearPID, out var value) && InLevelGearThermals.TryGetValue(gearPID, out var value2))
			{
				TSShader shader = value.Definition.Shader;
				Renderer[] array = value2;
				foreach (Renderer val in array)
				{
					PropertyInfo[] properties = shader.GetType().GetProperties();
					foreach (PropertyInfo propertyInfo in properties)
					{
						Type type = Nullable.GetUnderlyingType(propertyInfo.PropertyType) ?? propertyInfo.PropertyType;
						string text = "_" + propertyInfo.Name;
						if (type == typeof(float))
						{
							val.material.SetFloat(text, (float)propertyInfo.GetValue(shader));
						}
						else if (type == typeof(EOSColor))
						{
							EOSColor val2 = (EOSColor)propertyInfo.GetValue(shader);
							val.material.SetVector(text, Color.op_Implicit(val2.ToUnityColor()));
						}
						else if (type == typeof(bool))
						{
							bool flag = (bool)propertyInfo.GetValue(shader);
							val.material.SetFloat(text, flag ? 1f : 0f);
						}
						else if (type == typeof(Vec4))
						{
							Vec4 val3 = (Vec4)propertyInfo.GetValue(shader);
							val.material.SetVector(text, val3.ToVector4());
						}
					}
				}
				ModifiedInLevelGearThermals.Add(gearPID);
				return true;
			}
			return false;
		}

		internal void OnPlayerItemWielded(FirstPersonItemHolder fpsItemHolder, ItemEquippable item)
		{
			if (item.GearIDRange == null)
			{
				CurrentGearPID = 0u;
				return;
			}
			CurrentGearPID = ExpeditionGearManager.GetOfflineGearPID(item.GearIDRange);
			TryGetInLevelGearThermalRenderersFromItem(item, CurrentGearPID, out var _);
			TrySetThermalSightRenderer(CurrentGearPID);
		}

		public bool IsGearWithThermal(uint gearPID)
		{
			return ThermalOfflineGears.Contains(gearPID);
		}

		private void CleanupInLevelGearThermals(bool keepCurrentGear = false)
		{
			if (!keepCurrentGear || !InLevelGearThermals.ContainsKey(CurrentGearPID))
			{
				InLevelGearThermals.Clear();
			}
			else
			{
				Renderer[] value = InLevelGearThermals[CurrentGearPID];
				InLevelGearThermals.Clear();
				InLevelGearThermals[CurrentGearPID] = value;
			}
			ModifiedInLevelGearThermals.Clear();
		}

		internal void SetCurrentThermalSightSettings(float t)
		{
			if (InLevelGearThermals.TryGetValue(CurrentGearPID, out var value) && base.definitions.TryGetValue(CurrentGearPID, out var value2))
			{
				Renderer[] array = value;
				foreach (Renderer obj in array)
				{
					float zoom = value2.Definition.Shader.Zoom;
					float offAimPixelZoom = value2.Definition.OffAimPixelZoom;
					float num = Mathf.Lerp(zoom, offAimPixelZoom, t);
					obj.material.SetFloat("_Zoom", num);
				}
			}
		}

		private void Clear()
		{
			CurrentGearPID = 0u;
			CleanupInLevelGearThermals();
			CleanupPuzzleVisuals();
		}

		private TSAManager()
		{
			LevelAPI.OnBuildStart += Clear;
			LevelAPI.OnLevelCleanup += Clear;
		}

		static TSAManager()
		{
			Current = new TSAManager();
		}

		public void RegisterPuzzleVisual(CP_Bioscan_Core core)
		{
			Il2CppArrayBase<Renderer> componentsInChildren = ((Component)core).gameObject.GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren == null)
			{
				return;
			}
			foreach (Renderer item2 in ((IEnumerable<Renderer>)componentsInChildren).Where((Renderer comp) => ((Object)((Component)comp).gameObject).name.Equals("Zone")).ToList())
			{
				GameObject gameObject = ((Component)item2).gameObject;
				float @float = item2.material.GetFloat("_Intensity");
				float float2 = item2.material.GetFloat("_BehindWallIntensity");
				PuzzleVisualWrapper item = new PuzzleVisualWrapper
				{
					GO = gameObject,
					Renderer = item2,
					Intensity = @float,
					BehindWallIntensity = float2
				};
				PuzzleVisuals.Add(item);
			}
		}

		public void RegisterPuzzleVisual(PuzzleVisualWrapper wrapper)
		{
			PuzzleVisuals.Add(wrapper);
		}

		internal void SetPuzzleVisualsIntensity(float t)
		{
			PuzzleVisuals.ForEach(delegate(PuzzleVisualWrapper v)
			{
				v.SetIntensity(t);
			});
		}

		private void CleanupPuzzleVisuals()
		{
			PuzzleVisuals.Clear();
		}
	}
}
namespace ThermalSights.Patches
{
	internal static class CP_Bioscan_Core_Setup
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(CP_Bioscan_Core), "Setup")]
		private static void Post_CaptureBioscanVisual(CP_Bioscan_Core __instance)
		{
			TSAManager.Current.RegisterPuzzleVisual(__instance);
		}
	}
	[HarmonyPatch]
	internal static class FirstPersonItemHolder_SetWieldedItem
	{
		public static event Action<FirstPersonItemHolder, ItemEquippable> OnItemWielded;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(FirstPersonItemHolder), "SetWieldedItem")]
		private static void Post_SetWieldedItem(FirstPersonItemHolder __instance, ItemEquippable item)
		{
			TSAManager.Current.OnPlayerItemWielded(__instance, item);
			TSAManager.Current.SetPuzzleVisualsIntensity(1f);
			TSAManager.Current.SetCurrentThermalSightSettings(1f);
			FirstPersonItemHolder_SetWieldedItem.OnItemWielded?.Invoke(__instance, item);
		}
	}
	[HarmonyPatch]
	internal static class FPIS_Aim_Update
	{
		public static event Action<FPIS_Aim, float> OnAimUpdate;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(FPIS_Aim), "Update")]
		private static void Post_Aim_Update(FPIS_Aim __instance)
		{
			if (!((Object)(object)((FPItemState)__instance).Holder.WieldedItem == (Object)null))
			{
				float num = 1f - FirstPersonItemHolder.m_transitionDelta;
				if (!TSAManager.Current.IsGearWithThermal(TSAManager.Current.CurrentGearPID))
				{
					num = Math.Max(0.05f, num);
				}
				else
				{
					TSAManager.Current.SetCurrentThermalSightSettings(num);
				}
				TSAManager.Current.SetPuzzleVisualsIntensity(num);
				FPIS_Aim_Update.OnAimUpdate?.Invoke(__instance, num);
			}
		}
	}
}
namespace ThermalSights.Definition
{
	public class TSADefinition
	{
		public float OffAimPixelZoom { get; set; } = 1f;


		public TSShader Shader { get; set; } = new TSShader();

	}
	public class TSShader
	{
		[JsonPropertyName("DistanceFalloff")]
		[Range(0.0, 1.0)]
		public float HeatFalloff { get; set; } = 0.01f;


		[Range(0.0, 1.0)]
		public float FogFalloff { get; set; } = 0.1f;


		[JsonPropertyName("PixelZoom")]
		[Range(0.0, 1.0)]
		public float Zoom { get; set; } = 0.8f;


		[JsonPropertyName("AspectRatioAdjust")]
		[Range(0.0, 2.0)]
		public float RatioAdjust { get; set; } = 1f;


		[Range(0.0, 1.0)]
		public float DistortionCenter { get; set; } = 0.5f;


		public float DistortionScale { get; set; } = 1f;


		public float DistortionSpeed { get; set; } = 1f;


		public float DistortionSignalSpeed { get; set; } = 0.025f;


		[Range(0.0, 1.0)]
		public float DistortionMin { get; set; } = 0.01f;


		[Range(0.0, 1.0)]
		public float DistortionMax { get; set; } = 0.4f;


		[JsonPropertyName("AmbientTemperature")]
		[Range(0.0, 1.0)]
		public float AmbientTemp { get; set; } = 0.15f;


		[JsonPropertyName("BackgroundTemperature")]
		[Range(0.0, 1.0)]
		public float BackgroundTemp { get; set; } = 0.05f;


		[Range(0.0, 10.0)]
		public float AlbedoColorFactor { get; set; } = 0.5f;


		[Range(0.0, 10.0)]
		public float AmbientColorFactor { get; set; } = 5f;


		public float OcclusionHeat { get; set; } = 0.5f;


		public float BodyOcclusionHeat { get; set; } = 2.5f;


		[Range(0.0, 1.0)]
		public float ScreenIntensity { get; set; } = 0.2f;


		[Range(0.0, 1.0)]
		public float OffAngleFade { get; set; } = 0.95f;


		[Range(0.0, 1.0)]
		public float Noise { get; set; } = 0.1f;


		[JsonPropertyName("MinShadowEnemyDistortion")]
		[Range(0.0, 1.0)]
		public float DistortionMinShadowEnemies { get; set; } = 0.2f;


		[JsonPropertyName("MaxShadowEnemyDistortion")]
		[Range(0.0, 1.0)]
		public float DistortionMaxShadowEnemies { get; set; } = 1f;


		[Range(0.0, 1.0)]
		public float DistortionSignalSpeedShadowEnemies { get; set; } = 1f;


		public float ShadowEnemyFresnel { get; set; } = 10f;


		[Range(0.0, 1.0)]
		public float ShadowEnemyHeat { get; set; } = 0.1f;


		public EOSColor ReticuleColorA { get; set; } = new EOSColor
		{
			r = 1f,
			g = 1f,
			b = 1f,
			a = 1f
		};


		public EOSColor ReticuleColorB { get; set; } = new EOSColor
		{
			r = 1f,
			g = 1f,
			b = 1f,
			a = 1f
		};


		public EOSColor ReticuleColorC { get; set; } = new EOSColor
		{
			r = 1f,
			g = 1f,
			b = 1f,
			a = 1f
		};


		[Range(0.0, 20.0)]
		public float SightDirt { get; set; }

		public bool LitGlass { get; set; }

		public bool ClipBorders { get; set; } = true;


		public Vec4 AxisX { get; set; } = new Vec4();


		public Vec4 AxisY { get; set; } = new Vec4();


		public Vec4 AxisZ { get; set; } = new Vec4();


		public bool Flip { get; set; } = true;


		[JsonPropertyName("Distance1")]
		[Range(0.0, 100.0)]
		public float ProjDist1 { get; set; } = 100f;


		[JsonPropertyName("Distance2")]
		[Range(0.0, 100.0)]
		public float ProjDist2 { get; set; } = 66f;


		[JsonPropertyName("Distance3")]
		[Range(0.0, 100.0)]
		public float ProjDist3 { get; set; } = 33f;


		[JsonPropertyName("Size1")]
		[Range(0.0, 3.0)]
		public float ProjSize1 { get; set; } = 1f;


		[JsonPropertyName("Size2")]
		[Range(0.0, 3.0)]
		public float ProjSize2 { get; set; } = 1f;


		[JsonPropertyName("Size3")]
		[Range(0.0, 3.0)]
		public float ProjSize3 { get; set; } = 1f;


		[JsonPropertyName("Zeroing")]
		[Range(-1.0, 1.0)]
		public float ZeroOffset { get; set; }
	}
}

Plugins/Quixotic/QuixoticPlugin.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using CellMenu;
using GameData;
using HarmonyLib;
using Il2CppSystem;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using TMPro;
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("QuixoticPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("QuixoticPlugin")]
[assembly: AssemblyTitle("QuixoticPlugin")]
[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 QuixoticPlugin
{
	[HarmonyPatch(typeof(LG_ComputerTerminalCommandInterpreter), "DisableAlarmsCommand")]
	internal class DX_DeactivateAlarms
	{
		public static bool Prefix(LG_ComputerTerminalCommandInterpreter __instance)
		{
			if (RundownManager.Current.m_activeExpedition.LevelLayoutData != 7810)
			{
				return true;
			}
			__instance.AddOutput((TerminalLineType)3, "Executing alarm-shutdown protocol...", 3f, (TerminalSoundType)0, (TerminalSoundType)0);
			__instance.AddOutput((TerminalLineType)0, "Connecting to active alarm systems", 1f, (TerminalSoundType)0, (TerminalSoundType)0);
			__instance.AddOutput((TerminalLineType)0, "Confirming valid terminal ID", 2.4f, (TerminalSoundType)0, (TerminalSoundType)0);
			__instance.AddOutput((TerminalLineType)2, "Shutting down alarms...", 3f, (TerminalSoundType)0, (TerminalSoundType)0);
			ElevatorShaftLanding.StopAmbientAlarm();
			__instance.AddOutput((TerminalLineType)0, "Alarms linked to this terminal successfully shut down.", 1f, (TerminalSoundType)0, (TerminalSoundType)0);
			__instance.AddOutput((TerminalLineType)0, "<color=red>://ERROR!</color> High tiered alarm <color=orange>CmDx1e4rL1</color> failed to deactivate.", 1.3f, (TerminalSoundType)0, (TerminalSoundType)0);
			CoroutineManager.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(ClearHud()), (Action)null);
			return false;
		}

		private static IEnumerator ClearHud()
		{
			yield return (object)new WaitForSeconds(9.4f);
			GuiManager.PlayerLayer.m_objectiveTimer.SetTimerActive(false, true);
		}
	}
	[HarmonyPatch]
	internal class FixBPUDistribution
	{
		[HarmonyPatch(typeof(RundownManager), "SetActiveExpedition")]
		[HarmonyPostfix]
		public static void SetActiveExp(ref pActiveExpedition expPackage)
		{
			EntryPoint.Seed = expPackage.sessionSeed;
		}

		[HarmonyPatch(typeof(LG_PickupItem), "SetupAsBigPickupItem", new Type[]
		{
			typeof(int),
			typeof(BigPickupDistributionDataBlock),
			typeof(bool),
			typeof(int)
		})]
		[HarmonyPrefix]
		public static bool SpawnPatch(LG_PickupItem __instance, ref BigPickupDistributionDataBlock data, ref bool isWardenObjectiveItem, ref int objectiveChainIndex)
		{
			__instance.SetupCommon();
			uint itemID = data.SpawnData[EntryPoint.Seed % data.SpawnsPerZone].ItemID;
			__instance.SetupBigPickupItemWithItemId(itemID, isWardenObjectiveItem, objectiveChainIndex);
			Debug.Log(Object.op_Implicit(Deb.Purple($"SetupAsBigPickupItem, spawning item with id: {itemID}, isWardenObjectiveItem: {isWardenObjectiveItem}", 0f)));
			EntryPoint.Seed++;
			return false;
		}
	}
	[HarmonyPatch]
	internal class RemoveArtifactHeat
	{
		[HarmonyPatch(typeof(CM_ExpeditionIcon_New), "SetArtifactHeat")]
		[HarmonyPostfix]
		public static void HideRundownHeat(CM_ExpeditionIcon_New __instance)
		{
			//IL_001e: 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)
			__instance.HideArtifactHeat();
			__instance.m_statusText.transform.SetPositionAndRotation(__instance.m_artifactHeatText.transform.position, __instance.m_artifactHeatText.transform.rotation);
		}

		[HarmonyPatch(typeof(CM_MenuBar), "SetExpIconArtifactHeat")]
		[HarmonyPrefix]
		public static bool ReplaceMenuBarHeat(CM_MenuBar __instance)
		{
			TextMeshPro publicName = __instance.m_expIcon.m_publicName;
			((Component)publicName).gameObject.SetActive(true);
			((TMP_Text)publicName).autoSizeTextContainer = true;
			((TMP_Text)publicName).fontSizeMax = 60f;
			((TMP_Text)publicName).fontSize = 60f;
			return false;
		}

		[HarmonyPatch(typeof(CM_PageExpeditionSuccess), "OnEnable")]
		[HarmonyPostfix]
		public static void YeetSuccessScreenHeat(CM_PageExpeditionSuccess __instance)
		{
			//IL_001b: 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)
			((Component)__instance.m_ArtifactInventoryDisplay).transform.localPosition = new Vector3(99999f, 99999f, 99999f);
			__instance.m_artifactInfo_text.transform.localPosition = new Vector3(99999f, 99999f, 99999f);
		}

		[HarmonyPatch(typeof(CM_PageExpeditionFail), "OnEnable")]
		[HarmonyPostfix]
		public static void YeetDefeatScreenHeat(CM_PageExpeditionFail __instance)
		{
			//IL_001b: 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)
			((Component)__instance.m_ArtifactInventoryDisplay).transform.localPosition = new Vector3(99999f, 99999f, 99999f);
			__instance.m_artifactInfo_text.transform.localPosition = new Vector3(99999f, 99999f, 99999f);
		}

		[HarmonyPatch(typeof(CM_ExpeditionWindow), "SetExpeditionInfo")]
		[HarmonyPostfix]
		public static void PopupHeat(CM_ExpeditionWindow __instance)
		{
			((TMP_Text)__instance.m_artifactHeatTitle).text = Text.Get(42u);
		}
	}
	[BepInPlugin("Amor.QTP", "QuixoticPlugin", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class EntryPoint : BasePlugin
	{
		public static ManualLogSource? LogSource { get; private set; }

		public static int Seed { get; set; }

		public override void Load()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			LogSource = ((BasePlugin)this).Log;
			new Harmony("_QT").PatchAll();
			((BasePlugin)this).Log.LogMessage((object)"QuixoticPlugin is now loaded!");
		}
	}
}