Decompiled source of MW2 Highrise v0.4.1

plugins/MW2Highrise/MW2Highrise.dll

Decompiled 18 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using HG;
using KinematicCharacterController;
using Newtonsoft.Json;
using On.EntityStates;
using On.RoR2;
using On.RoR2.Projectile;
using R2API;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using RoR2.Navigation;
using RoR2.Projectile;
using RoR2.WwiseUtils;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.SceneManagement;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace MW2Highrise;

public sealed class HighriseWorld : MonoBehaviour
{
	private sealed class BossShape
	{
		internal CharacterSpawnCard card;

		internal CharacterBody body;

		internal float radius;

		internal float halfSegment;

		internal Vector3 center;

		internal Vector3 aimOffset;

		internal Vector3[] roots;
	}

	private sealed class MonsterPoolAudit
	{
		internal DirectorCard vagrant;

		internal readonly List<string> removed = new List<string>();

		internal readonly List<string> fallbacks = new List<string>();
	}

	internal readonly List<CharacterSpawnCard> BossCards = new List<CharacterSpawnCard>();

	private readonly Dictionary<CharacterSpawnCard, bool[]> bossNodes = new Dictionary<CharacterSpawnCard, bool[]>();

	private static readonly FieldInfo BossNodesField = typeof(NodeGraph).GetField("nodes", BindingFlags.Instance | BindingFlags.NonPublic);

	private static readonly FieldInfo BossLinksField = typeof(NodeGraph).GetField("links", BindingFlags.Instance | BindingFlags.NonPublic);

	internal bool Ready;

	internal HighriseLayout Layout;

	internal Bounds PlayBounds;

	internal Bounds WorldBounds;

	internal List<Vector3> Ground;

	internal Navigation.Result GroundResult;

	internal Navigation.Result AirResult;

	private readonly List<Object> owned = new List<Object>();

	private readonly Dictionary<Camera, float> farPlanes = new Dictionary<Camera, float>();

	internal bool NativePlayerRenderReady;

	private Transform validationGeometry;

	internal bool BossNodeAllowed(CharacterSpawnCard card, int node)
	{
		bool[] value;
		return !bossNodes.TryGetValue(card, out value) || (node >= 0 && node < value.Length && value[node]);
	}

	private static bool BossCombatLine(BossShape shape, int node, Vector3 target)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = target - shape.roots[node];
		val.y = 0f;
		Quaternion val2 = Util.QuaternionSafeLookRotation(val);
		Vector3 val3 = shape.roots[node] + val2 * shape.aimOffset;
		Vector3 val4 = target + Vector3.up * 1.5f;
		LayerIndex world = LayerIndex.world;
		return !Physics.Linecast(val3, val4, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask));
	}

	private bool ApprovedChampion(SpawnCard spawn)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		return spawn is CharacterSpawnCard && BossCards.Contains((CharacterSpawnCard)spawn);
	}

	private static DirectorCard FindNativeBoss(DccsPool source, string spawnName)
	{
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		Category[] poolCategories = source.poolCategories;
		foreach (Category val in poolCategories)
		{
			if (val == null)
			{
				continue;
			}
			List<DirectorCardCategorySelection> list = new List<DirectorCardCategorySelection>();
			if (val.alwaysIncluded != null)
			{
				PoolEntry[] alwaysIncluded = val.alwaysIncluded;
				foreach (PoolEntry val2 in alwaysIncluded)
				{
					if (val2 != null)
					{
						list.Add(val2.dccs);
					}
				}
			}
			if (val.includedIfNoConditionsMet != null)
			{
				PoolEntry[] alwaysIncluded = val.includedIfNoConditionsMet;
				foreach (PoolEntry val2 in alwaysIncluded)
				{
					if (val2 != null)
					{
						list.Add(val2.dccs);
					}
				}
			}
			if (val.includedIfConditionsMet != null)
			{
				ConditionalPoolEntry[] includedIfConditionsMet = val.includedIfConditionsMet;
				foreach (ConditionalPoolEntry val3 in includedIfConditionsMet)
				{
					if (val3 != null)
					{
						list.Add(((PoolEntry)val3).dccs);
					}
				}
			}
			foreach (DirectorCardCategorySelection item in list)
			{
				if (!Object.op_Implicit((Object)(object)item) || item.categories == null)
				{
					continue;
				}
				Category[] categories = item.categories;
				for (int j = 0; j < categories.Length; j++)
				{
					Category val4 = categories[j];
					if (val4.cards == null)
					{
						continue;
					}
					DirectorCard[] cards = val4.cards;
					foreach (DirectorCard val5 in cards)
					{
						if (val5 != null)
						{
							DirectorCard val6 = CopyDirectorCard(val5);
							SpawnCard spawnCard = val6.GetSpawnCard();
							CharacterBody val7 = NativeMonsterBody(spawnCard);
							if (Object.op_Implicit((Object)(object)spawnCard) && ((Object)spawnCard).name == spawnName && Object.op_Implicit((Object)(object)val7) && val7.isChampion)
							{
								return val6;
							}
						}
					}
				}
			}
		}
		return null;
	}

	private void ValidateGroundBosses(DccsPool source, CharacterSpawnCard vagrant)
	{
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Invalid comparison between Unknown and I4
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Invalid comparison between Unknown and I4
		//IL_00e4: 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_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e4: Invalid comparison between Unknown and I4
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Invalid comparison between I4 and Unknown
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_035d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_0375: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e1: 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_03ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f4: 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_0402: Unknown result type (might be due to invalid IL or missing references)
		//IL_0414: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07fb: Invalid comparison between Unknown and I4
		//IL_0834: Unknown result type (might be due to invalid IL or missing references)
		//IL_083b: Unknown result type (might be due to invalid IL or missing references)
		//IL_083d: 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_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0420: Unknown result type (might be due to invalid IL or missing references)
		//IL_0422: Unknown result type (might be due to invalid IL or missing references)
		//IL_042b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_0437: Unknown result type (might be due to invalid IL or missing references)
		//IL_0440: Unknown result type (might be due to invalid IL or missing references)
		//IL_0445: Unknown result type (might be due to invalid IL or missing references)
		//IL_0451: Unknown result type (might be due to invalid IL or missing references)
		//IL_0456: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0807: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_046e: Unknown result type (might be due to invalid IL or missing references)
		//IL_047b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0480: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_048c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0490: Unknown result type (might be due to invalid IL or missing references)
		//IL_049a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_084d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0852: Unknown result type (might be due to invalid IL or missing references)
		//IL_0854: Unknown result type (might be due to invalid IL or missing references)
		//IL_0856: Invalid comparison between Unknown and I4
		//IL_0779: Unknown result type (might be due to invalid IL or missing references)
		//IL_077b: Unknown result type (might be due to invalid IL or missing references)
		//IL_077c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0782: Expected I4, but got Unknown
		//IL_0791: Unknown result type (might be due to invalid IL or missing references)
		//IL_0793: Unknown result type (might be due to invalid IL or missing references)
		//IL_0794: Unknown result type (might be due to invalid IL or missing references)
		//IL_079a: Expected I4, but got Unknown
		//IL_0660: Unknown result type (might be due to invalid IL or missing references)
		//IL_0673: Unknown result type (might be due to invalid IL or missing references)
		//IL_0678: Unknown result type (might be due to invalid IL or missing references)
		//IL_067d: Unknown result type (might be due to invalid IL or missing references)
		//IL_08bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_08dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06be: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_06fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_070b: Unknown result type (might be due to invalid IL or missing references)
		//IL_070f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0716: Unknown result type (might be due to invalid IL or missing references)
		//IL_071b: Unknown result type (might be due to invalid IL or missing references)
		//IL_071f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0915: Unknown result type (might be due to invalid IL or missing references)
		//IL_0917: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ab: Expected I4, but got Unknown
		//IL_09cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d6: Invalid comparison between Unknown and I4
		//IL_0966: Unknown result type (might be due to invalid IL or missing references)
		//IL_0968: Unknown result type (might be due to invalid IL or missing references)
		//IL_0969: Unknown result type (might be due to invalid IL or missing references)
		//IL_096f: Expected I4, but got Unknown
		//IL_097e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0980: Unknown result type (might be due to invalid IL or missing references)
		//IL_0981: Unknown result type (might be due to invalid IL or missing references)
		//IL_0987: Expected I4, but got Unknown
		BossCards.Add(vagrant);
		List<BossShape> list = new List<BossShape>();
		string[] array = new string[2] { "cscTitanBlackBeach", "cscBeetleQueen" };
		foreach (string text in array)
		{
			DirectorCard val = FindNativeBoss(source, text);
			CharacterSpawnCard val2 = (CharacterSpawnCard)((val == null) ? null : /*isinst with value type is only supported in some contexts*/);
			CharacterBody val3 = NativeMonsterBody((SpawnCard)(object)val2);
			CapsuleCollider val4 = (Object.op_Implicit((Object)(object)val3) ? ((Component)val3).GetComponent<CapsuleCollider>() : null);
			if (!Object.op_Implicit((Object)(object)val2) || (int)((SpawnCard)val2).nodeGraphType != 0 || (int)((SpawnCard)val2).hullSize != 2 || !Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val4) || !((Collider)val4).enabled || ((Collider)val4).isTrigger || val4.direction != 1)
			{
				throw new Exception("Native Highrise boss requires an upright ground capsule: " + text);
			}
			Vector3 lossyScale = ((Component)val3).transform.lossyScale;
			float num = val4.radius * Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z));
			float num2 = Mathf.Max(val4.height * Mathf.Abs(lossyScale.y), num * 2f);
			if (num <= 0f || num2 <= 0f || float.IsNaN(num) || float.IsNaN(num2) || float.IsInfinity(num) || float.IsInfinity(num2))
			{
				throw new Exception("Invalid native boss dimensions: " + text);
			}
			list.Add(new BossShape
			{
				card = val2,
				body = val3,
				radius = num,
				halfSegment = num2 * 0.5f - num,
				center = Vector3.Scale(val4.center, lossyScale),
				aimOffset = (Object.op_Implicit((Object)(object)val3.aimOriginTransform) ? (val3.aimOriginTransform.position - ((Component)val3).transform.position) : Vector3.zero)
			});
		}
		NodeGraph graph = GroundResult.graph;
		Node[] array2 = (Node[])BossNodesField.GetValue(graph);
		Link[] array3 = (Link[])BossLinksField.GetValue(graph);
		HullMask val5 = (HullMask)4;
		bool[] array4 = new bool[array2.Length];
		for (int j = 0; j < array2.Length; j++)
		{
			array4[j] = (array2[j].forbiddenHulls & val5) == 0;
		}
		Result val7 = default(Result);
		LayerIndex world;
		foreach (BossShape item in list)
		{
			item.roots = (Vector3[])(object)new Vector3[array2.Length];
			int num3 = 0;
			int num4 = 0;
			for (int j = 0; j < array2.Length; j++)
			{
				if ((array2[j].forbiddenHulls & val5) != 0 || (byte)(array2[j].flags & ((SpawnCard)item.card).forbiddenFlags) != 0 || (byte)(array2[j].flags & ((SpawnCard)item.card).requiredFlags) != (int)((SpawnCard)item.card).requiredFlags)
				{
					array4[j] = false;
					continue;
				}
				num3++;
				Vector3 position = array2[j].position;
				BodyPlacementHelper val6 = new BodyPlacementHelper
				{
					body = item.body,
					spawnPointPosition = position,
					spawnPointRotation = Quaternion.identity
				};
				((BodyPlacementHelper)(ref val6)).GetSpawnTransformation(ref val7);
				ref Vector3 reference = ref item.roots[j];
				reference = val7.bodyPosition;
				Vector3 val8 = val7.bodyPosition + val7.bodyRotation * item.center + Vector3.up * 0.02f;
				Vector3 val9 = val7.bodyRotation * Vector3.up;
				float num5 = HullDef.Find(((SpawnCard)item.card).hullSize).radius * 0.7f;
				if (Util.IsPositionWithinMapBounds(position))
				{
					Vector3 val10 = val8 - val9 * item.halfSegment;
					Vector3 val11 = val8 + val9 * item.halfSegment;
					float radius = item.radius;
					world = LayerIndex.world;
					if (!Physics.CheckCapsule(val10, val11, radius, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
					{
						Vector3 val12 = position + Vector3.up * (num5 + 0.25f);
						world = LayerIndex.world;
						if (!HGPhysics.DoesOverlapSphere(val12, num5, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask) | LayerMask.op_Implicit(CommonMasks.characterBodiesOrDefault) | LayerMask.op_Implicit(CommonMasks.fakeActorLayers), (QueryTriggerInteraction)0))
						{
							num4++;
							continue;
						}
					}
				}
				array4[j] = false;
			}
			Plugin.Log.LogInfo((object)("HIGHRISE native ground boss fit card=" + ((Object)item.card).name + " body=" + ((Object)item.body).name + " radius=" + item.radius + " halfSegment=" + item.halfSegment + " eligibleNodes=" + num3 + " fullNativeBodyClearNodes=" + num4 + " nativeCardAndBodyUnchanged=True"));
		}
		int num6 = 0;
		for (int j = 0; j < array3.Length; j++)
		{
			if ((array3[j].hullMask & val5) == 0)
			{
				continue;
			}
			int nodeIndex = array3[j].nodeIndexA.nodeIndex;
			int nodeIndex2 = array3[j].nodeIndexB.nodeIndex;
			bool flag = array4[nodeIndex] && array4[nodeIndex2];
			if (flag)
			{
				foreach (BossShape item2 in list)
				{
					Vector3 val13 = item2.roots[nodeIndex2] - item2.roots[nodeIndex];
					float magnitude = ((Vector3)(ref val13)).magnitude;
					if (!(magnitude < 0.0001f))
					{
						Vector3 val14 = item2.roots[nodeIndex] + item2.center + Vector3.up * 0.02f;
						Vector3 val15 = val14 - Vector3.up * item2.halfSegment;
						Vector3 val16 = val14 + Vector3.up * item2.halfSegment;
						float radius2 = item2.radius;
						Vector3 val17 = val13 / magnitude;
						world = LayerIndex.world;
						if (Physics.CapsuleCast(val15, val16, radius2, val17, magnitude, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
						{
							flag = false;
							break;
						}
					}
				}
			}
			if (!flag)
			{
				ref Link reference2 = ref array3[j];
				reference2.hullMask &= ~val5;
				ref Link reference3 = ref array3[j];
				reference3.jumpHullMask &= ~val5;
				num6++;
			}
		}
		ValidateNativeMovementHull(array2, array3, list[0]);
		bool[] array5 = new bool[array2.Length];
		Link[] array6 = array3;
		for (int i = 0; i < array6.Length; i++)
		{
			Link val18 = array6[i];
			if ((val18.hullMask & val5) != 0)
			{
				array5[val18.nodeIndexA.nodeIndex] = true;
			}
		}
		HullMask val19 = (HullMask)(1 << (int)list[0].body.hullClassification);
		for (int j = 0; j < array2.Length; j++)
		{
			if ((array2[j].forbiddenHulls & val19) != 0)
			{
				array4[j] = false;
			}
		}
		int num7 = 0;
		for (int j = 0; j < array2.Length; j++)
		{
			ref bool reference4 = ref array4[j];
			reference4 &= array5[j];
			if (array4[j])
			{
				num7++;
				continue;
			}
			ref Node reference5 = ref array2[j];
			reference5.forbiddenHulls |= val5;
			ref HullMask reference6 = ref GroundResult.forbidden[j];
			reference6 |= val5;
		}
		for (int j = 0; j < array3.Length; j++)
		{
			if ((array3[j].hullMask & val5) != 0 && (!array4[array3[j].nodeIndexA.nodeIndex] || !array4[array3[j].nodeIndexB.nodeIndex]))
			{
				ref Link reference7 = ref array3[j];
				reference7.hullMask &= ~val5;
				ref Link reference8 = ref array3[j];
				reference8.jumpHullMask &= ~val5;
			}
		}
		PruneUnlinkedBossHull(array2, array3, (int)val5);
		num7 = 0;
		for (int j = 0; j < array2.Length; j++)
		{
			array4[j] &= (array2[j].forbiddenHulls & val5) == 0;
			if (array4[j])
			{
				num7++;
			}
		}
		if (num7 == 0)
		{
			throw new Exception("No connected native Titan/Beetle Queen ground nodes remain after physical fit validation.");
		}
		Native.Set(graph, "nodes", array2);
		Native.Set(graph, "links", array3);
		foreach (BossShape item3 in list)
		{
			BossCards.Add(item3.card);
			bossNodes.Add(item3.card, array4);
		}
		FilterTeleportersForGroundBosses(array2, array4, list);
		Plugin.Log.LogInfo((object)("HIGHRISE boss roster=[" + string.Join(",", BossCards.ConvertAll((CharacterSpawnCard c) => ((Object)c).name).ToArray()) + "] sharedGroundBossNodes=" + num7 + " nativeCapsuleFilteredLargeHullLinks=" + num6 + " nativeBodiesAndAIUnchanged=True sharedGamePoolsUnchanged=True"));
	}

	private void ValidateNativeMovementHull(Node[] nodes, Link[] links, BossShape shape)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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_0044: Invalid comparison between Unknown and I4
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00e7: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: 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)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: 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_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_038b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_0392: Unknown result type (might be due to invalid IL or missing references)
		//IL_0458: Unknown result type (might be due to invalid IL or missing references)
		//IL_045e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0460: Invalid comparison between Unknown and I4
		//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
		int num = 1 << (int)shape.body.hullClassification;
		bool[] array = new bool[nodes.Length];
		Vector3[] array2 = (Vector3[])(object)new Vector3[nodes.Length];
		int num2 = 0;
		int num3 = 0;
		int num4 = 0;
		Result val2 = default(Result);
		LayerIndex world;
		for (int i = 0; i < nodes.Length; i++)
		{
			if ((nodes[i].forbiddenHulls & num) == 0)
			{
				num2++;
				BodyPlacementHelper val = new BodyPlacementHelper
				{
					body = shape.body,
					spawnPointPosition = nodes[i].position,
					spawnPointRotation = Quaternion.identity
				};
				((BodyPlacementHelper)(ref val)).GetSpawnTransformation(ref val2);
				ref Vector3 reference = ref array2[i];
				reference = val2.bodyPosition;
				Vector3 val3 = val2.bodyPosition + val2.bodyRotation * shape.center + Vector3.up * 0.02f;
				int num5 = i;
				Vector3 val4 = val3 - Vector3.up * shape.halfSegment;
				Vector3 val5 = val3 + Vector3.up * shape.halfSegment;
				float radius = shape.radius;
				world = LayerIndex.world;
				array[num5] = !Physics.CheckCapsule(val4, val5, radius, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1);
			}
		}
		for (int i = 0; i < links.Length; i++)
		{
			if ((links[i].hullMask & num) == 0)
			{
				continue;
			}
			int nodeIndex = links[i].nodeIndexA.nodeIndex;
			int nodeIndex2 = links[i].nodeIndexB.nodeIndex;
			bool flag = array[nodeIndex] && array[nodeIndex2];
			if (flag)
			{
				Vector3 val6 = array2[nodeIndex2] - array2[nodeIndex];
				float magnitude = ((Vector3)(ref val6)).magnitude;
				Vector3 val3 = array2[nodeIndex] + shape.center + Vector3.up * 0.02f;
				if (magnitude > 0.0001f)
				{
					Vector3 val7 = val3 - Vector3.up * shape.halfSegment;
					Vector3 val8 = val3 + Vector3.up * shape.halfSegment;
					float radius2 = shape.radius;
					Vector3 val9 = val6 / magnitude;
					world = LayerIndex.world;
					if (Physics.CapsuleCast(val7, val8, radius2, val9, magnitude, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
					{
						flag = false;
					}
				}
			}
			if (!flag)
			{
				ref Link reference2 = ref links[i];
				reference2.hullMask &= ~num;
				ref Link reference3 = ref links[i];
				reference3.jumpHullMask &= ~num;
				num4++;
			}
		}
		bool[] array3 = new bool[nodes.Length];
		for (int j = 0; j < links.Length; j++)
		{
			Link val10 = links[j];
			if ((val10.hullMask & num) != 0)
			{
				array3[val10.nodeIndexA.nodeIndex] = true;
			}
		}
		for (int i = 0; i < nodes.Length; i++)
		{
			ref bool reference4 = ref array[i];
			reference4 &= array3[i];
			if (array[i])
			{
				num3++;
				continue;
			}
			ref Node reference5 = ref nodes[i];
			reference5.forbiddenHulls = (HullMask)(reference5.forbiddenHulls | num);
			ref HullMask reference6 = ref GroundResult.forbidden[i];
			reference6 = (HullMask)(reference6 | num);
		}
		for (int i = 0; i < links.Length; i++)
		{
			if ((links[i].hullMask & num) != 0 && (!array[links[i].nodeIndexA.nodeIndex] || !array[links[i].nodeIndexB.nodeIndex]))
			{
				ref Link reference7 = ref links[i];
				reference7.hullMask &= ~num;
				ref Link reference8 = ref links[i];
				reference8.jumpHullMask &= ~num;
			}
		}
		PruneUnlinkedBossHull(nodes, links, num);
		num3 = 0;
		for (int i = 0; i < nodes.Length; i++)
		{
			if ((nodes[i].forbiddenHulls & num) == 0)
			{
				num3++;
			}
		}
		Plugin.Log.LogInfo((object)string.Concat("HIGHRISE native boss movement fit body=", ((Object)shape.body).name, " nativeBodyHull=", shape.body.hullClassification, " nativeSpawnHull=", ((SpawnCard)shape.card).hullSize, " eligible=", num2, " retained=", num3, " filteredLinks=", num4, " nativeBodyHullUnchanged=True"));
	}

	private void PruneUnlinkedBossHull(Node[] nodes, Link[] links, int mask)
	{
		//IL_001f: 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_0033: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Invalid comparison between Unknown and I4
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: 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_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Invalid comparison between Unknown and I4
		bool flag;
		do
		{
			flag = false;
			bool[] array = new bool[nodes.Length];
			for (int i = 0; i < links.Length; i++)
			{
				Link val = links[i];
				if ((val.hullMask & mask) != 0 && ((nodes[val.nodeIndexA.nodeIndex].forbiddenHulls | nodes[val.nodeIndexB.nodeIndex].forbiddenHulls) & mask) == 0)
				{
					array[val.nodeIndexA.nodeIndex] = true;
				}
			}
			for (int j = 0; j < nodes.Length; j++)
			{
				if ((nodes[j].forbiddenHulls & mask) == 0 && !array[j])
				{
					ref Node reference = ref nodes[j];
					reference.forbiddenHulls = (HullMask)(reference.forbiddenHulls | mask);
					ref HullMask reference2 = ref GroundResult.forbidden[j];
					reference2 = (HullMask)(reference2 | mask);
					flag = true;
				}
			}
			for (int j = 0; j < links.Length; j++)
			{
				if ((links[j].hullMask & mask) != 0 && ((nodes[links[j].nodeIndexA.nodeIndex].forbiddenHulls | nodes[links[j].nodeIndexB.nodeIndex].forbiddenHulls) & mask) != 0)
				{
					ref Link reference3 = ref links[j];
					reference3.hullMask &= ~mask;
					ref Link reference4 = ref links[j];
					reference4.jumpHullMask &= ~mask;
					flag = true;
				}
			}
		}
		while (flag);
	}

	private void FilterTeleportersForGroundBosses(Node[] nodes, bool[] allowed, List<BossShape> shapes)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: 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_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: 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)
		int num = 0;
		int num2 = 0;
		StringBuilder stringBuilder = new StringBuilder("teleporterNode,x,y,z,sameSectionBossNodes25to40m,retained\n");
		for (int i = 0; i < nodes.Length; i++)
		{
			if ((byte)(nodes[i].flags & 2) == 0)
			{
				continue;
			}
			num++;
			int num3 = 0;
			for (int j = 0; j < nodes.Length; j++)
			{
				if (!allowed[j] || GroundResult.sectionIds[j] != GroundResult.sectionIds[i])
				{
					continue;
				}
				Vector3 val = nodes[j].position - nodes[i].position;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				if (sqrMagnitude < 625f || sqrMagnitude > 1600f || val.y > Mathf.Sqrt(sqrMagnitude) * 0.70710677f)
				{
					continue;
				}
				bool flag = true;
				foreach (BossShape shape in shapes)
				{
					if (!BossCombatLine(shape, j, nodes[i].position))
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					num3++;
				}
			}
			if (num3 > 0)
			{
				num2++;
			}
			else
			{
				ref Node reference = ref nodes[i];
				reference.flags = (NodeFlags)(byte)(reference.flags & 0xFD);
				ref NodeFlags reference2 = ref GroundResult.flags[i];
				reference2 = (NodeFlags)(byte)(reference2 & 0xFD);
			}
			stringBuilder.Append(i).Append(',').Append(nodes[i].position.x.ToString("R", CultureInfo.InvariantCulture))
				.Append(',')
				.Append(nodes[i].position.y.ToString("R", CultureInfo.InvariantCulture))
				.Append(',')
				.Append(nodes[i].position.z.ToString("R", CultureInfo.InvariantCulture))
				.Append(',')
				.Append(num3)
				.Append(',')
				.Append((num3 > 0) ? 1 : 0)
				.Append('\n');
		}
		Native.Set(GroundResult.graph, "nodes", nodes);
		Plugin.Log.LogInfo((object)("HIGHRISE Titan/Queen teleporter coverage original=" + num + " retained=" + num2 + " sameHumanSection=True clearCombatLineToTeleporter=True minRange=25 maxRange=40 nativeHullUnchanged=True"));
		if (Plugin.Testing)
		{
			File.WriteAllText(Path.Combine(Plugin.Folder, "highrise-ground-boss-coverage.csv"), stringBuilder.ToString());
		}
		if (num2 == 0)
		{
			throw new Exception("No Highrise teleporter court supports Vagrant, Titan and Beetle Queen within the normal native spawn range.");
		}
	}

	public static void Create(Scene scene)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("MW2 Highrise | native stage systems");
		SceneManager.MoveGameObjectToScene(val, scene);
		val.AddComponent<HighriseWorld>().Build(scene);
	}

	private GameObject Child(string name)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		GameObject val = new GameObject(name);
		val.transform.SetParent(((Component)this).transform, false);
		return val;
	}

	internal Vector3 SourcePoint(Vector3 original)
	{
		//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_004a: 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)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		if (Layout == null)
		{
			throw new InvalidOperationException("Highrise layout is not loaded.");
		}
		if (Layout.worldScale == 1f)
		{
			return original;
		}
		Vector3 val = HighriseLayout.V(Layout.sourcePivot);
		return val + (original - val) * Layout.worldScale;
	}

	private void Build(Scene scene)
	{
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0352: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_056e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0586: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0640: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_0427: Unknown result type (might be due to invalid IL or missing references)
		//IL_0429: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Unknown result type (might be due to invalid IL or missing references)
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_043a: Unknown result type (might be due to invalid IL or missing references)
		//IL_043f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0455: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0490: Unknown result type (might be due to invalid IL or missing references)
		//IL_075b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
		Layout = JsonConvert.DeserializeObject<HighriseLayout>(File.ReadAllText(Path.Combine(Plugin.Folder, "highrise-layout.json")));
		if (Layout == null || Layout.spawn == null || Layout.teleporters == null || Layout.teleporters.Length == 0)
		{
			throw new Exception("highrise-layout.json needs spawn and at least one teleporter candidate.");
		}
		if (float.IsNaN(Layout.worldScale) || float.IsInfinity(Layout.worldScale) || Layout.worldScale < 1f || Layout.worldScale > 5f)
		{
			throw new Exception("Highrise authoring scale must be within 1..5.");
		}
		if (Layout.worldScale != 1f)
		{
			HighriseLayout.V(Layout.sourcePivot);
		}
		HighriseLayout.V(Layout.spawn);
		float[][] teleporters = Layout.teleporters;
		foreach (float[] p in teleporters)
		{
			HighriseLayout.V(p);
		}
		if (Layout.groundSpacing < 1f || Layout.groundSpacing > 8f || Layout.airSpacing < 5f || Layout.airSpacing > 40f || Layout.groundLinkRange < Layout.groundSpacing || Layout.groundLinkRange > 12f)
		{
			throw new Exception("Invalid navigation spacing/link range.");
		}
		GameObject val = null;
		GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
		foreach (GameObject val2 in rootGameObjects)
		{
			if (((Object)val2).name == "Highrise Geometry")
			{
				val = val2;
			}
		}
		if (!Object.op_Implicit((Object)(object)val))
		{
			throw new Exception("Scene must have a root named Highrise Geometry.");
		}
		Vector3 val3 = val.transform.lossyScale - Vector3.one * Layout.worldScale;
		if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f)
		{
			throw new Exception("Highrise scene geometry scale does not match its authored layout metadata; rebuild both together.");
		}
		bool flag = true;
		int num = 0;
		Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>();
		foreach (Collider val4 in componentsInChildren)
		{
			if (val4.enabled && !val4.isTrigger)
			{
				((Component)val4).gameObject.layer = LayerIndex.world.intVal;
				if (flag)
				{
					WorldBounds = val4.bounds;
					flag = false;
				}
				else
				{
					((Bounds)(ref WorldBounds)).Encapsulate(val4.bounds);
				}
				num++;
			}
		}
		if (flag || ((Bounds)(ref WorldBounds)).size.x < 5f || ((Bounds)(ref WorldBounds)).size.z < 5f)
		{
			throw new Exception("Highrise Geometry has no usable solid collider bounds.");
		}
		PlayBounds = WorldBounds;
		if (Layout.playableMin != null || Layout.playableMax != null)
		{
			if (Layout.playableMin == null || Layout.playableMax == null)
			{
				throw new Exception("Specify both playableMin and playableMax, or neither.");
			}
			Vector3 val5 = HighriseLayout.V(Layout.playableMin);
			Vector3 val6 = HighriseLayout.V(Layout.playableMax);
			Vector3 val7 = val6 - val5;
			if (val7.x < 5f || val7.y < 0.5f || val7.z < 5f)
			{
				throw new Exception("Playable bounds must be ordered with at least 5m width/depth and 0.5m height.");
			}
			PlayBounds = new Bounds((val5 + val6) * 0.5f, val7);
			if (!((Bounds)(ref PlayBounds)).Contains(HighriseLayout.V(Layout.spawn)))
			{
				throw new Exception("Spawn is outside configured playable bounds.");
			}
			teleporters = Layout.teleporters;
			foreach (float[] p in teleporters)
			{
				if (!((Bounds)(ref PlayBounds)).Contains(HighriseLayout.V(p)))
				{
					throw new Exception("Teleporter candidate is outside configured playable bounds.");
				}
			}
			if (Layout.landmarks != null)
			{
				HighriseLandmark[] landmarks = Layout.landmarks;
				foreach (HighriseLandmark highriseLandmark in landmarks)
				{
					if (!((Bounds)(ref PlayBounds)).Contains(HighriseLayout.V(highriseLandmark.p)))
					{
						throw new Exception("Required landmark is outside configured playable bounds: " + highriseLandmark.name);
					}
				}
			}
		}
		Plugin.Log.LogInfo((object)string.Concat("HIGHRISE building native navigation authoredScale=", Layout.worldScale, " playableBounds=", PlayBounds, " collisionWorldBounds=", WorldBounds, " override=", Layout.playableMin != null, " solidColliders=", num, " runtimeScaleApplied=False"));
		Physics.SyncTransforms();
		ConfigureLighting();
		if (Plugin.Testing)
		{
			CaptureViews(null);
		}
		GroundResult = ((Plugin.Testing && !Plugin.CachedNavigationTest) ? null : NavigationCache.Load("ground"));
		if (GroundResult == null)
		{
			GroundResult = Navigation.BuildGround(Layout, PlayBounds);
			NavigationCache.Save("ground", GroundResult);
		}
		Ground = GroundResult.positions;
		owned.Add((Object)(object)GroundResult.graph);
		AirResult = ((Plugin.Testing && !Plugin.CachedNavigationTest) ? null : NavigationCache.Load("air"));
		if (AirResult == null)
		{
			AirResult = Navigation.BuildAir(Layout, PlayBounds);
			NavigationCache.Save("air", AirResult);
		}
		owned.Add((Object)(object)AirResult.graph);
		MapZones();
		if (!Plugin.Testing || Plugin.GameplayTest)
		{
			Systems();
		}
		Ready = true;
		Plugin.Log.LogInfo((object)string.Concat("HIGHRISE world ready colliders=", num, " bounds=", PlayBounds, " ground=", Ground.Count, " links=", GroundResult.links, " air=", AirResult.positions.Count, " excludedDisconnected=", GroundResult.excluded));
		if (Plugin.Testing)
		{
			WriteValidation();
		}
	}

	private void ConfigureLighting()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Invalid comparison between Unknown and I4
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: 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_019a: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0336: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: 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_03d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ea: Invalid comparison between Unknown and I4
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		//IL_044b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0450: Unknown result type (might be due to invalid IL or missing references)
		//IL_0455: Unknown result type (might be due to invalid IL or missing references)
		//IL_0477: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_052d: Unknown result type (might be due to invalid IL or missing references)
		if ((int)SystemInfo.graphicsDeviceType == 4)
		{
			return;
		}
		Vector3 val = HighriseLayout.V(Layout.sourceSunDirection);
		Vector3 val2 = HighriseLayout.V(Layout.sourceSkyColor);
		Vector3 val3 = HighriseLayout.V(Layout.sourceSunColor);
		if (((Vector3)(ref val)).sqrMagnitude < 0.001f || !FiniteNonnegative(Layout.sourceSkyIntensity) || !FiniteNonnegative(Layout.sourceAmbientIntensity) || !FiniteNonnegative(Layout.sunIntensity))
		{
			throw new Exception("Invalid original Highrise actor-lighting values.");
		}
		if (val2.x < 0f || val2.y < 0f || val2.z < 0f || val3.x < 0f || val3.y < 0f || val3.z < 0f)
		{
			throw new Exception("Highrise light colours must be nonnegative.");
		}
		((Vector3)(ref val)).Normalize();
		Color val4 = default(Color);
		((Color)(ref val4))..ctor(val2.x, val2.y, val2.z);
		Color val5 = val4 * Layout.sourceAmbientIntensity;
		ManualLogSource log = Plugin.Log;
		object[] array = new object[8] { "HIGHRISE SH before configuration activeScene=", null, null, null, null, null, null, null };
		object[] array2 = array;
		Scene val6 = SceneManager.GetActiveScene();
		array2[1] = ((Scene)(ref val6)).name;
		array[2] = " targetScene=";
		object[] array3 = array;
		val6 = ((Component)this).gameObject.scene;
		array3[3] = ((Scene)(ref val6)).name;
		array[4] = " ambientMode=";
		array[5] = RenderSettings.ambientMode;
		array[6] = " coefficients=";
		array[7] = Coefficients(RenderSettings.ambientProbe);
		log.LogInfo((object)string.Concat(array));
		RenderSettings.ambientIntensity = 1f;
		RenderSettings.ambientSkyColor = val4 * (Layout.sourceSkyIntensity + Layout.sourceAmbientIntensity);
		RenderSettings.ambientEquatorColor = val5;
		RenderSettings.ambientGroundColor = val5;
		RenderSettings.ambientLight = val5;
		RenderSettings.ambientMode = (AmbientMode)4;
		SphericalHarmonicsL2 val7 = default(SphericalHarmonicsL2);
		Plugin.Log.LogInfo((object)string.Concat("HIGHRISE SH before AddAmbientLight input=", val5, " coefficients=", Coefficients(val7)));
		((SphericalHarmonicsL2)(ref val7)).AddAmbientLight(val5);
		Plugin.Log.LogInfo((object)("HIGHRISE SH after AddAmbientLight coefficients=" + Coefficients(val7)));
		((SphericalHarmonicsL2)(ref val7)).AddDirectionalLight(Vector3.up, val4, Layout.sourceSkyIntensity);
		Plugin.Log.LogInfo((object)string.Concat("HIGHRISE SH after AddDirectionalLight direction=up color=", val4, " intensity=", Layout.sourceSkyIntensity, " coefficients=", Coefficients(val7)));
		RenderSettings.ambientProbe = val7;
		Plugin.Log.LogInfo((object)string.Concat("HIGHRISE SH assigned/readback ambientMode=", RenderSettings.ambientMode, " ambientLight=", RenderSettings.ambientLight, " sky=", RenderSettings.ambientSkyColor, " equator=", RenderSettings.ambientEquatorColor, " ground=", RenderSettings.ambientGroundColor, " coefficients=", Coefficients(RenderSettings.ambientProbe)));
		Light val8 = null;
		Light[] array4 = Object.FindObjectsOfType<Light>();
		foreach (Light val9 in array4)
		{
			if (((Component)val9).gameObject.scene == ((Component)this).gameObject.scene && (int)val9.type == 1 && ((Behaviour)val9).enabled)
			{
				val8 = val9;
				break;
			}
		}
		if (!Object.op_Implicit((Object)(object)val8))
		{
			val8 = Child("Highrise | original source sun for native actors").AddComponent<Light>();
		}
		val8.type = (LightType)1;
		((Component)val8).transform.rotation = Quaternion.LookRotation(-val, Vector3.up);
		val8.color = new Color(val3.x, val3.y, val3.z);
		val8.intensity = Layout.sunIntensity;
		val8.shadows = (LightShadows)2;
		val8.renderMode = (LightRenderMode)1;
		RenderSettings.sun = val8;
		Plugin.Log.LogInfo((object)string.Concat("HIGHRISE actor lighting sourceToLight=", val, " lightForward=", ((Component)val8).transform.forward, " sunColor=", val8.color, " sunIntensity=", val8.intensity, " skyColor=", val4, " skyIntensity=", Layout.sourceSkyIntensity, " ambientIntensity=", Layout.sourceAmbientIntensity, " bakedWorldUnchanged=True"));
	}

	private static string Coefficients(SphericalHarmonicsL2 value)
	{
		string[] array = new string[3];
		for (int i = 0; i < 3; i++)
		{
			string[] array2 = new string[9];
			for (int j = 0; j < 9; j++)
			{
				array2[j] = ((SphericalHarmonicsL2)(ref value))[i, j].ToString("R", CultureInfo.InvariantCulture);
			}
			array[i] = "[" + string.Join(",", array2) + "]";
		}
		return string.Join(";", array);
	}

	private static bool FiniteNonnegative(float value)
	{
		return !float.IsNaN(value) && !float.IsInfinity(value) && value >= 0f;
	}

	private void MapZones()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Child("Highrise | native fall recovery");
		val.layer = LayerIndex.collideWithCharacterHullOnly.intVal;
		val.transform.position = new Vector3(((Bounds)(ref PlayBounds)).center.x, ((Bounds)(ref PlayBounds)).min.y - 22f, ((Bounds)(ref PlayBounds)).center.z);
		BoxCollider val2 = val.AddComponent<BoxCollider>();
		val2.size = new Vector3(((Bounds)(ref PlayBounds)).size.x + 160f, 36f, ((Bounds)(ref PlayBounds)).size.z + 160f);
		((Collider)val2).isTrigger = true;
		MapZone val3 = val.AddComponent<MapZone>();
		val3.triggerType = (TriggerType)1;
		val3.zoneType = (ZoneType)0;
		GameObject val4 = Child("Highrise | native outer bounds");
		val4.layer = LayerIndex.collideWithCharacterHullOnly.intVal;
		val4.transform.position = ((Bounds)(ref PlayBounds)).center + Vector3.up * 15f;
		val2 = val4.AddComponent<BoxCollider>();
		val2.size = new Vector3(((Bounds)(ref PlayBounds)).size.x + 180f, ((Bounds)(ref PlayBounds)).size.y + 180f, ((Bounds)(ref PlayBounds)).size.z + 180f);
		((Collider)val2).isTrigger = true;
		val3 = val4.AddComponent<MapZone>();
		val3.triggerType = (TriggerType)0;
		val3.zoneType = (ZoneType)0;
	}

	private void Systems()
	{
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0445: Unknown result type (might be due to invalid IL or missing references)
		//IL_044c: Expected O, but got Unknown
		//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_055c: Unknown result type (might be due to invalid IL or missing references)
		//IL_057a: Unknown result type (might be due to invalid IL or missing references)
		//IL_057c: Unknown result type (might be due to invalid IL or missing references)
		NodeGraph graph = GroundResult.graph;
		NodeGraph graph2 = AirResult.graph;
		GameObject val = Child("StageInfo");
		val.SetActive(false);
		SceneInfo val2 = val.AddComponent<SceneInfo>();
		Native.Set(val2, "groundNodesAsset", graph);
		Native.Set(val2, "airNodesAsset", graph2);
		ClassicStageInfo val3 = val.AddComponent<ClassicStageInfo>();
		val3.SetMonsterDCCSP(CloneMonsterPool(Native.Load<DccsPool>("RoR2/Base/foggyswamp/dpFoggySwampMonsters.asset")));
		val3.SetInteractableDCCSP(Native.Load<DccsPool>("RoR2/Base/foggyswamp/dpFoggySwampInteractables.asset"));
		val3.sceneDirectorInteractibleCredits = 220;
		val3.sceneDirectorMonsterCredits = 20;
		val3.bonusInteractibleCreditObjects = (BonusInteractibleCreditObject[])(object)new BonusInteractibleCreditObject[0];
		val.SetActive(true);
		if (!Object.op_Implicit((Object)(object)val2.groundNodes) || !Object.op_Implicit((Object)(object)val2.airNodes))
		{
			throw new Exception("Native SceneInfo did not instantiate both Highrise graphs.");
		}
		FieldInfo field = typeof(NodeGraph).GetField("openGates", BindingFlags.Instance | BindingFlags.NonPublic);
		if (field == null || field.FieldType != typeof(bool[]))
		{
			throw new MissingFieldException("NodeGraph", "openGates");
		}
		NodeGraph[][] array = new NodeGraph[2][]
		{
			(NodeGraph[])(object)new NodeGraph[2] { graph, val2.groundNodes },
			(NodeGraph[])(object)new NodeGraph[2] { graph2, val2.airNodes }
		};
		foreach (NodeGraph[] array2 in array)
		{
			if (!(field.GetValue(array2[0]) is bool[] array3) || array3.Length != 256)
			{
				throw new Exception("Highrise source graph has invalid native gate state.");
			}
			Native.Set(array2[1], "openGates", (bool[])array3.Clone());
		}
		GroundResult.graph = val2.groundNodes;
		AirResult.graph = val2.airNodes;
		Plugin.Log.LogInfo((object)("HIGHRISE adopted native SceneInfo graph clones groundAssetId=" + ((Object)graph).GetInstanceID() + " groundRuntimeId=" + ((Object)GroundResult.graph).GetInstanceID() + " airAssetId=" + ((Object)graph2).GetInstanceID() + " airRuntimeId=" + ((Object)AirResult.graph).GetInstanceID() + " gateStatesCopied=True nativeSceneInfoOwnsRuntimeGraphs=True"));
		if (!Object.op_Implicit((Object)(object)GlobalEventManager.instance))
		{
			Child("Native gameplay events").AddComponent<GlobalEventManager>();
		}
		List<Vector3> list = new List<Vector3>();
		Vector3 spawn = HighriseLayout.V(Layout.spawn);
		foreach (Vector3 item in Ground)
		{
			Vector3 val4 = item - spawn;
			if (((Vector3)(ref val4)).sqrMagnitude < 64f && Navigation.Clear(item, (HullClassification)0))
			{
				list.Add(item);
			}
		}
		list.Sort(delegate(Vector3 a, Vector3 b)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val10 = a - spawn;
			float sqrMagnitude = ((Vector3)(ref val10)).sqrMagnitude;
			val10 = b - spawn;
			return sqrMagnitude.CompareTo(((Vector3)(ref val10)).sqrMagnitude);
		});
		if (list.Count == 0)
		{
			throw new Exception("No supported survivor spawn positions.");
		}
		for (int num = 0; num < Mathf.Min(8, list.Count); num++)
		{
			GameObject val5 = Child("Highrise arrival " + num);
			val5.transform.position = list[num] + Vector3.up * 0.2f;
			val5.AddComponent<SpawnPoint>();
		}
		Child("DirectorCore").AddComponent<DirectorCore>();
		val = Child("Native directors");
		val.SetActive(false);
		SceneDirector val6 = val.AddComponent<SceneDirector>();
		val6.usePlacedSpawnPoints = true;
		val6.teleporterSpawnCard = Native.Load<SpawnCard>("RoR2/Base/Teleporters/iscTeleporter.asset");
		DirectorCard val7 = new DirectorCard();
		val7.spawnCard = (SpawnCard)(object)Native.Load<InteractableSpawnCard>("RoR2/CU8/LemurianEgg/iscLemurianEgg.asset");
		val7.selectionWeight = 1;
		val6.lumerianEgg = val7;
		val6.expRewardCoefficient = 0.2f;
		val6.eliteBias = 1f;
		val6.spawnDistanceMultiplier = 1f;
		CombatDirector val8 = val.AddComponent<CombatDirector>();
		val8.customName = "Highrise slow waves";
		val8.creditMultiplier = 0.75f;
		val8.moneyWaveIntervals = (RangeFloat[])(object)new RangeFloat[1]
		{
			new RangeFloat
			{
				min = 4f,
				max = 6f
			}
		};
		val8.minSeriesSpawnInterval = 0.5f;
		val8.maxSeriesSpawnInterval = 2f;
		val8.minRerollSpawnInterval = 22f;
		val8.maxRerollSpawnInterval = 30f;
		val8.skipSpawnIfTooCheap = true;
		CombatDirector val9 = val.AddComponent<CombatDirector>();
		val9.customName = "Highrise fast waves";
		val9.creditMultiplier = 0.75f;
		val9.moneyWaveIntervals = (RangeFloat[])(object)new RangeFloat[1]
		{
			new RangeFloat
			{
				min = 2f,
				max = 4f
			}
		};
		val9.minSeriesSpawnInterval = 0.1f;
		val9.maxSeriesSpawnInterval = 1f;
		val9.minRerollSpawnInterval = 2f;
		val9.maxRerollSpawnInterval = 4f;
		((MonoBehaviour)this).StartCoroutine(EnableDirectors(val));
	}

	private DccsPool CloneMonsterPool(DccsPool source)
	{
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Expected O, but got Unknown
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)source) || source.poolCategories == null)
		{
			throw new Exception("Native Highrise monster pool is unavailable.");
		}
		DccsPool val = Object.Instantiate<DccsPool>(source);
		((Object)val).name = "Highrise | rooftop native monsters";
		owned.Add((Object)(object)val);
		MonsterPoolAudit monsterPoolAudit = new MonsterPoolAudit();
		monsterPoolAudit.vagrant = FindNativeVagrant(source);
		if (monsterPoolAudit.vagrant == null)
		{
			throw new Exception("The native Highrise source pool has no AIR Vagrant champion card.");
		}
		SpawnCard spawnCard = monsterPoolAudit.vagrant.GetSpawnCard();
		ValidateVagrantAirNodes((CharacterSpawnCard)(object)((spawnCard is CharacterSpawnCard) ? spawnCard : null));
		SpawnCard spawnCard2 = monsterPoolAudit.vagrant.GetSpawnCard();
		ValidateGroundBosses(source, (CharacterSpawnCard)(object)((spawnCard2 is CharacterSpawnCard) ? spawnCard2 : null));
		Dictionary<DirectorCardCategorySelection, DirectorCardCategorySelection> selections = new Dictionary<DirectorCardCategorySelection, DirectorCardCategorySelection>();
		List<Category> list = new List<Category>();
		Category[] poolCategories = source.poolCategories;
		foreach (Category val2 in poolCategories)
		{
			if (val2 == null)
			{
				continue;
			}
			Category val3 = new Category();
			val3.name = val2.name;
			val3.categoryWeight = val2.categoryWeight;
			Category val4 = val3;
			val4.alwaysIncluded = CloneMonsterEntries(val2.alwaysIncluded, selections, monsterPoolAudit);
			val4.includedIfNoConditionsMet = CloneMonsterEntries(val2.includedIfNoConditionsMet, selections, monsterPoolAudit);
			List<ConditionalPoolEntry> list2 = new List<ConditionalPoolEntry>();
			if (val2.includedIfConditionsMet != null)
			{
				ConditionalPoolEntry[] includedIfConditionsMet = val2.includedIfConditionsMet;
				foreach (ConditionalPoolEntry val5 in includedIfConditionsMet)
				{
					if (val5 != null)
					{
						DirectorCardCategorySelection val6 = CloneMonsterSelection(((PoolEntry)val5).dccs, selections, monsterPoolAudit);
						if (Object.op_Implicit((Object)(object)val6))
						{
							ConditionalPoolEntry val7 = new ConditionalPoolEntry();
							((PoolEntry)val7).dccs = val6;
							((PoolEntry)val7).weight = ((PoolEntry)val5).weight;
							val7.requiredExpansions = (ExpansionDef[])((val5.requiredExpansions == null) ? ((Array)new ExpansionDef[0]) : ((Array)(ExpansionDef[])val5.requiredExpansions.Clone()));
							list2.Add(val7);
						}
					}
				}
			}
			val4.includedIfConditionsMet = list2.ToArray();
			if (val4.alwaysIncluded.Length + val4.includedIfNoConditionsMet.Length + val4.includedIfConditionsMet.Length > 0)
			{
				list.Add(val4);
			}
		}
		val.poolCategories = list.ToArray();
		if (val.poolCategories.Length == 0)
		{
			throw new Exception("No native monster selections remain after the Highrise hull filter.");
		}
		Plugin.Log.LogInfo((object)("HIGHRISE stage-local native monster pool retainsAIRVagrant=True nativeCardHullUnchanged=True nativeBodiesAndAIUnchanged=True excludedUnverifiedLargeHullCards=" + monsterPoolAudit.removed.Count + " removed=[" + string.Join(", ", monsterPoolAudit.removed) + "] nativeVagrantChampionFallbacks=[" + string.Join(", ", monsterPoolAudit.fallbacks) + "] sourcePool=" + ((Object)source).name + " sharedPoolsUnchanged=True"));
		return val;
	}

	private static DirectorCard CopyDirectorCard(DirectorCard original)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		DirectorCard val = new DirectorCard();
		FieldInfo[] fields = typeof(DirectorCard).GetFields(BindingFlags.Instance | BindingFlags.Public);
		foreach (FieldInfo fieldInfo in fields)
		{
			fieldInfo.SetValue(val, fieldInfo.GetValue(original));
		}
		return val;
	}

	private static CharacterBody NativeMonsterBody(SpawnCard spawn)
	{
		if (!Object.op_Implicit((Object)(object)spawn) || !Object.op_Implicit((Object)(object)spawn.prefab))
		{
			return null;
		}
		CharacterMaster component = spawn.prefab.GetComponent<CharacterMaster>();
		return (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.bodyPrefab)) ? component.bodyPrefab.GetComponent<CharacterBody>() : null;
	}

	private static DirectorCard FindNativeVagrant(DccsPool source)
	{
		Category[] poolCategories = source.poolCategories;
		foreach (Category val in poolCategories)
		{
			if (val == null)
			{
				continue;
			}
			if (val.alwaysIncluded != null)
			{
				PoolEntry[] alwaysIncluded = val.alwaysIncluded;
				foreach (PoolEntry val2 in alwaysIncluded)
				{
					if (val2 != null)
					{
						DirectorCard val3 = FindNativeVagrant(val2.dccs);
						if (val3 != null)
						{
							return val3;
						}
					}
				}
			}
			if (val.includedIfNoConditionsMet != null)
			{
				PoolEntry[] alwaysIncluded = val.includedIfNoConditionsMet;
				foreach (PoolEntry val2 in alwaysIncluded)
				{
					if (val2 != null)
					{
						DirectorCard val3 = FindNativeVagrant(val2.dccs);
						if (val3 != null)
						{
							return val3;
						}
					}
				}
			}
			if (val.includedIfConditionsMet == null)
			{
				continue;
			}
			ConditionalPoolEntry[] includedIfConditionsMet = val.includedIfConditionsMet;
			foreach (ConditionalPoolEntry val4 in includedIfConditionsMet)
			{
				if (val4 != null)
				{
					DirectorCard val3 = FindNativeVagrant(((PoolEntry)val4).dccs);
					if (val3 != null)
					{
						return val3;
					}
				}
			}
		}
		return null;
	}

	private static DirectorCard FindNativeVagrant(DirectorCardCategorySelection source)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Invalid comparison between Unknown and I4
		if (!Object.op_Implicit((Object)(object)source) || source.categories == null)
		{
			return null;
		}
		Category[] categories = source.categories;
		for (int i = 0; i < categories.Length; i++)
		{
			Category val = categories[i];
			if (val.cards == null)
			{
				continue;
			}
			DirectorCard[] cards = val.cards;
			foreach (DirectorCard val2 in cards)
			{
				if (val2 != null)
				{
					DirectorCard val3 = CopyDirectorCard(val2);
					SpawnCard spawnCard = val3.GetSpawnCard();
					CharacterBody val4 = NativeMonsterBody(spawnCard);
					if (spawnCard is CharacterSpawnCard && (int)spawnCard.nodeGraphType == 1 && Object.op_Implicit((Object)(object)val4) && ((Object)val4).name == "VagrantBody" && val4.isChampion)
					{
						return val3;
					}
				}
			}
		}
		return null;
	}

	private void ValidateVagrantAirNodes(CharacterSpawnCard spawn)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Invalid comparison between Unknown and I4
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Invalid comparison between Unknown and I4
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Invalid comparison between I4 and Unknown
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0311: Unknown result type (might be due to invalid IL or missing references)
		//IL_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0336: Unknown result type (might be due to invalid IL or missing references)
		//IL_033b: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0370: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		//IL_0382: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_038b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0392: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_051e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0520: Unknown result type (might be due to invalid IL or missing references)
		//IL_0488: Unknown result type (might be due to invalid IL or missing references)
		//IL_048a: Unknown result type (might be due to invalid IL or missing references)
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		//IL_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0451: Unknown result type (might be due to invalid IL or missing references)
		//IL_0452: Unknown result type (might be due to invalid IL or missing references)
		//IL_046a: Unknown result type (might be due to invalid IL or missing references)
		//IL_046f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0471: Unknown result type (might be due to invalid IL or missing references)
		//IL_0472: Unknown result type (might be due to invalid IL or missing references)
		//IL_053c: Unknown result type (might be due to invalid IL or missing references)
		//IL_055a: Unknown result type (might be due to invalid IL or missing references)
		//IL_055f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0560: Unknown result type (might be due to invalid IL or missing references)
		//IL_0562: Unknown result type (might be due to invalid IL or missing references)
		//IL_0564: Invalid comparison between Unknown and I4
		//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ee: Invalid comparison between Unknown and I4
		//IL_0580: Unknown result type (might be due to invalid IL or missing references)
		//IL_0582: Unknown result type (might be due to invalid IL or missing references)
		//IL_0583: Unknown result type (might be due to invalid IL or missing references)
		//IL_0589: Expected I4, but got Unknown
		//IL_0598: Unknown result type (might be due to invalid IL or missing references)
		//IL_059a: Unknown result type (might be due to invalid IL or missing references)
		//IL_059b: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a1: Expected I4, but got Unknown
		//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_062a: Unknown result type (might be due to invalid IL or missing references)
		//IL_062f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0631: Unknown result type (might be due to invalid IL or missing references)
		//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_064d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0652: Unknown result type (might be due to invalid IL or missing references)
		//IL_0654: Unknown result type (might be due to invalid IL or missing references)
		//IL_0655: Unknown result type (might be due to invalid IL or missing references)
		//IL_066d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0672: Unknown result type (might be due to invalid IL or missing references)
		//IL_0674: Unknown result type (might be due to invalid IL or missing references)
		//IL_0675: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f0: Invalid comparison between Unknown and I4
		//IL_09f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a38: Unknown result type (might be due to invalid IL or missing references)
		//IL_070c: Unknown result type (might be due to invalid IL or missing references)
		//IL_070e: Unknown result type (might be due to invalid IL or missing references)
		//IL_070f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0715: Expected I4, but got Unknown
		//IL_0724: Unknown result type (might be due to invalid IL or missing references)
		//IL_0726: Unknown result type (might be due to invalid IL or missing references)
		//IL_0727: Unknown result type (might be due to invalid IL or missing references)
		//IL_072d: Expected I4, but got Unknown
		//IL_0779: Unknown result type (might be due to invalid IL or missing references)
		//IL_077e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0789: Unknown result type (might be due to invalid IL or missing references)
		//IL_078e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0798: Unknown result type (might be due to invalid IL or missing references)
		//IL_079d: Unknown result type (might be due to invalid IL or missing references)
		//IL_079f: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a1: Invalid comparison between Unknown and I4
		//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07da: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody val = NativeMonsterBody((SpawnCard)(object)spawn);
		CapsuleCollider val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<CapsuleCollider>() : null);
		if (!Object.op_Implicit((Object)(object)spawn) || (int)((SpawnCard)spawn).nodeGraphType != 1 || (int)((SpawnCard)spawn).hullSize != 2 || !Object.op_Implicit((Object)(object)val) || ((Object)val).name != "VagrantBody" || !Object.op_Implicit((Object)(object)val2) || !((Collider)val2).enabled || ((Collider)val2).isTrigger || val2.direction != 1)
		{
			throw new Exception("Installed native Vagrant card/body no longer matches the verified AIR/BeetleQueen upright root-capsule configuration.");
		}
		if (AirResult == null || !Object.op_Implicit((Object)(object)AirResult.graph))
		{
			throw new Exception("Native Vagrant requires the completed Highrise AIR graph.");
		}
		Physics.SyncTransforms();
		FieldInfo field = typeof(NodeGraph).GetField("nodes", BindingFlags.Instance | BindingFlags.NonPublic);
		Node[] array = ((field == null) ? null : (field.GetValue(AirResult.graph) as Node[]));
		if (array == null || array.Length != AirResult.positions.Count || AirResult.forbidden == null || AirResult.forbidden.Length != array.Length)
		{
			throw new Exception("Highrise AIR graph node/forbidden data is inconsistent.");
		}
		Vector3 lossyScale = ((Component)val).transform.lossyScale;
		float num = val2.radius * Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z));
		float num2 = Mathf.Max(val2.height * Mathf.Abs(lossyScale.y), num * 2f);
		Vector3 val3 = Vector3.Scale(val2.center, lossyScale);
		float num3 = num2 * 0.5f - num;
		if (num <= 0f || num2 <= 0f || float.IsNaN(num) || float.IsNaN(num2) || float.IsInfinity(num) || float.IsInfinity(num2))
		{
			throw new Exception("Native Vagrant physical capsule dimensions are invalid.");
		}
		HullMask val4 = (HullMask)(1 << (int)((SpawnCard)spawn).hullSize);
		int num4 = 0;
		int num5 = 0;
		int num6 = 0;
		int num7 = 0;
		int[] array2 = new int[Layout.teleporters.Length];
		bool[] array3 = new bool[array.Length];
		bool[] array4 = new bool[array.Length];
		Vector3[] array5 = (Vector3[])(object)new Vector3[array.Length];
		string[] array6 = new string[array.Length];
		Result val7 = default(Result);
		for (int i = 0; i < array.Length; i++)
		{
			if ((array[i].forbiddenHulls & val4) != 0 || (byte)(array[i].flags & ((SpawnCard)spawn).forbiddenFlags) != 0 || (byte)(array[i].flags & ((SpawnCard)spawn).requiredFlags) != (int)((SpawnCard)spawn).requiredFlags)
			{
				continue;
			}
			num4++;
			array3[i] = true;
			Vector3 position = array[i].position;
			Vector3 val5 = Vector3.zero;
			bool flag = false;
			string text;
			if (!Util.IsPositionWithinMapBounds(position))
			{
				num6++;
				text = "native map bounds";
			}
			else
			{
				BodyPlacementHelper val6 = new BodyPlacementHelper
				{
					body = val,
					spawnPointPosition = position,
					spawnPointRotation = Quaternion.identity
				};
				((BodyPlacementHelper)(ref val6)).GetSpawnTransformation(ref val7);
				val5 = val7.bodyPosition;
				Vector3 val8 = val5 + val7.bodyRotation * val3 + Vector3.up * 0.02f;
				Vector3 val9 = val7.bodyRotation * Vector3.up;
				Vector3 val10 = val8 - val9 * num3;
				Vector3 val11 = val8 + val9 * num3;
				LayerIndex world = LayerIndex.world;
				bool flag2 = !Physics.CheckCapsule(val10, val11, num, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1);
				Vector3 val12 = position;
				float num8 = HullDef.Find(((SpawnCard)spawn).hullSize).radius * 0.7f;
				world = LayerIndex.world;
				bool flag3 = !HGPhysics.DoesOverlapSphere(val12, num8, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask) | LayerMask.op_Implicit(CommonMasks.characterBodiesOrDefault) | LayerMask.op_Implicit(CommonMasks.fakeActorLayers), (QueryTriggerInteraction)0);
				flag = flag2 && flag3;
				if (flag)
				{
					text = "native full body and placement sphere clear";
				}
				else
				{
					num7++;
					text = (flag2 ? "native placement sphere blocked" : "native full body overlaps world");
				}
			}
			if (!flag)
			{
				ref Node reference = ref array[i];
				reference.forbiddenHulls |= val4;
				ref HullMask reference2 = ref AirResult.forbidden[i];
				reference2 |= val4;
			}
			array4[i] = flag;
			array5[i] = val5;
			array6[i] = text;
		}
		FieldInfo field2 = typeof(NodeGraph).GetField("links", BindingFlags.Instance | BindingFlags.NonPublic);
		Link[] array7 = ((field2 == null) ? null : (field2.GetValue(AirResult.graph) as Link[]));
		if (array7 == null)
		{
			throw new Exception("Highrise AIR graph links are unavailable for native boss filtering.");
		}
		int num9 = 0;
		for (int i = 0; i < array7.Length; i++)
		{
			if ((array7[i].hullMask & val4) != 0 && ((array[array7[i].nodeIndexA.nodeIndex].forbiddenHulls | array[array7[i].nodeIndexB.nodeIndex].forbiddenHulls) & val4) != 0)
			{
				ref Link reference3 = ref array7[i];
				reference3.hullMask &= ~val4;
				ref Link reference4 = ref array7[i];
				reference4.jumpHullMask &= ~val4;
				num9++;
			}
		}
		bool[] array8 = new bool[array.Length];
		Link[] array9 = array7;
		for (int j = 0; j < array9.Length; j++)
		{
			Link val13 = array9[j];
			if ((val13.hullMask & val4) != 0)
			{
				array8[val13.nodeIndexA.nodeIndex] = true;
			}
		}
		int num10 = 0;
		for (int i = 0; i < array.Length; i++)
		{
			if ((array[i].forbiddenHulls & val4) == 0 && !array8[i])
			{
				ref Node reference5 = ref array[i];
				reference5.forbiddenHulls |= val4;
				ref HullMask reference6 = ref AirResult.forbidden[i];
				reference6 |= val4;
				num10++;
			}
		}
		for (int i = 0; i < array7.Length; i++)
		{
			if ((array7[i].hullMask & val4) != 0 && ((array[array7[i].nodeIndexA.nodeIndex].forbiddenHulls | array[array7[i].nodeIndexB.nodeIndex].forbiddenHulls) & val4) != 0)
			{
				ref Link reference7 = ref array7[i];
				reference7.hullMask &= ~val4;
				ref Link reference8 = ref array7[i];
				reference8.jumpHullMask &= ~val4;
				num9++;
			}
		}
		StringBuilder stringBuilder = new StringBuilder("node,x,y,z,nativePlacementBodyAndSphereClear,retainedBossEligible,bodyX,bodyY,bodyZ,reason\n");
		for (int i = 0; i < array.Length; i++)
		{
			if (!array3[i])
			{
				continue;
			}
			Vector3 position = array[i].position;
			Vector3 val5 = array5[i];
			bool flag4 = (array[i].forbiddenHulls & val4) == 0;
			if (flag4)
			{
				num5++;
				for (int k = 0; k < array2.Length; k++)
				{
					Vector3 val14 = position - HighriseLayout.V(Layout.teleporters[k]);
					float magnitude = ((Vector3)(ref val14)).magnitude;
					if (magnitude >= 25f && magnitude <= 40f && ((Vector3)(ref val14)).normalized.y <= 0.70710677f)
					{
						array2[k]++;
					}
				}
			}
			stringBuilder.Append(i).Append(',').Append(position.x.ToString("R", CultureInfo.InvariantCulture))
				.Append(',')
				.Append(position.y.ToString("R", CultureInfo.InvariantCulture))
				.Append(',')
				.Append(position.z.ToString("R", CultureInfo.InvariantCulture))
				.Append(',')
				.Append(array4[i] ? 1 : 0)
				.Append(',')
				.Append(flag4 ? 1 : 0)
				.Append(',')
				.Append(val5.x.ToString("R", CultureInfo.InvariantCulture))
				.Append(',')
				.Append(val5.y.ToString("R", CultureInfo.InvariantCulture))
				.Append(',')
				.Append(val5.z.ToString("R", CultureInfo.InvariantCulture))
				.Append(',')
				.Append((!flag4 && array4[i]) ? "no remaining native large-hull AIR links" : array6[i])
				.Append('\n');
		}
		Native.Set(AirResult.graph, "nodes", array);
		Native.Set(AirResult.graph, "links", array7);
		Plugin.Log.LogInfo((object)string.Concat("HIGHRISE native AIR boss fit card=", ((Object)spawn).name, " body=", ((Object)val).name, " nativeHull=", ((SpawnCard)spawn).hullSize, " capsuleRadius=", num, " capsuleHeight=", num2, " capsuleCenter=", val2.center, " eligibleNodes=", num4, " retainedBossNodes=", num5, " filteredNodes=", num4 - num5, " bodyOrNativeSphereBlocked=", num7, " outsideNativeBounds=", num6, " isolatedAfterFiltering=", num10, " filteredLargeHullLinks=", num9, " staticUnscaledBossRange25to40mPerTPCandidate=[", string.Join(",", Array.ConvertAll(array2, (int value) => value.ToString())), "] nativeCardAndBodyUnchanged=True nativeEncounterTestStillRequired=True"));
		if (Plugin.Testing)
		{
			File.WriteAllText(Path.Combine(Plugin.Folder, "highrise-native-vagrant-node-fit.csv"), stringBuilder.ToString());
		}
		if (num5 == 0)
		{
			throw new Exception("No native Vagrant boss-eligible AIR nodes fit its actual installed body collider.");
		}
		FilterTeleportersForNativeVagrant(array, spawn);
		for (int i = 0; i < array2.Length; i++)
		{
			if (array2[i] == 0)
			{
				Plugin.Log.LogWarning((object)("HIGHRISE native Vagrant static unscaled standard-range coverage is zero at layout teleporter candidate " + i + "; actual Director target, multipliers and occupied nodes require native encounter validation."));
			}
		}
	}

	private void FilterTeleportersForNativeVagrant(Node[] airNodes, CharacterSpawnCard spawn)
	{
		//IL_00a8: 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_00d3: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_021