Decompiled source of LostCity v0.5.4

plugins/Tobeyyy.LostCity.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using LostCity.Core;
using LostCity.Dev;
using LostCity.Game;
using LostCity.Gen;
using Microsoft.CodeAnalysis;
using Peak;
using Peak.Network;
using Photon.Pun;
using Photon.Realtime;
using Unity.Profiling;
using UnityEngine;
using UnityEngine.Animations.Rigging;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tobeyyy.LostCity")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.5.4.0")]
[assembly: AssemblyInformationalVersion("0.5.4+9fc20123141d571ac84b53018a49b295f3c221d6")]
[assembly: AssemblyProduct("Tobeyyy.LostCity")]
[assembly: AssemblyTitle("LostCity")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.5.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Embedded]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace LostCity
{
	[BepInPlugin("Tobeyyy.LostCity", "LostCity", "0.5.4")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<int> FixedSeed;

		internal static ConfigEntry<float> FloodBelowStart;

		internal static ConfigEntry<float> WaterDepth;

		internal static ConfigEntry<bool> Drowning;

		internal static ConfigEntry<float> BreathSeconds;

		internal static ConfigEntry<float> RecoverSeconds;

		internal static ConfigEntry<float> DrownDamage;

		internal static ConfigEntry<STATUSTYPE> WaterStatus;

		internal static ConfigEntry<float> MaxClimb;

		internal static ConfigEntry<float> ShortcutClimb;

		internal static ConfigEntry<float> WallStamina;

		internal static ConfigEntry<float> FacadeStamina;

		internal static bool DevMode;

		internal static ConfigEntry<bool> DevHotkeys;

		internal static ConfigEntry<bool> AutoTest;

		internal static ConfigEntry<bool> AutoPlay;

		internal static ConfigEntry<bool> InfiniteChainLauncher;

		internal static ConfigEntry<bool> InfiniteJetpack;

		internal static ConfigEntry<bool> InfiniteLantern;

		internal static ConfigEntry<bool> InfiniteFood;

		internal static ConfigEntry<string> PlayFood;

		internal static ConfigEntry<int> PlayAscent;

		internal static ConfigEntry<bool> UnderwaterHaze;

		internal static ConfigEntry<bool> WaterBreaksFalls;

		internal static ConfigEntry<float> WaterFallDrag;

		internal static ConfigEntry<float> FogSpeed;

		internal static ConfigEntry<bool> Storms;

		internal static ConfigEntry<bool> Ambience;

		internal static ConfigEntry<bool> HostWarpKey;

		internal static ConfigEntry<float> AmbienceVolume;

		internal static ConfigEntry<float> JungleBedVolume;

		internal static ConfigEntry<bool> Missiles;

		internal static ConfigEntry<float> MissileFirstAlert;

		internal static ConfigEntry<float> MissileIntervalMin;

		internal static ConfigEntry<float> MissileIntervalMax;

		internal static ConfigEntry<float> MissileWarning;

		internal static ConfigEntry<float> MissileFirstWarning;

		internal static ConfigEntry<float> MissileDamage;

		internal static ConfigEntry<STATUSTYPE> MissileStatus;

		internal static ConfigEntry<float> MissileStartProgress;

		internal static ConfigEntry<float> MissileStopHeight;

		internal static ConfigEntry<float> VendingChance;

		internal static ConfigEntry<int> VendingUses;

		internal static ConfigEntry<string> VendingItems;

		internal static ConfigEntry<float> ZiplineChestChance;

		internal static ConfigEntry<int> AutoTestLevel;

		internal static ConfigEntry<bool> AutoTestQuit;

		internal static ConfigEntry<bool> AutoTestRouteProbes;

		internal static ConfigEntry<bool> AutoTestPerf;

		internal static ConfigEntry<string> AutoTestLab;

		internal static ConfigEntry<bool> WriteDump;

		internal static ConfigEntry<bool> SurveyIsland;

		internal static string ConflictingPlugin;

		private static readonly string[] Conflicts = new string[6] { "PLL", "AllBiomes", "TrueFinalAscent", "TerrainRandomiser", "TerrainCustomiser", "PeakWorkshop" };

		public const string Id = "Tobeyyy.LostCity";

		internal static ManualLogSource Log { get; private set; } = null;

		internal static Plugin Instance { get; private set; }

		public static string Name => "LostCity";

		public static string Version => "0.5.4";

		private void Awake()
		{
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Expected O, but got Unknown
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Replace the second biome with the Lost City. In multiplayer the host decides: if the host has it on, everyone with the mod gets the city.");
			FixedSeed = ((BaseUnityPlugin)this).Config.Bind<int>("General", "FixedSeed", 0, "0 = a city per island (a new city with every daily map, the same for everyone on it). Any other value always builds that one city. In multiplayer the host's value counts.");
			FloodBelowStart = ((BaseUnityPlugin)this).Config.Bind<float>("Generation", "FloodBelowStart", 51f, "Water level below the Shore campfire (the drop-down into the city). In multiplayer the host's value counts.");
			WaterDepth = ((BaseUnityPlugin)this).Config.Bind<float>("Generation", "FloodDepth", 5.5f, "Depth of the flood over the streets (over a scout's head). There is no swimming in PEAK: you walk on the bottom. In multiplayer the host's value counts.");
			if (Mathf.Approximately(FloodBelowStart.Value, 50f) && Mathf.Approximately(WaterDepth.Value, 6.5f))
			{
				FloodBelowStart.Value = 51f;
				WaterDepth.Value = 5.5f;
			}
			Drowning = ((BaseUnityPlugin)this).Config.Bind<bool>("Water", "Drowning", true, "Scouts hold their breath under the flood: a drown bar fills, and once it is full the water hurts. Out of the water it drains again.");
			BreathSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Water", "BreathSeconds", 10f, "Seconds with the head under water until the drown bar is full.");
			RecoverSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Water", "RecoverSeconds", 4f, "Seconds out of the water for a full drown bar to drain again.");
			DrownDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Water", "DrownStatusPerSecond", 0.05f, "How fast the status builds up while the drown bar is full and the head is under water (1 = a full bar).");
			WaterStatus = ((BaseUnityPlugin)this).Config.Bind<STATUSTYPE>("Water", "Status", (STATUSTYPE)0, "Which status drowning gives.");
			UnderwaterHaze = ((BaseUnityPlugin)this).Config.Bind<bool>("Water", "UnderwaterHaze", true, "Murky haze while the camera is under the flood (bad visibility).");
			WaterBreaksFalls = ((BaseUnityPlugin)this).Config.Bind<bool>("Water", "BreaksFalls", true, "The flood breaks falls: under water a falling scout slows down, so a jump from the harbour or a few floors does no harm. From great heights the fall still kills.");
			WaterFallDrag = ((BaseUnityPlugin)this).Config.Bind<float>("Water", "FallDrag", 2.6f, "How fast a fall slows under water (per second). Higher: safe from greater heights.");
			FogSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Fog", "SpeedMultiplier", 0.5f, "How fast the rising fog closes in, times the game's own speed (1 = vanilla, 0.5 = half as fast). The host's fog is what everyone sees, so all players should use the same value.");
			HostWarpKey = ((BaseUnityPlugin)this).Config.Bind<bool>("Host", "F6WarpToShoreCampfire", true, "F6, host only: bring every scout to the Shore campfire, the last one before the Lost City (to skip the beach, or gather everyone).");
			Ambience = ((BaseUnityPlugin)this).Config.Bind<bool>("Sound", "Ambience", true, "The city's own sounds: water lapping below you, creaking steel, falling debris, now and then a distant collapse.");
			AmbienceVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "AmbienceVolume", 1f, "Volume of the city's own sounds (also follows the game's sound-effect volume).");
			JungleBedVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Sound", "JungleBedVolume", 0.44f, "The game's jungle day and night background in the city, relative to its normal volume (1 = unchanged).");
			if (Mathf.Approximately(JungleBedVolume.Value, 0.55f))
			{
				JungleBedVolume.Value = 0.44f;
			}
			Storms = ((BaseUnityPlugin)this).Config.Bind<bool>("Weather", "SlotStorms", false, "Keep the slot's own weather in the city: the rain of Tropics days or the wind of Roots days (off: the city has missile alerts instead). In multiplayer the host's value counts.");
			Missiles = ((BaseUnityPlugin)this).Config.Bind<bool>("Missiles", "Enabled", true, "Missile alerts in the city: the phone warns, ten seconds later a missile strikes every scout who is not inside a building. In multiplayer the host's value counts.");
			MissileFirstAlert = ((BaseUnityPlugin)this).Config.Bind<float>("Missiles", "FirstAlertSeconds", 45f, "Seconds from the moment the first scout is StartProgress into the city until the first alert. The host's value counts.");
			MissileIntervalMin = ((BaseUnityPlugin)this).Config.Bind<float>("Missiles", "IntervalMinSeconds", 180f, "Shortest time from one alert to the next. The host's value counts.");
			MissileIntervalMax = ((BaseUnityPlugin)this).Config.Bind<float>("Missiles", "IntervalMaxSeconds", 300f, "Longest time from one alert to the next. The host's value counts.");
			MissileWarning = ((BaseUnityPlugin)this).Config.Bind<float>("Missiles", "WarningSeconds", 10f, "Seconds from the alert to the impact (the phone is up all that time). The host's value counts.");
			MissileFirstWarning = ((BaseUnityPlugin)this).Config.Bind<float>("Missiles", "FirstWarningSeconds", 15f, "The same for the very first alert in a city, so new players have more time to find cover. The host's value counts.");
			MissileDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Missiles", "Damage", 0.3f, "Status a missile gives a scout out in the open (1 = a full bar). The host's value counts.");
			MissileStatus = ((BaseUnityPlugin)this).Config.Bind<STATUSTYPE>("Missiles", "Status", (STATUSTYPE)0, "Which status a missile gives. The host's value counts.");
			MissileStartProgress = ((BaseUnityPlugin)this).Config.Bind<float>("Missiles", "StartProgress", 0.1f, "How far into the city (along the slot, Shore front 0 .. end wall 1) a scout must be before the alerts begin for them. In multiplayer the host's value counts.");
			MissileStopHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Missiles", "StopHeight", 0.8f, "Above this share of the city's height (flood 0 .. end campfire 1) a scout gets no more alerts. In multiplayer the host's value counts.");
			MaxClimb = ((BaseUnityPlugin)this).Config.Bind<float>("Generation", "MaxClimb", 26f, "Longest climb (up plus sideways) between rest spots on the guaranteed route; a full stamina bar climbs about 40 units. In multiplayer the host's value counts.");
			ShortcutClimb = ((BaseUnityPlugin)this).Config.Bind<float>("Generation", "ShortcutClimb", 34f, "Climb a strong player can do; extra features that would let such a player skip most of the route are left out. In multiplayer the host's value counts.");
			WallStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Generation", "WallStaminaMultiplier", 1.8f, "Climbing stamina cost on the city's own dam (only built if the island's end wall is missing). In multiplayer the host's value counts.");
			FacadeStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Generation", "FacadeStaminaMultiplier", 1.25f, "Climbing stamina cost on plain building facades. In multiplayer the host's value counts.");
			VendingChance = ((BaseUnityPlugin)this).Config.Bind<float>("Vending", "Chance", 0.33f, "Chance that an open floor has a vending machine (0 = none). In multiplayer the host's value counts.");
			VendingUses = ((BaseUnityPlugin)this).Config.Bind<int>("Vending", "Uses", 2, "Snacks a vending machine gives (1..9); then it is empty. The host's value counts.");
			VendingItems = ((BaseUnityPlugin)this).Config.Bind<string>("Vending", "Items", "Airplane Food:5, Sports Drink:54, Granola Bar:31, Bandages:10", "What a vending machine drops: item:weight pairs, the names of items in Resources/0_Items, the weights relative (here percent). The host's list counts.");
			if (VendingItems.Value == "Airplane Food:5, Sports Drink:60, Granola Bar:35")
			{
				VendingItems.Value = "Airplane Food:5, Sports Drink:54, Granola Bar:31, Bandages:10";
			}
			ZiplineChestChance = ((BaseUnityPlugin)this).Config.Bind<float>("Zipline", "ChestChance", 0.15f, "Chance that a suitcase in the Lost City holds a zipline shooter (3 shots; a cable downhill that you ride without stamina). 0 = never. The host fills the suitcases, so the host's value counts.");
			string text = Path.Combine(Paths.ConfigPath, "Tobeyyy.LostCity.Dev.cfg");
			ConfigFile val = new ConfigFile(text, false, ((BaseUnityPlugin)this).Info.Metadata)
			{
				SaveOnConfigSet = File.Exists(text)
			};
			DevMode = File.Exists(text);
			DevHotkeys = val.Bind<bool>("Dev", "Hotkeys", false, "F7: warp to the end campfire, F8: warp to Lost City slot (host), F9: write dump, F10: heal fully, Shift+F10: overview shots, F11: screenshot + note of what is under the crosshair, F5: chain launcher in hand, Shift+F5: zipline shooter in hand, F4: jetpack, F2: lantern, F3: food (Dev.PlayFood), F1: missile alert now (host).");
			AutoPlay = val.Bind<bool>("Dev", "AutoPlay", false, "Drive the game from the main menu into a solo run on Level_<AutoTestLevel> at ascent Dev.PlayAscent and leave you on the Shore with a jetpack, a chain launcher, a lantern and food.");
			PlayAscent = val.Bind<int>("Dev", "PlayAscent", -1, "Ascent (difficulty) of the AutoPlay run: 0..8 as on the kiosk's boarding pass, -1 = the highest (8), whatever is unlocked.");
			InfiniteChainLauncher = val.Bind<bool>("Dev", "InfiniteChainLauncher", false, "The chain launcher's uses never run out (for testing).");
			InfiniteJetpack = val.Bind<bool>("Dev", "InfiniteJetpack", false, "The jetpack's fuel never runs out (for testing).");
			InfiniteLantern = val.Bind<bool>("Dev", "InfiniteLantern", false, "The dev lantern (F2 / AutoPlay) never runs out of fuel (for testing).");
			InfiniteFood = val.Bind<bool>("Dev", "InfiniteFood", false, "The dev food (F3 / AutoPlay) can be eaten (hunger goes down as usual) but is never used up (for testing).");
			PlayFood = val.Bind<string>("Dev", "PlayFood", "Granola", "Dev food item: name (or part of it) of an item in Resources/0_Items, e.g. Granola (the cereal bar; PEAK has no cornflakes), TrailMix, Airplane Food, ScoutCookies.");
			AutoTest = val.Bind<bool>("Dev", "AutoTest", false, "Drive the game from the main menu into the Lost City solo, take screenshots, write a dump.");
			AutoTestLevel = val.Bind<int>("Dev", "AutoTestLevel", 17, "Island used by AutoTest (Level_N). Tropics: 0,3,4,7,8,10,11,14,15,17,19. Roots: the others up to 20.");
			AutoTestQuit = val.Bind<bool>("Dev", "AutoTestQuit", true, "Quit the game when AutoTest is done.");
			AutoTestPerf = val.Bind<bool>("Dev", "AutoTestPerf", false, "During AutoTest, only measure frame cost: the same camera stations in every segment (Shore, slot 2, Alpine/Mesa, segment 4), written to BepInEx/LostCity/perf.txt. Works with the city off too (vanilla comparison).");
			AutoTestLab = val.Bind<string>("Dev", "AutoTestLab", "", "During AutoTest, only run one experiment in the city and quit: 'bridges' = rope bridges of several lengths shot with different deck scales and sag values.");
			AutoTestRouteProbes = val.Bind<bool>("Dev", "AutoTestRouteProbes", true, "During AutoTest, warp onto every route node and check that it is standable (takes a few minutes).");
			SurveyIsland = val.Bind<bool>("Dev", "Survey", false, "On island load, write a height map of the vanilla slot to BepInEx/LostCity/survey (before the city replaces it).");
			WriteDump = val.Bind<bool>("Dev", "WriteDump", false, "Write a diagnostic dump of the slot frame and scene to BepInEx/LostCity/ on every island load.");
			foreach (PluginInfo value2 in Chainloader.PluginInfos.Values)
			{
				string text2 = value2.Metadata.GUID + " " + value2.Metadata.Name;
				string[] conflicts = Conflicts;
				foreach (string value in conflicts)
				{
					if (text2.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0 && value2.Metadata.GUID != "Tobeyyy.LostCity")
					{
						ConflictingPlugin = value2.Metadata.Name;
					}
				}
			}
			new Harmony("Tobeyyy.LostCity").PatchAll(typeof(Plugin).Assembly);
			SceneManager.sceneLoaded += OnSceneLoaded;
			((Component)this).gameObject.AddComponent<FallRescue>();
			((Component)this).gameObject.AddComponent<Handshake>();
			((Component)this).gameObject.AddComponent<Drowning>();
			((Component)this).gameObject.AddComponent<WaterFalls>();
			((Component)this).gameObject.AddComponent<FogPace>();
			((Component)this).gameObject.AddComponent<UnderwaterView>();
			((Component)this).gameObject.AddComponent<MissileStrikes>();
			((Component)this).gameObject.AddComponent<CityAmbience>();
			((Component)this).gameObject.AddComponent<HostWarp>();
			BridgeWear.Register();
			Vending.Register();
			MissileStrikes.Register();
			if (DevMode)
			{
				((Component)this).gameObject.AddComponent<DevTools>();
				((Component)this).gameObject.AddComponent<PlayTools>();
				if (AutoTest.Value || AutoPlay.Value)
				{
					((Component)this).gameObject.AddComponent<AutoTestDriver>();
				}
			}
			Log.LogInfo((object)("Plugin " + Name + " " + Version + " loaded" + ((ConflictingPlugin != null) ? (" (inactive: " + ConflictingPlugin + " present)") : "") + (DevMode ? " (developer config found)" : "") + "."));
		}

		private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Zipline.EnsureRegistered();
			CityRuntime.OnSceneLoaded(scene);
			if (CityRuntime.IsIsland(((Scene)(ref scene)).name) && WriteDump.Value)
			{
				DevDump.Write("load");
			}
		}
	}
	[HarmonyPatch]
	internal static class Patches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(MapHandler), "InitializeMap")]
		private static void AfterInitializeMap()
		{
			CityRuntime.AfterInitializeMap();
		}

		[HarmonyPostfix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private static void Title(ProgressPoint __instance, ref string __result)
		{
			//IL_0008: 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)
			if (CityRuntime.Active && __instance.biome == CityRuntime.Current.Biome)
			{
				__result = "LOST CITY";
			}
		}
	}
}
namespace LostCity.Gen
{
	public static class CityGenerator
	{
		private sealed class Geo
		{
			private struct Seg
			{
				public float Y0;

				public float Y1;
			}

			private sealed class Look
			{
				public int PilasterEvery;

				public int BeltEvery;

				public bool Shopfront;

				public Surface Fascia;

				public string ShopWord;

				public bool DripBand;

				public bool Ivy;
			}

			private sealed class PortPlan
			{
				public Rect Dock;

				public float ZLimit;

				public float WaterLimit;

				public float Top;

				public float DeckY;

				public string Why = "";

				public readonly List<QuayRun> Runs = new List<QuayRun>();

				public readonly List<Deck> Decks = new List<Deck>();

				public readonly List<Solid> Solids = new List<Solid>();

				public readonly List<Action<Piece>> Parts = new List<Action<Piece>>();

				public readonly List<DecorSpot> Decor = new List<DecorSpot>();

				public readonly List<(string name, Vector3 at)> Probes = new List<(string, Vector3)>();

				public readonly List<(string name, Vector3 eye, Vector3 target)> Views = new List<(string, Vector3, Vector3)>();

				public Vector3 House = new Vector3(float.NaN, 0f, 0f);
			}

			private sealed class Solid
			{
				public Vector2[] Quad;

				public Rect Area;

				public float Top;

				public string What;

				public object Owner;

				public bool OnQuay;
			}

			private sealed class QuayRun
			{
				public Vector2 A;

				public Vector2 B;

				public float Depth;

				public int Index;

				public readonly List<Vector2> Shown = new List<Vector2>();

				public readonly List<Vector2> Taken = new List<Vector2>();

				public readonly List<Vector2> Front = new List<Vector2>();

				public Vector2 U
				{
					get
					{
						//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_000c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0011: Unknown result type (might be due to invalid IL or missing references)
						//IL_0014: Unknown result type (might be due to invalid IL or missing references)
						Vector2 val = B - A;
						return ((Vector2)(ref val)).normalized;
					}
				}

				public Vector2 N => new Vector2(0f - U.y, U.x);

				public float Length => Vector2.Distance(A, B);

				public float Lift => (float)(Index & 1) * 0.025f;

				public float Back => (float)(Index & 1) * 0.015f;

				public float Yaw => YawOf(N);

				public Frame Frame => new Frame(A, Yaw);

				public Vector2 At(float s, float o)
				{
					//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_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_0023: Unknown result type (might be due to invalid IL or missing references)
					return A + U * s + N * o;
				}

				public Vector2[] Quad(float s0, float s1, float z0, float z1)
				{
					//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)
					return Corners(A, N, s0, s1, z0, z1);
				}

				public float ShownZ(float x)
				{
					//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_0029: 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_003f: Unknown result type (might be due to invalid IL or missing references)
					//IL_005d: Unknown result type (might be due to invalid IL or missing references)
					//IL_006c: Unknown result type (might be due to invalid IL or missing references)
					float num = float.NegativeInfinity;
					float num2 = float.MaxValue;
					float result = float.NegativeInfinity;
					foreach (Vector2 item in Shown)
					{
						if (Mathf.Abs(item.x - x) <= 2.01f)
						{
							num = Mathf.Max(num, item.y);
						}
						if (Mathf.Abs(item.x - x) < num2)
						{
							num2 = Mathf.Abs(item.x - x);
							result = item.y;
						}
					}
					if (!(num > float.NegativeInfinity))
					{
						return result;
					}
					return num;
				}

				public static bool Open(List<Vector2> taken, float s0, float s1)
				{
					//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_0012: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					foreach (Vector2 item in taken)
					{
						if (s1 > item.x && s0 < item.y)
						{
							return false;
						}
					}
					return true;
				}
			}

			private enum DeckKind
			{
				Walk,
				Jetty,
				Platform
			}

			private sealed class Deck
			{
				public DeckKind Kind;

				public Vector2 Root;

				public Vector2 Dir;

				public float Length;

				public float Width;

				public float Y;

				public float Lead;

				public float Skip;

				public float GapAt = -1f;

				public float GapLen;

				public float SagAt = -1f;

				public float SagAngle;

				public string Sign;

				public bool Davit;

				public Vector2 Side => new Vector2(Dir.y, 0f - Dir.x);

				public float Out
				{
					get
					{
						//IL_0001: Unknown result type (might be due to invalid IL or missing references)
						if (!(Side.y >= 0f))
						{
							return -1f;
						}
						return 1f;
					}
				}

				public Vector2 Normal => Side * Out;

				public Vector2 At(float s, float x)
				{
					//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_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_0023: Unknown result type (might be due to invalid IL or missing references)
					return Root + Dir * s + Side * x;
				}

				public Vector2[] Quad(float pad, float from, float to)
				{
					//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)
					return Corners(Root, Dir, (0f - Width) * 0.5f - pad, Width * 0.5f + pad, from, to);
				}
			}

			private struct Hull
			{
				public Vector3 At;

				public float Yaw;

				public float Pitch;

				public float Roll;

				public float Length;

				public float Beam;

				public float Depth;

				public bool Cabin;

				public Surface Paint;
			}

			private readonly struct Frame
			{
				public readonly Vector3 O;

				public readonly Quaternion R;

				public Frame(Vector2 o, float yaw)
					: this(new Vector3(o.x, 0f, o.y), Yaw(yaw))
				{
				}//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: 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)


				public Frame(Vector3 o, float yaw)
					: this(o, Yaw(yaw))
				{
				}//IL_0001: 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)


				public Frame(Vector3 o, Quaternion r)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_0009: Unknown result type (might be due to invalid IL or missing references)
					O = o;
					R = r;
				}

				public 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_000f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_0019: Unknown result type (might be due to invalid IL or missing references)
					return O + R * new Vector3(x, y, z);
				}

				public Vector3 D(float x, float y, float z)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0009: Unknown result type (might be due to invalid IL or missing references)
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					return R * new Vector3(x, y, z);
				}

				public void Box(Piece p, float x0, float y0, float z0, float x1, float y1, float z1, Surface s, bool collider = true, bool visible = true)
				{
					//IL_0023: 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)
					//IL_003d: Unknown result type (might be due to invalid IL or missing references)
					//IL_006c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0071: Unknown result type (might be due to invalid IL or missing references)
					//IL_0073: Unknown result type (might be due to invalid IL or missing references)
					Vector3 val = default(Vector3);
					((Vector3)(ref val))..ctor(Mathf.Abs(x1 - x0), Mathf.Abs(y1 - y0), Mathf.Abs(z1 - z0));
					if (!(val.x < 0.005f) && !(val.y < 0.005f) && !(val.z < 0.005f))
					{
						p.Rotated(P((x0 + x1) * 0.5f, (y0 + y1) * 0.5f, (z0 + z1) * 0.5f), val, R, s, collider, visible);
					}
				}

				public void Pane(Piece p, float x0, float y0, float x1, float y1, float z, Surface s, bool back = false)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0028: Unknown result type (might be due to invalid IL or missing references)
					//IL_0048: Unknown result type (might be due to invalid IL or missing references)
					p.Quad(P(x0, y0, z), P(x1, y0, z), P(x1, y1, z), P(x0, y1, z), D(0f, 0f, back ? (-1f) : 1f), s, collider: false);
				}

				public void SidePane(Piece p, float z0, float y0, float z1, float y1, float x, Surface s, bool back = false)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Unknown result type (might be due to invalid IL or missing references)
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0028: Unknown result type (might be due to invalid IL or missing references)
					//IL_0048: Unknown result type (might be due to invalid IL or missing references)
					p.Quad(P(x, y0, z0), P(x, y0, z1), P(x, y1, z1), P(x, y1, z0), D(back ? (-1f) : 1f, 0f, 0f), s, collider: false);
				}
			}

			private struct QuayCol
			{
				public bool Ok;

				public float X;

				public float Lo;

				public float Hi;

				public float Back;

				public float Shown;
			}

			private sealed class RoofArea
			{
				public Building B;

				public float Y;

				public Rect Inner;

				public readonly List<Rect> Used = new List<Rect>();

				public readonly List<Rect> Tall = new List<Rect>();
			}

			private readonly CityPlan _plan;

			private readonly Planner _pl;

			private readonly GenSettings _s;

			private readonly ulong _seed;

			private readonly CityLayout _lay = new CityLayout();

			private readonly float _l;

			private readonly float _h;

			private readonly float _xMin;

			private readonly float _xMax;

			private readonly float _flood;

			private readonly float _bed;

			private readonly float _ground;

			private readonly float _zStart;

			private readonly float _zWall;

			private readonly float _lip;

			private int _lootPlaced;

			private const int MaxLoot = 36;

			private int _roofLoot;

			private int _roofLootMissed;

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

			private float _lipStart;

			private readonly SlotEnds _ends;

			private readonly Dictionary<(int, int), List<List<Seg>>> _faceSegs = new Dictionary<(int, int), List<List<Seg>>>();

			private readonly Dictionary<(int, int), List<List<Seg>>> _faceFull = new Dictionary<(int, int), List<List<Seg>>>();

			private readonly Dictionary<(int, int), List<Rect>> _slabRects = new Dictionary<(int, int), List<Rect>>();

			private readonly Dictionary<(int, int, int), float> _stubs = new Dictionary<(int, int, int), float>();

			private const float ShaftLip = 0.03f;

			private readonly Dictionary<int, Look> _looks = new Dictionary<int, Look>();

			private static readonly string[] ShopWords = new string[12]
			{
				"CAFE", "DELI", "BAR", "BOOKS", "PHARMACY", "BAKERY", "HOTEL", "DINER", "MARKET", "TAXI",
				"BANK", "PIZZA"
			};

			private static readonly Surface[] SignColours = new Surface[4]
			{
				Surface.SignRed,
				Surface.SignBlue,
				Surface.SignYellow,
				Surface.Paint
			};

			private const float DMoss = 0.03f;

			private const float DGrime = 0.06f;

			private const float DSoot = 0.06f;

			private const float DStreak = 0.06f;

			private const float DShopGlass = 0.088f;

			private const float DIvy = 0.185f;

			private int _ledgeProbes;

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

			private int _gardenBeds;

			private int _gardenHives;

			private static readonly Color32 Lawn = new Color32((byte)105, (byte)150, (byte)62, byte.MaxValue);

			private static readonly Color32 Soil = new Color32((byte)92, (byte)68, (byte)50, byte.MaxValue);

			private const float TreeClearance = 6.5f;

			private const float PortStoneClearance = 1.6f;

			private const float PortReach = 21f;

			private const float PortFacadeClearance = 6f;

			private const float PortDockMargin = 2f;

			private const float ShoreGap = 0.5f;

			private const float CopingH = 0.16f;

			private const float QuayBand = 1.5f;

			private const float BollardZ = -0.95f;

			private const float HouseW = 6.6f;

			private const float HouseD = 5.4f;

			private const float HouseH = 3.6f;

			private const float HouseT = 0.3f;

			private const float HouseRise = 1.55f;

			private static readonly Color32 Rust = new Color32((byte)222, (byte)160, (byte)124, byte.MaxValue);

			private static readonly Color32 Weathered = new Color32((byte)200, (byte)196, (byte)182, byte.MaxValue);

			private static readonly Surface[] HullPaints = new Surface[6]
			{
				Surface.SignRed,
				Surface.SignBlue,
				Surface.Paint,
				Surface.Paint,
				Surface.SignYellow,
				Surface.Steel
			};

			private static readonly string[] LandmarkNames = new string[14]
			{
				"BING BONG BANK", "SCOUT TOWER", "PEAK PLAZA", "SUMMIT HOTEL", "ASCENT TRUST", "GRANOLA CORP", "CAMPFIRE RADIO", "LANTERN BANK", "COCONUT TOWER", "BADGE CENTER",
				"ROPE WORKS", "SCOUTMASTER HQ", "MARSHMALLOW INN", "BEACON HOUSE"
			};

			private readonly Dictionary<int, string> _landmarks = new Dictionary<int, string>();

			private readonly Dictionary<int, RoofArea> _roofAreas = new Dictionary<int, RoofArea>();

			private static readonly string[] RoofWords = new string[16]
			{
				"HOTEL", "BANK", "PLAZA", "TOWER", "MOTEL", "OFFICE", "SCOUT", "PEAK", "BING BONG", "CINEMA",
				"RADIO", "NEWS", "TRUST", "METRO", "PARKING", "INSURANCE"
			};

			private const float Sink = 0.6f;

			private const float StreetClearance = 5f;

			private readonly List<Rect> _streetProps = new List<Rect>();

			private readonly List<(string name, Vector3 at)> _streetMarks = new List<(string, Vector3)>();

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

			private float _harbourX;

			private int _vendFloors;

			private int _vendRolled;

			private int _vendPlaced;

			private const float VendFront = 1.8f;

			private static readonly string[] Hauliers = new string[8] { "CARGO", "EXPRESS", "FRESH", "LOGISTIK", "FRACHT", "POST", "MILCH", "MOVERS" };

			private static readonly string[] Ads = new string[12]
			{
				"COLA", "MOTEL", "SALE", "TAXI", "HOTEL", "PIZZA", "BANK", "OPEN", "DINER", "FUEL",
				"SODA", "CAFE"
			};

			public Geo(CityPlan plan, Planner pl, float l, float h, float xMin, float xMax, GenSettings s, ulong seed)
			{
				_plan = plan;
				_pl = pl;
				_s = s;
				_seed = seed;
				_l = l;
				_h = h;
				_xMin = xMin;
				_xMax = xMax;
				_flood = pl.Flood;
				_bed = pl.Bed;
				_ground = pl.GroundY;
				_zStart = pl.ZStartWall;
				_zWall = pl.ZWall;
				_lip = s.WallLipOverhang;
				_ends = pl.Ends;
			}

			public CityLayout Build()
			{
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: 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_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0244: Unknown result type (might be due to invalid IL or missing references)
				//IL_027a: 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_0227: Unknown result type (might be due to invalid IL or missing references)
				//IL_0289: Unknown result type (might be due to invalid IL or missing references)
				//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
				_lay.XMin = _xMin;
				_lay.XMax = _xMax;
				_lay.HalfWidth = (_xMax - _xMin) * 0.5f;
				_lay.WallZ = _zWall;
				_lay.ZStart = _zStart;
				_lay.PlateauTop = _h;
				foreach (Building building in _plan.Buildings)
				{
					if (!building.IsPseudo)
					{
						_lay.Shelters.Add(new ShelterBox
						{
							Min = new Vector3(building.X0, (building.Below != null) ? building.FloorY(building.FirstFloor) : (_bed - 2f), building.Z0),
							Max = new Vector3(building.X1, building.TopY, building.Z1)
						});
					}
				}
				float num = ((_ends != null) ? (-10f) : _zStart);
				float num2 = ((_ends != null) ? (_zWall + 60f) : _zWall);
				_lay.Water = new WaterSpec
				{
					Level = _flood,
					BedY = _bed,
					Min = new Vector2(_xMin - 30f, num),
					Max = new Vector2(_xMax + 30f, num2)
				};
				_lay.StartPoint = new Vector3(0f, 0f, 4f);
				_lay.EndPoint = new Vector3(0f, _h, _l - 3f);
				_lay.DockPoint = ((_plan.Stones.Count > 0) ? new Vector3(((Rect)(ref _plan.Stones[0].Rect)).center.x, _plan.Stones[0].Top, ((Rect)(ref _plan.Stones[0].Rect)).center.y) : new Vector3(0f, -20f, _zStart + 0.6f));
				_lay.Hazard = new WaterHazard
				{
					Top = _flood - 0.9f,
					Bottom = _bed - 2f,
					Min = new Vector2(_xMin - 30f, num),
					Max = new Vector2(_xMax + 30f, num2)
				};
				Ground();
				if (_ends == null)
				{
					BackWall();
				}
				AmuletStatue();
				ChooseLandmarks();
				ChooseGardens();
				foreach (Building building2 in _plan.Buildings)
				{
					Tower(building2, Rng.For(_seed, "tower", building2.Id));
				}
				_lootPlaced = 0;
				_lay.Bridges.AddRange(_plan.Bridges);
				_lay.Vines.AddRange(_plan.Vines);
				SetPieces();
				Stones(Rng.For(_seed, "stones"));
				if (_ends != null)
				{
					Port(Rng.For(_seed, "port"));
				}
				Parks(Rng.For(_seed, "parks"));
				StreetTrees(Rng.For(_seed, "streettrees"));
				Streets(Rng.For(_seed, "streets"));
				if (_ends == null)
				{
					DamDetail(Rng.For(_seed, "dam"));
					Harbour(Rng.For(_seed, "harbour"));
				}
				Decor(Rng.For(_seed, "decor"));
				HangingDecor(Rng.For(_seed, "hanging"));
				GiantIvy(Rng.For(_seed, "giantivy"));
				Route();
				DevViews();
				_lay.MainTowers = _plan.Buildings.Count((Building b) => b.Chain);
				_lay.FillerTowers = _plan.Buildings.Count - _lay.MainTowers;
				_lay.Notes.AddRange(_plan.Notes);
				_lay.Notes.Add(string.Format("rooftop gardens: {0} with {1} beds and {2} beehives; landmarks: {3}", _gardens.Count, _gardenBeds, _gardenHives, string.Join(", ", _landmarks.Values)));
				_lay.Notes.Add($"roof suitcases: {_roofLoot} ({_roofLootMissed} wanted on a roof without room for them); chests inside: {_lootPlaced}");
				_lay.Notes.Add($"vending machines: {_vendPlaced} on {_vendFloors} open floors (chance {_s.VendingChance * 100f:F0}%, {_vendRolled - _vendPlaced} rolled without room for one)");
				_lay.Notes.Add($"x {_xMin:F0}..{_xMax:F0}, flood {_flood:F0}, bed {_bed:F0}, wall z {_zWall:F0}, plateau {_pl.Plateau:F0}, bridges {_plan.Bridges.Count}, " + ((_ends != null) ? $"vanilla ends: shore to z {_zStart:F0}, landing {_pl.Landing}" : "own harbour wall and dam"));
				return _lay;
			}

			private void Ground()
			{
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0177: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01af: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: 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_0043: 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_0212: Unknown result type (might be due to invalid IL or missing references)
				//IL_022b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: 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_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0300: Unknown result type (might be due to invalid IL or missing references)
				//IL_0311: Unknown result type (might be due to invalid IL or missing references)
				Piece piece = new Piece("Ground");
				float num = _xMin - 30f;
				float num2 = _xMax + 30f;
				if (_ends != null)
				{
					piece.MinMax(new Vector3(num, _bed - 4f, -10f), new Vector3(num2, _bed, _zWall + 60f), Surface.Rubble);
					float[] array = new float[2] { -1f, 1f };
					foreach (float num3 in array)
					{
						float num4 = ((num3 < 0f) ? num : num2);
						piece.Quad(new Vector3(num4, _bed - 260f, -10f), new Vector3(num4, _bed - 260f, _l + 30f), new Vector3(num4, _flood - 0.05f, _l + 30f), new Vector3(num4, _flood - 0.05f, -10f), new Vector3(num3, 0f, 0f), Surface.Rock, collider: false);
					}
					_lay.Pieces.Add(piece);
					return;
				}
				piece.MinMax(new Vector3(num, _bed - 4f, _zStart - 1f), new Vector3(num2, _bed, _zWall + 1f), Surface.Rubble);
				piece.MinMax(new Vector3(num, _bed - 4f, _zStart - 10f), new Vector3(num2, -0.15f, _zStart), Surface.Dam);
				piece.MinMax(new Vector3(-12f, -3.15f, -4f), new Vector3(12f, -0.15f, _zStart - 10f), Surface.Dam);
				for (float num5 = -20f; num5 > _flood + 4f; num5 -= 20f)
				{
					piece.MinMax(new Vector3(_xMin, num5 - 0.7f, _zStart), new Vector3(_xMax, num5, _zStart + 1.2f), Surface.Dam);
				}
				float[] array2 = new float[2] { -1f, 1f };
				foreach (float num6 in array2)
				{
					float num7 = ((num6 < 0f) ? num : num2);
					piece.Quad(new Vector3(num7, _bed - 260f, _zStart - 10f), new Vector3(num7, _bed - 260f, _l + 30f), new Vector3(num7, _flood - 0.05f, _l + 30f), new Vector3(num7, _flood - 0.05f, _zStart - 10f), new Vector3(num6, 0f, 0f), Surface.Rock, collider: false);
				}
				_lay.Pieces.Add(piece);
			}

			private void BackWall()
			{
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: 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_01e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0200: Unknown result type (might be due to invalid IL or missing references)
				Piece piece = new Piece("BackWall");
				Extrusion extrusion = new Extrusion
				{
					XMin = _xMin - 30f,
					XMax = _xMax + 30f,
					Surface = Surface.Dam
				};
				float num = MathF.PI * 13f / 36f;
				float num2 = _lip / (1f - Mathf.Cos(num));
				float num3 = (_lipStart = _h - 0.8f - num2 * Mathf.Sin(num));
				List<Vector2> profile = extrusion.Profile;
				profile.Add(new Vector2(_zWall, _bed - 4f));
				profile.Add(new Vector2(_zWall + 6f, _bed - 4f));
				profile.Add(new Vector2(_zWall + 6f, _h));
				profile.Add(new Vector2(_zWall - _lip, _h));
				profile.Add(new Vector2(_zWall - _lip, _h - 0.8f));
				for (int num4 = 9; num4 >= 0; num4--)
				{
					float num5 = num * (float)num4 / 10f;
					profile.Add(new Vector2(_zWall - num2 * (1f - Mathf.Cos(num5)), num3 + num2 * Mathf.Sin(num5)));
				}
				piece.Extrusions.Add(extrusion);
				_lay.Pieces.Add(piece);
				Piece piece2 = new Piece("Plateau");
				float num6 = Mathf.Max(_l + 30f, _zWall + 6f + 24f);
				piece2.MinMax(new Vector3(_xMin - 30f, _h - 10f, _zWall + 6f - 0.5f), new Vector3(_xMax + 30f, _h, num6), Surface.Dam);
				_lay.Pieces.Add(piece2);
			}

			private float Bottom(Building b)
			{
				if (b.Below != null)
				{
					return b.FloorY(b.FirstFloor);
				}
				return _bed - 3f;
			}

			private void Tower(Building b, Rng rng)
			{
				//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_010a: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0143: Unknown result type (might be due to invalid IL or missing references)
				//IL_015c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0212: Unknown result type (might be due to invalid IL or missing references)
				//IL_0217: Unknown result type (might be due to invalid IL or missing references)
				//IL_0236: Unknown result type (might be due to invalid IL or missing references)
				//IL_0251: 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_04b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
				Piece piece = new Piece(b.Name)
				{
					Tint = b.Tint
				};
				float top = b.TopY + (b.Broken ? 0f : 1.6f);
				SortedSet<int> sortedSet = new SortedSet<int>(b.OpenFloors);
				foreach (int openFloor in b.OpenFloors)
				{
					if (openFloor + 1 <= b.Floors)
					{
						sortedSet.Add(openFloor + 1);
					}
				}
				sortedSet.Add(b.Floors);
				foreach (int item in sortedSet)
				{
					if (item <= b.FirstFloor)
					{
						continue;
					}
					List<Rect> list = new List<Rect>();
					foreach (Shaft shaft in b.Shafts)
					{
						if (item > shaft.From && item <= shaft.To)
						{
							list.Add(Rect.MinMaxRect(shaft.X0, shaft.Z0, shaft.X1, shaft.Z1));
						}
					}
					foreach (Vector2Int hole in b.Holes)
					{
						Vector2Int current4 = hole;
						if (((Vector2Int)(ref current4)).x + 1 == item)
						{
							list.Add(HoleRect(b, ((Vector2Int)(ref current4)).y));
						}
					}
					foreach (Stair stair in b.Stairs)
					{
						if (stair.Floor + 1 == item)
						{
							list.Add(stair.Well);
						}
					}
					List<Rect> list2 = SlabRects(b, list, (item == b.Floors) ? 0.5f : 0.02f);
					_slabRects[(b.Id, item)] = list2;
					foreach (Rect item2 in list2)
					{
						Rect current6 = item2;
						piece.MinMax(new Vector3(((Rect)(ref current6)).xMin, b.FloorY(item) - 0.45f, ((Rect)(ref current6)).yMin), new Vector3(((Rect)(ref current6)).xMax, b.FloorY(item), ((Rect)(ref current6)).yMax), (item == b.Floors) ? Surface.Roof : Surface.Floor);
					}
				}
				for (int i = 0; i < 4; i++)
				{
					Face(piece, b, i, Bottom(b), top, rng);
				}
				for (int j = 0; j < 4; j++)
				{
					FacadeDetail(piece, b, j, _faceSegs[(b.Id, j)], top, Rng.For(_seed, "facade", b.Id * 4 + j));
				}
				foreach (int openFloor2 in b.OpenFloors)
				{
					Office(piece, b, openFloor2, Rng.For(_seed, "office", b.Id * 1000 + openFloor2));
					InteriorSkin(piece, b, openFloor2);
				}
				for (int k = 0; k < b.Shafts.Count; k++)
				{
					ShaftWalls(piece, b, b.Shafts[k], Rng.For(_seed, "shaft", b.Id * 16 + k));
				}
				foreach (Vector2Int hole2 in b.Holes)
				{
					Vector2Int current8 = hole2;
					Collapse(piece, b, current8, Rng.For(_seed, "collapse", b.Id * 64 + ((Vector2Int)(ref current8)).x));
				}
				for (int l = 0; l < b.Stairs.Count; l++)
				{
					StairFlight(piece, b, b.Stairs[l], Rng.For(_seed, "stair", b.Id * 64 + l));
				}
				foreach (FireStair fireStair in b.FireStairs)
				{
					FireEscape(piece, b, fireStair);
				}
				foreach (Vector3Int balcony in b.Balconies)
				{
					Balcony(piece, b, balcony);
				}
				OpeningDetail(piece, b, Rng.For(_seed, "openings", b.Id));
				NicheDetail(piece, b);
				LedgeDetail(piece, b);
				RuinTop(piece, b, Rng.For(_seed, "ruintop", b.Id));
				Roof(piece, b, rng);
				_lay.Pieces.Add(piece);
			}

			private static Rect HoleRect(Building b, int cell)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				return b.HoleRect(cell);
			}

			private static List<Rect> SlabRects(Building b, List<Rect> holes, float inset = 0.02f)
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				List<Rect> list = new List<Rect> { Rect.MinMaxRect(b.X0 + inset, b.Z0 + inset, b.X1 - inset, b.Z1 - inset) };
				foreach (Rect hole in holes)
				{
					Rect current = hole;
					List<Rect> list2 = new List<Rect>();
					foreach (Rect item in list)
					{
						Rect current2 = item;
						if (!((Rect)(ref current2)).Overlaps(current))
						{
							list2.Add(current2);
							continue;
						}
						if (((Rect)(ref current)).xMin > ((Rect)(ref current2)).xMin)
						{
							list2.Add(Rect.MinMaxRect(((Rect)(ref current2)).xMin, ((Rect)(ref current2)).yMin, ((Rect)(ref current)).xMin, ((Rect)(ref current2)).yMax));
						}
						if (((Rect)(ref current)).xMax < ((Rect)(ref current2)).xMax)
						{
							list2.Add(Rect.MinMaxRect(((Rect)(ref current)).xMax, ((Rect)(ref current2)).yMin, ((Rect)(ref current2)).xMax, ((Rect)(ref current2)).yMax));
						}
						float num = Mathf.Max(((Rect)(ref current2)).xMin, ((Rect)(ref current)).xMin);
						float num2 = Mathf.Min(((Rect)(ref current2)).xMax, ((Rect)(ref current)).xMax);
						if (((Rect)(ref current)).yMin > ((Rect)(ref current2)).yMin)
						{
							list2.Add(Rect.MinMaxRect(num, ((Rect)(ref current2)).yMin, num2, ((Rect)(ref current)).yMin));
						}
						if (((Rect)(ref current)).yMax < ((Rect)(ref current2)).yMax)
						{
							list2.Add(Rect.MinMaxRect(num, ((Rect)(ref current)).yMax, num2, ((Rect)(ref current2)).yMax));
						}
					}
					list = list2;
				}
				return list;
			}

			private static void OpeningSpan(Building b, Vector3Int o, out float a0, out float a1, out float y0, out float y1)
			{
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				float num = b.BayWidth(((Vector3Int)(ref o)).x);
				float num2 = b.BayCenter(((Vector3Int)(ref o)).x, ((Vector3Int)(ref o)).y);
				float num3 = Mathf.Min(Mathf.Max(1.15f, num * 0.5f - WindowInset(b)), num * 0.5f - 0.12f);
				a0 = num2 - num3;
				a1 = num2 + num3;
				float num4 = b.FloorY(((Vector3Int)(ref o)).z);
				float num5 = Sill(b);
				float num6 = 4.8600006f;
				float num7 = Mathf.Min(num6, Mathf.Max(num5 + WindowHeight(b), num5 + 3.2f));
				if (b.Doors.Contains(o))
				{
					y0 = num4 - 0.45f;
					y1 = num4 + Mathf.Max(3.4f, num7);
				}
				else
				{
					y0 = num4 + num5;
					y1 = num4 + num7;
				}
			}

			private static float WindowHeight(Building b)
			{
				return b.Style switch
				{
					Style.GlassOffice => 4.6600003f, 
					Style.Residential => 2.3f, 
					Style.Ruin => 2.6f, 
					_ => 2.4f, 
				};
			}

			private void NicheHole(Building b, Niche n, int bay, out float y0, out float y1)
			{
				Rng rng = Rng.For(_seed, "nichehole", (b.Id * 32 + n.Face * 8 + n.Floor % 8) * 16 + bay);
				float num = b.FloorY(n.Floor);
				bool flag = n.Bay1 > n.Bay0 && (bay == n.Bay0 || bay == n.Bay1);
				y0 = num - 0.45f + rng.Range(-0.1f, 0.2f);
				y1 = num + n.Height * (flag ? rng.Range(0.7f, 0.88f) : rng.Range(0.93f, 1f));
			}

			private void Face(Piece p, Building b, int f, float bottom, float top, Rng rng)
			{
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0214: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0408: 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_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_018d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_0512: Unknown result type (might be due to invalid IL or missing references)
				//IL_059d: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_05c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_055b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0560: Unknown result type (might be due to invalid IL or missing references)
				//IL_0564: Unknown result type (might be due to invalid IL or missing references)
				//IL_056b: Unknown result type (might be due to invalid IL or missing references)
				int num = b.Bays(f);
				float num2 = b.BayWidth(f);
				float num3 = ((f % 2 == 0) ? b.X0 : b.Z0);
				Surface surface = FacadeSurface(b);
				List<List<Seg>> list = new List<List<Seg>>(num);
				List<List<Seg>> list2 = new List<List<Seg>>(num);
				List<List<Vector3Int>> list3 = new List<List<Vector3Int>>(num);
				float y3;
				float y4;
				for (int i = 0; i < num; i++)
				{
					List<Vector2> list4 = new List<Vector2>
					{
						new Vector2(bottom, top)
					};
					foreach (Niche nich in b.Niches)
					{
						if (nich.Contains(f, i))
						{
							NicheHole(b, nich, i, out var y, out var y2);
							Subtract(list4, y, y2);
						}
					}
					if (b.RoofGaps.Contains(new Vector2Int(f, i)))
					{
						Subtract(list4, b.TopY, top + 1f);
					}
					if (b.Broken)
					{
						float num4 = (rng.Chance(0.5f) ? (rng.Range(0.5f, 2.5f) * 5.51f) : 0f);
						list4.Add(new Vector2(top, top + num4));
						_stubs[(b.Id, f, i)] = top + num4;
					}
					list2.Add(ToSegs(list4));
					List<Vector3Int> list5 = new List<Vector3Int>();
					foreach (Vector3Int opening in b.Openings)
					{
						Vector3Int current2 = opening;
						if (((Vector3Int)(ref current2)).x == f && ((Vector3Int)(ref current2)).y == i)
						{
							list5.Add(current2);
							OpeningSpan(b, current2, out y3, out y4, out var y5, out var y6);
							Subtract(list4, y5, y6);
						}
					}
					list3.Add(list5);
					list.Add(ToSegs(list4));
				}
				int num5 = 0;
				while (num5 < num)
				{
					if (list3[num5].Count > 0)
					{
						OpeningSpan(b, list3[num5][0], out var a, out var a2, out y4, out y3);
						float num6 = num3 + (float)num5 * num2;
						float a3 = num6 + num2;
						foreach (Seg item in list2[num5])
						{
							FaceBoxA(p, b, f, num6, a, item.Y0, item.Y1, surface, collider: true, visible: false);
							FaceBoxA(p, b, f, a2, a3, item.Y0, item.Y1, surface, collider: true, visible: false);
						}
						foreach (Seg item2 in list[num5])
						{
							FaceBoxA(p, b, f, a, a2, item2.Y0, item2.Y1, surface, collider: true, visible: false);
						}
						num5++;
						continue;
					}
					int j;
					for (j = num5; j + 1 < num && list3[j + 1].Count == 0 && Same(list2[j + 1], list2[num5]); j++)
					{
					}
					foreach (Seg item3 in list2[num5])
					{
						FaceBox(p, b, f, num5, j, item3.Y0, item3.Y1, surface, collider: true, visible: false);
					}
					num5 = j + 1;
				}
				List<List<Vector2>> list6 = WindowRows(b, f, list, rng);
				for (int k = 0; k < num; k++)
				{
					float num7 = num3 + (float)k * num2;
					float num8 = num7 + num2;
					float num9 = b.BayCenter(f, k);
					float num10 = num2 * 0.5f - WindowInsetOf(b);
					float a4 = float.NaN;
					float a5 = float.NaN;
					if (list3[k].Count > 0)
					{
						OpeningSpan(b, list3[k][0], out a4, out a5, out y3, out y4);
					}
					List<float> list7 = new List<float>
					{
						num7,
						num8,
						num9 - num10,
						num9 + num10
					};
					if (!float.IsNaN(a4))
					{
						list7.Add(a4);
						list7.Add(a5);
					}
					list7.Sort();
					for (int l = 0; l + 1 < list7.Count; l++)
					{
						float num11 = list7[l];
						float num12 = list7[l + 1];
						float num13 = (num11 + num12) * 0.5f;
						if (num12 - num11 < 0.02f || num13 < num7 || num13 > num8)
						{
							continue;
						}
						bool flag = !float.IsNaN(a4) && num13 > a4 && num13 < a5;
						List<Vector2> list8 = new List<Vector2>();
						foreach (Seg item4 in flag ? list[k] : list2[k])
						{
							list8.Add(new Vector2(item4.Y0, item4.Y1));
						}
						if (num13 > num9 - num10 && num13 < num9 + num10)
						{
							foreach (Vector2 item5 in list6[k])
							{
								Subtract(list8, item5.x, item5.y);
							}
						}
						foreach (Vector2 item6 in list8)
						{
							if (item6.y - item6.x > 0.02f)
							{
								FaceBoxA(p, b, f, num11, num12, item6.x, item6.y, surface, collider: false);
							}
						}
					}
				}
				_faceSegs[(b.Id, f)] = list;
				_faceFull[(b.Id, f)] = list2;
				Windows(p, b, f, list6);
			}

			private static List<Seg> ToSegs(List<Vector2> intervals)
			{
				//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_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_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				List<Seg> list = new List<Seg>();
				foreach (Vector2 interval in intervals)
				{
					if (interval.y - interval.x > 0.05f)
					{
						list.Add(new Seg
						{
							Y0 = interval.x,
							Y1 = interval.y
						});
					}
				}
				return list;
			}

			private static void FaceBoxA(Piece p, Building b, int f, float a0, float a1, float y0, float y1, Surface surface, bool collider = true, bool visible = true)
			{
				//IL_0033: 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_009a: 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_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: 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)
				if (!(a1 - a0 < 0.02f))
				{
					float num = 0.5f;
					switch (f)
					{
					case 0:
						p.MinMax(new Vector3(a0, y0, b.Z0), new Vector3(a1, y1, b.Z0 + num), surface, collider, visible);
						break;
					case 2:
						p.MinMax(new Vector3(a0, y0, b.Z1 - num), new Vector3(a1, y1, b.Z1), surface, collider, visible);
						break;
					case 1:
						p.MinMax(new Vector3(b.X1 - num, y0, Mathf.Max(a0, b.Z0 + num)), new Vector3(b.X1, y1, Mathf.Min(a1, b.Z1 - num)), surface, collider, visible);
						break;
					default:
						p.MinMax(new Vector3(b.X0, y0, Mathf.Max(a0, b.Z0 + num)), new Vector3(b.X0 + num, y1, Mathf.Min(a1, b.Z1 - num)), surface, collider, visible);
						break;
					}
				}
			}

			private static bool Same(List<Seg> a, List<Seg> c)
			{
				if (a.Count != c.Count)
				{
					return false;
				}
				for (int i = 0; i < a.Count; i++)
				{
					if (Mathf.Abs(a[i].Y0 - c[i].Y0) > 0.001f || Mathf.Abs(a[i].Y1 - c[i].Y1) > 0.001f)
					{
						return false;
					}
				}
				return true;
			}

			private static void Subtract(List<Vector2> intervals, float a, float c)
			{
				//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_0014: 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_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				for (int num = intervals.Count - 1; num >= 0; num--)
				{
					Vector2 val = intervals[num];
					if (!(c <= val.x) && !(a >= val.y))
					{
						intervals.RemoveAt(num);
						if (val.x < a)
						{
							intervals.Insert(num, new Vector2(val.x, a));
						}
						if (c < val.y)
						{
							intervals.Insert((val.x < a) ? (num + 1) : num, new Vector2(c, val.y));
						}
					}
				}
			}

			private static Surface FacadeSurface(Building b)
			{
				switch (b.Style)
				{
				case Style.GlassOffice:
					return Surface.Curtain;
				case Style.Residential:
					return Surface.Brick;
				case Style.Ruin:
					return Surface.Rock;
				default:
				{
					Building building = b;
					while (building.Below != null)
					{
						building = building.Below;
					}
					if ((building.Id & 1) != 0)
					{
						return Surface.Stone;
					}
					return Surface.Concrete;
				}
				}
			}

			private static void FaceBox(Piece p, Building b, int f, int b0, int b1, float y0, float y1, Surface surface, bool collider = true, bool visible = true)
			{
				float num = b.BayWidth(f);
				float a = ((f % 2 == 0) ? b.X0 : b.Z0) + (float)b0 * num;
				float a2 = ((f % 2 == 0) ? b.X0 : b.Z0) + (float)(b1 + 1) * num;
				FaceBoxA(p, b, f, a, a2, y0, y1, surface, collider, visible);
			}

			private static float WindowInsetOf(Building b)
			{
				if (b.Style != Style.GlassOffice)
				{
					if (b.Style != Style.Residential)
					{
						if (b.Style != Style.Ruin)
						{
							return 0.3f;
						}
						return 0.5f;
					}
					return 0.7f;
				}
				return 0.15f;
			}

			private List<List<Vector2>> WindowRows(Building b, int f, List<List<Seg>> bays, Rng rng)
			{
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				float sill = b.Sill;
				float num = ((b.Style == Style.GlassOffice) ? 4.6600003f : ((b.Style == Style.Residential) ? 2.3f : ((b.Style == Style.Ruin) ? 2.6f : 2.4f)));
				int num2 = Mathf.Max(b.FirstFloor, Mathf.CeilToInt((_flood + 0.3f - sill - b.BaseY) / 5.51f));
				List<List<Vector2>> list = new List<List<Vector2>>(bays.Count);
				for (int i = 0; i < bays.Count; i++)
				{
					List<Vector2> list2 = new List<Vector2>();
					for (int j = num2; j < b.Floors; j++)
					{
						float num3 = b.FloorY(j) + sill;
						float num4 = num3 + num;
						if (num3 < _flood)
						{
							continue;
						}
						bool flag = false;
						foreach (Seg item in bays[i])
						{
							if (item.Y0 <= num3 && item.Y1 >= num4)
							{
								flag = true;
								break;
							}
						}
						if (flag)
						{
							list2.Add(new Vector2(num3, num4));
						}
					}
					list.Add(list2);
				}
				return list;
			}

			private void Windows(Piece p, Building b, int f, List<List<Vector2>> rows)
			{
				//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_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_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: 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_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: 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_013f: Unknown result type (might be due to invalid IL or missing references)
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: 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_0159: Unknown result type (might be due to invalid IL or missing references)
				float num = b.BayWidth(f);
				float num2 = num * 0.5f - WindowInsetOf(b);
				Surface s = ((b.Style != Style.GlassOffice) ? Surface.Window : Surface.Glass);
				Vector3 val = Building.FaceNormal(f);
				for (int i = 0; i < rows.Count; i++)
				{
					float num3 = b.BayCenter(f, i);
					foreach (Vector2 item2 in rows[i])
					{
						p.Panels.Add(Oriented(b.FacePoint(f, num3 - num2, item2.x, -0.15f), b.FacePoint(f, num3 + num2, item2.x, -0.15f), b.FacePoint(f, num3 + num2, item2.y, -0.15f), b.FacePoint(f, num3 - num2, item2.y, -0.15f), val, s));
						int item = Mathf.FloorToInt((item2.x - b.BaseY) / 5.51f + 0.001f);
						if (b.OpenFloors.Contains(item))
						{
							float outward = -0.53f;
							p.Panels.Add(Oriented(b.FacePoint(f, num3 - num2, item2.x, outward), b.FacePoint(f, num3 + num2, item2.x, outward), b.FacePoint(f, num3 + num2, item2.y, outward), b.FacePoint(f, num3 - num2, item2.y, outward), -val, Surface.Window));
						}
					}
				}
			}

			private static Panel Oriented(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 facing, Surface s)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: 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_0063: 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_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				Vector3 val = Vector3.Cross(d - a, b - a);
				if (Vector3.Dot(val, facing) < 0f)
				{
					Vector3 val2 = b;
					b = d;
					d = val2;
				}
				return new Panel
				{
					A = a,
					B = b,
					C = c,
					D = d,
					Surface = s,
					Tint = Piece.White
				};
			}

			private void ShaftWalls(Piece p, Building b, Shaft sh, Rng rng)
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c3: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dd: 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_01f2: 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_0146: 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_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_0167: Unknown result type (might be due to invalid IL or missing references)
				float num = b.FloorY(sh.From);
				float num2 = Mathf.Min(b.FloorY(sh.To + 1), b.TopY) - 0.45f;
				for (int i = 0; i < 4; i++)
				{
					List<Vector2> list = new List<Vector2>
					{
						new Vector2(num, num2)
					};
					float num3 = ((i % 2 == 0) ? (sh.X0 - 0.3f) : (sh.Z0 - 0.3f));
					float num4 = ((i % 2 == 0) ? (sh.X1 + 0.3f) : (sh.Z1 + 0.3f));
					float num5 = (num3 + num4) * 0.5f;
					if (i == sh.DoorFace)
					{
						Strip(p, i, sh, num3, num5 - 0.7975f, num, num2, 0.3f);
						Strip(p, i, sh, num5 + 0.7975f, num4, num, num2, 0.3f);
						List<Vector2> list2 = new List<Vector2>
						{
							new Vector2(num, num2)
						};
						Subtract(list2, b.FloorY(sh.From), b.FloorY(sh.From) + 3.2f);
						Subtract(list2, b.FloorY(sh.To) - 0.45f, b.FloorY(sh.To) + 3.2f);
						foreach (Vector2 item in list2)
						{
							Strip(p, i, sh, num5 - 0.7975f, num5 + 0.7975f, item.x, item.y, 0.3f);
						}
					}
					else
					{
						Strip(p, i, sh, num3, num4, num, num2, 0.3f);
					}
				}
				Vector3 val = DoorPoint(sh, b.FloorY(sh.To));
				p.MinMax(val + new Vector3(-0.9f, -0.45f, -0.9f), val + new Vector3(0.9f, 0f, 0.9f), Surface.Floor);
				if (rng.Chance(0.5f))
				{
					ShaftLadder(p, sh, num, num2);
				}
				else
				{
					ShaftObstacles(p, b, sh, num, num2, rng);
				}
			}

			private static Vector3 ShaftWallPoint(Shaft sh, int f, float a, float y, float d)
			{
				//IL_0025: 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_003c: 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)
				return (Vector3)(f switch
				{
					0 => new Vector3(a, y, sh.Z0 + 0.03f + d), 
					2 => new Vector3(a, y, sh.Z1 - 0.03f - d), 
					1 => new Vector3(sh.X1 - 0.03f - d, y, a), 
					_ => new Vector3(sh.X0 + 0.03f + d, y, a), 
				});
			}

			private static void ShaftLadder(Piece p, Shaft sh, float y0, float y1)
			{
				//IL_00ff: 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_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0167: Unknown result type (might be due to invalid IL or missing references)
				//IL_0225: Unknown result type (might be due to invalid IL or missing references)
				//IL_022a: Unknown result type (might be due to invalid IL or missing references)
				//IL_023a: Unknown result type (might be due to invalid IL or missing references)
				//IL_023f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0247: Unknown result type (might be due to invalid IL or missing references)
				//IL_0249: Unknown result type (might be due to invalid IL or missing references)
				//IL_024b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0250: Unknown result type (might be due to invalid IL or missing references)
				//IL_0252: Unknown result type (might be due to invalid IL or missing references)
				//IL_0254: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
				int side = (sh.DoorFace + 1) % 4;
				float num = ((sh.DoorFace == 0) ? sh.Z0 : ((sh.DoorFace == 2) ? sh.Z1 : ((sh.DoorFace == 1) ? sh.X1 : sh.X0)));
				float num2 = ((sh.DoorFace == 0 || sh.DoorFace == 3) ? 1f : (-1f));
				float a = num + num2 * 0.78f;
				float num3 = y0 + 0.02f;
				float num4 = y1 - 0.25f;
				float[] array = new float[2] { -0.28f, 0.28f };
				foreach (float num5 in array)
				{
					Bar(At(num5 - 0.035f, num3, 0.14f), At(num5 + 0.035f, num4, 0.21f));
				}
				for (float num6 = num3 + 0.3f; num6 < num4 - 0.1f; num6 += 0.32f)
				{
					Bar(At(-0.28f, num6 - 0.025f, 0.155f), At(0.28f, num6 + 0.025f, 0.195f));
				}
				for (float num7 = num3 + 1f; num7 < num4; num7 += 2.2f)
				{
					float[] array2 = new float[2] { -0.28f, 0.28f };
					foreach (float num8 in array2)
					{
						Bar(At(num8 - 0.03f, num7 - 0.04f, 0f), At(num8 + 0.03f, num7 + 0.04f, 0.15f));
					}
				}
				Vector3 val = At(-0.36f, num3, 0f);
				Vector3 val2 = At(0.36f, num4, 0.22f);
				p.MinMax(Vector3.Min(val, val2), Vector3.Max(val, val2), Surface.Ladder, collider: true, visible: false);
				Vector3 At(float u, float y2, float d)
				{
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					return ShaftWallPoint(sh, side, a + u, y2, d);
				}
				void Bar(Vector3 c0, Vector3 c1)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_000f: Unknown result type (might be due to invalid IL or missing references)
					p.MinMax(Vector3.Min(c0, c1), Vector3.Max(c0, c1), Surface.Ladder, collider: false);
				}
			}

			private void ShaftObstacles(Piece p, Building b, Shaft sh, float y0, float y1, Rng rng)
			{
				//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_0411: Unknown result type (might be due to invalid IL or missing references)
				//IL_0420: Unknown result type (might be due to invalid IL or missing references)
				//IL_042e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0443: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_050a: Unknown result type (might be due to invalid IL or missing references)
				//IL_050c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0512: Unknown result type (might be due to invalid IL or missing references)
				//IL_0514: Unknown result type (might be due to invalid IL or missing references)
				//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b7: 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_035e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0385: Unknown result type (might be due to invalid IL or missing references)
				//IL_049f: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0196: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d6: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_0207: Unknown result type (might be due to invalid IL or missing references)
				//IL_0215: Unknown result type (might be due to invalid IL or missing references)
				//IL_0226: Unknown result type (might be due to invalid IL or missing references)
				//IL_022b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0230: Unknown result type (might be due to invalid IL or missing references)
				//IL_0241: Unknown result type (might be due to invalid IL or missing references)
				//IL_0246: Unknown result type (might be due to invalid IL or missing references)
				//IL_0254: Unknown result type (might be due to invalid IL or missing references)
				//IL_0265: Unknown result type (might be due to invalid IL or missing references)
				//IL_026a: 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_0285: Unknown result type (might be due to invalid IL or missing references)
				float num = sh.X0 + 0.03f;
				float num2 = sh.X1 - 0.03f;
				float num3 = sh.Z0 + 0.03f;
				float num4 = sh.Z1 - 0.03f;
				float lowDoorTop = b.FloorY(sh.From) + 3.6f;
				float highDoor = b.FloorY(sh.To) - 0.6f;
				float num5 = float.NaN;
				Vector3 zero = Vector3.zero;
				if (highDoor - lowDoorTop > 5.7f)
				{
					float num6 = rng.Range(lowDoorTop + 1f, highDoor - 2.7f - 1f);
					float num7 = (rng.Chance(0.5f) ? (num2 - 1f) : (num + 1f));
					float num8 = (rng.Chance(0.5f) ? (num4 - 1f) : (num3 + 1f));
					if (sh.DoorFace == 0)
					{
						num8 = num4 - 1f;
					}
					if (sh.DoorFace == 2)
					{
						num8 = num3 + 1f;
					}
					if (sh.DoorFace == 1)
					{
						num7 = num + 1f;
					}
					if (sh.DoorFace == 3)
					{
						num7 = num2 - 1f;
					}
					((Vector3)(ref zero))..ctor(num7, num6, num8);
					p.MinMax(zero + new Vector3(-1f, 0f, -1f), zero + new Vector3(1f, 2.7f, 1f), Surface.Steel);
					p.MinMax(zero + new Vector3(-0.45f, 2.7f, -0.45f), zero + new Vector3(0.45f, 2.76f, 0.45f), Surface.Metal, collider: false);
					p.MinMax(zero + new Vector3(-0.5f, 0.1f, -1.03f), zero + new Vector3(0.5f, 2.45f, -1f), Surface.Window, collider: false);
					p.MinMax(zero + new Vector3(-0.5f, 0.1f, 1f), zero + new Vector3(0.5f, 2.45f, 1.03f), Surface.Window, collider: false);
					num5 = num6 + 2.7f;
				}
				int num9 = Mathf.Max(1, Mathf.FloorToInt((y1 - y0) / 6.5f));
				for (int i = 0; i < 12; i++)
				{
					if (num9 <= 0)
					{
						break;
					}
					float num10 = rng.Range(y0 + 1f, y1 - 1f);
					if (ClearOfDoors(num10 - 0.2f, num10 + 0.2f) && (float.IsNaN(num5) || !(num10 > zero.y - 1.2f) || !(num10 < num5 + 1.6f)))
					{
						float num11 = rng.Range(-0.6f, 0.6f);
						if (rng.Chance(0.5f))
						{
							p.MinMax(new Vector3(num - 0.2f, num10 - 0.17f, (num3 + num4) * 0.5f + num11 - 0.15f), new Vector3(num2 + 0.2f, num10 + 0.17f, (num3 + num4) * 0.5f + num11 + 0.15f), Surface.Steel);
						}
						else
						{
							p.MinMax(new Vector3((num + num2) * 0.5f + num11 - 0.15f, num10 - 0.17f, num3 - 0.2f), new Vector3((num + num2) * 0.5f + num11 + 0.15f, num10 + 0.17f, num4 + 0.2f), Surface.Steel);
						}
						num9--;
					}
				}
				Vector3 val = default(Vector3);
				Vector3 val2 = default(Vector3);
				if (!float.IsNaN(num5))
				{
					((Vector3)(ref val))..ctor(zero.x, y1 - 0.05f, zero.z);
					((Vector3)(ref val2))..ctor(zero.x + 0.2f, num5 + 0.08f, zero.z);
				}
				else
				{
					Vector3 val3 = default(Vector3);
					((Vector3)(ref val3))..ctor(rng.Chance(0.5f) ? (num + 0.55f) : (num2 - 0.55f), 0f, rng.Chance(0.5f) ? (num3 + 0.55f) : (num4 - 0.55f));
					((Vector3)(ref val))..ctor(val3.x, y1 - 0.05f, val3.z);
					((Vector3)(ref val2))..ctor(val3.x + 0.3f, y0 + 0.05f, val3.z + 0.2f);
				}
				if (val.y - val2.y > 4f)
				{
					_lay.Vines.Add(new VinePlan
					{
						From = val,
						To = val2,
						Hang = -0.25f,
						Chain = true,
						SpotA = -1,
						SpotB = -1
					});
				}
				bool ClearOfDoors(float ya, float yb)
				{
					if (!(ya > lowDoorTop) || !(yb < highDoor))
					{
						return ya > b.FloorY(sh.To) + 3.6f;
					}
					return true;
				}
			}

			private static Vector3 DoorPoint(Shaft sh, float y)
			{
				//IL_0051: 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_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				float num = (sh.X0 + sh.X1) * 0.5f;
				float num2 = (sh.Z0 + sh.Z1) * 0.5f;
				return (Vector3)(sh.DoorFace switch
				{
					0 => new Vector3(num, y, sh.Z0 - 0.6f), 
					1 => new Vector3(sh.X1 + 0.6f, y, num2), 
					2 => new Vector3(num, y, sh.Z1 + 0.6f), 
					_ => new Vector3(sh.X0 - 0.6f, y, num2), 
				});
			}

			private static void Strip(Piece p, int f, Shaft sh, float a0, float a1, float y0, float y1, float t)
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: 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_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				if (!(a1 - a0 < 0.05f) && !(y1 - y0 < 0.05f))
				{
					switch (f)
					{
					case 0:
						p.MinMax(new Vector3(a0, y0, sh.Z0 - t), new Vector3(a1, y1, sh.Z0 + 0.03f), Surface.Concrete);
						break;
					case 2:
						p.MinMax(new Vector3(a0, y0, sh.Z1 - 0.03f), new Vector3(a1, y1, sh.Z1 + t), Surface.Concrete);
						break;
					case 1:
						p.MinMax(new Vector3(sh.X1 - 0.03f, y0, a0), new Vector3(sh.X1 + t, y1, a1), Surface.Concrete);
						break;
					default:
						p.MinMax(new Vector3(sh.X0 - t, y0, a0), new Vector3(sh.X0 + 0.03f, y1, a1), Surface.Concrete);
						break;
					}
				}
			}

			private void Collapse(Piece p, Building b, Vector2Int h, Rng rng)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: 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_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: 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_018d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0273: 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_02bf: Unknown result type (might be due to invalid IL or missing references)
				Rect val = HoleRect(b, ((Vector2Int)(ref h)).y);
				float num = b.FloorY(((Vector2Int)(ref h)).x);
				float num2 = b.FloorY(((Vector2Int)(ref h)).x + 1);
				float num3 = num2 - 0.45f;
				Vector3 a = default(Vector3);
				((Vector3)(ref a))..ctor(((Rect)(ref val)).center.x, num, ((Rect)(ref val)).yMin - 2.2f);
				Vector3 b2 = default(Vector3);
				((Vector3)(ref b2))..ctor(((Rect)(ref val)).center.x, num3 - 3f, ((Rect)(ref val)).center.y - 0.4f);
				p.Beam(a, b2, ((Rect)(ref val)).width - 0.8f, 0.45f, Surface.Carpet);
				float[] array = new float[3] { 0.6f, 1.1f, 1.6f };
				Vector3 val2 = default(Vector3);
				for (int i = 0; i < array.Length; i++)
				{
					float num4 = (rng.Chance(0.5f) ? (-1f) : 1f);
					float num5 = ((Rect)(ref val)).center.x + num4 * (((Rect)(ref val)).width * 0.5f + rng.Range(0.2f, 0.9f));
					float num6 = Mathf.Lerp(((Rect)(ref val)).yMin - 1.6f, ((Rect)(ref val)).yMax - 0.6f, ((float)i + 0.5f) / (float)array.Length) + rng.Range(-0.3f, 0.3f);
					((Vector3)(ref val2))..ctor(rng.Range(1f, 1.6f), array[i] + rng.Range(-0.15f, 0.1f), rng.Range(1f, 1.5f));
					p.Rotated(new Vector3(num5, num + val2.y * 0.5f - 0.05f, num6), val2, Quaternion.Euler(rng.Range(-6f, 6f), rng.Range(0f, 360f), rng.Range(-6f, 6f)), Surface.Carpet);
				}
				Vector3 center = default(Vector3);
				for (int num7 = rng.Range(3, 7); num7 > 0; num7--)
				{
					float num8 = rng.Range(0.25f, 0.6f);
					((Vector3)(ref center))..ctor(rng.Range(((Rect)(ref val)).xMin - 1f, ((Rect)(ref val)).xMax + 1f), num + num8 * 0.3f, rng.Range(((Rect)(ref val)).yMin - 2.5f, ((Rect)(ref val)).yMax + 0.5f));
					p.Rotated(center, new Vector3(num8 * 1.5f, num8, num8 * 1.2f), Quaternion.Euler(rng.Range(-25f, 25f), rng.Range(0f, 360f), rng.Range(-25f, 25f)), rng.Chance(0.5f) ? Surface.Carpet : Surface.Ceiling, collider: false);
				}
			}

			private static void Balcony(Piece p, Building b, Vector3Int bal)
			{
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: 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_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				int x = ((Vector3Int)(ref bal)).x;
				int y = ((Vector3Int)(ref bal)).y;
				int z = ((Vector3Int)(ref bal)).z;
				float num = b.BayWidth(x);
				float num2 = b.BayCenter(x, y) - num * 0.5f;
				float a = num2 + 2f * num;
				float num3 = b.FloorY(z);
				Vector3 val = Building.FaceNormal(x);
				Vector3 val2 = b.FacePoint(x, num2, num3 - 0.35f, -0.3f);
				Vector3 val3 = b.FacePoint(x, a, num3, 2.1750002f);
				p.MinMax(Vector3.Min(val2, val3), Vector3.Max(val2, val3), Surface.Floor);
				Vector3 val4 = b.FacePoint(x, num2, num3, 2.0550003f);
				Vector3 val5 = b.FacePoint(x, a, num3 + 1.595f, 2.1750002f);
				p.MinMax(Vector3.Min(val4, val5), Vector3.Max(val4, val5), Surface.Metal);
			}

			private void Decor(Rng rng)
			{
				//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_04de: Unknown result type (might be due to invalid IL or missing references)
				//IL_051d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0522: Unknown result type (might be due to invalid IL or missing references)
				//IL_0539: Unknown result type (might be due to invalid IL or missing references)
				//IL_053b: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0752: Unknown result type (might be due to invalid IL or missing references)
				//IL_0759: Unknown result type (might be due to invalid IL or missing references)
				//IL_0767: Unknown result type (might be due to invalid IL or missing references)
				//IL_076c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0133: Unknown result type (might be due to invalid IL or missing references)
				//IL_014a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_0791: Unknown result type (might be due to invalid IL or missing references)
				//IL_0793: Unknown result type (might be due to invalid IL or missing references)
				//IL_062f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0634: Unknown result type (might be due to invalid IL or missing references)
				//IL_064b: Unknown result type (might be due to invalid IL or missing references)
				//IL_064d: Unknown result type (might be due to invalid IL or missing references)
				//IL_024b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0262: Unknown result type (might be due to invalid IL or missing references)
				//IL_026c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0271: Unknown result type (might be due to invalid IL or missing references)
				//IL_032d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0344: Unknown result type (might be due to invalid IL or missing references)
				//IL_034e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0353: Unknown result type (might be due to invalid IL or missing references)
				//IL_040f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0426: 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)
				HashSet<int> hashSet = new HashSet<int>(_plan.SolutionSpots);
				Vector3 val = default(Vector3);
				foreach (Spot s in _plan.Spots)
				{
					switch (s.Kind)
					{
					case SpotKind.Roof:
					{
						Building building = _plan.Buildings.First((Building x) => x.Id == s.Building);
						if (building.TopY < _flood + 1f)
						{
							break;
						}
						RoofArea r = RoofAreaOf(building);
						float num = building.W * building.D;
						for (int num2 = rng.Range(2, 4); num2 > 0; num2--)
						{
							if (Place(r, rng, 2.2f, 2.2f, 1.6f, out var rect, 0.3f) || Place(r, rng, 1.6f, 1.6f, 1.6f, out rect, 0.1f))
							{
								_roofLoot++;
								_lay.Decor.Add(new DecorSpot
								{
									Position = new Vector3(((Rect)(ref rect)).center.x, s.Y, ((Rect)(ref rect)).center.y),
									Kind = DecorKind.Roof,
									Clearance = 2f,
									Radius = 1.1f,
									Loot = true,
									Rare = rng.Chance(0.12f)
								});
							}
							else
							{
								_roofLootMissed++;
							}
						}
						int num3 = rng.Range(0, Mathf.Clamp(Mathf.RoundToInt(num / 320f), 1, 4) + 1);
						for (int num4 = 0; num4 < num3; num4++)
						{
							float[] array = new float[3] { 19f, 14f, 8f };
							foreach (float num6