Decompiled source of House Builder v1.0.8

Mods/WoodStudios.HouseBuilder.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using FybCommon;
using HarmonyLib;
using HoldTheFort;
using HouseBuilder;
using Il2CppFishNet;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.AvatarFramework;
using Il2CppScheduleOne.AvatarFramework.Animation;
using Il2CppScheduleOne.Building;
using Il2CppScheduleOne.Core.Items.Framework;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Equipping;
using Il2CppScheduleOne.Instancing;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Map;
using Il2CppScheduleOne.NPCs;
using Il2CppScheduleOne.Networking;
using Il2CppScheduleOne.Persistence;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.Property;
using Il2CppScheduleOne.Storage;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.Shop;
using Il2CppScheduleOne.Weather;
using Il2CppSteamworks;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using S1API.Items;
using S1API.Items.Storable;
using S1API.Lifecycle;
using S1API.Rendering;
using S1API.Shops;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(HouseCore), "House Builder", "1.0.8", "Wood Studios", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonOptionalDependencies(new string[] { "HoldTheFort" })]
[assembly: AssemblyCompany("WoodStudios.HouseBuilder")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("WoodStudios.HouseBuilder")]
[assembly: AssemblyTitle("WoodStudios.HouseBuilder")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HouseBuilder
{
	internal static class Building
	{
		private enum Part
		{
			None,
			Foundation,
			Floor,
			Wall,
			Stairs,
			Steps,
			Railing,
			Roof
		}

		private sealed class PartsOf
		{
			public List<(string name, Transform t)> All;

			public Dictionary<string, Transform> Found = new Dictionary<string, Transform>();

			public MeshRenderer[] Siding;

			public Material Painted;
		}

		private sealed class Piece
		{
			public Placement.Placed P;

			public Part Kind;

			public Vector3 Pos;

			public Vector3 Fwd;

			public Vector3 Right;
		}

		private struct Frame
		{
			public Vector3 Origin;

			public Quaternion Rot;

			public float Yaw;

			public bool FromHouse;

			public Vector3 X => Rot * Vector3.right;

			public Vector3 Z => Rot * Vector3.forward;

			public Vector3 Local(Vector3 w)
			{
				//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_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				return Quaternion.Inverse(Rot) * (w - Origin);
			}

			public Vector3 World(float lx, float lz, float y)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0022: 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)
				Vector3 result = Origin + Rot * new Vector3(lx, 0f, lz);
				result.y = y;
				return result;
			}
		}

		public const string FoundationId = "hb_foundation";

		public const string FloorId = "hb_floor";

		public const string WallId = "hb_wall";

		public const string DoorId = "hb_wall_door";

		public const string WindowId = "hb_wall_window";

		public const string StairsId = "hb_stairs";

		public const string StepsId = "hb_steps";

		public const string RailingId = "hb_railing";

		public const string RoofId = "hb_roof";

		private const float Cell = 2f;

		private const float Storey = 3f;

		private const float Rise = 1f;

		private const float Reach = 14f;

		private static GameObject _src;

		private static readonly Dictionary<int, PartsOf> PartsCache = new Dictionary<int, PartsOf>();

		private static readonly List<Piece> Pieces = new List<Piece>();

		private static int _seenVersion = -1;

		private static int _tidiedVersion = -1;

		private static int _houseSig = int.MinValue;

		private static Material _drywall;

		private static readonly Color[] Paints = (Color[])(object)new Color[6]
		{
			new Color(0.8f, 0.8f, 0.76f),
			new Color(0.58f, 0.66f, 0.72f),
			new Color(0.56f, 0.62f, 0.5f),
			new Color(0.74f, 0.64f, 0.48f),
			new Color(0.52f, 0.2f, 0.16f),
			new Color(0.24f, 0.25f, 0.27f)
		};

		private static readonly string[] PaintNames = new string[6] { "white", "blue-grey", "sage", "tan", "barn red", "charcoal" };

		private static Part PartOf(string id)
		{
			switch (id)
			{
			case "hb_foundation":
				return Part.Foundation;
			case "hb_floor":
				return Part.Floor;
			case "hb_wall":
			case "hb_wall_door":
			case "hb_wall_window":
				return Part.Wall;
			case "hb_stairs":
				return Part.Stairs;
			case "hb_steps":
				return Part.Steps;
			case "hb_railing":
				return Part.Railing;
			case "hb_roof":
				return Part.Roof;
			default:
				return Part.None;
			}
		}

		public static bool Is(string id)
		{
			return PartOf(id) != Part.None;
		}

		public static GameObject Model(string node)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00df: 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_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Expected O, but got Unknown
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: 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_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0515: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)_src == (Object)null)
			{
				_src = GltfLoader.LoadEmbedded("HTF_House.glb", Models.Root);
				((Object)_src).name = "HB_HouseKit";
				_src.SetActive(false);
			}
			Transform val = null;
			for (int i = 0; i < _src.transform.childCount; i++)
			{
				Transform child = _src.transform.GetChild(i);
				if (((Object)child).name == node || ((Object)child).name.StartsWith(node + ".", StringComparison.Ordinal))
				{
					val = child;
					break;
				}
			}
			if ((Object)val == (Object)null)
			{
				throw new Exception("house kit has no " + node);
			}
			GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, Models.Root);
			((Object)val2).name = "HB_House_" + node;
			val2.transform.localPosition = Vector3.zero;
			val2.transform.localRotation = Quaternion.identity;
			val2.SetActive(true);
			switch (node)
			{
			case "Foundation":
				Box(val2, new Vector3(0f, -1.5f, 0f), new Vector3(2f, 3f, 2f));
				Models.NavBlock(val2, new Vector3(0f, -0.5f, 0f), new Vector3(2f, 2f, 2f));
				break;
			case "Floor":
				Box(val2, new Vector3(0f, -0.1f, 0f), new Vector3(2f, 0.2f, 2f));
				break;
			case "Wall":
				Box(val2, new Vector3(0f, 1.5f, 0f), new Vector3(2f, 3f, 0.2f));
				Models.NavBlock(val2, new Vector3(0f, 1.5f, 0f), new Vector3(2f, 3f, 0.2f));
				break;
			case "WallDoor":
			{
				Box(val2, new Vector3(-0.75f, 1.5f, 0f), new Vector3(0.5f, 3f, 0.2f));
				Box(val2, new Vector3(0.75f, 1.5f, 0f), new Vector3(0.5f, 3f, 0.2f));
				Box(val2, new Vector3(0f, 2.6f, 0f), new Vector3(1f, 0.8f, 0.2f));
				Transform val3 = Find(val2.transform, "DoorLeaf");
				if ((Object)val3 != (Object)null)
				{
					Box(((Component)val3).gameObject, new Vector3(0.48f, 1.095f, 0f), new Vector3(0.96f, 2.15f, 0.06f));
				}
				break;
			}
			case "WallWindow":
				Box(val2, new Vector3(-0.775f, 1.5f, 0f), new Vector3(0.45f, 3f, 0.2f));
				Box(val2, new Vector3(0.775f, 1.5f, 0f), new Vector3(0.45f, 3f, 0.2f));
				Box(val2, new Vector3(0f, 0.45f, 0f), new Vector3(1.1f, 0.9f, 0.2f));
				Box(val2, new Vector3(0f, 2.6f, 0f), new Vector3(1.1f, 0.8f, 0.2f));
				Box(val2, new Vector3(0f, 1.55f, 0f), new Vector3(1.1f, 1.3f, 0.06f));
				Models.NavBlock(val2, new Vector3(0f, 1.5f, 0f), new Vector3(2f, 3f, 0.2f));
				break;
			case "Stairs":
				Ramp(val2, new Vector3(0f, 1.5f, 1f), -36.87f, new Vector3(1.8f, 0.1f, 5f));
				break;
			case "Steps":
				Ramp(val2, new Vector3(0f, -0.4f, 0.6f), 33.69f, new Vector3(1.8f, 0.1f, 1.45f));
				break;
			case "Railing":
				Box(val2, new Vector3(0f, 0.5f, 0f), new Vector3(2f, 1f, 0.1f));
				break;
			case "Roof":
				Ramp(val2, new Vector3(0f, 0.57f, 0f), -26.57f, new Vector3(2f, 0.15f, 2.24f));
				foreach (Transform componentsInChild in val2.GetComponentsInChildren<Transform>(true))
				{
					if (((Object)componentsInChild).name.StartsWith("GableL1") || ((Object)componentsInChild).name.StartsWith("GableL2") || ((Object)componentsInChild).name.StartsWith("GableR1") || ((Object)componentsInChild).name.StartsWith("GableR2") || ((Object)componentsInChild).name.StartsWith("Ridge"))
					{
						((Component)componentsInChild).gameObject.SetActive(false);
					}
				}
				break;
			}
			return val2;
		}

		private static void Box(GameObject go, Vector3 center, Vector3 size)
		{
			//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)
			BoxCollider obj = go.AddComponent<BoxCollider>();
			obj.center = center;
			obj.size = size;
		}

		private static void Ramp(GameObject go, Vector3 center, float pitch, Vector3 size)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0048: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("HB_Ramp");
			val.transform.SetParent(go.transform, false);
			val.transform.localPosition = center;
			val.transform.localRotation = Quaternion.Euler(pitch, 0f, 0f);
			val.AddComponent<BoxCollider>().size = size;
		}

		private static PartsOf Parts(Transform root)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_006b: Expected O, but got Unknown
			int instanceID = ((Object)root).GetInstanceID();
			if (PartsCache.TryGetValue(instanceID, out var value))
			{
				return value;
			}
			if (PartsCache.Count > 4000)
			{
				PartsCache.Clear();
			}
			value = new PartsOf
			{
				All = new List<(string, Transform)>()
			};
			foreach (Transform componentsInChild in ((Component)root).GetComponentsInChildren<Transform>(true))
			{
				if ((Object)componentsInChild != (Object)root)
				{
					value.All.Add((((Object)componentsInChild).name, componentsInChild));
				}
			}
			PartsCache[instanceID] = value;
			return value;
		}

		private static Transform Find(Transform root, string prefix)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			PartsOf partsOf = Parts(root);
			if (partsOf.Found.TryGetValue(prefix, out var value) && (Object)value != (Object)null)
			{
				return value;
			}
			foreach (var (text, val) in partsOf.All)
			{
				if (text.StartsWith(prefix, StringComparison.Ordinal) && (Object)val != (Object)null)
				{
					partsOf.Found[prefix] = val;
					return val;
				}
			}
			return null;
		}

		private static void Collect()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_008d: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
			Pieces.Clear();
			List<Placement.Placed> list = new List<Placement.Placed>(Placement.All);
			list.AddRange(CoopMirror.All);
			foreach (Placement.Placed item in list)
			{
				if (item != null && !((Object)item.Go == (Object)null) && item.Spec != null)
				{
					Part part = PartOf(item.Spec.Id);
					if (part != Part.None)
					{
						Transform transform = item.Go.transform;
						Pieces.Add(new Piece
						{
							P = item,
							Kind = part,
							Pos = transform.position,
							Fwd = Flat(transform.forward),
							Right = Flat(transform.right)
						});
					}
				}
			}
		}

		private static Vector3 Flat(Vector3 v)
		{
			//IL_0022: 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)
			v.y = 0f;
			if (!(((Vector3)(ref v)).sqrMagnitude > 1E-06f))
			{
				return Vector3.forward;
			}
			return ((Vector3)(ref v)).normalized;
		}

		private static bool Near(Vector3 a, Vector3 b, float flat = 0.3f, float up = 0.15f)
		{
			//IL_0000: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			if (Mathf.Abs(a.y - b.y) < up)
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(a.x - b.x, a.z - b.z);
				return ((Vector2)(ref val)).sqrMagnitude < flat * flat;
			}
			return false;
		}

		private static Piece At(Part kind, Vector3 p, float flat = 0.3f, float up = 0.15f)
		{
			//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)
			foreach (Piece piece in Pieces)
			{
				if (piece.Kind == kind && Near(piece.Pos, p, flat, up))
				{
					return piece;
				}
			}
			return null;
		}

		private static bool Deck(Vector3 p)
		{
			//IL_0001: 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)
			if (At(Part.Foundation, p) == null)
			{
				return At(Part.Floor, p) != null;
			}
			return true;
		}

		private static bool WallOn(Vector3 edgeCentre, bool railingCounts = false)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			foreach (Piece piece in Pieces)
			{
				if ((piece.Kind == Part.Wall || (railingCounts && piece.Kind == Part.Railing)) && Near(piece.Pos, edgeCentre))
				{
					return true;
				}
			}
			return false;
		}

		private static Frame FrameNear(Vector3 p, out Piece foundation)
		{
			//IL_0038: 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_00f8: 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_010d: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			foundation = null;
			float num = 900f;
			Vector2 val = default(Vector2);
			foreach (Piece piece in Pieces)
			{
				if (piece.Kind == Part.Foundation)
				{
					((Vector2)(ref val))..ctor(piece.Pos.x - p.x, piece.Pos.z - p.z);
					float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						foundation = piece;
					}
				}
			}
			if (foundation != null)
			{
				float num2 = Mathf.Round(foundation.P.Go.transform.eulerAngles.y * 1000f) / 1000f;
				return new Frame
				{
					Origin = foundation.Pos,
					Rot = Quaternion.Euler(0f, num2, 0f),
					Yaw = num2,
					FromHouse = true
				};
			}
			Placement.GridFrame(p, out var origin, out var yaw);
			return new Frame
			{
				Origin = origin,
				Rot = Quaternion.Euler(0f, yaw, 0f),
				Yaw = yaw,
				FromHouse = false
			};
		}

		private static Vector3 CellCentre(Frame f, Vector3 w, float y)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0022: 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)
			Vector3 val = f.Local(w);
			return f.World(Mathf.Round(val.x / 2f) * 2f, Mathf.Round(val.z / 2f) * 2f, y);
		}

		private static void Edge(Frame f, Vector3 w, float y, out Vector3 centre, out Vector3 along, out Vector3 cellA, out Vector3 cellB)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_0116: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009a: 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_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)
			Vector3 val = f.Local(w);
			float num = val.x / 2f;
			float num2 = val.z / 2f;
			float num3 = Mathf.Floor(num) + 0.5f;
			float num4 = Mathf.Floor(num2) + 0.5f;
			if (Mathf.Abs(num - num3) < Mathf.Abs(num2 - num4))
			{
				float num5 = Mathf.Round(num2);
				centre = f.World(num3 * 2f, num5 * 2f, y);
				along = f.Z;
				cellA = f.World((num3 - 0.5f) * 2f, num5 * 2f, y);
				cellB = f.World((num3 + 0.5f) * 2f, num5 * 2f, y);
			}
			else
			{
				float num6 = Mathf.Round(num);
				centre = f.World(num6 * 2f, num4 * 2f, y);
				along = f.X;
				cellA = f.World(num6 * 2f, (num4 - 0.5f) * 2f, y);
				cellB = f.World(num6 * 2f, (num4 + 0.5f) * 2f, y);
			}
		}

		private static bool OnPlane(Camera cam, float y, out Vector3 at)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			at = Vector3.zero;
			Vector3 position = ((Component)cam).transform.position;
			Vector3 forward = ((Component)cam).transform.forward;
			if (Mathf.Abs(forward.y) < 0.02f)
			{
				return false;
			}
			float num = (y - position.y) / forward.y;
			if (num <= 0.3f || num > 14f)
			{
				return false;
			}
			at = position + forward * num;
			return true;
		}

		private static Vector3 GridDir(Frame f, Vector3 look, int turns)
		{
			//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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0042: 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_005f: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Quaternion.Inverse(f.Rot) * Flat(look);
			int num = ((!(Mathf.Abs(val.x) > Mathf.Abs(val.z))) ? ((!(val.z > 0f)) ? 2 : 0) : ((val.x > 0f) ? 1 : 3));
			num = ((num + turns) % 4 + 4) % 4;
			Quaternion rot = f.Rot;
			return rot * (Vector3)(num switch
			{
				2 => Vector3.back, 
				1 => Vector3.right, 
				0 => Vector3.forward, 
				_ => Vector3.left, 
			});
		}

		public static bool Aim(ItemSpec spec, Camera cam, Player player, bool hasHit, RaycastHit hit, int turns, out Vector3 pos, out Quaternion rot, out string problem)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0070: 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_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: 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_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_0181: 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_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0542: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_054a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: 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_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			pos = Vector3.zero;
			rot = Quaternion.identity;
			problem = null;
			if (_seenVersion != Placement.Version)
			{
				Collect();
				_seenVersion = Placement.Version;
			}
			Part part = PartOf(spec.Id);
			Vector3 position = ((Component)player).transform.position;
			Vector3 forward = ((Component)cam).transform.forward;
			bool flag = forward.y > 0.22f;
			if (part == Part.Foundation)
			{
				return AimFoundation(cam, player, hasHit, hit, out pos, out rot, out problem);
			}
			Piece foundation;
			Frame f = FrameNear(position, out foundation);
			if (foundation == null)
			{
				problem = "Start with a foundation (Foundation, at the hardware store)";
				return false;
			}
			float y = foundation.Pos.y;
			int num = Mathf.Max(0, Mathf.RoundToInt((position.y - y) / 3f));
			int num2 = (flag ? (num + 1) : num);
			float num3 = y + (float)num2 * 3f;
			if (!OnPlane(cam, num3, out var at))
			{
				if (!hasHit)
				{
					problem = (flag ? "Look up at where it goes" : "Look at where it goes");
					return false;
				}
				at = ((RaycastHit)(ref hit)).point;
				at.y = num3;
			}
			Vector3 along;
			switch (part)
			{
			case Part.Floor:
			{
				if (num2 < 1)
				{
					problem = "Look up to put in a ceiling (floors go a storey up; use foundations on the ground)";
					return false;
				}
				Vector3 val4 = (pos = CellCentre(f, at, num3));
				rot = Quaternion.Euler(0f, f.Yaw + 90f * (float)(turns % 2), 0f);
				if (At(Part.Floor, val4) != null)
				{
					problem = "There's a floor here already";
					return true;
				}
				foreach (Piece piece2 in Pieces)
				{
					if (piece2.Kind == Part.Stairs && Mathf.Abs(piece2.Pos.y - (num3 - 3f)) < 0.15f && (Near(piece2.Pos, val4, 0.3f, 3.2f) || Near(piece2.Pos + piece2.Fwd * 2f, val4, 0.3f, 3.2f)))
					{
						problem = "Leave this open over the stairs";
						return true;
					}
				}
				if (!FloorSupported(f, val4, num3))
				{
					problem = "Needs a wall under its edge or a floor next to it";
				}
				return true;
			}
			case Part.Wall:
			case Part.Railing:
			{
				Edge(f, at, num3, out var centre2, out along, out var cellA2, out var cellB2);
				bool flag4 = Deck(cellA2);
				bool flag5 = Deck(cellB2);
				Vector3 val8 = Flat(cellB2 - cellA2);
				Vector3 val9 = ((flag4 && !flag5) ? val8 : ((flag5 && !flag4) ? (-val8) : ((Vector3.Dot(position - centre2, val8) > 0f) ? val8 : (-val8))));
				if (turns % 2 == 1)
				{
					val9 = -val9;
				}
				pos = centre2;
				rot = Quaternion.LookRotation(val9, Vector3.up);
				if (WallOn(centre2, railingCounts: true))
				{
					problem = "Something's already on this edge";
					return true;
				}
				if (!flag4 && !flag5)
				{
					problem = ((part == Part.Railing) ? "Railings go along the edge of a floor" : "Walls stand on a foundation or a floor");
				}
				return true;
			}
			case Part.Steps:
			{
				Edge(f, at, num3, out var centre, out along, out var cellA, out var cellB);
				bool flag2 = Deck(cellA);
				bool flag3 = Deck(cellB);
				Vector3 val3 = cellB - cellA;
				val3.y = 0f;
				((Vector3)(ref val3)).Normalize();
				if (flag3 && !flag2)
				{
					val3 = -val3;
				}
				pos = centre;
				rot = Quaternion.LookRotation(val3, Vector3.up);
				if (At(Part.Steps, centre) != null)
				{
					problem = "There are steps here already";
					return true;
				}
				if (flag2 == flag3)
				{
					problem = (flag2 ? "Porch steps go on an outside edge" : "Porch steps go against the edge of a foundation");
				}
				else if (WallOn(centre) && !DoorOn(centre))
				{
					problem = "There's a wall in the way (use a wall with a door)";
				}
				return true;
			}
			case Part.Stairs:
			{
				Vector3 val5 = CellCentre(f, at, num3);
				Vector3 val6 = GridDir(f, forward, turns);
				Vector3 val7 = val5 + val6 * 2f;
				pos = val5;
				rot = Quaternion.LookRotation(val6, Vector3.up);
				if (At(Part.Stairs, val5) != null || At(Part.Stairs, val7) != null)
				{
					problem = "There are stairs here already";
					return true;
				}
				if (!Deck(val5))
				{
					problem = "Stairs stand on a foundation or a floor";
					return true;
				}
				if (WallOn(val5 + val6 * 1f))
				{
					problem = "A wall is in the way of the stairs";
					return true;
				}
				if (At(Part.Floor, val5 + Vector3.up * 3f) != null || At(Part.Floor, val7 + Vector3.up * 3f) != null)
				{
					problem = "Take up the floor above first, so the stairs have a way up";
				}
				return true;
			}
			case Part.Roof:
			{
				if (num2 < 1)
				{
					problem = "Look up: roofs go on top of the walls";
					return false;
				}
				Vector3 val = CellCentre(f, at, num3);
				Vector3 val2 = GridDir(f, forward, turns);
				float num4 = num3;
				Piece piece = RoofAt(val - val2 * 2f, num3, val2);
				if (piece != null)
				{
					num4 = piece.Pos.y + 1f;
				}
				pos = new Vector3(val.x, num4, val.z);
				rot = Quaternion.LookRotation(val2, Vector3.up);
				foreach (Piece piece3 in Pieces)
				{
					if (piece3.Kind == Part.Roof && Near(piece3.Pos, val, 0.3f, 3f) && piece3.Pos.y >= num3 - 0.1f)
					{
						problem = "There's a roof here already";
						return true;
					}
				}
				if (!RoofSupported(f, val, num3, num4, val2, piece != null))
				{
					problem = "Needs walls or a ceiling under it";
				}
				return true;
			}
			default:
				return false;
			}
		}

		private static bool DoorOn(Vector3 e)
		{
			//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)
			foreach (Piece piece in Pieces)
			{
				if (piece.Kind == Part.Wall && piece.P.Spec.Id == "hb_wall_door" && Near(piece.Pos, e))
				{
					return true;
				}
			}
			return false;
		}

		private static Piece RoofAt(Vector3 c, float plane, Vector3 dir)
		{
			//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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			foreach (Piece piece in Pieces)
			{
				if (piece.Kind == Part.Roof && Near(piece.Pos, c, 0.3f, 100f) && piece.Pos.y >= plane - 0.1f && Vector3.Dot(piece.Fwd, dir) > 0.9f)
				{
					return piece;
				}
			}
			return null;
		}

		private static IEnumerable<Vector3> Edges(Frame f, Vector3 c)
		{
			//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)
			yield return c + f.X * 1f;
			yield return c - f.X * 1f;
			yield return c + f.Z * 1f;
			yield return c - f.Z * 1f;
		}

		private static IEnumerable<Vector3> Neighbours(Frame f, Vector3 c)
		{
			//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)
			yield return c + f.X * 2f;
			yield return c - f.X * 2f;
			yield return c + f.Z * 2f;
			yield return c - f.Z * 2f;
		}

		private static bool FloorSupported(Frame f, Vector3 c, float y)
		{
			//IL_0001: 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_004a: 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)
			foreach (Vector3 item in Edges(f, c))
			{
				if (WallOn(item - Vector3.up * 3f))
				{
					return true;
				}
			}
			foreach (Vector3 item2 in Neighbours(f, c))
			{
				if (Deck(item2))
				{
					return true;
				}
			}
			return false;
		}

		private static bool RoofSupported(Frame f, Vector3 c, float y, float h, Vector3 dir, bool stacked)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			//IL_00a2: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			if (stacked)
			{
				return true;
			}
			if (Deck(c))
			{
				return true;
			}
			foreach (Vector3 item in Edges(f, c))
			{
				if (WallOn(item - Vector3.up * 3f))
				{
					return true;
				}
			}
			Vector3 val = Vector3.Cross(Vector3.up, dir);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3[] array = (Vector3[])(object)new Vector3[2]
			{
				c + normalized * 2f,
				c - normalized * 2f
			};
			foreach (Vector3 b in array)
			{
				foreach (Piece piece in Pieces)
				{
					if (piece.Kind == Part.Roof && Near(piece.Pos, b) && Mathf.Abs(piece.Pos.y - h) < 0.15f)
					{
						return true;
					}
				}
			}
			return false;
		}

		private static bool AimFoundation(Camera cam, Player player, bool hasHit, RaycastHit hit, out Vector3 pos, out Quaternion rot, out string problem)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: 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_0340: Unknown result type (might be due to invalid IL or missing references)
			pos = Vector3.zero;
			rot = Quaternion.identity;
			problem = null;
			Piece foundation;
			Frame f = FrameNear(hasHit ? ((RaycastHit)(ref hit)).point : ((Component)player).transform.position, out foundation);
			Vector3 val;
			if (foundation != null)
			{
				if (!OnPlane(cam, foundation.Pos.y, out var at))
				{
					if (!hasHit)
					{
						problem = "Aim at the ground next to your house";
						return false;
					}
					at = ((RaycastHit)(ref hit)).point;
				}
				val = CellCentre(f, at, foundation.Pos.y);
				Vector2 val2 = default(Vector2);
				((Vector2)(ref val2))..ctor(val.x - foundation.Pos.x, val.z - foundation.Pos.z);
				if (((Vector2)(ref val2)).magnitude > 24f)
				{
					foundation = null;
				}
			}
			else
			{
				val = Vector3.zero;
			}
			if (foundation == null)
			{
				if (!hasHit || ((RaycastHit)(ref hit)).normal.y < 0.6f)
				{
					problem = "Aim at the ground";
					return false;
				}
				Vector3 val3 = f.Local(((RaycastHit)(ref hit)).point);
				val = f.World(Mathf.Round(val3.x / 0.5f) * 0.5f, Mathf.Round(val3.z / 0.5f) * 0.5f, ((RaycastHit)(ref hit)).point.y);
			}
			float num = float.MaxValue;
			float num2 = float.MinValue;
			int num3 = 0;
			Vector2[] array = (Vector2[])(object)new Vector2[5]
			{
				Vector2.zero,
				new Vector2(-0.85f, -0.85f),
				new Vector2(0.85f, -0.85f),
				new Vector2(-0.85f, 0.85f),
				new Vector2(0.85f, 0.85f)
			};
			foreach (Vector2 val4 in array)
			{
				if (GroundAt(val + f.X * val4.x + f.Z * val4.y, val.y + 4f, player, out var y))
				{
					num = Mathf.Min(num, y);
					num2 = Mathf.Max(num2, y);
					num3++;
				}
			}
			if (num3 == 0)
			{
				problem = "Aim at the ground";
				return false;
			}
			float num4 = ((foundation != null && num2 < foundation.Pos.y + 2.5f && num2 > foundation.Pos.y - 3f) ? foundation.Pos.y : (Mathf.Round((num2 + 0.15f) * 20f) / 20f));
			pos = new Vector3(val.x, num4, val.z);
			rot = f.Rot;
			if (At(Part.Foundation, pos) != null)
			{
				problem = "There's a foundation here already";
				return true;
			}
			if (num2 > num4 + 0.05f)
			{
				problem = "The ground is too high here";
				return true;
			}
			if (num < num4 - 2.9f)
			{
				problem = "Too steep here";
				return true;
			}
			if (Blocked(pos + Vector3.up * 1.35f, new Vector3(0.9f, 1.2f, 0.9f), rot, player))
			{
				problem = "Something's in the way";
			}
			return true;
		}

		private static bool GroundAt(Vector3 p, float fromY, Player player, out float y)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			y = 0f;
			Il2CppStructArray<RaycastHit> val = Physics.RaycastAll(new Vector3(p.x, fromY, p.z), Vector3.down, 12f, -5, (QueryTriggerInteraction)1);
			bool result = false;
			float num = float.MaxValue;
			for (int i = 0; i < ((Il2CppArrayBase<RaycastHit>)(object)val).Length; i++)
			{
				RaycastHit val2 = ((Il2CppArrayBase<RaycastHit>)(object)val)[i];
				Collider collider = ((RaycastHit)(ref val2)).collider;
				if (!((Object)collider == (Object)null) && !Ours(collider) && !Placement.IsPropertyBounds(collider) && !IsTree(collider) && !((Component)collider).transform.IsChildOf(((Component)player).transform) && !((Object)((Component)collider).GetComponentInParent<NPC>() != (Object)null) && ((RaycastHit)(ref val2)).distance < num)
				{
					num = ((RaycastHit)(ref val2)).distance;
					y = ((RaycastHit)(ref val2)).point.y;
					result = true;
				}
			}
			return result;
		}

		private static bool IsTree(Collider c)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			Transform val = ((Component)c).transform;
			while ((Object)val != (Object)null)
			{
				string name = ((Object)val).name;
				if (name.StartsWith("Tree", StringComparison.OrdinalIgnoreCase) || name.Contains("InstanceWorldObject") || name.Contains("InstancedMapTrees"))
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		private static bool Ours(Collider c)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			Transform val = ((Component)c).transform;
			while ((Object)val != (Object)null)
			{
				string name = ((Object)val).name;
				if (name.StartsWith("HB_Placed_", StringComparison.Ordinal) || name.StartsWith("HB_Mirror_", StringComparison.Ordinal) || name == "HB_Ghost")
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		private static bool Blocked(Vector3 centre, Vector3 half, Quaternion rot, Player player)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			Il2CppReferenceArray<Collider> val = Physics.OverlapBox(centre, half, rot, -5, (QueryTriggerInteraction)1);
			for (int i = 0; i < ((Il2CppArrayBase<Collider>)(object)val).Length; i++)
			{
				Collider val2 = ((Il2CppArrayBase<Collider>)(object)val)[i];
				if (!((Object)val2 == (Object)null) && !val2.isTrigger && !Ours(val2) && !Placement.IsPropertyBounds(val2) && !IsTree(val2) && !((Component)val2).transform.IsChildOf(((Component)player).transform) && !(((MemberInfo)((Object)val2).GetIl2CppType()).Name == "TerrainCollider") && !((Object)((Component)val2).GetComponentInParent<NPC>() != (Object)null))
				{
					return true;
				}
			}
			return false;
		}

		public static void DevSample(Player player)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//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_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			Collect();
			Piece foundation;
			Frame f = FrameNear(((Component)player).transform.position, out foundation);
			if (foundation == null)
			{
				HouseCore.Log.Msg("Dev: lay a foundation first.");
				return;
			}
			float y0 = foundation.Pos.y;
			int num = 2;
			int num2 = 4;
			for (int i = num; i <= num2; i++)
			{
				for (int j = 0; j <= 1; j++)
				{
					Placement.DevPlace("hb_foundation", C(i, j, 0), f.Rot);
				}
			}
			for (int k = 0; k <= 1; k++)
			{
				for (int l = num; l <= num2; l++)
				{
					Placement.DevPlace((k == 0 && l == 3) ? "hb_wall_door" : ((l == 3) ? "hb_wall" : "hb_wall_window"), C(l, 0, k) - f.Z * 1f, Face(-f.Z));
					Placement.DevPlace((l == 3) ? "hb_wall_window" : "hb_wall", C(l, 1, k) + f.Z * 1f, Face(f.Z));
				}
				for (int m = 0; m <= 1; m++)
				{
					Placement.DevPlace((m == 0) ? "hb_wall_window" : "hb_wall", C(num, m, k) - f.X * 1f, Face(-f.X));
					Placement.DevPlace((m == 1) ? "hb_wall_window" : "hb_wall", C(num2, m, k) + f.X * 1f, Face(f.X));
				}
			}
			Placement.DevPlace("hb_stairs", C(3, 0, 0), Face(f.Z));
			for (int n = num; n <= num2; n++)
			{
				for (int num3 = 0; num3 <= 1; num3++)
				{
					if (n != 3)
					{
						Placement.DevPlace("hb_floor", C(n, num3, 1), f.Rot);
					}
					Placement.DevPlace("hb_floor", C(n, num3, 2), f.Rot);
				}
			}
			Placement.DevPlace("hb_railing", C(3, 0, 1) - f.X * 1f, Face(-f.X));
			Placement.DevPlace("hb_railing", C(3, 0, 1) + f.X * 1f, Face(f.X));
			for (int num4 = num; num4 <= num2; num4++)
			{
				Placement.DevPlace("hb_roof", C(num4, 0, 2), Face(f.Z));
				Placement.DevPlace("hb_roof", C(num4, 1, 2), Face(-f.Z));
			}
			Placement.DevPlace("hb_steps", C(3, 0, 0) - f.Z * 1f, Face(-f.Z));
			HouseCore.Log.Msg("Dev: sample house built.");
			Vector3 C(int num5, int num6, int lv)
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				return f.World((float)num5 * 2f, (float)num6 * 2f, y0 + (float)lv * 3f);
			}
			static Quaternion Face(Vector3 d)
			{
				//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_0006: Unknown result type (might be due to invalid IL or missing references)
				return Quaternion.LookRotation(d, Vector3.up);
			}
		}

		public static void Update()
		{
			try
			{
				if (_tidiedVersion != Placement.Version)
				{
					_tidiedVersion = Placement.Version;
					Collect();
					_seenVersion = Placement.Version;
					int num = 17;
					foreach (Piece piece in Pieces)
					{
						num = num * 31 + (int)piece.Kind * 7 + Mathf.RoundToInt(piece.Pos.x * 4f) * 73 + Mathf.RoundToInt(piece.Pos.y * 4f) * 37 + Mathf.RoundToInt(piece.Pos.z * 4f) * 19 + piece.P.Channel * 3 + Mathf.RoundToInt(piece.Fwd.x * 2f) + Mathf.RoundToInt(piece.Fwd.z * 2f) * 5;
					}
					if (num != _houseSig)
					{
						_houseSig = num;
						Tidy();
					}
				}
				SwingDoors();
			}
			catch (Exception ex)
			{
				HouseCore.Log.Warning("House: " + ex.Message);
				_tidiedVersion = Placement.Version;
			}
		}

		private static void Tidy()
		{
			//IL_008a: 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_00a3: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: 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_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: 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_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0418: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e9: Unknown result type (might be due to invalid IL or missing references)
			if (Pieces.Count == 0)
			{
				return;
			}
			Dictionary<long, List<(Piece, string, bool)>> dictionary = new Dictionary<long, List<(Piece, string, bool)>>();
			foreach (Piece piece5 in Pieces)
			{
				if (piece5.Kind != Part.Wall)
				{
					continue;
				}
				(string, float)[] array = new(string, float)[2]
				{
					("PostL", -1f),
					("PostR", 1f)
				};
				for (int i = 0; i < array.Length; i++)
				{
					(string, float) tuple = array[i];
					string item = tuple.Item1;
					float item2 = tuple.Item2;
					long key = Key(piece5.Pos + piece5.Right * (item2 * 2f * 0.5f));
					if (!dictionary.TryGetValue(key, out var value))
					{
						List<(Piece, string, bool)> list = (dictionary[key] = new List<(Piece, string, bool)>());
						value = list;
					}
					value.Add((piece5, item, Mathf.Abs(piece5.Right.x) > Mathf.Abs(piece5.Right.z)));
				}
				bool inside = Deck(piece5.Pos + piece5.Fwd * 1f) && Deck(piece5.Pos - piece5.Fwd * 1f);
				Paint(piece5.P, inside);
			}
			foreach (KeyValuePair<long, List<(Piece, string, bool)>> item5 in dictionary)
			{
				List<(Piece, string, bool)> value2 = item5.Value;
				bool flag = false;
				foreach (var item6 in value2)
				{
					if (item6.Item3 != value2[0].Item3)
					{
						flag = true;
					}
				}
				bool flag2 = value2.Count == 1 || flag;
				for (int j = 0; j < value2.Count; j++)
				{
					Transform val = Find(value2[j].Item1.P.Go.transform, value2[j].Item2);
					if ((Object)val != (Object)null)
					{
						((Component)val).gameObject.SetActive(flag2 && j == 0);
					}
				}
			}
			foreach (Piece piece6 in Pieces)
			{
				if (piece6.Kind != Part.Roof)
				{
					continue;
				}
				Piece piece = null;
				Piece piece2 = null;
				foreach (Piece piece7 in Pieces)
				{
					if (piece7.Kind == Part.Roof && piece7 != piece6)
					{
						if (Vector3.Dot(piece7.Fwd, piece6.Fwd) > 0.9f && Near(piece7.Pos, piece6.Pos - piece6.Fwd * 2f + Vector3.down * 1f))
						{
							piece = piece7;
						}
						if (Vector3.Dot(piece7.Fwd, piece6.Fwd) < -0.9f && Near(piece7.Pos, piece6.Pos + piece6.Fwd * 2f))
						{
							piece2 = piece7;
						}
					}
				}
				int num = 0;
				Piece piece3 = piece;
				while (piece3 != null && num < 3)
				{
					Piece piece4 = null;
					foreach (Piece piece8 in Pieces)
					{
						if (piece8.Kind == Part.Roof && piece8 != piece3 && Vector3.Dot(piece8.Fwd, piece3.Fwd) > 0.9f && Near(piece8.Pos, piece3.Pos - piece3.Fwd * 2f + Vector3.down * 1f))
						{
							piece4 = piece8;
							break;
						}
					}
					piece3 = piece4;
					num++;
				}
				num = Mathf.Min(num, 2);
				Transform transform = piece6.P.Go.transform;
				Show(transform, "Eave", piece == null);
				Show(transform, "Ridge", piece2 != null && (piece6.Pos.x < piece2.Pos.x - 0.01f || (Mathf.Abs(piece6.Pos.x - piece2.Pos.x) <= 0.01f && piece6.Pos.z < piece2.Pos.z)));
				(string, float)[] array2 = new(string, float)[2]
				{
					("L", -1f),
					("R", 1f)
				};
				for (int k = 0; k < array2.Length; k++)
				{
					(string, float) tuple2 = array2[k];
					string item3 = tuple2.Item1;
					float item4 = tuple2.Item2;
					bool flag3 = false;
					foreach (Piece piece9 in Pieces)
					{
						if (piece9.Kind == Part.Roof && piece9 != piece6 && Vector3.Dot(piece9.Fwd, piece6.Fwd) > 0.9f && Near(piece9.Pos, piece6.Pos + piece6.Right * (item4 * 2f)))
						{
							flag3 = true;
							break;
						}
					}
					for (int l = 0; l < 3; l++)
					{
						Show(transform, "Gable" + item3 + l, !flag3 && l == num);
					}
				}
			}
		}

		private static long Key(Vector3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			long num = Mathf.RoundToInt(p.x * 5f);
			long num2 = Mathf.RoundToInt(p.y * 5f);
			long num3 = Mathf.RoundToInt(p.z * 5f);
			return (num * 73856093) ^ (num2 * 19349663) ^ (num3 * 83492791);
		}

		private static void Show(Transform root, string name, bool on)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			string value = name + ".";
			foreach (var (text, val) in Parts(root).All)
			{
				if ((text == name || text.StartsWith(value, StringComparison.Ordinal)) && (Object)val != (Object)null && ((Component)val).gameObject.activeSelf != on)
				{
					((Component)val).gameObject.SetActive(on);
				}
			}
		}

		private static void Paint(Placement.Placed p, bool inside)
		{
			//IL_0089: 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_0013: Expected O, but got Unknown
			//IL_00be: 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_00ce: Expected O, but got Unknown
			//IL_00ce: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Expected O, but got Unknown
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Expected O, but got Unknown
			//IL_01dc: Expected O, but got Unknown
			Material val;
			if (inside)
			{
				if ((Object)_drywall == (Object)null)
				{
					_drywall = Models.Mat("house_siding_inside", new Color(0.88f, 0.86f, 0.81f), 0f, 0.1f);
				}
				val = _drywall;
			}
			else
			{
				int num = (p.Channel % Paints.Length + Paints.Length) % Paints.Length;
				val = Models.Mat("house_siding_" + num, Paints[num], 0f, 0.25f);
			}
			PartsOf partsOf = Parts(p.Go.transform);
			if ((Object)partsOf.Painted == (Object)val)
			{
				return;
			}
			if (partsOf.Siding == null)
			{
				List<MeshRenderer> list = new List<MeshRenderer>();
				foreach (MeshRenderer componentsInChild in p.Go.GetComponentsInChildren<MeshRenderer>(true))
				{
					string name = ((Object)((Component)componentsInChild).transform).name;
					if (!name.StartsWith("Post", StringComparison.Ordinal) && !name.StartsWith("DoorLeaf", StringComparison.Ordinal))
					{
						list.Add(componentsInChild);
					}
				}
				partsOf.Siding = list.ToArray();
			}
			partsOf.Painted = val;
			MeshRenderer[] siding = partsOf.Siding;
			foreach (MeshRenderer val2 in siding)
			{
				if ((Object)val2 == (Object)null)
				{
					continue;
				}
				Il2CppReferenceArray<Material> sharedMaterials = ((Renderer)val2).sharedMaterials;
				bool flag = false;
				for (int j = 0; j < ((Il2CppArrayBase<Material>)(object)sharedMaterials).Length; j++)
				{
					Material val3 = ((Il2CppArrayBase<Material>)(object)sharedMaterials)[j];
					if (!((Object)val3 == (Object)null) && ((Object)val3).name.Contains("siding") && !((Object)val3 == (Object)val))
					{
						((Il2CppArrayBase<Material>)(object)sharedMaterials)[j] = val;
						flag = true;
					}
				}
				if (flag)
				{
					((Renderer)val2).sharedMaterials = sharedMaterials;
				}
			}
		}

		private static void SwingDoors()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d6: Unknown result type (might be due to invalid IL or missing references)
			foreach (Piece piece in Pieces)
			{
				if (piece.Kind != Part.Wall || piece.P.Spec.Id != "hb_wall_door" || (Object)piece.P.Go == (Object)null)
				{
					continue;
				}
				Transform val = Find(piece.P.Go.transform, "DoorPivot");
				if (!((Object)val == (Object)null))
				{
					Quaternion val2 = Quaternion.Euler(0f, piece.P.Closed ? (-100f) : 0f, 0f);
					if (Quaternion.Angle(val.localRotation, val2) > 0.5f)
					{
						val.localRotation = Quaternion.RotateTowards(val.localRotation, val2, 220f * Time.deltaTime);
					}
				}
			}
		}

		public static bool TryUse(Placement.Placed target, out string hint)
		{
			//IL_003e: 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_0158: 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)
			hint = null;
			Part part = PartOf(target.Spec.Id);
			if (part == Part.None)
			{
				return false;
			}
			string text = "[Hold Right Click] Pick up";
			if (part == Part.Wall)
			{
				string text2 = $"[{HouseCore.PaintKey}] Paint ({PaintNames[(target.Channel % Paints.Length + Paints.Length) % Paints.Length]})";
				if (target.Spec.Id == "hb_wall_door")
				{
					hint = $"[{FortifyApi.UseKey}] {(target.Closed ? "Close" : "Open")} the door    {text2}    {text}";
					if (FortifyApi.KeyDown(FortifyApi.UseKey))
					{
						target.Closed = !target.Closed;
						Placement.UpdateRecord(target);
					}
				}
				else
				{
					hint = text2 + "    " + text;
				}
				if (FortifyApi.KeyDown(HouseCore.PaintKey))
				{
					target.Channel = (target.Channel + 1) % Paints.Length;
					Placement.UpdateRecord(target);
					Placement.Version++;
				}
				return true;
			}
			hint = text;
			return true;
		}
	}
	internal static class Catalog
	{
		public static readonly List<ItemSpec> Items = new List<ItemSpec>
		{
			new ItemSpec
			{
				Id = "hb_foundation",
				Name = "Foundation",
				Model = "Foundation",
				Price = 60f,
				RotateStep = 0f,
				IconColor = new Color(0.6f, 0.6f, 0.58f),
				Description = "A 2 x 2 m concrete foundation, the start of a house. Lay them side by side and they stay level with each other, with the footings going down into the ground on a slope. Your first one sets the grid for the whole house."
			},
			new ItemSpec
			{
				Id = "hb_wall",
				Name = "House Wall",
				Model = "Wall",
				Price = 50f,
				RotateStep = 180f,
				IconColor = new Color(0.8f, 0.8f, 0.76f),
				Description = "A 2 m wall, 3 m tall, with lap siding outside and drywall inside. Aim at the edge of a foundation or floor. Corners tidy themselves up and walls inside the house get drywall on both sides. P paints the siding."
			},
			new ItemSpec
			{
				Id = "hb_wall_door",
				Name = "House Wall with Door",
				Model = "WallDoor",
				Price = 120f,
				RotateStep = 180f,
				IconColor = new Color(0.36f, 0.13f, 0.1f),
				Description = "A 2 m house wall with a panelled front door. E opens and closes it, P paints the siding."
			},
			new ItemSpec
			{
				Id = "hb_wall_window",
				Name = "House Wall with Window",
				Model = "WallWindow",
				Price = 80f,
				RotateStep = 180f,
				IconColor = new Color(0.42f, 0.55f, 0.62f),
				Description = "A 2 m house wall with a four-pane window and a sill. P paints the siding."
			},
			new ItemSpec
			{
				Id = "hb_floor",
				Name = "Floor / Ceiling",
				Model = "Floor",
				Price = 40f,
				RotateStep = 90f,
				IconColor = new Color(0.56f, 0.38f, 0.22f),
				Description = "A 2 x 2 m wooden floor with a white ceiling underneath. Look up from inside to put in a ceiling: it's the floor of the next storey up. Leave the space over your stairs open."
			},
			new ItemSpec
			{
				Id = "hb_stairs",
				Name = "Staircase",
				Model = "Stairs",
				Price = 150f,
				StackLimit = 20,
				IconColor = new Color(0.52f, 0.35f, 0.21f),
				Description = "A wooden staircase with handrails, 2 m wide and 4 m long, up one storey. Place it on a floor facing the way you want to climb; the floor above it stays open."
			},
			new ItemSpec
			{
				Id = "hb_steps",
				Name = "Porch Steps",
				Model = "Steps",
				Price = 40f,
				RotateStep = 0f,
				StackLimit = 20,
				IconColor = new Color(0.6f, 0.6f, 0.58f),
				Description = "Concrete steps from the ground up to your foundation. Aim at an outside edge, in front of a door."
			},
			new ItemSpec
			{
				Id = "hb_railing",
				Name = "Railing",
				Model = "Railing",
				Price = 30f,
				RotateStep = 180f,
				IconColor = new Color(0.93f, 0.93f, 0.91f),
				Description = "A 2 m white railing for balconies, landings and round the stairs."
			},
			new ItemSpec
			{
				Id = "hb_roof",
				Name = "Roof",
				Model = "Roof",
				Price = 45f,
				IconColor = new Color(0.2f, 0.21f, 0.23f),
				Description = "A 2 x 2 m pitched roof section with shingles. Look up at the top of your walls; R turns which way it slopes. Put two facing each other for a gable roof, line them up for a long one, and step them up for a wide house. Eaves, the ridge cap and the gable ends fit themselves."
			}
		};

		private static readonly Dictionary<string, ItemSpec> ById = new Dictionary<string, ItemSpec>(StringComparer.OrdinalIgnoreCase);

		public static ItemSpec Get(string id)
		{
			if (string.IsNullOrEmpty(id))
			{
				return null;
			}
			if (ById.Count == 0)
			{
				foreach (ItemSpec item in Items)
				{
					ById[item.Id] = item;
				}
			}
			if (!ById.TryGetValue(id, out var value))
			{
				return null;
			}
			return value;
		}

		public static void BuildTemplates()
		{
			foreach (ItemSpec item in Items)
			{
				if ((Object)(object)item.Template == (Object)null)
				{
					item.Template = Building.Model(item.Model);
				}
			}
		}
	}
	internal static class CoopMirror
	{
		private sealed class Shown
		{
			public string Payload;

			public readonly List<Placement.Placed> Pieces = new List<Placement.Placed>();
		}

		private const string Key = "hb_pieces";

		private const int Chunk = 3500;

		private const int MaxChunks = 24;

		private static readonly Dictionary<ulong, Shown> Views = new Dictionary<ulong, Shown>();

		private static readonly List<Placement.Placed> AllMirrors = new List<Placement.Placed>();

		private static string _published;

		private static int _publishedChunks;

		private static float _nextBuild;

		private static float _nextView;

		public static List<Placement.Placed> All => AllMirrors;

		private static bool InLobby(out CSteamID lobby, out int members)
		{
			//IL_0001: 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_0043: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			lobby = default(CSteamID);
			members = 0;
			try
			{
				Lobby instance = Singleton<Lobby>.Instance;
				if ((Object)(object)instance == (Object)null || !instance.IsInLobby || instance.LobbyID == 0L)
				{
					return false;
				}
				lobby = new CSteamID
				{
					m_SteamID = instance.LobbyID
				};
				members = SteamMatchmaking.GetNumLobbyMembers(lobby);
				return members > 1;
			}
			catch
			{
				return false;
			}
		}

		public static void Update()
		{
			//IL_006c: 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)
			if (!InLobby(out var lobby, out var members))
			{
				if (Views.Count > 0)
				{
					Clear();
				}
				_published = null;
				return;
			}
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime >= _nextBuild)
			{
				_nextBuild = unscaledTime + 1f;
				string text = Build();
				if (text != _published)
				{
					Publish(lobby, text);
				}
			}
			if (unscaledTime >= _nextView)
			{
				_nextView = unscaledTime + 1f;
				Refresh(lobby, members);
			}
		}

		public static void Reset()
		{
			Clear();
			_published = null;
			_publishedChunks = 0;
			_nextBuild = (_nextView = 0f);
		}

		private static string Build()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0094: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			StringBuilder stringBuilder = new StringBuilder();
			foreach (Placement.Placed item in Placement.All)
			{
				try
				{
					if (item != null && !((Object)(object)item.Go == (Object)null) && item.Spec != null && !((Object)(object)item.Spec.Template == (Object)null))
					{
						Transform transform = item.Go.transform;
						Vector3 position = transform.position;
						Quaternion rotation = transform.rotation;
						if (stringBuilder.Length > 0)
						{
							stringBuilder.Append('~');
						}
						stringBuilder.Append(item.Spec.Id).Append(';');
						Num(stringBuilder, position.x, 3);
						stringBuilder.Append(',');
						Num(stringBuilder, position.y, 3);
						stringBuilder.Append(',');
						Num(stringBuilder, position.z, 3);
						stringBuilder.Append(';');
						Num(stringBuilder, rotation.x, 4);
						stringBuilder.Append(',');
						Num(stringBuilder, rotation.y, 4);
						stringBuilder.Append(',');
						Num(stringBuilder, rotation.z, 4);
						stringBuilder.Append(',');
						Num(stringBuilder, rotation.w, 4);
						stringBuilder.Append(';');
						stringBuilder.Append(item.Closed ? '1' : '0').Append(';').Append(item.Channel.ToString(CultureInfo.InvariantCulture));
					}
				}
				catch
				{
				}
			}
			return stringBuilder.ToString();
		}

		private static void Publish(CSteamID lobby, string payload)
		{
			//IL_002b: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int num = ((payload.Length != 0) ? Math.Min(24, (payload.Length + 3500 - 1) / 3500) : 0);
				for (int i = 0; i < num; i++)
				{
					SteamMatchmaking.SetLobbyMemberData(lobby, "hb_pieces_" + i, payload.Substring(i * 3500, Math.Min(3500, payload.Length - i * 3500)));
				}
				for (int j = num; j < _publishedChunks; j++)
				{
					SteamMatchmaking.SetLobbyMemberData(lobby, "hb_pieces_" + j, "");
				}
				SteamMatchmaking.SetLobbyMemberData(lobby, "hb_pieces_n", num.ToString(CultureInfo.InvariantCulture) + "|" + Math.Min(payload.Length, num * 3500).ToString(CultureInfo.InvariantCulture));
				_publishedChunks = num;
				_published = payload;
			}
			catch
			{
			}
		}

		private static void Refresh(CSteamID lobby, int members)
		{
			//IL_0003: 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_0027: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_005e: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			ulong num = 0uL;
			try
			{
				num = SteamUser.GetSteamID().m_SteamID;
			}
			catch
			{
			}
			HashSet<ulong> hashSet = new HashSet<ulong>();
			bool flag = false;
			for (int i = 0; i < members; i++)
			{
				CSteamID lobbyMemberByIndex;
				try
				{
					lobbyMemberByIndex = SteamMatchmaking.GetLobbyMemberByIndex(lobby, i);
				}
				catch
				{
					continue;
				}
				if (lobbyMemberByIndex.m_SteamID == num || lobbyMemberByIndex.m_SteamID == 0L)
				{
					continue;
				}
				hashSet.Add(lobbyMemberByIndex.m_SteamID);
				string lobbyMemberData = SteamMatchmaking.GetLobbyMemberData(lobby, lobbyMemberByIndex, "hb_pieces_n");
				if (string.IsNullOrEmpty(lobbyMemberData))
				{
					continue;
				}
				string[] array = lobbyMemberData.Split('|');
				if (array.Length < 2 || !int.TryParse(array[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) || !int.TryParse(array[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2) || result < 0 || result > 24)
				{
					continue;
				}
				StringBuilder stringBuilder = new StringBuilder();
				for (int j = 0; j < result; j++)
				{
					stringBuilder.Append(SteamMatchmaking.GetLobbyMemberData(lobby, lobbyMemberByIndex, "hb_pieces_" + j) ?? "");
				}
				string text = stringBuilder.ToString();
				if (text.Length == result2 && (!Views.TryGetValue(lobbyMemberByIndex.m_SteamID, out var value) || !(value.Payload == text)))
				{
					if (value != null)
					{
						Destroy(value);
					}
					value = new Shown
					{
						Payload = text
					};
					Views[lobbyMemberByIndex.m_SteamID] = value;
					Spawn(value, text);
					flag = true;
				}
			}
			List<ulong> list = new List<ulong>();
			foreach (KeyValuePair<ulong, Shown> view in Views)
			{
				if (!hashSet.Contains(view.Key))
				{
					list.Add(view.Key);
				}
			}
			foreach (ulong item in list)
			{
				Destroy(Views[item]);
				Views.Remove(item);
				flag = true;
			}
			if (flag)
			{
				Rebuild();
			}
		}

		private static void Spawn(Shown shown, string payload)
		{
			//IL_0093: 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)
			if (string.IsNullOrEmpty(payload))
			{
				return;
			}
			string[] array = payload.Split('~');
			foreach (string text in array)
			{
				try
				{
					string[] array2 = text.Split(';');
					if (array2.Length >= 3)
					{
						ItemSpec itemSpec = Catalog.Get(array2[0]);
						if (itemSpec != null && !((Object)(object)itemSpec.Template == (Object)null))
						{
							GameObject val = Object.Instantiate<GameObject>(itemSpec.Template);
							((Object)val).name = "HB_Mirror_" + itemSpec.Id;
							val.transform.SetParent((Transform)null, false);
							val.transform.SetPositionAndRotation(Vec(array2[1]), Rot(array2[2]));
							val.SetActive(true);
							int result;
							Placement.Placed item = new Placement.Placed
							{
								Go = val,
								Spec = itemSpec,
								Closed = (array2.Length > 3 && array2[3] == "1"),
								Channel = ((array2.Length > 4 && int.TryParse(array2[4], NumberStyles.Integer, CultureInfo.InvariantCulture, out result)) ? result : 0),
								Mirror = true
							};
							shown.Pieces.Add(item);
						}
					}
				}
				catch
				{
				}
			}
		}

		private static void Rebuild()
		{
			AllMirrors.Clear();
			foreach (Shown value in Views.Values)
			{
				AllMirrors.AddRange(value.Pieces);
			}
			Placement.Version++;
		}

		private static void Num(StringBuilder sb, float v, int dp)
		{
			sb.Append(Math.Round(v, dp).ToString(CultureInfo.InvariantCulture));
		}

		private static Vector3 Vec(string s)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			string[] a = s.Split(',');
			return new Vector3(P(a, 0), P(a, 1), P(a, 2));
		}

		private static Quaternion Rot(string s)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0048: Unknown result type (might be due to invalid IL or missing