Decompiled source of AdditionalRundownAdvancements v0.2.3

AdditionalRundownAdvancements.dll

Decompiled 2 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.Security;
using System.Security.Permissions;
using System.Text.Json;
using System.Text.Json.Serialization;
using AIGraph;
using ARA.LevelLayout;
using ARA.LevelLayout.DefinitionData;
using AmorLib.Dependencies;
using AmorLib.Utils;
using AmorLib.Utils.Extensions;
using AmorLib.Utils.JsonElementConverters;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Hook;
using FluffyUnderware.DevTools.Extensions;
using GTFO.API;
using GTFO.API.Extensions;
using GTFO.API.Utilities;
using GameData;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppInterop.Runtime.Runtime;
using Il2CppInterop.Runtime.Runtime.VersionSpecific.MethodInfo;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using LevelGeneration;
using MTFO.API;
using Microsoft.CodeAnalysis;
using Player;
using UnityEngine;
using UnityEngine.Animations;
using XXHashing;

[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("AdditionalRundownAdvancements")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+99be8d1bca5dfe32472d70cdb19ae19517d22fef")]
[assembly: AssemblyProduct("AdditionalRundownAdvancements")]
[assembly: AssemblyTitle("AdditionalRundownAdvancements")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ARA
{
	internal static class ARAJson
	{
		private static readonly JsonSerializerOptions _setting = JsonSerializerUtil.CreateDefaultSettings(true, PData_Wrapper.IsLoaded, InjectLib_Wrapper.IsLoaded);

		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);
		}
	}
	internal static class ARALogger
	{
		internal static readonly ManualLogSource MLS;

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

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

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

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

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

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

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

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

		public static void Warn(string str)
		{
			MLS.LogWarning((object)str);
		}
	}
	public abstract class CustomConfigBase
	{
		public static readonly string Module = Path.Combine(MTFOPathAPI.CustomPath, "AdditionalRundownAdvancements");

		public abstract string ModulePath { get; }

		public abstract void Setup();

		public virtual void OnBuildStart()
		{
		}

		public virtual void OnBeforeBatchBuild(BatchName batch)
		{
		}

		public virtual void OnBuildDone()
		{
		}

		public virtual void OnEnterLevel()
		{
		}

		public virtual void OnLevelCleanup()
		{
		}
	}
	public static class CustomConfigManager
	{
		public static readonly List<CustomConfigBase> CustomConfigs = new List<CustomConfigBase>();

		public static void Setup(IEnumerable<CustomConfigBase> configs)
		{
			foreach (CustomConfigBase config in configs)
			{
				CustomConfigs.Add(config);
				config.Setup();
			}
			LevelAPI.OnBuildStart += OnBuildStart;
			LevelAPI.OnBeforeBuildBatch += OnBeforeBatchBuild;
			LevelAPI.OnBuildDone += OnBuildDone;
			LevelAPI.OnEnterLevel += OnEnterLevel;
			LevelAPI.OnLevelCleanup += OnLevelCleanup;
		}

		private static void OnBuildStart()
		{
			CustomConfigs.ForEach(delegate(CustomConfigBase config)
			{
				config.OnBuildStart();
			});
		}

		private static void OnBeforeBatchBuild(BatchName batch)
		{
			//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)
			CustomConfigs.ForEach(delegate(CustomConfigBase config)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				config.OnBeforeBatchBuild(batch);
			});
		}

		private static void OnBuildDone()
		{
			CustomConfigs.ForEach(delegate(CustomConfigBase config)
			{
				config.OnBuildDone();
			});
		}

		private static void OnEnterLevel()
		{
			CustomConfigs.ForEach(delegate(CustomConfigBase config)
			{
				config.OnEnterLevel();
			});
		}

		private static void OnLevelCleanup()
		{
			CustomConfigs.ForEach(delegate(CustomConfigBase config)
			{
				config.OnLevelCleanup();
			});
		}
	}
	[BepInPlugin("Amor.ARA", "AdditionalRundownAdvancements", "0.2.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal sealed class EntryPoint : BasePlugin
	{
		public const string MODNAME = "AdditionalRundownAdvancements";

		public override void Load()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("Amor.ARA").PatchAll();
			AssetAPI.OnStartupAssetsLoaded += OnStartupAssetsLoaded;
			ARALogger.Info("ARA is done loading!");
		}

		private void OnStartupAssetsLoaded()
		{
			IEnumerable<CustomConfigBase> configs = from t in AccessTools.GetTypesFromAssembly(((object)this).GetType().Assembly)
				where typeof(CustomConfigBase).IsAssignableFrom(t) && !t.IsAbstract
				select (CustomConfigBase)Activator.CreateInstance(t);
			CustomConfigManager.Setup(configs);
		}
	}
}
namespace ARA.Patches
{
	[HarmonyPatch(typeof(ElevatorCargoCage), "SpawnObjectiveItemsInLandingArea")]
	internal static class ElevatorCargoPatches
	{
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool Pre_SpawnItems(out ElevatorCargoCustomData? __state)
		{
			if (LayoutConfigManager.Current == LayoutConfigDefinition.Empty)
			{
				__state = null;
				return true;
			}
			__state = LayoutConfigManager.Current.Elevator;
			if (__state.DisableElevatorCargo)
			{
				ElevatorRide.Current.m_cargoCageInUse = false;
				return false;
			}
			return !__state.OverrideCargoItems;
		}

		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void Post_SpawnItems(ElevatorCargoCage __instance, ElevatorCargoCustomData? __state)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected I4, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			if (__state == null || __state.CargoItems.Length == 0)
			{
				return;
			}
			if (__instance.m_itemsToMoveToCargo == null)
			{
				List<Transform> val2 = (__instance.m_itemsToMoveToCargo = new List<Transform>());
			}
			uint[] cargoItems = __state.CargoItems;
			bool flag = default(bool);
			foreach (uint num in cargoItems)
			{
				ItemDataBlock block = GameDataBlockBase<ItemDataBlock>.GetBlock(num);
				if (block == null || !((GameDataBlockBase<ItemDataBlock>)(object)block).internalEnabled)
				{
					BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Failed to find enabled ItemDataBlock ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<uint>(num);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("!");
					}
					ARALogger.Error(val3);
					continue;
				}
				LG_PickupItem val4 = LG_PickupItem.SpawnGenericPickupItem(ElevatorShaftLanding.CargoAlign);
				val4.SpawnNode = Builder.GetElevatorArea().m_courseNode;
				int num2 = Random.Range(0, int.MaxValue);
				InventorySlot inventorySlot = block.inventorySlot;
				InventorySlot val5 = inventorySlot;
				switch (val5 - 5)
				{
				case 0:
					val4.SetupAsConsumable(num2, num);
					break;
				case 1:
				case 3:
					val4.SetupAsBigPickupItem(num2, num, false, 0);
					break;
				case 2:
				case 4:
					val4.SetupAsSmallGenericPickup(num2, num, false);
					break;
				default:
				{
					BepInExWarningLogInterpolatedStringHandler val6 = new BepInExWarningLogInterpolatedStringHandler(61, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Unknown item type ");
						((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<InventorySlot>(block.inventorySlot);
						((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" for ");
						((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(((GameDataBlockBase<ItemDataBlock>)(object)block).name);
						((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" (");
						((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<uint>(num);
						((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("), attempting spawning as big pickup");
					}
					ARALogger.Warn(val6);
					val4.SetupAsBigPickupItem(num2, num, false, 0);
					break;
				}
				}
				__instance.m_itemsToMoveToCargo.Add(((Component)val4).transform);
			}
			ElevatorRide.Current.m_cargoCageInUse = true;
		}
	}
	[HarmonyPatch(typeof(LG_DistributionJobUtils), "GetRandomNodeFromZoneForFunction")]
	internal static class GeneratorClusterPatch
	{
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		public static bool ForceGeneratorClusterSpawn(ref AIG_CourseNode __result, LG_Zone zone, ExpeditionFunction func, float randomValue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			if ((int)func != 19)
			{
				return true;
			}
			if (!LayoutConfigManager.TryGetCurrentZoneData(zone, out ZoneCustomData zoneData) || !zoneData.ForceGeneratorClusterMarkers)
			{
				return true;
			}
			List<LG_Area> list = new List<LG_Area>();
			Enumerator<LG_Area> enumerator = zone.m_areas.GetEnumerator();
			while (enumerator.MoveNext())
			{
				LG_Area current = enumerator.Current;
				if (current.GetMarkerSpawnerCount((ExpeditionFunction)19) > 0)
				{
					list.Add(current);
				}
			}
			if (list.Count == 0)
			{
				return true;
			}
			int index = Math.Clamp((int)(randomValue * (float)list.Count), 0, list.Count - 1);
			bool flag = default(bool);
			BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(44, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Selected area for forced generator cluster: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(list[index].m_navInfo.m_suffix);
			}
			ARALogger.Debug(val);
			__result = list[index].m_courseNode;
			return false;
		}
	}
	[HarmonyPatch]
	internal static class WorldEventUtilsPatches
	{
		private unsafe delegate bool d_ForceSpawnMarker(IntPtr position, IntPtr rotation, IntPtr parent, uint markerBlockID, int index, ExpeditionFunction wantedFunc, out IntPtr spawnedObject, Il2CppMethodInfo* methodInfo);

		private static INativeDetour? ForceSpawnMarkerDetour;

		private static d_ForceSpawnMarker? orig_ForceSpawnMarker;

		[HarmonyPrepare]
		private unsafe static void ApplyNativePatch()
		{
			if (ForceSpawnMarkerDetour == null)
			{
				ForceSpawnMarkerDetour = CreateGenericStaticDetour<d_ForceSpawnMarker>(typeof(WorldEventUtils), "TryForceSpawnMarkerResult", typeof(bool).FullName, new string[7]
				{
					typeof(Vector3).FullName,
					typeof(Quaternion).FullName,
					typeof(Transform).FullName,
					typeof(uint).FullName,
					typeof(int).FullName,
					typeof(ExpeditionFunction).FullName,
					typeof(GameObject).MakeByRefType().FullName
				}, new Type[1] { typeof(MiningMarkerDataBlock) }, ForceSpawnMarkerPatch, out orig_ForceSpawnMarker);
			}
		}

		[HarmonyPatch(typeof(WorldEventUtils), "TrySpawnItemOnAlign")]
		[HarmonyPrefix]
		[HarmonyWrapSafe]
		private static bool Pre_TryForceSpawnItem(Transform itemAlign, out SpecificDataContainer? __state)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return !LayoutConfigManager.TryGetSpecificDataContainer(itemAlign.position, out __state);
		}

		[HarmonyPatch(typeof(WorldEventUtils), "TrySpawnItemOnAlign")]
		[HarmonyPostfix]
		[HarmonyWrapSafe]
		private static void Post_TryForceSpawnItem(ref bool __result, bool __runOriginal, uint itemID, Transform itemAlign, uint seed, ref ItemInLevel spawnedItem, SpecificDataContainer? __state)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected I4, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			SpecificDataContainer __state2 = __state;
			if (__runOriginal || __state2 == null)
			{
				return;
			}
			ItemDataBlock block = GameDataBlockBase<ItemDataBlock>.GetBlock(itemID);
			bool flag = default(bool);
			if (block == null || !((GameDataBlockBase<ItemDataBlock>)(object)block).internalEnabled)
			{
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(38, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to find enabled ItemDataBlock ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(itemID);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("!");
				}
				ARALogger.Error(val);
				return;
			}
			LG_PickupItem val2 = LG_PickupItem.SpawnGenericPickupItem(itemAlign);
			val2.SpawnNode = __state2.SpawnNode;
			int num = (int)XXHash.Hash(seed, 0u, false);
			InventorySlot inventorySlot = block.inventorySlot;
			InventorySlot val3 = inventorySlot;
			switch (val3 - 5)
			{
			case 0:
				val2.SetupAsConsumable(num, itemID);
				break;
			case 1:
			case 3:
				val2.SetupAsBigPickupItem(num, itemID, false, 0);
				break;
			case 2:
			case 4:
				val2.SetupAsSmallGenericPickup(num, itemID, false);
				break;
			default:
			{
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(38, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Unknown item type ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<InventorySlot>(block.inventorySlot);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" for ItemDataBlock ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(itemID);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("!");
				}
				ARALogger.Error(val);
				return;
			}
			}
			spawnedItem = ((Component)val2).GetComponentInChildren<ItemInLevel>();
			Queue<WardenObjectiveEventData> eData = new Queue<WardenObjectiveEventData>(__state2.EventsOnPickup);
			ItemInLevel obj = spawnedItem;
			if (obj != null)
			{
				obj.GetSyncComponent().OnSyncStateChange += Action<ePickupItemStatus, pPickupPlacement, PlayerAgent, bool>.op_Implicit((Action<ePickupItemStatus, pPickupPlacement, PlayerAgent, bool>)delegate(ePickupItemStatus status, pPickupPlacement placement, PlayerAgent _, bool isRecall)
				{
					//IL_0001: 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_0073: Unknown result type (might be due to invalid IL or missing references)
					//IL_0075: Invalid comparison between Unknown and I4
					//IL_0022: Unknown result type (might be due to invalid IL or missing references)
					//IL_0028: Expected O, but got Unknown
					if ((!placement.hasBeenPickedUp || !placement.linkedToMachine) && isRecall)
					{
						bool flag2 = default(bool);
						BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(59, 1, ref flag2);
						if (flag2)
						{
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("isRecall for SpecificDataContainer ");
							((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(__state2.WorldEventObjectFilter);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("; restore EventsOnPickup");
						}
						ARALogger.Warn(val4);
						eData = new Queue<WardenObjectiveEventData>(__state2.EventsOnPickup);
					}
					if ((int)status == 1 && !isRecall)
					{
						while (eData.Count > 0)
						{
							WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(eData.Dequeue(), (eWardenObjectiveEventTrigger)0, true, 0f);
						}
					}
				});
			}
			__result = (Object)(object)spawnedItem != (Object)null;
		}

		private unsafe static INativeDetour CreateGenericStaticDetour<TDelegate>(Type classType, string methodName, string returnType, string[] paramTypes, Type[] genericArguments, TDelegate to, out TDelegate original) where TDelegate : Delegate
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			IntPtr il2CppClass = IL2CPP.GetIl2CppClass(classType.Module.Name, string.Empty, classType.Name);
			if (il2CppClass == IntPtr.Zero)
			{
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(33, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to get class pointer for ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(methodName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("?");
				}
				ARALogger.Error(val);
				original = null;
				return null;
			}
			IntPtr il2CppMethod = IL2CPP.GetIl2CppMethod(il2CppClass, true, methodName, returnType, paramTypes);
			MethodInfo val2 = new MethodInfo(IL2CPP.il2cpp_method_get_object(il2CppMethod, il2CppClass));
			MethodInfo val3 = val2.MakeGenericMethod(((IEnumerable<Type>)genericArguments).Select((Func<Type, Type>)Il2CppType.From).ToArray());
			INativeMethodInfoStruct val4 = UnityVersionHandler.Wrap((Il2CppMethodInfo*)(void*)IL2CPP.il2cpp_method_get_from_reflection(((Il2CppObjectBase)val3).Pointer));
			return INativeDetour.CreateAndApply<TDelegate>(val4.MethodPointer, to, ref original);
		}

		private unsafe static bool ForceSpawnMarkerPatch(IntPtr position, IntPtr rotation, IntPtr parent, uint markerBlockID, int index, ExpeditionFunction wantedFunc, out IntPtr spawnedObject, Il2CppMethodInfo* methodInfo)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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)
			spawnedObject = IntPtr.Zero;
			Vector3 val = (Vector3)(*(void*)position);
			Quaternion val2 = (Quaternion)(*(void*)rotation);
			if (!LayoutConfigManager.TryGetSpecificDataContainer(val, out SpecificDataContainer container))
			{
				orig_ForceSpawnMarker(position, rotation, parent, markerBlockID, index, wantedFunc, out spawnedObject, methodInfo);
				return spawnedObject != IntPtr.Zero;
			}
			GameObject val3 = new GameObject();
			Transform val4 = new Transform(parent);
			try
			{
				string extraPrefab;
				string customPrefabs = container.GetCustomPrefabs(out extraPrefab);
				GameObject loadedAsset = AssetAPI.GetLoadedAsset<GameObject>(customPrefabs);
				val3 = GameObjectPlusExtensions.ClonePrefabSpawners(loadedAsset, val, val2, val4);
				if ((Object)(object)val3.GetComponentInChildren<LG_ComputerTerminal>() == (Object)null && !Utility.IsNullOrWhiteSpace(extraPrefab))
				{
					bool flag = false;
					foreach (LG_MarkerProducer componentsInChild in val3.GetComponentsInChildren<LG_MarkerProducer>(false))
					{
						if (!flag && HasTerminalMarker(componentsInChild.MarkerDataBlockType, componentsInChild.MarkerDataBlockID))
						{
							GameObject loadedAsset2 = AssetAPI.GetLoadedAsset<GameObject>(extraPrefab);
							val3 = GameObjectPlusExtensions.ClonePrefabSpawners(loadedAsset2, ((Component)componentsInChild).transform.position, ((Component)componentsInChild).transform.rotation, ((Component)componentsInChild).transform.parent);
							flag = true;
						}
						((Component)componentsInChild).gameObject.SetActive(false);
					}
				}
			}
			catch (Exception ex)
			{
				bool flag2 = default(bool);
				BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(73, 1, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Unable to load custom terminal prefab(s), is the correct complex loaded?\n");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<Exception>(ex);
				}
				ARALogger.Error(val5);
				orig_ForceSpawnMarker(position, rotation, parent, markerBlockID, index, wantedFunc, out spawnedObject, methodInfo);
				return spawnedObject != IntPtr.Zero;
			}
			((Object)val3).name = container.WorldEventObjectFilter;
			iLG_SpawnedInNodeHandler componentInChildren = val3.GetComponentInChildren<iLG_SpawnedInNodeHandler>();
			if (componentInChildren == null)
			{
				return false;
			}
			componentInChildren.SpawnNode = container.SpawnNode;
			spawnedObject = ((Il2CppObjectBase)val3).Pointer;
			return spawnedObject != IntPtr.Zero;
		}

		private static bool HasTerminalMarker(LG_MarkerDataBlockType type, uint id)
		{
			//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_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected I4, but got Unknown
			switch ((int)type)
			{
			case 0:
			{
				MiningMarkerDataBlock block3 = GameDataBlockBase<MiningMarkerDataBlock>.GetBlock(id);
				return block3 != null && ((GameDataBlockBase<MiningMarkerDataBlock>)(object)block3).internalEnabled && ListExtensions.ToManaged<MarkerComposition>(block3.GetCompositions()).Any((MarkerComposition comp) => (int)comp.function == 7);
			}
			case 1:
			{
				ServiceMarkerDataBlock block2 = GameDataBlockBase<ServiceMarkerDataBlock>.GetBlock(id);
				return block2 != null && ((GameDataBlockBase<ServiceMarkerDataBlock>)(object)block2).internalEnabled && ListExtensions.ToManaged<MarkerComposition>(block2.GetCompositions()).Any((MarkerComposition comp) => (int)comp.function == 7);
			}
			case 2:
			{
				TechMarkerDataBlock block = GameDataBlockBase<TechMarkerDataBlock>.GetBlock(id);
				return block != null && ((GameDataBlockBase<TechMarkerDataBlock>)(object)block).internalEnabled && ListExtensions.ToManaged<MarkerComposition>(block.GetCompositions()).Any((MarkerComposition comp) => (int)comp.function == 7);
			}
			default:
				return false;
			}
		}
	}
}
namespace ARA.LevelLayout
{
	public sealed class LayoutConfigDefinition
	{
		[JsonIgnore]
		public static readonly LayoutConfigDefinition Empty = new LayoutConfigDefinition();

		public uint MainLevelLayout { get; set; } = 0u;


		public ElevatorCargoCustomData Elevator { get; set; } = new ElevatorCargoCustomData();


		[JsonPropertyName("SetupWorldEventObjectOnAllTerminals")]
		public bool AllWorldEventTerminals { get; set; } = false;


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

	}
	public class LayoutConfigManager : CustomConfigBase
	{
		private static readonly Dictionary<string, HashSet<uint>> _filepathLayoutMap = new Dictionary<string, HashSet<uint>>();

		private static readonly Dictionary<uint, LayoutConfigDefinition> _customLayoutData = new Dictionary<uint, LayoutConfigDefinition>();

		private static readonly Dictionary<Vector3, SpecificDataContainer> _positionToContainerMap = new Dictionary<Vector3, SpecificDataContainer>();

		public static LayoutConfigDefinition Current { get; private set; } = LayoutConfigDefinition.Empty;


		public override string ModulePath => CustomConfigBase.Module + "/LevelLayout";

		public static bool TryGetCurrentZoneData(LG_Zone zone, [MaybeNullWhen(false)] out ZoneCustomData zoneData)
		{
			LG_Zone zone2 = zone;
			zoneData = Current.Zones.FirstOrDefault(delegate(ZoneCustomData z)
			{
				int result;
				if (z != null)
				{
					(int, int, int) intTuple = ((GlobalBase)z).IntTuple;
					(int, int, int) tuple = GlobalIndexUtil.ToIntTuple(zone2);
					result = ((intTuple.Item1 == tuple.Item1 && intTuple.Item2 == tuple.Item2 && intTuple.Item3 == tuple.Item3) ? 1 : 0);
				}
				else
				{
					result = 0;
				}
				return (byte)result != 0;
			}, null);
			return zoneData != null;
		}

		public static bool TryGetSpecificDataContainer(Vector3 position, [MaybeNullWhen(false)] out SpecificDataContainer container)
		{
			//IL_001a: 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)
			foreach (KeyValuePair<Vector3, SpecificDataContainer> item in _positionToContainerMap)
			{
				if (Vector3Ext.Approximately(item.Key, position))
				{
					container = item.Value;
					return true;
				}
			}
			container = null;
			return false;
		}

		public override void Setup()
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			Directory.CreateDirectory(ModulePath);
			string path = Path.Combine(ModulePath, "Template.json");
			LayoutConfigDefinition layoutConfigDefinition = new LayoutConfigDefinition();
			layoutConfigDefinition.Zones = new ZoneCustomData[1]
			{
				new ZoneCustomData()
			};
			LayoutConfigDefinition value = layoutConfigDefinition;
			File.WriteAllText(path, ARAJson.Serialize(value, typeof(LayoutConfigDefinition)));
			foreach (string item in Directory.EnumerateFiles(ModulePath, "*.json", SearchOption.AllDirectories))
			{
				string content = File.ReadAllText(item);
				ReadFileContent(item, content);
			}
			LiveEditListener val = LiveEdit.CreateListener(ModulePath, "*.json", true);
			val.FileCreated += new LiveEditEventHandler(FileCreatedOrChanged);
			val.FileChanged += new LiveEditEventHandler(FileCreatedOrChanged);
			val.FileDeleted += new LiveEditEventHandler(FileDeleted);
		}

		private static void ReadFileContent(string file, string content)
		{
			HashSet<uint> orAddNew = CollectionExtensions.GetOrAddNew<string, HashSet<uint>>((IDictionary<string, HashSet<uint>>)_filepathLayoutMap, file);
			foreach (uint item in orAddNew)
			{
				_customLayoutData.Remove(item);
			}
			orAddNew.Clear();
			LayoutConfigDefinition layoutConfigDefinition = ARAJson.Deserialize<LayoutConfigDefinition>(content);
			if (layoutConfigDefinition != null && layoutConfigDefinition.MainLevelLayout != 0)
			{
				orAddNew.Add(layoutConfigDefinition.MainLevelLayout);
				_customLayoutData[layoutConfigDefinition.MainLevelLayout] = layoutConfigDefinition;
			}
		}

		private void FileCreatedOrChanged(LiveEditEventArgs e)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			LiveEditEventArgs e2 = e;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LiveEdit file changed: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e2.FullPath);
			}
			ARALogger.Warn(val);
			LiveEdit.TryReadFileContent(e2.FullPath, (Action<string>)delegate(string content)
			{
				ReadFileContent(e2.FullPath, content);
			});
		}

		private void FileDeleted(LiveEditEventArgs e)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			LiveEditEventArgs e2 = e;
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LiveEdit file deleted: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e2.FullPath);
			}
			ARALogger.Warn(val);
			LiveEdit.TryReadFileContent(e2.FullPath, (Action<string>)delegate
			{
				foreach (uint item in _filepathLayoutMap[e2.FullPath])
				{
					_customLayoutData.Remove(item);
				}
				_filepathLayoutMap.Remove(e2.FullPath);
			});
		}

		public override void OnBuildStart()
		{
			uint levelLayoutData = RundownManager.ActiveExpedition.LevelLayoutData;
			Current = (_customLayoutData.TryGetValue(levelLayoutData, out LayoutConfigDefinition value) ? value : LayoutConfigDefinition.Empty);
			_positionToContainerMap.Clear();
		}

		public override void OnBeforeBatchBuild(BatchName batch)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if ((int)batch != 46)
			{
				return;
			}
			Dictionary<int, List<LG_WorldEventObject>> dictionary = new Dictionary<int, List<LG_WorldEventObject>>();
			foreach (LG_WorldEventObject item in Object.FindObjectsOfType<LG_WorldEventObject>())
			{
				Vector3 position = ((Component)item).transform.position;
				eDimensionIndex dimensionIndex = Dimension.GetDimensionFromPos(position).DimensionIndex;
				LG_Area area = CourseNodeUtil.GetCourseNode(position, dimensionIndex).m_area;
				CollectionExtensions.GetOrAddNew<int, List<LG_WorldEventObject>>((IDictionary<int, List<LG_WorldEventObject>>)dictionary, ((Object)area).GetInstanceID()).Add(item);
			}
			ARALogger.Debug("Applying layout data");
			Enumerator<LG_Zone> enumerator2 = Builder.CurrentFloor.allZones.GetEnumerator();
			while (enumerator2.MoveNext())
			{
				LG_Zone current2 = enumerator2.Current;
				ApplyLayoutData(current2, dictionary);
			}
		}

		public override void OnEnterLevel()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			ElevatorCargoCage val = Object.FindObjectOfType<ElevatorCargoCage>();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			foreach (ItemCuller componentsInChild in ((Component)val).GetComponentsInChildren<ItemCuller>())
			{
				componentsInChild.MoveToNode(Builder.GetElevatorArea().m_courseNode.m_cullNode, ((Component)val).transform.position);
			}
		}

		private static void ApplyLayoutData(LG_Zone zone, Dictionary<int, List<LG_WorldEventObject>> preAllocWE)
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			if (Current.AllWorldEventTerminals)
			{
				AddWorldEventToTerminals(zone);
			}
			if (!TryGetCurrentZoneData(zone, out ZoneCustomData zoneData) || (Object)(object)((GlobalBase)(zoneData?)).Zone == (Object)null)
			{
				return;
			}
			zoneData.AddSpawnPoints();
			WE_ObjectCustomData[] worldEventObjects = zoneData.WorldEventObjects;
			foreach (WE_ObjectCustomData wE_ObjectCustomData in worldEventObjects)
			{
				if (!wE_ObjectCustomData.IsAreaIndexValid(zone, out LG_Area area))
				{
					continue;
				}
				if (!wE_ObjectCustomData.UseExistingFilterInArea || !wE_ObjectCustomData.TryGetExistingFilterInArea(preAllocWE, area, out LG_WorldEventObject weObj))
				{
					weObj = ComponentExt.AddChildGameObject<LG_WorldEventObject>((Component)(object)area, wE_ObjectCustomData.WorldEventObjectFilter);
					if (wE_ObjectCustomData.UseRandomPosition)
					{
						wE_ObjectCustomData.Position = area.m_courseNode.GetRandomPositionInside();
					}
					((Component)weObj).transform.SetPositionAndRotation(wE_ObjectCustomData.Position, Quaternion.Euler(wE_ObjectCustomData.Rotation));
					((Component)weObj).transform.localScale = wE_ObjectCustomData.Scale;
					weObj.WorldEventComponents = Il2CppReferenceArray<IWorldEventComponent>.op_Implicit(Array.Empty<IWorldEventComponent>());
				}
				foreach (var (worldEventComponent2, wE_ComponentCustomData2) in wE_ObjectCustomData.Components)
				{
					switch (worldEventComponent2)
					{
					case WorldEventComponent.WE_SpecificTerminal:
						if (wE_ComponentCustomData2.PrefabOverride == TerminalPrefab.None)
						{
							break;
						}
						goto case WorldEventComponent.WE_SpecificPickup;
					case WorldEventComponent.WE_SpecificPickup:
						_positionToContainerMap[wE_ObjectCustomData.Position] = new SpecificDataContainer(wE_ObjectCustomData.WorldEventObjectFilter, area.m_courseNode, wE_ComponentCustomData2.PrefabOverride, wE_ComponentCustomData2.EventsOnPickup);
						break;
					case WorldEventComponent.WE_ChainedPuzzle:
						GameObjectPlusExtensions.AddOrGetComponent<LG_WorldEventChainPuzzle>(((Component)weObj).gameObject);
						break;
					case WorldEventComponent.WE_NavMarker:
					{
						PlaceNavMarkerOnGO val = GameObjectPlusExtensions.AddOrGetComponent<PlaceNavMarkerOnGO>(((Component)weObj).gameObject);
						val.type = wE_ComponentCustomData2.NavMarkerType;
						val.m_placeOnStart = wE_ComponentCustomData2.PlaceOnStart;
						GameObjectPlusExtensions.AddOrGetComponent<LG_WorldEventNavMarker>(((Component)weObj).gameObject);
						break;
					}
					}
				}
			}
		}

		private static void AddWorldEventToTerminals(LG_Zone zone)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected I4, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected I4, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected I4, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected I4, but got Unknown
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Expected I4, but got Unknown
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected I4, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < zone.TerminalsSpawnedInZone.Count; i++)
			{
				LG_ComputerTerminal val = zone.TerminalsSpawnedInZone[i];
				LG_MarkerProducer componentInParent = ((Component)val).GetComponentInParent<LG_MarkerProducer>();
				if (!((Object)(object)componentInParent == (Object)null))
				{
					string text = $"WE_ARA_Term_{(int)zone.DimensionIndex}_{(int)zone.Layer.m_type}_{(int)zone.LocalIndex}_{i}";
					LG_WorldEventObject val2 = ComponentExt.AddChildGameObject<LG_WorldEventObject>((Component)(object)componentInParent, text);
					((Component)val2).transform.localPosition = Vector3.zero;
					val2.WorldEventComponents = Il2CppReferenceArray<IWorldEventComponent>.op_Implicit(Array.Empty<IWorldEventComponent>());
				}
			}
			LG_WardenObjective_Reactor val3 = default(LG_WardenObjective_Reactor);
			if (GameObjectPlusExtensions.TryAndGetComponent<LG_WardenObjective_Reactor>(((Component)zone).gameObject, ref val3))
			{
				string text2 = $"WE_ARA_Term_{(int)zone.DimensionIndex}_{(int)zone.Layer.m_type}_{(int)zone.LocalIndex}_Reactor";
				Transform terminalAlign = val3.m_terminalAlign;
				LG_WorldEventObject val4 = ((terminalAlign != null) ? ComponentExt.AddChildGameObject<LG_WorldEventObject>((Component)(object)terminalAlign, text2) : null);
				if (!((Object)(object)val4 == (Object)null))
				{
					((Component)val4).transform.localPosition = Vector3.zero;
					val4.WorldEventComponents = Il2CppReferenceArray<IWorldEventComponent>.op_Implicit(Array.Empty<IWorldEventComponent>());
				}
			}
		}
	}
}
namespace ARA.LevelLayout.DefinitionData
{
	public sealed class ElevatorCargoCustomData
	{
		[JsonPropertyName("ForceDisableElevatorCargo")]
		public bool DisableElevatorCargo { get; set; } = false;


		[JsonPropertyName("OverrideDefaultElevatorCargoItems")]
		public bool OverrideCargoItems { get; set; } = false;


		[JsonPropertyName("CustomElevatorCargoItems")]
		public uint[] CargoItems { get; set; } = Array.Empty<uint>();

	}
	public enum TerminalPrefab
	{
		None,
		Default,
		MiningCover,
		MiniTerminal,
		DataCenterCube,
		ServiceCover,
		CyberDeck,
		GardensCover,
		GardensShelf
	}
	public sealed class SpecificDataContainer
	{
		private const string DefaultPrefab = "Assets/AssetPrefabs/Complex/Generic/FunctionMarkers/Terminal_Floor.prefab";

		private static readonly Dictionary<TerminalPrefab, (string Prefab, string? Extra)> _prefabMap = new Dictionary<TerminalPrefab, (string, string)>
		{
			[TerminalPrefab.MiningCover] = ("Assets/AssetPrefabs/Complex/Mining/SubMarkers/Props/submarker_mining_cover_120x120x240/submarker_mining_cover_120x120x240_Terminal_t.prefab", null),
			[TerminalPrefab.MiniTerminal] = ("Assets/AssetPrefabs/Complex/Generic/FunctionMarkers/Terminal_Mini.prefab", null),
			[TerminalPrefab.ServiceCover] = ("Assets/AssetPrefabs/Complex/Service/MarkerCompositions/Floodways_terminal_wall_120x120x240/Floodways_terminal_wall_120x120x240_01.prefab", null),
			[TerminalPrefab.CyberDeck] = ("Assets/AssetPrefabs/Complex/Generic/FunctionMarkers/Terminal_CyberDeck.prefab", null),
			[TerminalPrefab.DataCenterCube] = ("Assets/AssetPrefabs/Complex/Tech/Markers/MarkerCompositions/DataCenter_submarker_240x240x400/DataCenter_submarker_240x240x400_V01_terminal.prefab", "Assets/AssetPrefabs/Complex/Generic/FunctionMarkers/Terminal_Mini.prefab"),
			[TerminalPrefab.GardensCover] = ("Assets/AssetPrefabs/Complex/Service/MarkerCompositions/Gardens_Concrete_Submarker_Station_180x180x240/Gardens_Concrete_Submarker_Station_180x180x240_V02.prefab", "Assets/AssetPrefabs/Complex/Service/MarkerCompositions/Gardens_concrete_terminal_locker_200x300x50/Gardens_concrete_terminal_locker_200x300x50.prefab"),
			[TerminalPrefab.GardensShelf] = ("Assets/AssetPrefabs/Complex/Service/MarkerCompositions/Gardens_Concrete_Submarker_Station_180x180x240/Gardens_Concrete_Submarker_Station_180x180x240_V03.prefab", "Assets/AssetPrefabs/Complex/Generic/FunctionMarkers/Terminal_Mini.prefab")
		};

		public string WorldEventObjectFilter;

		public AIG_CourseNode SpawnNode;

		public TerminalPrefab TerminalPrefabOverride;

		public List<WardenObjectiveEventData> EventsOnPickup;

		public SpecificDataContainer(string filter, AIG_CourseNode node, TerminalPrefab prefabType, List<WardenObjectiveEventData> events)
		{
			WorldEventObjectFilter = filter;
			SpawnNode = node;
			TerminalPrefabOverride = prefabType;
			EventsOnPickup = events;
		}

		public string GetCustomPrefabs(out string? extraPrefab)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			if (_prefabMap.TryGetValue(TerminalPrefabOverride, out (string, string) value))
			{
				extraPrefab = value.Item2;
				return value.Item1;
			}
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(59, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Invalid PrefabOverride \"");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<TerminalPrefab>(TerminalPrefabOverride);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" for filter ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(WorldEventObjectFilter);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", using default prefab");
			}
			ARALogger.Warn(val);
			extraPrefab = null;
			return "Assets/AssetPrefabs/Complex/Generic/FunctionMarkers/Terminal_Floor.prefab";
		}
	}
	public enum WorldEventComponent
	{
		None,
		WE_ChainedPuzzle,
		WE_NavMarker,
		WE_CollisionTrigger,
		WE_LookatTrigger,
		WE_InteractTrigger,
		WE_SpecificTerminal,
		WE_SpecificPickup
	}
	public enum ColliderType
	{
		Box,
		Sphere,
		Capsule
	}
	public sealed class WE_ComponentCustomData
	{
		public TerminalPrefab PrefabOverride { get; set; } = TerminalPrefab.None;


		public List<WardenObjectiveEventData> EventsOnPickup { get; set; } = new List<WardenObjectiveEventData>();


		public eMarkerType NavMarkerType { get; set; } = (eMarkerType)1;


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


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


		public ColliderType ColliderType { get; set; } = ColliderType.Box;


		public Vector3 Center { get; set; } = Vector3.zero;


		public Vector3 Size { get; set; } = Vector3.one;


		public float Radius { get; set; } = 0f;


		public float Height { get; set; } = 0f;


		public Axis Direction { get; set; } = (Axis)0;


		public float LookatMaxDistance { get; set; } = 0f;


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


		public eCarryItemInsertTargetType CarryItemInsertType { get; set; } = (eCarryItemInsertTargetType)0;


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

	}
	public sealed class WE_ObjectCustomData
	{
		public string WorldEventObjectFilter { get; set; } = string.Empty;


		public int AreaIndex { get; set; } = 0;


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


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


		public Vector3 Position { get; set; } = Vector3.zero;


		public Vector3 Rotation { get; set; } = Vector3.zero;


		public Vector3 Scale { get; set; } = Vector3.one;


		public Dictionary<WorldEventComponent, WE_ComponentCustomData> Components { get; set; } = new Dictionary<WorldEventComponent, WE_ComponentCustomData>();


		public bool IsAreaIndexValid(LG_Zone zone, [MaybeNullWhen(false)] out LG_Area area)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			if (AreaIndex >= 0 && AreaIndex < zone.m_areas.Count)
			{
				area = zone.m_areas[AreaIndex];
				return true;
			}
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(31, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Invalid AreaIndex ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(AreaIndex);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" for filter ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(WorldEventObjectFilter);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("!");
			}
			ARALogger.Error(val);
			area = null;
			return false;
		}

		public bool TryGetExistingFilterInArea(Dictionary<int, List<LG_WorldEventObject>> preAllocWE, LG_Area area, [MaybeNullWhen(false)] out LG_WorldEventObject weObj)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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)
			weObj = ((IEnumerable<LG_WorldEventObject>)CollectionExtensions.GetOrAddNew<int, List<LG_WorldEventObject>>((IDictionary<int, List<LG_WorldEventObject>>)preAllocWE, ((Object)area).GetInstanceID())).FirstOrDefault((Func<LG_WorldEventObject, bool>)((LG_WorldEventObject we) => we.WorldEventObjectKey == WorldEventObjectFilter));
			if ((Object)(object)weObj == (Object)null)
			{
				return false;
			}
			Position = ((Component)weObj).transform.position;
			if (Rotation != Vector3.zero)
			{
				((Component)weObj).transform.rotation = Quaternion.Euler(Rotation);
			}
			if (Scale != Vector3.one)
			{
				((Component)weObj).transform.localScale = Scale;
			}
			return true;
		}
	}
	public sealed class ZoneCustomData : GlobalBase
	{
		public Vector3[] HibernateSpawnAligns { get; set; } = Array.Empty<Vector3>();


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


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


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


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


		public void AddSpawnPoints()
		{
			AddSpawnPoints("HSA", HibernateSpawnAligns, (LG_Area area) => area.m_spawnAligns);
			AddSpawnPoints("ESP", EnemySpawnPoints, (LG_Area area) => area.m_enemySpawnPoints);
			AddSpawnPoints("SBP", BioscanSpawnPoints, (LG_Area area) => area.m_bioscanSpawnPoints);
		}

		private void AddSpawnPoints(string source, Vector3[] positions, Func<LG_Area, List<Transform>> targetList)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < positions.Length; i++)
			{
				Vector3 val = positions[i];
				LG_Area area = CourseNodeUtil.GetCourseNode(val, ((GlobalBase)this).DimensionIndex).m_area;
				if (!((Object)(object)area == (Object)null))
				{
					string text = "ARA_" + source + "_SpawnPoint";
					if (i > 0)
					{
						text += $" ({i})";
					}
					GameObject val2 = new GameObject(text);
					val2.transform.SetPositionAndRotation(val, Quaternion.identity);
					val2.transform.SetParent(((Component)area).transform, true);
					targetList(area).Add(val2.transform);
				}
			}
		}
	}
}