Decompiled source of PerkinsTent v0.1.1

BepInEx/plugins/PocketTent/PocketTent.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("PocketTent")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("PocketTent")]
[assembly: AssemblyTitle("PocketTent")]
[assembly: AssemblyVersion("0.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PocketTent
{
	public static class BundleModel
	{
		private static Material Make(Color color)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(((Renderer)PrefabManager.Instance.GetPrefab("wood_floor").GetComponentInChildren<MeshRenderer>()).sharedMaterial);
			val.mainTexture = (Texture)(object)Texture2D.whiteTexture;
			val.color = color;
			if (val.HasProperty("_BumpMap"))
			{
				val.SetTexture("_BumpMap", (Texture)null);
			}
			val.DisableKeyword("_NORMALMAP");
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", 0.08f);
			}
			return val;
		}

		private static void Rod(Transform root, string name, Vector3 a, Vector3 b, float diameter, Material mat)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0043: 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)
			//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_0069: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)obj).name = name;
			obj.transform.SetParent(root, false);
			obj.transform.localPosition = (a + b) * 0.5f;
			obj.transform.localRotation = Quaternion.FromToRotation(Vector3.up, b - a);
			obj.transform.localScale = new Vector3(diameter, Vector3.Distance(a, b) * 0.5f, diameter);
			Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>());
			obj.GetComponent<Renderer>().sharedMaterial = mat;
		}

		private static void Ring(Transform root, string name, float radius, float width, float z, Material mat)
		{
			//IL_0057: 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_00a3: 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)
			List<Vector3> list = new List<Vector3>();
			List<int> list2 = new List<int>();
			for (int i = 0; i < 16; i++)
			{
				float num = (float)i * (float)Math.PI / 8f;
				float num2 = (float)(i + 1) * (float)Math.PI / 8f;
				int count = list.Count;
				list.Add(new Vector3(Mathf.Cos(num) * radius, Mathf.Sin(num) * radius, z - width * 0.5f));
				list.Add(new Vector3(Mathf.Cos(num2) * radius, Mathf.Sin(num2) * radius, z - width * 0.5f));
				list.Add(new Vector3(Mathf.Cos(num) * radius, Mathf.Sin(num) * radius, z + width * 0.5f));
				list.Add(new Vector3(Mathf.Cos(num2) * radius, Mathf.Sin(num2) * radius, z + width * 0.5f));
				list2.AddRange(new int[12]
				{
					count,
					count + 2,
					count + 1,
					count + 1,
					count + 2,
					count + 3,
					count + 1,
					count + 2,
					count,
					count + 3,
					count + 2,
					count + 1
				});
			}
			MeshObject(root, name, list, list2, mat);
		}

		private static void MeshObject(Transform root, string name, List<Vector3> v, List<int> t, Material mat)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.transform.SetParent(root, false);
			Mesh val2 = new Mesh();
			List<Vector3> list = new List<Vector3>();
			List<int> list2 = new List<int>();
			foreach (int item in t)
			{
				list2.Add(list.Count);
				list.Add(v[item]);
			}
			val2.SetVertices(list);
			val2.SetTriangles(list2, 0);
			val2.RecalculateNormals();
			val2.RecalculateBounds();
			val.AddComponent<MeshFilter>().sharedMesh = val2;
			((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = mat;
		}

		public static void Build(GameObject prefab)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: 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_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: 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_0592: 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_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ce: 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_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_05df: 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_05f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_0643: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_0669: Unknown result type (might be due to invalid IL or missing references)
			//IL_0674: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: 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)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0773: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			Collider[] componentsInChildren2 = prefab.GetComponentsInChildren<Collider>(true);
			foreach (Collider val in componentsInChildren2)
			{
				if (!val.isTrigger)
				{
					val.enabled = false;
				}
			}
			GameObject val2 = new GameObject("Rolled tent bundle");
			val2.transform.SetParent(prefab.transform, false);
			val2.transform.localPosition = new Vector3(0f, 0.28f, 0f);
			Transform transform = val2.transform;
			Material val3 = Make(new Color(0.6f, 0.42f, 0.24f));
			Material val4 = Make(new Color(0.74f, 0.55f, 0.33f));
			Material mat = Make(new Color(0.25f, 0.1f, 0.045f));
			Material mat2 = Make(new Color(0.2f, 0.22f, 0.23f));
			Material mat3 = Make(new Color(0.48f, 0.46f, 0.4f));
			Material mat4 = Make(new Color(0.62f, 0.44f, 0.2f));
			for (int j = 0; j < 16; j++)
			{
				List<Vector3> list = new List<Vector3>();
				List<int> list2 = new List<int>();
				for (int k = 0; k < 5; k++)
				{
					float num = (float)k / 4f;
					for (int l = 0; l < 2; l++)
					{
						float num2 = (float)(j + l) * (float)Math.PI / 8f;
						float num3 = 0.24f + 0.018f * Mathf.Sin(num * (float)Math.PI) + 0.006f * Mathf.Sin(num2 * 3f + (float)k);
						list.Add(new Vector3(Mathf.Cos(num2) * num3, Mathf.Sin(num2) * num3, Mathf.Lerp(-0.52f, 0.52f, num)));
					}
					if (k > 0)
					{
						int num4 = k * 2;
						list2.AddRange(new int[6]
						{
							num4 - 2,
							num4 - 1,
							num4,
							num4 - 1,
							num4 + 1,
							num4
						});
					}
				}
				MeshObject(transform, "Folded hide panel", list, list2, (j % 3 == 0) ? val4 : val3);
			}
			int[] array = new int[2] { -1, 1 };
			foreach (int num5 in array)
			{
				Rod(transform, "Dark rolled end", new Vector3(0f, 0f, (float)num5 * 0.5f), new Vector3(0f, 0f, (float)num5 * 0.515f), 0.47f, mat);
				List<Vector3> list3 = new List<Vector3>();
				List<int> list4 = new List<int>();
				for (int m = 0; m <= 96; m++)
				{
					float num6 = (float)m / 96f;
					float num7 = num6 * (float)Math.PI * 5f;
					float num8 = 0.025f + 0.2f * num6;
					list3.Add(new Vector3(Mathf.Cos(num7) * num8, Mathf.Sin(num7) * num8, (float)num5 * 0.53f));
					list3.Add(new Vector3(Mathf.Cos(num7) * (num8 + 0.026f), Mathf.Sin(num7) * (num8 + 0.026f), (float)num5 * 0.53f));
					if (m > 0)
					{
						int num9 = m * 2;
						list4.AddRange(new int[12]
						{
							num9 - 2,
							num9,
							num9 - 1,
							num9 - 1,
							num9,
							num9 + 1,
							num9 - 1,
							num9,
							num9 - 2,
							num9 + 1,
							num9,
							num9 - 1
						});
					}
				}
				MeshObject(transform, "Spiral of rolled leather", list3, list4, val4);
			}
			float[] array2 = new float[2] { -0.31f, 0.31f };
			foreach (float num10 in array2)
			{
				Ring(transform, "Wide leather strap", 0.272f, 0.1f, num10, mat);
				float[] array3 = new float[2] { -0.065f, 0.065f };
				foreach (float num11 in array3)
				{
					Rod(transform, "Buckle edge", new Vector3(0.278f, -0.065f, num10 + num11), new Vector3(0.278f, 0.065f, num10 + num11), 0.018f, mat3);
				}
				array3 = new float[2] { -0.065f, 0.065f };
				foreach (float num12 in array3)
				{
					Rod(transform, "Buckle edge", new Vector3(0.278f, num12, num10 - 0.065f), new Vector3(0.278f, num12, num10 + 0.065f), 0.018f, mat3);
				}
				Rod(transform, "Buckle tongue", new Vector3(0.285f, 0f, num10 - 0.06f), new Vector3(0.285f, 0f, num10 + 0.025f), 0.012f, mat2);
			}
			Vector3 val5 = default(Vector3);
			for (int num13 = 0; num13 < 3; num13++)
			{
				((Vector3)(ref val5))..ctor(0.25f, -0.13f + (float)num13 * 0.075f, 0f);
				Rod(transform, "Iron tent peg", val5 + Vector3.back * 0.5f, val5 + Vector3.forward * 0.53f, 0.05f, mat2);
				Rod(transform, "Peg hooked head", val5 + Vector3.forward * 0.53f, val5 + new Vector3(0.07f, 0f, 0.53f), 0.05f, mat2);
				List<Vector3> v = new List<Vector3>
				{
					val5 + new Vector3(-0.025f, -0.025f, -0.5f),
					val5 + new Vector3(0.025f, -0.025f, -0.5f),
					val5 + new Vector3(0.025f, 0.025f, -0.5f),
					val5 + new Vector3(-0.025f, 0.025f, -0.5f),
					val5 + new Vector3(0f, 0f, -0.65f)
				};
				MeshObject(transform, "Pointed iron peg", v, new List<int>
				{
					0, 4, 1, 1, 4, 2, 2, 4, 3, 3,
					4, 0
				}, mat3);
			}
			int loop;
			for (loop = 0; loop < 3; loop++)
			{
				for (int num14 = 0; num14 < 18; num14++)
				{
					float angle = (float)num14 * (float)Math.PI / 9f;
					float angle2 = (float)(num14 + 1) * (float)Math.PI / 9f;
					Rod(transform, "Coiled hemp rope", P(angle), P(angle2), 0.028f, mat4);
				}
			}
			BoxCollider obj = prefab.AddComponent<BoxCollider>();
			obj.center = new Vector3(0.03f, 0.28f, -0.05f);
			obj.size = new Vector3(0.65f, 0.56f, 1.2f);
			Vector3 P(float num15)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				return new Vector3(0.19f + Mathf.Cos(num15) * 0.12f, -0.08f + Mathf.Sin(num15) * 0.13f, 0.25f + (float)loop * 0.03f);
			}
		}
	}
	public static class Client
	{
		public static ItemData? PendingCloth;

		public static string Id = "";

		public static Vector3? Back;

		public static Vector3 Origin;

		private static GameObject? room;

		private static float next;

		private static Vector3? landing;

		private static float landingStarted;

		private const string Recovery = "branchofyore.pockettent.recovery";

		public static bool PlacementPending => PendingCloth != null;

		public static bool InsideRoom
		{
			get
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: 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_0055: 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_0074: Unknown result type (might be due to invalid IL or missing references)
				Player localPlayer = Player.m_localPlayer;
				if (!Object.op_Implicit((Object)(object)room) || !Object.op_Implicit((Object)(object)localPlayer) || Id == "")
				{
					return false;
				}
				Vector3 val = ((Component)localPlayer).transform.position - Origin;
				if (Mathf.Abs(val.x) < 8.2f && Mathf.Abs(val.z) < 10.2f && val.y > -0.5f)
				{
					return val.y < 7f;
				}
				return false;
			}
		}

		public static bool Travelling => landing.HasValue;

		public static void Receive(long sender, ZPackage pkg)
		{
			//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_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_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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: 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_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			if (sender != Network.ServerId)
			{
				return;
			}
			int num = pkg.ReadInt();
			string text = pkg.ReadString();
			Vector3 val = pkg.ReadVector3();
			Vector3 val2 = pkg.ReadVector3();
			string text2 = pkg.ReadString();
			if (text2.Length > 0)
			{
				Plugin.Message(text2);
			}
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				return;
			}
			switch (num)
			{
			case 9:
			case 10:
			{
				if (!(Vector3.Distance(((Component)localPlayer).transform.position, val) < 80f))
				{
					return;
				}
				GameObject prefab = ZNetScene.instance.GetPrefab("wood_floor");
				if (!Object.op_Implicit((Object)(object)prefab))
				{
					return;
				}
				if (num == 10)
				{
					Piece component = prefab.GetComponent<Piece>();
					if (component != null)
					{
						component.m_placeEffect.Create(val, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
					}
				}
				else
				{
					WearNTear component2 = prefab.GetComponent<WearNTear>();
					if (component2 != null)
					{
						component2.m_destroyedEffect.Create(val + Vector3.up * 0.7f, Quaternion.identity, (Transform)null, 1.5f, -1, default(ZDOID));
					}
				}
				return;
			}
			case 0:
			case 7:
			{
				if (PendingCloth != null && PendingCloth.m_customData.TryGetValue("branchofyore.pockettent.id", out var value) && value == text)
				{
					if (num == 7)
					{
						((Humanoid)localPlayer).GetInventory().RemoveItem(PendingCloth);
					}
					PendingCloth = null;
				}
				break;
			}
			}
			if (num == 1 || num == 12)
			{
				Vector3 at = ((num == 12) ? ((Component)localPlayer).transform.position : (val + new Vector3(0f, 0.3f, -7f)));
				Clear();
				Id = text;
				Back = val2;
				Origin = val;
				room = Visual.Room(val);
				localPlayer.m_customData["branchofyore.pockettent.recovery"] = string.Join("|", val2.x.ToString(CultureInfo.InvariantCulture), val2.y.ToString(CultureInfo.InvariantCulture), val2.z.ToString(CultureInfo.InvariantCulture));
				Land(localPlayer, at);
			}
			if (num == 2 && Id == text)
			{
				Back = val2;
				Land(localPlayer, val2);
			}
		}

		public static void Tick()
		{
			//IL_0021: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				return;
			}
			if (landing.HasValue)
			{
				Move(localPlayer, landing.Value);
				if (Time.unscaledTime - landingStarted > 2f && (Network.InRoomBand(landing.Value) || ZoneSystem.instance.IsZoneLoaded(ZoneSystem.GetZone(landing.Value))))
				{
					landing = null;
				}
				return;
			}
			if (Object.op_Implicit((Object)(object)room) && !((Character)localPlayer).IsTeleporting() && !Network.InRoomBand(((Component)localPlayer).transform.position) && Vector3.Distance(((Component)localPlayer).transform.position, (Vector3)(((??)Back) ?? ((Component)localPlayer).transform.position)) < 2f)
			{
				Network.Send(5, Id);
				Clear();
				localPlayer.m_customData.Remove("branchofyore.pockettent.recovery");
			}
			if (Object.op_Implicit((Object)(object)room) && Time.unscaledTime > next)
			{
				next = Time.unscaledTime + 2f;
				Network.Send(4, Id);
			}
		}

		public static void Recover(Player p)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if (Network.InRoomBand(((Component)p).transform.position))
			{
				PlayerProfile playerProfile = Game.instance.GetPlayerProfile();
				ZDO val = Network.FindRoomAt(((Component)p).transform.position);
				if (playerProfile.HaveCustomSpawnPoint() && Vector3.Distance(playerProfile.GetCustomSpawnPoint(), ((Component)p).transform.position) < 5f && val != null && val.GetBool("deployed", false))
				{
					Clear();
					Id = val.GetString("branchofyore.pockettent.id", "");
					Origin = val.GetPosition();
					Back = val.GetVec3("entrance", Vector3.zero);
					room = Visual.Room(Origin);
					Network.Send(11, Id);
					return;
				}
			}
			if (p.m_customData.TryGetValue("branchofyore.pockettent.recovery", out var value))
			{
				string[] array = value.Split(new char[1] { '|' });
				Vector3? val2 = null;
				if (array.Length == 3 && Network.InRoomBand(((Component)p).transform.position))
				{
					val2 = new Vector3(float.Parse(array[0], CultureInfo.InvariantCulture), float.Parse(array[1], CultureInfo.InvariantCulture), float.Parse(array[2], CultureInfo.InvariantCulture));
				}
				p.m_customData.Remove("branchofyore.pockettent.recovery");
				Clear();
				if (val2.HasValue)
				{
					Land(p, val2.Value);
				}
			}
		}

		private static void Land(Player p, Vector3 at)
		{
			//IL_0000: 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)
			landing = at;
			landingStarted = Time.unscaledTime;
			Move(p, at);
		}

		private static void Move(Player p, Vector3 at)
		{
			//IL_0006: 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_0019: 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_0049: 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)
			((Component)p).transform.position = at;
			Rigidbody component = ((Component)p).GetComponent<Rigidbody>();
			component.position = at;
			component.linearVelocity = Vector3.zero;
			((Component)p).GetComponent<ZNetView>().GetZDO().SetPosition(at);
			AccessTools.Field(typeof(Character), "m_maxAirAltitude").SetValue(p, at.y);
			ZNet.instance.SetReferencePosition(at);
			Physics.SyncTransforms();
		}

		public static void Clear()
		{
			InteriorClimate.Clear();
			if (Object.op_Implicit((Object)(object)room))
			{
				Object.Destroy((Object)(object)room);
			}
			room = null;
			Id = "";
			Back = null;
			landing = null;
		}
	}
	public static class InteriorClimate
	{
		[HarmonyPatch(typeof(Player), "UpdateBreathParticles")]
		private static class NoColdBreath
		{
			private static bool Prefix(Player __instance)
			{
				if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || !Client.InsideRoom)
				{
					return true;
				}
				if (Object.op_Implicit((Object)(object)__instance.m_breathParticles))
				{
					__instance.m_breathParticles.Stop(true, (ParticleSystemStopBehavior)0);
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(AudioMan), "UpdateWindAmbience")]
		private static class NoIndoorWind
		{
			private static bool Prefix(AudioMan __instance)
			{
				return Silence(__instance, "m_windLoopSource");
			}
		}

		[HarmonyPatch(typeof(AudioMan), "UpdateOceanAmbiance")]
		private static class NoIndoorOcean
		{
			private static bool Prefix(AudioMan __instance)
			{
				return Silence(__instance, "m_oceanAmbientSource");
			}
		}

		private const string Name = "PocketTentWarmInterior";

		private static EnvMan? active;

		private static string previous = "";

		private static readonly FieldInfo Force = AccessTools.Field(typeof(EnvMan), "m_forceEnv");

		public static void Tick()
		{
			if (!Client.InsideRoom || !Object.op_Implicit((Object)(object)EnvMan.instance))
			{
				Clear();
				return;
			}
			EnvMan instance = EnvMan.instance;
			if ((Object)(object)active != (Object)(object)instance)
			{
				Clear();
				active = instance;
				previous = (string)Force.GetValue(instance);
				if (instance.m_environments.Find((EnvSetup e) => e.m_name == "PocketTentWarmInterior") == null)
				{
					EnvSetup val = instance.m_environments.Find((EnvSetup e) => e.m_name == "Clear") ?? instance.GetCurrentEnvironment();
					if (val == null)
					{
						active = null;
						return;
					}
					EnvSetup val2 = val.Clone();
					val2.m_name = "PocketTentWarmInterior";
					val2.m_isCold = false;
					val2.m_isColdAtNight = false;
					val2.m_isFreezing = false;
					val2.m_isFreezingAtNight = false;
					val2.m_isWet = false;
					val2.m_windMin = 0f;
					val2.m_windMax = 0f;
					val2.m_snowBuildup = 0f;
					val2.m_envObject = null;
					val2.m_psystems = Array.Empty<GameObject>();
					val2.m_ambientLoop = null;
					val2.m_ambientVol = 0f;
					val2.m_ambientList = "";
					instance.m_environments.Add(val2);
				}
			}
			instance.SetForceEnvironment("PocketTentWarmInterior");
		}

		public static void Clear()
		{
			if (Object.op_Implicit((Object)(object)active) && (string)Force.GetValue(active) == "PocketTentWarmInterior")
			{
				active.SetForceEnvironment(previous);
			}
			active = null;
			previous = "";
		}

		private static bool Silence(AudioMan audio, string field)
		{
			if (!Client.InsideRoom)
			{
				return true;
			}
			object? value = AccessTools.Field(typeof(AudioMan), field).GetValue(audio);
			AudioSource val = (AudioSource)((value is AudioSource) ? value : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				val.volume = 0f;
			}
			return false;
		}
	}
	public static class Network
	{
		private const string Request = "branchofyore.pockettent.request";

		private const string Reply = "branchofyore.pockettent.reply";

		private static readonly Dictionary<string, ZDO> records = new Dictionary<string, ZDO>();

		private static readonly Dictionary<ZDOID, (string tent, float time)> occupants = new Dictionary<ZDOID, (string, float)>();

		private static bool indexed;

		public static string LastDiagnostic = "";

		public static long ServerId
		{
			get
			{
				if (ZRoutedRpc.instance != null)
				{
					return (long)AccessTools.Method(typeof(ZRoutedRpc), "GetServerPeerID", (Type[])null, (Type[])null).Invoke(ZRoutedRpc.instance, null);
				}
				return 0L;
			}
		}

		public static bool InRoomBand(Vector3 p)
		{
			//IL_0000: 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_001a: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (p.y > 8990f && p.y < 9050f && p.x >= 3900f && p.x <= 7500f && p.z >= 3900f)
			{
				return p.z <= 7500f;
			}
			return false;
		}

		public static Vector3 Room(int slot)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3((float)(4000 + slot % 25 * 128), 9000f, (float)(4000 + slot / 25 * 128));
		}

		public static void Reset()
		{
			records.Clear();
			occupants.Clear();
			indexed = false;
		}

		public static void Register(ZRoutedRpc rpc)
		{
			rpc.Register<ZPackage>("branchofyore.pockettent.request", (Action<long, ZPackage>)Receive);
			rpc.Register<ZPackage>("branchofyore.pockettent.reply", (Action<long, ZPackage>)Client.Receive);
		}

		public static void Send(int action, string id)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (Object.op_Implicit((Object)(object)localPlayer) && ZRoutedRpc.instance != null)
			{
				ZPackage val = new ZPackage();
				val.Write(action);
				val.Write(((Character)localPlayer).GetZDOID());
				val.Write(id);
				ZRoutedRpc.instance.InvokeRoutedRPC(ServerId, "branchofyore.pockettent.request", new object[1] { val });
			}
		}

		private static void Index()
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			if (indexed)
			{
				return;
			}
			List<ZDO> list = new List<ZDO>();
			int num = 0;
			while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative("PocketTentRecord", list, ref num))
			{
			}
			foreach (ZDO item in list)
			{
				string text = item.GetString("branchofyore.pockettent.id", "");
				if (text.Length == 32)
				{
					records[text] = item;
				}
			}
			List<ZDO> list2 = new List<ZDO>();
			num = 0;
			while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative("PocketTentExterior", list2, ref num))
			{
			}
			foreach (ZDO item2 in list2)
			{
				if (records.TryGetValue(item2.GetString("branchofyore.pockettent.id", ""), out ZDO value))
				{
					value.Set("shell", item2.m_uid);
				}
			}
			indexed = true;
		}

		public static void Place(string id, Vector3 pos, Quaternion rotation)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0013: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			ZPackage val = new ZPackage();
			val.Write(6);
			val.Write(((Character)Player.m_localPlayer).GetZDOID());
			val.Write(id);
			val.Write(pos);
			val.Write(rotation);
			ZRoutedRpc.instance.InvokeRoutedRPC(ServerId, "branchofyore.pockettent.request", new object[1] { val });
		}

		private static void Respond(long peer, int action, string id, Vector3 room, Vector3 back, string text = "")
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0015: 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)
			ZPackage val = new ZPackage();
			val.Write(action);
			val.Write(id);
			val.Write(room);
			val.Write(back);
			val.Write(text);
			ZRoutedRpc.instance.InvokeRoutedRPC(peer, "branchofyore.pockettent.reply", new object[1] { val });
		}

		public static ZDO? Find(string id)
		{
			Index();
			if (!records.TryGetValue(id, out ZDO value))
			{
				return null;
			}
			return value;
		}

		public static ZDO? FindRoomAt(Vector3 point)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			indexed = false;
			Index();
			return ((IEnumerable<ZDO>)records.Values).FirstOrDefault((Func<ZDO, bool>)delegate(ZDO z)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0012: 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_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)
				Vector3 val = point - z.GetPosition();
				return Math.Abs(val.x) < 8.2f && Math.Abs(val.z) < 10.2f && val.y > -0.5f && val.y < 7f;
			});
		}

		public static bool Occupied(string id, ZDO record)
		{
			//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_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			List<ZDO> allCharacterZDOS = ZNet.instance.GetAllCharacterZDOS();
			HashSet<ZDOID> hashSet = new HashSet<ZDOID>(allCharacterZDOS.Select((ZDO p) => p.m_uid));
			ZDOID[] array = occupants.Keys.ToArray();
			foreach (ZDOID val in array)
			{
				if (!hashSet.Contains(val))
				{
					occupants.Remove(val);
				}
			}
			if (!occupants.Any<KeyValuePair<ZDOID, (string, float)>>((KeyValuePair<ZDOID, (string tent, float time)> p) => p.Value.tent == id))
			{
				return allCharacterZDOS.Any((ZDO p) => Vector3.Distance(p.GetPosition(), record.GetPosition()) < 30f);
			}
			return true;
		}

		public static void Receive(long sender, ZPackage pkg)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0492: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0645: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: 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_04d2: 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_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: 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_085e: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: Unknown result type (might be due to invalid IL or missing references)
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_087e: Unknown result type (might be due to invalid IL or missing references)
			//IL_086c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0714: Unknown result type (might be due to invalid IL or missing references)
			//IL_0719: Unknown result type (might be due to invalid IL or missing references)
			//IL_071d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: 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_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: 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_05ce: 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_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_089d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: 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_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_078b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: 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_062b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_079b: 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_07a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0802: Unknown result type (might be due to invalid IL or missing references)
			//IL_083c: Unknown result type (might be due to invalid IL or missing references)
			//IL_083e: 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_0398: 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_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: 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_03f2: 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_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: 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_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: 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_045e: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer())
			{
				return;
			}
			try
			{
				if (pkg.GetArray().Length > 160)
				{
					return;
				}
				LastDiagnostic = "Received request";
				int num = pkg.ReadInt();
				ZDOID val = pkg.ReadZDOID();
				string text = pkg.ReadString();
				Vector3 val2 = ((num == 6) ? pkg.ReadVector3() : Vector3.zero);
				Quaternion val3 = ((num == 6) ? pkg.ReadQuaternion() : Quaternion.identity);
				if (text.Length != 32 || !Guid.TryParseExact(text, "N", out var _))
				{
					return;
				}
				ZDO zDO = ZDOMan.instance.GetZDO(val);
				if (zDO == null || zDO.GetOwner() != sender)
				{
					return;
				}
				Index();
				records.TryGetValue(text, out ZDO value);
				Vector3 position = zDO.GetPosition();
				string requestedId = text;
				if (num == 0 || num == 6)
				{
					if (InRoomBand(position))
					{
						Tell("Can't be placed in a tent");
					}
					else if (zDO.GetBool(ZDOVars.s_dead, false))
					{
						Tell("Pitch the tent outside.");
					}
					else
					{
						if (num == 6 && (float.IsNaN(((Vector3)(ref val2)).sqrMagnitude) || float.IsInfinity(((Vector3)(ref val2)).sqrMagnitude) || Vector3.Distance(position, val2) > 8f))
						{
							return;
						}
						long owner = zDO.GetLong(ZDOVars.s_playerID, 0L);
						if (owner == 0L)
						{
							return;
						}
						string id = text;
						KeyValuePair<string, ZDO>[] array = records.Where<KeyValuePair<string, ZDO>>((KeyValuePair<string, ZDO> pair) => pair.Value.GetLong("tentOwner", 0L) == owner).ToArray();
						if (array.Any((KeyValuePair<string, ZDO> pair) => pair.Value.GetBool("deployed", false)))
						{
							Tell("You already have a tent pitched. Pack it before placing another.");
							return;
						}
						if (array.Length != 0)
						{
							KeyValuePair<string, ZDO> keyValuePair = array.OrderBy<KeyValuePair<string, ZDO>, string>((KeyValuePair<string, ZDO> pair) => pair.Key, StringComparer.Ordinal).First();
							text = keyValuePair.Key;
							value = keyValuePair.Value;
						}
						else
						{
							if (value != null)
							{
								text = Guid.NewGuid().ToString("N");
							}
							value = null;
						}
						Vector3 val4 = zDO.GetRotation() * Vector3.forward;
						Vector3 val5 = ((num == 6) ? val2 : (position + val4 * 4f));
						val5.y = ZoneSystem.instance.GetGroundHeight(val5);
						if (Math.Abs(val5.y - position.y) > 3f || val5.y < 31f)
						{
							Tell("Find level, dry ground outside.");
							return;
						}
						if (!Terrain.CanLevel(val5))
						{
							Tell("Find gentler ground for the tent.");
							return;
						}
						if (value == null)
						{
							if (records.Count >= 625)
							{
								Tell("Prototype room limit reached.");
								return;
							}
							GameObject obj = Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("PocketTentRecord"), Room(records.Count), Quaternion.identity);
							obj.SetActive(true);
							value = obj.GetComponent<ZNetView>().GetZDO();
							value.Set("branchofyore.pockettent.id", text);
							records[text] = value;
						}
						value.Set("tentOwner", owner);
						Terrain.Level(val5);
						Quaternion val6 = ((num == 6) ? Quaternion.Euler(0f, ((Quaternion)(ref val3)).eulerAngles.y, 0f) : Quaternion.identity);
						GameObject obj2 = Object.Instantiate<GameObject>(ZNetScene.instance.GetPrefab("PocketTentExterior"), val5, val6);
						obj2.SetActive(true);
						ZDO zDO2 = obj2.GetComponent<ZNetView>().GetZDO();
						zDO2.Set("branchofyore.pockettent.id", text);
						value.Set("entrance", val5 + val6 * Vector3.forward * 4.3f);
						value.Set("shell", zDO2.m_uid);
						value.Set("deployed", true);
						Respond(0L, 10, text, val5, val5);
						LastDiagnostic = "Tent pitched. Interact with the opening to enter.";
						Respond(sender, 7, id, value.GetPosition(), val5, LastDiagnostic);
					}
					return;
				}
				if (value == null)
				{
					Tell("This tent belongs to another world or is missing.");
					return;
				}
				Vector3 vec = value.GetVec3("entrance", Vector3.zero);
				switch (num)
				{
				case 11:
					if (value.GetBool("deployed", false) && !zDO.GetBool(ZDOVars.s_dead, false))
					{
						Vector3 val9 = position - value.GetPosition();
						if (!(Math.Abs(val9.x) > 8.2f) && !(Math.Abs(val9.z) > 10.2f) && !(val9.y < -0.5f) && !(val9.y > 7f))
						{
							occupants[val] = (text, Time.unscaledTime);
							Respond(sender, 12, text, value.GetPosition(), vec);
						}
					}
					return;
				case 1:
				{
					if (!value.GetBool("deployed", false) || zDO.GetBool(ZDOVars.s_dead, false) || Vector3.Distance(position, vec) > 6f)
					{
						return;
					}
					ZDO zDO5 = ZDOMan.instance.GetZDO(value.GetZDOID("shell"));
					if (zDO5 != null)
					{
						Vector3 val10 = Quaternion.Inverse(zDO5.GetRotation()) * (position - zDO5.GetPosition());
						if (!(val10.z < 2.4f) && !(val10.z > 6.5f) && !(Math.Abs(val10.x) > 2f))
						{
							occupants[val] = (text, Time.unscaledTime);
							Respond(sender, 1, text, value.GetPosition(), vec);
						}
					}
					return;
				}
				case 2:
				{
					if (!occupants.TryGetValue(val, out (string, float) value2) || value2.Item1 != text)
					{
						LastDiagnostic = "Exit denied: player is not registered in room";
					}
					else
					{
						Respond(sender, 2, text, value.GetPosition(), vec);
					}
					return;
				}
				case 3:
				{
					if (!value.GetBool("deployed", false))
					{
						return;
					}
					ZDO zDO3 = ZDOMan.instance.GetZDO(value.GetZDOID("shell"));
					if (zDO3 == null)
					{
						return;
					}
					Vector3 val7 = Quaternion.Inverse(zDO3.GetRotation()) * (position - zDO3.GetPosition());
					Bounds val8 = new Bounds(new Vector3(0f, 1.85f, 0.15f), new Vector3(5.2f, 3.8f, 7.4f));
					if (((Bounds)(ref val8)).SqrDistance(val7) > 36f)
					{
						return;
					}
					if (value.GetLong("tentOwner", 0L) != zDO.GetLong(ZDOVars.s_playerID, 0L))
					{
						Tell("Only the tent owner can pack it.");
						return;
					}
					if (Occupied(text, value))
					{
						Tell("Someone is still inside. The tent cannot be packed.");
						return;
					}
					ZDO zDO4 = ZDOMan.instance.GetZDO(value.GetZDOID("shell"));
					Vector3 room = ((zDO4 != null) ? zDO4.GetPosition() : vec);
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("PocketTentBundle");
					ItemData obj3 = itemPrefab.GetComponent<ItemDrop>().m_itemData.Clone();
					obj3.m_dropPrefab = itemPrefab;
					obj3.m_stack = 1;
					obj3.m_customData["branchofyore.pockettent.id"] = text;
					ItemDrop.DropItem(obj3, 1, vec + Vector3.up * 0.3f, Quaternion.identity);
					value.Set("deployed", false);
					if (zDO4 != null)
					{
						zDO4.SetOwner(ZNet.GetUID());
						ZDOMan.instance.DestroyZDO(zDO4);
					}
					Respond(0L, 9, text, room, vec);
					Tell("Tent packed. Use the hammer to pitch it elsewhere.");
					return;
				}
				case 5:
					if (!InRoomBand(position))
					{
						occupants.Remove(val);
						return;
					}
					break;
				}
				if (num == 4 && occupants.TryGetValue(val, out (string, float) value3) && value3.Item1 == text)
				{
					occupants[val] = (text, Time.unscaledTime);
				}
				void Tell(string t)
				{
					//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)
					LastDiagnostic = t;
					Respond(sender, 0, requestedId, Vector3.zero, Vector3.zero, t);
				}
			}
			catch (Exception ex)
			{
				LastDiagnostic = ex.ToString();
				Debug.LogWarning((object)("Pocket Tent request: " + ex.Message));
			}
		}
	}
	[BepInPlugin("branchofyore.pockettent", "PerkinsTent", "0.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Humanoid), "UseItem")]
		private static class UseBundle
		{
			private static bool Prefix(Humanoid __instance, ItemData item)
			{
				if (!Object.op_Implicit((Object)(object)item.m_dropPrefab) || ((Object)item.m_dropPrefab).name != "PocketTentBundle")
				{
					return true;
				}
				if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
				{
					return false;
				}
				if (!__instance.GetInventory().ContainsItem(item))
				{
					return false;
				}
				Message("Use the hammer to place your tent.");
				return false;
			}
		}

		[HarmonyPatch(typeof(Player), "TryPlacePiece")]
		private static class BlockNestedTent
		{
			private static bool Prefix(Player __instance, Piece piece, ref bool __result)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)((Component)piece).gameObject).name != "PocketTentPlacement" || !Network.InRoomBand(((Component)__instance).transform.position))
				{
					return true;
				}
				((Character)__instance).Message((MessageType)2, "Can't be placed in a tent", 0, (Sprite)null, false);
				__result = false;
				return false;
			}
		}

		[HarmonyPatch(typeof(Player), "ConsumeResources")]
		private static class TentCost
		{
			private static bool Prefix(Requirement[] requirements)
			{
				if (requirements.Length == 1 && Object.op_Implicit((Object)(object)requirements[0].m_resItem))
				{
					return !(((Object)((Component)requirements[0].m_resItem).gameObject).name == "PocketTentBundle");
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Player), "RemovePiece")]
		private static class RemoveTent
		{
			private static bool Prefix(Player __instance, ref bool __result)
			{
				//IL_0038: 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_004d: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				GameCamera instance = GameCamera.instance;
				if (!Object.op_Implicit((Object)(object)instance))
				{
					return true;
				}
				int num = (int)AccessTools.Field(typeof(Player), "m_removeRayMask").GetValue(__instance);
				Ray val = default(Ray);
				((Ray)(ref val))..ctor(((Component)instance).transform.position, ((Component)instance).transform.forward);
				RaycastHit val2 = default(RaycastHit);
				bool num2 = Physics.Raycast(val, ref val2, 50f, num);
				TentBody tentBody = (num2 ? ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<TentBody>() : null);
				float num3 = (num2 ? ((RaycastHit)(ref val2)).distance : 50f);
				TentBody[] array = Object.FindObjectsByType<TentBody>((FindObjectsSortMode)0);
				RaycastHit val3 = default(RaycastHit);
				foreach (TentBody tentBody2 in array)
				{
					if (Object.op_Implicit((Object)(object)tentBody2.RemovalTarget) && ((Collider)tentBody2.RemovalTarget).Raycast(val, ref val3, num3))
					{
						tentBody = tentBody2;
						val2 = val3;
						num3 = ((RaycastHit)(ref val3)).distance;
					}
				}
				if (!Object.op_Implicit((Object)(object)tentBody))
				{
					return true;
				}
				__result = false;
				if (Vector3.Distance(((RaycastHit)(ref val2)).point, ((Character)__instance).GetEyePoint()) > 8f || !PrivateArea.CheckAccess(((Component)tentBody).transform.position, 0f, true, false))
				{
					return false;
				}
				ZNetView component = ((Component)tentBody).GetComponent<ZNetView>();
				if (Object.op_Implicit((Object)(object)component) && component.IsValid())
				{
					Network.Send(3, component.GetZDO().GetString("branchofyore.pockettent.id", ""));
				}
				__result = true;
				return false;
			}
		}

		[HarmonyPatch(typeof(Player), "PlacePiece")]
		private static class HammerPlacement
		{
			private static bool Prefix(Player __instance, Piece piece, Vector3 pos, Quaternion rot)
			{
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)((Component)piece).gameObject).name != "PocketTentPlacement")
				{
					return true;
				}
				if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
				{
					return false;
				}
				if (Network.InRoomBand(((Component)__instance).transform.position))
				{
					Message("Can't be placed in a tent");
					return false;
				}
				if (Client.PlacementPending)
				{
					Message("Tent placement is already pending.");
					return false;
				}
				ItemData val = null;
				foreach (ItemData allItem in ((Humanoid)__instance).GetInventory().GetAllItems())
				{
					if (Object.op_Implicit((Object)(object)allItem.m_dropPrefab) && !(((Object)allItem.m_dropPrefab).name != "PocketTentBundle"))
					{
						val = allItem;
						break;
					}
				}
				if (val == null)
				{
					Message("Requires one Tent Cloth");
					return false;
				}
				if (!val.m_customData.TryGetValue("branchofyore.pockettent.id", out var value))
				{
					value = Guid.NewGuid().ToString("N");
					val.m_customData["branchofyore.pockettent.id"] = value;
				}
				Client.PendingCloth = val;
				Network.Place(value, pos, rot);
				return false;
			}
		}

		[HarmonyPatch(typeof(EnvMan), "CheckInteriorBuildingOverride")]
		private static class AllowTentFurniture
		{
			private static void Postfix(ref bool __result)
			{
				if (Client.InsideRoom)
				{
					__result = true;
				}
			}
		}

		[HarmonyPatch(typeof(WearNTear), "UpdateSupport")]
		private static class StableInterior
		{
			private static bool Prefix(WearNTear __instance)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				if (!Network.InRoomBand(((Component)__instance).transform.position))
				{
					return true;
				}
				float num = (float)AccessTools.Method(typeof(WearNTear), "GetMaxSupport", (Type[])null, (Type[])null).Invoke(__instance, null);
				AccessTools.Field(typeof(WearNTear), "m_support").SetValue(__instance, num);
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if (Object.op_Implicit((Object)(object)component) && component.IsValid())
				{
					component.GetZDO().Set(ZDOVars.s_support, num);
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(PlayerProfile), "SaveLogoutPoint")]
		private static class SafeLogout
		{
			private static void Postfix(PlayerProfile __instance)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				if (Client.Back.HasValue)
				{
					__instance.SetLogoutPoint(Client.Back.Value);
				}
			}
		}

		[HarmonyPatch(typeof(Player), "OnSpawned")]
		private static class Recover
		{
			private static void Postfix(Player __instance)
			{
				if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
				{
					Client.Recover(__instance);
				}
			}
		}

		public const string Id = "branchofyore.pockettent";

		public const string Bundle = "PocketTentBundle";

		public const string Record = "PocketTentRecord";

		public const string Exterior = "PocketTentExterior";

		public const string Key = "branchofyore.pockettent.id";

		private Harmony harmony;

		private ZRoutedRpc? bound;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			harmony = new Harmony("branchofyore.pockettent");
			harmony.PatchAll();
			PrefabManager.OnVanillaPrefabsAvailable += Register;
		}

		private void Register()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			ItemConfig val = new ItemConfig();
			val.Name = "Tent Cloth";
			val.Description = "Used to pitch your tent with a hammer. Returned when you pack the tent. Its interior stays in this world.";
			val.CraftingStation = "piece_workbench";
			val.MinStationLevel = 1;
			val.Amount = 1;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("SurtlingCore", 2, 0, true),
				new RequirementConfig("GreydwarfEye", 10, 0, true),
				new RequirementConfig("DeerHide", 20, 0, true)
			};
			CustomItem val2 = new CustomItem("PocketTentBundle", "LeatherScraps", val);
			val2.ItemDrop.m_itemData.m_shared.m_maxStackSize = 1;
			val2.ItemDrop.m_itemData.m_shared.m_weight = 5f;
			val2.ItemDrop.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { LoadIcon("cloth") };
			BundleModel.Build(((Component)val2.ItemDrop).gameObject);
			ItemManager.Instance.AddItem(val2);
			AddNetworkPrefab("PocketTentRecord", exterior: false);
			AddNetworkPrefab("PocketTentExterior", exterior: true);
			PieceConfig val3 = new PieceConfig();
			val3.Name = "Perkins's Tent";
			val3.Description = "Requires one Tent Cloth. One tent per player. Remove with the hammer to recover the cloth and keep the interior.";
			val3.PieceTable = "Hammer";
			val3.Category = "Furniture";
			val3.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig("PocketTentBundle", 1, 0, false)
			};
			CustomPiece val4 = new CustomPiece("PocketTentPlacement", true, val3);
			Visual.Tent(val4.PiecePrefab.transform);
			val4.Piece.m_groundOnly = true;
			val4.Piece.m_icon = LoadIcon("tent");
			PieceManager.Instance.AddPiece(val4);
			Terrain.Register();
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
		}

		private static void AddNetworkPrefab(string name, bool exterior)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			GameObject val = new GameObject(name);
			val.SetActive(false);
			val.AddComponent<ZNetView>().m_persistent = true;
			if (exterior)
			{
				val.AddComponent<TentBody>();
				Piece obj = val.AddComponent<Piece>();
				obj.m_name = "Perkins's Tent";
				obj.m_canBeRemoved = true;
			}
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val, false));
			val.SetActive(true);
		}

		private static Sprite LoadIcon(string name)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_00ab: 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)
			using Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream("PocketTent.Assets." + name + ".png");
			if (stream == null)
			{
				throw new InvalidOperationException("Missing tent icon: " + name);
			}
			byte[] array = new byte[stream.Length];
			int num;
			for (int i = 0; i < array.Length; i += num)
			{
				num = stream.Read(array, i, array.Length - i);
				if (num == 0)
				{
					break;
				}
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			AssetUtils.LoadImage(val, array);
			((Object)val).name = "PocketTent_" + name;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
		}

		private void Update()
		{
			if (bound != ZRoutedRpc.instance)
			{
				bound = ZRoutedRpc.instance;
				Network.Reset();
				Client.Clear();
				Client.PendingCloth = null;
				if (bound != null)
				{
					Network.Register(bound);
				}
			}
			Client.Tick();
			InteriorClimate.Tick();
		}

		public static void Message(string text)
		{
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, text, 0, (Sprite)null, false);
			}
		}

		private void OnDestroy()
		{
			PrefabManager.OnVanillaPrefabsAvailable -= Register;
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			Client.Clear();
		}
	}
	public static class Terrain
	{
		[HarmonyPatch(typeof(ObjectDB), "UpdateRegisters")]
		private static class RegisterOperation
		{
			private static void Postfix(ObjectDB __instance)
			{
				AddToDatabase(__instance);
			}
		}

		private const string Name = "PocketTentGroundLevel";

		private static GameObject? prefab;

		public static void Register()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0050: 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_0067: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			prefab = new GameObject("PocketTentGroundLevel");
			prefab.SetActive(false);
			prefab.AddComponent<TerrainOp>().m_settings = new Settings
			{
				m_level = true,
				m_levelRadius = 4.15f,
				m_square = false,
				m_halfOffset = false,
				m_paintCleared = true,
				m_paintRadius = 4.15f,
				m_paintType = (PaintType)0
			};
			PrefabManager.Instance.AddPrefab(new CustomPrefab(prefab, false));
			prefab.SetActive(true);
			if (Object.op_Implicit((Object)(object)ObjectDB.instance))
			{
				AddToDatabase(ObjectDB.instance);
			}
		}

		public static bool CanLevel(Vector3 at)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 16; i++)
			{
				float num = (float)i * (float)Math.PI / 8f;
				Vector3 val = at + new Vector3(Mathf.Sin(num) * 4.15f, 0f, Mathf.Cos(num) * 4.15f);
				if (Mathf.Abs(ZoneSystem.instance.GetGroundHeight(val) - at.y) > 1.5f)
				{
					return false;
				}
			}
			return true;
		}

		public static void Level(Vector3 at)
		{
			//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)
			AddToDatabase(ObjectDB.instance);
			Object.Instantiate<GameObject>(prefab, at, Quaternion.identity);
		}

		private static void AddToDatabase(ObjectDB db)
		{
			if (Object.op_Implicit((Object)(object)prefab))
			{
				TerrainOp component = prefab.GetComponent<TerrainOp>();
				if (!db.m_terrainOps.Contains(component))
				{
					db.m_terrainOps.Add(component);
				}
				db.m_terrainOpsByHash[StringExtensionMethods.GetStableHashCode("PocketTentGroundLevel")] = component;
			}
		}
	}
	public sealed class TentBody : MonoBehaviour
	{
		public BoxCollider RemovalTarget;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0066: 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)
			Visual.Tent(((Component)this).transform, interactive: true);
			GameObject val = new GameObject("Hammer removal target");
			val.transform.SetParent(((Component)this).transform, false);
			val.layer = LayerMask.NameToLayer("Ignore Raycast");
			RemovalTarget = val.AddComponent<BoxCollider>();
			((Collider)RemovalTarget).isTrigger = true;
			RemovalTarget.center = new Vector3(0f, 1.85f, 0.15f);
			RemovalTarget.size = new Vector3(5.2f, 3.8f, 7.4f);
		}
	}
	public sealed class TentEntrance : MonoBehaviour, Hoverable, Interactable
	{
		private ZNetView view;

		private void Awake()
		{
			view = ((Component)this).GetComponentInParent<ZNetView>();
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public string GetHoverName()
		{
			return "Perkins's Tent";
		}

		public string GetHoverText()
		{
			return Localization.instance.Localize("Perkins's Tent\n[<color=yellow>$KEY_Use</color>] Enter\n[<color=yellow>Shift + $KEY_Use</color>] Pack");
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			//IL_003d: 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)
			if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer || !Object.op_Implicit((Object)(object)view) || !view.IsValid())
			{
				return false;
			}
			if (((Component)view).transform.InverseTransformPoint(((Component)user).transform.position).z < 2.4f)
			{
				return false;
			}
			Network.Send((!alt) ? 1 : 3, view.GetZDO().GetString("branchofyore.pockettent.id", ""));
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}
	}
	public sealed class TentExit : MonoBehaviour, Hoverable, Interactable
	{
		public float GetHoverOffset()
		{
			return 0f;
		}

		public string GetHoverName()
		{
			return "Tent entrance";
		}

		public string GetHoverText()
		{
			return Localization.instance.Localize("[<color=yellow>$KEY_Use</color>] Leave tent");
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer)
			{
				return false;
			}
			Network.Send(2, Client.Id);
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}
	}
	public static class Visual
	{
		private static Material? wood;

		private static Material? cloth;

		private static Material? rope;

		private static Material? trim;

		private static Material Material(bool fabric)
		{
			//IL_006b: 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_0071: Expected O, but got Unknown
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			if (fabric && Object.op_Implicit((Object)(object)cloth))
			{
				return cloth;
			}
			if (!fabric && Object.op_Implicit((Object)(object)wood))
			{
				return wood;
			}
			GameObject prefab = PrefabManager.Instance.GetPrefab("wood_floor");
			MeshRenderer val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponentInChildren<MeshRenderer>() : null);
			Material val2 = (Object.op_Implicit((Object)(object)val) ? new Material(((Renderer)val).sharedMaterial) : new Material(Shader.Find("Standard")));
			if (fabric)
			{
				Texture2D val3 = new Texture2D(256, 256, (TextureFormat)3, true);
				for (int i = 0; i < 256; i++)
				{
					for (int j = 0; j < 256; j++)
					{
						float num = 0.65f + 0.25f * Mathf.PerlinNoise((float)j * 0.034f, (float)i * 0.034f) + 0.16f * Mathf.PerlinNoise((float)j * 0.48f, (float)i * 0.48f);
						if ((float)Mathf.Min(new int[4]
						{
							j,
							255 - j,
							i,
							255 - i
						}) < 3f)
						{
							num *= 0.6f;
						}
						if ((j % 16 < 5 && (i == 6 || i == 249)) || (i % 16 < 5 && (j == 6 || j == 249)))
						{
							num = 1.25f;
						}
						val3.SetPixel(j, i, new Color(0.48f * num, 0.29f * num, 0.155f * num));
					}
				}
				((Texture)val3).wrapMode = (TextureWrapMode)0;
				val3.Apply();
				val2.mainTexture = (Texture)(object)val3;
				if (val2.HasProperty("_BumpMap"))
				{
					val2.SetTexture("_BumpMap", (Texture)null);
				}
				val2.DisableKeyword("_NORMALMAP");
				val2.SetFloat("_Glossiness", 0f);
				val2.color = Color.white;
			}
			else
			{
				val2.color = new Color(0.55f, 0.4f, 0.27f);
			}
			if (fabric)
			{
				cloth = val2;
			}
			else
			{
				wood = val2;
			}
			return val2;
		}

		public static GameObject Block(Transform parent, string name, Vector3 at, Vector3 size, bool fabric = false)
		{
			//IL_0020: 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)
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)obj).name = name;
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = at;
			obj.transform.localScale = size;
			obj.layer = LayerMask.NameToLayer("piece");
			obj.GetComponent<Renderer>().sharedMaterial = Material(fabric);
			return obj;
		}

		private static void Pole(Transform parent, Vector3 a, Vector3 b, float thickness)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			Block(parent, "Timber", (a + b) * 0.5f, new Vector3(thickness, Vector3.Distance(a, b), thickness)).transform.localRotation = Quaternion.FromToRotation(Vector3.up, b - a);
		}

		private static void Cord(Transform parent, Vector3 a, Vector3 b, float radius, bool leather = false)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_006a: 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_00a4: 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_00af: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)rope))
			{
				rope = new Material(Material(fabric: true));
				rope.color = new Color(1.6f, 1.7f, 1.8f);
			}
			if (!Object.op_Implicit((Object)(object)trim))
			{
				trim = new Material(Material(fabric: true));
				trim.color = new Color(0.5f, 0.45f, 0.4f);
			}
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)obj).name = (leather ? "Leather seam binding" : "Hemp cord");
			obj.transform.SetParent(parent, false);
			obj.transform.localPosition = (a + b) * 0.5f;
			obj.transform.localRotation = Quaternion.FromToRotation(Vector3.up, b - a);
			obj.transform.localScale = new Vector3(radius, Vector3.Distance(a, b) * 0.5f, radius);
			obj.GetComponent<Collider>().enabled = false;
			obj.GetComponent<Renderer>().sharedMaterial = (leather ? trim : rope);
		}

		public static void Tent(Transform root, bool interactive = false)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: 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_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Expected O, but got Unknown
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Expected O, but got Unknown
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e4: Expected O, but got Unknown
			//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Unknown result type (might be due to invalid IL or missing references)
			//IL_0638: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_0554: 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_0560: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_056a: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_057b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Canvas tent form");
			val.transform.SetParent(root, false);
			root = val.transform;
			GameObject val2 = new GameObject("Brown canvas");
			val2.transform.SetParent(root, false);
			val2.layer = LayerMask.NameToLayer("piece");
			Mesh val3 = new Mesh();
			List<Vector3> verts = new List<Vector3>();
			List<int> triangles = new List<int>();
			List<Vector2> uv = new List<Vector2>();
			int[] array = new int[2] { -1, 1 };
			foreach (int side in array)
			{
				for (int j = 0; j < 8; j++)
				{
					for (int k = 0; k < 12; k++)
					{
						Quad(Point(side, j, k), Point(side, j + 1, k), Point(side, j, k + 1), Point(side, j + 1, k + 1));
					}
				}
			}
			array = new int[2] { -1, 1 };
			foreach (int side2 in array)
			{
				int[] array2 = new int[4] { 0, 4, 8, 12 };
				foreach (int length in array2)
				{
					for (int m = 0; m < 8; m++)
					{
						Cord(root, Point(side2, m, length) + Vector3.up * 0.015f, Point(side2, m + 1, length) + Vector3.up * 0.015f, 0.022f, leather: true);
					}
				}
			}
			for (int n = 0; n < 12; n++)
			{
				Cord(root, Point(1, 0, n) + Vector3.up * 0.02f, Point(1, 0, n + 1) + Vector3.up * 0.02f, 0.065f, leather: true);
			}
			Cord(root, new Vector3(0.2f, 0f, 3.35f), new Vector3(0f, 3.49f, 3.32f), 0.04f, leather: true);
			Cord(root, new Vector3(-1.35f, 0.12f, 3.67f), new Vector3(0f, 3.49f, 3.32f), 0.04f, leather: true);
			Face(new Vector3(-2.35f, 0f, -3.3f), new Vector3(0f, 3.49f, -3.3f), new Vector3(2.35f, 0f, -3.3f));
			Face(new Vector3(0.2f, 0f, 3.33f), new Vector3(0f, 3.49f, 3.3f), new Vector3(2.35f, 0f, 3.33f));
			Face(new Vector3(-2.55f, 0f, 3.4f), new Vector3(0f, 3.49f, 3.3f), new Vector3(-1.35f, 0.12f, 3.65f));
			val3.SetVertices(verts);
			val3.SetUVs(0, uv);
			val3.SetTriangles(triangles, 0);
			val3.RecalculateNormals();
			val3.RecalculateBounds();
			val2.AddComponent<MeshFilter>().sharedMesh = val3;
			((Renderer)val2.AddComponent<MeshRenderer>()).sharedMaterial = Material(fabric: true);
			val2.AddComponent<MeshCollider>().sharedMesh = val3;
			array = new int[2] { -1, 1 };
			foreach (int num in array)
			{
				Pole(root, new Vector3(0f, 0f, (float)num * 3.3f), new Vector3(0f, 3.7f, (float)num * 3.3f), 0.1f);
				Cord(root, new Vector3(0f, 3.6f, (float)num * 3.3f), new Vector3(0f, 0.15f, (float)num * 5.3f), 0.04f);
				Pole(root, new Vector3(0f, 0f, (float)num * 5.3f), new Vector3(0.12f, 0.4f, (float)num * 5.3f), 0.085f);
				for (int num2 = 0; num2 < 4; num2++)
				{
					Cord(root, new Vector3(-0.075f, 3.5f + (float)num2 * 0.045f, (float)num * 3.3f), new Vector3(0.075f, 3.5f + (float)num2 * 0.045f, (float)num * 3.3f), 0.045f);
				}
			}
			array = new int[2] { -1, 1 };
			Vector3 val4 = default(Vector3);
			foreach (int num3 in array)
			{
				float[] array3 = new float[3] { -3.3f, 0f, 3.3f };
				foreach (float num4 in array3)
				{
					((Vector3)(ref val4))..ctor((float)num3 * 3.05f, 0.1f, num4);
					Cord(root, new Vector3((float)num3 * 2.22f, 0.28f, num4), val4, 0.035f);
					Pole(root, val4 - Vector3.up * 0.1f, val4 + Vector3.up * 0.25f, 0.075f);
				}
			}
			Material val5 = new Material(Material(fabric: true));
			val5.color = Color.black;
			GameObject val6 = new GameObject("Dark entrance");
			val6.transform.SetParent(root, false);
			Mesh val7 = new Mesh();
			val7.vertices = (Vector3[])(object)new Vector3[3]
			{
				new Vector3(-2.35f, 0.02f, 3.28f),
				new Vector3(0f, 3.49f, 3.28f),
				new Vector3(2.35f, 0.02f, 3.28f)
			};
			val7.triangles = new int[6] { 0, 1, 2, 2, 1, 0 };
			val7.RecalculateNormals();
			val6.AddComponent<MeshFilter>().sharedMesh = val7;
			((Renderer)val6.AddComponent<MeshRenderer>()).sharedMaterial = val5;
			GameObject val8 = Block(root, "Entrance interaction", new Vector3(-0.5f, 1f, 3.34f), new Vector3(1.2f, 2f, 0.12f), fabric: true);
			val8.GetComponent<Renderer>().enabled = false;
			if (interactive)
			{
				val8.AddComponent<TentEntrance>();
			}
			void Face(Vector3 a, Vector3 b, Vector3 c)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//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_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: 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_003b: 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_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: 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_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				int count = verts.Count;
				verts.AddRange((IEnumerable<Vector3>)(object)new Vector3[6] { a, b, c, c, b, a });
				uv.AddRange((IEnumerable<Vector2>)(object)new Vector2[6]
				{
					UV(a),
					UV(b),
					UV(c),
					UV(c),
					UV(b),
					UV(a)
				});
				triangles.AddRange(new int[6]
				{
					count,
					count + 1,
					count + 2,
					count + 3,
					count + 4,
					count + 5
				});
			}
			static Vector3 Point(int num8, int step, int num7)
			{
				//IL_0093: Unknown result type (might be due to invalid IL or missing references)
				float num5 = (float)step / 8f;
				float num6 = (float)num7 / 12f;
				return new Vector3((float)num8 * (2.35f * num5 + 0.04f * Mathf.Sin(num6 * (float)Math.PI * 8f) * Mathf.Sin(num5 * (float)Math.PI)), 0.04f + 3.45f * (1f - num5) - 0.18f * Mathf.Sin(num5 * (float)Math.PI) - 0.15f * Mathf.Sin(num6 * (float)Math.PI) * (1f - num5), Mathf.Lerp(-3.3f, 3.3f, num6));
			}
			void Quad(Vector3 a, Vector3 b, Vector3 c, 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_0002: 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_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)
				Face(a, b, c);
				Face(c, b, d);
			}
			static Vector2 UV(Vector3 p)
			{
				//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_0013: 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_002c: Unknown result type (might be due to invalid IL or missing references)
				return new Vector2((p.x + p.y) * 0.65f, p.z * 0.65f + p.y * 0.15f);
			}
		}

		public static GameObject Room(Vector3 origin)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0011: 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_0021: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00d2: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: 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_0352: 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_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Expected O, but got Unknown
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: 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_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Pocket Tent Interior");
			val.transform.position = origin;
			GameObject val2 = new GameObject("Tent warmth");
			val2.SetActive(false);
			val2.transform.SetParent(val.transform, false);
			val2.layer = LayerMask.NameToLayer("character_trigger");
			BoxCollider obj = val2.AddComponent<BoxCollider>();
			obj.center = new Vector3(0f, 3f, 0f);
			obj.size = new Vector3(15.8f, 6f, 19.8f);
			((Collider)obj).isTrigger = true;
			EffectArea obj2 = val2