Decompiled source of Palinode v0.3.0

Palinode.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLevelLoader;
using TMPro;
using Unity.AI.Navigation;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

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

[DefaultExecutionOrder(10000)]
public sealed class Exterior : MonoBehaviour
{
	private const string ExitMessage = "local.palinode.extraexit.v1";

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

	private readonly List<NavMeshDataInstance> navigation = new List<NavMeshDataInstance>();

	private readonly List<NavMeshBuildSource> sources = new List<NavMeshBuildSource>();

	private readonly List<Vector3> shelters = new List<Vector3>();

	private readonly Dictionary<Material, List<CombineInstance>> batches = new Dictionary<Material, List<CombineInstance>>();

	private EntranceTeleport[] entrances;

	private Vector3 origin;

	private Vector3 ramp;

	private Vector3 forward;

	private Vector3 right;

	private Material stone;

	private Material trim;

	private Material bronze;

	private Material dark;

	private Material floor;

	private Material water;

	private Material amber;

	private Material cyan;

	private Material red;

	private Material window;

	private Material tideMaterial;

	private Transform halo;

	private Volume skyVolume;

	private AudioSource hum;

	private Light[] districtLights;

	private bool wasInside;

	private bool anchored;

	private bool announced;

	private bool tideWarned;

	private float landedAt = -1f;

	private float damageTimer;

	private float exposure;

	private int lastStage = -1;

	private CustomMessagingManager exitMessages;

	private readonly Dictionary<EntranceTeleport, int> exitSites = new Dictionary<EntranceTeleport, int>();

	private readonly Dictionary<int, Texture2D[]> surfaceTextures = new Dictionary<int, Texture2D[]>();

	private readonly Dictionary<int, GameObject> nativeDoors = new Dictionary<int, GameObject>();

	private readonly Dictionary<int, Vector3> nativeDoorSizes = new Dictionary<int, Vector3>();

	private AudioSource soundtrack;

	public Vector3 Ramp => ramp;

	public Vector3 Forward => forward;

	public Vector3 Right => right;

	public bool Ready => anchored;

	private Quaternion Facing => Quaternion.LookRotation(forward, Vector3.up);

	private IEnumerator BuildDistrict()
	{
		B("Shallow mirror basin", 0f, 0.006f, 15f, 440f, 0.012f, 440f, water);
		B("Observatory court", 0f, 0.028f, 7f, 57f, 0.055f, 61f, floor);
		B("Ship apron", 0f, 0.031f, -10f, 27f, 0.062f, 30f, floor);
		for (int i = -1; i <= 1; i += 2)
		{
			B("Court border", i * 28, 0.05f, 7f, 0.5f, 0.1f, 61f, trim);
			B("Bronze inlay", (float)i * 3.3f, 0.066f, 12.5f, 0.1f, 0.035f, 25f, bronze);
			B("Drain", (float)i * 3.65f, 0.066f, 12f, 0.35f, 0.035f, 24f, dark);
			for (int j = 0; j < 64; j++)
			{
				B("Drain grate", (float)i * 3.65f, 0.091f, (float)j * 0.36f, 0.4f, 0.028f, 0.045f, bronze);
			}
			for (int k = 0; k < 5; k++)
			{
				float z = 3f + (float)k * 4.5f;
				B("Mooring bollard", (float)i * 5.5f, 0.4f, z, 0.45f, 0.8f, 0.45f, bronze, solid: true);
				B("Bollard cap", (float)i * 5.5f, 0.84f, z, 0.65f, 0.1f, 0.65f, trim);
				B("Route inset light", (float)i * 3.3f, 0.09f, z, 0.16f, 0.02f, 0.48f, amber);
			}
		}
		for (int l = -2; l <= 2; l++)
		{
			B("Apron seam", l * 5, 0.07f, -8f, 0.07f, 0.035f, 22f, bronze);
		}
		yield return null;
		for (int m = -1; m <= 1; m += 2)
		{
			B("Observatory wing", m * 15, 10f, 30f, 19f, 20f, 10f, stone, solid: true);
			B("Terraced plinth", m * 15, 0.5f, 26f, 20f, 1f, 14f, dark, solid: true);
			B("Wing lower cornice", m * 15, 4.7f, 24.6f, 19.7f, 0.6f, 1f, trim);
			B("Wing upper cornice", m * 15, 19.6f, 24.5f, 20f, 0.8f, 1.4f, trim);
			for (int n = 0; n < 4; n++)
			{
				float num = (float)m * (8.8f + (float)n * 4.2f);
				B("Facade buttress", num, 10f, 24.1f, 0.7f, 19f, 1.6f, trim, solid: true);
				B("Bronze rib", num, 11f, 23.25f, 0.12f, 16f, 0.12f, bronze);
				B("Tall lancet glass", num + (float)m * 1.8f, 12.5f, 24.88f, 2.5f, 10.5f, 0.1f, window);
				for (int num2 = 0; num2 < 5; num2++)
				{
					B("Window transom", num + (float)m * 1.8f, 8.4f + (float)(num2 * 2), 24.75f, 2.6f, 0.1f, 0.2f, bronze);
				}
				B("Window mullion", num + (float)m * 1.8f, 12.5f, 24.7f, 0.14f, 10.8f, 0.25f, trim);
			}
		}
		yield return null;
		B("Entrance left wall", -3.85f, 2.2f, 25.5f, 4.3f, 4.4f, 1f, stone, solid: true);
		B("Entrance right wall", 3.85f, 2.2f, 25.5f, 4.3f, 4.4f, 1f, stone, solid: true);
		B("Entrance lintel", 0f, 4.6f, 25.5f, 12f, 0.8f, 1.4f, trim, solid: true);
		Arc("Observatory outer archivolt", P(0f, 18f, 30f), 14.8f, 2.2f, 5f, 0f, 360f, stone, Facing);
		Arc("Carved outer ring", P(0f, 18f, 27.3f), 15.6f, 0.4f, 0.6f, 0f, 360f, trim, Facing);
		Arc("Inner bronze rim", P(0f, 18f, 27.1f), 13.4f, 0.3f, 0.3f, 0f, 360f, bronze, Facing);
		Arc("Phosphor measuring ring", P(0f, 18f, 26.9f), 12.8f, 0.08f, 0.08f, 0f, 360f, cyan, Facing);
		for (int num3 = 0; num3 < 60; num3++)
		{
			float num4 = (float)num3 * (float)Math.PI * 2f / 60f;
			Vector3 val = right * Mathf.Cos(num4) + Vector3.up * Mathf.Sin(num4);
			Beam("Instrument graduation", P(0f, 18f, 26.7f) + val * 12.25f, P(0f, 18f, 26.7f) + val * ((num3 % 5 == 0) ? 12.85f : 12.55f), (num3 % 5 == 0) ? 0.14f : 0.06f, 0.08f, (num3 % 5 == 0) ? amber : bronze);
		}
		GameObject rotating = new GameObject("The stopped hour moves backwards");
		rotating.transform.SetParent(((Component)this).transform);
		rotating.transform.position = P(0f, 18f, 29f);
		rotating.transform.rotation = Facing;
		halo = rotating.transform;
		Mesh hand = RingMesh(9f, 0.13f, 0.2f, 0f, 360f, 120);
		owned.Add((Object)(object)hand);
		rotating.AddComponent<MeshFilter>().sharedMesh = hand;
		((Renderer)rotating.AddComponent<MeshRenderer>()).sharedMaterial = bronze;
		Arc("Second eccentric orbit", P(2f, 18f, 30f), 7.5f, 0.17f, 0.25f, 0f, 360f, bronze, Facing * Quaternion.Euler(15f, 25f, 0f));
		Arc("Suspended pupil", P(0f, 18f, 31f), 3.3f, 0.2f, 0.5f, 0f, 360f, amber, Facing);
		B("Central black aperture", 0f, 18f, 32f, 4f, 4f, 0.2f, dark);
		Label("P A L I N O D E", 0f, 5.4f, 24.7f, 10f, new Color(0.85f, 0.8f, 0.65f));
		Label("T I D A L   O B S E R V A T O R Y   /   0 7 4", 0f, 4.15f, 24.6f, 2.6f, new Color(0.8f, 0.72f, 0.5f));
		Door(0f, 25f, main: true);
		yield return null;
		for (int num5 = -1; num5 <= 1; num5 += 2)
		{
			for (int num6 = 0; num6 < 7; num6++)
			{
				float num7 = (float)num5 * (17f + (float)num6 * 2.6f);
				float num8 = 17f - (float)num6 * 5.8f;
				float num9 = 13f + (float)num6 * 0.8f;
				B("Colonnade foot", num7, 0.6f, num8, 2.4f, 1.2f, 2.4f, dark, solid: true);
				B("Salt column", num7, num9 / 2f, num8, 1.2f, num9, 1.4f, stone, solid: true);
				B("Column collar", num7, 3f, num8, 1.6f, 0.35f, 1.8f, trim);
				B("Column capital", num7, num9, num8, 2.2f, 0.6f, 2.5f, trim);
				Arc("Flying tidal rib", P(num7 + (float)(num5 * 7), num9 - 1f, num8), 7f, 1f, 1.4f, (num5 > 0) ? 90 : 0, 90f, stone, Facing);
				Arc("Rib bronze lining", P(num7 + (float)(num5 * 7), num9 - 1f, num8 - 0.74f), 6.4f, 0.1f, 0.12f, (num5 > 0) ? 90 : 0, 90f, bronze, Facing);
				if (num6 % 2 == 0)
				{
					Lamp(num7, 3.7f, num8 - 1f, warm: true, 650f);
				}
				if (num6 < 6)
				{
					Beam("Arcade lintel", P(num7, num9, num8), P((float)num5 * (17f + (float)(num6 + 1) * 2.6f), num9 + 0.8f, 17f - (float)(num6 + 1) * 5.8f), 1.4f, 0.8f, trim);
				}
			}
		}
		yield return null;
		B("Exit house left", 11.95f, 3.3f, 2.6f, 3.5f, 6.6f, 6f, stone, solid: true);
		B("Exit house right", 18.05f, 3.3f, 2.6f, 3.5f, 6.6f, 6f, stone, solid: true);
		B("Exit house rear", 15f, 3.3f, 5.5f, 8f, 6.6f, 0.7f, stone, solid: true);
		B("Exit door head", 15f, 4.5f, 0.05f, 2.8f, 2.5f, 0.7f, stone, solid: true);
		B("Pavilion copper roof", 15f, 6.8f, 2.5f, 9f, 0.5f, 7f, bronze);
		B("Pavilion cornice", 15f, 6.4f, 2.5f, 9.4f, 0.35f, 7.4f, trim);
		Arc("Exit fanlight", P(15f, 4.5f, -0.37f), 1.4f, 0.18f, 0.1f, 0f, 180f, bronze, Facing);
		Door(15f, 0f, main: false);
		Label("F I R E   E X I T", 15f, 4.1f, -0.44f, 3.8f, new Color(1f, 0.65f, 0.4f));
		Label("01 / SURFACE RETURN", 15f, 5.1f, -0.44f, 1.8f, new Color(0.75f, 0.76f, 0.66f));
		Refuge(0f, 22f);
		Refuge(0f, 11f);
		Refuge(15f, -3f);
		Refuge(7f, -3f);
		for (int num10 = 0; num10 < 5; num10++)
		{
			B("Exit route arrow", 3f + (float)num10 * 2.2f, 0.08f, -1.2f, 0.7f, 0.025f, 0.17f, red);
		}
		Label("MAIN / 25 m", -4f, 1.3f, 2f, 2.2f, new Color(0.93f, 0.72f, 0.37f));
		yield return null;
		for (int num11 = -1; num11 <= 1; num11 += 2)
		{
			for (int num12 = 0; num12 < 4; num12++)
			{
				float num13 = num11 * (9 + num12 % 2 * 3);
				float num14 = 5 + num12 * 4;
				B("Salt garden basin", num13, 0.45f, num14, 2f, 0.9f, 2.5f, stone, solid: true);
				B("Black salt soil", num13, 0.92f, num14, 1.7f, 0.08f, 2.2f, dark);
				for (int num15 = 0; num15 < 5; num15++)
				{
					Vector3 val2 = P(num13 + (float)(num15 % 3 - 1) * 0.35f, 0.94f, num14 + ((float)(num15 % 2) - 0.5f) * 0.6f);
					Beam("Bleached reed", val2, val2 + Vector3.up * (0.8f + (float)num15 * 0.2f) + right * 0.2f, 0.04f, 0.04f, trim);
					Beam("Reed branch", val2 + Vector3.up * 0.5f, val2 + Vector3.up * 1.1f + right * ((num15 % 2 == 0) ? 0.4f : (-0.4f)), 0.025f, 0.025f, trim);
				}
			}
			B("Bench seat", num11 * 9, 1f, 0f, 3f, 0.22f, 1f, bronze, solid: true);
			B("Bench foot", num11 * 10, 0.45f, 0f, 0.2f, 0.9f, 0.7f, bronze, solid: true);
			B("Bench foot", num11 * 8, 0.45f, 0f, 0.2f, 0.9f, 0.7f, bronze, solid: true);
		}
		yield return null;
		Random rng = new Random(74074);
		for (int num16 = 0; num16 < 28; num16++)
		{
			float num17 = (float)num16 * (float)Math.PI * 2f / 28f;
			float num18 = 190 + rng.Next(12);
			float num19 = Mathf.Cos(num17) * num18;
			float num20 = Mathf.Sin(num17) * num18;
			float num21 = 15 + rng.Next(30);
			float num22 = 5 + rng.Next(7);
			B("Drowned perimeter tower", num19, num21 / 2f, num20, num22, num21, num22, stone);
			B("Tower crown", num19, num21, num20, num22 + 1f, 0.8f, num22 + 1f, trim);
			B("Flood line", num19, 3f, num20, num22 + 0.1f, 0.45f, num22 + 0.1f, bronze);
			for (int num23 = 0; (float)num23 < num21 / 4f - 1f; num23++)
			{
				B("Recessed tower window", num19, 4f + (float)num23 * 3.5f, num20 - num22 / 2f - 0.03f, num22 * 0.5f, 1.8f, 0.08f, window);
				B("Tower sill", num19, 3f + (float)num23 * 3.5f, num20 - num22 / 2f - 0.12f, num22 * 0.6f, 0.18f, 0.35f, trim);
			}
			if (num16 % 3 == 0)
			{
				Arc("Broken distant arch", P(num19 + num22, 8f, num20), num22, 1.1f, 2f, 15f, 140f, stone, Facing);
			}
		}
		yield return null;
		B("Inverted sea", 0f, 76f, 15f, 510f, 1f, 510f, water);
		for (int num24 = 0; num24 < 8; num24++)
		{
			Arc("Sea surface ripple", P(0f, 75.4f - (float)num24 * 0.08f, 17f), 20 + num24 * 13, 0.15f + (float)num24 * 0.05f, 0.08f, 0f, 360f, (num24 % 3 == 0) ? cyan : bronze, Facing * Quaternion.Euler(90f, 0f, 0f));
		}
		for (int num25 = 0; num25 < 18; num25++)
		{
			float num26 = (float)num25 * (float)Math.PI * 2f / 18f;
			float num27 = 48 + rng.Next(20);
			float x = Mathf.Cos(num26) * num27;
			float num28 = 17f + Mathf.Sin(num26) * num27;
			float num29 = 12 + rng.Next(22);
			B("Inverted city block", x, 76f - num29 / 2f, num28, 6f, num29, 7f, stone);
			B("Inverted foundation", x, 75f, num28, 8f, 2f, 9f, dark);
			for (int num30 = 0; (float)num30 < num29 / 4f; num30++)
			{
				B("Hanging archive window", x, 74f - (float)num30 * 3.5f, num28 - 3.55f, 3.4f, 1.4f, 0.09f, window);
				B("Hanging archive mullion", x, 74f - (float)num30 * 3.5f, num28 - 3.62f, 0.12f, 1.5f, 0.12f, bronze);
			}
			Beam("Impossible falling water", P(x, 76f - num29, num28), P(x, Mathf.Max(18f, 68f - num29), num28), 0.06f, 0.06f, tideMaterial);
		}
		yield return null;
		for (int num31 = 0; num31 < 10; num31++)
		{
			float radius = 34 + num31 * 7;
			Arc("Tide contour", P(0f, 0.03f, 8f), radius, 0.035f, 0.035f, 0f, 360f, tideMaterial, Facing * Quaternion.Euler(90f, 0f, 0f));
		}
	}

	private void Door(float x, float z, bool main)
	{
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		Material mat = (main ? amber : red);
		float num = (main ? 1.88f : 1.05f);
		for (int i = -1; i <= 1; i += 2)
		{
			B("Native door stone surround", x + (float)i * num, 1.75f, z + 0.2f, 0.3f, 3.5f, 0.7f, trim, solid: true);
			Lamp(x + (float)i * (num + 0.7f), 2.7f, z - 0.3f, main, 550f);
		}
		B("Door header light", x, 3.25f, z - 0.2f, 2.25f, 0.12f, 0.14f, mat);
		B("Entry threshold", x, 0.045f, z - 0.35f, 2.5f, 0.09f, 1f, trim);
		Label(main ? "ENTRANCE" : "EXIT", x, 3.65f, z - 0.38f, 2.2f, main ? new Color(1f, 0.7f, 0.35f) : new Color(1f, 0.38f, 0.19f));
	}

	private void Refuge(float x, float z)
	{
		//IL_000e: 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_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		shelters.Add(P(x, 0f, z));
		B("Refuge tiled floor", x, 0.075f, z, 5f, 0.04f, 5f, floor);
		for (int i = -1; i <= 1; i += 2)
		{
			B("Refuge border", x + (float)i * 2.45f, 0.102f, z, 0.08f, 0.025f, 5f, amber);
			B("Refuge border", x, 0.102f, z + (float)i * 2.45f, 5f, 0.025f, 0.08f, amber);
			B("Refuge pillar", x + (float)i * 2.8f, 2.1f, z, 0.25f, 4.2f, 0.3f, bronze, solid: true);
		}
		Arc("Refuge vault", P(x, 3.9f, z), 2.8f, 0.22f, 1.2f, 0f, 180f, trim, Facing);
		Arc("Refuge vault light", P(x, 3.9f, z - 0.63f), 2.6f, 0.05f, 0.06f, 0f, 180f, amber, Facing);
		Label("TIDE REFUGE", x, 4.5f, z - 0.65f, 1.6f, new Color(1f, 0.64f, 0.3f));
		Lamp(x - 2.8f, 2.4f, z - 0.3f, warm: true, 450f);
	}

	public static void Build()
	{
		//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)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Expected O, but got Unknown
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		Scene scene = SceneManager.GetSceneByName(Plugin.Moon.sceneName);
		if (!((Scene)(ref scene)).IsValid() || !((Scene)(ref scene)).isLoaded)
		{
			throw new InvalidOperationException("Exterior scene missing");
		}
		EntranceTeleport[] source = (from e in Object.FindObjectsOfType<EntranceTeleport>()
			where ((Component)e).gameObject.scene == scene && e.isEntranceToBuilding
			select e).ToArray();
		if (!source.Any((EntranceTeleport e) => e.entranceId == 0) || !source.Any((EntranceTeleport e) => e.entranceId == 1))
		{
			throw new InvalidOperationException("Entrance pair missing");
		}
		GameObject val = new GameObject("PALINODE • The Drowned Observatory");
		SceneManager.MoveGameObjectToScene(val, scene);
		Exterior exterior = (Plugin.World = val.AddComponent<Exterior>());
		exterior.entrances = source;
		exterior.Create(scene);
		((MonoBehaviour)exterior).StartCoroutine(exterior.PrepareSafely(exterior.PrepareExterior()));
	}

	private Vector3 P(float x, float y, float z)
	{
		//IL_0001: 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_000d: 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)
		//IL_0017: 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_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		return ramp + right * x + Vector3.up * y + forward * z;
	}

	private void Create(Scene scene)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: 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_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: 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_01a6: 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_01c4: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		origin = StartOfRound.Instance.shipLandingPosition.position;
		ramp = origin;
		forward = Vector3.forward;
		right = Vector3.right;
		GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
		foreach (GameObject val in rootGameObjects)
		{
			if (!((Object)(object)val == (Object)(object)((Component)this).gameObject))
			{
				Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val2 in componentsInChildren)
				{
					val2.enabled = false;
				}
				Terrain[] componentsInChildren2 = val.GetComponentsInChildren<Terrain>(true);
				foreach (Terrain val3 in componentsInChildren2)
				{
					val3.drawHeightmap = false;
					val3.drawTreesAndFoliage = false;
				}
				Collider[] componentsInChildren3 = val.GetComponentsInChildren<Collider>(true);
				foreach (Collider val4 in componentsInChildren3)
				{
					val4.enabled = false;
				}
				Light[] componentsInChildren4 = val.GetComponentsInChildren<Light>(true);
				foreach (Light val5 in componentsInChildren4)
				{
					((Behaviour)val5).enabled = false;
				}
				LocalVolumetricFog[] componentsInChildren5 = val.GetComponentsInChildren<LocalVolumetricFog>(true);
				foreach (LocalVolumetricFog val6 in componentsInChildren5)
				{
					((Behaviour)val6).enabled = false;
				}
				NavMeshSurface[] componentsInChildren6 = val.GetComponentsInChildren<NavMeshSurface>(true);
				foreach (NavMeshSurface val7 in componentsInChildren6)
				{
					val7.RemoveData();
					((Behaviour)val7).enabled = false;
				}
				NavMeshLink[] componentsInChildren7 = val.GetComponentsInChildren<NavMeshLink>(true);
				foreach (NavMeshLink val8 in componentsInChildren7)
				{
					((Behaviour)val8).enabled = false;
				}
			}
		}
		CaptureNativeDoors(scene);
		AddFireExits();
		CreateMaterials();
		Box("Basin foundation", origin - Vector3.up * 0.65f, new Vector3(460f, 1.3f, 460f), dark, solid: true, Quaternion.identity);
		Flush();
		CreateAtmosphere();
		float[] array = new float[44100];
		for (int num3 = 0; num3 < array.Length; num3++)
		{
			float num4 = (float)num3 / 22050f;
			array[num3] = 0.09f * (Mathf.Sin(num4 * 2f * (float)Math.PI * 110f) + 0.3f * Mathf.Sin(num4 * 2f * (float)Math.PI * 164.81f)) * (0.5f + 0.5f * Mathf.Sin(num4 * (float)Math.PI));
		}
		AudioClip val9 = AudioClip.Create("Observatory tide bell", array.Length, 1, 22050, false);
		val9.SetData(array, 0);
		owned.Add((Object)(object)val9);
		hum = ((Component)this).gameObject.AddComponent<AudioSource>();
		hum.clip = val9;
		hum.loop = true;
		hum.spatialBlend = 0f;
		hum.volume = 0f;
		hum.Play();
	}

	private IEnumerator PrepareSafely(IEnumerator steps)
	{
		Stack<IEnumerator> pending = new Stack<IEnumerator>();
		pending.Push(steps);
		while (pending.Count > 0 && Plugin.Active)
		{
			object next = null;
			bool advanced;
			try
			{
				advanced = pending.Peek().MoveNext();
				if (advanced)
				{
					next = pending.Peek().Current;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Palinode exterior preparation failed: " + ex));
				((Behaviour)this).enabled = false;
				break;
			}
			if (!advanced)
			{
				pending.Pop();
			}
			else if (next is IEnumerator nested)
			{
				pending.Push(nested);
			}
			else
			{
				yield return next;
			}
		}
	}

	private IEnumerator PrepareExterior()
	{
		yield return null;
		float started = Time.realtimeSinceStartup;
		StartOfRound s = StartOfRound.Instance;
		ramp = s.groundOutsideShipSpawnPosition.position;
		ramp.y = origin.y;
		Exterior exterior = this;
		Vector3 val = Vector3.ProjectOnPlane(ramp - s.middleOfShipNode.position, Vector3.up);
		exterior.forward = ((Vector3)(ref val)).normalized;
		if (((Vector3)(ref forward)).sqrMagnitude < 0.5f)
		{
			forward = Vector3.forward;
		}
		right = Vector3.Cross(Vector3.up, forward);
		yield return BuildDistrict();
		yield return BuildOuterDistrict();
		yield return BuildRefinements();
		AnchorDoors();
		yield return FlushInFrames();
		yield return BakeNavMeshInFrames();
		yield return PrepareSoundtrack();
		GameObject[] nodes = (from x in GameObject.FindGameObjectsWithTag("OutsideAINode")
			where x.scene == ((Component)this).gameObject.scene
			select x).ToArray();
		NavMeshHit val3 = default(NavMeshHit);
		for (int num = 0; num < nodes.Length; num++)
		{
			float num2 = (float)num * (float)Math.PI * 2f / (float)Math.Max(1, nodes.Length);
			float num3 = 48 + num % 5 * 29;
			Vector3 val2 = P(Mathf.Cos(num2) * num3, 0.1f, Mathf.Sin(num2) * num3);
			nodes[num].transform.position = (NavMesh.SamplePosition(val2, ref val3, 12f, -1) ? ((NavMeshHit)(ref val3)).position : val2);
		}
		districtLights = ((Component)this).GetComponentsInChildren<Light>();
		anchored = true;
		soundtrack.Play();
		Plugin.Log.LogInfo((object)("PALINODE exterior ready in " + (Time.realtimeSinceStartup - started).ToString("F2") + "s; before landing=" + !s.shipHasLanded + "; " + ((Component)this).GetComponentsInChildren<Renderer>().Length + " renderers, " + sources.Count + " navigation sources."));
	}

	private void AnchorDoors()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: 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_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: 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_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
		EntranceTeleport[] array = entrances;
		foreach (EntranceTeleport val in array)
		{
			NetworkObject component = ((Component)val).GetComponent<NetworkObject>();
			if ((Object)(object)component != (Object)null)
			{
				component.AutoObjectParentSync = false;
			}
			int site = exitSites[val];
			Vector2 val2 = ExitOffset(site);
			Vector3 val3 = P(val2.x, 0f, val2.y);
			PlaceNativeDoor(val.entranceId, val3);
			Vector3 val4 = nativeDoorSizes[val.entranceId];
			Vector3 val5 = val3 + Vector3.up * (val4.y * 0.5f);
			object? value = AccessTools.Field(typeof(EntranceTeleport), "triggerScript").GetValue(val);
			InteractTrigger val6 = (InteractTrigger)((value is InteractTrigger) ? value : null);
			if ((Object)(object)val6 == (Object)null)
			{
				val6 = ((Component)val).GetComponent<InteractTrigger>() ?? ((Component)val).GetComponentInChildren<InteractTrigger>(true);
			}
			if ((Object)(object)val6 == (Object)null)
			{
				throw new InvalidOperationException("Door has no interaction trigger: " + val.entranceId);
			}
			Transform entrancePoint = val.entrancePoint;
			entrancePoint.SetParent(((Component)this).transform, true);
			if ((Object)(object)((Component)val6).transform != (Object)(object)((Component)val).transform)
			{
				((Component)val6).transform.SetParent(((Component)this).transform, true);
			}
			((Component)val).transform.SetParent(((Component)this).transform, true);
			((Component)val).transform.SetPositionAndRotation(val5, Facing);
			((Component)val).transform.localScale = Vector3.one;
			((Component)val6).transform.SetPositionAndRotation(val5, Facing);
			((Component)val6).transform.localScale = Vector3.one;
			Collider[] componentsInChildren = ((Component)val6).GetComponentsInChildren<Collider>(true);
			foreach (Collider val7 in componentsInChildren)
			{
				val7.enabled = false;
			}
			BoxCollider val8 = ((Component)val6).GetComponent<BoxCollider>();
			if ((Object)(object)val8 == (Object)null)
			{
				val8 = ((Component)val6).gameObject.AddComponent<BoxCollider>();
			}
			val8.center = Vector3.zero;
			val8.size = new Vector3(val4.x, val4.y, 0.48f);
			((Collider)val8).isTrigger = true;
			((Collider)val8).enabled = true;
			entrancePoint.SetPositionAndRotation(val3 - forward * 1.55f + Vector3.up * 0.2f, Quaternion.LookRotation(-forward));
			val6.interactable = true;
			val6.hoverTip = ((val.entranceId == 0) ? "Enter observatory : [LMB]" : "Use fire exit : [LMB]");
			ManualLogSource log = Plugin.Log;
			object[] array2 = new object[8] { "Door ", val.entranceId, " aligned: visual=", val5, " collider=", null, null, null };
			Bounds bounds = ((Collider)val8).bounds;
			array2[5] = ((Bounds)(ref bounds)).center;
			array2[6] = " arrival=";
			array2[7] = entrancePoint.position;
			log.LogInfo((object)string.Concat(array2));
		}
	}

	private IEnumerator BakeNavMeshInFrames()
	{
		Bounds bounds = new Bounds(origin, new Vector3(470f, 90f, 470f));
		for (int i = 0; i < NavMesh.GetSettingsCount(); i++)
		{
			NavMeshBuildSettings settings = NavMesh.GetSettingsByIndex(i);
			NavMeshData data = new NavMeshData(((NavMeshBuildSettings)(ref settings)).agentTypeID);
			owned.Add((Object)(object)data);
			yield return NavMeshBuilder.UpdateNavMeshDataAsync(data, settings, sources, bounds);
			if ((Object)(object)data != (Object)null)
			{
				navigation.Add(NavMesh.AddNavMeshData(data));
			}
		}
	}

	private bool Sheltered(PlayerControllerB p)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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)
		//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_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		if (!p.isInHangarShipRoom && !p.isInsideFactory)
		{
			Bounds bounds = StartOfRound.Instance.shipBounds.bounds;
			if (!((Bounds)(ref bounds)).Contains(((Component)p).transform.position))
			{
				foreach (Vector3 shelter in shelters)
				{
					Vector3 val = ((Component)p).transform.position - shelter;
					if (Mathf.Abs(Vector3.Dot(val, right)) <= 2.5f && Mathf.Abs(Vector3.Dot(val, forward)) <= 2.5f)
					{
						return true;
					}
				}
				return false;
			}
		}
		return true;
	}

	private void LateUpdate()
	{
		if (!Plugin.Active || (Object)(object)StartOfRound.Instance == (Object)null)
		{
			return;
		}
		StartOfRound instance = StartOfRound.Instance;
		PlayerControllerB val = instance.localPlayerController;
		if ((Object)(object)val != (Object)null && val.isPlayerDead && !instance.overrideSpectateCamera && (Object)(object)val.spectatedPlayerScript != (Object)null)
		{
			val = val.spectatedPlayerScript;
		}
		bool flag = (Object)(object)val != (Object)null && val.isInsideFactory;
		if ((Object)(object)skyVolume != (Object)null)
		{
			((Behaviour)skyVolume).enabled = !flag;
		}
		if (districtLights == null || wasInside == flag)
		{
			return;
		}
		wasInside = flag;
		Light[] array = districtLights;
		foreach (Light val2 in array)
		{
			if ((Object)(object)val2 != (Object)null)
			{
				((Behaviour)val2).enabled = !flag;
			}
		}
	}

	private void Update()
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: 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_0221: 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_0258: 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_034c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		if (!Plugin.Active || (Object)(object)StartOfRound.Instance == (Object)null)
		{
			return;
		}
		StartOfRound instance = StartOfRound.Instance;
		if (instance.shipHasLanded && landedAt < 0f)
		{
			landedAt = Time.time;
		}
		UpdateSoundtrack(instance);
		PlayerControllerB localPlayerController = instance.localPlayerController;
		if (!anchored || !instance.shipHasLanded || instance.shipIsLeaving || (Object)(object)localPlayerController == (Object)null || !localPlayerController.isPlayerControlled || localPlayerController.isPlayerDead)
		{
			if ((Object)(object)hum != (Object)null)
			{
				hum.volume = 0f;
			}
			return;
		}
		if (!announced)
		{
			HUDManager.Instance.DisplayTip("074 PALINODE / SS", "Observatory ahead. Four fire exits: landing court, aqueduct, freight quay, cloister.\nWhen the tide bell sounds, seek an amber refuge.", false, false, "Palinode");
			announced = true;
		}
		float normalizedTimeOfDay = TimeOfDay.Instance.normalizedTimeOfDay;
		NetworkTime serverTime = NetworkManager.Singleton.ServerTime;
		double time = ((NetworkTime)(ref serverTime)).Time;
		float num = (float)(time % 72.0);
		int num2 = ((!(normalizedTimeOfDay < 0.3f)) ? ((num >= 56f) ? 2 : ((num >= 48f) ? 1 : 0)) : 0);
		if (num2 == 0)
		{
			tideWarned = false;
		}
		if (num2 == 1)
		{
			tideWarned = true;
		}
		bool flag = !localPlayerController.isInsideFactory && !localPlayerController.isInHangarShipRoom;
		if (num2 != lastStage && flag && num2 > 0)
		{
			HUDManager.Instance.DisplayTip((num2 == 1) ? "TIDE BELL / SEEK AMBER" : "NEGATIVE TIDE", (num2 == 1) ? "The sea falls in 8 seconds. Reach a lit refuge or the ship." : "Remain inside the amber border until the bell stops.", true, false, "PalinodeTide");
		}
		lastStage = num2;
		hum.volume = ((!flag || num2 <= 0) ? 0f : ((num2 == 1) ? 0.28f : 0.4f));
		if ((Object)(object)halo != (Object)null)
		{
			halo.localRotation = Facing * Quaternion.AngleAxis((float)(time * 0.8), Vector3.forward);
		}
		if ((Object)(object)water != (Object)null)
		{
			water.SetTextureOffset("_BaseColorMap", new Vector2((float)(time * 0.001), 0f));
		}
		if ((Object)(object)tideMaterial != (Object)null)
		{
			tideMaterial.SetColor("_EmissiveColor", ((num2 == 2) ? new Color(0.25f, 0.9f, 1f) : new Color(0.03f, 0.15f, 0.17f)) * ((num2 == 2) ? 2f : 0.4f));
		}
		bool flag2 = num2 == 2 && tideWarned && !Sheltered(localPlayerController) && Time.time - landedAt > 12f;
		exposure = (flag2 ? (exposure + Time.deltaTime) : 0f);
		damageTimer += Time.deltaTime;
		if (damageTimer >= 1f)
		{
			damageTimer = 0f;
			if (flag2 && exposure > 1f && ((NetworkBehaviour)localPlayerController).IsOwner)
			{
				localPlayerController.DamagePlayer((normalizedTimeOfDay >= 0.65f) ? 25 : 20, true, true, (CauseOfDeath)13, 0, false, Vector3.zero);
			}
			if (!localPlayerController.isInsideFactory && ((Component)localPlayerController).transform.position.y < origin.y - 12f && ((NetworkBehaviour)localPlayerController).IsOwner)
			{
				localPlayerController.DamagePlayer(100, true, true, (CauseOfDeath)2, 0, false, Vector3.zero);
			}
		}
	}

	private void OnDestroy()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		if (exitMessages != null)
		{
			exitMessages.UnregisterNamedMessageHandler("local.palinode.extraexit.v1");
		}
		foreach (NavMeshDataInstance item in navigation)
		{
			NavMeshDataInstance current = item;
			if (((NavMeshDataInstance)(ref current)).valid)
			{
				((NavMeshDataInstance)(ref current)).Remove();
			}
		}
		foreach (Object item2 in owned)
		{
			if (item2 != (Object)null)
			{
				NavMeshData val = (NavMeshData)(object)((item2 is NavMeshData) ? item2 : null);
				if ((Object)(object)val != (Object)null)
				{
					NavMeshBuilder.Cancel(val);
				}
				Object.Destroy(item2);
			}
		}
		if ((Object)(object)Plugin.World == (Object)(object)this)
		{
			Plugin.World = null;
		}
	}

	private Vector2 ExitOffset(int site)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		return (Vector2)(site switch
		{
			0 => new Vector2(0f, 25f), 
			1 => new Vector2(15f, 0f), 
			2 => new Vector2(-105f, 14f), 
			3 => new Vector2(110f, 14f), 
			_ => new Vector2(0f, 171f), 
		});
	}

	private void AddFireExits()
	{
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Expected O, but got Unknown
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Expected O, but got Unknown
		EntranceTeleport val = entrances.First((EntranceTeleport e) => e.entranceId == 1);
		exitSites[entrances.First((EntranceTeleport e) => e.entranceId == 0)] = 0;
		exitSites[val] = 1;
		List<EntranceTeleport> list = entrances.ToList();
		for (int num = 2; num <= 4; num++)
		{
			GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)this).transform);
			((Object)val2).name = "PALINODE fire exit " + num;
			ExtraExit extraExit = val2.AddComponent<ExtraExit>();
			extraExit.Site = num;
			EntranceTeleport component = val2.GetComponent<EntranceTeleport>();
			component.entranceId = num;
			component.exitScript = null;
			GameObject val3 = new GameObject("Fire exit " + num + " arrival");
			val3.transform.SetParent(((Component)this).transform);
			component.entrancePoint = val3.transform;
			component.entrancePointAudio = val3.AddComponent<AudioSource>();
			component.entrancePointAudio.spatialBlend = 1f;
			component.entrancePointAudio.maxDistance = 20f;
			component.entrancePointAudio.outputAudioMixerGroup = val.entrancePointAudio.outputAudioMixerGroup;
			nativeDoors[num] = Object.Instantiate<GameObject>(nativeDoors[1], ((Component)this).transform);
			((Object)nativeDoors[num]).name = "Vanilla fire exit visual " + num;
			nativeDoorSizes[num] = nativeDoorSizes[1];
			exitSites[component] = num;
			list.Add(component);
		}
		entrances = list.ToArray();
		RestoreExitIds();
		exitMessages = NetworkManager.Singleton.CustomMessagingManager;
		exitMessages.RegisterNamedMessageHandler("local.palinode.extraexit.v1", new HandleNamedMessageDelegate(ReceiveExtraExit));
	}

	internal void RestoreExitIds()
	{
		foreach (KeyValuePair<EntranceTeleport, int> exitSite in exitSites)
		{
			if ((Object)(object)exitSite.Key != (Object)null)
			{
				exitSite.Key.entranceId = exitSite.Value;
			}
		}
	}

	internal unsafe void SendExtraExit(EntranceTeleport source, int player)
	{
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		NetworkManager singleton = NetworkManager.Singleton;
		if ((Object)(object)singleton == (Object)null || !singleton.IsListening || !Plugin.Active || player < 0 || player > 255)
		{
			return;
		}
		if (singleton.IsServer)
		{
			RelayExtraExit(singleton.LocalClientId, source.entranceId, player);
			return;
		}
		FastBufferWriter val = default(FastBufferWriter);
		((FastBufferWriter)(ref val))..ctor(2, (Allocator)2, -1);
		try
		{
			((FastBufferWriter)(ref val)).WriteByteSafe((byte)source.entranceId);
			((FastBufferWriter)(ref val)).WriteByteSafe((byte)player);
			exitMessages.SendNamedMessage("local.palinode.extraexit.v1", 0uL, val, (NetworkDelivery)3);
		}
		finally
		{
			((IDisposable)(*(FastBufferWriter*)(&val))/*cast due to .constrained prefix*/).Dispose();
		}
	}

	private void ReceiveExtraExit(ulong sender, FastBufferReader reader)
	{
		if (Plugin.Active && ((FastBufferReader)(ref reader)).TryBeginRead(2))
		{
			byte id = default(byte);
			((FastBufferReader)(ref reader)).ReadByteSafe(ref id);
			byte player = default(byte);
			((FastBufferReader)(ref reader)).ReadByteSafe(ref player);
			NetworkManager singleton = NetworkManager.Singleton;
			if (singleton.IsServer)
			{
				RelayExtraExit(sender, id, player);
			}
			else if (sender == 0)
			{
				ApplyExtraExit(id, player);
			}
		}
	}

	private unsafe void RelayExtraExit(ulong sender, int id, int player)
	{
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)instance == (Object)null || player < 0 || player >= instance.allPlayerScripts.Length)
		{
			return;
		}
		PlayerControllerB val = instance.allPlayerScripts[player];
		EntranceTeleport val2 = ((IEnumerable<EntranceTeleport>)entrances).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport e) => e.entranceId == id && (Object)(object)((Component)e).GetComponent<ExtraExit>() != (Object)null));
		if ((Object)(object)val == (Object)null || val.actualClientId != sender || val.isPlayerDead || (Object)(object)val2 == (Object)null || !val2.FindExitPoint())
		{
			return;
		}
		ApplyExtraExit(id, player);
		FastBufferWriter val3 = default(FastBufferWriter);
		((FastBufferWriter)(ref val3))..ctor(2, (Allocator)2, -1);
		try
		{
			((FastBufferWriter)(ref val3)).WriteByteSafe((byte)id);
			((FastBufferWriter)(ref val3)).WriteByteSafe((byte)player);
			foreach (ulong connectedClientsId in NetworkManager.Singleton.ConnectedClientsIds)
			{
				if (connectedClientsId != 0)
				{
					exitMessages.SendNamedMessage("local.palinode.extraexit.v1", connectedClientsId, val3, (NetworkDelivery)3);
				}
			}
		}
		finally
		{
			((IDisposable)(*(FastBufferWriter*)(&val3))/*cast due to .constrained prefix*/).Dispose();
		}
	}

	private void ApplyExtraExit(int id, int player)
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		StartOfRound instance = StartOfRound.Instance;
		if ((Object)(object)instance == (Object)null || player < 0 || player >= instance.allPlayerScripts.Length)
		{
			return;
		}
		PlayerControllerB val = instance.allPlayerScripts[player];
		if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)instance.localPlayerController)
		{
			return;
		}
		EntranceTeleport val2 = ((IEnumerable<EntranceTeleport>)entrances).FirstOrDefault((Func<EntranceTeleport, bool>)((EntranceTeleport e) => e.entranceId == id));
		if ((Object)(object)val2 == (Object)null || !val2.FindExitPoint())
		{
			return;
		}
		val.TeleportPlayer(val2.exitScript.entrancePoint.position, true, val2.exitScript.entrancePoint.eulerAngles.y, false, true);
		val.isInElevator = false;
		val.isInHangarShipRoom = false;
		val.isInsideFactory = true;
		GrabbableObject[] itemSlots = val.ItemSlots;
		foreach (GrabbableObject val3 in itemSlots)
		{
			if ((Object)(object)val3 != (Object)null)
			{
				val3.isInFactory = true;
			}
		}
		if ((Object)(object)val.ItemOnlySlot != (Object)null)
		{
			val.ItemOnlySlot.isInFactory = true;
		}
		if ((Object)(object)instance.localPlayerController != (Object)null && instance.localPlayerController.isPlayerDead && (Object)(object)instance.localPlayerController.spectatedPlayerScript == (Object)(object)val)
		{
			AccessTools.Method(typeof(EntranceTeleport), "SetAudioPreset", (Type[])null, (Type[])null).Invoke(val2, new object[1] { player });
		}
		else
		{
			val2.PlayAudioAtTeleportPositions();
		}
	}

	private Material Surface(string name, Color color, float smooth, float metal, int texture)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_002a: 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_0085: Expected O, but got Unknown
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Expected O, but got Unknown
		//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: 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_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		Material val = new Material(Shader.Find("HDRP/Lit"));
		((Object)val).name = name;
		owned.Add((Object)(object)val);
		val.SetColor("_BaseColor", color);
		val.SetFloat("_Smoothness", smooth);
		val.SetFloat("_Metallic", metal);
		if (texture >= 0)
		{
			if (surfaceTextures.TryGetValue(texture, out var value))
			{
				SetSurfaceTextures(val, value[0], value[1], texture);
				return val;
			}
			Texture2D val2 = new Texture2D(512, 512, (TextureFormat)4, true);
			((Object)val2).name = name + " patina";
			((Texture)val2).wrapMode = (TextureWrapMode)0;
			((Texture)val2).anisoLevel = 4;
			Color[] array = (Color[])(object)new Color[262144];
			Texture2D val3 = new Texture2D(512, 512, (TextureFormat)4, true, true);
			((Texture)val3).wrapMode = (TextureWrapMode)0;
			((Texture)val3).anisoLevel = 4;
			Color[] array2 = (Color[])(object)new Color[262144];
			float[] array3 = new float[262144];
			Random random = new Random(74074 + texture);
			Color val4 = default(Color);
			for (int i = 0; i < 512; i++)
			{
				for (int j = 0; j < 512; j++)
				{
					float num = Mathf.PerlinNoise((float)j * 0.071f, (float)i * 0.071f) * 0.26f + Mathf.PerlinNoise((float)j * 0.31f, (float)i * 0.31f) * 0.12f;
					float num2 = Mathf.PerlinNoise((float)j * 0.014f, (float)i * 0.038f);
					int num3 = i / 64;
					int num4 = (j + num3 % 2 * 64) % 128;
					bool flag = texture switch
					{
						1 => j % 64 < 2 || i % 64 < 2, 
						0 => i % 64 < 3 || num4 < 3, 
						_ => false, 
					};
					float num5 = Mathf.Sin((float)j * 0.09f + Mathf.Sin((float)i * 0.055f) * 4f) + Mathf.Sin((float)i * 0.12f + (float)j * 0.023f);
					float num6 = (flag ? 0.23f : (0.52f + num));
					if (texture == 2)
					{
						num6 = 0.55f + num + num5 * 0.06f;
					}
					if (texture == 3)
					{
						num6 = 0.5f + num + ((j % 32 < 2) ? 0.18f : 0f);
					}
					float num7 = (float)random.NextDouble() * 0.1f;
					((Color)(ref val4))..ctor(num6 + num7, num6 + num7, num6 + num7);
					if (num2 < 0.48f && texture != 2)
					{
						val4 = Color.Lerp(val4, new Color(0.23f, 0.36f, 0.31f), (0.48f - num2) * 1.7f);
					}
					if (texture == 3 && num2 > 0.55f)
					{
						val4 = Color.Lerp(val4, new Color(0.41f, 0.24f, 0.12f), (num2 - 0.55f) * 2f);
					}
					array[i * 512 + j] = val4;
					array3[i * 512 + j] = ((texture == 2) ? (num5 * 0.06f) : (flag ? 0f : (num + 0.3f)));
				}
			}
			for (int k = 0; k < 512; k++)
			{
				for (int l = 0; l < 512; l++)
				{
					float num8 = (array3[k * 512 + (l + 1) % 512] - array3[k * 512 + (l + 512 - 1) % 512]) * 1.4f;
					float num9 = (array3[(k + 1) % 512 * 512 + l] - array3[(k + 512 - 1) % 512 * 512 + l]) * 1.4f;
					Vector3 val5 = new Vector3(0f - num8, 0f - num9, 1f);
					Vector3 normalized = ((Vector3)(ref val5)).normalized;
					ref Color reference = ref array2[k * 512 + l];
					reference = new Color(normalized.x * 0.5f + 0.5f, normalized.y * 0.5f + 0.5f, normalized.z * 0.5f + 0.5f, 1f);
				}
			}
			val2.SetPixels(array);
			val2.Apply(true, true);
			val3.SetPixels(array2);
			val3.Apply(true, true);
			owned.Add((Object)(object)val2);
			owned.Add((Object)(object)val3);
			surfaceTextures[texture] = (Texture2D[])(object)new Texture2D[2] { val2, val3 };
			SetSurfaceTextures(val, val2, val3, texture);
		}
		return val;
	}

	private void SetSurfaceTextures(Material material, Texture2D color, Texture2D normal, int texture)
	{
		material.SetTexture("_BaseColorMap", (Texture)(object)color);
		material.SetTexture("_NormalMap", (Texture)(object)normal);
		material.SetFloat("_NormalScale", (texture == 2) ? 0.7f : 0.45f);
		material.EnableKeyword("_NORMALMAP_TANGENT_SPACE");
	}

	private Material Emission(string name, Color color, float strength)
	{
		//IL_0002: 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_001c: Unknown result type (might be due to invalid IL or missing references)
		Material val = Surface(name, color, 0.45f, 0.15f, -1);
		val.SetColor("_EmissiveColor", color * strength);
		val.SetFloat("_EmissiveExposureWeight", 0.4f);
		return val;
	}

	private void CreateMaterials()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: 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_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: 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)
		stone = Surface("Salt-scoured limestone", new Color(0.64f, 0.67f, 0.61f), 0.32f, 0f, 0);
		trim = Surface("Pale carved travertine", new Color(0.82f, 0.76f, 0.61f), 0.45f, 0.05f, 0);
		floor = Surface("Rain-dark observatory tiles", new Color(0.48f, 0.54f, 0.49f), 0.48f, 0.08f, 1);
		bronze = Surface("Oxidised bronze", new Color(0.36f, 0.47f, 0.37f), 0.63f, 0.65f, 3);
		dark = Surface("Deep basalt", new Color(0.22f, 0.28f, 0.28f), 0.35f, 0.05f, 0);
		water = Surface("Tidal mirror", new Color(0.1f, 0.29f, 0.31f), 0.94f, 0.7f, 2);
		amber = Emission("Amber refuge lamps", new Color(1f, 0.53f, 0.15f), 3f);
		cyan = Emission("Sea phosphor", new Color(0.32f, 0.87f, 0.85f), 1.5f);
		red = Emission("Exit vermilion", new Color(0.95f, 0.16f, 0.07f), 1.6f);
		window = Emission("Archive glass", new Color(0.18f, 0.37f, 0.37f), 0.22f);
		tideMaterial = Emission("Negative tide veins", new Color(0.03f, 0.15f, 0.17f), 0.4f);
	}

	private void AddMesh(Mesh mesh, Material material, Matrix4x4 matrix)
	{
		//IL_003a: 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)
		owned.Add((Object)(object)mesh);
		if (!batches.ContainsKey(material))
		{
			batches.Add(material, new List<CombineInstance>());
		}
		List<CombineInstance> list = batches[material];
		CombineInstance item = default(CombineInstance);
		((CombineInstance)(ref item)).mesh = mesh;
		((CombineInstance)(ref item)).transform = matrix;
		list.Add(item);
	}

	private void Box(string name, Vector3 center, Vector3 size, Material material, bool solid, Quaternion rotation)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: 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)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: 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_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: 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_0261: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Expected O, but got Unknown
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: 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_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015b: 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_0162: 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_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		Mesh val = new Mesh();
		((Object)val).name = name;
		List<Vector3> list = new List<Vector3>();
		List<Vector2> list2 = new List<Vector2>();
		List<int> list3 = new List<int>();
		Vector3[] array = (Vector3[])(object)new Vector3[6]
		{
			Vector3.right,
			Vector3.left,
			Vector3.up,
			Vector3.down,
			Vector3.forward,
			Vector3.back
		};
		Vector3[] array2 = array;
		for (int i = 0; i < array2.Length; i++)
		{
			Vector3 val2 = array2[i];
			Vector3 val3 = ((Mathf.Abs(val2.y) > 0.5f) ? Vector3.right : Vector3.Cross(Vector3.up, val2));
			Vector3 val4 = Vector3.Cross(val2, val3);
			Vector3 val5 = Vector3.Scale(val3, size) * 0.5f;
			Vector3 val6 = Vector3.Scale(val4, size) * 0.5f;
			Vector3 val7 = Vector3.Scale(val2, size) * 0.5f;
			int count = list.Count;
			list.Add(val7 - val5 - val6);
			list.Add(val7 + val5 - val6);
			list.Add(val7 + val5 + val6);
			list.Add(val7 - val5 + val6);
			float num = ((Vector3)(ref val5)).magnitude * 0.5f;
			float num2 = ((Vector3)(ref val6)).magnitude * 0.5f;
			list2.Add(Vector2.zero);
			list2.Add(new Vector2(num, 0f));
			list2.Add(new Vector2(num, num2));
			list2.Add(new Vector2(0f, num2));
			list3.AddRange(new int[6]
			{
				count,
				count + 1,
				count + 2,
				count,
				count + 2,
				count + 3
			});
		}
		val.SetVertices(list);
		val.SetUVs(0, list2);
		val.SetTriangles(list3, 0);
		val.RecalculateNormals();
		val.RecalculateTangents();
		Matrix4x4 val8 = Matrix4x4.TRS(center, rotation, Vector3.one);
		AddMesh(val, material, val8);
		if (solid)
		{
			GameObject val9 = new GameObject(name + " collision");
			val9.transform.SetParent(((Component)this).transform);
			val9.transform.SetPositionAndRotation(center, rotation);
			val9.layer = LayerMask.NameToLayer("Room");
			val9.AddComponent<BoxCollider>().size = size;
			List<NavMeshBuildSource> list4 = sources;
			NavMeshBuildSource item = default(NavMeshBuildSource);
			((NavMeshBuildSource)(ref item)).shape = (NavMeshBuildSourceShape)2;
			((NavMeshBuildSource)(ref item)).transform = val8;
			((NavMeshBuildSource)(ref item)).size = size;
			((NavMeshBuildSource)(ref item)).area = 0;
			list4.Add(item);
		}
	}

	private void B(string name, float x, float y, float z, float sx, float sy, float sz, Material mat, bool solid = false)
	{
		//IL_0007: 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)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		Box(name, P(x, y, z), new Vector3(sx, sy, sz), mat, solid, Facing);
	}

	private void Beam(string name, Vector3 a, Vector3 b, float width, float depth, Material material, bool solid = false)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		Box(name, (a + b) * 0.5f, new Vector3(width, depth, Vector3.Distance(a, b)), material, solid, Quaternion.LookRotation(b - a));
	}

	private Mesh RingMesh(float radius, float width, float depth, float start, float sweep, int segments)
	{
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		List<Vector2> list2 = new List<Vector2>();
		List<int> list3 = new List<int>();
		for (int i = 0; i <= segments; i++)
		{
			float num = (start + (float)i * sweep / (float)segments) * ((float)Math.PI / 180f);
			for (int j = 0; j < 4; j++)
			{
				float num2 = radius + ((j == 0 || j == 3) ? (width * 0.5f) : ((0f - width) * 0.5f));
				list.Add(new Vector3(Mathf.Cos(num) * num2, Mathf.Sin(num) * num2, (j < 2) ? ((0f - depth) * 0.5f) : (depth * 0.5f)));
				list2.Add(new Vector2((float)i * radius * sweep * ((float)Math.PI / 180f) / (float)segments / 4f, (float)j * 0.25f));
			}
			if (i != segments)
			{
				for (int k = 0; k < 4; k++)
				{
					int num3 = i * 4 + k;
					int num4 = i * 4 + (k + 1) % 4;
					list3.AddRange(new int[6]
					{
						num3,
						num4,
						num4 + 4,
						num3,
						num4 + 4,
						num3 + 4
					});
				}
			}
		}
		Mesh val = new Mesh();
		val.SetVertices(list);
		val.SetUVs(0, list2);
		val.SetTriangles(list3, 0);
		val.RecalculateNormals();
		val.RecalculateTangents();
		return val;
	}

	private void Arc(string name, Vector3 center, float radius, float width, float depth, float start, float sweep, Material material, Quaternion rot)
	{
		//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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		Mesh val = RingMesh(radius, width, depth, start, sweep, Mathf.Max(12, (int)(sweep / 4f)));
		((Object)val).name = name;
		AddMesh(val, material, Matrix4x4.TRS(center, rot, Vector3.one));
	}

	private void Flush()
	{
		IEnumerator enumerator = FlushInFrames();
		while (enumerator.MoveNext())
		{
		}
	}

	private IEnumerator FlushInFrames()
	{
		foreach (KeyValuePair<Material, List<CombineInstance>> pair in batches)
		{
			int i = 0;
			while (true)
			{
				int num = i;
				KeyValuePair<Material, List<CombineInstance>> keyValuePair = pair;
				if (num >= keyValuePair.Value.Count)
				{
					break;
				}
				KeyValuePair<Material, List<CombineInstance>> keyValuePair2 = pair;
				List<CombineInstance> value = keyValuePair2.Value;
				int index = i;
				KeyValuePair<Material, List<CombineInstance>> keyValuePair3 = pair;
				List<CombineInstance> chunk = value.GetRange(index, Math.Min(200, keyValuePair3.Value.Count - i));
				Mesh combined = new Mesh();
				combined.indexFormat = (IndexFormat)1;
				KeyValuePair<Material, List<CombineInstance>> keyValuePair4 = pair;
				((Object)combined).name = "PALINODE batched " + ((Object)keyValuePair4.Key).name;
				combined.CombineMeshes(chunk.ToArray(), true, true);
				owned.Add((Object)(object)combined);
				foreach (CombineInstance item in chunk)
				{
					CombineInstance current = item;
					owned.Remove((Object)(object)((CombineInstance)(ref current)).mesh);
					Object.Destroy((Object)(object)((CombineInstance)(ref current)).mesh);
				}
				GameObject obj = new GameObject(((Object)combined).name);
				obj.transform.SetParent(((Component)this).transform, false);
				obj.AddComponent<MeshFilter>().sharedMesh = combined;
				MeshRenderer renderer = obj.AddComponent<MeshRenderer>();
				KeyValuePair<Material, List<CombineInstance>> keyValuePair5 = pair;
				((Renderer)renderer).sharedMaterial = keyValuePair5.Key;
				KeyValuePair<Material, List<CombineInstance>> keyValuePair6 = pair;
				((Renderer)renderer).shadowCastingMode = (ShadowCastingMode)(!((Object)(object)keyValuePair6.Key == (Object)(object)water));
				yield return null;
				i += 200;
			}
		}
		batches.Clear();
	}

	private void Lamp(float x, float y, float z, bool warm, float intensity = 350f)
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Expected O, but got Unknown
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		B("Brass lamp housing", x, y, z, 0.42f, 0.85f, 0.45f, bronze);
		B("Lamp glass", x, y, z - 0.245f, 0.27f, 0.56f, 0.04f, warm ? amber : cyan);
		GameObject val = new GameObject("Observatory lantern");
		val.transform.SetParent(((Component)this).transform);
		val.transform.position = P(x, y, z - 0.4f);
		Light val2 = val.AddComponent<Light>();
		val2.type = (LightType)2;
		val2.color = (warm ? new Color(1f, 0.56f, 0.25f) : new Color(0.36f, 0.8f, 0.86f));
		val2.range = 10f;
		val2.shadows = (LightShadows)0;
		HDAdditionalLightData val3 = val.AddComponent<HDAdditionalLightData>();
		val3.SetIntensity(intensity, (LightUnit)0);
	}

	private void Label(string words, float x, float y, float z, float size, Color color)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		GameObject val = new GameObject("Sign • " + words);
		val.transform.SetParent(((Component)this).transform);
		val.transform.SetPositionAndRotation(P(x, y, z), Facing);
		TextMeshPro val2 = val.AddComponent<TextMeshPro>();
		((TMP_Text)val2).text = words;
		((TMP_Text)val2).fontSize = size;
		((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
		((Graphic)val2).color = color;
		((TMP_Text)val2).rectTransform.sizeDelta = new Vector2(24f, 5f);
		((TMP_Text)val2).enableWordWrapping = false;
		((TMP_Text)val2).fontSharedMaterial = new Material(((TMP_Text)val2).fontSharedMaterial);
		owned.Add((Object)(object)((TMP_Text)val2).fontSharedMaterial);
		((TMP_Text)val2).fontSharedMaterial.SetFloat("_CullMode", 0f);
	}

	private void CreateAtmosphere()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("PALINODE exterior atmosphere");
		val.transform.SetParent(((Component)this).transform);
		val.layer = 0;
		skyVolume = val.AddComponent<Volume>();
		skyVolume.isGlobal = true;
		skyVolume.priority = 500f;
		VolumeProfile val2 = ScriptableObject.CreateInstance<VolumeProfile>();
		owned.Add((Object)(object)val2);
		skyVolume.sharedProfile = val2;
		VisualEnvironment val3 = val2.Add<VisualEnvironment>(true);
		((VolumeParameter<int>)(object)val3.skyType).Override(3);
		((VolumeParameter<SkyAmbientMode>)(object)val3.skyAmbientMode).Override((SkyAmbientMode)1);
		GradientSky val4 = val2.Add<GradientSky>(true);
		((VolumeParameter<Color>)(object)val4.top).Override(new Color(0.018f, 0.065f, 0.095f));
		((VolumeParameter<Color>)(object)val4.middle).Override(new Color(0.22f, 0.39f, 0.42f));
		((VolumeParameter<Color>)(object)val4.bottom).Override(new Color(0.06f, 0.13f, 0.16f));
		((VolumeParameter<float>)(object)val4.gradientDiffusion).Override(1f);
		((VolumeParameter<float>)(object)((SkySettings)val4).exposure).Override(8.6f);
		Fog val5 = val2.Add<Fog>(true);
		((VolumeParameter<bool>)(object)val5.enabled).Override(true);
		((VolumeParameter<float>)(object)val5.meanFreePath).Override(420f);
		((VolumeParameter<float>)(object)val5.baseHeight).Override(origin.y - 10f);
		((VolumeParameter<float>)(object)val5.maximumHeight).Override(origin.y + 100f);
		((VolumeParameter<Color>)(object)val5.color).Override(new Color(0.15f, 0.29f, 0.31f));
		((VolumeParameter<Color>)(object)val5.albedo).Override(new Color(0.5f, 0.67f, 0.67f));
		((VolumeParameter<bool>)(object)val5.enableVolumetricFog).Override(false);
		Exposure val6 = val2.Add<Exposure>(true);
		((VolumeParameter<ExposureMode>)(object)val6.mode).Override((ExposureMode)0);
		((VolumeParameter<float>)(object)val6.fixedExposure).Override(9.5f);
		Bloom val7 = val2.Add<Bloom>(true);
		((VolumeParameter<float>)(object)val7.intensity).Override(0.2f);
		((VolumeParameter<float>)(object)val7.threshold).Override(1.2f);
		ColorAdjustments val8 = val2.Add<ColorAdjustments>(true);
		((VolumeParameter<float>)(object)val8.saturation).Override(-5f);
		((VolumeParameter<float>)(object)val8.contrast).Override(8f);
		Directional("Pale tide sun", new Color(1f, 0.83f, 0.63f), 6500f, new Vector3(38f, -35f, 0f));
		Directional("Ocean fill", new Color(0.36f, 0.68f, 0.82f), 6000f, new Vector3(60f, 145f, 0f));
	}

	private void Directional(string name, Color color, float lux, Vector3 angle)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_001e: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(((Component)this).transform);
		val.transform.rotation = Quaternion.Euler(angle);
		Light val2 = val.AddComponent<Light>();
		val2.type = (LightType)1;
		val2.color = color;
		val2.shadows = (LightShadows)((!(name == "Ocean fill")) ? 2 : 0);
		HDAdditionalLightData val3 = val.AddComponent<HDAdditionalLightData>();
		val3.SetIntensity(lux, (LightUnit)2);
	}

	private void CaptureNativeDoors(Scene scene)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: 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)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Expected O, but got Unknown
		//IL_017d: 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_01a4: Expected O, but got Unknown
		//IL_01c6: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Unknown result type (might be due to invalid IL or missing references)
		int[] array = new int[2] { 0, 1 };
		Vector3 position = default(Vector3);
		foreach (int id in array)
		{
			string containerName = ((id == 0) ? "OutsideEntranceVisualDoorsContainer" : "FireExitDoorContainer");
			Transform val = ((IEnumerable<Transform>)Resources.FindObjectsOfTypeAll<Transform>()).FirstOrDefault((Func<Transform, bool>)((Transform t) => ((Component)t).gameObject.scene == scene && ((Object)t).name == containerName));
			if ((Object)(object)val == (Object)null)
			{
				throw new InvalidOperationException("Missing vanilla visual door container: " + containerName);
			}
			MeshRenderer[] array2 = (from r in ((Component)val).GetComponentsInChildren<MeshRenderer>(true)
				where (Object)(object)((Component)r).GetComponent<MeshFilter>() != (Object)null && (id == 1 || ((Object)r).name != "Plane")
				select r).ToArray();
			if (array2.Length == 0)
			{
				throw new InvalidOperationException("Vanilla door has no mesh");
			}
			Bounds bounds = ((Renderer)array2[0]).bounds;
			MeshRenderer[] array3 = array2;
			foreach (MeshRenderer val2 in array3)
			{
				((Bounds)(ref bounds)).Encapsulate(((Renderer)val2).bounds);
			}
			((Vector3)(ref position))..ctor(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).center.z);
			GameObject val3 = new GameObject((id == 0) ? "Vanilla main entrance" : "Vanilla fire exit");
			val3.transform.SetParent(((Component)this).transform);
			val3.transform.position = position;
			MeshRenderer[] array4 = array2;
			foreach (MeshRenderer val4 in array4)
			{
				GameObject val5 = new GameObject(((Object)val4).name);
				val5.transform.SetParent(val3.transform, false);
				val5.transform.position = ((Component)val4).transform.position;
				val5.transform.rotation = ((Component)val4).transform.rotation;
				val5.transform.localScale = ((Component)val4).transform.lossyScale;
				val5.AddComponent<MeshFilter>().sharedMesh = ((Component)val4).GetComponent<MeshFilter>().sharedMesh;
				((Renderer)val5.AddComponent<MeshRenderer>()).sharedMaterials = ((Renderer)val4).sharedMaterials;
			}
			nativeDoors[id] = val3;
			nativeDoorSizes[id] = new Vector3((id == 0) ? ((Bounds)(ref bounds)).size.z : ((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.y, (id == 0) ? ((Bounds)(ref bounds)).size.x : ((Bounds)(ref bounds)).size.z);
			val3.SetActive(false);
			Plugin.Log.LogInfo((object)("Preserved vanilla door " + id + ": " + array2.Length + " meshes; dimensions=" + nativeDoorSizes[id]));
		}
	}

	private void PlaceNativeDoor(int id, Vector3 p)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = nativeDoors[id];
		Vector3 val2 = ((id == 0) ? Vector3.right : Vector3.back);
		val.transform.SetPositionAndRotation(p, Quaternion.FromToRotation(val2, -forward));
		val.SetActive(true);
	}

	private IEnumerator BuildOuterDistrict()
	{
		B("Northern processional avenue", 0f, 0.08f, 110f, 14f, 0.12f, 160f, floor);
		B("Southern service avenue", 0f, 0.08f, -100f, 14f, 0.12f, 150f, floor);
		B("Western aqueduct road", -105f, 0.08f, 0f, 196f, 0.12f, 14f, floor);
		B("Eastern quay road", 110f, 0.08f, -12f, 185f, 0.12f, 14f, floor);
		for (int i = -1; i <= 1; i += 2)
		{
			B("Outer ring north south", i * 160, 0.08f, 0f, 12f, 0.12f, 330f, floor);
			B("Outer ring east west", 0f, 0.08f, i * 160, 330f, 0.12f, 12f, floor);
			for (int j = 0; j < 12; j++)
			{
				float num = 35 + j * 11;
				B("Avenue kerb", (float)i * 7.3f, 0.16f, num, 0.45f, 0.3f, 10f, trim, solid: true);
				B("Service kerb", (float)i * 7.3f, 0.16f, 0f - num, 0.45f, 0.3f, 10f, trim, solid: true);
				if (j % 3 == 0)
				{
					Refuge(i * 12, num);
					Refuge(i * 12, 0f - num);
				}
			}
			for (int k = 0; k < 7; k++)
			{
				float num2 = 42 + k * 19;
				if ((i >= 0 || !(Mathf.Abs(num2 - 105f) < 10f)) && (i <= 0 || !(Mathf.Abs(num2 - 110f) < 10f)))
				{
					B("Quay kerb", (float)i * num2, 0.16f, 7.4f, 17f, 0.3f, 0.45f, trim, solid: true);
				}
				if (k % 2 == 0)
				{
					Refuge((float)i * num2, -18f);
				}
			}
		}
		yield return null;
		for (int l = 0; l < 10; l++)
		{
			float num3 = -90 + l * 20;
			B("Aqueduct pier base", -83f, 0.8f, num3, 6f, 1.6f, 6f, dark, solid: true);
			B("Aqueduct pier", -83f, 9f, num3, 3.5f, 18f, 4f, stone, solid: true);
			B("Aqueduct capital", -83f, 18f, num3, 5.4f, 0.7f, 5.4f, trim);
			Arc("Lower aqueduct arch", P(-83f, 8f, num3 + 10f), 10f, 1.6f, 3f, 0f, 180f, stone, Facing * Quaternion.Euler(0f, 90f, 0f));
			Arc("Upper aqueduct arch", P(-83f, 21f, num3 + 10f), 10f, 1f, 2.5f, 0f, 180f, trim, Facing * Quaternion.Euler(0f, 90f, 0f));
			B("Aqueduct channel", -83f, 31f, num3 + 10f, 5f, 1.4f, 21f, bronze);
			for (int m = -1; m <= 1; m += 2)
			{
				B("Channel parapet", -83f + (float)m * 2.7f, 32f, num3 + 10f, 0.4f, 2f, 21f, stone);
			}
		}
		Hall(-126f, 48f, 26f, 38f, 13f, "PUMP HOUSE / 03");
		Hall(-128f, -55f, 30f, 35f, 17f, "SALT EXCHANGE");
		yield return null;
		Hall(97f, 45f, 34f, 44f, 16f, "TIDAL FREIGHT / 06");
		Hall(146f, -65f, 31f, 47f, 20f, "ARCHIVE ANNEX");
		Hall(75f, -95f, 24f, 29f, 11f, "SIGNAL WORKS");
		for (int n = 0; n < 5; n++)
		{
			float num4 = 80 + n * 23;
			B("Dock foot", num4, 1f, 108f, 5f, 2f, 6f, stone, solid: true);
			B("Crane mast", num4, 11f, 108f, 1f, 20f, 1f, bronze, solid: true);
			Beam("Crane jib", P(num4, 20f, 108f), P(num4 - 14f, 20f, 108f), 0.8f, 0.8f, bronze);
			Beam("Crane diagonal", P(num4, 12f, 108f), P(num4 - 13f, 20f, 108f), 0.25f, 0.25f, bronze);
			Beam("Hanging chain", P(num4 - 13f, 20f, 108f), P(num4 - 13f, 5f, 108f), 0.07f, 0.07f, dark);
			Arc("Crane hook", P(num4 - 13f, 4.5f, 108f), 0.6f, 0.1f, 0.12f, -160f, 220f, bronze, Facing);
			for (int num5 = 0; num5 < 3; num5++)
			{
				float num6 = 90 + num5 * 5;
				B("Cargo crate", num4, 1.5f, num6, 3f, 3f, 3f, bronze, solid: true);
				for (int num7 = -1; num7 <= 1; num7++)
				{
					B("Crate band", num4 + (float)num7 * 1.1f, 1.5f, num6 - 1.52f, 0.1f, 3f, 0.08f, trim);
				}
			}
		}
		yield return null;
		B("Cloister court", 0f, 0.08f, 130f, 70f, 0.12f, 65f, floor);
		for (int num8 = -1; num8 <= 1; num8 += 2)
		{
			for (int num9 = 0; num9 < 6; num9++)
			{
				float num10 = 101 + num9 * 11;
				B("Cloister column", num8 * 31, 6f, num10, 1.5f, 12f, 1.5f, stone, solid: true);
				B("Cloister base", num8 * 31, 0.5f, num10, 2.3f, 1f, 2.3f, trim, solid: true);
				Arc("Cloister arch", P(num8 * 31, 7f, num10 + 5.5f), 5.5f, 0.8f, 1.4f, 0f, 180f, stone, Facing * Quaternion.Euler(0f, 90f, 0f));
				B("Cloister roof", num8 * 31, 13f, num10, 8f, 0.5f, 11f, bronze);
			}
		}
		Arc("Fallen celestial wheel", P(0f, 15f, 140f), 14f, 1.3f, 3f, 0f, 360f, stone, Facing * Quaternion.Euler(0f, 20f, 20f));
		Arc("Inner celestial wheel", P(0f, 15f, 140f), 11f, 0.3f, 0.5f, 0f, 360f, cyan, Facing * Quaternion.Euler(35f, -25f, 0f));
		B("Instrument pedestal", 0f, 1f, 140f, 17f, 2f, 10f, stone, solid: true);
		Label("THE SEA REMEMBERS", 0f, 2.7f, 134f, 5f, new Color(0.75f, 0.83f, 0.72f));
		Refuge(0f, 115f);
		Refuge(-25f, 145f);
		Refuge(25f, 145f);
		yield return null;
		for (int num11 = 0; num11 < 3; num11++)
		{
			for (int num12 = -1; num12 <= 1; num12 += 2)
			{
				Hall(num12 * (40 + num11 * 34), -135f, 21f, 30f, 12 + num11 * 5, "RESIDENCE / " + (num11 + 1));
			}
		}
		yield return null;
		for (int num13 = -1; num13 <= 1; num13 += 2)
		{
			B("Seawall north south", num13 * 215, 3f, 0f, 4f, 6f, 434f, stone, solid: true);
			B("Seawall east west", 0f, 3f, num13 * 215, 434f, 6f, 4f, stone, solid: true);
			B("Seawall coping", num13 * 215, 6.2f, 0f, 4.8f, 0.6f, 434f, trim);
			B("Seawall coping", 0f, 6.2f, num13 * 215, 434f, 0.6f, 4.8f, trim);
			for (int num14 = 0; num14 < 15; num14++)
			{
				float num15 = -196 + num14 * 28;
				B("Retaining buttress", num13 * 211, 4f, num15, 5f, 8f, 3f, stone, solid: true);
				B("Retaining buttress", num15, 4f, num13 * 211, 3f, 8f, 5f, stone, solid: true);
				float num16 = 32 + num14 * 17 % 38;
				B("Beyond the seawall", num13 * 229, num16 / 2f, num15, 19f, num16, 18f, dark);
				B("Beyond the seawall", num15, num16 / 2f, num13 * 229, 18f, num16, 19f, dark);
			}
		}
		yield return null;
		GroundWear();
	}

	private void Hall(float x, float z, float width, float length, float height, string name)
	{
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		for (int i = -1; i <= 1; i += 2)
		{
			B(name + " side wall", x + (float)i * width / 2f, height / 2f, z, 1.2f, height, length, stone, solid: true);
			B(name + " front wall", x + (float)i * (width / 4f + 1.5f), height / 2f, z - length / 2f, width / 2f - 3f, height, 1.2f, stone, solid: true);
			B(name + " rear wall", x + (float)i * (width / 4f + 1.5f), height / 2f, z + length / 2f, width / 2f - 3f, height, 1.2f, stone, solid: true);
			B("Hall cornice", x + (float)i * width / 2f, height, z, 2f, 0.6f, length + 1f, trim);
			for (int j = 0; j < 4; j++)
			{
				float z2 = z - length / 2f + 4f + (float)j * (length - 8f) / 3f;
				B("Hall buttress", x + (float)i * (width / 2f + 0.65f), height * 0.5f, z2, 1.3f, height, 1.4f, trim, solid: true);
				B("Inner pilaster", x + (float)i * (width / 2f - 0.8f), height * 0.45f, z2, 0.5f, height * 0.9f, 1f, bronze);
			}
		}
		B(name + " floor", x, 0.06f, z, width, 0.12f, length, floor);
		B("Hall entrance head", x, height * 0.7f, z - length / 2f, 6f, height * 0.6f, 1.2f, stone, solid: true);
		B("Hall rear head", x, height * 0.7f, z + length / 2f, 6f, height * 0.6f, 1.2f, stone, solid: true);
		for (int k = 0; k < 5; k++)
		{
			float z3 = z - length / 2f + (float)k * length / 4f;
			Beam("Roof truss left", P(x - width / 2f, height, z3), P(x, height + 4f, z3), 0.5f, 0.6f, bronze);
			Beam("Roof truss right", P(x, height + 4f, z3), P(x + width / 2f, height, z3), 0.5f, 0.6f, bronze);
			Beam("Roof tie", P(x - width / 2f, height, z3), P(x + width / 2f, height, z3), 0.25f, 0.25f, bronze);
		}
		Label(name, x, height * 0.63f, z - length / 2f - 0.7f, 4f, new Color(0.8f, 0.75f, 0.55f));
		Lamp(x - 4f, 3f, z - length / 2f - 1f, warm: true, 700f);
		Lamp(x + 4f, 3f, z - length / 2f - 1f, warm: true, 700f);
		Refuge(x, z - length / 2f - 5f);
	}

	private void GroundWear()
	{
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: 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_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		Random random = new Random(749);
		for (int i = 0; i < 270; i++)
		{
			float num = random.Next(-200, 201);
			float num2 = random.Next(-200, 201);
			if (!(Mathf.Abs(num) < 20f) && !(Mathf.Abs(num2) < 23f) && (!(Mathf.Abs(num) < 40f) || !(Mathf.Abs(num2) < 45f)) && !(Mathf.Abs(Mathf.Abs(num) - 160f) < 10f) && !(Mathf.Abs(Mathf.Abs(num2) - 160f) < 10f))
			{
				float num3 = 0.4f + (float)random.NextDouble() * 2f;
				Box("Broken paving", P(num, 0.08f, num2), new Vector3(num3, 0.12f, num3 * 0.65f), (i % 3 == 0) ? trim : stone, solid: false, Facing * Quaternion.Euler(0f, (float)random.Next(180), 0f));
				if (i % 5 == 0)
				{
					Box("Salt debris", P(num, 0.25f, num2), new Vector3(0.7f, 0.5f, 1.2f), stone, solid: true, Facing * Quaternion.Euler(0f, (float)random.Next(180), 0f));
				}
			}
		}
	}

	private IEnumerator BuildRefinements()
	{
		ExitPavilion(2, -105f, 14f, "AQUEDUCT / WEST");
		yield return null;
		ExitPavilion(3, 110f, 14f, "FREIGHT / EAST");
		yield return null;
		ExitPavilion(4, 0f, 171f, "CLOISTER / NORTH");
		yield return null;
		Arc("Landing compass brass rim", P(0f, 0.09f, -5f), 3f, 0.065f, 0.05f, 0f, 360f, bronze, Facing * Quaternion.Euler(90f, 0f, 0f));
		for (int i = 0; i < 16; i++)
		{
			float num = (float)i * (float)Math.PI / 8f;
			Vector3 val = right * Mathf.Cos(num) + forward * Mathf.Sin(num);
			Beam("Compass point", P(0f, 0.12f, -5f) + val * ((i % 4 == 0) ? 1.8f : 2.6f), P(0f, 0.12f, -5f) + val * 2.9f, 0.055f, 0.025f, trim);
		}
		Directory(-10f, -7f);
		RouteSign(-19f, 0f, "02 / AQUEDUCT", west: true);
		RouteSign(27f, -12f, "03 / FREIGHT QUAY", west: false);
		RouteSign(4f, 78f, "04 / NORTH CLOISTER", west: false);
		for (int j = 0; j < 12; j++)
		{
			float num2 = 35 + j * 12;
			B("Processional brass guide", 0f, 0.155f, num2, 0.12f, 0.028f, 2f, bronze);
			B("West transit inlay", 0f - num2, 0.155f, 0f, 2f, 0.028f, 0.12f, bronze);
			B("Freight transit inlay", num2, 0.155f, -12f, 2f, 0.028f, 0.12f, bronze);
			if (j % 3 == 0)
			{
				B("Aqueduct exit marker", 0f - num2, 0.17f, 0f, 0.75f, 0.025f, 0.18f, red);
				B("Freight exit marker", num2, 0.17f, -12f, 0.75f, 0.025f, 0.18f, red);
				B("Cloister exit marker", 0f, 0.17f, num2, 0.18f, 0.025f, 0.75f, red);
			}
		}
		yield return null;
		for (int k = -1; k <= 1; k += 2)
		{
			for (int l = 0; l < 3; l++)
			{
				float x = k * (10 + l * 5);
				float z = 23.85f;
				Arc("Facade tidal rose", P(x, 4.5f, z), 1.35f, 0.12f, 0.1f, 0f, 360f, bronze, Facing);
				for (int m = 0; m < 8; m++)
				{
					float num3 = (float)m * (float)Math.PI / 4f;
					Vector3 val2 = right * Mathf.Cos(num3) + Vector3.up * Mathf.Sin(num3);
					Beam("Rose tracery", P(x, 4.5f, z), P(x, 4.5f, z) + val2 * 1.1f, 0.045f, 0.06f, trim);
				}
				B("Archive sill relief", x, 6.3f, z, 3.3f, 0.16f, 0.25f, trim);
			}
			for (int n = 0; n < 6; n++)
			{
				float z2 = 27 + n * 5;
				B("Archive service conduit", k * 26, 2.5f, z2, 0.28f, 0.28f, 5.1f, bronze);
				Arc("Conduit collar", P(k * 26, 2.5f, z2), 0.19f, 0.05f, 0.12f, 0f, 360f, trim, Facing);
			}
			for (int num4 = 0; num4 < 5; num4++)
			{
				float num5 = 31 + num4 * 5;
				B("Archive railing post", (float)k * 29.5f, 0.85f, num5, 0.13f, 1.7f, 0.13f, bronze, solid: true);
				B("Archive railing upper", (float)k * 29.5f, 1.5f, num5 + 2.5f, 0.1f, 0.1f, 5f, bronze);
				B("Archive railing lower", (float)k * 29.5f, 0.65f, num5 + 2.5f, 0.075f, 0.075f, 5f, bronze);
			}
		}
		yield return null;
		FurnishHall(-126f, 48f, 26f, 38f, "Pressure gauges");
		FurnishHall(-128f, -55f, 30f, 35f, "Salt archive");
		yield return null;
		FurnishHall(97f, 45f, 34f, 44f, "Freight manifests");
		FurnishHall(146f, -65f, 31f, 47f, "Tidal records");
		FurnishHall(75f, -95f, 24f, 29f, "Signal relays");
		yield return null;
		for (int num6 = -1; num6 <= 1; num6 += 2)
		{
			for (int num7 = 0; num7 < 8; num7++)
			{
				float z3 = -75 + num7 * 24;
				float num8 = num6 * 159;
				B("Promenade lamp plinth", num8, 0.35f, z3, 1f, 0.7f, 1f, stone, solid: true);
				Beam("Promenade tapered mast", P(num8, 0.7f, z3), P(num8, 7f, z3), 0.16f, 0.16f, bronze);
				Beam("Promenade crook", P(num8, 7f, z3), P(num8 - (float)num6 * 1.5f, 7.5f, z3), 0.12f, 0.12f, bronze);
				Arc("Promenade lantern cage", P(num8 - (float)num6 * 1.5f, 6.95f, z3), 0.45f, 0.055f, 0.35f, 0f, 360f, bronze, Facing);
				B("Promenade warm globe", num8 - (float)num6 * 1.5f, 6.95f, z3, 0.3f, 0.65f, 0.3f, amber);
			}
			for (int num9 = 0; num9 < 5; num9++)
			{
				SaltGarden(num6 * (43 + num9 * 30), -166f);
			}
		}
		yield return null;
		for (int num10 = 0; num10 < 6; num10++)
		{
			float z4 = -74 + num10 * 29;
			Arc("Aqueduct pressure wheel", P(-80.8f, 4f, z4), 1.15f, 0.1f, 0.18f, 0f, 360f, bronze, Facing * Quaternion.Euler(0f, 90f, 0f));
			Beam("Aqueduct pressure shaft", P(-83f, 4f, z4), P(-79.6f, 4f, z4), 0.14f, 0.14f, bronze);
			B("Aqueduct gauge plaque", -80.65f, 5.8f, z4, 0.1f, 0.75f, 1.2f, trim);
		}
		Arc("Cloister meditation pool", P(0f, 0.17f, 148f), 6f, 0.6f, 0.3f, 0f, 360f, trim, Facing * Quaternion.Euler(90f, 0f, 0f));
		for (int num11 = 0; num11 < 12; num11++)
		{
			float num12 = (float)num11 * (float)Math.PI / 6f;
			B("Cloister votive", Mathf.Cos(num12) * 6.8f, 0.46f, 148f + Mathf.Sin(num12) * 6.8f, 0.17f, 0.6f, 0.17f, amber);
		}
		AddSeaMotes();
	}

	private void ExitPavilion(int id, float x, float z, string district)
	{
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_048e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_038c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_033c: Unknown result type (might be due to invalid IL or missing references)
		//IL_051b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0540: Unknown result type (might be due to invalid IL or missing references)
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		//IL_046f: Unknown result type (might be due to invalid IL or missing references)
		Material mat = ((id == 4) ? trim : stone);
		B("Exit " + id + " paved approach", x, 0.085f, z - 3f, 10f, 0.12f, 10f, floor);
		B("Exit " + id + " left wall", x - 2.8f, 3f, z + 2.7f, 3.2f, 6f, 6f, mat, solid: true);
		B("Exit " + id + " right wall", x + 2.8f, 3f, z + 2.7f, 3.2f, 6f, 6f, mat, solid: true);
		B("Exit " + id + " rear wall", x, 3f, z + 5.5f, 9f, 6f, 0.8f, mat, solid: true);
		B("Exit " + id + " lintel", x, 4.8f, z, 2.4f, 2.8f, 0.8f, mat, solid: true);
		B("Exit " + id + " roof", x, 6.2f, z + 2.6f, 10f, 0.4f, 7f, bronze);
		B("Exit " + id + " cornice", x, 5.8f, z + 2.6f, 10.6f, 0.35f, 7.5f, trim);
		Door(x, z, main: false);
		Label("FIRE EXIT / 0" + id, x, 4.25f, z - 0.55f, 3.4f, new Color(1f, 0.58f, 0.35f));
		Label(district, x, 5.1f, z - 0.55f, 1.75f, new Color(0.85f, 0.83f, 0.68f));
		Refuge(x, z - 9f);
		switch (id)
		{
		case 2:
		{
			Arc("Pump exit pressure wheel", P(x, 8.2f, z + 2.5f), 2f, 0.26f, 1f, 0f, 360f, bronze, Facing);
			for (int j = -1; j <= 1; j += 2)
			{
				Beam("Pump exit chimney", P(x + (float)j * 3.4f, 5f, z + 3f), P(x + (float)j * 3.4f, 10f, z + 3f), 0.45f, 0.45f, bronze);
				Arc("Pump chimney collar", P(x + (float)j * 3.4f, 9.5f, z + 3f), 0.35f, 0.09f, 0.2f, 0f, 360f, trim, Facing * Quaternion.Euler(90f, 0f, 0f));
			}
			break;
		}
		case 3:
		{
			Beam("Freight signal mast", P(x + 5.8f, 0f, z + 2f), P(x + 5.8f, 14f, z + 2f), 0.2f, 0.2f, bronze);
			for (int k = 0; k < 3; k++)
			{
				B("Freight exit cargo stack", x - 6f, 1.1f + (float)k * 2.2f, z + 3f, 2.5f, 2.2f, 3f, bronze, solid: true);
				B("Cargo numberplate", x - 6f, 1.1f + (float)k * 2.2f, z + 1.47f, 1.4f, 0.5f, 0.05f, trim);
			}
			Arc("Signal halo", P(x + 5.8f, 12.5f, z + 2f), 1.25f, 0.08f, 0.12f, 0f, 360f, cyan, Facing);
			break;
		}
		default:
		{
			Arc("Cloister exit archivolt", P(x, 8.5f, z + 2f), 3.8f, 0.55f, 1.4f, 0f, 180f, trim, Facing);
			for (int i = -1; i <= 1; i += 2)
			{
				B("Cloister exit spire", x + (float)i * 4.5f, 8f, z + 3f, 0.55f, 8f, 0.55f, trim);
				Arc("Cloister exit aureole", P(x + (float)i * 4.5f, 11f, z + 3f), 0.85f, 0.08f, 0.16f, 0f, 360f, amber, Facing);
			}
			break;
		}
		}
	}

	private void Directory(float x, float z)
	{
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		for (int i = -1; i <= 1; i += 2)
		{
			B("Directory post", x + (float)i * 2.7f, 2f, z, 0.14f, 4f, 0.14f, bronze, solid: true);
		}
		B("Directory basalt panel", x, 2.7f, z, 5.9f, 2.8f, 0.22f, dark);
		B("Directory brass cap", x, 4.15f, z, 6.1f, 0.12f, 0.35f, bronze);
		Label("074 / DISTRICT DIRECTORY", x, 3.6f, z - 0.14f, 1.7f, new Color(0.85f, 0.77f, 0.56f));
		Label("MAIN  /  OBSERVATORY\n01  LANDING COURT   •   02  WEST AQUEDUCT\n03  EASTERN FREIGHT   •   04  NORTH CLOISTER", x, 2.7f, z - 0.14f, 1.15f, new Color(0.7f, 0.82f, 0.79f));
	}

	private void RouteSign(float x, float z, string text, bool west)
	{
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		B("District wayfinding post", x, 1.5f, z, 0.14f, 3f, 0.14f, bronze, solid: true);
		B("District wayfinding backplate", x, 2.65f, z, 4.5f, 0.8f, 0.12f, dark);
		Label((west ? "<  " : "   ") + text + (west ? "" : "  >"), x, 2.65f, z - 0.08f, 1.6f, new Color(0.9f, 0.65f, 0.43f));
	}

	private void FurnishHall(float x, float z, float width, float length, string title)
	{
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		for (int i = -1; i <= 1; i += 2)
		{
			float num = x + (float)i * (width / 2f - 3.3f);
			for (int j = 0; j < 3; j++)
			{
				float z2 = z - length / 2f + 8f + (float)j * (length - 16f) / 2f;
				B("Archive shelving", num, 1.7f, z2, 3f, 3.4f, 1.1f, bronze, solid: true);
				for (int k = 0; k < 3; k++)
				{
					B("Archive shelf", num, 0.5f + (float)k * 1.05f, z2, 3.15f, 0.12f, 1.3f, trim);
					for (int l = 0; l < 5; l++)
					{
						B("Sealed archival folio", num - 1.1f + (float)l * 0.5f, 0.87f + (float)k * 1.05f, z2, 0.28f, 0.6f, 0.65f, (l % 2 == 0) ? dark : stone);
					}
				}
			}
		}
		Label(title, x, 2.2f, z + length / 2f - 0.72f, 2.8f, new Color(0.75f, 0.8f, 0.69f));
	}

	private void SaltGarden(float x, float z)
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: 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_00d0: 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)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: 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)
		B("Raised salt planter", x, 0.45f, z, 4.8f, 0.9f, 3f, stone, solid: true);
		B("Planter soil", x, 0.94f, z, 4.4f, 0.12f, 2.6f, dark);
		for (int i = 0; i < 12; i++)
		{
			Vector3 val = P(x - 1.9f + (float)(i % 6) * 0.75f, 1f, z - 0.7f + (float)(i / 6) * 1.4f);
			float num = 0.9f + (float)(i % 4) * 0.25f;
			Beam("Salt fern stem", val, val + Vector3.up * num, 0.045f, 0.045f, bronze);
			for (int j = -1; j <= 1; j += 2)
			{
				Beam("Salt fern frond", val + Vector3.up * (num * 0.4f), val + Vector3.up * (num * 0.75f) + right * ((float)j * 0.45f), 0.12f, 0.025f, trim);
			}
		}
	}

	private void AddSeaMotes()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references