Decompiled source of AdditionalRundownAdvancements v0.5.1

AdditionalRundownAdvancements.dll

Decompiled 3 days 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 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 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+17216d9784816f593db9e6d93d1f37b7c70e323a")]
[assembly: AssemblyProduct("AdditionalRundownAdvancements")]
[assembly: AssemblyTitle("AdditionalRundownAdvancements")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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 += config.OnBuildStart;
				LevelAPI.OnBeforeBuildBatch += config.OnBeforeBatchBuild;
				LevelAPI.OnBuildDone += config.OnBuildDone;
				LevelAPI.OnEnterLevel += config.OnEnterLevel;
				LevelAPI.OnLevelCleanup += config.OnLevelCleanup;
			}
		}
	}
	[BepInPlugin("Amor.ARA", "AdditionalRundownAdvancements", "0.5.1")]
	[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> val = (__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)
			if (__runOriginal || __state == 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 = __state.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>(__state.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>(__state.WorldEventObjectFilter);
							((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("; restore EventsOnPickup");
						}
						ARALogger.Warn(val4);
						eData = new Queue<WardenObjectiveEventData>(__state.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 sealed 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>();

		private static readonly Dictionary<string, IntPtr> _currentARAFilters = new Dictionary<string, IntPtr>();

		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)
		{
			List<ZoneCustomData> list = Current.Zones.Where(delegate(ZoneCustomData zData)
			{
				int result;
				if (zData != null)
				{
					(int, int, int) intTuple = ((GlobalBase)zData).IntTuple;
					(int, int, int) tuple = GlobalIndexUtil.ToIntTuple(zone);
					result = ((intTuple.Item1 == tuple.Item1 && intTuple.Item2 == tuple.Item2 && intTuple.Item3 == tuple.Item3) ? 1 : 0);
				}
				else
				{
					result = 0;
				}
				return (byte)result != 0;
			}).ToList();
			zoneData = list.Count switch
			{
				0 => null, 
				1 => list[0], 
				_ => new ZoneCustomData
				{
					HibernateSpawnAligns = list.SelectMany((ZoneCustomData zData) => zData.HibernateSpawnAligns).ToArray(),
					EnemySpawnPoints = list.SelectMany((ZoneCustomData zData) => zData.EnemySpawnPoints).ToArray(),
					BioscanSpawnPoints = list.SelectMany((ZoneCustomData zData) => zData.BioscanSpawnPoints).ToArray(),
					ForceGeneratorClusterMarkers = list.Any((ZoneCustomData zData) => zData.ForceGeneratorClusterMarkers),
					WorldEventObjects = list.SelectMany((ZoneCustomData zData) => zData.WorldEventObjects).ToArray()
				}, 
			};
			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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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)));
			bool flag = default(bool);
			foreach (string item in Directory.EnumerateFiles(ModulePath, "*.json", SearchOption.AllDirectories))
			{
				try
				{
					string content = File.ReadAllText(item);
					ReadFileContent(item, content);
				}
				catch (Exception ex)
				{
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(21, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Error reading file ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(item);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(":\n");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
					}
					ARALogger.Error(val);
				}
			}
			LiveEditListener val2 = LiveEdit.CreateListener(ModulePath, "*.json", true);
			val2.FileCreated += new LiveEditEventHandler(FileCreated);
			val2.FileChanged += new LiveEditEventHandler(FileChanged);
			val2.FileDeleted += new LiveEditEventHandler(FileDeleted);
		}

		private static uint 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;
			}
			return layoutConfigDefinition?.MainLevelLayout ?? 0;
		}

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

		private void FileChanged(LiveEditEventArgs e)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LiveEdit file changed: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.FullPath);
			}
			ARALogger.Warn(val);
			LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate(string content)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Invalid comparison between Unknown and I4
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Expected O, but got Unknown
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0175: Unknown result type (might be due to invalid IL or missing references)
				//IL_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
				uint num = ReadFileContent(e.FullPath, content);
				if (Current == LayoutConfigDefinition.Empty || Current.MainLevelLayout != num || (int)GameStateManager.CurrentStateName != 10)
				{
					return;
				}
				Collider val3 = default(Collider);
				foreach (WE_ObjectCustomData item in _customLayoutData[num].Zones.SelectMany((ZoneCustomData zData) => zData.WorldEventObjects))
				{
					if (_currentARAFilters.TryGetValue(item.WorldEventObjectFilter, out var value) && !item.UseExistingFilterInArea && !item.UseRandomPosition)
					{
						LG_WorldEventObject val2 = new LG_WorldEventObject(value);
						((Component)val2).transform.position = item.Position;
						((Component)val2).transform.rotation = Quaternion.Euler(item.Rotation);
						((Component)val2).transform.localScale = item.Scale;
						if (GameObjectPlusExtensions.TryAndGetComponent<Collider>(((Component)val2).gameObject, ref val3))
						{
							foreach (WE_ComponentCustomData value2 in item.Components.Values)
							{
								switch (value2.ColliderType)
								{
								case ColliderType.Box:
								{
									BoxCollider val6 = ((Il2CppObjectBase)val3).Cast<BoxCollider>();
									val6.center = value2.Center;
									val6.size = value2.Size;
									break;
								}
								case ColliderType.Sphere:
								{
									SphereCollider val5 = ((Il2CppObjectBase)val3).Cast<SphereCollider>();
									val5.center = value2.Center;
									val5.radius = value2.Radius;
									break;
								}
								case ColliderType.Capsule:
								{
									CapsuleCollider val4 = ((Il2CppObjectBase)val3).Cast<CapsuleCollider>();
									val4.center = value2.Center;
									val4.radius = value2.Radius;
									val4.height = value2.Height;
									break;
								}
								}
							}
						}
					}
				}
			});
		}

		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
			bool flag = default(bool);
			BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(23, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LiveEdit file deleted: ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.FullPath);
			}
			ARALogger.Warn(val);
			LiveEdit.TryReadFileContent(e.FullPath, (Action<string>)delegate
			{
				foreach (uint item in _filepathLayoutMap[e.FullPath])
				{
					_customLayoutData.Remove(item);
				}
				_filepathLayoutMap.Remove(e.FullPath);
			});
		}

		public override void OnBuildStart()
		{
			uint levelLayoutData = RundownManager.ActiveExpedition.LevelLayoutData;
			Current = (_customLayoutData.TryGetValue(levelLayoutData, out LayoutConfigDefinition value) ? value : LayoutConfigDefinition.Empty);
			_positionToContainerMap.Clear();
			_currentARAFilters.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
			if ((int)batch == 46)
			{
				ARALogger.Debug("Applying layout data");
				WE_ObjectCustomData.AllocatePreexistingWorldEventObjects();
				Enumerator<LG_Zone> enumerator = Builder.CurrentFloor.allZones.GetEnumerator();
				while (enumerator.MoveNext())
				{
					LG_Zone current = enumerator.Current;
					AddWorldEventObjectToTerminals(current);
					ApplyLayoutZoneData(current);
				}
				SetupAnimationTriggers();
			}
		}

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

		private static void ApplyLayoutZoneData(LG_Zone zone)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Expected O, but got Unknown
			//IL_0430: Expected O, but got Unknown
			if (!TryGetCurrentZoneData(zone, out ZoneCustomData zoneData) || (Object)(object)((GlobalBase)(zoneData?)).Zone == (Object)null)
			{
				return;
			}
			zoneData.AddSpawnPoints();
			WE_ObjectCustomData[] worldEventObjects = zoneData.WorldEventObjects;
			bool flag = default(bool);
			foreach (WE_ObjectCustomData wE_ObjectCustomData in worldEventObjects)
			{
				if (wE_ObjectCustomData.ShouldCreateNewWorldEventObject(zone, out LG_WorldEventObject weObj))
				{
					weObj = ComponentExt.AddChildGameObject<LG_WorldEventObject>((Component)(object)wE_ObjectCustomData.Area, wE_ObjectCustomData.WorldEventObjectFilter);
					GameObjectPlusExtensions.SetPositionRotationScale(((Component)weObj).transform, wE_ObjectCustomData.Position, wE_ObjectCustomData.Rotation, wE_ObjectCustomData.Scale);
					weObj.WorldEventComponents = Il2CppReferenceArray<IWorldEventComponent>.op_Implicit(Array.Empty<IWorldEventComponent>());
					if (!_currentARAFilters.TryAdd(wE_ObjectCustomData.WorldEventObjectFilter, ((Il2CppObjectBase)weObj).Pointer))
					{
						BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(80, 1, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Duplicates of WorldEventObjectFilter \"");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(wE_ObjectCustomData.WorldEventObjectFilter);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" will be illegible for LiveEdit mid-level");
						}
						ARALogger.Debug(val);
					}
				}
				if ((Object)(object)weObj == (Object)null)
				{
					continue;
				}
				foreach (var (worldEventComponent2, wE_ComponentCustomData2) in wE_ObjectCustomData.Components)
				{
					if (worldEventComponent2 >= WorldEventComponent.WE_CollisionTrigger && worldEventComponent2 <= WorldEventComponent.WE_InteractTrigger)
					{
						switch (wE_ComponentCustomData2.ColliderType)
						{
						case ColliderType.Box:
						{
							BoxCollider val4 = ((Component)weObj).gameObject.AddComponent<BoxCollider>();
							((Component)val4).gameObject.layer = 14;
							val4.center = wE_ComponentCustomData2.Center;
							val4.size = wE_ComponentCustomData2.Size;
							break;
						}
						case ColliderType.Sphere:
						{
							SphereCollider val3 = ((Component)weObj).gameObject.AddComponent<SphereCollider>();
							((Component)val3).gameObject.layer = 14;
							val3.center = wE_ComponentCustomData2.Center;
							val3.radius = wE_ComponentCustomData2.Radius;
							break;
						}
						case ColliderType.Capsule:
						{
							CapsuleCollider val2 = ((Component)weObj).gameObject.AddComponent<CapsuleCollider>();
							((Component)val2).gameObject.layer = 14;
							val2.center = wE_ComponentCustomData2.Center;
							val2.radius = wE_ComponentCustomData2.Radius;
							val2.height = wE_ComponentCustomData2.Height;
							break;
						}
						}
					}
					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, wE_ObjectCustomData.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 val10 = GameObjectPlusExtensions.AddOrGetComponent<PlaceNavMarkerOnGO>(((Component)weObj).gameObject);
						val10.type = wE_ComponentCustomData2.NavMarkerType;
						val10.m_placeOnStart = wE_ComponentCustomData2.PlaceOnStart;
						GameObjectPlusExtensions.AddOrGetComponent<LG_WorldEventNavMarker>(((Component)weObj).gameObject);
						break;
					}
					case WorldEventComponent.WE_CollisionTrigger:
					{
						LG_CollisionWorldEventTrigger val12 = GameObjectPlusExtensions.AddOrGetComponent<LG_CollisionWorldEventTrigger>(((Component)weObj).gameObject);
						val12.m_isToggle = wE_ComponentCustomData2.IsToggle;
						break;
					}
					case WorldEventComponent.WE_LookatTrigger:
					{
						LG_LookatWorldEventTrigger val11 = GameObjectPlusExtensions.AddOrGetComponent<LG_LookatWorldEventTrigger>(((Component)weObj).gameObject);
						val11.m_lookatMaxDistance = wE_ComponentCustomData2.LookatMaxDistance;
						val11.m_isToggle = wE_ComponentCustomData2.IsToggle;
						break;
					}
					case WorldEventComponent.WE_InteractTrigger:
					{
						LG_InteractWorldEventTrigger val5 = GameObjectPlusExtensions.AddOrGetComponent<LG_InteractWorldEventTrigger>(((Component)weObj).gameObject);
						LG_InteractWorldEventTrigger val6 = val5;
						if (((Interact_Base)val6).m_colliderToOwn == null)
						{
							Collider val7 = (((Interact_Base)val6).m_colliderToOwn = ((Component)weObj).gameObject.GetComponent<Collider>());
						}
						val5.m_interactionText = wE_ComponentCustomData2.InteractionText;
						val5.m_isToggle = wE_ComponentCustomData2.IsToggle;
						val5.m_insertType = wE_ComponentCustomData2.CarryItemInsertType;
						val6 = val5;
						if (val6.m_carryAlign == null)
						{
							LG_InteractWorldEventTrigger obj = val6;
							Transform val8 = new Transform
							{
								position = wE_ComponentCustomData2.CarryItemTransform.Position,
								rotation = GameObjectPlusExtensions.ToQuaternion(wE_ComponentCustomData2.CarryItemTransform.Rotation),
								localScale = wE_ComponentCustomData2.CarryItemTransform.Scale
							};
							Transform val9 = val8;
							obj.m_carryAlign = val8;
						}
						val5.m_removeItemOnInsert = wE_ComponentCustomData2.RemoveItemOnInsert;
						val5.m_itemStateAfterInsert = wE_ComponentCustomData2.ItemStateAfterInsert;
						break;
					}
					}
				}
			}
		}

		private static void AddWorldEventObjectToTerminals(LG_Zone zone)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected I4, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected I4, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected I4, but got Unknown
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected I4, but got Unknown
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected I4, but got Unknown
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected I4, but got Unknown
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			if (!Current.AllWorldEventTerminals)
			{
				return;
			}
			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>());
				}
			}
		}

		private static void SetupAnimationTriggers()
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			foreach (WE_ObjectCustomData item in Current.Zones.SelectMany((ZoneCustomData zData) => zData.WorldEventObjects))
			{
				if (!_currentARAFilters.TryGetValue(item.WorldEventObjectFilter, out var value) || !item.Components.TryGetValue(WorldEventComponent.WE_AnimationTrigger, out WE_ComponentCustomData weComp))
				{
					continue;
				}
				List<GameObject> list = new List<GameObject>();
				LG_WorldEventObject val = new LG_WorldEventObject(value);
				LG_WorldEventObject val2 = val;
				if (!Utility.IsNullOrWhiteSpace(weComp.WorldEventAnimationFilter))
				{
					val2 = ComponentExt.AddChildGameObject<LG_WorldEventObject>((Component)(object)item.Area, weComp.WorldEventAnimationFilter);
					((Component)val2).transform.position = new Vector3(item.Position.x, item.Position.y + 1f, item.Position.z);
					val2.WorldEventComponents = Il2CppReferenceArray<IWorldEventComponent>.op_Implicit(Array.Empty<IWorldEventComponent>());
					list.Add(((Component)val).gameObject);
				}
				string[] aRAObjectsToActivate = weComp.ARAObjectsToActivate;
				foreach (string key in aRAObjectsToActivate)
				{
					if (_currentARAFilters.TryGetValue(key, out var value2))
					{
						LG_WorldEventObject val3 = new LG_WorldEventObject(value2);
						list.Add(((Component)val3).gameObject);
					}
				}
				if (list.Count != 0)
				{
					LG_WorldEventAnimationTrigger val4 = GameObjectPlusExtensions.AddOrGetComponent<LG_WorldEventAnimationTrigger>(((Component)val2).gameObject);
					val4.m_playResetOnSetup = weComp.PlayResetOnStartup;
					val4.m_gameObjectsToActivateOnTrigger = Il2CppReferenceArray<GameObjectActivationPair>.op_Implicit(((IEnumerable<GameObject>)list).Select((Func<GameObject, GameObjectActivationPair>)((GameObject go) => new GameObjectActivationPair
					{
						GameObjectToSet = go,
						ActivationMode = weComp.ActivationMode
					})).ToArray());
					val4.m_gameObjectsToActivateOnReset = Il2CppReferenceArray<GameObjectActivationPair>.op_Implicit(((IEnumerable<GameObject>)list).Select((Func<GameObject, GameObjectActivationPair>)((GameObject go) => new GameObjectActivationPair
					{
						GameObjectToSet = go,
						ActivationMode = !weComp.ActivationMode
					})).ToArray());
				}
			}
		}
	}
}
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.Default] = ("Assets/AssetPrefabs/Complex/Generic/FunctionMarkers/Terminal_Floor.prefab", null),
			[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,
		WE_AnimationTrigger
	}
	public enum ColliderType
	{
		None,
		Box,
		Sphere,
		Capsule
	}
	public struct CustomTransform
	{
		public Vector3 Position;

		public Vector3 Rotation;

		public Vector3 Scale;

		[JsonConstructor]
		public CustomTransform(Vector3 position, Vector3 rotation, Vector3 scale)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: 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_0010: 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_0019: 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_0021: 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)
			Position = position;
			Rotation = rotation;
			Scale = ((scale == default(Vector3)) ? Vector3.one : scale);
		}
	}
	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 ColliderType ColliderType { get; set; } = ColliderType.None;

		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 bool IsToggle { get; set; } = false;

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

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

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

		public CustomTransform CarryItemTransform { get; set; } = default(CustomTransform);

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

		public eCarryItemCustomState ItemStateAfterInsert { get; set; } = (eCarryItemCustomState)0;

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

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

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

		public string[] ARAObjectsToActivate { get; set; } = Array.Empty<string>();
	}
	public sealed class WE_ObjectCustomData
	{
		private static ILookup<int, LG_WorldEventObject> _preAllocWE;

		private static Random _weRand;

		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 CustomTransform[] RandomPositions { get; set; } = Array.Empty<CustomTransform>();

		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>();

		internal LG_Area Area { get; private set; } = null;

		internal static void AllocatePreexistingWorldEventObjects()
		{
			_preAllocWE = (from <>h__TransparentIdentifier0 in ((IEnumerable<LG_WorldEventObject>)Object.FindObjectsOfType<LG_WorldEventObject>()).Select(delegate(LG_WorldEventObject weObj)
				{
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					object obj = weObj.ParentArea;
					if (obj == null)
					{
						AIG_CourseNode courseNode = CourseNodeUtil.GetCourseNode(((Component)weObj).transform.position);
						obj = ((courseNode != null) ? courseNode.m_area : null);
					}
					return new
					{
						weObj = weObj,
						area = (LG_Area)obj
					};
				})
				where (Object)(object)<>h__TransparentIdentifier0.area != (Object)null
				select (key: ((Object)<>h__TransparentIdentifier0.area).GetInstanceID(), weObj: <>h__TransparentIdentifier0.weObj)).ToLookup(((int key, LG_WorldEventObject weObj) x) => x.key, ((int key, LG_WorldEventObject weObj) y) => y.weObj);
			_weRand = RandomUtil.CreateSessionRandom("WE_ObjectCustomData");
		}

		internal bool ShouldCreateNewWorldEventObject(LG_Zone zone, [MaybeNull] out LG_WorldEventObject weObj)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAreaIndexValid(zone))
			{
				weObj = null;
				return false;
			}
			if (UseRandomPosition)
			{
				if (RandomPositions.Length != 0)
				{
					CustomTransform customTransform = RandomPositions[_weRand.Next(RandomPositions.Length)];
					Position = customTransform.Position;
					Rotation = customTransform.Rotation;
					Scale = customTransform.Scale;
				}
				else if (AreaIndex == -1)
				{
					LG_Area val = zone.m_areas[_weRand.Next(zone.m_areas.Count)];
					Position = val.m_courseNode.GetRandomPositionInside();
					Rotation = new Vector3(0f, (float)_weRand.Next(360), 0f);
				}
				else
				{
					Position = Area.m_courseNode.GetRandomPositionInside();
					Rotation = new Vector3(0f, (float)_weRand.Next(360), 0f);
				}
			}
			if (UseExistingFilterInArea)
			{
				weObj = _preAllocWE[((Object)Area).GetInstanceID()].FirstOrDefault((Func<LG_WorldEventObject, bool>)((LG_WorldEventObject w) => w.WorldEventObjectKey == WorldEventObjectFilter));
				if ((Object)(object)weObj != (Object)null)
				{
					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;
					}
				}
				else
				{
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(37, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Unable to find preexisting \"");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(WorldEventObjectFilter);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\" in area");
					}
					ARALogger.Error(val2);
				}
				return false;
			}
			weObj = null;
			return true;
		}

		private bool IsAreaIndexValid(LG_Zone zone)
		{
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (AreaIndex >= 0 && AreaIndex < zone.m_areas.Count)
			{
				Area = zone.m_areas[AreaIndex];
				return true;
			}
			bool flag = default(bool);
			BepInExErrorLogInterpolatedStringHandler val2;
			if (AreaIndex == -1)
			{
				try
				{
					Area = CourseNodeUtil.GetCourseNode(Position, zone.DimensionIndex).m_area;
					if (!zone.m_areas.Contains(Area))
					{
						BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(34, 3, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\"");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(WorldEventObjectFilter);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\": Area inferred from ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(Position);
							((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is not in ");
							((BepInExLogInterpolatedStringHandler)val).AppendFormatted<(int, int, int)>(GlobalIndexUtil.ToIntTuple(zone));
						}
						ARALogger.Warn(val);
					}
					return true;
				}
				catch
				{
					val2 = new BepInExErrorLogInterpolatedStringHandler(33, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\"");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(WorldEventObjectFilter);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\": Failed to infer AreaIndex at ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Vector3>(Position);
					}
					ARALogger.Error(val2);
				}
			}
			val2 = new BepInExErrorLogInterpolatedStringHandler(31, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Invalid AreaIndex ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(AreaIndex);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" for filter ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(WorldEventObjectFilter);
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("!");
			}
			ARALogger.Error(val2);
			Area = null;
			return false;
		}
	}
	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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < positions.Length; i++)
			{
				Vector3 val = positions[i];
				AIG_CourseNode courseNode = CourseNodeUtil.GetCourseNode(val, ((GlobalBase)this).DimensionIndex);
				LG_Area val2 = ((courseNode != null) ? courseNode.m_area : null);
				if (!((Object)(object)val2 == (Object)null))
				{
					string text = "ARA_" + source + "_SpawnPoint";
					if (i > 0)
					{
						text += $" ({i})";
					}
					GameObject val3 = new GameObject(text);
					val3.transform.SetPositionAndRotation(val, Quaternion.identity);
					val3.transform.SetParent(((Component)val2).transform, true);
					targetList(val2).Add(val3.transform);
				}
			}
		}
	}
}