Decompiled source of HTF1v1 v1.2.10

HTF1v1.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FishNet;
using FishNet.Broadcast;
using FishNet.Connection;
using FishNet.Object;
using FishNet.Serializing;
using FishNet.Transporting;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 HTF1v1
{
	internal static class Cfg
	{
		public static ConfigEntry<bool> Enabled;

		public static ConfigEntry<KeyCode> ToggleKey;

		public static ConfigEntry<float> ArenaSize;

		public static ConfigEntry<Vector3> ArenaOrigin;

		public static ConfigEntry<float> WallHeightMult;

		public static ConfigEntry<int> CountdownSeconds;

		public static ConfigEntry<int> StartMoney;

		public static ConfigEntry<float> MinSpawnDistance;

		public static ConfigEntry<float> PvpDamageMultiplier;

		public static ConfigEntry<float> RecoilMultiplier;

		public static ConfigEntry<int> ScoreCap;

		public static ConfigEntry<bool> ClearWeaponsBetweenRounds;

		public static ConfigEntry<bool> AutoCleanThrownItems;

		public static ConfigEntry<bool> VerboseLogging;

		public static ConfigEntry<bool> EnableSlide;

		public static ConfigEntry<float> SlideSpeedMult;

		public static ConfigEntry<float> SlideDuration;

		public static ConfigEntry<int> WeaponsPerSpawn;

		public static ConfigEntry<bool> IncludeMelee;

		public static ConfigEntry<bool> ShowWeaponLabels;

		public static ConfigEntry<bool> IncludeExplosives;

		public static ConfigEntry<float> RoundTimeLimit;

		public static ConfigEntry<bool> EnableLights;

		public static ConfigEntry<bool> RotateMaps;

		public static ConfigEntry<string> EnabledMaps;

		public static ConfigEntry<float> FloodDelaySeconds;

		public static ConfigEntry<float> FloodRiseSeconds;

		public static ConfigEntry<float> FloodWarnSeconds;

		public static ConfigEntry<int> FloodDamage;

		public static ConfigEntry<float> FloodWaveHeight;

		public static ConfigEntry<Color> FloodColor;

		public static ConfigEntry<bool> FloodSounds;

		public static ConfigEntry<bool> FloodUnderwaterEffect;

		public static ConfigEntry<bool> FloodEndsRound;

		public static ConfigEntry<bool> IncludeCigarette;

		public static ConfigEntry<string> BlockedWeapons;

		public static ConfigEntry<bool> ShowMenuButton;

		public static ConfigEntry<bool> CountdownSound;

		public static ConfigEntry<bool> PlayMusic;

		public static ConfigEntry<string> MusicTrack;

		public static ConfigEntry<float> FogAmount;

		public static ConfigEntry<bool> NoHunger;

		public static ConfigEntry<KeyCode> BuyMenuKey;

		public static ConfigEntry<int> BuyMenuSlots;

		public static ConfigEntry<bool> ClearInventoryEachRound;

		public static ConfigEntry<bool> SuppressIslandWarning;

		public static void Bind(ConfigFile c)
		{
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			Enabled = c.Bind<bool>("General", "Enabled", true, "Master switch for the 1v1 mode.");
			ToggleKey = c.Bind<KeyCode>("General", "ToggleKey", (KeyCode)290, "In-game hotkey to enter/leave 1v1 mode without using the menu button.");
			SuppressIslandWarning = c.Bind<bool>("General", "SuppressIslandWarning", true, "Completely suppress the 'You can't progress if you leave your friends' warning.");
			VerboseLogging = c.Bind<bool>("General", "VerboseLogging", false, "Extra diagnostics. Never logs per-frame.");
			EnableSlide = c.Bind<bool>("Movement", "EnableSlide", true, "Crouch while moving fast on the ground to slide, FPS-style.");
			SlideSpeedMult = c.Bind<float>("Movement", "SlideSpeedMult", 1.45f, "Slide launch speed as a multiple of sprint speed.");
			SlideDuration = c.Bind<float>("Movement", "SlideDuration", 0.8f, "How long a slide lasts, in seconds.");
			IncludeExplosives = c.Bind<bool>("Shop", "IncludeExplosives", true, "Include TNT and other explosives on the weapon wall.");
			RoundTimeLimit = c.Bind<float>("Round", "RoundTimeLimit", 240f, "Seconds per round. If nobody dies before it expires, the round resets and NOBODY scores. 0 = no limit.");
			BuyMenuKey = c.Bind<KeyCode>("Shop", "BuyMenuKey", (KeyCode)116, "Opens the buy panel during the pre-round buy window.");
			BuyMenuSlots = c.Bind<int>("Shop", "BuyMenuSlots", 10, "How many weapons appear in the buy panel (max 10, keys 1-9 and 0).");
			IncludeCigarette = c.Bind<bool>("Shop", "IncludeCigarette", true, "Sell a cigarette item if one is registered by another mod. (CigaretteMod does not add a purchasable item, so this usually finds nothing.)");
			BlockedWeapons = c.Bind<string>("Shop", "BlockedWeapons", "knuckle", "Comma-separated name fragments that are never sold. Case-insensitive.");
			ShowMenuButton = c.Bind<bool>("General", "ShowMenuButton", false, "Add the 1v1 button to the main menu. Off = use the hotkey only.");
			CountdownSound = c.Bind<bool>("Round", "CountdownSound", true, "Play a tick on each countdown number and a cue when the fight starts.");
			PlayMusic = c.Bind<bool>("Round", "PlayMusic", true, "Play the game's combat music while the duel is running.");
			MusicTrack = c.Bind<string>("Round", "MusicTrack", "BossFight1", "Music clip name. Known-good values: BossFight1, BossFightMini, MainMenu.");
			FogAmount = c.Bind<float>("Map", "FogAmount", 0.1f, "Fog strength, 0 = off, 0.10 = light haze. Restored on exit.");
			NoHunger = c.Bind<bool>("Round", "NoHunger", true, "Stop hunger draining while the duel is active.");
			EnabledMaps = c.Bind<string>("Map", "EnabledMaps", "", "Comma-separated list of maps in the rotation. Blank = all of them. HOST ONLY - a client's setting is overwritten by whatever the host picks. Known ids: " + Maps.IdList() + ".");
			FloodDelaySeconds = c.Bind<float>("Flood", "FloodDelaySeconds", 5f, "SKYLINE FLOODED: seconds of dry fighting before the water starts rising.");
			FloodRiseSeconds = c.Bind<float>("Flood", "FloodRiseSeconds", 10f, "SKYLINE FLOODED: base seconds the water takes to climb from the pit floor to deck level.");
			FloodWarnSeconds = c.Bind<float>("Flood", "FloodWarnSeconds", 5f, "SKYLINE FLOODED: how long before the flood the timer turns red, pulses and starts ticking.");
			FloodDamage = c.Bind<int>("Flood", "FloodDamage", 12, "SKYLINE FLOODED: damage taken every 0.5s while touching the water. 0 = harmless water.");
			FloodWaveHeight = c.Bind<float>("Flood", "FloodWaveHeight", 0.22f, "SKYLINE FLOODED: wave amplitude in metres. 0 = a flat surface.");
			FloodColor = c.Bind<Color>("Flood", "FloodColor", new Color(0.13f, 0.45f, 0.78f, 0.72f), "SKYLINE FLOODED: water colour. The alpha is how see-through it is.");
			FloodSounds = c.Bind<bool>("Flood", "FloodSounds", true, "SKYLINE FLOODED: play the countdown ticks, the flood alarm and the splashes.");
			FloodUnderwaterEffect = c.Bind<bool>("Flood", "FloodUnderwaterEffect", true, "SKYLINE FLOODED: apply the game's own underwater fog, screen overlay and muffled audio while you are in the water.");
			FloodEndsRound = c.Bind<bool>("Flood", "FloodEndsRound", false, "SKYLINE FLOODED: once the pit finishes rising (100%), end the round with no score - same as the RoundTimeLimit expiring. Off = the round just keeps running as before.");
			RotateMaps = c.Bind<bool>("Map", "RotateMaps", true, "Pick a random map each round (ARENA / SKYLINE). Off = always ARENA.");
			EnableLights = c.Bind<bool>("Map", "EnableLights", true, "Street lamps and arena lighting.");
			ClearInventoryEachRound = c.Bind<bool>("Round", "ClearInventoryEachRound", true, "Wipe every player's inventory at the start of each round, so nobody keeps last round's guns.");
			WeaponsPerSpawn = c.Bind<int>("Shop", "WeaponsPerSpawn", 0, "How many weapons to offer at each spawn. 0 = every weapon in the game.");
			IncludeMelee = c.Bind<bool>("Shop", "IncludeMelee", true, "Include melee weapons (knives, bats) alongside guns.");
			ShowWeaponLabels = c.Bind<bool>("Shop", "ShowWeaponLabels", true, "Float the weapon's name and price above each buy point.");
			ArenaSize = c.Bind<float>("Map", "ArenaSize", 60f, "Outer size of the arena floor in metres (square).");
			ArenaOrigin = c.Bind<Vector3>("Map", "ArenaOrigin", new Vector3(0f, 800f, 0f), "World position the arena is built at. High up so it never overlaps island geometry.");
			WallHeightMult = c.Bind<float>("Map", "WallHeightMult", 2.5f, "Outer wall height as a multiple of the player's measured max jump height (plus body height).");
			CountdownSeconds = c.Bind<int>("Round", "CountdownSeconds", 10, "Pre-round buy window in seconds. Players are frozen and can buy; the colour fade spans it.");
			StartMoney = c.Bind<int>("Round", "StartMoney", 99999, "Money the shared wallet is topped up to at the start of every round.");
			MinSpawnDistance = c.Bind<float>("Round", "MinSpawnDistance", 28f, "Minimum distance between the two chosen spawn points.");
			RecoilMultiplier = c.Bind<float>("Round", "RecoilMultiplier", 0.7f, "Scales gun recoil while a 1v1 round is running. 0.7 = 30% less recoil. 1 = vanilla. Applies to both the camera kick and the weapon-rig kick, and only inside 1v1.");
			PvpDamageMultiplier = c.Bind<float>("Round", "PvpDamageMultiplier", 1f, "Overrides the game's player-vs-player damage scale (vanilla is 0.25, i.e. quartered). 1 = full damage.");
			ScoreCap = c.Bind<int>("Round", "ScoreCap", 10, "First to this score wins: the match then auto-resets to 0-0 and restarts at round 1. 0 = no cap.");
			ClearWeaponsBetweenRounds = c.Bind<bool>("Round", "ClearWeaponsBetweenRounds", true, "Despawn weapons dropped on the arena floor at the start of each round.");
			AutoCleanThrownItems = c.Bind<bool>("Round", "AutoCleanThrownItems", true, "Automatically clean up and remove loose weapons and items on the arena floor when a round ends and switches.");
			try
			{
				if (CountdownSeconds != null && CountdownSeconds.Value == 3)
				{
					CountdownSeconds.Value = 10;
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("HTF1v1 config migration: " + ex.Message));
			}
			try
			{
				if (FloodDelaySeconds != null && FloodDelaySeconds.Value == 45f)
				{
					FloodDelaySeconds.Value = 5f;
				}
			}
			catch (Exception ex2)
			{
				Debug.LogWarning((object)("HTF1v1 config migration: " + ex2.Message));
			}
			try
			{
				if (FloodWarnSeconds != null && FloodWarnSeconds.Value == 10f)
				{
					FloodWarnSeconds.Value = 5f;
				}
			}
			catch (Exception ex3)
			{
				Debug.LogWarning((object)("HTF1v1 config migration: " + ex3.Message));
			}
			try
			{
				if (FloodEndsRound != null && FloodEndsRound.Value)
				{
					FloodEndsRound.Value = false;
				}
			}
			catch (Exception ex4)
			{
				Debug.LogWarning((object)("HTF1v1 config migration: " + ex4.Message));
			}
			try
			{
				if (FloodRiseSeconds != null && FloodRiseSeconds.Value >= 45f)
				{
					FloodRiseSeconds.Value = 10f;
				}
			}
			catch (Exception ex5)
			{
				Debug.LogWarning((object)("HTF1v1 config migration: " + ex5.Message));
			}
		}
	}
	internal static class Patches
	{
		private static readonly FieldInfo _warningGroupField = AccessTools.Field(typeof(IslandUI), "_warningGroup");

		private static readonly FieldInfo _deathFriendsHelpTextField = AccessTools.Field(typeof(DeathUI), "_friendsHelpText");

		public static void Apply(Harmony h)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Expected O, but got Unknown
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Expected O, but got Unknown
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Expected O, but got Unknown
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Expected O, but got Unknown
			//IL_038c: Expected O, but got Unknown
			Try(h, "Player.BlockInputs getter", AccessTools.PropertyGetter(typeof(Player), "BlockInputs"), null, new HarmonyMethod(typeof(Patches), "BlockInputs_Post", (Type[])null));
			Try(h, "Weapon.Shoot", AccessTools.Method(typeof(Weapon), "Shoot", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Patches), "Shoot_Pre", (Type[])null), null);
			Try(h, "PlayerEffects.UpdateEffects", AccessTools.Method(typeof(PlayerEffects), "UpdateEffects", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Patches), "UpdateEffects_Pre", (Type[])null), null);
			Try(h, "PlayerManager.OnPlayerDied", AccessTools.Method(typeof(PlayerManager), "OnPlayerDied", new Type[1] { typeof(Player) }, (Type[])null), null, new HarmonyMethod(typeof(Patches), "OnPlayerDied_Post", (Type[])null));
			Try(h, "Server.RpcLogic___HitPlayer___2449261505", AccessTools.Method(typeof(Server), "RpcLogic___HitPlayer___2449261505", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Patches), "HitPlayer_Pre", (Type[])null), null);
			Try(h, "PlayerCamera.Recoil", AccessTools.Method(typeof(PlayerCamera), "Recoil", new Type[1] { typeof(Vector2) }, (Type[])null), new HarmonyMethod(typeof(Patches), "Recoil_Pre", (Type[])null), null);
			Try(h, "PlayerToolMovement.Recoil", AccessTools.Method(typeof(PlayerToolMovement), "Recoil", new Type[1] { typeof(Vector2) }, (Type[])null), new HarmonyMethod(typeof(Patches), "Recoil_Pre", (Type[])null), null);
			Try(h, "PlayerUI.ToggleIslandWarning", AccessTools.Method(typeof(PlayerUI), "ToggleIslandWarning", new Type[1] { typeof(bool) }, (Type[])null), new HarmonyMethod(typeof(Patches), "ToggleIslandWarning_Pre", (Type[])null), null);
			Try(h, "IslandUI._islandUIToggleIslandWarning", AccessTools.Method(typeof(IslandUI), "_islandUIToggleIslandWarning", new Type[1] { typeof(bool) }, (Type[])null), new HarmonyMethod(typeof(Patches), "IslandUIToggleIslandWarning_Pre", (Type[])null), null);
			Try(h, "IslandWarning.OnTriggerExit", AccessTools.Method(typeof(IslandWarning), "OnTriggerExit", new Type[1] { typeof(Collider) }, (Type[])null), new HarmonyMethod(typeof(Patches), "IslandWarning_OnTriggerExit_Pre", (Type[])null), null);
			Try(h, "DazedUtils.AllPlayersNearbyCheck", AccessTools.Method(typeof(DazedUtils), "AllPlayersNearbyCheck", new Type[2]
			{
				typeof(Vector3),
				typeof(float)
			}, (Type[])null), new HarmonyMethod(typeof(Patches), "AllPlayersNearbyCheck_Pre", (Type[])null), null);
			Try(h, "DeathUI.ToggleDeathUI", AccessTools.Method(typeof(DeathUI), "ToggleDeathUI", new Type[1] { typeof(bool) }, (Type[])null), null, new HarmonyMethod(typeof(Patches), "DeathUI_ToggleDeathUI_Post", (Type[])null));
			Try(h, "SaveManager.SaveServer", AccessTools.Method(typeof(SaveManager), "SaveServer", new Type[1] { typeof(bool) }, (Type[])null), new HarmonyMethod(typeof(Patches), "SaveServer_Pre", (Type[])null), new HarmonyMethod(typeof(Patches), "SaveServer_Post", (Type[])null));
		}

		private static void Try(Harmony h, string label, MethodBase target, HarmonyMethod pre, HarmonyMethod post)
		{
			try
			{
				if (target == null)
				{
					Plugin.Warn("Patch target not found: " + label + " (skipped)");
					return;
				}
				h.Patch(target, pre, post, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				if (Cfg.VerboseLogging.Value)
				{
					Plugin.Log("Patched " + label);
				}
			}
			catch (Exception ex)
			{
				Plugin.Err("Failed to patch " + label + ": " + ex.Message);
			}
		}

		private static void BlockInputs_Post(ref bool __result)
		{
			try
			{
				if (Rounds.InputFrozen)
				{
					__result = true;
				}
			}
			catch
			{
			}
		}

		private static bool Shoot_Pre()
		{
			try
			{
				return !Rounds.InputFrozen;
			}
			catch
			{
				return true;
			}
		}

		private static bool UpdateEffects_Pre()
		{
			try
			{
				return !Rounds.OwnsSaturation;
			}
			catch
			{
				return true;
			}
		}

		private static void Move_Post(PlayerMovement __instance)
		{
			try
			{
				Slide.Apply(__instance);
			}
			catch
			{
			}
		}

		private static void UpdateMoveSpeed_Post(PlayerMovement __instance)
		{
			try
			{
				Slide.RaiseSpeedCap(__instance);
			}
			catch
			{
			}
		}

		private static bool LowerFullness_Pre()
		{
			try
			{
				return !Rounds.Active || !Cfg.NoHunger.Value;
			}
			catch
			{
				return true;
			}
		}

		private static void Recoil_Pre(ref Vector2 recoil)
		{
			//IL_0038: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Rounds.Active && Cfg.Enabled.Value)
				{
					float num = Cfg.RecoilMultiplier.Value;
					if (num < 0f)
					{
						num = 0f;
					}
					if (num != 1f)
					{
						recoil *= num;
					}
				}
			}
			catch
			{
			}
		}

		private static void OnPlayerDied_Post(Player player)
		{
			try
			{
				Rounds.OnDeath(player);
			}
			catch (Exception ex)
			{
				Plugin.Err("OnPlayerDied_Post: " + ex.Message);
			}
		}

		private static void HitPlayer_Pre(Player __0, Player __5)
		{
			try
			{
				Rounds.RecordAttacker(__0, __5);
			}
			catch
			{
			}
		}

		private static void ToggleIslandWarning_Pre(ref bool to)
		{
			try
			{
				if (Cfg.SuppressIslandWarning.Value || Rounds.Active)
				{
					to = false;
				}
			}
			catch
			{
			}
		}

		private static bool IslandUIToggleIslandWarning_Pre(IslandUI __instance, ref bool to)
		{
			try
			{
				if (Cfg.SuppressIslandWarning.Value || Rounds.Active)
				{
					to = false;
					if ((Object)(object)__instance != (Object)null && _warningGroupField != null)
					{
						object? value = _warningGroupField.GetValue(__instance);
						CanvasGroup val = (CanvasGroup)((value is CanvasGroup) ? value : null);
						if ((Object)(object)val != (Object)null)
						{
							try
							{
								Type type = AccessTools.TypeByName("LeanTween");
								if (type != null)
								{
									AccessTools.Method(type, "cancel", new Type[1] { typeof(GameObject) }, (Type[])null)?.Invoke(null, new object[1] { ((Component)val).gameObject });
								}
							}
							catch
							{
							}
							val.alpha = 0f;
							((Component)val).gameObject.SetActive(false);
						}
					}
					return false;
				}
			}
			catch
			{
			}
			return true;
		}

		private static bool IslandWarning_OnTriggerExit_Pre()
		{
			try
			{
				if (Cfg.SuppressIslandWarning.Value || Rounds.Active)
				{
					return false;
				}
			}
			catch
			{
			}
			return true;
		}

		private static bool AllPlayersNearbyCheck_Pre(ref bool __result)
		{
			try
			{
				if (Cfg.SuppressIslandWarning.Value || Rounds.Active)
				{
					__result = true;
					return false;
				}
			}
			catch
			{
			}
			return true;
		}

		private static void DeathUI_ToggleDeathUI_Post(DeathUI __instance)
		{
			try
			{
				if ((Cfg.SuppressIslandWarning.Value || Rounds.Active) && (Object)(object)__instance != (Object)null && _deathFriendsHelpTextField != null)
				{
					object? value = _deathFriendsHelpTextField.GetValue(__instance);
					GameObject val = (GameObject)((value is GameObject) ? value : null);
					if ((Object)(object)val != (Object)null)
					{
						val.SetActive(false);
					}
				}
			}
			catch
			{
			}
		}

		private static void SaveServer_Pre()
		{
			try
			{
				if (Rounds.Active && Rounds.SavedMoneyValid)
				{
					Rounds.ForceInstantMoney(Rounds.SavedMoney);
				}
			}
			catch
			{
			}
		}

		private static void SaveServer_Post()
		{
			try
			{
				if (Rounds.Active)
				{
					Rounds.TopUpMoney();
				}
			}
			catch
			{
			}
		}
	}
	[BepInPlugin("JacobSmear.htf1v1", "HTF 1v1", "1.2.10")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "JacobSmear.htf1v1";

		private static ManualLogSource _log;

		private Harmony _harmony;

		private bool _pendingEnter;

		private float _nextInjectTry;

		private GameObject _menuButton;

		public static void Log(string m)
		{
			if (_log != null)
			{
				_log.LogInfo((object)m);
			}
		}

		public static void Warn(string m)
		{
			if (_log != null)
			{
				_log.LogWarning((object)m);
			}
		}

		public static void Err(string m)
		{
			if (_log != null)
			{
				_log.LogError((object)m);
			}
		}

		private void Awake()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			_log = ((BaseUnityPlugin)this).Logger;
			try
			{
				try
				{
					Cfg.Bind(((BaseUnityPlugin)this).Config);
				}
				catch (Exception ex)
				{
					Err("Config binding failed, continuing with defaults: " + ex);
				}
				if (Cfg.Enabled == null)
				{
					Err("Config unavailable - HTF 1v1 cannot start.");
					return;
				}
				if (!Cfg.Enabled.Value)
				{
					Log("HTF 1v1 is disabled in config.");
					return;
				}
				_harmony = new Harmony("JacobSmear.htf1v1");
				Patches.Apply(_harmony);
				Net.Init();
				IslandManager.OnFirstIslandLoaded += OnIslandReady;
				SceneManager.sceneLoaded += OnSceneLoaded;
				Log("HTF 1v1 v1.2.3 loaded. Hotkey: " + ((object)Cfg.ToggleKey.Value/*cast due to .constrained prefix*/).ToString() + " | ScoreCap=" + Cfg.ScoreCap.Value + " | Countdown=" + Cfg.CountdownSeconds.Value + "s");
			}
			catch (Exception ex2)
			{
				Err("Awake failed: " + ex2);
			}
		}

		private void OnDestroy()
		{
			try
			{
				IslandManager.OnFirstIslandLoaded -= OnIslandReady;
				SceneManager.sceneLoaded -= OnSceneLoaded;
				if (Rounds.Active)
				{
					Rounds.Exit();
				}
				Net.Shutdown();
				if (_harmony != null)
				{
					_harmony.UnpatchSelf();
				}
			}
			catch (Exception ex)
			{
				Err("OnDestroy: " + ex);
			}
		}

		private void OnSceneLoaded(Scene s, LoadSceneMode mode)
		{
			_nextInjectTry = 0f;
		}

		private void OnIslandReady()
		{
			try
			{
				if (_pendingEnter)
				{
					_pendingEnter = false;
					((MonoBehaviour)this).StartCoroutine(EnterAfterDelay());
				}
			}
			catch (Exception ex)
			{
				Err("OnIslandReady: " + ex);
			}
		}

		private IEnumerator EnterAfterDelay()
		{
			yield return (object)new WaitForSeconds(1.5f);
			for (int i = 0; i < 40; i++)
			{
				if (!((Object)(object)Player.LocalPlayer == (Object)null))
				{
					break;
				}
				yield return (object)new WaitForSeconds(0.25f);
			}
			Rounds.Enter();
		}

		private void Update()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			if (Cfg.Enabled == null)
			{
				return;
			}
			try
			{
				if (!Cfg.Enabled.Value)
				{
					if (Rounds.Active)
					{
						Rounds.Exit();
					}
					return;
				}
				Net.Tick();
				Rounds.Tick();
				Slide.Tick();
				BuyMenu.Tick();
				if (Input.GetKeyDown(Cfg.ToggleKey.Value))
				{
					Toggle();
				}
				if (Cfg.ShowMenuButton.Value && (Object)(object)_menuButton == (Object)null && Time.unscaledTime >= _nextInjectTry)
				{
					_nextInjectTry = Time.unscaledTime + 2f;
					TryInjectMenuButton();
				}
			}
			catch (Exception ex)
			{
				Err("Update: " + ex);
			}
		}

		private void Toggle()
		{
			try
			{
				if (Rounds.Active)
				{
					Rounds.Exit();
				}
				else if ((Object)(object)Island.CurIsland == (Object)null)
				{
					_pendingEnter = true;
					Warn("1v1 armed - no world is loaded yet. Start or join a game and it will activate automatically.");
				}
				else
				{
					Rounds.Enter();
				}
			}
			catch (Exception ex)
			{
				Err("Toggle: " + ex);
			}
		}

		private void TryInjectMenuButton()
		{
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			try
			{
				CanvasManager val = Object.FindFirstObjectByType<CanvasManager>();
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				List<GameObject> field = Util.GetField<List<GameObject>>(val, "_allMainMenuButtons");
				if (field == null || field.Count == 0 || (Object)(object)field[0] == (Object)null)
				{
					return;
				}
				Button val2 = ((IEnumerable<Button>)field[0].GetComponentsInChildren<Button>(true)).FirstOrDefault((Func<Button, bool>)((Button b) => (Object)(object)b != (Object)null));
				if ((Object)(object)val2 == (Object)null)
				{
					return;
				}
				GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, ((Component)val2).transform.parent);
				((Object)val3).name = "HTF1v1_Button";
				val3.transform.SetSiblingIndex(((Component)val2).transform.GetSiblingIndex() + 1);
				val3.SetActive(true);
				Button component = val3.GetComponent<Button>();
				if ((Object)(object)component != (Object)null)
				{
					for (int num = 0; num < ((UnityEventBase)component.onClick).GetPersistentEventCount(); num++)
					{
						((UnityEventBase)component.onClick).SetPersistentListenerState(num, (UnityEventCallState)0);
					}
					((UnityEventBase)component.onClick).RemoveAllListeners();
					((UnityEvent)component.onClick).AddListener(new UnityAction(OnMenuButtonClicked));
					((Selectable)component).interactable = true;
				}
				Component[] components = val3.GetComponents<Component>();
				foreach (Component val4 in components)
				{
					if (!((Object)(object)val4 == (Object)null) && ((object)val4).GetType().Name == "UIButton")
					{
						Util.SetField(val4, "_selectOnShow", false);
					}
				}
				components = val3.GetComponentsInChildren<Component>(true);
				foreach (Component val5 in components)
				{
					if (!((Object)(object)val5 == (Object)null) && ((object)val5).GetType().Name.IndexOf("Localize", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						Object.Destroy((Object)(object)val5);
					}
				}
				TextMeshProUGUI[] componentsInChildren = val3.GetComponentsInChildren<TextMeshProUGUI>(true);
				for (int num2 = 0; num2 < componentsInChildren.Length; num2++)
				{
					((TMP_Text)componentsInChildren[num2]).text = "1v1";
				}
				Text[] componentsInChildren2 = val3.GetComponentsInChildren<Text>(true);
				for (int num2 = 0; num2 < componentsInChildren2.Length; num2++)
				{
					componentsInChildren2[num2].text = "1v1";
				}
				_menuButton = val3;
				Log("Injected '1v1' button into the main menu (cloned from '" + ((Object)val2).name + "').");
			}
			catch (Exception ex)
			{
				Warn("Menu button injection failed: " + ex.Message);
			}
		}

		private void OnMenuButtonClicked()
		{
			try
			{
				Log("'1v1' clicked.");
				Toggle();
			}
			catch (Exception ex)
			{
				Err("OnMenuButtonClicked: " + ex);
			}
		}
	}
	internal static class Util
	{
		private const BindingFlags PRIV = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		public static FieldInfo Field(Type t, string name)
		{
			Type type = t;
			while (type != null)
			{
				FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					return field;
				}
				type = type.BaseType;
			}
			return null;
		}

		public static T GetField<T>(object o, string name, T fallback = default(T))
		{
			try
			{
				if (o == null)
				{
					return fallback;
				}
				FieldInfo fieldInfo = Field(o.GetType(), name);
				if (fieldInfo == null)
				{
					return fallback;
				}
				object value = fieldInfo.GetValue(o);
				return (value is T) ? ((T)value) : fallback;
			}
			catch
			{
				return fallback;
			}
		}

		public static bool SetField(object o, string name, object value)
		{
			try
			{
				if (o == null)
				{
					return false;
				}
				FieldInfo fieldInfo = Field(o.GetType(), name);
				if (fieldInfo == null)
				{
					return false;
				}
				fieldInfo.SetValue(o, value);
				return true;
			}
			catch
			{
				return false;
			}
		}

		public static int LayerFromMask(LayerMask mask, int fallback = 0)
		{
			int value = ((LayerMask)(ref mask)).value;
			if (value == 0)
			{
				return fallback;
			}
			for (int i = 0; i < 32; i++)
			{
				if ((value & (1 << i)) != 0)
				{
					return i;
				}
			}
			return fallback;
		}

		public static bool MaskContains(LayerMask mask, int layer)
		{
			return (((LayerMask)(ref mask)).value & (1 << layer)) != 0;
		}

		public static void SetLayerRecursive(GameObject go, int layer)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			go.layer = layer;
			foreach (Transform item in go.transform)
			{
				SetLayerRecursive(((Component)item).gameObject, layer);
			}
		}
	}
	internal class Arena
	{
		public GameObject Root;

		public Palette Pal;

		public Metrics M;

		public MapKind Kind;

		public readonly List<Vector3> Spawns = new List<Vector3>();

		public readonly List<float> Openness = new List<float>();

		public Vector3 Origin;

		public float Size;

		public float WallHeight;

		public float TunnelClearance;

		public float PitHalf;

		public float PitFloorY;

		public float DeckY;

		private int _levelLayer;

		private int _lights;

		public const float ClearanceProbe = 8f;

		public bool Built => (Object)(object)Root != (Object)null;

		public static string NameOf(MapKind k)
		{
			return Maps.DisplayName(k);
		}

		public static Arena Build(Metrics m, MapKind kind)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00cf: 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)
			Arena arena = new Arena();
			arena.M = m;
			arena.Kind = kind;
			arena.Origin = Cfg.ArenaOrigin.Value;
			arena.Size = Mathf.Max(24f, Cfg.ArenaSize.Value);
			arena.WallHeight = m.CapsuleHeight + Mathf.Max(1f, m.JumpHeight) * Mathf.Max(1f, Cfg.WallHeightMult.Value);
			arena.TunnelClearance = Mathf.Max(2.2f, m.CapsuleHeight * 1.6f);
			arena._levelLayer = Util.LayerFromMask(GameInfo.LevelLayer);
			arena.Pal = Palette.Build();
			arena.Root = new GameObject("HTF1v1_Arena_" + NameOf(kind));
			arena.Root.transform.position = arena.Origin;
			try
			{
				if (Maps.LayoutOf(kind) == MapKind.Skyscraper)
				{
					SkyscraperGrid grid = SkyscraperGen.GenerateGrid();
					SkyscraperGen.Instantiate3D(arena, grid, FloorTheme.ExecutiveSuite);
					string filePath = Path.Combine(Directory.GetCurrentDirectory(), "skyscraper_base.txt");
					arena.ExportLayoutText(filePath);
					string filePath2 = Path.Combine(Directory.GetCurrentDirectory(), "skyscraper_mod.txt");
					arena.LoadLayoutText(filePath2);
				}
				else
				{
					arena.BuildShell();
					switch (Maps.LayoutOf(kind))
					{
					case MapKind.Skyline:
						arena.BuildSkyline();
						break;
					case MapKind.Warehouse:
						arena.BuildWarehouse();
						break;
					case MapKind.Facility:
						arena.BuildFacility();
						break;
					default:
						arena.BuildArena();
						break;
					}
				}
				Physics.SyncTransforms();
				arena.BuildSpawns();
			}
			catch (Exception ex)
			{
				Plugin.Err("Arena.Build failed: " + ex);
				arena.Destroy();
				return null;
			}
			Plugin.Log($"Map '{NameOf(kind)}' built at {arena.Origin} | size={arena.Size:0}m walls={arena.WallHeight:0.0}m | {arena.Spawns.Count} spawns | {arena._lights} lights | shader={arena.Pal.ShaderName}");
			arena.WarnAboutLayers();
			return arena;
		}

		private void WarnAboutLayers()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string text = LayerMask.LayerToName(_levelLayer);
				if (!Util.MaskContains(GameInfo.CanJumpOnLayers, _levelLayer))
				{
					Plugin.Warn("Arena layer '" + text + "' is not in GameInfo.CanJumpOnLayers - jumping off arena surfaces may fail.");
				}
				if (!Util.MaskContains(GameInfo.ProjectileHitLayer, _levelLayer))
				{
					Plugin.Warn("Arena layer '" + text + "' is not in GameInfo.ProjectileHitLayer - bullets may pass through walls.");
				}
			}
			catch
			{
			}
		}

		public void ExportLayoutText(string filePath)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0072: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("# Skyscraper Procedural Layout Dump");
			foreach (Transform item in Root.transform)
			{
				Transform val = item;
				if (!((Object)(object)((Component)val).GetComponent<MeshRenderer>() == (Object)null))
				{
					CultureInfo invariantCulture = CultureInfo.InvariantCulture;
					object[] obj = new object[10]
					{
						((Object)val).name.Replace(" ", "_"),
						val.localPosition.x,
						val.localPosition.y,
						val.localPosition.z,
						null,
						null,
						null,
						null,
						null,
						null
					};
					Quaternion localRotation = val.localRotation;
					obj[4] = ((Quaternion)(ref localRotation)).eulerAngles.x;
					localRotation = val.localRotation;
					obj[5] = ((Quaternion)(ref localRotation)).eulerAngles.y;
					localRotation = val.localRotation;
					obj[6] = ((Quaternion)(ref localRotation)).eulerAngles.z;
					obj[7] = val.localScale.x;
					obj[8] = val.localScale.y;
					obj[9] = val.localScale.z;
					stringBuilder.AppendLine(string.Format(invariantCulture, "{0} {1:F4} {2:F4} {3:F4} {4:F4} {5:F4} {6:F4} {7:F4} {8:F4} {9:F4}", obj));
				}
			}
			try
			{
				File.WriteAllText(filePath, stringBuilder.ToString());
			}
			catch
			{
			}
			Plugin.Log("Exported base layout to " + filePath);
		}

		public void LoadLayoutText(string filePath)
		{
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			if (!File.Exists(filePath))
			{
				return;
			}
			string[] array = File.ReadAllLines(filePath);
			HashSet<string> hashSet = new HashSet<string>();
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			string[] array2 = array;
			foreach (string text in array2)
			{
				if (string.IsNullOrWhiteSpace(text) || text.StartsWith("#"))
				{
					continue;
				}
				string[] array3 = text.Split(' ', StringSplitOptions.RemoveEmptyEntries);
				if (array3.Length >= 10)
				{
					string text2 = array3[0].Replace("_", " ");
					hashSet.Add(array3[0]);
					Transform val = Root.transform.Find(array3[0]) ?? Root.transform.Find(text2);
					if ((Object)(object)val != (Object)null)
					{
						val.localPosition = new Vector3(float.Parse(array3[1], invariantCulture), float.Parse(array3[2], invariantCulture), float.Parse(array3[3], invariantCulture));
						val.localRotation = Quaternion.Euler(float.Parse(array3[4], invariantCulture), float.Parse(array3[5], invariantCulture), float.Parse(array3[6], invariantCulture));
						val.localScale = new Vector3(float.Parse(array3[7], invariantCulture), float.Parse(array3[8], invariantCulture), float.Parse(array3[9], invariantCulture));
					}
				}
			}
			List<GameObject> list = new List<GameObject>();
			foreach (Transform item in Root.transform)
			{
				Transform val2 = item;
				if ((Object)(object)((Component)val2).GetComponent<MeshRenderer>() != (Object)null && !hashSet.Contains(((Object)val2).name.Replace(" ", "_")))
				{
					list.Add(((Component)val2).gameObject);
				}
			}
			foreach (GameObject item2 in list)
			{
				Object.Destroy((Object)(object)item2);
			}
			Plugin.Log($"Loaded custom layout from {filePath}. Overrode {hashSet.Count} objects, deleted {list.Count}.");
		}

		internal GameObject Box(string name, Vector3 centre, Vector3 size, Material template, bool visible = true)
		{
			//IL_002b: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = name;
			val.transform.SetParent(Root.transform, false);
			val.transform.localPosition = centre;
			val.transform.localScale = size;
			val.layer = _levelLayer;
			Renderer component = val.GetComponent<Renderer>();
			if (!visible)
			{
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
			}
			else if ((Object)(object)component != (Object)null && (Object)(object)template != (Object)null)
			{
				Material val2 = Pal.Instance(template);
				Palette.SetTiling(val2, size);
				component.sharedMaterial = val2;
			}
			if ((Object)(object)val.GetComponent<BoxCollider>() == (Object)null)
			{
				val.AddComponent<BoxCollider>();
			}
			return val;
		}

		internal GameObject VisualBox(string name, Vector3 centre, Vector3 size, Material template)
		{
			//IL_002a: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)obj).name = name;
			obj.transform.SetParent(Root.transform, false);
			obj.transform.localPosition = centre;
			obj.transform.localScale = size;
			BoxCollider component = obj.GetComponent<BoxCollider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			Renderer component2 = obj.GetComponent<Renderer>();
			if ((Object)(object)component2 != (Object)null && (Object)(object)template != (Object)null)
			{
				Material val = Pal.Instance(template);
				Palette.SetTiling(val, size);
				component2.sharedMaterial = val;
			}
			return obj;
		}

		private GameObject Ramp(string name, Vector3 centre, float run, float rise, float width, float yawDeg, Material mat)
		{
			//IL_0020: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Sqrt(run * run + rise * rise);
			float num2 = Mathf.Atan2(rise, run) * 57.29578f;
			GameObject obj = Box(name, centre, new Vector3(num, 0.5f, width), mat);
			obj.transform.localRotation = Quaternion.Euler(0f, yawDeg, 0f - num2);
			return obj;
		}

		private void Lamp(string name, Vector3 baseLocal, float height)
		{
			//IL_000c: 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)
			//IL_0033: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_00b5: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			Box(name + "_Pole", baseLocal + new Vector3(0f, height * 0.5f, 0f), new Vector3(0.22f, height, 0.22f), Pal.Metal);
			Box(name + "_Head", baseLocal + new Vector3(0f, height + 0.12f, 0f), new Vector3(0.8f, 0.25f, 0.8f), Pal.Lamp);
			if (Cfg.EnableLights.Value)
			{
				GameObject val = new GameObject(name + "_Light");
				val.transform.SetParent(Root.transform, false);
				val.transform.localPosition = baseLocal + new Vector3(0f, height - 0.15f, 0f);
				Light obj = val.AddComponent<Light>();
				obj.type = (LightType)2;
				obj.color = new Color(1f, 0.87f, 0.68f);
				obj.intensity = 3.2f;
				obj.range = Mathf.Max(14f, height * 4.5f);
				obj.shadows = (LightShadows)0;
				_lights++;
			}
		}

		internal void FillLight(Vector3 local, float range, float intensity, Color c)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (Cfg.EnableLights.Value)
			{
				GameObject val = new GameObject("Fill_Light");
				val.transform.SetParent(Root.transform, false);
				val.transform.localPosition = local;
				Light obj = val.AddComponent<Light>();
				obj.type = (LightType)2;
				obj.color = c;
				obj.intensity = intensity;
				obj.range = range;
				obj.shadows = (LightShadows)0;
				_lights++;
			}
		}

		private void CrateStack(string name, Vector3 centre, float c)
		{
			//IL_000c: 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)
			//IL_002b: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			Box(name + "_1", centre + new Vector3(0f, c * 0.5f, 0f), new Vector3(c, c, c), Pal.Cover);
			Box(name + "_2", centre + new Vector3(c * 1.02f, c * 0.5f, 0f), new Vector3(c, c, c), Pal.Cover);
			Box(name + "_3", centre + new Vector3(c * 0.5f, c * 1.5f, 0f), new Vector3(c, c, c), Pal.Cover);
			Box(name + "_4", centre + new Vector3(0f, c * 0.5f, c * 1.02f), new Vector3(c, c, c), Pal.Cover);
		}

		private void BuildShell()
		{
			//IL_0031: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			float size = Size;
			float num = size * 0.5f;
			float num2 = 1f;
			float wallHeight = WallHeight;
			Box("Floor", new Vector3(0f, -0.5f, 0f), new Vector3(size, 1f, size), Pal.Floor);
			Box("Wall_N", new Vector3(0f, wallHeight * 0.5f, num + num2 * 0.5f), new Vector3(size + num2 * 2f, wallHeight, num2), Pal.Wall);
			Box("Wall_S", new Vector3(0f, wallHeight * 0.5f, 0f - num - num2 * 0.5f), new Vector3(size + num2 * 2f, wallHeight, num2), Pal.Wall);
			Box("Wall_E", new Vector3(num + num2 * 0.5f, wallHeight * 0.5f, 0f), new Vector3(num2, wallHeight, size + num2 * 2f), Pal.Wall);
			Box("Wall_W", new Vector3(0f - num - num2 * 0.5f, wallHeight * 0.5f, 0f), new Vector3(num2, wallHeight, size + num2 * 2f), Pal.Wall);
			float num3 = wallHeight + Mathf.Max(30f, Size * 0.5f);
			Box("Bounds_Ceiling", new Vector3(0f, num3, 0f), new Vector3(size + num2 * 2f, 1f, size + num2 * 2f), null, visible: false);
			Box("Bounds_Under", new Vector3(0f, -4f, 0f), new Vector3(size + num2 * 2f, 1f, size + num2 * 2f), null, visible: false);
		}

		private void BuildArena()
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			float size = Size;
			float num = size * 0.5f;
			float capsuleHeight = M.CapsuleHeight;
			float tunnelClearance = TunnelClearance;
			float num2 = Mathf.Max(2.5f, M.CapsuleRadius * 6f);
			float num3 = size * 0.4f;
			float num4 = 0.5f;
			float num5 = num2 * 0.5f + num4 * 0.5f;
			Box("Tunnel_Side_N", new Vector3(0f, tunnelClearance * 0.5f, num5), new Vector3(num3, tunnelClearance, num4), Pal.Tunnel);
			Box("Tunnel_Side_S", new Vector3(0f, tunnelClearance * 0.5f, 0f - num5), new Vector3(num3, tunnelClearance, num4), Pal.Tunnel);
			Box("Tunnel_Roof", new Vector3(0f, tunnelClearance + 0.25f, 0f), new Vector3(num3, 0.5f, num2 + num4 * 2f), Pal.Tunnel);
			float num6 = size * 0.28f;
			float num7 = Mathf.Max(1.8f, capsuleHeight * 1.15f);
			Box("Cover_NE", new Vector3(num6, num7 * 0.5f, num6), new Vector3(size * 0.13f, num7, size * 0.06f), Pal.Cover);
			Box("Cover_SW", new Vector3(0f - num6, num7 * 0.5f, 0f - num6), new Vector3(size * 0.13f, num7, size * 0.06f), Pal.Cover);
			Box("Cover_NW", new Vector3(0f - num6, num7 * 0.5f, num6), new Vector3(size * 0.06f, num7, size * 0.13f), Pal.Cover);
			Box("Cover_SE", new Vector3(num6, num7 * 0.5f, 0f - num6), new Vector3(size * 0.06f, num7, size * 0.13f), Pal.Cover);
			float num8 = Mathf.Max(1f, capsuleHeight * 0.62f);
			float num9 = num3 * 0.5f + size * 0.09f;
			Box("Cover_TunnelE", new Vector3(num9, num8 * 0.5f, 0f), new Vector3(size * 0.05f, num8, size * 0.16f), Pal.Cover);
			Box("Cover_TunnelW", new Vector3(0f - num9, num8 * 0.5f, 0f), new Vector3(size * 0.05f, num8, size * 0.16f), Pal.Cover);
			float num10 = size * 0.34f;
			Box("Pillar_N", new Vector3(0f, num7 * 0.675f, num10), new Vector3(size * 0.045f, num7 * 1.35f, size * 0.045f), Pal.Cover);
			Box("Pillar_S", new Vector3(0f, num7 * 0.675f, 0f - num10), new Vector3(size * 0.045f, num7 * 1.35f, size * 0.045f), Pal.Cover);
			float num11 = Mathf.Clamp(M.JumpHeight * 1.5f, 1.6f, WallHeight * 0.45f);
			float num12 = size * 0.24f;
			float num13 = size * 0.15f;
			float num14 = num - num13 * 0.5f - 0.6f;
			Box("Platform_E", new Vector3(num14, num11 * 0.5f, 0f), new Vector3(num13, num11, num12), Pal.Platform);
			Box("Platform_W", new Vector3(0f - num14, num11 * 0.5f, 0f), new Vector3(num13, num11, num12), Pal.Platform);
			float num15 = num11 / Mathf.Tan(MathF.PI * 2f / 15f);
			float width = Mathf.Max(2.6f, M.CapsuleRadius * 7f);
			Ramp("Ramp_E", new Vector3(num14 - num13 * 0.5f - num15 * 0.5f, num11 * 0.5f, num12 * 0.25f), num15, num11, width, 180f, Pal.Platform);
			Ramp("Ramp_W", new Vector3(0f - num14 + num13 * 0.5f + num15 * 0.5f, num11 * 0.5f, (0f - num12) * 0.25f), num15, num11, width, 0f, Pal.Platform);
			float num16 = size * 0.42f;
			Box("Alcove_NE", new Vector3(num16, num7 * 0.5f, num16 * 0.55f), new Vector3(size * 0.03f, num7, size * 0.14f), Pal.Wall);
			Box("Alcove_SW", new Vector3(0f - num16, num7 * 0.5f, (0f - num16) * 0.55f), new Vector3(size * 0.03f, num7, size * 0.14f), Pal.Wall);
			Box("Alcove_NW", new Vector3((0f - num16) * 0.55f, num7 * 0.5f, num16), new Vector3(size * 0.14f, num7, size * 0.03f), Pal.Wall);
			Box("Alcove_SE", new Vector3(num16 * 0.55f, num7 * 0.5f, 0f - num16), new Vector3(size * 0.14f, num7, size * 0.03f), Pal.Wall);
			float height = Mathf.Max(4.5f, capsuleHeight * 2.6f);
			float num17 = size * 0.32f;
			float num18 = size * 0.26f;
			Lamp("Lamp_NE", new Vector3(num18, 0f, num17), height);
			Lamp("Lamp_NW", new Vector3(0f - num18, 0f, num17), height);
			Lamp("Lamp_SE", new Vector3(num18, 0f, 0f - num17), height);
			Lamp("Lamp_SW", new Vector3(0f - num18, 0f, 0f - num17), height);
			FillLight(new Vector3(0f, tunnelClearance + 8f, 0f), size * 0.9f, 2.2f, new Color(0.85f, 0.92f, 1f));
		}

		private void BuildSkyline()
		{
			//IL_009b: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0635: Unknown result type (might be due to invalid IL or missing references)
			//IL_065d: Unknown result type (might be due to invalid IL or missing references)
			//IL_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0725: Unknown result type (might be due to invalid IL or missing references)
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_0762: Unknown result type (might be due to invalid IL or missing references)
			float size = Size;
			float capsuleHeight = M.CapsuleHeight;
			float num = Mathf.Clamp(M.JumpHeight * 2.2f, 2.6f, WallHeight * 0.42f);
			float num2 = size * 0.26f;
			float num3 = size - num2 * 2f;
			float num4 = num3 * 0.5f;
			float num5 = capsuleHeight * 0.45f;
			PitHalf = num4;
			PitFloorY = 0f;
			DeckY = num;
			float num6 = num4 + num2 * 0.5f;
			Box("Deck_N", new Vector3(0f, num * 0.5f, num6), new Vector3(size, num, num2), Pal.Platform);
			Box("Deck_S", new Vector3(0f, num * 0.5f, 0f - num6), new Vector3(size, num, num2), Pal.Platform);
			Box("Deck_E", new Vector3(num6, num * 0.5f, 0f), new Vector3(num2, num, num3), Pal.Platform);
			Box("Deck_W", new Vector3(0f - num6, num * 0.5f, 0f), new Vector3(num2, num, num3), Pal.Platform);
			Box("Rail_N", new Vector3(0f, num + num5 * 0.5f, num4), new Vector3(num3, num5, 0.25f), Pal.Metal);
			Box("Rail_S", new Vector3(0f, num + num5 * 0.5f, 0f - num4), new Vector3(num3, num5, 0.25f), Pal.Metal);
			Box("Rail_E", new Vector3(num4, num + num5 * 0.5f, 0f), new Vector3(0.25f, num5, num3), Pal.Metal);
			Box("Rail_W", new Vector3(0f - num4, num + num5 * 0.5f, 0f), new Vector3(0.25f, num5, num3), Pal.Metal);
			float num7 = num / Mathf.Tan(0.43633232f);
			float width = Mathf.Max(3f, M.CapsuleRadius * 8f);
			float num8 = num3 * 0.24f;
			Ramp("Ramp_N", new Vector3(num8, num * 0.5f, num4 - num7 * 0.5f), num7, num, width, 90f, Pal.Platform);
			Ramp("Ramp_S", new Vector3(0f - num8, num * 0.5f, 0f - num4 + num7 * 0.5f), num7, num, width, 270f, Pal.Platform);
			Ramp("Ramp_E", new Vector3(num4 - num7 * 0.5f, num * 0.5f, 0f - num8), num7, num, width, 0f, Pal.Platform);
			Ramp("Ramp_W", new Vector3(0f - num4 + num7 * 0.5f, num * 0.5f, num8), num7, num, width, 180f, Pal.Platform);
			float num9 = Mathf.Max(2.6f, M.CapsuleRadius * 7f);
			Box("Bridge_EW", new Vector3(0f, num, 0f), new Vector3(num3, 0.45f, num9), Pal.Metal);
			Box("Bridge_Cover_A", new Vector3((0f - num3) * 0.16f, num + 0.22f + capsuleHeight * 0.32f, 0f), new Vector3(0.6f, capsuleHeight * 0.64f, num9), Pal.Cover);
			Box("Bridge_Cover_B", new Vector3(num3 * 0.16f, num + 0.22f + capsuleHeight * 0.32f, 0f), new Vector3(0.6f, capsuleHeight * 0.64f, num9), Pal.Cover);
			float size2 = size * 0.1f;
			float height = capsuleHeight * 2.4f;
			float num10 = num4 + num2 * 0.55f;
			BuildSkylineTower("Tower_NE", new Vector3(num10, num, num10), size2, height, num, num5);
			BuildSkylineTower("Tower_SW", new Vector3(0f - num10, num, 0f - num10), size2, height, num, num5);
			float c = Mathf.Max(1.1f, capsuleHeight * 0.62f);
			CrateStack("Pit_Crates_A", new Vector3(num3 * 0.24f, 0f, num3 * 0.22f), c);
			CrateStack("Pit_Crates_B", new Vector3((0f - num3) * 0.24f, 0f, (0f - num3) * 0.22f), c);
			float num11 = Mathf.Max(1f, capsuleHeight * 0.62f);
			Box("Pit_Wall_A", new Vector3((0f - num3) * 0.22f, num11 * 0.5f, num3 * 0.2f), new Vector3(num3 * 0.3f, num11, 0.6f), Pal.Cover);
			Box("Pit_Wall_B", new Vector3(num3 * 0.22f, num11 * 0.5f, (0f - num3) * 0.2f), new Vector3(num3 * 0.3f, num11, 0.6f), Pal.Cover);
			float num12 = num4 + num2 * 0.5f;
			Box("Deck_Cover_N", new Vector3((0f - size) * 0.22f, num + num11 * 0.5f, num12), new Vector3(size * 0.12f, num11, 0.6f), Pal.Cover);
			Box("Deck_Cover_S", new Vector3(size * 0.22f, num + num11 * 0.5f, 0f - num12), new Vector3(size * 0.12f, num11, 0.6f), Pal.Cover);
			CrateStack("Deck_Crates_E", new Vector3(num12, num, (0f - size) * 0.2f), c);
			CrateStack("Deck_Crates_W", new Vector3(0f - num12, num, size * 0.2f), c);
			float height2 = Mathf.Max(4.5f, capsuleHeight * 2.6f);
			Lamp("Lamp_N", new Vector3(0f - num8, num, num6), height2);
			Lamp("Lamp_S", new Vector3(num8, num, 0f - num6), height2);
			Lamp("Lamp_E", new Vector3(num6, num, num8), height2);
			Lamp("Lamp_W", new Vector3(0f - num6, num, 0f - num8), height2);
			FillLight(new Vector3(0f, num + 10f, 0f), size, 2.4f, new Color(0.82f, 0.9f, 1f));
			FillLight(new Vector3(0f, capsuleHeight * 1.2f, 0f), num3 * 0.9f, 1.6f, new Color(1f, 0.95f, 0.85f));
		}

		private void BuildSkylineTower(string name, Vector3 baseLocal, float size, float height, float deckH, float railH)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0068: 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_00a3: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			Box(name + "_Body", baseLocal + new Vector3(0f, height * 0.5f, 0f), new Vector3(size, height, size), Pal.Wall);
			Box(name + "_Cap", baseLocal + new Vector3(0f, height + 0.25f, 0f), new Vector3(size * 1.2f, 0.5f, size * 1.2f), Pal.Platform);
			Box(name + "_Rail", baseLocal + new Vector3(0f, height + 0.5f + railH * 0.5f, size * 0.55f), new Vector3(size * 1.2f, railH, 0.2f), Pal.Metal);
			float num = height / Mathf.Tan(MathF.PI / 6f);
			float width = Mathf.Max(2.6f, M.CapsuleRadius * 7f);
			float num2 = 0f - Mathf.Sign(baseLocal.x);
			Ramp(name + "_Ramp", baseLocal + new Vector3(num2 * (size * 0.5f + num * 0.5f), height * 0.5f, 0f), num, height, width, (num2 > 0f) ? 0f : 180f, Pal.Platform);
		}

		private void BuildWarehouse()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: 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_0223: 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_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0521: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: 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_0578: 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_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06be: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_076e: Unknown result type (might be due to invalid IL or missing references)
			//IL_078c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0817: Unknown result type (might be due to invalid IL or missing references)
			//IL_082d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0877: Unknown result type (might be due to invalid IL or missing references)
			//IL_088b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0910: Unknown result type (might be due to invalid IL or missing references)
			//IL_092f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0945: Unknown result type (might be due to invalid IL or missing references)
			//IL_0966: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b04: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b15: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b64: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c63: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c77: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cdf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d5e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e87: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ec6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f04: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f82: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fc2: Unknown result type (might be due to invalid IL or missing references)
			//IL_1022: Unknown result type (might be due to invalid IL or missing references)
			//IL_1030: Unknown result type (might be due to invalid IL or missing references)
			//IL_1058: Unknown result type (might be due to invalid IL or missing references)
			//IL_1072: Unknown result type (might be due to invalid IL or missing references)
			//IL_10ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_10ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_10f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1105: Unknown result type (might be due to invalid IL or missing references)
			//IL_115f: Unknown result type (might be due to invalid IL or missing references)
			//IL_116a: Unknown result type (might be due to invalid IL or missing references)
			//IL_11a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_11af: Unknown result type (might be due to invalid IL or missing references)
			//IL_122e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1239: Unknown result type (might be due to invalid IL or missing references)
			//IL_1271: Unknown result type (might be due to invalid IL or missing references)
			//IL_1282: Unknown result type (might be due to invalid IL or missing references)
			//IL_12b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_12d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1329: Unknown result type (might be due to invalid IL or missing references)
			//IL_133d: Unknown result type (might be due to invalid IL or missing references)
			//IL_136f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1383: Unknown result type (might be due to invalid IL or missing references)
			//IL_13ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_13bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_13e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_13fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_1423: Unknown result type (might be due to invalid IL or missing references)
			//IL_1437: Unknown result type (might be due to invalid IL or missing references)
			//IL_145f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1473: Unknown result type (might be due to invalid IL or missing references)
			//IL_149b: Unknown result type (might be due to invalid IL or missing references)
			//IL_14af: Unknown result type (might be due to invalid IL or missing references)
			//IL_14db: Unknown result type (might be due to invalid IL or missing references)
			//IL_14e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_151a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1525: Unknown result type (might be due to invalid IL or missing references)
			//IL_157f: Unknown result type (might be due to invalid IL or missing references)
			//IL_158a: Unknown result type (might be due to invalid IL or missing references)
			//IL_15bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_15d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_160e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1628: Unknown result type (might be due to invalid IL or missing references)
			//IL_166c: Unknown result type (might be due to invalid IL or missing references)
			//IL_168f: Unknown result type (might be due to invalid IL or missing references)
			//IL_16af: Unknown result type (might be due to invalid IL or missing references)
			//IL_16cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_16ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_1711: Unknown result type (might be due to invalid IL or missing references)
			//IL_1731: Unknown result type (might be due to invalid IL or missing references)
			//IL_1752: Unknown result type (might be due to invalid IL or missing references)
			//IL_1772: Unknown result type (might be due to invalid IL or missing references)
			//IL_178c: Unknown result type (might be due to invalid IL or missing references)
			//IL_17ac: Unknown result type (might be due to invalid IL or missing references)
			float size = Size;
			float num = size * 0.5f;
			float capsuleHeight = M.CapsuleHeight;
			float lowH = Mathf.Max(1f, capsuleHeight * 0.62f);
			float num2 = Mathf.Max(1.1f, capsuleHeight * 0.62f);
			Material template = Pal.Colored(new Color(0.42f, 0.41f, 0.39f));
			Material wallMat = Pal.Colored(new Color(0.22f, 0.23f, 0.26f));
			Material val = Pal.Colored(new Color(0.5f, 0.52f, 0.55f));
			Material val2 = Pal.Colored(new Color(0.24f, 0.25f, 0.27f));
			Material frameMat = Pal.Colored(new Color(0.92f, 0.48f, 0.1f));
			Material template2 = Pal.Colored(new Color(0.95f, 0.78f, 0.1f));
			Material val3 = Pal.Colored(new Color(0.09f, 0.09f, 0.1f));
			Material val4 = Pal.Colored(new Color(0.18f, 0.44f, 0.9f));
			Material val5 = Pal.Colored(new Color(0.78f, 0.18f, 0.14f));
			Material val6 = Pal.Colored(new Color(0.14f, 0.55f, 0.3f));
			Material c = Pal.Colored(new Color(0.95f, 0.72f, 0.1f));
			Material val7 = Pal.Colored(new Color(0.55f, 0.55f, 0.58f));
			Material val8 = Pal.Colored(new Color(1f, 0.96f, 0.78f));
			Material val9 = Pal.Colored(new Color(0.72f, 0.88f, 1f));
			Material val10 = Pal.Colored(new Color(1f, 0.2f, 0.16f));
			Material exitMat = Pal.Colored(new Color(0.2f, 0.95f, 0.35f));
			Material val11 = Pal.Colored(new Color(0.68f, 0.18f, 0.16f));
			Material val12 = Pal.Colored(new Color(0.2f, 0.35f, 0.62f));
			Material doorMat = Pal.Colored(new Color(0.2f, 0.44f, 0.28f));
			Material val13 = Pal.Colored(new Color(0.34f, 0.22f, 0.12f));
			float num3 = WallHeight * 1.22f;
			int num4 = 3;
			for (int i = 0; i < num4; i++)
			{
				for (int j = 0; j < num4; j++)
				{
					float num5 = 0f - num + ((float)i + 0.5f) * (size / (float)num4);
					float num6 = 0f - num + ((float)j + 0.5f) * (size / (float)num4);
					Box("WH_Ceil_" + i + "_" + j, new Vector3(num5, num3, num6), new Vector3(size / (float)num4 - 0.2f, 0.22f, size / (float)num4 - 0.2f), val2);
				}
			}
			for (int k = 0; k < 4; k++)
			{
				float num7 = 0f - num + (float)k / 3f * size;
				Box("WH_TrussX_" + k, new Vector3(0f, num3 - 0.38f, num7), new Vector3(size * 0.98f, 0.28f, 0.35f), val3);
			}
			for (int l = 0; l < 4; l++)
			{
				float num8 = 0f - num + (float)l / 3f * size;
				Box("WH_TrussZ_" + l, new Vector3(num8, num3 - 0.38f, 0f), new Vector3(0.35f, 0.28f, size * 0.98f), val3);
			}
			for (int m = 0; m < 4; m++)
			{
				float num9 = (0f - num) * 0.65f + (float)m * (size * 0.22f);
				Box("WH_TrussDiag_" + m, new Vector3(num9, num3 - 0.38f, 0f), new Vector3(size * 0.32f, 0.12f, 0.12f), val3).transform.localRotation = Quaternion.Euler(0f, 35f, 0f);
			}
			for (int n = 0; n < 2; n++)
			{
				float num10 = (0f - size) * 0.2f + (float)n * (size * 0.4f);
				Box("WH_Fan_Hub_" + n, new Vector3(0f, num3 - 0.55f, num10), new Vector3(0.35f, 0.25f, 0.35f), val2);
				Box("WH_Fan_B1_" + n, new Vector3(0f, num3 - 0.6f, num10), new Vector3(2.2f, 0.06f, 0.2f), val2);
				Box("WH_Fan_B2_" + n, new Vector3(0f, num3 - 0.6f, num10), new Vector3(2.2f, 0.06f, 0.2f), val2).transform.localRotation = Quaternion.Euler(0f, 90f, 0f);
			}
			float num11 = num3 - 0.55f;
			for (int num12 = 0; num12 < 5; num12++)
			{
				for (int num13 = 0; num13 < 6; num13++)
				{
					float num14 = 0f - num + ((float)num12 + 0.5f) * (size / 5f);
					float num15 = 0f - num + ((float)num13 + 0.5f) * (size / 6f);
					Box("WH_Fluo_H_" + num12 + "_" + num13, new Vector3(num14, num11, num15), new Vector3(2.4f, 0.1f, 0.35f), val);
					Box("WH_Fluo_G_" + num12 + "_" + num13, new Vector3(num14, num11 - 0.06f, num15), new Vector3(2.2f, 0.05f, 0.28f), val8);
					FillLight(new Vector3(num14, num11 - 0.15f, num15), 6.5f, 1.1f, new Color(1f, 0.96f, 0.85f));
				}
			}
			for (int num16 = 0; num16 < 3; num16++)
			{
				float num17 = 0f - num + (float)(num16 + 1) * (size / 4f);
				Box("WH_Sky_" + num16, new Vector3(0f, num3 - 0.02f, num17), new Vector3(size * 0.16f, 0.05f, 1.6f), val9);
				FillLight(new Vector3(0f, num3 - 0.4f, num17), size * 0.35f, 1f, new Color(0.65f, 0.85f, 1f));
			}
			Box("WH_Line_MainA", new Vector3(0f, 0.03f, (0f - size) * 0.02f), new Vector3(size * 0.68f, 0.06f, 0.15f), template2);
			Box("WH_Line_MainB", new Vector3(0f, 0.03f, size * 0.02f), new Vector3(size * 0.68f, 0.06f, 0.15f), template2);
			for (int num18 = 0; num18 < 5; num18++)
			{
				float num19 = (0f - size) * 0.18f + (float)num18 * (size * 0.09f);
				Box("WH_Chev_" + num18, new Vector3(num19, 0.03f, (0f - size) * 0.36f), new Vector3(0.8f, 0.06f, 0.25f), template2).transform.localRotation = Quaternion.Euler(0f, 35f, 0f);
			}
			Box("WH_X_A", new Vector3(0f, 0.04f, 0f), new Vector3(size * 0.09f, 0.08f, 0.4f), val11).transform.localRotation = Quaternion.Euler(0f, 45f, 0f);
			Box("WH_X_B", new Vector3(0f, 0.04f, 0f), new Vector3(size * 0.09f, 0.08f, 0.4f), val11).transform.localRotation = Quaternion.Euler(0f, -45f, 0f);
			BuildPipeBankZ(0f - num + 0.35f, 0f, size * 0.9f, val4, val5, c, val7, val6, "PW_L");
			BuildPipeBankZ(num - 0.35f, 0f, size * 0.9f, val4, val5, c, val7, val6, "PW_R");
			BuildPipeBankX(0f, 0f - num + 0.35f, size * 0.9f, val4, val5, c, val7, val6, "PW_N");
			BuildPipeBankX(0f, num - 0.35f, size * 0.9f, val4, val5, c, val7, val6, "PW_S");
			float num20 = WallHeight * 0.92f;
			(float, float, string)[] array = new(float, float, string)[4]
			{
				(0f - num + 0.55f, 0f - num + 0.55f, "NW"),
				(num - 0.55f, 0f - num + 0.55f, "NE"),
				(0f - num + 0.55f, num - 0.55f, "SW"),
				(num - 0.55f, num - 0.55f, "SE")
			};
			for (int num21 = 0; num21 < array.Length; num21++)
			{
				(float, float, string) tuple = array[num21];
				float num22 = ((tuple.Item1 < 0f) ? 0.35f : (-0.35f));
				Box("WH_PipeDrop_" + tuple.Item3 + "_A", new Vector3(tuple.Item1, num20 * 0.5f, tuple.Item2), new Vector3(0.32f, num20, 0.32f), val4);
				Box("WH_PipeDrop_" + tuple.Item3 + "_B", new Vector3(tuple.Item1 + num22, num20 * 0.5f, tuple.Item2), new Vector3(0.28f, num20, 0.28f), val5);
				Box("WH_PipeElbow_" + tuple.Item3, new Vector3(tuple.Item1, num20 - 0.15f, tuple.Item2), new Vector3(0.5f, 0.5f, 0.5f), val7);
			}
			for (int num23 = 0; num23 < 3; num23++)
			{
				float num24 = (0f - size) * 0.3f + (float)num23 * (size * 0.3f);
				Box("WH_Breaker_" + num23, new Vector3(0f - num + 0.28f, WallHeight * 0.5f, num24), new Vector3(0.18f, 1.2f, 0.9f), val2);
				Box("WH_BreakerLED_" + num23, new Vector3(0f - num + 0.18f, WallHeight * 0.55f, num24 + 0.3f), new Vector3(0.06f, 0.12f, 0.12f), val10);
			}
			float h = WallHeight * 0.78f;
			for (int num25 = 0; num25 < 3; num25++)
			{
				float num26 = (0f - size) * 0.24f + (float)num25 * (size * 0.24f);
				BuildStorageRack("WH_RackA_" + num25, new Vector3(num26, 0f, size * 0.16f), 3f, h, 1.8f, frameMat, val2, num2);
				BuildStorageRack("WH_RackB_" + num25, new Vector3(num26, 0f, (0f - size) * 0.16f), 3f, h, 1.8f, frameMat, val2, num2);
			}
			BuildStorageRack("WH_RackE_L", new Vector3((0f - size) * 0.42f, 0f, 0f), 2.2f, WallHeight * 0.88f, 1.2f, frameMat, val2, num2);
			BuildStorageRack("WH_RackE_R", new Vector3(size * 0.42f, 0f, 0f), 2.2f, WallHeight * 0.88f, 1.2f, frameMat, val2, num2);
			float h2 = capsuleHeight * 1.55f;
			float wallT = 0.28f;
			float doorW = Mathf.Max(1.6f, capsuleHeight * 0.95f);
			float doorH = capsuleHeight * 1.4f;
			BuildRoomShell("WH_Office", new Vector3((0f - size) * 0.36f, 0f, size * 0.34f), size * 0.2f, size * 0.18f, h2, wallT, doorW, doorH, wallMat, val, val11, 1, exitMat, val8);
			BuildOfficeInterior(new Vector3((0f - size) * 0.36f, 0f, size * 0.34f), size * 0.2f, size * 0.18f, h2, lowH, num2, val13, val2, val, val3, val9);
			BuildRoomShell("WH_Locker", new Vector3(size * 0.36f, 0f, size * 0.34f), size * 0.2f, size * 0.18f, h2, wallT, doorW, doorH, wallMat, val, val12, 1, exitMat, val8);
			BuildLockerInterior(new Vector3(size * 0.36f, 0f, size * 0.34f), size * 0.2f, size * 0.18f, h2, capsuleHeight, val2, val, val12, val8);
			BuildRoomShell("WH_Server", new Vector3((0f - size) * 0.36f, 0f, (0f - size) * 0.34f), size * 0.2f, size * 0.18f, h2, wallT, doorW, doorH, wallMat, val, doorMat, -1, exitMat, val8);
			BuildServerInterior(new Vector3((0f - size) * 0.36f, 0f, (0f - size) * 0.34f), size * 0.2f, size * 0.18f, h2, capsuleHeight, val3, val2, val9, val10);
			BuildRoomShell("WH_Break", new Vector3(size * 0.36f, 0f, (0f - size) * 0.34f), size * 0.2f, size * 0.18f, h2, wallT, doorW, doorH, wallMat, val, val11, -1, exitMat, val8);
			BuildBreakInterior(new Vector3(size * 0.36f, 0f, (0f - size) * 0.34f), size * 0.2f, size * 0.18f, h2, lowH, val13, val, val11, val8);
			float num27 = capsuleHeight * 1.6f;
			float num28 = size * 0.5f;
			float num29 = 1.4f;
			float num30 = capsuleHeight * 0.55f;
			float num31 = 0.28f;
			Box("WH_CW_Floor", new Vector3(0f, num27, size * 0.44f), new Vector3(num28, 0.18f, num29), val2);
			Box("WH_CW_Grill", new Vector3(0f, num27 + 0.11f, size * 0.44f), new Vector3(num28 - 0.2f, 0.03f, num29 - 0.2f), val3);
			Box("WH_CW_RailF", new Vector3(0f, num27 + num30 * 0.5f + 0.1f, size * 0.44f - num29 * 0.5f), new Vector3(num28, num30, 0.1f), template2);
			Box("WH_CW_RailKick", new Vector3(0f, num27 + num30 * 0.85f + 0.1f, size * 0.44f - num29 * 0.5f), new Vector3(num28, 0.08f, 0.14f), val3);
			for (int num32 = 0; num32 < 5; num32++)
			{
				float num33 = (0f - num28) * 0.45f + (float)num32 * (num28 * 0.225f);
				Box("WH_CW_LegA_" + num32, new Vector3(num33, num27 * 0.5f, size * 0.44f - num29 * 0.4f), new Vector3(num31, num27, num31), val2);
				Box("WH_CW_LegB_" + num32, new Vector3(num33, num27 * 0.5f, size * 0.44f + num29 * 0.4f), new Vector3(num31, num27, num31), val2);
			}
			int num34 = 6;
			float num35 = 0.65f;
			float num36 = num29;
			float num37 = (0f - num28) * 0.5f - (float)num34 * num35;
			for (int num38 = 0; num38 < num34; num38++)
			{
				float num39 = num27 * (float)(num38 + 1) / (float)num34;
				Box("WH_CW_Steps_" + num38, new Vector3(num37 + num35 * ((float)num38 + 0.5f), num39 * 0.5f, size * 0.44f), new Vector3(num35, num39, num36), val2);
			}
			Box("WH_Nook_A_Front", new Vector3(0f - num + 1.9f, num2 * 0.5f, (0f - size) * 0.03f), new Vector3(num2, num2, num2 * 1.4f), Pal.Cover);
			Box("WH_Nook_A_Back", new Vector3(0f - num + 0.9f, num2 * 1.05f, (0f - size) * 0.03f), new Vector3(num2 * 0.9f, num2 * 2.1f, num2 * 1.5f), Pal.Cover);
			for (int num40 = 0; num40 < 3; num40++)
			{
				Box("WH_Pallet_" + num40, new Vector3(num - 1.6f, 0.12f + (float)num40 * 0.24f, size * 0.06f + (float)num40 * 0.05f), new Vector3(1.4f, 0.18f, 1.1f), val13);
			}
			Box("WH_Pallet_Wrap", new Vector3(num - 1.6f, 1.5f, size * 0.06f), new Vector3(1.35f, 2.4f, 1.05f), val2);
			Box("WH_Dump_Body", new Vector3((0f - size) * 0.05f, 0.9f, num - 2.6f), new Vector3(2.4f, 1.8f, 1.6f), val6);
			Box("WH_Dump_Lid", new Vector3((0f - size) * 0.05f, 1.85f, num - 2.6f), new Vector3(2.3f, 0.12f, 1.5f), val2);
			Box("WH_Fork_Body", new Vector3(size * 0.06f, 0.9f, 0f - num + 3f), new Vector3(1.6f, 1.6f, 2.6f), template2);
			Box("WH_Fork_Mast", new Vector3(size * 0.06f, 2.6f, 0f - num + 4.2f), new Vector3(0.4f, 3.4f, 0.4f), val2);
			Box("WH_Fork_Forks", new Vector3(size * 0.06f, 0.2f, 0f - num + 5.3f), new Vector3(1.2f, 0.15f, 0.9f), val2);
			Box("WH_UCrate_A", new Vector3((0f - num28) * 0.35f, num2 * 0.5f, size * 0.44f), new Vector3(num2, num2, num2), Pal.Cover);
			Box("WH_UCrate_B", new Vector3(num28 * 0.35f, num2 * 0.5f, size * 0.44f), new Vector3(num2, num2, num2), Pal.Cover);
			float num41 = 0.7f;
			float num42 = num3 - 0.4f;
			for (int num43 = -1; num43 <= 1; num43++)
			{
				Box("WH_Pillar_C_" + num43, new Vector3((float)num43 * size * 0.16f, num42 * 0.5f, 0f), new Vector3(num41, num42, num41), template);
				Box("WH_PillarStr_" + num43, new Vector3((float)num43 * size * 0.16f, 1.4f, 0f), new Vector3(num41 + 0.02f, 0.6f, num41 + 0.02f), template2);
				Box("WH_PillarStr2_" + num43, new Vector3((float)num43 * size * 0.16f, 1.4f, 0f), new Vector3(num41 + 0.03f, 0.15f, num41 + 0.03f), val3);
			}
			float height = Mathf.Max(4.5f, capsuleHeight * 2.6f);
			Lamp("WH_Lamp_Ctr", new Vector3(0f, 0f, 0f), height);
			FillLight(new Vector3((0f - size) * 0.28f, capsuleHeight * 2f, size * 0.28f), size * 0.6f, 1.2f, new Color(1f, 0.94f, 0.8f));
			FillLight(new Vector3(size * 0.28f, capsuleHeight * 2f, size * 0.28f), size * 0.6f, 1.2f, new Color(0.85f, 0.9f, 1f));
			FillLight(new Vector3((0f - size) * 0.28f, capsuleHeight * 2f, (0f - size) * 0.28f), size * 0.6f, 1.2f, new Color(1f, 0.94f, 0.8f));
			FillLight(new Vector3(size * 0.28f, capsuleHeight * 2f, (0f - size) * 0.28f), size * 0.6f, 1.2f, new Color(0.85f, 0.9f, 1f));
			FillLight(new Vector3(0f, 0.6f, 0f), size * 0.9f, 0.4f, new Color(0.55f, 0.65f, 0.85f));
		}

		private GameObject MakeDoor(string name, Vector3 pos, Vector3 size, Material mat, Vector3 hingeAnchorLocal, float minA, float maxA)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = Box(name, pos, size, mat);
			Rigidbody obj2 = obj.AddComponent<Rigidbody>();
			obj2.mass = 3f;
			obj2.drag = 0.6f;
			obj2.angularDrag = 3f;
			obj2.useGravity = false;
			obj2.interpolation = (RigidbodyInterpolation)1;
			obj2.collisionDetectionMode = (CollisionDetectionMode)1;
			HingeJoint obj3 = obj.AddComponent<HingeJoint>();
			((Joint)obj3).axis = new Vector3(0f, 1f, 0f);
			((Joint)obj3).anchor = hingeAnchorLocal;
			obj3.useLimits = true;
			JointLimits limits = default(JointLimits);
			((JointLimits)(ref limits)).min = minA;
			((JointLimits)(ref limits)).max = maxA;
			((JointLimits)(ref limits)).bounciness = 0f;
			obj3.limits = limits;
			obj3.spring = new JointSpring
			{
				spring = 0.5f,
				damper = 2f,
				targetPosition = 0f
			};
			obj3.useSpring = true;
			return obj;
		}

		private void BuildStorageRack(string name, Vector3 center, float w, float h, float d, Material frameMat, Material beamMat, float box)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0088: 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)
			//IL_0096: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: 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_01f0: 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_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: 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_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: 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_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: 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_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.14f;
			float num2 = h * 0.02f;
			float num3 = h * 0.36f;
			float num4 = h * 0.68f;
			Box(name + "_Up0", center + new Vector3((0f - w) * 0.5f, h * 0.5f, (0f - d) * 0.5f), new Vector3(num, h, num), frameMat);
			Box(name + "_Up1", center + new Vector3(w * 0.5f, h * 0.5f, (0f - d) * 0.5f), new Vector3(num, h, num), frameMat);
			Box(name + "_Up2", center + new Vector3((0f - w) * 0.5f, h * 0.5f, d * 0.5f), new Vector3(num, h, num), frameMat);
			Box(name + "_Up3", center + new Vector3(w * 0.5f, h * 0.5f, d * 0.5f), new Vector3(num, h, num), frameMat);
			Box(name + "_BraceA", center + new Vector3((0f - w) * 0.5f, h * 0.5f, 0f), new Vector3(num * 0.7f, h * 0.9f, 0.06f), beamMat).transform.localRotation = Quaternion.Euler(30f, 0f, 0f);
			Box(name + "_BraceB", center + new Vector3(w * 0.5f, h * 0.5f, 0f), new Vector3(num * 0.7f, h * 0.9f, 0.06f), beamMat).transform.localRotation = Quaternion.Euler(-30f, 0f, 0f);
			float[] array = new float[3] { num2, num3, num4 };
			for (int i = 0; i < array.Length; i++)
			{
				float num5 = array[i];
				Box(name + "_BeamF_" + i, center + new Vector3(0f, num5, (0f - d) * 0.5f), new Vector3(w, 0.14f, 0.14f), beamMat);
				Box(name + "_BeamB_" + i, center + new Vector3(0f, num5, d * 0.5f), new Vector3(w, 0.14f, 0.14f), beamMat);
				Box(name + "_Shelf_" + i, center + new Vector3(0f, num5 + 0.08f, 0f), new Vector3(w - 0.05f, 0.06f, d - 0.05f), Pal.Metal);
			}
			Box(name + "_Stk0A", center + new Vector3((0f - w) * 0.28f, num2 + 0.15f + box * 0.5f, 0f), new Vector3(box, box, box * 0.9f), Pal.Cover);
			Box(name + "_Stk0B", center + new Vector3(w * 0.28f, num2 + 0.15f + box * 0.5f, 0f), new Vector3(box, box, box * 0.9f), Pal.Cover);
			Box(name + "_Stk1A", center + new Vector3((0f - w) * 0.28f, num3 + 0.15f + box * 0.5f, 0f), new Vector3(box, box, box * 0.9f), Pal.Cover);
			Box(name + "_Stk1B", center + new Vector3(w * 0.28f, num3 + 0.15f + box * 0.5f, 0f), new Vector3(box * 0.8f, box * 0.7f, box * 0.8f), Pal.Cover);
		}

		private void BuildRoomShell(string name, Vector3 center, float w, float d, float h, float wallT, float doorW, float doorH, Material wallMat, Material ceilMat, Material doorMat, int frontDirZ, Material exitMat, Material lightMat)
		{
			//IL_0000: 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_0042: 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_0078: 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_00af: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: 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_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			float x = center.x;
			float z = center.z;
			float num = z - (float)frontDirZ * d * 0.5f;
			float num2 = z + (float)frontDirZ * d * 0.5f;
			Box(name + "_BackW", new Vec