Decompiled source of REPO1v1 v1.2.0

REPO1v1.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Tomoya083139")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+1cdf2956bb765e0e3458eff4ee12507ead967e83")]
[assembly: AssemblyProduct("REPO1v1")]
[assembly: AssemblyTitle("REPO1v1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace REPO1v1
{
	internal static class ArenaGround
	{
		private const float Margin = 30f;

		private const float WallHeight = 12f;

		private const float GroundTop = -0.05f;

		private const float GroundThickness = 0.1f;

		private static LevelGenerator? _builtFor;

		private const string RootName = "PvP Arena Ground";

		private const float VoidStep = 0.5f;

		private const float FloorLevel = 1.5f;

		internal static bool IsArenaGround(Collider collider)
		{
			if ((Object)(object)((Component)collider).transform.parent != (Object)null)
			{
				return ((Object)((Component)collider).transform.parent).name == "PvP Arena Ground";
			}
			return false;
		}

		internal static void EnsureBuilt(LevelGenerator generator)
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: 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_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_builtFor == (Object)(object)generator)
			{
				return;
			}
			_builtFor = generator;
			Module[] array = Object.FindObjectsOfType<Module>();
			if (array.Length == 0)
			{
				return;
			}
			float halfModule = LevelGenerator.ModuleWidth * LevelGenerator.TileSize / 2f;
			float num = array.Min((Module m) => ((Component)m).transform.position.x) - halfModule - 30f;
			float num2 = array.Max((Module m) => ((Component)m).transform.position.x) + halfModule + 30f;
			float num3 = array.Min((Module m) => ((Component)m).transform.position.z) - halfModule - 30f;
			float num4 = array.Max((Module m) => ((Component)m).transform.position.z) + halfModule + 30f;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor((num + num2) / 2f, 0f, (num3 + num4) / 2f);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(num2 - num, 0f, num4 - num3);
			GameObject val3 = new GameObject("PvP Arena Ground");
			val3.transform.SetParent(generator.LevelParent.transform, true);
			float cell = halfModule * 2f;
			HashSet<(int, int)> hashSet = (from m in array
				where !ShopExterior.IsStartRoom(m)
				select (Mathf.RoundToInt(((Component)m).transform.position.x / cell), Mathf.RoundToInt((((Component)m).transform.position.z - halfModule) / cell))).ToHashSet();
			int num5 = 0;
			Vector3 center = default(Vector3);
			for (int num6 = Mathf.FloorToInt(num / cell); num6 <= Mathf.CeilToInt(num2 / cell); num6++)
			{
				for (int num7 = Mathf.FloorToInt((num3 - halfModule) / cell); num7 <= Mathf.CeilToInt((num4 - halfModule) / cell); num7++)
				{
					if (!hashSet.Contains((num6, num7)))
					{
						((Vector3)(ref center))..ctor((float)num6 * cell, -0.1f, (float)num7 * cell + halfModule);
						AddCollider(val3, "Ground", center, new Vector3(cell, 0.1f, cell));
						num5++;
					}
				}
			}
			int num8 = FillVoids(val3, from m in array
				where !ShopExterior.IsStartRoom(m)
				select ((Component)m).transform.position);
			float num9 = 5.95f;
			AddCollider(val3, "Wall North", new Vector3(val.x, num9, num4), new Vector3(val2.x, 12f, 1f));
			AddCollider(val3, "Wall South", new Vector3(val.x, num9, num3), new Vector3(val2.x, 12f, 1f));
			AddCollider(val3, "Wall East", new Vector3(num2, num9, val.z), new Vector3(1f, 12f, val2.z));
			AddCollider(val3, "Wall West", new Vector3(num, num9, val.z), new Vector3(1f, 12f, val2.z));
			REPO1v1.Logger.LogInfo((object)$"Arena ground: {val2.x:0}m x {val2.z:0}m around the shop, {num5} floor tiles, {num8} patches inside room tiles");
		}

		private static int FillVoids(GameObject root, IEnumerable<Vector3> roomCenters)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_00cf: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			Physics.SyncTransforms();
			float num = LevelGenerator.ModuleWidth * LevelGenerator.TileSize / 2f;
			int num2 = 0;
			foreach (Vector3 roomCenter in roomCenters)
			{
				for (float num3 = 0f - num + 0.25f; num3 < num; num3 += 0.5f)
				{
					float? num4 = null;
					for (float num5 = 0f - num + 0.25f; num5 < num + 0.5f; num5 += 0.5f)
					{
						bool flag = num5 < num && IsVoid(new Vector3(roomCenter.x + num3, 0f, roomCenter.z + num5));
						if (flag && !num4.HasValue)
						{
							num4 = num5;
						}
						else if (!flag && num4.HasValue)
						{
							float num6 = num4.Value - 0.25f;
							float num7 = num5 - 0.25f;
							AddCollider(root, "Ground Patch", new Vector3(roomCenter.x + num3, -0.1f, roomCenter.z + (num6 + num7) / 2f), new Vector3(0.5f, 0.1f, num7 - num6));
							num2++;
							num4 = null;
						}
					}
				}
			}
			return num2;
		}

		private static bool IsVoid(Vector3 point)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = Physics.RaycastAll(point + Vector3.up * 30f, Vector3.down, 110f, -1, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (((RaycastHit)(ref val)).point.y < 1.5f && (Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<PlayerAvatar>() == (Object)null && (Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<PhysGrabObject>() == (Object)null)
				{
					return false;
				}
			}
			return true;
		}

		private static void AddCollider(GameObject root, string name, Vector3 center, Vector3 size)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name)
			{
				layer = 0
			};
			val.transform.SetParent(root.transform, false);
			val.transform.position = center;
			val.AddComponent<BoxCollider>().size = size;
		}
	}
	internal static class ArmoryRacks
	{
		internal readonly struct Placement
		{
			internal readonly Item Item;

			internal readonly Vector3 Position;

			internal readonly Quaternion Rotation;

			internal Placement(Item item, Vector3 position, Quaternion rotation)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				Item = item;
				Position = position;
				Rotation = rotation;
			}
		}

		private readonly struct Segment
		{
			internal readonly Vector3 Floor;

			internal readonly Vector3 Inward;

			internal readonly Transform Module;

			internal readonly bool IsCentre;

			internal Vector3 Along => Vector3.Cross(Vector3.up, Inward);

			internal Segment(Vector3 floor, Vector3 inward, Transform module, bool isCentre)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				Floor = floor;
				Inward = inward;
				Module = module;
				IsCentre = isCentre;
			}
		}

		private class Row
		{
			internal Segment Segment;

			internal float[] Heights;

			internal float Depth;

			internal float[] Used;

			internal int Count;

			internal readonly List<(int plan, int shelf)> Slots = new List<(int, int)>();
		}

		private sealed class Footprint
		{
			private static readonly Dictionary<(Item, float), Footprint> Cache = new Dictionary<(Item, float), Footprint>();

			internal Quaternion Rotation;

			internal Vector3 Size;

			internal Vector3 RootToBottomCentre;

			internal Vector3 SpawnPoint;

			private const float LowItem = 0.45f;

			internal static Footprint Of(Item item, float depth)
			{
				if (!Cache.TryGetValue((item, depth), out Footprint value))
				{
					value = Measure(item, depth);
					Cache[(item, depth)] = value;
				}
				return value;
			}

			private static Footprint Measure(Item item, float depth)
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: 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_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: 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)
				GameObject prefab = ((PrefabRef<GameObject>)(object)item.prefab).Prefab;
				if ((Object)(object)prefab == (Object)null)
				{
					return FromSizeClass(item);
				}
				Quaternion val = SpawnOffset(item);
				Quaternion val2 = Quaternion.Euler(0f, 90f, 0f);
				Quaternion val3 = Quaternion.Euler(0f, 0f, 90f);
				List<Footprint> list = (from rotation in (IEnumerable<Quaternion>)(object)new Quaternion[4]
					{
						val,
						val2 * val,
						val3 * val,
						val3 * val2 * val
					}
					select MeasureRotated(prefab, rotation) into measured
					where measured != null
					select (measured)).ToList();
				if (list.Count == 0)
				{
					return FromSizeClass(item);
				}
				return list.FirstOrDefault((Footprint f) => fitsDepth(f) && f.Size.y <= 0.45f) ?? list.FirstOrDefault(fitsDepth) ?? list.OrderBy((Footprint f) => f.Size.z).First();
				bool fitsDepth(Footprint f)
				{
					return f.Size.z <= depth - 0.05f;
				}
			}

			private static Footprint? MeasureRotated(GameObject prefab, Quaternion rotation)
			{
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0202: Unknown result type (might be due to invalid IL or missing references)
				//IL_0207: Unknown result type (might be due to invalid IL or missing references)
				//IL_0219: Unknown result type (might be due to invalid IL or missing references)
				//IL_021e: Unknown result type (might be due to invalid IL or missing references)
				//IL_024a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0253: Unknown result type (might be due to invalid IL or missing references)
				//IL_0258: Unknown result type (might be due to invalid IL or missing references)
				//IL_025d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0243: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0122: Unknown result type (might be due to invalid IL or missing references)
				//IL_0127: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0135: Unknown result type (might be due to invalid IL or missing references)
				//IL_0262: Unknown result type (might be due to invalid IL or missing references)
				//IL_026a: Unknown result type (might be due to invalid IL or missing references)
				//IL_026b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0273: Unknown result type (might be due to invalid IL or missing references)
				//IL_0278: Unknown result type (might be due to invalid IL or missing references)
				//IL_0280: Unknown result type (might be due to invalid IL or missing references)
				//IL_028c: 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_02a2: 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_02ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_02af: Unknown result type (might be due to invalid IL or missing references)
				//IL_0141: 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_016e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				//IL_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_018e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b5: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
				Transform transform = prefab.transform;
				Bounds? val = null;
				IEnumerable<(Mesh, Transform, Renderer)> enumerable = (from filter in prefab.GetComponentsInChildren<MeshFilter>(true)
					select (mesh: filter.sharedMesh, part: ((Component)filter).transform, renderer: ((Component)filter).GetComponent<Renderer>())).Concat(from skinned in prefab.GetComponentsInChildren<SkinnedMeshRenderer>(true)
					select (mesh: skinned.sharedMesh, part: ((Component)skinned).transform, renderer: (Renderer)(object)skinned));
				Vector3 val5;
				foreach (var (val2, val3, val4) in enumerable)
				{
					if ((Object)(object)val2 != (Object)null)
					{
						Bounds bounds = val2.bounds;
						val5 = ((Bounds)(ref bounds)).size;
						float magnitude = ((Vector3)(ref val5)).magnitude;
						val5 = val3.lossyScale;
						if (magnitude * ((Vector3)(ref val5)).magnitude > 5f)
						{
							continue;
						}
					}
					if ((Object)(object)val2 == (Object)null || (Object)(object)val4 == (Object)null || !val4.enabled || !IsShown(val3, transform) || (Object)(object)((Component)val3).GetComponentInParent<BatteryVisualLogic>(true) != (Object)null)
					{
						continue;
					}
					Matrix4x4 val6 = transform.worldToLocalMatrix * val3.localToWorldMatrix;
					Bounds bounds2 = val2.bounds;
					for (int num = 0; num < 8; num++)
					{
						Vector3 val7 = ((Bounds)(ref bounds2)).center + Vector3.Scale(((Bounds)(ref bounds2)).extents, new Vector3((float)(((num & 1) != 0) ? 1 : (-1)), (float)(((num & 2) != 0) ? 1 : (-1)), (float)(((num & 4) != 0) ? 1 : (-1))));
						Vector3 val8 = rotation * ((Matrix4x4)(ref val6)).MultiplyPoint3x4(val7);
						if (val.HasValue)
						{
							Bounds valueOrDefault = val.GetValueOrDefault();
							((Bounds)(ref valueOrDefault)).Encapsulate(val8);
							val = valueOrDefault;
						}
						else
						{
							val = new Bounds(val8, Vector3.zero);
						}
					}
				}
				if (val.HasValue)
				{
					Bounds valueOrDefault2 = val.GetValueOrDefault();
					val5 = ((Bounds)(ref valueOrDefault2)).size;
					if (!(((Vector3)(ref val5)).magnitude < 0.05f))
					{
						val5 = ((Bounds)(ref valueOrDefault2)).size;
						if (!(((Vector3)(ref val5)).magnitude > 4f))
						{
							ItemVolume componentInChildren = prefab.GetComponentInChildren<ItemVolume>(true);
							Vector3 spawnPoint = (((Object)(object)componentInChildren != (Object)null) ? (rotation * transform.InverseTransformPoint(((Component)componentInChildren).transform.position)) : Vector3.zero);
							return new Footprint
							{
								Rotation = rotation,
								Size = ((Bounds)(ref valueOrDefault2)).size,
								RootToBottomCentre = new Vector3(((Bounds)(ref valueOrDefault2)).center.x, ((Bounds)(ref valueOrDefault2)).min.y, ((Bounds)(ref valueOrDefault2)).center.z),
								SpawnPoint = spawnPoint
							};
						}
					}
				}
				return null;
			}

			internal static Quaternion SpawnOffset(Item item)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: 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_0072: 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_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				Quaternion spawnRotationOffset = item.spawnRotationOffset;
				float num = Mathf.Sqrt(spawnRotationOffset.x * spawnRotationOffset.x + spawnRotationOffset.y * spawnRotationOffset.y + spawnRotationOffset.z * spawnRotationOffset.z + spawnRotationOffset.w * spawnRotationOffset.w);
				if (!(num < 0.001f))
				{
					return new Quaternion(spawnRotationOffset.x / num, spawnRotationOffset.y / num, spawnRotationOffset.z / num, spawnRotationOffset.w / num);
				}
				return Quaternion.identity;
			}

			private static bool IsShown(Transform transform, Transform root)
			{
				Transform val = transform;
				while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root)
				{
					if (!((Component)val).gameObject.activeSelf)
					{
						return false;
					}
					val = val.parent;
				}
				return true;
			}

			private static Footprint FromSizeClass(Item item)
			{
				//IL_0001: 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_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				var (num, num2, _) = SizeOf(item.itemVolume);
				return new Footprint
				{
					Rotation = SpawnOffset(item),
					Size = new Vector3(num, num2 * 2f, 0.4f),
					RootToBottomCentre = new Vector3(0f, 0f - num2, 0f),
					SpawnPoint = Vector3.zero
				};
			}
		}

		private const float ModuleSize = 15f;

		private const float SegmentWidth = 4.6f;

		private const float SegmentOffset = 4.6f;

		private const float MaxPropSize = 6f;

		private const float MaxWallPropSize = 10f;

		private const float RackDepth = 0.7f;

		private const float FloorRowDepth = 1.2f;

		private const float BoardThickness = 0.05f;

		private const float WallGap = 0.05f;

		private const float ExtractionClearance = 5f;

		private static readonly float[] ShelfHeights = new float[4] { 0.1f, 0.65f, 1.2f, 1.75f };

		private static readonly HashSet<itemType> FloorTypes = new HashSet<itemType>
		{
			(itemType)2,
			(itemType)14,
			(itemType)5
		};

		private static readonly itemType[] TypeOrder;

		private const int RackCapacity = 12;

		private static LevelGenerator? _plannedFor;

		private static readonly List<Placement> Plan;

		private static readonly List<string> Unplaced;

		private static readonly List<string> RejectedSegments;

		private static readonly List<Segment> UsedSegments;

		private static int _rackCount;

		private static int _floorRowCount;

		private static readonly List<Item> UnplacedList;

		private static readonly List<Vector3> UsedShelfSpots;

		private static readonly itemType[] ShelfTypes;

		private const float TallItem = 0.7f;

		private const float SlotGap = 0.08f;

		private static string? _probeFailure;

		private static Material? _rackMaterial;

		private static readonly string[] StructuralNames;

		private static readonly string[] PropFolders;

		internal static IReadOnlyList<Placement> Placements => Plan;

		internal static IReadOnlyList<Item> UnplacedItems => UnplacedList;

		internal static void EnsurePlanned()
		{
			LevelGenerator instance = LevelGenerator.Instance;
			if (!PvpShop.IsActive || (Object)(object)instance == (Object)null || (Object)(object)_plannedFor == (Object)(object)instance || (Object)(object)StatsManager.instance == (Object)null)
			{
				return;
			}
			_plannedFor = instance;
			Plan.Clear();
			Unplaced.Clear();
			UnplacedList.Clear();
			RejectedSegments.Clear();
			UsedSegments.Clear();
			_rackCount = 0;
			_floorRowCount = 0;
			Physics.SyncTransforms();
			ShopExterior.ClearAroundAddedRooms(instance);
			ShopExterior.OpenShutters();
			Physics.SyncTransforms();
			ShopExterior.SolidifyScenery();
			ArenaGround.EnsureBuilt(instance);
			Physics.SyncTransforms();
			Module main = MainRoom();
			List<Segment> list = (from segment in FindWallSegments(instance)
				where (Object)(object)main != (Object)null && (Object)(object)segment.Module == (Object)(object)((Component)main).transform
				select segment).ToList();
			Queue<Segment> segments = new Queue<Segment>(list);
			Queue<Segment> segments2 = new Queue<Segment>(list.Concat(from segment in RoomCentreSegments()
				where (Object)(object)main != (Object)null && (Object)(object)segment.Module == (Object)(object)((Component)main).transform
				select segment));
			List<Item> list2 = StatsManager.instance.itemDictionary.Values.Where((Item item) => (Object)(object)item != (Object)null && !item.disabled && item.physicalItem && !string.IsNullOrEmpty(((PrefabRef<GameObject>)(object)item.prefab)?.ResourcePath) && !IsExcluded(item)).OrderBy(delegate(Item item)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				int num = Array.IndexOf(TypeOrder, item.itemType);
				return (num < 0) ? TypeOrder.Length : num;
			}).ThenBy((Item item) => item.itemName)
				.ToList();
			HashSet<Item> onShelves = (((Object)(object)main != (Object)null) ? PlaceOnShopShelves(list2, main) : new HashSet<Item>());
			list2 = list2.Where((Item item) => !onShelves.Contains(item)).ToList();
			List<Row> list3 = new List<Row>();
			foreach (Item item in list2.Where((Item item) => !StandsOnFloor(item)))
			{
				Place(item, list3, segments, isFloor: false);
			}
			List<Row> list4 = new List<Row>();
			foreach (Item item2 in list2.Where(StandsOnFloor))
			{
				Place(item2, list4, segments2, isFloor: true);
			}
			CentreShelves(list3.Concat(list4));
			REPO1v1.Logger.LogInfo((object)($"PvP shop plan: {Plan.Count}/{list2.Count + onShelves.Count} items, {onShelves.Count} on the shop's shelves, {_rackCount} racks, {_floorRowCount} floor rows" + ((Unplaced.Count > 0) ? (", no space for: " + string.Join(", ", Unplaced)) : "")));
			if (RejectedSegments.Count > 0)
			{
				REPO1v1.Logger.LogInfo((object)string.Concat("Walls skipped because something is in the way:", string.Concat(RejectedSegments.Select((string r) => "\n  " + r))));
			}
		}

		private static Module? MainRoom()
		{
			return (from module in Object.FindObjectsOfType<Module>()
				where ShopExterior.IsShopModule(module) && !ShopExterior.IsStartRoom(module) && ((Object)module).name.Contains(" - N - ")
				orderby Vector3.Distance(((Component)module).transform.position, new Vector3(0f, ((Component)module).transform.position.y, 7.5f))
				select module).FirstOrDefault();
		}

		private static HashSet<Item> PlaceOnShopShelves(List<Item> items, Module main)
		{
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			UsedShelfSpots.Clear();
			HashSet<Item> hashSet = new HashSet<Item>();
			List<ItemVolume> list = (from volume in ((Component)main).GetComponentsInChildren<ItemVolume>(true)
				where (int)volume.itemSecretShopType == 0
				orderby Mathf.Round(((Component)volume).transform.position.x * 100f), Mathf.Round(((Component)volume).transform.position.z * 100f), Mathf.Round(((Component)volume).transform.position.y * 100f)
				select volume).ToList();
			itemType[] shelfTypes = ShelfTypes;
			foreach (itemType type in shelfTypes)
			{
				foreach (Item item in items.Where((Item val2) => val2.itemType == type))
				{
					ItemVolume val = ((IEnumerable<ItemVolume>)list).FirstOrDefault((Func<ItemVolume, bool>)((ItemVolume volume) => volume.itemVolume == item.itemVolume));
					if (!((Object)(object)val == (Object)null))
					{
						list.Remove(val);
						hashSet.Add(item);
						UsedShelfSpots.Add(((Component)val).transform.position);
						Plan.Add(new Placement(item, ((Component)val).transform.position, ((Component)val).transform.rotation * Footprint.SpawnOffset(item)));
					}
				}
			}
			return hashSet;
		}

		private static bool StandsOnFloor(Item item)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (!FloorTypes.Contains(item.itemType))
			{
				return Footprint.Of(item, 0.7f).Size.y > 0.7f;
			}
			return true;
		}

		private static bool IsExcluded(Item item)
		{
			string[] array = PluginConfig.ExcludedItems.Value.Split(',');
			foreach (string text in array)
			{
				string text2 = text.Trim();
				if (text2.Length > 0 && (string.Equals(text2, item.itemName, StringComparison.OrdinalIgnoreCase) || string.Equals(text2, ((object)Unsafe.As<itemType, itemType>(ref item.itemType)/*cast due to .constrained prefix*/).ToString(), StringComparison.OrdinalIgnoreCase)))
				{
					return true;
				}
			}
			return false;
		}

		private static void Place(Item item, List<Row> rows, Queue<Segment> segments, bool isFloor)
		{
			Footprint footprint = Footprint.Of(item, isFloor ? 1.2f : 0.7f);
			while (true)
			{
				foreach (Row item2 in rows.Where((Row row2) => isFloor || row2.Count < 12))
				{
					if (TryTakeSlot(item2, item, footprint))
					{
						item2.Count++;
						return;
					}
				}
				Row row = null;
				while (row == null && segments.Count > 0)
				{
					Segment segment = segments.Dequeue();
					if (!UsedSegments.Any((Segment used) => used.Inward == segment.Inward && Vector3.Distance(used.Floor, segment.Floor) < 4.5899997f))
					{
						row = (isFloor ? TryCreateFloorRow(segment) : TryCreateRack(segment));
						if (row != null)
						{
							UsedSegments.Add(segment);
						}
					}
				}
				if (row == null)
				{
					break;
				}
				rows.Add(row);
			}
			foreach (Row row2 in rows)
			{
				if (TryTakeSlot(row2, item, footprint))
				{
					row2.Count++;
					return;
				}
			}
			Unplaced.Add(item.itemName);
			UnplacedList.Add(item);
		}

		private static void CentreShelves(IEnumerable<Row> rows)
		{
			//IL_0049: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			foreach (Row row in rows)
			{
				foreach (var slot in row.Slots)
				{
					int item = slot.plan;
					int item2 = slot.shelf;
					Placement placement = Plan[item];
					Vector3 val = row.Segment.Along * ((4.6f - row.Used[item2]) / 2f);
					Plan[item] = new Placement(placement.Item, placement.Position + val, placement.Rotation);
				}
			}
		}

		private static float Clearance(Row row, int shelf)
		{
			if (shelf + 1 >= row.Heights.Length)
			{
				return 2f;
			}
			return row.Heights[shelf + 1] - row.Heights[shelf] - 0.05f;
		}

		private static bool TryTakeSlot(Row row, Item item, Footprint footprint)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			float num = footprint.Size.x + 0.08f;
			foreach (int item2 in ShelfOrder(row, footprint))
			{
				if (!(row.Used[item2] + num > 4.6f))
				{
					float num2 = row.Used[item2] + num / 2f - 2.3f;
					row.Used[item2] += num;
					float num3 = row.Heights[item2] + ((row.Heights.Length > 1) ? 0.05f : 0f);
					Vector3 val = new Vector3(num2, num3 + 0.03f, 0.05f + row.Depth / 2f) - footprint.RootToBottomCentre + footprint.SpawnPoint;
					Segment segment = row.Segment;
					Vector3 position = segment.Floor + segment.Along * val.x + Vector3.up * val.y + segment.Inward * val.z;
					Quaternion rotation = Quaternion.LookRotation(segment.Inward, Vector3.up) * footprint.Rotation;
					row.Slots.Add((Plan.Count, item2));
					Plan.Add(new Placement(item, position, rotation));
					return true;
				}
			}
			return false;
		}

		private static IEnumerable<int> ShelfOrder(Row row, Footprint footprint)
		{
			int num = row.Heights.Length;
			int preferred = ((num != 1 && !(footprint.Size.x >= 0.7f)) ? ((footprint.Size.x >= 0.45f) ? 1 : Mathf.Min(2, num - 1)) : 0);
			return from shelf in Enumerable.Range(0, num)
				where footprint.Size.y + 0.05f <= Clearance(row, shelf)
				orderby row.Used[shelf] - ((shelf == preferred) ? 0.6f : 0f), Mathf.Abs(shelf - preferred)
				select shelf;
		}

		private static List<Segment> FindWallSegments(LevelGenerator generator)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			Vector3 truck = (((Object)(object)generator.LevelPathTruck != (Object)null) ? ((Component)generator.LevelPathTruck).transform.position : Vector3.zero);
			Vector3? val = (((Object)(object)ShopManager.instance != (Object)null && (Object)(object)ShopManager.instance.extractionPoint != (Object)null) ? new Vector3?(ShopManager.instance.extractionPoint.position) : ((Vector3?)null));
			Module[] source = Object.FindObjectsOfType<Module>();
			List<Segment> list = new List<Segment>();
			foreach (Module item in source.Where((Module module) => ShopExterior.IsShopModule(module) && !ShopExterior.IsStartRoom(module)))
			{
				Vector3 position = ((Component)item).transform.position;
				Vector3[] array = (Vector3[])(object)new Vector3[4]
				{
					Vector3.forward,
					Vector3.right,
					Vector3.back,
					Vector3.left
				};
				foreach (Vector3 val2 in array)
				{
					Vector3 edge = position + val2 * 7.5f;
					if (source.Any((Module other) => ShopExterior.IsStartRoom(other) && Vector3.Distance(((Component)other).transform.position, edge) < 4f))
					{
						continue;
					}
					Vector3 along = Vector3.Cross(Vector3.up, -val2);
					float[] array2 = new float[3] { -4.6f, 4.6f, 0f };
					foreach (float offset in array2)
					{
						if (TryFindSegment(((Component)item).transform, val2, along, offset, out var segment) && (!val.HasValue || Vector3.Distance(segment.Floor, val.Value) > 5f))
						{
							list.Add(segment);
						}
					}
				}
			}
			return (from segment2 in list
				orderby (!((Object)segment2.Module).name.Contains(" - N - ")) ? (((Object)segment2.Module).name.Contains(" - DE - ") ? 1 : 2) : 0, segment2.IsCentre ? 1 : 0, Vector3.Distance(segment2.Floor, truck), segment2.Floor.x, segment2.Floor.z
				select segment2).ToList();
		}

		private static IEnumerable<Segment> RoomCentreSegments()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Vector3? extraction = (((Object)(object)ShopManager.instance != (Object)null && (Object)(object)ShopManager.instance.extractionPoint != (Object)null) ? new Vector3?(ShopManager.instance.extractionPoint.position) : ((Vector3?)null));
			return from segment in (from module in Object.FindObjectsOfType<Module>()
					where ShopExterior.IsShopModule(module) && !ShopExterior.IsStartRoom(module)
					select module).OrderBy(delegate(Module module)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					Vector3 position = ((Component)module).transform.position;
					return ((Vector3)(ref position)).magnitude;
				}).ThenBy((Module module) => ((Component)module).transform.position.x).SelectMany((Module module) => ((IEnumerable<Vector3>)(object)new Vector3[2]
				{
					Vector3.forward,
					Vector3.right
				}).SelectMany((Vector3 inward) => new float[3] { 0f, -4f, 4f }.Select((float shift) => new Segment(((Component)module).transform.position + inward * (shift - 0.05f - 0.6f), inward, ((Component)module).transform, isCentre: true))))
				where !extraction.HasValue || Vector3.Distance(segment.Floor, extraction.Value) > 5f
				select segment;
		}

		private static bool TryFindSegment(Transform module, Vector3 outward, Vector3 along, float offset, out Segment segment)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_0142: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			segment = default(Segment);
			_probeFailure = null;
			int mask = LayerMask.GetMask(new string[1] { "Default" });
			Vector3 point = module.position + along * offset + outward * 6.3f;
			float? num = FindFloorHeight(point, module.position.y, mask);
			if (!num.HasValue)
			{
				_probeFailure = "no floor";
				return false;
			}
			Vector3 val = module.position + along * offset;
			val.y = num.Value;
			float? num2 = null;
			for (int i = 0; i <= 6; i++)
			{
				float num3 = Mathf.Lerp(-2.1f, 2.1f, (float)i / 6f);
				float? num4 = FindWallDistance(val + along * num3, outward, mask, module);
				if (!num4.HasValue)
				{
					_probeFailure = $"no wall at {num3:0.0} (floor {num.Value:0.00})";
					return false;
				}
				num2 = ((!num2.HasValue) ? num4 : new float?(Mathf.Min(num2.Value, num4.Value)));
			}
			segment = new Segment(val + outward * num2.Value, -outward, module, offset == 0f);
			return true;
		}

		private static float? FindFloorHeight(Vector3 point, float baseHeight, int mask)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_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)
			//IL_0047: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(point.x, baseHeight + 4.5f, point.z);
			float? num = null;
			RaycastHit[] array = Physics.RaycastAll(val, Vector3.down, 5.2f, mask, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val2 = array[i];
				if (((RaycastHit)(ref val2)).normal.y > 0.7f && ((RaycastHit)(ref val2)).point.y >= baseHeight - 0.4f && !ShopExterior.IsNetworkedObject(((Component)((RaycastHit)(ref val2)).collider).transform) && ((Object)((RaycastHit)(ref val2)).collider).name != "Rack Part" && !ArenaGround.IsArenaGround(((RaycastHit)(ref val2)).collider) && (!num.HasValue || ((RaycastHit)(ref val2)).point.y < num))
				{
					num = ((RaycastHit)(ref val2)).point.y;
				}
			}
			return num;
		}

		private static float? FindWallDistance(Vector3 center, Vector3 outward, int mask, Transform module)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			float? num = null;
			Vector3 val = center + Vector3.up * 0.5f + outward * 5f;
			RaycastHit[] array = Physics.RaycastAll(val, outward, 4f, mask, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val2 = array[i];
				float num2 = 5f + ((RaycastHit)(ref val2)).distance;
				if (Mathf.Abs(((RaycastHit)(ref val2)).normal.y) < 0.3f && num2 > 6.5f && num2 < 7.7f && !ShopExterior.IsNetworkedObject(((Component)((RaycastHit)(ref val2)).collider).transform) && (!num.HasValue || num2 < num))
				{
					num = num2;
				}
			}
			return num;
		}

		private static Row? TryCreateRack(Segment segment)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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_00b7: 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_00bf: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			if (segment.Floor.y - segment.Module.position.y > 1f)
			{
				RejectedSegments.Add($"{((Object)segment.Module).name}: upper floor at {segment.Floor}");
				return null;
			}
			if (!TryClearSpace(segment, 1f))
			{
				return null;
			}
			_rackCount++;
			Row row = new Row();
			row.Segment = segment;
			row.Heights = ShelfHeights;
			row.Depth = 0.7f;
			row.Used = new float[ShelfHeights.Length];
			Row result = row;
			Quaternion val = Quaternion.LookRotation(segment.Inward, Vector3.up);
			Vector3 val2 = segment.Floor + segment.Inward * 0.4f;
			float num = ShelfHeights[ShelfHeights.Length - 1] + 0.05f;
			GameObject val3 = new GameObject("PvP Display Rack");
			val3.transform.SetPositionAndRotation(val2, val);
			val3.transform.SetParent(segment.Module, true);
			Material material = FindRackMaterial(segment.Module);
			float[] shelfHeights = ShelfHeights;
			foreach (float num2 in shelfHeights)
			{
				AddBox(val3.transform, material, new Vector3(0f, num2 + 0.025f, 0f), new Vector3(4.6f, 0.05f, 0.7f));
			}
			float[] array = new float[3] { -2.3f, 0f, 2.3f };
			foreach (float num3 in array)
			{
				float[] array2 = new float[2] { -0.35f, 0.35f };
				foreach (float num4 in array2)
				{
					AddBox(val3.transform, material, new Vector3(num3, num / 2f, num4), new Vector3(0.06f, num, 0.06f));
				}
			}
			AddBox(val3.transform, material, new Vector3(0f, num / 2f, -0.35f), new Vector3(4.6f, num, 0.03f));
			float[] array3 = new float[2] { -2.3f, 2.3f };
			foreach (float num5 in array3)
			{
				AddBox(val3.transform, material, new Vector3(num5, num / 2f, 0f), new Vector3(0.03f, num, 0.7f));
			}
			for (int m = 0; m < ShelfHeights.Length; m++)
			{
				AddBox(val3.transform, material, new Vector3(0f, ShelfHeights[m] + 0.08f, 0.35f), new Vector3(4.6f, 0.06f, 0.02f));
			}
			Light val4 = new GameObject("PvP Rack Light").AddComponent<Light>();
			((Component)val4).transform.SetParent(val3.transform, false);
			((Component)val4).transform.localPosition = new Vector3(0f, num + 0.8f, 1.5500001f);
			val4.type = (LightType)2;
			val4.range = 6f;
			val4.intensity = 2.5f;
			val4.color = new Color(1f, 0.93f, 0.8f);
			val4.shadows = (LightShadows)0;
			return result;
		}

		private static Row? TryCreateFloorRow(Segment segment)
		{
			if (!TryClearSpace(segment, 1.2f))
			{
				return null;
			}
			_floorRowCount++;
			Row row = new Row();
			row.Segment = segment;
			row.Heights = new float[1];
			row.Depth = 1.2f;
			row.Used = new float[1];
			return row;
		}

		private static void AddBox(Transform parent, Material? material, Vector3 localPosition, Vector3 size)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = "Rack Part";
			val.layer = 0;
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPosition;
			val.transform.localScale = size;
			if ((Object)(object)material != (Object)null)
			{
				((Renderer)val.GetComponent<MeshRenderer>()).sharedMaterial = material;
			}
		}

		private static Material? FindRackMaterial(Transform module)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_rackMaterial != (Object)null)
			{
				return _rackMaterial;
			}
			Material val = (from r in Object.FindObjectsOfType<MeshRenderer>()
				select ((Renderer)r).sharedMaterial into m
				where (Object)(object)m != (Object)null && (Object)(object)m.shader != (Object)null && ((Object)m.shader).name == "Standard" && m.renderQueue < 2450
				orderby ((Object)m).name
				select m).FirstOrDefault();
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Material val2 = new Material(val)
			{
				name = "PvP Rack Metal"
			};
			string[] array = new string[9] { "_MainTex", "_BumpMap", "_MetallicGlossMap", "_OcclusionMap", "_EmissionMap", "_ParallaxMap", "_DetailMask", "_DetailAlbedoMap", "_DetailNormalMap" };
			foreach (string text in array)
			{
				if (val2.HasProperty(text))
				{
					val2.SetTexture(text, (Texture)null);
				}
			}
			string[] array2 = new string[8] { "_NORMALMAP", "_METALLICGLOSSMAP", "_EMISSION", "_PARALLAXMAP", "_DETAIL_MULX2", "_ALPHATEST_ON", "_ALPHABLEND_ON", "_ALPHAPREMULTIPLY_ON" };
			foreach (string text2 in array2)
			{
				val2.DisableKeyword(text2);
			}
			val2.color = new Color(0.42f, 0.44f, 0.46f);
			if (val2.HasProperty("_Metallic"))
			{
				val2.SetFloat("_Metallic", 0.6f);
			}
			if (val2.HasProperty("_Glossiness"))
			{
				val2.SetFloat("_Glossiness", 0.35f);
			}
			val2.renderQueue = 2000;
			_rackMaterial = val2;
			return val2;
		}

		private static bool TryClearSpace(Segment segment, float depth)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			if (!HasFloor(segment, depth))
			{
				RejectedSegments.Add($"{((Object)segment.Module).name}: no floor under part of it at {segment.Floor}");
				return false;
			}
			Quaternion val = Quaternion.LookRotation(segment.Inward, Vector3.up);
			Vector3 val2 = segment.Floor + segment.Inward * (0.25f + (depth - 0.2f) / 2f) + Vector3.up * 1.25f;
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(2.3f, 1.15f, (depth - 0.2f) / 2f);
			foreach (Vector3 usedShelfSpot in UsedShelfSpots)
			{
				Vector3 val4 = Quaternion.Inverse(val) * (usedShelfSpot - val2);
				if (Mathf.Abs(val4.x) < val3.x + 0.3f && Mathf.Abs(val4.y) < val3.y + 0.3f && Mathf.Abs(val4.z) < val3.z + 0.3f)
				{
					RejectedSegments.Add($"{((Object)segment.Module).name}: shop shelf with stock at {usedShelfSpot}");
					return false;
				}
			}
			HashSet<Transform> hashSet = new HashSet<Transform>();
			Collider[] array = Physics.OverlapBox(val2, val3, val, -1, (QueryTriggerInteraction)1);
			foreach (Collider val5 in array)
			{
				if (!(((Object)val5).name == "Rack Part") && !((Object)(object)((Component)val5).GetComponentInParent<PlayerAvatar>() != (Object)null) && !((Object)(object)((Component)val5).GetComponentInParent<PhysGrabObject>() != (Object)null))
				{
					Transform val6 = FindPropRoot(((Component)val5).transform, segment.Module);
					if ((Object)(object)val6 == (Object)null)
					{
						RejectedSegments.Add($"{((Object)segment.Module).name}: {PathOf(((Component)val5).transform, segment.Module)} ({MaxSize(((Component)val5).transform):0.0}m, layer {LayerMask.LayerToName(((Component)val5).gameObject.layer)})");
						return false;
					}
					hashSet.Add(val6);
				}
			}
			foreach (Transform item in hashSet)
			{
				((Component)item).gameObject.SetActive(false);
			}
			return true;
		}

		private static bool HasFloor(Segment segment, float depth)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i <= 6; i++)
			{
				float num = Mathf.Lerp(-2.1f, 2.1f, (float)i / 6f);
				float[] array = new float[2]
				{
					0.3f,
					depth - 0.1f
				};
				foreach (float num2 in array)
				{
					Vector3 val = segment.Floor + segment.Along * num + segment.Inward * (0.05f + num2) + Vector3.up * 2.5f;
					if (!Physics.RaycastAll(val, Vector3.down, 3.2f, LayerMask.GetMask(new string[1] { "Default" }), (QueryTriggerInteraction)1).Any((RaycastHit hit) => ((RaycastHit)(ref hit)).normal.y > 0.7f && Mathf.Abs(((RaycastHit)(ref hit)).point.y - segment.Floor.y) <= 0.35f && !ArenaGround.IsArenaGround(((RaycastHit)(ref hit)).collider)))
					{
						return false;
					}
				}
			}
			return true;
		}

		private static Transform? FindPropRoot(Transform hit, Transform module)
		{
			if (!hit.IsChildOf(module) || ShopExterior.IsNetworkedObject(hit) || IsExtractionMachinery(hit, module) || (Object)(object)((Component)hit).GetComponentInParent<ShopKeeper>() != (Object)null)
			{
				return null;
			}
			Transform result = null;
			Transform val = hit;
			while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)module && !IsFolder(((Object)val).name) && !IsStructural(((Object)val).name))
			{
				bool flag = (Object)(object)val.parent != (Object)null && PropFolders.Contains(((Object)val.parent).name);
				if (MaxSize(val) > (flag ? 10f : 6f))
				{
					break;
				}
				result = val;
				val = val.parent;
			}
			return result;
		}

		private static bool IsExtractionMachinery(Transform hit, Transform module)
		{
			ExtractionPoint componentInParent = ((Component)hit).GetComponentInParent<ExtractionPoint>();
			if ((Object)(object)componentInParent != (Object)null && (Object)(object)((Component)componentInParent).transform != (Object)(object)module)
			{
				return ((Component)componentInParent).transform.IsChildOf(module);
			}
			return false;
		}

		private static string PathOf(Transform transform, Transform root)
		{
			List<string> list = new List<string>();
			Transform val = transform;
			while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root)
			{
				list.Insert(0, ((Object)val).name);
				val = val.parent;
			}
			return string.Join("/", list);
		}

		private static bool IsStructural(string name)
		{
			string text = name.ToLower();
			return StructuralNames.Any(text.Contains);
		}

		private static bool IsFolder(string name)
		{
			if (!PropFolders.Contains(name))
			{
				if (name.Length > 0 && name == name.ToUpper())
				{
					return name.Any(char.IsLetter);
				}
				return false;
			}
			return true;
		}

		private static float MaxSize(Transform transform)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: 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)
			Bounds? val = null;
			Collider[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Collider>();
			foreach (Collider val2 in componentsInChildren)
			{
				Bounds value;
				if (val.HasValue)
				{
					Bounds valueOrDefault = val.GetValueOrDefault();
					value = Encapsulate(valueOrDefault, val2.bounds);
				}
				else
				{
					value = val2.bounds;
				}
				val = value;
			}
			Renderer[] componentsInChildren2 = ((Component)transform).GetComponentsInChildren<Renderer>();
			foreach (Renderer val3 in componentsInChildren2)
			{
				Bounds value2;
				if (val.HasValue)
				{
					Bounds valueOrDefault2 = val.GetValueOrDefault();
					value2 = Encapsulate(valueOrDefault2, val3.bounds);
				}
				else
				{
					value2 = val3.bounds;
				}
				val = value2;
			}
			if (val.HasValue)
			{
				Bounds valueOrDefault3 = val.GetValueOrDefault();
				return Mathf.Max(new float[3]
				{
					((Bounds)(ref valueOrDefault3)).size.x,
					((Bounds)(ref valueOrDefault3)).size.y,
					((Bounds)(ref valueOrDefault3)).size.z
				});
			}
			return 0f;
		}

		private static Bounds Encapsulate(Bounds bounds, Bounds other)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			((Bounds)(ref bounds)).Encapsulate(other);
			return bounds;
		}

		private static (float width, float height, bool tallOnly) SizeOf(itemVolume volume)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected I4, but got Unknown
			switch ((int)volume)
			{
			case 0:
			case 4:
			case 6:
			case 7:
				return (width: 0.35f, height: 0.2f, tallOnly: false);
			case 1:
				return (width: 0.5f, height: 0.25f, tallOnly: false);
			case 3:
				return (width: 1.1f, height: 0.35f, tallOnly: true);
			case 5:
				return (width: 0.7f, height: 0.6f, tallOnly: true);
			case 8:
				return (width: 0.9f, height: 0.45f, tallOnly: true);
			case 9:
				return (width: 1.8f, height: 0.6f, tallOnly: true);
			default:
				return (width: 0.8f, height: 0.35f, tallOnly: true);
			}
		}

		static ArmoryRacks()
		{
			itemType[] array = new itemType[11];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			TypeOrder = (itemType[])(object)array;
			Plan = new List<Placement>();
			Unplaced = new List<string>();
			RejectedSegments = new List<string>();
			UsedSegments = new List<Segment>();
			UnplacedList = new List<Item>();
			UsedShelfSpots = new List<Vector3>();
			itemType[] array2 = new itemType[9];
			RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			ShelfTypes = (itemType[])(object)array2;
			StructuralNames = new string[10] { "wall", "floor", "ceiling", "door", "window", "pillar", "column", "stairs", "ramp", "beam" };
			PropFolders = new string[2] { "Not Connected", "Connected" };
		}
	}
	internal class ItemRespawner : MonoBehaviour
	{
		private const float TakenDistance = 2f;

		private const float BadSpawnSeconds = 5f;

		private const float BadSpawnExtraDelay = 2f;

		private const float BadSpawnMaxDelay = 20f;

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

		private static LevelGenerator? _badSpawnsLevel;

		private Item _item;

		private Vector3 _spawnPosition;

		private Quaternion _spawnRotation;

		private LevelGenerator _level;

		private bool _consumed;

		private bool _grabbed;

		private float _spawnTime;

		private PhysGrabObject? _physGrabObject;

		private ItemEquippable? _equippable;

		private float _extraDelay;

		internal static void Track(ItemAttributes itemAttributes)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if (PvpShop.IsActive && SemiFunc.IsMasterClientOrSingleplayer() && !((Object)(object)itemAttributes.item == (Object)null))
			{
				ItemRespawner itemRespawner = ((Component)itemAttributes).gameObject.AddComponent<ItemRespawner>();
				itemRespawner._item = itemAttributes.item;
				itemRespawner._physGrabObject = ((Component)itemAttributes).GetComponent<PhysGrabObject>();
				itemRespawner._equippable = ((Component)itemAttributes).GetComponent<ItemEquippable>();
				itemRespawner._spawnPosition = ((Component)itemAttributes).transform.position;
				itemRespawner._spawnRotation = ((Component)itemAttributes).transform.rotation;
				itemRespawner._level = LevelGenerator.Instance;
				itemRespawner._spawnTime = Time.time;
			}
		}

		internal void Consume()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (!_consumed)
			{
				_consumed = true;
				((MonoBehaviour)REPO1v1.Instance).StartCoroutine(RespawnAfterDelay(_item, _spawnPosition, _spawnRotation, _level, _extraDelay));
			}
		}

		private void Update()
		{
			//IL_007f: 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)
			if ((Object)(object)_physGrabObject != (Object)null)
			{
				_physGrabObject.OverrideKnockOutOfGrabDisable(0.5f);
			}
			if (_consumed)
			{
				return;
			}
			if ((Object)(object)_equippable != (Object)null && _equippable.isEquipped)
			{
				Consume();
				return;
			}
			if ((Object)(object)_physGrabObject != (Object)null && _physGrabObject.playerGrabbing.Count > 0)
			{
				_grabbed = true;
			}
			if (_grabbed && Vector3.Distance(((Component)this).transform.position, _spawnPosition) > 2f)
			{
				Consume();
			}
		}

		private void OnDestroy()
		{
			//IL_006e: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			if (!_consumed && !_grabbed && Time.time - _spawnTime < 5f && (Object)(object)LevelGenerator.Instance == (Object)(object)_level)
			{
				if ((Object)(object)_badSpawnsLevel != (Object)(object)_level)
				{
					BadSpawns.Clear();
					_badSpawnsLevel = _level;
				}
				BadSpawns.TryGetValue(_spawnPosition, out var value);
				BadSpawns[_spawnPosition] = value + 1;
				_extraDelay = Mathf.Min(2f * (float)(value + 1), 20f);
				if (value == 2)
				{
					REPO1v1.Logger.LogWarning((object)$"{_item.itemName} keeps getting lost right after spawning at {_spawnPosition}; still replacing it, more slowly.");
				}
			}
			Consume();
		}

		private static IEnumerator RespawnAfterDelay(Item item, Vector3 position, Quaternion rotation, LevelGenerator level, float extraDelay)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(PluginConfig.ItemRespawnDelay.Value + extraDelay);
			if (!((Object)(object)level == (Object)null) && !((Object)(object)LevelGenerator.Instance != (Object)(object)level) && PvpShop.IsActive && (int)GameDirector.instance.currentState == 2)
			{
				ShopLayout.SpawnItem(item, position, rotation);
			}
		}
	}
	internal static class PluginConfig
	{
		internal static ConfigEntry<int> ShopCurrency { get; private set; }

		internal static ConfigEntry<float> ItemRespawnDelay { get; private set; }

		internal static ConfigEntry<bool> DisableShopKeeper { get; private set; }

		internal static ConfigEntry<string> ExcludedItems { get; private set; }

		internal static ConfigEntry<KeyboardShortcut> ResetUpgradesKey { get; private set; }

		internal static ConfigEntry<int> ExtraRooms { get; private set; }

		internal static ConfigEntry<float> AimSensitivity { get; private set; }

		internal static ConfigEntry<KeyboardShortcut> ZoomKey { get; private set; }

		internal static ConfigEntry<float> ZoomFov { get; private set; }

		internal static ConfigEntry<bool> StraightShots { get; private set; }

		internal static ConfigEntry<float> GrabForce { get; private set; }

		internal static ConfigEntry<float> GrabCatchUpDistance { get; private set; }

		internal static ConfigEntry<bool> VerifiedShopsOnly { get; private set; }

		internal static void Bind(ConfigFile config)
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			ShopCurrency = config.Bind<int>("Shop", "Currency", 9999, "Money (in $K) given to the team in every PvP shop, so nothing is ever too expensive.");
			ItemRespawnDelay = config.Bind<float>("Shop", "ItemRespawnSeconds", 0.5f, "Seconds before a used or destroyed shop item reappears in its spot.");
			DisableShopKeeper = config.Bind<bool>("Shop", "DisableShopKeeper", true, "Keep the shop keeper asleep so he does not punish players for fighting.");
			ExcludedItems = config.Bind<string>("Shop", "ExcludedItems", "drone, Roll Staff, Void Staff, Zero Gravity Staff, Phase Bridge, Semibot Walkies, Leaf Blower, POCKET C.A.R.T., C.A.R.T., B.I.G. C.A.R.T., ORB CART, Valuable Tracker, Extraction Tracker, Hauler, Scout", "Items not stocked in the PvP shop, comma separated: exact item names, or item types (drone, orb, cart, vehicle, ...).");
			if (ExcludedItems.Value == "drone, Roll Staff, Void Staff, Zero Gravity Staff, Phase Bridge, Semibot Walkies, Leaf Blower, POCKET C.A.R.T., C.A.R.T., Valuable Tracker, Hauler, Scout")
			{
				ExcludedItems.Value = (string)((ConfigEntryBase)ExcludedItems).DefaultValue;
			}
			ResetUpgradesKey = config.Bind<KeyboardShortcut>("Upgrades", "ResetKey", new KeyboardShortcut((KeyCode)290, Array.Empty<KeyCode>()), "Key that removes all of your own upgrades while in the PvP shop.");
			AimSensitivity = config.Bind<float>("Weapons", "AimSensitivity", 0.6f, new ConfigDescription("Aim sensitivity while holding a weapon, relative to your normal sensitivity. While zoomed in (Weapons.ZoomKey or a scope) it is lowered further in proportion to the zoom.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>()));
			ZoomKey = config.Bind<KeyboardShortcut>("Weapons", "ZoomKey", new KeyboardShortcut((KeyCode)324, Array.Empty<KeyCode>()), "Hold to zoom in (aim down sights) while holding a gun or launcher. Default: right mouse button.");
			ZoomFov = config.Bind<float>("Weapons", "ZoomFov", 35f, new ConfigDescription("Field of view while zoomed in (smaller = more zoom).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 70f), Array.Empty<object>()));
			StraightShots = config.Bind<bool>("Weapons", "StraightShots", true, "Guns shoot exactly where they point (no random spread).");
			GrabForce = config.Bind<float>("Weapons", "GrabForce", 4f, new ConfigDescription("How much harder held shop items (weapons...) are pulled to your hands than vanilla, so they keep up when you sprint and turn. 1 = vanilla.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 6f), Array.Empty<object>()));
			GrabCatchUpDistance = config.Bind<float>("Weapons", "GrabCatchUpDistance", 0.2f, new ConfigDescription("A held shop item lagging further behind your hands than this (metres) is put back into them.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 2f), Array.Empty<object>()));
			ExtraRooms = config.Bind<int>("Stage", "ArenaRoomCount", 3, "Extra rooms added right next to the shop in every PvP shop, each from a different random map (Arctic, Manor, Museum, Wizard). Limited by free space around the shop. 0 = shop only.");
			VerifiedShopsOnly = config.Bind<bool>("Stage", "VerifiedShopsOnly", true, "Only use shop layouts (start room variants) verified to fit every extra room and item. Off = any shop layout.");
		}
	}
	internal static class PvpShop
	{
		internal static bool IsActive
		{
			get
			{
				if ((Object)(object)RunManager.instance != (Object)null)
				{
					return SemiFunc.RunIsShop();
				}
				return false;
			}
		}

		internal static void Update()
		{
			if (IsActive && !((Object)(object)RoundDirector.instance == (Object)null))
			{
				RoundDirector.instance.debugInfiniteBattery = true;
			}
		}

		internal static void TopUpCurrency()
		{
			if (IsActive && SemiFunc.IsMasterClientOrSingleplayer() && SemiFunc.StatGetRunCurrency() < PluginConfig.ShopCurrency.Value)
			{
				SemiFunc.StatSetRunCurrency(PluginConfig.ShopCurrency.Value);
			}
		}
	}
	[HarmonyPatch]
	internal static class PvpWeapons
	{
		private static bool _zooming;

		private static itemType? HeldType(out PhysGrabObject? held)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			PhysGrabber instance = PhysGrabber.instance;
			held = (((Object)(object)instance != (Object)null && instance.grabbed) ? instance.grabbedPhysGrabObject : null);
			ItemAttributes val = (((Object)(object)held != (Object)null) ? ((Component)held).GetComponent<ItemAttributes>() : null);
			if (!((Object)(object)val != (Object)null) || !((Object)(object)val.item != (Object)null))
			{
				return null;
			}
			return val.item.itemType;
		}

		private static bool IsGun(itemType? type)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			if ((int)type.GetValueOrDefault() != 9)
			{
				return (int)type.GetValueOrDefault() == 15;
			}
			return true;
		}

		private static bool IsWeapon(itemType? type)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			if (!IsGun(type))
			{
				return (int)type.GetValueOrDefault() == 7;
			}
			return true;
		}

		internal static void Update()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			_zooming = false;
			if (!PvpShop.IsActive || (Object)(object)CameraZoom.Instance == (Object)null || ((Object)(object)ChatManager.instance != (Object)null && ChatManager.instance.StateIsActive()))
			{
				return;
			}
			PhysGrabObject held;
			itemType? type = HeldType(out held);
			if ((Object)(object)held != (Object)null && IsGun(type))
			{
				KeyboardShortcut value = PluginConfig.ZoomKey.Value;
				if (((KeyboardShortcut)(ref value)).IsPressed())
				{
					_zooming = true;
					CameraZoom.Instance.OverrideZoomSet(PluginConfig.ZoomFov.Value, 0.1f, 8f, 8f, ((Component)held).gameObject, 50);
				}
			}
		}

		private static float SensitivityScale()
		{
			if (!PvpShop.IsActive || !IsWeapon(HeldType(out PhysGrabObject _)))
			{
				return 1f;
			}
			float num = PluginConfig.AimSensitivity.Value;
			Camera main = Camera.main;
			float num2 = (((Object)(object)CameraZoom.Instance != (Object)null) ? CameraZoom.Instance.playerZoomDefault : 0f);
			if ((Object)(object)main != (Object)null && num2 > 1f && main.fieldOfView < num2 - 1f)
			{
				num *= main.fieldOfView / num2;
			}
			return num;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(InputManager), "GetMouseX")]
		private static void GetMouseX_Postfix(ref float __result)
		{
			__result *= SensitivityScale();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(InputManager), "GetMouseY")]
		private static void GetMouseY_Postfix(ref float __result)
		{
			__result *= SensitivityScale();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(InputManager), "KeyHold")]
		private static void KeyHold_Postfix(InputKey key, ref bool __result)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			if (_zooming && (int)key == 11)
			{
				__result = false;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ItemGun), "Start")]
		private static void ItemGun_Start_Postfix(ItemGun __instance)
		{
			if (PvpShop.IsActive && PluginConfig.StraightShots.Value)
			{
				__instance.gunRandomSpread = 0f;
			}
		}
	}
	[BepInPlugin("Tomoya083139.REPO1v1", "REPO1v1", "1.2.0")]
	public class REPO1v1 : BaseUnityPlugin
	{
		internal static REPO1v1 Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			PluginConfig.Bind(((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0025: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
			PvpShop.Update();
			UpgradeReset.Update();
			PvpWeapons.Update();
		}
	}
	internal static class ShopExterior
	{
		private static readonly Bounds TruckArea = new Bounds(new Vector3(0f, 2.5f, -7.5f), new Vector3(8f, 6f, 15f));

		private const float OutsideReach = 32f;

		private const float LargePiece = 30f;

		internal static bool CanClear(LevelGenerator generator, Bounds area, List<Bounds> shopRooms, out string blocker)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			foreach (Component item in PiecesIn(generator, area))
			{
				if (!IsHideable(item, shopRooms))
				{
					Bounds val = BoundsOf(item);
					string text = (IsNetworkedObject(item.transform) ? "networked" : (((Bounds)(ref val)).Intersects(TruckArea) ? "reaches the truck area" : "reaches a shop room"));
					blocker = $"{PathOf(item.transform)} [{((object)item).GetType().Name}] center {((Bounds)(ref val)).center} size {((Bounds)(ref val)).size}, {text}";
					return false;
				}
			}
			blocker = "";
			return true;
		}

		internal static void ClearAroundAddedRooms(LevelGenerator generator)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			Module[] source = Object.FindObjectsOfType<Module>();
			List<Bounds> shopRooms = (from module in source
				where IsShopModule(module) && !IsStartRoom(module)
				select RoomBounds(((Component)module).transform.position)).ToList();
			int num = 0;
			foreach (Module item in source.Where((Module module) => !IsShopModule(module) && !IsStartRoom(module)))
			{
				foreach (Component item2 in PiecesIn(generator, RoomBounds(((Component)item).transform.position)))
				{
					if (IsHideable(item2, shopRooms))
					{
						Hide(item2);
						num++;
					}
				}
			}
			if (num > 0)
			{
				REPO1v1.Logger.LogInfo((object)$"Hid {num} piece(s) of shop exterior inside added rooms");
			}
		}

		internal static void OpenShutters()
		{
			int num = 0;
			foreach (Module item in from module in Object.FindObjectsOfType<Module>()
				where IsShopModule(module) && !IsStartRoom(module)
				select module)
			{
				foreach (Transform item2 in (from part in ((Component)item).GetComponentsInChildren<Transform>(true)
					where ((Object)part).name == "Garage Door"
					select part).ToList())
				{
					((Component)item2).gameObject.SetActive(false);
					num++;
				}
			}
			if (num > 0)
			{
				REPO1v1.Logger.LogInfo((object)$"Opened {num} shutter(s) in the shop");
			}
		}

		internal static void SolidifyScenery()
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			Module[] source = Object.FindObjectsOfType<Module>();
			Module val = ((IEnumerable<Module>)source).FirstOrDefault((Func<Module, bool>)IsStartRoom);
			List<Module> list = source.Where((Module module) => !IsStartRoom(module)).ToList();
			if ((Object)(object)val == (Object)null || list.Count == 0)
			{
				return;
			}
			List<Bounds> source2 = (from module in list
				where !IsShopModule(module) || Vector3.Distance(((Component)module).transform.position, new Vector3(0f, 0f, 7.5f)) < 1f
				select RoomBounds(((Component)module).transform.position)).ToList();
			Bounds val2 = default(Bounds);
			((Bounds)(ref val2))..ctor(((Component)list[0]).transform.position, Vector3.zero);
			foreach (Module item in list)
			{
				((Bounds)(ref val2)).Encapsulate(((Component)item).transform.position);
			}
			((Bounds)(ref val2)).Expand(new Vector3(32f, 100f, 32f) * 2f);
			int num = 0;
			MeshRenderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val3 in componentsInChildren)
			{
				Bounds bounds = ((Renderer)val3).bounds;
				float num3 = Mathf.Max(((Bounds)(ref bounds)).size.x, ((Bounds)(ref bounds)).size.z);
				MeshFilter component = ((Component)val3).GetComponent<MeshFilter>();
				if (((Renderer)val3).enabled && !((Object)(object)component == (Object)null) && !((Object)(object)component.sharedMesh == (Object)null) && ((Component)val3).gameObject.layer == 0 && !((Object)(object)((Component)val3).GetComponent<Collider>() != (Object)null) && !IsNetworkedObject(((Component)val3).transform) && !IsTruckPart(((Component)val3).transform) && !(((Component)val3).transform.lossyScale.x <= 0f) && !(((Component)val3).transform.lossyScale.y <= 0f) && !(((Component)val3).transform.lossyScale.z <= 0f) && !(((Bounds)(ref bounds)).size.y < 0.3f) && !(num3 < 0.3f) && !(num3 > 12f) && !(((Bounds)(ref bounds)).min.y > 2f) && !(((Bounds)(ref bounds)).max.y < 0.3f) && ((Bounds)(ref val2)).Contains(((Bounds)(ref bounds)).center) && !((Bounds)(ref bounds)).Intersects(TruckArea) && !source2.Any((Bounds room) => ((Bounds)(ref room)).Intersects(bounds)) && Physics.OverlapBox(((Bounds)(ref bounds)).center, ((Bounds)(ref bounds)).extents * 0.9f, Quaternion.identity, -1, (QueryTriggerInteraction)1).Length == 0)
				{
					((Component)val3).gameObject.AddComponent<BoxCollider>();
					num++;
				}
			}
			if (num > 0)
			{
				REPO1v1.Logger.LogInfo((object)$"Gave {num} piece(s) of shop exterior collision");
			}
		}

		private static bool IsTruckPart(Transform transform)
		{
			Transform val = transform;
			while ((Object)(object)val != (Object)null)
			{
				if (((Object)val).name.StartsWith("Truck"))
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		internal static bool IsNetworkedObject(Transform transform)
		{
			PhotonView componentInParent = ((Component)transform).GetComponentInParent<PhotonView>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				return (Object)(object)((Component)componentInParent).GetComponent<Module>() == (Object)null;
			}
			return false;
		}

		internal static bool IsShopModule(Module module)
		{
			return ((Object)module).name.Contains("Shop");
		}

		internal static bool IsStartRoom(Module module)
		{
			return (Object)(object)((Component)module).GetComponentInChildren<StartRoom>() != (Object)null;
		}

		private static Bounds RoomBounds(Vector3 moduleCenter)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			return new Bounds(moduleCenter - Vector3.up * 0.1f + Vector3.up * 2.5f, new Vector3(14f, 5.2f, 14f));
		}

		private static IEnumerable<Component> PiecesIn(LevelGenerator generator, Bounds area)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			HashSet<Component> hashSet = new HashSet<Component>();
			Collider[] array = Physics.OverlapBox(((Bounds)(ref area)).center, ((Bounds)(ref area)).extents, Quaternion.identity, -1, (QueryTriggerInteraction)1);
			foreach (Collider val in array)
			{
				if (val.enabled && IsScenery(((Component)val).transform))
				{
					hashSet.Add((Component)(object)val);
				}
			}
			Renderer[] array2 = Object.FindObjectsOfType<Renderer>();
			foreach (Renderer val2 in array2)
			{
				if (val2.enabled && ((Component)val2).gameObject.scene == ((Component)generator).gameObject.scene && IsScenery(((Component)val2).transform))
				{
					Bounds bounds = val2.bounds;
					if (((Bounds)(ref bounds)).Intersects(area))
					{
						hashSet.Add((Component)(object)val2);
					}
				}
			}
			hashSet.RemoveWhere((Component piece) => IsOutOfTheWay(piece, area));
			return hashSet;
		}

		private static bool IsOutOfTheWay(Component piece, Bounds area)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			Bounds val = BoundsOf(piece);
			float num = ((Bounds)(ref area)).min.y + 0.1f + 0.1f - 0.02f;
			if (((Bounds)(ref val)).max.y < num)
			{
				return true;
			}
			if (Mathf.Max(((Bounds)(ref val)).size.x, ((Bounds)(ref val)).size.z) < 30f)
			{
				return false;
			}
			Collider val2 = (Collider)(((object)((piece is Collider) ? piece : null)) ?? ((object)piece.GetComponent<Collider>()));
			if ((Object)(object)val2 != (Object)null && val2.enabled)
			{
				float? num2 = HighestPointInside(val2, area);
				if (num2.HasValue)
				{
					return num2.Value < num;
				}
				return true;
			}
			return ((Bounds)(ref val)).size.y >= 3f;
		}

		private static float? HighestPointInside(Collider collider, Bounds area)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (