Decompiled source of Wetland Rooftops v0.11.0

plugins/WetlandRooftops/WetlandRooftops.dll

Decompiled 12 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.Text;
using BepInEx;
using BepInEx.Logging;
using Newtonsoft.Json;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Navigation;
using RoR2.WwiseUtils;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.SceneManagement;

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

public sealed class DioramaView : MonoBehaviour
{
	private bool built;

	private void OnEnable()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		if (!built)
		{
			built = true;
			GameObject val = new GameObject("The village in miniature");
			val.transform.SetParent(((Component)this).transform, false);
			val.AddComponent<StageWorld>().BuildDiorama();
		}
	}
}
internal static class Navigation
{
	private static int World
	{
		get
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			LayerIndex world = LayerIndex.world;
			return LayerMask.op_Implicit(((LayerIndex)(ref world)).mask);
		}
	}

	private static Vector3 V(float[] p)
	{
		//IL_000a: 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_0012: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3(p[0], p[1], p[2]);
	}

	private static bool Clear(Vector3 p, int hull)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		HullDef val = HullDef.Find((HullClassification)hull);
		return !Physics.CheckCapsule(p + Vector3.up * (val.radius + 0.3f), p + Vector3.up * (val.height - val.radius + 0.3f), val.radius, World, (QueryTriggerInteraction)1);
	}

	private static bool Floor(Vector3 p)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		return Physics.Raycast(p + Vector3.up * 0.8f, Vector3.down, 1.8f, World, (QueryTriggerInteraction)1);
	}

	private static bool Wide(Vector3 p, float radius)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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)
		//IL_0020: 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_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		return Floor(p + Vector3.right * radius) && Floor(p - Vector3.right * radius) && Floor(p + Vector3.forward * radius) && Floor(p - Vector3.forward * radius);
	}

	internal static NodeGraph BuildGround(Layout layout, out List<Vector3> positions, out int linkCount, out int components)
	{
		//IL_0025: 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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: 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_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_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: 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_01ed: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: 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_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: 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_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: 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_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: 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_0490: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		Point[] nodes = layout.nodes;
		RaycastHit val2 = default(RaycastHit);
		Vector3 val3;
		foreach (Point point in nodes)
		{
			Vector3 val = V(point.p);
			if (!Physics.Raycast(val + Vector3.up, Vector3.down, ref val2, 2.5f, World, (QueryTriggerInteraction)1) || ((RaycastHit)(ref val2)).normal.y < 0.69f)
			{
				continue;
			}
			val = ((RaycastHit)(ref val2)).point + Vector3.up * 0.13f;
			if (!Clear(val, 0))
			{
				continue;
			}
			bool flag = false;
			foreach (Vector3 item in list)
			{
				val3 = item - val;
				if (((Vector3)(ref val3)).sqrMagnitude < 0.5f)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				list.Add(val);
			}
		}
		NodeFlags[] array = (NodeFlags[])(object)new NodeFlags[list.Count];
		HullMask[] array2 = (HullMask[])(object)new HullMask[list.Count];
		for (int j = 0; j < list.Count; j++)
		{
			Vector3 val = list[j];
			array[j] = (NodeFlags)0;
			if (!Physics.Raycast(val + Vector3.up * 0.5f, Vector3.up, 60f, World, (QueryTriggerInteraction)1))
			{
				ref NodeFlags reference = ref array[j];
				reference = (NodeFlags)(byte)(reference | 1);
			}
			if (!Wide(val, 2.5f))
			{
				ref NodeFlags reference2 = ref array[j];
				reference2 = (NodeFlags)(byte)(reference2 | 0x18);
			}
			nodes = layout.teleporters;
			foreach (Point point2 in nodes)
			{
				val3 = val - V(point2.p);
				if (((Vector3)(ref val3)).sqrMagnitude < 20f && Wide(val, 7f) && Clear(val, 2))
				{
					ref NodeFlags reference3 = ref array[j];
					reference3 = (NodeFlags)(byte)(reference3 | 2);
				}
			}
			for (int k = 1; k < 3; k++)
			{
				if (!Clear(val, k) || !Wide(val, HullDef.Find((HullClassification)k).radius + 0.2f))
				{
					ref HullMask reference4 = ref array2[j];
					reference4 = (HullMask)(reference4 | (1 << k));
				}
			}
		}
		List<Link>[] array3 = Connect(list, array2, air: false);
		AddJumpConnections(layout, list, array2, array3);
		bool[] array4 = new bool[list.Count];
		int num = 0;
		float num2 = float.PositiveInfinity;
		for (int j = 0; j < list.Count; j++)
		{
			val3 = list[j] - V(layout.spawn);
			float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
			if (sqrMagnitude < num2)
			{
				num2 = sqrMagnitude;
				num = j;
			}
		}
		Queue<int> queue = new Queue<int>();
		queue.Enqueue(num);
		array4[num] = true;
		while (queue.Count > 0)
		{
			foreach (Link item2 in array3[queue.Dequeue()])
			{
				int nodeIndex = item2.nodeIndexB.nodeIndex;
				if (!array4[nodeIndex] && (item2.hullMask & 1) != 0)
				{
					array4[nodeIndex] = true;
					queue.Enqueue(nodeIndex);
				}
			}
		}
		int num3 = 0;
		bool[] array5 = array4;
		for (int i = 0; i < array5.Length; i++)
		{
			if (!array5[i])
			{
				num3++;
			}
		}
		if (num3 > 12)
		{
			throw new Exception("Navigation disconnected from arrival: " + num3 + " nodes. Refusing to spawn a broken stage.");
		}
		if (num3 > 0)
		{
			List<Vector3> list2 = new List<Vector3>();
			List<NodeFlags> list3 = new List<NodeFlags>();
			List<HullMask> list4 = new List<HullMask>();
			for (int j = 0; j < list.Count; j++)
			{
				if (array4[j])
				{
					list2.Add(list[j]);
					list3.Add(array[j]);
					list4.Add(array2[j]);
				}
			}
			list = list2;
			array = list3.ToArray();
			array2 = list4.ToArray();
			array3 = Connect(list, array2, air: false);
			AddJumpConnections(layout, list, array2, array3);
			Plugin.Log.LogInfo((object)("Excluded " + num3 + " unreachable decorative-edge nodes from spawning."));
		}
		components = CountComponents(array3);
		linkCount = 0;
		List<Link>[] array6 = array3;
		foreach (List<Link> list5 in array6)
		{
			linkCount += list5.Count;
		}
		if (Plugin.Testing)
		{
			StringBuilder stringBuilder = new StringBuilder("index,x,y,z,flags,hulls\n");
			for (int j = 0; j < list.Count; j++)
			{
				StringBuilder stringBuilder2 = stringBuilder;
				object[] array7 = new object[11]
				{
					j, ",", null, null, null, null, null, null, null, null,
					null
				};
				object[] array8 = array7;
				float x = list[j].x;
				array8[2] = x.ToString(CultureInfo.InvariantCulture);
				array7[3] = ",";
				object[] array9 = array7;
				x = list[j].y;
				array9[4] = x.ToString(CultureInfo.InvariantCulture);
				array7[5] = ",";
				object[] array10 = array7;
				x = list[j].z;
				array10[6] = x.ToString(CultureInfo.InvariantCulture);
				array7[7] = ",";
				array7[8] = (int)array[j];
				array7[9] = ",";
				array7[10] = (int)array2[j];
				stringBuilder2.AppendLine(string.Concat(array7));
			}
			File.WriteAllText(Path.Combine(Plugin.Folder, "ground-nodes.csv"), stringBuilder.ToString());
			stringBuilder = new StringBuilder("a,b,hulls,jumpHulls,minJumpHeight\n");
			array6 = array3;
			foreach (List<Link> list6 in array6)
			{
				foreach (Link item3 in list6)
				{
					StringBuilder stringBuilder3 = stringBuilder;
					object[] array7 = new object[9]
					{
						item3.nodeIndexA.nodeIndex,
						",",
						item3.nodeIndexB.nodeIndex,
						",",
						item3.hullMask,
						",",
						item3.jumpHullMask,
						",",
						null
					};
					object[] array11 = array7;
					float x = item3.minJumpHeight;
					array11[8] = x.ToString(CultureInfo.InvariantCulture);
					stringBuilder3.AppendLine(string.Concat(array7));
				}
			}
			File.WriteAllText(Path.Combine(Plugin.Folder, "ground-links.csv"), stringBuilder.ToString());
		}
		positions = list;
		return Graph(list, array3, array, array2, "Wetland Rooftops Ground");
	}

	private static void AddJumpConnections(Layout layout, List<Vector3> ps, HullMask[] forbidden, List<Link>[] lists)
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: 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_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		if (layout.jumpConnections == null)
		{
			return;
		}
		JumpConnection[] jumpConnections = layout.jumpConnections;
		foreach (JumpConnection jumpConnection in jumpConnections)
		{
			int num = -1;
			int num2 = -1;
			float num3 = 100f;
			float num4 = 100f;
			for (int j = 0; j < ps.Count; j++)
			{
				if (((uint)forbidden[j] & 1u) == 0)
				{
					Vector3 val = ps[j] - V(jumpConnection.a);
					float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
					val = ps[j] - V(jumpConnection.b);
					float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude;
					if (sqrMagnitude < num3)
					{
						num = j;
						num3 = sqrMagnitude;
					}
					if (sqrMagnitude2 < num4)
					{
						num2 = j;
						num4 = sqrMagnitude2;
					}
				}
			}
			if (num < 0 || num2 < 0 || num == num2 || num3 > 4f || num4 > 4f || Vector3.Distance(ps[num], ps[num2]) > 6.8f)
			{
				throw new Exception("No safe jump anchors for " + jumpConnection.name);
			}
			bool[] array = new bool[2] { false, true };
			foreach (bool flag in array)
			{
				int j = (flag ? num2 : num);
				int num5 = (flag ? num : num2);
				lists[j].Add(new Link
				{
					nodeIndexA = new NodeIndex(j),
					nodeIndexB = new NodeIndex(num5),
					distanceScore = Vector3.Distance(ps[j], ps[num5]),
					maxSlope = 90f,
					minJumpHeight = 3.2f,
					hullMask = 1,
					jumpHullMask = 1,
					gateIndex = 0
				});
			}
			Plugin.Log.LogInfo((object)("WRT jump connection " + jumpConnection.name + " distance=" + Vector3.Distance(ps[num], ps[num2])));
		}
	}

	internal static NodeGraph BuildAir()
	{
		//IL_00a1: 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_003d: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		Vector3 val = default(Vector3);
		for (int i = -164; i <= 164; i += 22)
		{
			for (int j = -164; j <= 164; j += 22)
			{
				for (int k = 124; k <= 210; k += 20)
				{
					((Vector3)(ref val))..ctor((float)i, (float)k, (float)j);
					if (Clear(val, 1))
					{
						list.Add(val);
					}
				}
			}
		}
		HullMask[] array = (HullMask[])(object)new HullMask[list.Count];
		for (int l = 0; l < array.Length; l++)
		{
			array[l] = (HullMask)((!Clear(list[l], 2)) ? 4 : 0);
		}
		List<Link>[] adj = Connect(list, array, air: true);
		return Graph(list, adj, (NodeFlags[])(object)new NodeFlags[list.Count], array, "Wetland Rooftops Air");
	}

	private static List<Link>[] Connect(List<Vector3> ps, HullMask[] forbidden, bool air)
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		List<Link>[] array = new List<Link>[ps.Count];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = new List<Link>();
		}
		float num = (air ? 33f : 5.5f);
		for (int i = 0; i < ps.Count; i++)
		{
			for (int j = i + 1; j < ps.Count; j++)
			{
				Vector3 val = ps[j] - ps[i];
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (magnitude > num || magnitude < 0.1f)
				{
					continue;
				}
				Vector2 val2;
				if (!air)
				{
					float num2 = Mathf.Abs(val.y);
					val2 = new Vector2(val.x, val.z);
					if (num2 > ((Vector2)(ref val2)).magnitude * 0.65f)
					{
						continue;
					}
				}
				if (!air)
				{
					bool flag = true;
					int num3 = Mathf.CeilToInt(magnitude / 0.65f);
					for (int k = 1; k < num3; k++)
					{
						if (!Floor(Vector3.Lerp(ps[i], ps[j], (float)k / (float)num3)))
						{
							flag = false;
							break;
						}
					}
					if (!flag)
					{
						continue;
					}
				}
				int num4 = 0;
				for (int l = 0; l < 3; l++)
				{
					if ((((uint)forbidden[i] | (uint)forbidden[j]) & (uint)(1 << l)) == 0)
					{
						HullDef val3 = HullDef.Find((HullClassification)l);
						Vector3 val4 = ps[i] + Vector3.up * (val3.radius + 0.35f);
						Vector3 val5 = ps[i] + Vector3.up * (val3.height - val3.radius + 0.35f);
						if (!Physics.CapsuleCast(val4, val5, val3.radius * 0.92f, ((Vector3)(ref val)).normalized, magnitude, World, (QueryTriggerInteraction)1))
						{
							num4 |= 1 << l;
						}
					}
				}
				if (num4 != 0)
				{
					List<Link> obj = array[i];
					Link item = new Link
					{
						nodeIndexA = new NodeIndex(i),
						nodeIndexB = new NodeIndex(j),
						distanceScore = magnitude,
						hullMask = num4,
						jumpHullMask = 0,
						gateIndex = 0
					};
					float y = val.y;
					val2 = new Vector2(val.x, val.z);
					item.maxSlope = Mathf.Abs(Mathf.Atan2(y, ((Vector2)(ref val2)).magnitude) * 57.29578f);
					obj.Add(item);
					array[j].Add(new Link
					{
						nodeIndexA = new NodeIndex(j),
						nodeIndexB = new NodeIndex(i),
						distanceScore = magnitude,
						hullMask = num4,
						jumpHullMask = 0,
						gateIndex = 0
					});
				}
			}
		}
		return array;
	}

	private static int CountComponents(List<Link>[] adj)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		bool[] array = new bool[adj.Length];
		int num = 0;
		for (int i = 0; i < adj.Length; i++)
		{
			if (array[i])
			{
				continue;
			}
			num++;
			Queue<int> queue = new Queue<int>();
			queue.Enqueue(i);
			array[i] = true;
			while (queue.Count > 0)
			{
				foreach (Link item in adj[queue.Dequeue()])
				{
					int nodeIndex = item.nodeIndexB.nodeIndex;
					if (!array[nodeIndex] && (item.hullMask & 1) != 0)
					{
						array[nodeIndex] = true;
						queue.Enqueue(nodeIndex);
					}
				}
			}
		}
		return num;
	}

	private static NodeGraph Graph(List<Vector3> ps, List<Link>[] adj, NodeFlags[] flags, HullMask[] forbidden, string name)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: 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_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		NodeGraph val = ScriptableObject.CreateInstance<NodeGraph>();
		((Object)val).name = name;
		Node[] array = (Node[])(object)new Node[ps.Count];
		List<Link> list = new List<Link>();
		SerializableBitArray[] array2 = (SerializableBitArray[])(object)new SerializableBitArray[ps.Count];
		for (int i = 0; i < ps.Count; i++)
		{
			array2[i] = new SerializableBitArray(ps.Count);
		}
		for (int i = 0; i < ps.Count; i++)
		{
			for (int j = i; j < ps.Count; j++)
			{
				bool flag = i == j || !Physics.Linecast(ps[i] + Vector3.up, ps[j] + Vector3.up, World, (QueryTriggerInteraction)1);
				array2[i][j] = flag;
				array2[j][i] = flag;
			}
		}
		for (int i = 0; i < ps.Count; i++)
		{
			ref Node reference = ref array[i];
			reference = new Node
			{
				position = ps[i],
				linkListIndex = new LinkListIndex
				{
					index = list.Count,
					size = (uint)adj[i].Count
				},
				forbiddenHulls = forbidden[i],
				lineOfSightMask = array2[i],
				flags = flags[i],
				gateIndex = 0
			};
			list.AddRange(adj[i]);
		}
		Assets.Set(val, "nodes", array);
		Assets.Set(val, "links", list.ToArray());
		Assets.Call(val, "Awake");
		return val;
	}
}
[BepInPlugin("local.wetlandrooftops", "Wetland Rooftops", "0.11.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource Log;

	internal static string Folder;

	internal static SceneDef Definition;

	internal static UnlockableDef EnvironmentLog;

	internal static UnlockableDef NewtLog;

	private AssetBundle bundle;

	internal static bool Testing;

	internal static bool GameplayTest;

	private bool testStarted;

	private float nextDiagnostic;

	private void Awake()
	{
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Expected O, but got Unknown
		//IL_0324: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		Testing = Array.IndexOf(Environment.GetCommandLineArgs(), "-wetland-test") >= 0;
		GameplayTest = Array.IndexOf(Environment.GetCommandLineArgs(), "-wetland-gameplay") >= 0;
		if (Testing)
		{
			Application.runInBackground = true;
			RoR2Application.CachedCoroutineWaitForEndOfFrame = null;
		}
		bundle = AssetBundle.LoadFromFile(Path.Combine(Folder, "wetlandrooftops.scene"));
		if (!Object.op_Implicit((Object)(object)bundle))
		{
			throw new Exception("Wetland Rooftops scene bundle failed to load.");
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Scene bundle loaded: " + string.Join(", ", bundle.GetAllScenePaths())));
		SceneDef val = Assets.Load<SceneDef>("RoR2/Base/foggyswamp/foggyswamp.asset");
		Definition = Object.Instantiate<SceneDef>(val);
		Definition.cachedName = "wetlandrooftops";
		Definition.baseSceneNameOverride = "wetlandrooftops";
		Definition.sceneAddress = null;
		Definition.nameToken = "WRT_TITLE";
		Definition.subtitleToken = "WRT_SUBTITLE";
		Definition.loreToken = "WRT_LORE";
		Definition.stageOrder = 2;
		Definition.sceneType = (SceneType)1;
		Definition.requiredExpansion = null;
		Definition.isOfflineScene = false;
		Definition.suppressPlayerEntry = false;
		Definition.suppressNpcEntry = false;
		Definition.blockOrbitalSkills = false;
		Definition.environmentColor = new Color(0.2f, 0.43f, 0.39f);
		Definition.portalSelectionMessageString = "WRT_SEER";
		Definition.shouldIncludeInLogbook = true;
		Definition.hasSafeStart = true;
		Texture2D val2 = new Texture2D(2, 2);
		ImageConversion.LoadImage(val2, File.ReadAllBytes(Path.Combine(Folder, "preview.png")));
		Definition.previewTexture = (Texture)(object)val2;
		Definition.previewTextureReference = null;
		Definition.portalMaterial = StageRegistration.MakeBazaarSeerMaterial(val2);
		Definition.portalMaterialReference = null;
		Definition.dioramaPrefabAddress = null;
		Definition.dioramaPrefab = MakeDiorama();
		EnvironmentLog = ScriptableObject.CreateInstance<UnlockableDef>();
		EnvironmentLog.cachedName = "Logs.Stages.wetlandrooftops";
		EnvironmentLog.nameToken = "WRT_TITLE";
		EnvironmentLog.getHowToUnlockString = () => "Find the Environment Log in Wetland Rooftops.";
		EnvironmentLog.getUnlockedString = () => "Recovered from above the mire.";
		NewtLog = ScriptableObject.CreateInstance<UnlockableDef>();
		NewtLog.cachedName = "NewtStatue.wetlandrooftops.0";
		NewtLog.hidden = true;
		LanguageAPI.Add("WRT_TITLE", "Wetland Rooftops");
		LanguageAPI.Add("WRT_SUBTITLE", "A Light Above the Mire");
		LanguageAPI.Add("WRT_SEER", "You dream of lanterns above an endless forest.");
		LanguageAPI.Add("WRT_LORE", "The ladders ended long before the lights did.\n\nFrom the marsh, we had mistaken them for stars. Up here, every light belonged to a window, every bridge to a home. The windmill was still turning. Someone had repaired its sail with three different colours of cloth.\n\nWe found no one.\n\nI left the lantern burning.");
		ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(StageContent.Register);
		if (((BaseUnityPlugin)this).Config.Bind<bool>("Stage", "NaturalStageSelection", true, "Appear as an alternate second stage, including later loops.").Value)
		{
			StageRegistration.RegisterSceneDefToNormalProgression(Definition, 1f, true, true);
		}
		SceneManager.sceneLoaded += OnSceneLoaded;
		RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnGameLoaded));
		if (Testing)
		{
			((MonoBehaviour)this).StartCoroutine(TestFallback());
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Wetland Rooftops registered as an alternate second stage.");
	}

	private GameObject MakeDiorama()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_0055: 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_006b: Expected O, but got Unknown
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Expected O, but got Unknown
		GameObject val = new GameObject("Wetland Rooftops logbook diorama");
		val.SetActive(false);
		Object.DontDestroyOnLoad((Object)(object)val);
		val.AddComponent<DioramaView>();
		GameObject val2 = new GameObject("Focus");
		val2.transform.SetParent(val.transform, false);
		val2.transform.localPosition = new Vector3(0f, 0.2f, 0f);
		GameObject val3 = new GameObject("Camera");
		val3.transform.SetParent(val.transform, false);
		val3.transform.localPosition = new Vector3(-5f, 4f, -6f);
		ModelPanelParameters val4 = val.AddComponent<ModelPanelParameters>();
		val4.focusPointTransform = val2.transform;
		val4.cameraPositionTransform = val3.transform;
		val4.minDistance = 3f;
		val4.maxDistance = 12f;
		val4.triggerOnLogbook = new UnityEvent();
		return val;
	}

	private void Update()
	{
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		if (Testing)
		{
			RoR2Application.CachedCoroutineWaitForEndOfFrame = null;
			if (GameplayTest && Object.op_Implicit((Object)(object)Run.instance) && Time.timeScale == 0f)
			{
				Time.timeScale = 1f;
			}
			if (!AkSoundEngine.IsInitialized())
			{
				typeof(SoundbankLoader).GetField("pendingLoads", BindingFlags.Static | BindingFlags.NonPublic).SetValue(null, 0);
			}
			if (Time.realtimeSinceStartup > nextDiagnostic)
			{
				nextDiagnostic = Time.realtimeSinceStartup + 15f;
				ManualLogSource log = Log;
				object[] array = new object[8]
				{
					"WRT TEST heartbeat time=",
					Time.realtimeSinceStartup,
					" scene=",
					null,
					null,
					null,
					null,
					null
				};
				Scene activeScene = SceneManager.GetActiveScene();
				array[3] = ((Scene)(ref activeScene)).name;
				array[4] = " catalog=";
				array[5] = RoR2Application.loadFinished;
				array[6] = " loaded=";
				array[7] = RoR2Application.loadFinished;
				log.LogInfo((object)string.Concat(array));
			}
		}
	}

	private void OnGameLoaded()
	{
		if (Testing && !testStarted)
		{
			((MonoBehaviour)this).StartCoroutine(GameplayTest ? TestGameplay() : TestLoad());
		}
	}

	private IEnumerator TestFallback()
	{
		yield return (object)new WaitForSecondsRealtime(150f);
		if (!testStarted)
		{
			Log.LogError((object)("WRT TEST initialization timeout, catalog count=" + RoR2Application.loadFinished));
			Application.Quit();
		}
	}

	private IEnumerator TestGameplay()
	{
		testStarted = true;
		Log.LogInfo((object)("WRT TEST native initialization finished; catalog=" + SceneCatalog.allSceneDefs.Length + " custom=" + SceneCatalog.FindSceneDef("wetlandrooftops")));
		yield return (object)new WaitForSecondsRealtime(2f);
		Console.instance.SubmitCmd((NetworkUser)null, "host 0", false);
		yield return (object)new WaitForSecondsRealtime(8f);
		Log.LogInfo((object)("WRT TEST server=" + NetworkServer.active + " pregame=" + PreGameController.instance));
		Console.instance.SubmitCmd((NetworkUser)null, "pregame_start_run", false);
		yield return (object)new WaitForSecondsRealtime(15f);
		Log.LogInfo((object)("WRT TEST run=" + Run.instance));
		VehicleSeat[] array = Object.FindObjectsOfType<VehicleSeat>();
		foreach (VehicleSeat val in array)
		{
			if (val.hasPassenger)
			{
				val.EjectPassenger();
			}
		}
		if (Object.op_Implicit((Object)(object)Run.instance))
		{
			Run.instance.AdvanceStage(Definition);
		}
		yield return (object)new WaitForSecondsRealtime(14f);
		Layout testLayout = JsonConvert.DeserializeObject<Layout>(File.ReadAllText(Path.Combine(Folder, "layout.json")));
		CharacterBody player = null;
		foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
		{
			if (readOnlyInstances.isPlayerControlled)
			{
				player = readOnlyInstances;
				break;
			}
		}
		array = Object.FindObjectsOfType<VehicleSeat>();
		foreach (VehicleSeat val in array)
		{
			if (val.hasPassenger)
			{
				val.EjectPassenger();
			}
		}
		if (!Object.op_Implicit((Object)(object)player))
		{
			foreach (NetworkUser readOnlyInstances2 in NetworkUser.readOnlyInstancesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyInstances2.master))
				{
					player = readOnlyInstances2.master.GetBody();
					if (!Object.op_Implicit((Object)(object)player))
					{
						player = readOnlyInstances2.master.Respawn(new Vector3(testLayout.spawn[0], testLayout.spawn[1] + 1f, testLayout.spawn[2]), Quaternion.identity, false);
					}
					break;
				}
			}
		}
		yield return (object)new WaitForSecondsRealtime(3f);
		array = Object.FindObjectsOfType<VehicleSeat>();
		foreach (VehicleSeat val in array)
		{
			if (val.hasPassenger)
			{
				val.EjectPassenger();
			}
		}
		yield return (object)new WaitForSecondsRealtime(1f);
		foreach (CharacterBody readOnlyInstances3 in CharacterBody.readOnlyInstancesList)
		{
			Log.LogInfo((object)string.Concat("WRT TEST body=", ((Object)readOnlyInstances3).name, " team=", readOnlyInstances3.teamComponent.teamIndex, " controlled=", readOnlyInstances3.isPlayerControlled, " authority=", readOnlyInstances3.hasEffectiveAuthority, " motor=", Object.op_Implicit((Object)(object)readOnlyInstances3.characterMotor) && ((Behaviour)readOnlyInstances3.characterMotor).enabled, " vehicle=", readOnlyInstances3.currentVehicle, " timeScale=", Time.timeScale));
		}
		TeleporterInteraction tp = TeleporterInteraction.instance;
		Log.LogInfo((object)string.Concat("WRT TEST systems stage=", Stage.instance, " definition=", Object.op_Implicit((Object)(object)Stage.instance) ? Stage.instance.sceneDef : null, " sceneInfo=", SceneInfo.instance, " purchases=", Object.FindObjectsOfType<PurchaseInteraction>().Length, " bodies=", CharacterBody.readOnlyInstancesList.Count));
		Time.timeScale = 1f;
		if (Object.op_Implicit((Object)(object)player))
		{
			player.AddTimedBuff(Buffs.HiddenInvincibility, 400f);
			TeleportHelper.TeleportBody(player, new Vector3(testLayout.spawn[0], 70f, testLayout.spawn[2]));
			yield return (object)new WaitForSecondsRealtime(3f);
			Log.LogInfo((object)("WRT TEST fall recovery=" + (player.footPosition.y > 110f) + " position=" + player.footPosition));
			TeleportHelper.TeleportBody(player, new Vector3(testLayout.windStart[0], testLayout.windStart[1] + 0.7f, testLayout.windStart[2]));
			yield return (object)new WaitForSecondsRealtime(4f);
			Log.LogInfo((object)string.Concat("WRT TEST updraft landing=", player.footPosition, " close=", Vector3.Distance(player.footPosition, new Vector3(testLayout.windEnd[0], testLayout.windEnd[1] - 1f, testLayout.windEnd[2])) < 12f));
		}
		if (Object.op_Implicit((Object)(object)tp))
		{
			DirectorCore instance = DirectorCore.instance;
			CharacterSpawnCard obj = Assets.Load<CharacterSpawnCard>("RoR2/Base/Vagrant/cscVagrant.asset");
			DirectorPlacementRule val2 = new DirectorPlacementRule();
			val2.placementMode = (PlacementMode)1;
			val2.position = ((Component)tp).transform.position;
			val2.minDistance = 20f;
			val2.maxDistance = 70f;
			DirectorSpawnRequest val3 = new DirectorSpawnRequest((SpawnCard)(object)obj, val2, new Xoroshiro128Plus(73uL));
			val3.teamIndexOverride = (TeamIndex)2;
			GameObject val4 = instance.TrySpawnObject(val3);
			Log.LogInfo((object)("WRT TEST flying boss spawn=" + ((Object)(object)val4 != (Object)null)));
		}
		if (Object.op_Implicit((Object)(object)player) && Object.op_Implicit((Object)(object)tp))
		{
			player.AddTimedBuff(Buffs.HiddenInvincibility, 400f);
			TeleportHelper.TeleportBody(player, ((Component)tp).transform.position + Vector3.up * 2f);
			tp.OnInteractionBegin(((Component)player).GetComponent<Interactor>());
		}
		yield return (object)new WaitForSecondsRealtime(12f);
		Log.LogInfo((object)("WRT TEST encounter state=" + (Object.op_Implicit((Object)(object)tp) ? ((object)tp.activationState).ToString() : "missing") + " charge=" + (Object.op_Implicit((Object)(object)tp) ? tp.chargeFraction : 0f) + " bodies=" + CharacterBody.readOnlyInstancesList.Count));
		StageWorld world = Object.FindObjectOfType<StageWorld>();
		if (Object.op_Implicit((Object)(object)world) && world.Ready)
		{
			world.WriteValidation();
			world.CaptureScale(player);
		}
		ManualLogSource log = Log;
		object[] array2 = new object[6] { "WRT TEST gameplay scene=", null, null, null, null, null };
		object[] array3 = array2;
		Scene activeScene = SceneManager.GetActiveScene();
		array3[1] = ((Scene)(ref activeScene)).name;
		array2[2] = " teleporter=";
		array2[3] = TeleporterInteraction.instance;
		array2[4] = " bodies=";
		array2[5] = CharacterBody.readOnlyInstancesList.Count;
		log.LogInfo((object)string.Concat(array2));
		if (Object.op_Implicit((Object)(object)tp) && Object.op_Implicit((Object)(object)player))
		{
			Time.timeScale = 4f;
			int ticks = 0;
			int defeated = 0;
			while (Object.op_Implicit((Object)(object)tp) && !tp.isCharged && ticks++ < 90)
			{
				Time.timeScale = 4f;
				if (Object.op_Implicit((Object)(object)player))
				{
					if (Object.op_Implicit((Object)(object)player.inputBank))
					{
						player.inputBank.moveVector = Vector3.zero;
					}
					if (Vector3.Distance(player.footPosition, ((Component)tp).transform.position) > 4f)
					{
						TeleportHelper.TeleportBody(player, ((Component)tp).transform.position + Vector3.up * 2f);
					}
				}
				List<CharacterBody> bodies = new List<CharacterBody>(CharacterBody.readOnlyInstancesList);
				foreach (CharacterBody item in bodies)
				{
					if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)item.teamComponent) && ((int)item.teamComponent.teamIndex == 2 || (int)item.teamComponent.teamIndex == 4 || (int)item.teamComponent.teamIndex == 3) && Object.op_Implicit((Object)(object)item.healthComponent))
					{
						defeated++;
						item.healthComponent.Suicide((GameObject)null, (GameObject)null, DamageTypeCombo.op_Implicit((DamageType)0));
					}
				}
				if (ticks % 10 == 0)
				{
					Log.LogInfo((object)("WRT TEST charging tick=" + ticks + " fraction=" + tp.chargeFraction + " player=" + (Object.op_Implicit((Object)(object)player) ? ((object)player.footPosition/*cast due to .constrained prefix*/).ToString() : "missing") + " scale=" + Time.timeScale));
				}
				yield return (object)new WaitForSecondsRealtime(1f);
			}
			Time.timeScale = 1f;
			Log.LogInfo((object)("WRT TEST encounter complete charged=" + (Object.op_Implicit((Object)(object)tp) && tp.isCharged) + " defeated=" + defeated));
			if (Object.op_Implicit((Object)(object)tp) && tp.isCharged)
			{
				tp.OnInteractionBegin(((Component)player).GetComponent<Interactor>());
				yield return (object)new WaitForSecondsRealtime(15f);
				ManualLogSource log2 = Log;
				activeScene = SceneManager.GetActiveScene();
				log2.LogInfo((object)("WRT TEST exit destination=" + ((Scene)(ref activeScene)).name));
			}
		}
		Application.Quit();
	}

	private IEnumerator TestLoad()
	{
		testStarted = true;
		yield return (object)new WaitForSecondsRealtime(2f);
		Log.LogInfo((object)"WRT TEST loading isolated stage geometry");
		yield return SceneManager.LoadSceneAsync("wetlandrooftops");
		yield return (object)new WaitForSecondsRealtime(4f);
		StageWorld world = Object.FindObjectOfType<StageWorld>();
		if (Object.op_Implicit((Object)(object)world) && world.Ready)
		{
			world.WriteValidation();
		}
		else
		{
			Log.LogError((object)"WRT TEST FAILED: stage not ready");
		}
		Log.LogInfo((object)"WRT TEST completed geometry load");
		Application.Quit();
	}

	[ConCommand(/*Could not decode attribute arguments.*/)]
	private static void GoToRooftops(ConCommandArgs args)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Run.instance))
		{
			throw new ConCommandException("Start a run first, then use wrt_go.");
		}
		Run.instance.AdvanceStage(Definition);
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		if (((Scene)(ref scene)).name != "wetlandrooftops")
		{
			return;
		}
		try
		{
			StageWorld.Create(scene);
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Wetland Rooftops construction failed: " + ex));
		}
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
		RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(OnGameLoaded));
	}
}
internal static class Assets
{
	public static T Load<T>(string key) where T : Object
	{
		//IL_004a: 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_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		IList<IResourceLocation> list = default(IList<IResourceLocation>);
		foreach (IResourceLocator resourceLocator in Addressables.ResourceLocators)
		{
			if (resourceLocator.Locate((object)key, typeof(T), ref list) && list.Count > 0)
			{
				return Addressables.LoadAssetAsync<T>(list[0]).WaitForCompletion();
			}
		}
		string value = "/" + Path.GetFileName(key);
		foreach (IResourceLocator resourceLocator2 in Addressables.ResourceLocators)
		{
			foreach (object key2 in resourceLocator2.Keys)
			{
				if (key2 is string text && text.EndsWith(value, StringComparison.OrdinalIgnoreCase) && resourceLocator2.Locate(key2, typeof(T), ref list) && list.Count > 0)
				{
					Plugin.Log.LogInfo((object)("Resolved native asset " + text));
					return Addressables.LoadAssetAsync<T>(list[0]).WaitForCompletion();
				}
			}
		}
		throw new Exception("Missing native asset " + key);
	}

	public static void Set(object target, string field, object value)
	{
		FieldInfo field2 = target.GetType().GetField(field, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (field2 == null)
		{
			throw new MissingFieldException(target.GetType().Name, field);
		}
		field2.SetValue(target, value);
	}

	public static void Call(object target, string method)
	{
		target.GetType().GetMethod(method, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Invoke(target, null);
	}
}
[Serializable]
public class Point
{
	public float[] p;
}
[Serializable]
public class Swatch
{
	public float r;

	public float g;

	public float b;
}
[Serializable]
public class Solid
{
	public float[] p;

	public float[] s;

	public float[] tilt;

	public float yaw;

	public float pitch;
}
[Serializable]
public class Landmark
{
	public string name;

	public float[] p;
}
[Serializable]
public class PadDefinition
{
	public string name;

	public float[] p;

	public float radius;

	public float inner;
}
[Serializable]
public class RouteDefinition
{
	public string kind;

	public float width;

	public float[][] points;
}
[Serializable]
public class FloatingIslet
{
	public string name;

	public float[] p;

	public float radius;
}
[Serializable]
public class FloatingCrystal
{
	public float[] p;

	public float size;

	public float phase;
}
[Serializable]
public class TreeLantern
{
	public float[] p;

	public bool green;

	public bool pointLight;

	public string tree;
}
[Serializable]
public class JumpConnection
{
	public string name;

	public float[] a;

	public float[] b;

	public float[] lip;

	public float[] edge;

	public float gap;
}
[Serializable]
public class Layout
{
	public Swatch[] palette;

	public Solid[] colliders;

	public Point[] nodes;

	public Point[] lights;

	public Point[] trees;

	public Point[] teleporters;

	public Point[] forest;

	public Point[] plants;

	public Point[] floorQuads;

	public Point[] bridgeFloorQuads;

	public Point[] isletFloorQuads;

	public Point[] steppingFloorQuads;

	public float[] sailPivot;

	public float[] spawn;

	public float[] windStart;

	public float[] windEnd;

	public float[] shrine;

	public float[] scaleReference;

	public float[][] captureViews;

	public float[][] captureTargets;

	public Landmark[] landmarks;

	public PadDefinition[] padDefinitions;

	public RouteDefinition[] routes;

	public FloatingIslet[] floatingIslets;

	public FloatingIslet[] steppingRocks;

	public FloatingCrystal[] floatingCrystals;

	public FloatingCrystal[] floatingDebris;

	public TreeLantern[] treeLanterns;

	public JumpConnection[] jumpConnections;

	public float horizontalExpansion;

	public float verticalExpansion;

	public float baseAltitude;
}
internal static class StageArt
{
	private static AssetBundle artBundle;

	internal static Shader ArtShader(string path)
	{
		if (!Object.op_Implicit((Object)(object)artBundle))
		{
			artBundle = AssetBundle.LoadFromFile(Path.Combine(Plugin.Folder, "wetlandrooftops.art"));
		}
		if (!Object.op_Implicit((Object)(object)artBundle))
		{
			throw new Exception("Wetland Rooftops art bundle missing or invalid");
		}
		Shader val = artBundle.LoadAsset<Shader>(path);
		if (!Object.op_Implicit((Object)(object)val) || !val.isSupported)
		{
			throw new Exception("Wetland Rooftops shader unsupported: " + path);
		}
		return val;
	}

	private static Texture2D Relief(string name, int size, Func<float, float, float> height, float strength, List<Object> owned)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(size, size, (TextureFormat)4, true, true);
		((Object)val).name = name;
		((Texture)val).wrapMode = (TextureWrapMode)0;
		((Texture)val).filterMode = (FilterMode)2;
		((Texture)val).anisoLevel = 8;
		Color[] array = (Color[])(object)new Color[size * size];
		float num = 1f / (float)size;
		for (int i = 0; i < size; i++)
		{
			for (int j = 0; j < size; j++)
			{
				float num2 = (float)j / (float)size;
				float num3 = (float)i / (float)size;
				float num4 = (height(num2 + num, num3) - height(num2 - num, num3)) * strength;
				float num5 = (height(num2, num3 + num) - height(num2, num3 - num)) * strength;
				Vector3 val2 = new Vector3(0f - num4, 0f - num5, 1f);
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				ref Color reference = ref array[i * size + j];
				reference = new Color(1f, normalized.y * 0.5f + 0.5f, normalized.z * 0.5f + 0.5f, normalized.x * 0.5f + 0.5f);
			}
		}
		val.SetPixels(array);
		val.Apply(true, true);
		owned.Add((Object)(object)val);
		return val;
	}

	private static Texture2D Surface(string name, int size, Func<float, float, Color> paint, List<Object> owned)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(size, size, (TextureFormat)3, true);
		((Object)val).name = name;
		((Texture)val).wrapMode = (TextureWrapMode)0;
		((Texture)val).filterMode = (FilterMode)2;
		((Texture)val).anisoLevel = 8;
		Color[] array = (Color[])(object)new Color[size * size];
		for (int i = 0; i < size; i++)
		{
			for (int j = 0; j < size; j++)
			{
				ref Color reference = ref array[i * size + j];
				reference = paint((float)j / (float)size, (float)i / (float)size);
			}
		}
		val.SetPixels(array);
		val.Apply(true, true);
		owned.Add((Object)(object)val);
		return val;
	}

	private static Texture2D LoadPainted(string file, List<Object> owned)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		Texture2D val = new Texture2D(2, 2, (TextureFormat)3, true);
		((Object)val).name = "Wetland painted material | " + file;
		ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Plugin.Folder, file)));
		((Texture)val).wrapMode = (TextureWrapMode)0;
		((Texture)val).filterMode = (FilterMode)2;
		((Texture)val).anisoLevel = 8;
		owned.Add((Object)(object)val);
		return val;
	}

	internal static Material[] CreateMaterials(Swatch[] palette, List<Object> owned)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Expected O, but got Unknown
		//IL_029f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Expected O, but got Unknown
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: Expected O, but got Unknown
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ce: 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_04ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0494: Unknown result type (might be due to invalid IL or missing references)
		//IL_059f: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0660: Unknown result type (might be due to invalid IL or missing references)
		//IL_066a: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06af: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_070a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0781: Unknown result type (might be due to invalid IL or missing references)
		//IL_07af: Unknown result type (might be due to invalid IL or missing references)
		//IL_0805: Unknown result type (might be due to invalid IL or missing references)
		//IL_0833: Unknown result type (might be due to invalid IL or missing references)
		//IL_094e: Unknown result type (might be due to invalid IL or missing references)
		//IL_120b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1212: Expected O, but got Unknown
		//IL_1256: Unknown result type (might be due to invalid IL or missing references)
		//IL_12bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_12c4: Expected O, but got Unknown
		//IL_12f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a97: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b66: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b7d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0abb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c36: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c7a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cbf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d03: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d59: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d7a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e9a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ea4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f1b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f3c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f7b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f85: Unknown result type (might be due to invalid IL or missing references)
		//IL_103c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1046: Unknown result type (might be due to invalid IL or missing references)
		//IL_10a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_10b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_10f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_11af: Unknown result type (might be due to invalid IL or missing references)
		Shader val = Assets.Load<Shader>("RoR2/Base/Shaders/HGStandard.shader");
		Texture2D val2 = new Texture2D(2, 2, (TextureFormat)3, true);
		((Object)val2).name = "Wetland timber | original painted grain";
		ImageConversion.LoadImage(val2, File.ReadAllBytes(Path.Combine(Plugin.Folder, "timber-clean-hd.png")));
		((Texture)val2).wrapMode = (TextureWrapMode)0;
		((Texture)val2).filterMode = (FilterMode)2;
		((Texture)val2).anisoLevel = 8;
		owned.Add((Object)(object)val2);
		Texture2D val3 = LoadPainted("roof-clean-hd.png", owned);
		Texture2D val4 = Surface("Canopy | layered leaf values", 128, delegate(float x, float y)
		{
			//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_0065: Unknown result type (might be due to invalid IL or missing references)
			float num2 = Mathf.PerlinNoise(x * 5f, y * 5f);
			float num3 = Mathf.PerlinNoise(x * 24f, y * 15f);
			float num4 = 0.66f + num2 * 0.24f + Mathf.SmoothStep(0.3f, 0.75f, num3) * 0.16f;
			return new Color(num4 * 0.93f, num4, num4 * 0.86f);
		}, owned);
		Texture2D val5 = Surface("Faded woven canvas", 512, delegate(float x, float y)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			float num2 = 0.84f + 0.1f * Mathf.PerlinNoise(x * 10f, y * 10f) + 0.025f * Mathf.Sin(x * 72f) * Mathf.Sin(y * 72f);
			return new Color(num2, num2 * 0.98f, num2 * 0.93f);
		}, owned);
		Texture2D val6 = LoadPainted("bark-clean-hd.png", owned);
		Texture2D val7 = new Texture2D(2, 2, (TextureFormat)4, true);
		((Object)val7).name = "Wetland canopy | painted bough";
		ImageConversion.LoadImage(val7, File.ReadAllBytes(Path.Combine(Plugin.Folder, "canopy-cluster-hd.png")));
		((Texture)val7).wrapMode = (TextureWrapMode)1;
		((Texture)val7).filterMode = (FilterMode)2;
		((Texture)val7).anisoLevel = 8;
		owned.Add((Object)(object)val7);
		Texture2D val8 = Relief("Authored cut timber | fine relief", 512, delegate(float u, float v)
		{
			float num2 = u * 6.283185f * 13f + Mathf.Sin(v * 6.283185f) * 0.7f + Mathf.Sin(v * 18.849554f) * 0.16f;
			return Mathf.Sin(num2) * 0.55f + Mathf.Sin(num2 * 3f) * 0.16f + Mathf.Cos(u * 6.283185f * 31f + Mathf.Sin(v * 12.56637f)) * 0.12f;
		}, 2.8f, owned);
		Texture2D val9 = Relief("Authored bark | longitudinal fissures", 512, delegate(float u, float v)
		{
			float num2 = Mathf.Sin(v * 12.56637f) * 0.35f + Mathf.Sin(v * 31.4159f) * 0.13f;
			return Mathf.Pow(Mathf.Abs(Mathf.Sin(u * 6.283185f * 7f + num2)), 0.45f) + 0.2f * Mathf.Sin(u * 6.283185f * 19f + v * 6.283185f);
		}, 5f, owned);
		Texture2D val10 = Relief("Authored shingle | split reed relief", 256, (float u, float v) => Mathf.Sin(u * 6.283185f * 11f + Mathf.Sin(v * 6.283185f)) * 0.5f + Mathf.Sin(v * 6.283185f * 5f) * 0.15f, 1.8f, owned);
		Texture2D val11 = Surface("Woven wetland reed panels", 256, delegate(float u, float v)
		{
			//IL_0048: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			float num2 = 0.88f + 0.09f * Mathf.Sin(u * 6.283185f * 24f) + 0.035f * Mathf.Sin(v * 6.283185f * 19f);
			return new Color(num2, num2 * 0.94f, num2 * 0.77f);
		}, owned);
		Texture2D val12 = Surface("Moonroot | quiet cut slate", 512, delegate(float u, float v)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			float num2 = Mathf.PerlinNoise(u * 5f + 43f, v * 5f + 17f);
			float num3 = Mathf.PerlinNoise(u * 79f, v * 79f);
			float num4 = 0.69f + num2 * 0.19f + num3 * 0.035f;
			return new Color(num4 * 0.96f, num4, num4 * 0.97f);
		}, owned);
		Texture2D val13 = Relief("Moonroot | restrained slate pores", 256, (float u, float v) => Mathf.PerlinNoise(u * 23f, v * 23f) * 0.4f + Mathf.PerlinNoise(u * 7f, v * 7f) * 0.3f, 0.65f, owned);
		Texture2D val14 = Surface("Petrichor | pale island wood", 256, delegate(float u, float v)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			float num2 = 0.72f + Mathf.PerlinNoise(u * 18f, v * 4f) * 0.14f + 0.025f * Mathf.Sin(u * 170f + Mathf.Sin(v * 12f));
			return new Color(num2 * 0.9f, num2, num2 * 0.95f);
		}, owned);
		Texture2D val15 = new Texture2D(2, 2, (TextureFormat)4, true, true);
		((Object)val15).name = "Heartwood | original cellular fissure field";
		ImageConversion.LoadImage(val15, File.ReadAllBytes(Path.Combine(Plugin.Folder, "heartwood-fissures.png")));
		((Texture)val15).wrapMode = (TextureWrapMode)0;
		((Texture)val15).filterMode = (FilterMode)2;
		((Texture)val15).anisoLevel = 8;
		owned.Add((Object)(object)val15);
		Texture2D val16 = Surface("Petrichor | translucent mineral inclusions", 256, delegate(float u, float v)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			float num2 = Mathf.PerlinNoise(u * 8f, v * 3f);
			float num3 = Mathf.Pow(Mathf.Abs(Mathf.Sin(v * 56f + Mathf.Sin(u * 12f) * 0.7f)), 14f);
			float num4 = 0.64f + num2 * 0.28f + num3 * 0.08f;
			return new Color(num4 * 0.78f, num4, num4 * 0.94f);
		}, owned);
		Material[] array = (Material[])(object)new Material[palette.Length];
		for (int num = 0; num < array.Length; num++)
		{
			Swatch swatch = palette[num];
			Material val17 = new Material((num == 11 || num == 59 || num == 20 || num == 21) ? val : ArtShader("Assets/WetlandSurface.shader"));
			((Object)val17).name = "Wetland Rooftops | surface " + num;
			val17.SetColor("_Color", new Color(swatch.r, swatch.g, swatch.b) * ((num <= 7 || num == 13 || num == 16 || num == 17 || num == 18) ? 1.45f : 1f));
			val17.SetFloat("_RampInfo", 1f);
			val17.SetFloat("_NormalStrength", 0f);
			val17.SetFloat("_SpecularStrength", 0.04f);
			val17.SetFloat("_SpecularExponent", 8f);
			val17.SetFloat("_Smoothness", 0.05f);
			val17.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
			if (num <= 3)
			{
				val17.SetTexture("_MainTex", (Texture)(object)val2);
				val17.mainTextureScale = new Vector2(0.18f, 0.23f);
				val17.SetColor("_Color", (Color)((num == 3) ? new Color(0.36f, 0.42f, 0.36f) : (new Color(1.03f, 0.95f, 0.8f) * num switch
				{
					2 => 1.08f, 
					1 => 0.89f, 
					_ => 1f, 
				})));
				val17.SetTexture("_NormalTex", (Texture)(object)val8);
				val17.SetFloat("_NormalStrength", 0.8f);
				val17.SetFloat("_Smoothness", (num == 3) ? 0.18f : 0.34f);
				val17.SetFloat("_SpecularStrength", 0.22f);
				val17.SetFloat("_SpecularExponent", 12f);
				val17.SetFloat("_ForceSpecOn", 1f);
				val17.EnableKeyword("FORCE_SPEC");
			}
			if (num == 4 || num == 5 || num == 16 || num == 17)
			{
				val17.SetTexture("_MainTex", (Texture)(object)val3);
				val17.mainTextureScale = new Vector2(0.3f, 0.3f);
				val17.SetColor("_Color", new Color(0.64f, 0.82f, 0.74f) * num switch
				{
					17 => 0.9f, 
					5 => 1.12f, 
					_ => 1f, 
				});
				val17.SetTexture("_NormalTex", (Texture)(object)val10);
				val17.SetFloat("_NormalStrength", 0.75f);
				val17.SetFloat("_Smoothness", 0.28f);
				val17.SetFloat("_SpecularStrength", 0.24f);
			}
			if (num == 6 || num == 18)
			{
				val17.SetTexture("_MainTex", (Texture)(object)val5);
				val17.mainTextureScale = Vector2.one * 0.45f;
			}
			if (num == 8 || num == 9 || num == 14)
			{
				val17.SetTexture("_MainTex", (Texture)(object)val4);
				val17.mainTextureScale = Vector2.one * 1.3f;
			}
			if (num == 10)
			{
				val17.SetTexture("_MainTex", (Texture)(object)val6);
				val17.SetColor("_Color", new Color(0.67f, 0.75f, 0.6f));
				val17.mainTextureScale = new Vector2(0.14f, 0.12f);
				val17.SetTexture("_NormalTex", (Texture)(object)val9);
				val17.SetFloat("_NormalStrength", 1f);
				val17.SetFloat("_Smoothness", 0.1f);
				val17.SetFloat("_SpecularStrength", 0.12f);
			}
			if (num == 11)
			{
				val17.SetColor("_Color", new Color(0.33f, 0.16f, 0.045f));
				val17.EnableKeyword("EMISSION");
				val17.SetColor("_EmColor", new Color(1f, 0.48f, 0.12f));
				val17.SetFloat("_EmPower", 2.5f);
				val17.SetTexture("_EmTex", (Texture)(object)Texture2D.whiteTexture);
			}
			if (num == 59)
			{
				val17.SetColor("_Color", new Color(0.045f, 0.24f, 0.08f));
				val17.EnableKeyword("EMISSION");
				val17.SetColor("_EmColor", new Color(0.12f, 1f, 0.3f));
				val17.SetFloat("_EmPower", 2.3f);
				val17.SetTexture("_EmTex", (Texture)(object)Texture2D.whiteTexture);
			}
			if (num == 7 || num == 12 || num == 15 || num == 23)
			{
				val17.SetFloat("_Smoothness", (num == 15 || num == 23) ? 0.76f : 0.42f);
				val17.SetFloat("_SpecularStrength", 0.4f);
				val17.SetFloat("_SpecularExponent", 18f);
				val17.SetFloat("_ForceSpecOn", 1f);
				val17.EnableKeyword("FORCE_SPEC");
			}
			if (num == 22)
			{
				val17.SetTexture("_MainTex", (Texture)(object)val4);
				val17.SetFloat("_RampInfo", 4f);
			}
			if (num == 24)
			{
				val17.SetTexture("_MainTex", (Texture)(object)val11);
				val17.mainTextureScale = new Vector2(0.5f, 0.5f);
				val17.SetTexture("_NormalTex", (Texture)(object)val10);
				val17.SetFloat("_NormalStrength", 0.35f);
			}
			if (num != 11 && num != 20 && num != 21)
			{
				val17.SetFloat("_NormalStrength", (num == 10) ? 0.28f : ((num == 24) ? 0.1f : ((num <= 3) ? 0.14f : 0.2f)));
				val17.SetFloat("_Wetness", (num <= 3) ? 0.23f : ((num == 10) ? 0.06f : 0.12f));
				if (num == 7 || num == 12)
				{
					val17.SetFloat("_Metallic", 0.55f);
					val17.SetFloat("_Smoothness", 0.33f);
				}
				if (num == 23)
				{
					val17.SetFloat("_Wetness", 0.35f);
					val17.SetFloat("_Smoothness", 0.72f);
				}
				if (num <= 2)
				{
					val17.SetColor("_Color", new Color(0.58f, 0.56f, 0.47f) * num switch
					{
						2 => 1.08f, 
						1 => 0.89f, 
						_ => 1f, 
					});
				}
				if (num == 10)
				{
					val17.SetColor("_Color", new Color(0.44f, 0.49f, 0.43f));
					val17.SetFloat("_MossStrength", 0.72f);
					val17.SetFloat("_BarkTriplanar", 1f);
					val17.SetFloat("_NormalStrength", 0.1f);
				}
				if (num == 45)
				{
					val17.SetTexture("_MainTex", (Texture)(object)val6);
					val17.SetColor("_Color", new Color(0.4f, 0.46f, 0.39f));
					val17.mainTextureScale = new Vector2(0.14f, 0.12f);
					val17.SetTexture("_NormalTex", (Texture)(object)val9);
					val17.SetFloat("_NormalStrength", 0.1f);
					val17.SetFloat("_MossStrength", 0.67f);
					val17.SetFloat("_BarkTriplanar", 1f);
					val17.SetTexture("_SapTex", (Texture)(object)val15);
					val17.SetFloat("_SapVeins", 1.65f);
					val17.SetFloat("_Smoothness", 0.2f);
				}
				if (num == 46 || num == 47)
				{
					val17.SetTexture("_MainTex", (Texture)(object)val16);
					val17.mainTextureScale = new Vector2(0.6f, 0.28f);
					val17.SetFloat("_Crystal", 1f);
				}
				if (num == 46)
				{
					val17.SetColor("_Color", new Color(0.17f, 0.36f, 0.34f));
					val17.SetFloat("_Metallic", 0.32f);
					val17.SetFloat("_Smoothness", 0.64f);
					val17.SetColor("_EmissionColor", new Color(0.015f, 0.1f, 0.08f));
					val17.SetFloat("_EmissionStrength", 0.35f);
				}
				if (num == 47)
				{
					val17.SetColor("_EmissionColor", new Color(0.05f, 0.7f, 0.43f));
					val17.SetFloat("_EmissionStrength", 1.6f);
					val17.SetFloat("_Smoothness", 0.7f);
				}
				if (num == 56)
				{
					val17.SetColor("_Color", new Color(0.025f, 0.13f, 0.1f));
					val17.SetColor("_EmissionColor", new Color(0.045f, 0.72f, 0.43f));
					val17.SetFloat("_EmissionStrength", 1.45f);
					val17.SetFloat("_Smoothness", 0.35f);
				}
				if (num == 57 || num == 58)
				{
					val17.SetTexture("_MainTex", (Texture)(object)((num == 57) ? val12 : val2));
					val17.SetTexture("_NormalTex", (Texture)(object)((num == 57) ? val13 : val8));
					val17.SetFloat("_NormalStrength", 0.12f);
					val17.SetFloat("_BarkTriplanar", 1f);
					val17.SetTexture("_SapTex", (Texture)(object)val15);
					val17.SetFloat("_SapVeins", (num == 57) ? 0.72f : 1.1f);
					val17.SetFloat("_MossStrength", 0.28f);
					val17.SetFloat("_Smoothness", 0.24f);
				}
				if (num >= 28 && num <= 31)
				{
					val17.SetTexture("_MainTex", (Texture)(object)val12);
					val17.mainTextureScale = Vector2.one * 0.24f;
					val17.SetTexture("_NormalTex", (Texture)(object)val13);
					val17.SetFloat("_NormalStrength", 0.16f);
					val17.SetFloat("_Smoothness", 0.25f);
					val17.SetFloat("_Wetness", 0.3f);
				}
				if (num == 32)
				{
					val17.SetColor("_Color", new Color(0.04f, 0.22f, 0.16f));
					val17.SetColor("_EmissionColor", new Color(0.08f, 0.82f, 0.54f));
					val17.SetFloat("_EmissionStrength", 2.7f);
				}
				if (num == 34)
				{
					val17.SetTexture("_MainTex", (Texture)(object)val5);
					val17.mainTextureScale = Vector2.one * 0.45f;
					val17.SetFloat("_Smoothness", 0.05f);
				}
				if (num == 35)
				{
					val17.SetFloat("_Metallic", 0.65f);
					val17.SetFloat("_Smoothness", 0.33f);
				}
				if (num <= 5 || (num >= 28 && num <= 31) || num == 24)
				{
					val17.SetFloat("_Age", (num <= 3) ? 0.8f : 0.55f);
				}
				if (num == 36)
				{
					val17.SetTexture("_MainTex", (Texture)(object)val12);
					val17.mainTextureScale = Vector2.one * 0.24f;
					val17.SetFloat("_MossStrength", 0.8f);
					val17.SetFloat("_Smoothness", 0.18f);
				}
				if (num == 37 || num == 38 || num == 40)
				{
					val17.SetTexture("_MainTex", (Texture)(object)val4);
					val17.mainTextureScale = Vector2.one * 0.35f;
					val17.SetFloat("_Smoothness", 0.35f);
				}
				if (num == 39)
				{
					val17.SetColor("_EmissionColor", new Color(0.045f, 0.46f, 0.28f));
					val17.SetFloat("_EmissionStrength", 0.65f);
					val17.SetFloat("_Smoothness", 0.35f);
				}
				if (num == 42)
				{
					val17.SetTexture("_MainTex", (Texture)(object)val14);
					val17.SetFloat("_BarkTriplanar", 1f);
					val17.SetFloat("_MossStrength", 0.45f);
					val17.SetFloat("_Smoothness", 0.15f);
				}
				if (num == 41 || num == 43)
				{
					val17.SetTexture("_MainTex", (Texture)(object)val5);
					val17.mainTextureScale = new Vector2(1.5f, 2f);
					val17.SetFloat("_Smoothness", 0.08f);
				}
			}
			if (num == 20 || num == 21 || (num >= 48 && num <= 52))
			{
				owned.Add((Object)(object)val17);
				val17 = new Material(ArtShader("Assets/WetlandCanopy.shader"));
				((Object)val17).name = "Living canopy | wrapped light and wind " + num;
				val17.SetTexture("_MainTex", (Texture)(object)val7);
				val17.SetColor("_Color", new Color(swatch.r, swatch.g, swatch.b));
				val17.SetFloat("_Cutoff", 0.38f);
				val17.SetFloat("_Wind", 0.26f);
				val17.renderQueue = 2450;
			}
			if (num >= 53 && num <= 55)
			{
				owned.Add((Object)(object)val17);
				val17 = new Material(ArtShader("Assets/WetlandMountains.shader"));
				((Object)val17).name = "Petrichor | morning ridge " + (num - 52);
				val17.SetColor("_Color", new Color(0.25f, 0.35f, 0.29f));
				val17.SetFloat("_Layer", (float)(num - 53));
			}
			array[num] = val17;
			owned.Add((Object)(object)val17);
		}
		return array;
	}

	internal static Material WindMaterial(List<Object> owned)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Expected O, but got Unknown
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Expected O, but got Unknown
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(32, 32, (TextureFormat)4, true);
		((Object)val).name = "Soft updraft wisp";
		((Texture)val).wrapMode = (TextureWrapMode)1;
		for (int i = 0; i < 32; i++)
		{
			for (int j = 0; j < 32; j++)
			{
				float num = ((float)j - 15.5f) / 15.5f;
				float num2 = ((float)i - 15.5f) / 15.5f;
				float num3 = Mathf.Pow(Mathf.Clamp01(1f - num * num - num2 * num2), 3f);
				val.SetPixel(j, i, new Color(1f, 1f, 1f, num3));
			}
		}
		val.Apply(true, true);
		owned.Add((Object)(object)val);
		Material val2 = new Material(Assets.Load<Shader>("RoR2/Base/Shaders/HGCloudRemap.shader"));
		((Object)val2).name = "Wetland updraft | soft moving air";
		val2.SetTexture("_MainTex", (Texture)(object)val);
		val2.SetFloat("_SrcBlend", 5f);
		val2.SetFloat("_DstBlend", 10f);
		val2.SetColor("_TintColor", new Color(0.62f, 0.86f, 0.71f, 0.35f));
		val2.SetFloat("_DisableRemapOn", 1f);
		val2.EnableKeyword("DISABLEREMAP");
		val2.SetFloat("_CloudsOn", 0f);
		val2.DisableKeyword("USE_CLOUDS");
		val2.SetFloat("_AlphaBoost", 1f);
		val2.SetFloat("_VertexColorOn", 1f);
		val2.EnableKeyword("VERTEXCOLOR");
		val2.renderQueue = 3000;
		owned.Add((Object)(object)val2);
		return val2;
	}
}
internal sealed class StageContent : IContentPackProvider
{
	private readonly ContentPack pack = new ContentPack();

	public string identifier => "local.wetlandrooftops";

	internal static void Register(AddContentPackProviderDelegate add)
	{
		add.Invoke((IContentPackProvider)(object)new StageContent());
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		pack.sceneDefs.Add((SceneDef[])(object)new SceneDef[1] { Plugin.Definition });
		pack.unlockableDefs.Add((UnlockableDef[])(object)new UnlockableDef[2]
		{
			Plugin.EnvironmentLog,
			Plugin.NewtLog
		});
		args.ReportProgress(1f);
		yield break;
	}

	public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
	{
		ContentPack.Copy(pack, args.output);
		args.ReportProgress(1f);
		yield break;
	}

	public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
	{
		args.ReportProgress(1f);
		yield break;
	}
}
public sealed class StageWorld : MonoBehaviour
{
	private sealed class Cloth
	{
		internal Mesh mesh;

		internal Vector3[] rest;

		internal Vector3[] working;

		internal float minZ;

		internal float maxZ;
	}

	private sealed class MineralDrift
	{
		internal Transform transform;

		internal Vector3 anchor;

		internal float phase;
	}

	internal bool Ready;

	internal Layout layout;

	private Material[] materials;

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

	private readonly List<Cloth> cloth = new List<Cloth>();

	private float clothTimer;

	private readonly List<MineralDrift> mineralDrifts = new List<MineralDrift>();

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

	private bool qualityConfigured;

	private float previousShadowDistance;

	private int previousCascades;

	private ShadowResolution previousShadowResolution;

	private readonly Dictionary<Camera, DepthTextureMode> previousDepthModes = new Dictionary<Camera, DepthTextureMode>();

	private readonly Dictionary<PostProcessLayer, Antialiasing> previousAntialiasing = new Dictionary<PostProcessLayer, Antialiasing>();

	private readonly Dictionary<PostProcessLayer, Quality> previousSmaaQuality = new Dictionary<PostProcessLayer, Quality>();

	private Transform sails;

	private NodeGraph ground;

	private NodeGraph air;

	internal List<Vector3> groundPositions;

	internal int links;

	internal int components;

	private readonly HashSet<int> preparedCameras = new HashSet<int>();

	private static Vector3 V(float[] p)
	{
		//IL_000a: 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_0012: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3(p[0], p[1], p[2]);
	}

	internal Vector3 DesignPoint(Vector3 p)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3(p.x * layout.horizontalExpansion, layout.baseAltitude + (p.y - layout.baseAltitude) * layout.verticalExpansion, p.z * layout.horizontalExpansion);
	}

	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)
		GameObject val = new GameObject("Wetland Rooftops | village");
		SceneManager.MoveGameObjectToScene(val, scene);
		StageWorld stageWorld = val.AddComponent<StageWorld>();
		stageWorld.Build();
	}

	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;
	}

	private void Build()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Invalid comparison between Unknown and I4
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Invalid comparison between Unknown and I4
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Invalid comparison between Unknown and I4
		layout = JsonConvert.DeserializeObject<Layout>(File.ReadAllText(Path.Combine(Plugin.Folder, "layout.json")));
		if ((int)SystemInfo.graphicsDeviceType != 4)
		{
			Materials();
		}
		else
		{
			materials = (Material[])(object)new Material[layout.palette.Length];
		}
		Geometry();
		if ((int)SystemInfo.graphicsDeviceType != 4)
		{
			NativeFoliage();
		}
		Collision();
		if ((int)SystemInfo.graphicsDeviceType != 4)
		{
			Atmosphere();
		}
		Physics.SyncTransforms();
		ground = Navigation.BuildGround(layout, out groundPositions, out links, out components);
		owned.Add((Object)(object)ground);
		air = Navigation.BuildAir();
		owned.Add((Object)(object)air);
		if (components != 1)
		{
			Plugin.Log.LogWarning((object)("Ground route graph has " + components + " connected components; inspect validation report."));
		}
		WindShortcut();
		Systems();
		Ready = true;
		Plugin.Log.LogInfo((object)("Built Wetland Rooftops: " + groundPositions.Count + " ground nodes, " + links + " links, " + components + " components."));
	}

	internal void BuildDiorama()
	{
		//IL_0035: 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_005f: Unknown result type (might be due to invalid IL or missing references)
		layout = JsonConvert.DeserializeObject<Layout>(File.ReadAllText(Path.Combine(Plugin.Folder, "layout.json")));
		Materials();
		Geometry(diorama: true);
		((Component)this).transform.localScale = Vector3.one * 0.024f;
		((Component)this).transform.localPosition = new Vector3(0f, -3.3f, -0.9f);
		Light[] componentsInChildren = ((Component)this).GetComponentsInChildren<Light>();
		foreach (Light val in componentsInChildren)
		{
			Object.Destroy((Object)(object)val);
		}
	}

	private void Materials()
	{
		materials = StageArt.CreateMaterials(layout.palette, owned);
	}

	private void Geometry(bool diorama = false)
	{
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_072d: 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_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Expected O, but got Unknown
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: 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_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_0312: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Unknown result type (might be due to invalid IL or missing references)
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c2: 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_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_049d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_057b: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0628: Unknown result type (might be due to invalid IL or missing references)
		//IL_062d: 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_0644: Unknown result type (might be due to invalid IL or missing references)
		//IL_0649: 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_06b4: Unknown result type (might be due to invalid IL or missing references)
		using (BinaryReader binaryReader = new BinaryReader(File.OpenRead(Path.Combine(Plugin.Folder, "village.meshbin"))))
		{
			if (Encoding.ASCII.GetString(binaryReader.ReadBytes(4)) != "WRT1")
			{
				throw new Exception("Invalid village geometry");
			}
			int num = binaryReader.ReadInt32();
			for (int i = 0; i < num; i++)
			{
				int num2 = binaryReader.ReadInt32();
				int count = binaryReader.ReadInt32();
				int num3 = binaryReader.ReadInt32();
				string text = Encoding.UTF8.GetString(binaryReader.ReadBytes(count));
				int num4 = binaryReader.ReadInt32();
				Vector3[] array = (Vector3[])(object)new Vector3[num3];
				Vector3[] array2 = (Vector3[])(object)new Vector3[num3];
				Vector2[] array3 = (Vector2[])(object)new Vector2[num3];
				for (int j = 0; j < num3; j++)
				{
					ref Vector3 reference = ref array[j];
					reference = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
					ref Vector3 reference2 = ref array2[j];
					reference2 = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
					ref Vector2 reference3 = ref array3[j];
					reference3 = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
				}
				int[] array4 = new int[num4];
				for (int j = 0; j < num4; j++)
				{
					array4[j] = binaryReader.ReadInt32();
				}
				if (diorama && ((num2 >= 53 && num2 <= 55) || text.StartsWith("Canopy giants |")))
				{
					continue;
				}
				Mesh val = new Mesh();
				((Object)val).name = text;
				if (num3 > 65535)
				{
					val.indexFormat = (IndexFormat)1;
				}
				val.vertices = array;
				val.normals = array2;
				val.uv = array3;
				val.triangles = array4;
				if (num2 == 20 || num2 == 21 || (num2 >= 48 && num2 <= 52))
				{
					Color[] array5 = (Color[])(object)new Color[num3];
					for (int j = 0; j < num3; j++)
					{
						float num5 = Mathf.PerlinNoise(array[j].x * 0.095f + 27f, array[j].z * 0.095f + 14f);
						ref Color reference4 = ref array5[j];
						reference4 = new Color(num5, 1f, 1f, 1f);
					}
					val.colors = array5;
				}
				Vector3 val2 = Vector3.zero;
				int result = -1;
				if (text.StartsWith("Resonance | floating crystal cluster ") && int.TryParse(text.Substring(text.LastIndexOf(' ') + 1), out result) && layout.floatingCrystals != null && result < layout.floatingCrystals.Length)
				{
					val2 = V(layout.floatingCrystals[result].p);
					for (int j = 0; j < num3; j++)
					{
						ref Vector3 reference5 = ref array[j];
						reference5 -= val2;
					}
					val.vertices = array;
				}
				bool flag = text.StartsWith("Levitation | Heartwood suspended stone ");
				if (flag && int.TryParse(text.Substring(text.LastIndexOf(' ') + 1), out result) && layout.floatingDebris != null && result < layout.floatingDebris.Length)
				{
					val2 = V(layout.floatingDebris[result].p);
					for (int j = 0; j < num3; j++)
					{
						ref Vector3 reference6 = ref array[j];
						reference6 -= val2;
					}
					val.vertices = array;
				}
				val.RecalculateBounds();
				if (num2 <= 5 || num2 == 10 || num2 == 45 || num2 == 16 || num2 == 17 || num2 == 24 || (num2 >= 28 && num2 <= 31))
				{
					val.RecalculateTangents();
				}
				owned.Add((Object)(object)val);
				GameObject val3 = Child(text);
				val3.AddComponent<MeshFilter>().sharedMesh = val;
				MeshRenderer val4 = val3.AddComponent<MeshRenderer>();
				((Renderer)val4).sharedMaterial = materials[num2];
				((Renderer)val4).shadowCastingMode = (ShadowCastingMode)((num2 != 11 && num2 != 59) ? 1 : 0);
				Bounds bounds;
				if (num2 == 10 || num2 == 20 || num2 == 21)
				{
					bounds = val.bounds;
					float x = ((Bounds)(ref bounds)).center.x;
					bounds = val.bounds;
					Vector2 val5 = new Vector2(x, ((Bounds)(ref bounds)).center.z);
					if (!(((Vector2)(ref val5)).magnitude > 205f))
					{
						bounds = val.bounds;
						if (!(((Bounds)(ref bounds)).max.y < 90f))
						{
							goto IL_0510;
						}
					}
					((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0;
				}
				goto IL_0510;
				IL_0510:
				if (text.StartsWith("Canopy giants |"))
				{
					((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0;
				}
				if (num2 >= 53 && num2 <= 55)
				{
					((Renderer)val4).shadowCastingMode = (ShadowCastingMode)0;
					((Renderer)val4).receiveShadows = false;
					((Renderer)val4).lightProbeUsage = (LightProbeUsage)0;
					((Renderer)val4).reflectionProbeUsage = (ReflectionProbeUsage)0;
				}
				if (result >= 0)
				{
					val3.transform.localPosition = val2;
					mineralDrifts.Add(new MineralDrift
					{
						transform = val3.transform,
						anchor = val2,
						phase = (flag ? layout.floatingDebris : layout.floatingCrystals)[result].phase
					});
				}
				if (text == "awning")
				{
					List<Cloth> list = this.cloth;
					Cloth cloth = new Cloth
					{
						mesh = val,
						rest = array,
						working = (Vector3[])array.Clone()
					};
					bounds = val.bounds;
					cloth.minZ = ((Bounds)(ref bounds)).min.z;
					bounds = val.bounds;
					cloth.maxZ = ((Bounds)(ref bounds)).max.z;
					list.Add(cloth);
				}
				if (text == "sails")
				{
					if (!Object.op_Implicit((Object)(object)sails))
					{
						sails = Child("Windmill | turning sails").transform;
						sails.position = V(layout.sailPivot);
					}
					val3.transform.SetParent(sails, false);
				}
			}
		}
		for (int j = 0; j < layout.lights.Length; j += 3)
		{
			GameObject val6 = Child("Lantern warm pool");
			val6.transform.position = V(layout.lights[j].p);
			Light val7 = val6.AddComponent<Light>();
			val7.type = (LightType)2;
			val7.color = new Color(1f, 0.58f, 0.29f);
			val7.intensity = 4f;
			val7.range = 13f;
			val7.shadows = (LightShadows)0;
		}
	}

	private void NativeFoliage()
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: 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_0165: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Assets.Load<GameObject>("RoR2/Base/foggyswamp/foggyswamp base tree ref.spm");
		GameObject val2 = Assets.Load<GameObject>("RoR2/Base/foggyswamp/spmFSFern3.spm");
		Point[] forest = layout.forest;
		foreach (Point point in forest)
		{
			GameObject val3 = Object.Instantiate<GameObject>(val, ((Component)this).transform);
			((Object)val3).name = "Wetland distant canopy";
			val3.transform.position = V(point.p);
			val3.transform.rotation = Quaternion.Euler(0f, point.p[4], 0f);
			val3.transform.localScale = new Vector3(point.p[3] * 2.2f, point.p[3], point.p[3] * 2.2f);
			Collider[] componentsInChildren = val3.GetComponentsInChildren<Collider>();
			foreach (Collider val4 in componentsInChildren)
			{
				Object.Destroy((Object)(object)val4);
			}
		}
		forest = layout.plants;
		foreach (Point point in forest)
		{
			GameObject val3 = Object.Instantiate<GameObject>(val2, ((Component)this).transform);
			((Object)val3).name = "Wetland fern planter";
			val3.transform.position = V(point.p);
			val3.transform.localScale = Vector3.one * point.p[3];
			Collider[] componentsInChildren = val3.GetComponentsInChildren<Collider>();
			foreach (Collider val4 in componentsInChildren)
			{
				Object.Destroy((Object)(object)val4);
			}
		}
	}

	private void FloorCollision(Point[] quads, string name)
	{
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		if (quads == null || quads.Length == 0)
		{
			return;
		}
		Vector3[] array = (Vector3[])(object)new Vector3[quads.Length * 4];
		int[] array2 = new int[quads.Length * 6];
		for (int i = 0; i < quads.Length; i++)
		{
			float[] p = quads[i].p;
			int num = i * 4;
			int num2 = i * 6;
			for (int j = 0; j < 4; j++)
			{
				ref Vector3 reference = ref array[num + j];
				reference = new Vector3(p[j * 3], p[j * 3 + 1], p[j * 3 + 2]);
			}
			array2[num2] = num;
			array2[num2 + 1] = num + 1;
			array2[num2 + 2] = num + 2;
			array2[num2 + 3] = num;
			array2[num2 + 4] = num + 2;
			array2[num2 + 5] = num + 3;
		}
		Mesh val = new Mesh();
		((Object)val).name = name;
		val.indexFormat = (IndexFormat)1;
		val.vertices = array;
		val.triangles = array2;
		val.RecalculateBounds();
		owned.Add((Object)(object)val);
		GameObject val2 = Child(name);
		val2.layer = LayerIndex.world.intVal;
		val2.AddComponent<MeshCollider>().sharedMesh = val;
	}

	private void Collision()
	{
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: 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_02f5: 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_033a: 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_010a: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: 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_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		FloorCollision(layout.floorQuads, "Solid | six circular courts with tree wells");
		FloorCollision(layout.bridgeFloorQuads, "Solid | exact catenary bridge decks");
		FloorCollision(layout.isletFloorQuads, "Solid | detached tree islands, excluded from directors");
		FloorCollision(layout.steppingFloorQuads, "Solid | optional jumpable rocks, excluded from directors");
		Solid[] colliders = layout.colliders;
		foreach (Solid solid in colliders)
		{
			GameObject val = Child("Solid | structural collision");
			val.layer = LayerIndex.world.intVal;
			val.transform.position = V(solid.p);
			Quaternion val2 = Quaternion.Euler(solid.pitch, solid.yaw, 0f);
			if (solid.tilt != null && solid.tilt.Length == 4)
			{
				val2 = Quaternion.AngleAxis(solid.tilt[3], V(solid.tilt)) * val2;
			}
			val.transform.rotation = val2;
			val.AddComponent<BoxCollider>().size = V(solid.s);
		}
		Point[] trees = layout.trees;
		foreach (Point point in trees)
		{
			GameObject val = Child("Load-bearing tree collision");
			val.layer = LayerIndex.world.intVal;
			Quaternion val2 = ((point.p.Length >= 8) ? Quaternion.AngleAxis(point.p[7], new Vector3(point.p[4], point.p[5], point.p[6])) : Quaternion.identity);
			val.transform.position = V(point.p) + val2 * Vector3.up * 7f;
			val.transform.rotation = val2;
			CapsuleCollider val3 = val.AddComponent<CapsuleCollider>();
			val3.radius = point.p[3] * 0.85f;
			val3.height = 100f;
		}
		GameObject val4 = Child("Wetland fall recovery");
		val4.layer = LayerIndex.collideWithCharacterHullOnly.intVal;
		val4.transform.position = new Vector3(0f, 30f, 10f);
		BoxCollider val5 = val4.AddComponent<BoxCollider>();
		val5.size = new Vector3(850f, 100f, 850f);
		((Collider)val5).isTrigger = true;
		MapZone val6 = val4.AddComponent<MapZone>();
		val6.triggerType = (TriggerType)1;
		val6.zoneType = (ZoneType)0;
		GameObject val7 = Child("Wetland outer bounds");
		val7.layer = LayerIndex.collideWithCharacterHullOnly.intVal;
		val7.transform.position = new Vector3(0f, 170f, 16.5f);
		val5 = val7.AddComponent<BoxCollider>();
		val5.size = new Vector3(693f, 330f, 627f);
		((Collider)val5).isTrigger = true;
		val6 = val7.AddComponent<MapZone>();
		val6.triggerType = (TriggerType)0;
		val6.zoneType = (ZoneType)0;
	}

	private void WindShortcut()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing reference