Decompiled source of HelResurrection v0.3.25

BepInEx/plugins/HelResurrection/HelResurrection.dll

Decompiled a day 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.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;

[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("HelResurrection")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.3.25.0")]
[assembly: AssemblyInformationalVersion("0.3.25")]
[assembly: AssemblyProduct("HelResurrection")]
[assembly: AssemblyTitle("HelResurrection")]
[assembly: AssemblyVersion("0.3.25.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 HelResurrection
{
	public static class Chamber
	{
		[HarmonyPatch(typeof(GameCamera), "LateUpdate")]
		private static class DeadCamera
		{
			private static void Postfix(GameCamera __instance)
			{
				//IL_0015: 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_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				if (Client.Waiting && Client.InChamber)
				{
					((Component)__instance).transform.position = Client.Room + new Vector3(4f, 4f, -5f);
					((Component)__instance).transform.rotation = Quaternion.LookRotation(Client.Room + new Vector3(0f, 1f, 1f) - ((Component)__instance).transform.position);
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "UpdateBlackScreen")]
		private static class WaitScreen
		{
			private static void Postfix(Hud __instance)
			{
				if (Client.Waiting)
				{
					float num = (Client.InChamber ? (1f - Mathf.Clamp01((Time.unscaledTime - Client.ChamberEntered) / 0.8f)) : Mathf.Clamp01((Time.unscaledTime - Client.DeathStarted - 1.25f) / 1.25f));
					__instance.m_loadingScreen.alpha = num;
					((Component)__instance.m_loadingScreen).gameObject.SetActive(num > 0f);
				}
			}
		}

		public static GameObject? Root;

		private static readonly List<Object> Assets = new List<Object>();

		private static bool bodyCreated;

		private static Material? stoneMaterial;

		private static Mesh? stoneMesh;

		public static int RelaxedLimbs;

		public static int FireEffects;

		public static readonly Vector3 ExitPosition = new Vector3(0f, 0f, -7.5f);

		public static bool InExitPortal(Vector3 point)
		{
			//IL_000e: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Root))
			{
				return false;
			}
			Vector3 val = point - Root.transform.position - ExitPosition;
			if (Mathf.Abs(val.x) < 1.1f && Mathf.Abs(val.z) < 0.7f && val.y > -0.3f)
			{
				return val.y < 3.2f;
			}
			return false;
		}

		public static void Create(Vector3 center, ZDOID dead)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: 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_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: 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_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: 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_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: 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_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0614: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0722: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_074a: Unknown result type (might be due to invalid IL or missing references)
			//IL_077c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0790: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_080a: Unknown result type (might be due to invalid IL or missing references)
			//IL_081e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0832: Unknown result type (might be due to invalid IL or missing references)
			//IL_0851: Unknown result type (might be due to invalid IL or missing references)
			//IL_0865: Unknown result type (might be due to invalid IL or missing references)
			//IL_0879: Unknown result type (might be due to invalid IL or missing references)
			//IL_0995: Unknown result type (might be due to invalid IL or missing references)
			//IL_099a: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a52: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aaf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afe: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0915: Unknown result type (might be due to invalid IL or missing references)
			//IL_092a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0949: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bf: Unknown result type (might be due to invalid IL or missing references)
			Destroy();
			FireEffects = 0;
			Root = new GameObject("HelChamber");
			Root.transform.position = center;
			Block("Floor", new Vector3(0f, -0.5f, 0f), new Vector3(20f, 1f, 20f), new Color(0.09f, 0.085f, 0.085f));
			Block("Roof", new Vector3(0f, 9f, 0f), new Vector3(20f, 1f, 20f), new Color(0.025f, 0.025f, 0.03f));
			Block("Back", new Vector3(0f, 4f, 10f), new Vector3(20f, 10f, 1f), new Color(0.04f, 0.035f, 0.04f));
			Block("Front", new Vector3(0f, 4f, -10f), new Vector3(20f, 10f, 1f), new Color(0.04f, 0.035f, 0.04f));
			Block("Left", new Vector3(-10f, 4f, 0f), new Vector3(1f, 10f, 20f), new Color(0.04f, 0.035f, 0.04f));
			Block("Right", new Vector3(10f, 4f, 0f), new Vector3(1f, 10f, 20f), new Color(0.04f, 0.035f, 0.04f));
			Block("AltarStep", new Vector3(0f, 0.12f, 1f), new Vector3(3.8f, 0.24f, 4.6f), new Color(0.14f, 0.16f, 0.17f));
			Block("AltarBase", new Vector3(0f, 0.48f, 1f), new Vector3(1.7f, 0.72f, 2.9f), new Color(0.1f, 0.12f, 0.14f));
			Block("SoulSlab", new Vector3(0f, 0.89f, 1f), new Vector3(2.1f, 0.26f, 3.3f), new Color(0.27f, 0.29f, 0.3f));
			Block("HeadStone", new Vector3(0f, 1.035f, 2.18f), new Vector3(1.3f, 0.025f, 0.45f), new Color(0.23f, 0.26f, 0.28f));
			for (int i = -1; i <= 1; i += 2)
			{
				for (int j = 0; j < 3; j++)
				{
					float num = -5 + j * 5;
					Block("PillarFoot", new Vector3((float)(i * 6), 0.25f, num), new Vector3(1.7f, 0.5f, 1.7f), new Color(0.12f, 0.14f, 0.16f));
					Block("Pillar", new Vector3((float)(i * 6), 3.1f, num), new Vector3(1.1f, 5.8f, 1.1f), new Color(0.16f, 0.18f, 0.2f));
					Block("PillarCrown", new Vector3((float)(i * 6), 6.1f, num), new Vector3(1.7f, 0.45f, 1.7f), new Color(0.13f, 0.15f, 0.18f));
				}
				Block("GatePost", new Vector3((float)i * 2.3f, 3.1f, 8.6f), new Vector3(0.8f, 6.2f, 1f), new Color(0.17f, 0.19f, 0.21f));
				Block("GateLintel", new Vector3((float)i * 1.1f, 6.5f, 8.6f), new Vector3(2.7f, 0.65f, 1.1f), new Color(0.19f, 0.21f, 0.23f)).transform.localRotation = Quaternion.Euler(0f, 0f, (float)(i * -22));
			}
			Block("SealedGate", new Vector3(0f, 3.2f, 9.3f), new Vector3(4f, 6.4f, 0.4f), new Color(0.012f, 0.017f, 0.024f));
			Block("ThroneDais", new Vector3(0f, 0.2f, 6.5f), new Vector3(5f, 0.4f, 4f), new Color(0.13f, 0.1f, 0.105f));
			Block("ThroneStep", new Vector3(0f, 0.1f, 4.2f), new Vector3(4f, 0.2f, 0.8f), new Color(0.18f, 0.13f, 0.12f));
			Block("ThroneSeat", new Vector3(0f, 0.95f, 6.8f), new Vector3(2.1f, 1.1f, 1.9f), new Color(0.18f, 0.15f, 0.15f));
			Block("ThroneBack", new Vector3(0f, 2.5f, 7.55f), new Vector3(2.3f, 3.8f, 0.45f), new Color(0.14f, 0.115f, 0.12f));
			for (int k = -1; k <= 1; k += 2)
			{
				Block("ThroneArm", new Vector3((float)k * 1.1f, 1.5f, 6.75f), new Vector3(0.4f, 1.3f, 2.1f), new Color(0.22f, 0.17f, 0.16f));
				Block("ThroneCrown", new Vector3((float)k * 0.7f, 4.35f, 7.55f), new Vector3(0.42f, 1.2f, 0.55f), new Color(0.2f, 0.15f, 0.15f)).transform.localRotation = Quaternion.Euler(0f, 0f, (float)(k * -18));
				Block("EmberChannel", new Vector3((float)(k * 4), 0.025f, 0f), new Vector3(0.16f, 0.04f, 14f), new Color(0.65f, 0.075f, 0.015f));
			}
			for (int l = 0; l < 6; l++)
			{
				Block("ProcessionalStone", new Vector3(0f, 0.018f, -7f + (float)l * 1.1f), new Vector3(2.3f, 0.035f, 0.85f), new Color(0.18f, 0.2f, 0.22f));
			}
			for (int m = -1; m <= 1; m += 2)
			{
				Block("BrazierFoot", new Vector3((float)(m * 3), 0.18f, 2f), new Vector3(1f, 0.36f, 1f), new Color(0.13f, 0.14f, 0.15f));
				Block("BrazierStem", new Vector3((float)(m * 3), 0.65f, 2f), new Vector3(0.5f, 0.9f, 0.5f), new Color(0.12f, 0.13f, 0.14f));
				Block("BrazierBowl", new Vector3((float)(m * 3), 1.15f, 2f), new Vector3(1.1f, 0.22f, 1.1f), new Color(0.21f, 0.19f, 0.18f));
				Material sharedMaterial = Block("Ember", new Vector3((float)(m * 3), 1.29f, 2f), new Vector3(0.77f, 0.09f, 0.77f), new Color(0.8f, 0.19f, 0.025f)).GetComponent<Renderer>().sharedMaterial;
				if (sharedMaterial.HasProperty("_EmissionColor"))
				{
					sharedMaterial.EnableKeyword("_EMISSION");
					sharedMaterial.SetColor("_EmissionColor", new Color(0.65f, 0.04f, 0.005f));
				}
				AddFire(new Vector3((float)(m * 3), 1.35f, 2f));
				GameObject val = new GameObject("EmberLight", new Type[1] { typeof(Light) });
				val.transform.SetParent(Root.transform, false);
				val.transform.localPosition = new Vector3((float)(m * 3), 2f, 2f);
				Light component = val.GetComponent<Light>();
				component.color = new Color(1f, 0.12f, 0.035f);
				component.range = 10f;
				component.intensity = 2f;
				component.renderMode = (LightRenderMode)1;
			}
			GameObject val2 = new GameObject("SoulLight", new Type[1] { typeof(Light) });
			val2.transform.SetParent(Root.transform, false);
			val2.transform.localPosition = new Vector3(0f, 4f, 0f);
			Light component2 = val2.GetComponent<Light>();
			component2.color = new Color(0.8f, 0.42f, 0.32f);
			component2.range = 12f;
			component2.intensity = 1.6f;
			component2.renderMode = (LightRenderMode)1;
			GameObject val3 = new GameObject("ThroneGlow", new Type[1] { typeof(Light) });
			val3.transform.SetParent(Root.transform, false);
			val3.transform.localPosition = new Vector3(0f, 3f, 7.9f);
			Light component3 = val3.GetComponent<Light>();
			component3.color = new Color(1f, 0.13f, 0.035f);
			component3.range = 8f;
			component3.intensity = 0.8f;
			component3.renderMode = (LightRenderMode)1;
			GameObject val4 = new GameObject("HelFaceLight", new Type[1] { typeof(Light) });
			val4.transform.SetParent(Root.transform, false);
			val4.transform.localPosition = new Vector3(0f, 2.8f, 5.2f);
			Light component4 = val4.GetComponent<Light>();
			component4.color = new Color(0.45f, 0.48f, 0.55f);
			component4.range = 4f;
			component4.intensity = 3f;
			component4.renderMode = (LightRenderMode)1;
			if (Object.op_Implicit((Object)(object)GameCamera.instance) && !Object.op_Implicit((Object)(object)((Component)GameCamera.instance).GetComponent<HelAtmosphere>()))
			{
				((Component)GameCamera.instance).gameObject.AddComponent<HelAtmosphere>();
			}
			CreateExitPortal();
			HelFigure.Create(Root.transform);
			Physics.SyncTransforms();
		}

		private static void CreateExitPortal()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: 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_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ReturnPortal");
			val.transform.SetParent(Root.transform, false);
			val.transform.localPosition = ExitPosition;
			GameObject prefab = ZNetScene.instance.GetPrefab("portal_wood");
			if (Object.op_Implicit((Object)(object)prefab))
			{
				MeshFilter[] componentsInChildren = prefab.GetComponentsInChildren<MeshFilter>(true);
				foreach (MeshFilter val2 in componentsInChildren)
				{
					MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>();
					if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)val2.sharedMesh))
					{
						GameObject val3 = new GameObject("Portal_" + ((Object)val2).name, new Type[2]
						{
							typeof(MeshFilter),
							typeof(MeshRenderer)
						});
						val3.transform.SetParent(val.transform, false);
						val3.transform.localPosition = prefab.transform.InverseTransformPoint(((Component)val2).transform.position);
						val3.transform.localRotation = Quaternion.Inverse(prefab.transform.rotation) * ((Component)val2).transform.rotation;
						val3.transform.localScale = ((Component)val2).transform.lossyScale;
						val3.GetComponent<MeshFilter>().sharedMesh = val2.sharedMesh;
						((Renderer)val3.GetComponent<MeshRenderer>()).sharedMaterials = ((Renderer)component).sharedMaterials;
					}
				}
				ParticleSystem[] componentsInChildren2 = prefab.GetComponentsInChildren<ParticleSystem>(true);
				foreach (ParticleSystem val4 in componentsInChildren2)
				{
					if (((Component)val4).GetComponentsInChildren<MonoBehaviour>(true).Length == 0)
					{
						GameObject obj = Object.Instantiate<GameObject>(((Component)val4).gameObject, val.transform, false);
						obj.transform.localPosition = prefab.transform.InverseTransformPoint(((Component)val4).transform.position);
						obj.transform.localRotation = Quaternion.Inverse(prefab.transform.rotation) * ((Component)val4).transform.rotation;
						obj.SetActive(true);
						MainModule main = obj.GetComponent<ParticleSystem>().main;
						((MainModule)(ref main)).loop = true;
						obj.GetComponent<ParticleSystem>().Play(true);
					}
				}
			}
			else
			{
				Block("PortalLeft", ExitPosition + new Vector3(-1.4f, 1.6f, 0f), new Vector3(0.5f, 3.2f, 0.6f), new Color(0.2f, 0.14f, 0.1f));
				Block("PortalRight", ExitPosition + new Vector3(1.4f, 1.6f, 0f), new Vector3(0.5f, 3.2f, 0.6f), new Color(0.2f, 0.14f, 0.1f));
				Block("PortalLintel", ExitPosition + new Vector3(0f, 3.2f, 0f), new Vector3(3.3f, 0.5f, 0.6f), new Color(0.2f, 0.14f, 0.1f));
			}
			Light obj2 = val.AddComponent<Light>();
			obj2.type = (LightType)2;
			obj2.color = new Color(1f, 0.4f, 0.08f);
			obj2.range = 6f;
			obj2.intensity = 1.5f;
		}

		private static void AddFire(Vector3 position)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ZNetScene.instance.GetPrefab("fire_pit");
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				prefab = ZNetScene.instance.GetPrefab("piece_groundtorch");
			}
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				return;
			}
			GameObject val = new GameObject("BrazierFire");
			val.transform.SetParent(Root.transform, false);
			val.transform.localPosition = position;
			ParticleSystem[] componentsInChildren = prefab.GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val2 in componentsInChildren)
			{
				string text = ((Object)val2).name.ToLowerInvariant();
				if ((text.Contains("flame") || text.Contains("fire") || text.Contains("spark") || text.Contains("sparc") || text.Contains("ember")) && ((Component)val2).GetComponentsInChildren<ZNetView>(true).Length == 0 && ((Component)val2).GetComponentsInChildren<MonoBehaviour>(true).Length == 0)
				{
					GameObject obj = Object.Instantiate<GameObject>(((Component)val2).gameObject, val.transform, false);
					((Object)obj).name = "HelFire_" + ((Object)val2).name;
					obj.transform.localPosition = Vector3.zero;
					obj.transform.localRotation = Quaternion.identity;
					obj.transform.localScale = Vector3.one * 0.8f;
					obj.SetActive(true);
					ParticleSystem[] componentsInChildren2 = obj.GetComponentsInChildren<ParticleSystem>(true);
					foreach (ParticleSystem obj2 in componentsInChildren2)
					{
						MainModule main = obj2.main;
						((MainModule)(ref main)).loop = true;
						obj2.Play(true);
					}
					FireEffects++;
				}
			}
		}

		private static GameObject Block(string name, Vector3 pos, Vector3 scale, Color color)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Expected O, but got Unknown
			//IL_0258: 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_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = name;
			val.layer = LayerMask.NameToLayer("Default");
			val.transform.SetParent(Root.transform, false);
			val.transform.localPosition = pos;
			val.transform.localScale = scale;
			if (!Object.op_Implicit((Object)(object)stoneMaterial))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("stone_floor_2x2");
				stoneMaterial = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponentsInChildren<MeshRenderer>(true).SelectMany((MeshRenderer r) => ((Renderer)r).sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => Object.op_Implicit((Object)(object)m) && ((Object)m.shader).name == "Custom/Piece")) : null);
				MeshRenderer val2 = (Object.op_Implicit((Object)(object)prefab) ? ((IEnumerable<MeshRenderer>)prefab.GetComponentsInChildren<MeshRenderer>(true)).FirstOrDefault((Func<MeshRenderer, bool>)((MeshRenderer r) => (Object)(object)((Renderer)r).sharedMaterial == (Object)(object)stoneMaterial && Object.op_Implicit((Object)(object)((Component)r).GetComponent<MeshFilter>()))) : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					stoneMesh = Object.Instantiate<Mesh>(((Component)val2).GetComponent<MeshFilter>().sharedMesh);
					Bounds bounds = stoneMesh.bounds;
					Vector3[] vertices = stoneMesh.vertices;
					for (int num = 0; num < vertices.Length; num++)
					{
						Vector3 val3 = vertices[num] - ((Bounds)(ref bounds)).center;
						vertices[num] = new Vector3(val3.x / Mathf.Max(0.001f, ((Bounds)(ref bounds)).size.x), val3.y / Mathf.Max(0.001f, ((Bounds)(ref bounds)).size.y), val3.z / Mathf.Max(0.001f, ((Bounds)(ref bounds)).size.z));
					}
					stoneMesh.vertices = vertices;
					stoneMesh.RecalculateNormals();
					stoneMesh.RecalculateBounds();
					Assets.Add((Object)(object)stoneMesh);
				}
				if (!Object.op_Implicit((Object)(object)stoneMaterial))
				{
					stoneMaterial = Resources.FindObjectsOfTypeAll<Material>().First((Material m) => Object.op_Implicit((Object)(object)m) && Object.op_Implicit((Object)(object)m.shader));
				}
			}
			Material val4 = new Material(stoneMaterial);
			if (val4.HasProperty("_Color"))
			{
				val4.SetColor("_Color", Color.Lerp(color, Color.white, 0.15f));
			}
			if (Object.op_Implicit((Object)(object)stoneMesh))
			{
				val.GetComponent<MeshFilter>().sharedMesh = stoneMesh;
			}
			Assets.Add((Object)(object)val4);
			val.GetComponent<Renderer>().sharedMaterial = val4;
			return val;
		}

		public static void Pose()
		{
			//IL_0025: 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_0044: Expected O, but got Unknown
			//IL_04a4: 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_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: 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_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Expected O, but got Unknown
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: 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_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0589: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: 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_03dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0650: Unknown result type (might be due to invalid IL or missing references)
			//IL_065e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0663: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: 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_05f3: 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_061c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0621: 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_069d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_070e: 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_0729: Unknown result type (might be due to invalid IL or missing references)
			//IL_073e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0750: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Unknown result type (might be due to invalid IL or missing references)
			//IL_0777: Unknown result type (might be due to invalid IL or missing references)
			//IL_0782: Unknown result type (might be due to invalid IL or missing references)
			//IL_0787: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Root) || bodyCreated || !Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				return;
			}
			GameObject val = ZNetScene.instance.FindInstance(Client.Dead);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			GameObject val2 = new GameObject("WaitingSoul");
			val2.transform.SetParent(Root.transform, false);
			SkinnedMeshRenderer[] componentsInChildren = val.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			Transform[] array = (from b in componentsInChildren.SelectMany((SkinnedMeshRenderer s) => s.bones)
				where Object.op_Implicit((Object)(object)b)
				select b).Distinct().ToArray();
			Dictionary<Transform, Quaternion> dictionary = array.ToDictionary((Transform b) => b, (Transform b) => b.localRotation);
			Dictionary<Transform, Vector3> dictionary2 = array.ToDictionary((Transform b) => b, (Transform b) => b.localPosition);
			Dictionary<Transform, Matrix4x4> dictionary3 = new Dictionary<Transform, Matrix4x4>();
			SkinnedMeshRenderer[] array2 = componentsInChildren;
			foreach (SkinnedMeshRenderer val3 in array2)
			{
				if (!Object.op_Implicit((Object)(object)val3.sharedMesh))
				{
					continue;
				}
				Matrix4x4[] bindposes = val3.sharedMesh.bindposes;
				for (int num2 = 0; num2 < val3.bones.Length && num2 < bindposes.Length; num2++)
				{
					if (Object.op_Implicit((Object)(object)val3.bones[num2]) && !dictionary3.ContainsKey(val3.bones[num2]))
					{
						dictionary3.Add(val3.bones[num2], ((Component)val3).transform.localToWorldMatrix * ((Matrix4x4)(ref bindposes[num2])).inverse);
					}
				}
			}
			Matrix4x4 val4;
			foreach (KeyValuePair<Transform, Matrix4x4> item in dictionary3.OrderBy((KeyValuePair<Transform, Matrix4x4> p) => Depth(p.Key)))
			{
				Transform key = item.Key;
				val4 = item.Value;
				Vector3 val5 = Vector4.op_Implicit(((Matrix4x4)(ref val4)).GetColumn(3));
				val4 = item.Value;
				Vector3 val6 = Vector4.op_Implicit(((Matrix4x4)(ref val4)).GetColumn(2));
				val4 = item.Value;
				key.SetPositionAndRotation(val5, Quaternion.LookRotation(val6, Vector4.op_Implicit(((Matrix4x4)(ref val4)).GetColumn(1))));
			}
			RelaxedLimbs = Relax(array);
			Transform val7 = ((IEnumerable<Transform>)array).FirstOrDefault((Func<Transform, bool>)((Transform b) => ((Object)b).name.Equals("Head", StringComparison.OrdinalIgnoreCase)));
			Vector3? val8 = (Object.op_Implicit((Object)(object)val7) ? new Vector3?(val.transform.InverseTransformPoint(val7.position)) : ((Vector3?)null));
			try
			{
				array2 = componentsInChildren;
				foreach (SkinnedMeshRenderer val9 in array2)
				{
					if (Object.op_Implicit((Object)(object)val9.sharedMesh) && ((Renderer)val9).enabled)
					{
						Mesh val10 = new Mesh();
						val9.BakeMesh(val10, false);
						Assets.Add((Object)(object)val10);
						Matrix4x4 val11 = val.transform.worldToLocalMatrix * ((Component)val9).transform.localToWorldMatrix;
						Vector3[] vertices = val10.vertices;
						for (int num3 = 0; num3 < vertices.Length; num3++)
						{
							vertices[num3] = ((Matrix4x4)(ref val11)).MultiplyPoint3x4(vertices[num3]);
						}
						val10.vertices = vertices;
						Vector3[] normals = val10.normals;
						val4 = ((Matrix4x4)(ref val11)).inverse;
						Matrix4x4 transpose = ((Matrix4x4)(ref val4)).transpose;
						for (int num4 = 0; num4 < normals.Length; num4++)
						{
							int num5 = num4;
							Vector3 val12 = ((Matrix4x4)(ref transpose)).MultiplyVector(normals[num4]);
							normals[num5] = ((Vector3)(ref val12)).normalized;
						}
						val10.normals = normals;
						val10.RecalculateBounds();
						GameObject val13 = new GameObject("SoulMesh", new Type[2]
						{
							typeof(MeshFilter),
							typeof(MeshRenderer)
						});
						val13.transform.SetParent(val2.transform, false);
						val13.GetComponent<MeshFilter>().sharedMesh = val10;
						((Renderer)val13.GetComponent<MeshRenderer>()).sharedMaterials = ((Renderer)val9).sharedMaterials;
					}
				}
			}
			finally
			{
				foreach (KeyValuePair<Transform, Quaternion> item2 in dictionary)
				{
					if (Object.op_Implicit((Object)(object)item2.Key))
					{
						item2.Key.localRotation = item2.Value;
					}
				}
				foreach (KeyValuePair<Transform, Vector3> item3 in dictionary2)
				{
					if (Object.op_Implicit((Object)(object)item3.Key))
					{
						item3.Key.localPosition = item3.Value;
					}
				}
			}
			Renderer[] componentsInChildren2 = val2.GetComponentsInChildren<Renderer>();
			if (componentsInChildren2.Length == 0)
			{
				Object.Destroy((Object)(object)val2);
				return;
			}
			Bounds bounds = componentsInChildren2[0].bounds;
			Renderer[] array3 = componentsInChildren2;
			foreach (Renderer val14 in array3)
			{
				((Bounds)(ref bounds)).Encapsulate(val14.bounds);
			}
			Vector3 val15 = val2.transform.InverseTransformPoint(((Bounds)(ref bounds)).center);
			val2.transform.localRotation = ((((Bounds)(ref bounds)).size.y > ((Bounds)(ref bounds)).size.z) ? Quaternion.Euler(90f, 0f, 0f) : Quaternion.Euler(0f, 0f, 180f));
			if (val8.HasValue)
			{
				Vector3 val16 = val2.transform.TransformPoint(val8.Value);
				Vector3 val17 = val2.transform.TransformPoint(val15);
				if (val16.z < val17.z)
				{
					val2.transform.localRotation = Quaternion.Euler(0f, 180f, 0f) * val2.transform.localRotation;
				}
			}
			val2.transform.localRotation = Quaternion.Euler(180f, 0f, 0f) * val2.transform.localRotation;
			bounds = componentsInChildren2[0].bounds;
			array3 = componentsInChildren2;
			foreach (Renderer val18 in array3)
			{
				((Bounds)(ref bounds)).Encapsulate(val18.bounds);
			}
			float num6 = 2.15f / Mathf.Max(0.1f, ((Bounds)(ref bounds)).size.z);
			val2.transform.localScale = Vector3.one * Mathf.Min(1f, num6);
			bounds = componentsInChildren2[0].bounds;
			array3 = componentsInChildren2;
			foreach (Renderer val19 in array3)
			{
				((Bounds)(ref bounds)).Encapsulate(val19.bounds);
			}
			Transform transform = val2.transform;
			transform.position += new Vector3(Root.transform.position.x - ((Bounds)(ref bounds)).center.x, Root.transform.position.y + 1.04f - ((Bounds)(ref bounds)).min.y, Root.transform.position.z + 1f - ((Bounds)(ref bounds)).center.z);
			bodyCreated = true;
			static int Depth(Transform bone)
			{
				int num7 = 0;
				Transform parent = bone.parent;
				while (Object.op_Implicit((Object)(object)parent))
				{
					num7++;
					parent = parent.parent;
				}
				return num7;
			}
		}

		private static int Relax(Transform[] bones)
		{
			//IL_0061: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: 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)
			Transform val = Find("Hips");
			Transform val2 = Find("Head");
			Transform val3 = Find("LeftArm");
			Transform val4 = Find("RightArm");
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val4))
			{
				return 0;
			}
			Vector3 val5 = val2.position - val.position;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			val5 = val4.position - val3.position;
			Vector3 normalized2 = ((Vector3)(ref val5)).normalized;
			val5 = Vector3.Cross(normalized2, normalized);
			Vector3 normalized3 = ((Vector3)(ref val5)).normalized;
			int count = 0;
			bool[] array = new bool[2] { true, false };
			foreach (bool num in array)
			{
				string text = (num ? "Left" : "Right");
				float num2 = ((!num) ? 1 : (-1));
				Aim(text + "Arm", text + "ForeArm", -normalized + normalized2 * (num2 * 0.24f));
				Aim(text + "ForeArm", text + "Hand", -normalized + normalized3 * 0.08f);
				Aim(text + "UpLeg", text + "Leg", -normalized + normalized2 * (num2 * 0.07f));
				Aim(text + "Leg", text + "Foot", -normalized - normalized3 * 0.04f);
			}
			return count;
			void Aim(string jointName, string childName, Vector3 direction)
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				Transform val6 = Find(jointName);
				Transform val7 = Find(childName);
				if (Object.op_Implicit((Object)(object)val6) && Object.op_Implicit((Object)(object)val7))
				{
					Vector3 val8 = val7.position - val6.position;
					if (!(((Vector3)(ref val8)).sqrMagnitude < 1E-05f))
					{
						val6.rotation = Quaternion.FromToRotation(val8, direction) * val6.rotation;
						count++;
					}
				}
			}
			Transform? Find(string name)
			{
				return ((IEnumerable<Transform>)bones).FirstOrDefault((Func<Transform, bool>)((Transform b) => ((Object)b).name.Equals(name, StringComparison.OrdinalIgnoreCase) || ((Object)b).name.EndsWith(":" + name, StringComparison.OrdinalIgnoreCase)));
			}
		}

		public static void Destroy()
		{
			if (Object.op_Implicit((Object)(object)Root))
			{
				Object.Destroy((Object)(object)Root);
			}
			Root = null;
			bodyCreated = false;
			foreach (Object asset in Assets)
			{
				if (Object.op_Implicit(asset))
				{
					Object.Destroy(asset);
				}
			}
			Assets.Clear();
			stoneMaterial = null;
			stoneMesh = null;
		}

		public static void HideBody()
		{
			if (Object.op_Implicit((Object)(object)Root))
			{
				Transform val = Root.transform.Find("WaitingSoul");
				if (Object.op_Implicit((Object)(object)val))
				{
					((Component)val).gameObject.SetActive(false);
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
			bodyCreated = true;
		}
	}
	public static class ChamberMusic
	{
		private static AudioSource? source;

		private static AudioClip? clip;

		private static readonly Dictionary<AudioSource, bool> muted = new Dictionary<AudioSource, bool>();

		private static float gain;

		private static bool entering;

		public const float FadeSeconds = 3f;

		public static bool Active
		{
			get
			{
				if (Object.op_Implicit((Object)(object)source))
				{
					return source.isPlaying;
				}
				return false;
			}
		}

		public static float Volume
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)source))
				{
					return 0f;
				}
				return source.volume;
			}
		}

		public static float Duration
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)clip))
				{
					return 0f;
				}
				return clip.length;
			}
		}

		public static bool Fading
		{
			get
			{
				if (!Client.InChamber)
				{
					return Active;
				}
				return false;
			}
		}

		public static void Tick()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Game.instance))
			{
				Stop();
				return;
			}
			if (!Client.InChamber)
			{
				entering = false;
				if (Object.op_Implicit((Object)(object)source))
				{
					gain = Mathf.MoveTowards(gain, 0f, Time.unscaledDeltaTime / 3f);
					source.volume = gain * Mathf.Clamp01(MusicMan.m_masterMusicVolume);
					if (gain <= 0f)
					{
						Stop();
					}
				}
				return;
			}
			if (!Object.op_Implicit((Object)(object)source))
			{
				if (!Object.op_Implicit((Object)(object)clip))
				{
					clip = LoadWav("HelResurrection.Theme.wav", "The Threshold of Hel");
				}
				source = new GameObject("Hel chamber soundtrack").AddComponent<AudioSource>();
				source.clip = clip;
				source.loop = true;
				source.spatialBlend = 0f;
				source.playOnAwake = false;
				source.volume = 0f;
			}
			if (!entering)
			{
				source.Stop();
				source.timeSamples = 0;
				gain = 1f;
				source.Play();
				entering = true;
			}
			float masterMusicVolume = MusicMan.m_masterMusicVolume;
			source.volume = gain * Mathf.Clamp01(masterMusicVolume);
			if (!Object.op_Implicit((Object)(object)MusicMan.instance))
			{
				return;
			}
			AudioSource[] componentsInChildren = ((Component)MusicMan.instance).GetComponentsInChildren<AudioSource>(true);
			foreach (AudioSource val in componentsInChildren)
			{
				if (!muted.ContainsKey(val))
				{
					muted.Add(val, val.mute);
				}
				val.mute = true;
			}
		}

		public static void Leave()
		{
			entering = false;
		}

		public static void Stop()
		{
			if (Object.op_Implicit((Object)(object)source))
			{
				source.Stop();
				Object.Destroy((Object)(object)((Component)source).gameObject);
			}
			source = null;
			gain = 0f;
			entering = false;
			foreach (KeyValuePair<AudioSource, bool> item in muted)
			{
				if (Object.op_Implicit((Object)(object)item.Key))
				{
					item.Key.mute = item.Value;
				}
			}
			muted.Clear();
		}

		public static void Destroy()
		{
			Stop();
			if (Object.op_Implicit((Object)(object)clip))
			{
				Object.Destroy((Object)(object)clip);
			}
			clip = null;
		}

		internal static AudioClip LoadWav(string resource, string title)
		{
			using Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream(resource);
			using BinaryReader binaryReader = new BinaryReader(stream);
			if (new string(binaryReader.ReadChars(4)) != "RIFF")
			{
				throw new InvalidDataException("Invalid Hel soundtrack RIFF header");
			}
			binaryReader.ReadUInt32();
			if (new string(binaryReader.ReadChars(4)) != "WAVE")
			{
				throw new InvalidDataException("Invalid Hel soundtrack WAV header");
			}
			int num = 0;
			int num2 = 0;
			long position = 0L;
			int num3 = 0;
			while (stream.Position + 8 <= stream.Length)
			{
				string text = new string(binaryReader.ReadChars(4));
				uint num4 = binaryReader.ReadUInt32();
				long num5 = stream.Position + num4 + num4 % 2;
				if (num5 > stream.Length)
				{
					throw new InvalidDataException("Truncated Hel soundtrack");
				}
				if (text == "fmt ")
				{
					if (num4 < 16 || binaryReader.ReadUInt16() != 1)
					{
						throw new InvalidDataException("Hel soundtrack requires PCM WAV");
					}
					num2 = binaryReader.ReadUInt16();
					num = binaryReader.ReadInt32();
					binaryReader.ReadInt32();
					binaryReader.ReadUInt16();
					if (binaryReader.ReadUInt16() != 16)
					{
						throw new InvalidDataException("Hel soundtrack requires 16-bit PCM");
					}
				}
				if (text == "data")
				{
					position = stream.Position;
					num3 = checked((int)num4);
				}
				stream.Position = num5;
			}
			if (num2 < 1 || num2 > 2 || num <= 0 || num3 == 0 || num3 % (num2 * 2) != 0)
			{
				throw new InvalidDataException("Invalid Hel soundtrack audio format");
			}
			stream.Position = position;
			float[] array = new float[num3 / 2];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = (float)binaryReader.ReadInt16() / 32768f;
			}
			AudioClip val = AudioClip.Create(title, array.Length / num2, num2, num, false);
			typeof(AudioClip).GetMethod("SetData", new Type[2]
			{
				typeof(float[]),
				typeof(int)
			}).Invoke(val, new object[2] { array, 0 });
			return val;
		}
	}
	public static class ChamberSafety
	{
		[HarmonyPatch(typeof(Character), "ApplyDamage")]
		private static class DamageTicks
		{
			private static bool Prefix(Character __instance)
			{
				return !Protected(__instance);
			}
		}

		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		private static class IncomingDamage
		{
			private static bool Prefix(Character __instance)
			{
				return !Protected(__instance);
			}
		}

		[HarmonyPatch(typeof(Character), "SetHealth")]
		private static class MinimumHealth
		{
			private static void Prefix(Character __instance, ref float health)
			{
				if (Protected(__instance))
				{
					health = Mathf.Max(1f, health);
				}
			}
		}

		[HarmonyPatch(typeof(Character), "CheckDeath")]
		private static class DeathCheck
		{
			private static bool Prefix(Character __instance)
			{
				if (!Protected(__instance))
				{
					return true;
				}
				if (__instance.GetHealth() <= 0f)
				{
					__instance.SetHealth(1f);
				}
				return false;
			}
		}

		internal static bool Protected(Character player)
		{
			//IL_0029: 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)
			if ((Object)(object)player == (Object)(object)Player.m_localPlayer && Client.InChamber && !Client.Waiting && !player.IsDead())
			{
				return Vector3.Distance(((Component)player).transform.position, Client.Room) <= 18f;
			}
			return false;
		}
	}
	public static class Client
	{
		public static bool Waiting;

		public static bool InChamber;

		public static bool AllowRespawn;

		public static bool RescueComplete;

		public static bool SpawningInHel;

		public static ZDOID Grave;

		public static ZDOID Dead;

		public static Vector3? ReturnPoint;

		public static Vector3? RevivePoint;

		public static Vector3 Room;

		public static float Progress;

		public static readonly RespawnHold RespawnGesture = new RespawnHold();

		public static readonly RevivalProgress Revival = new RevivalProgress();

		public static float DeathStarted;

		public static float ChamberEntered;

		public const float DeathSceneSeconds = 2.5f;

		private static float nextSend;

		private static float holdStart;

		private static float lastServer;

		private static float nextEmote;

		private static ZDOID praying;

		private const string Recovery = "branchofyore.helresurrection.return";

		private static bool holding;

		private static bool wakePending;

		private static float nextWake;

		private static float wakeDeadline;

		private static Vector3? landing;

		private static float landingStarted;

		public static float ReceivedProgress => Revival.Evaluate(Time.unscaledTime, Object.op_Implicit((Object)(object)ZNet.instance) ? ZNet.instance.GetTimeSeconds() : 0.0);

		public static bool BeingRevived
		{
			get
			{
				if (Waiting && InChamber)
				{
					return Revival.Active(Time.unscaledTime);
				}
				return false;
			}
		}

		public static void Wait(Player p, TombStone grave)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			Waiting = true;
			DeathStarted = Time.unscaledTime;
			ChamberEntered = -1f;
			Grave = Plugin.Data((Component?)(object)grave).m_uid;
			Dead = ((Character)p).GetZDOID();
			ReturnPoint = Plugin.Data((Component?)(object)grave).GetVec3("branchofyore.helresurrection.returnFeet", ((Component)grave).transform.position);
			Plugin.Data((Component?)(object)p).Set("branchofyore.helresurrection.waiting", true);
			nextSend = 0f;
		}

		public static void Move(Player p, Vector3 point)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Rigidbody component = ((Component)p).GetComponent<Rigidbody>();
			component.position = point;
			component.linearVelocity = Vector3.zero;
			((Component)p).transform.position = point;
			Plugin.Data((Component?)(object)p).SetPosition(point);
			AccessTools.Field(typeof(Character), "m_maxAirAltitude").SetValue(p, point.y);
			ZNet.instance.SetReferencePosition(point);
			Physics.SyncTransforms();
		}

		public static void Recover(Player p)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (!InChamber && !SpawningInHel && p.m_customData.TryGetValue("branchofyore.helresurrection.return", out var value))
			{
				string[] array = value.Split(new char[1] { '|' });
				if (array.Length == 3 && float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3))
				{
					Land(p, new Vector3(result, result2, result3));
				}
				p.m_customData.Remove("branchofyore.helresurrection.return");
			}
		}

		public static void Receive(long sender, ZPackage pkg)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			if (sender != Network.ServerId || pkg.GetArray().Length > 256)
			{
				return;
			}
			try
			{
				int num = pkg.ReadInt();
				ZDOID val = pkg.ReadZDOID();
				ZDOID val2 = pkg.ReadZDOID();
				Vector3 room = pkg.ReadVector3();
				Vector3 val3 = pkg.ReadVector3();
				Player localPlayer = Player.m_localPlayer;
				if (!Object.op_Implicit((Object)(object)localPlayer))
				{
					return;
				}
				if (num == 0 && Waiting && Grave == val && Dead == val2)
				{
					lastServer = Time.unscaledTime;
					if (!InChamber && Time.unscaledTime - DeathStarted >= 2.5f)
					{
						Enter(localPlayer, val, val2, room, val3);
					}
				}
				else if (num == 1 && !((Character)localPlayer).IsDead() && !InChamber && praying == val)
				{
					Enter(localPlayer, val, val2, room, val3);
				}
				else if (num == 2 && Waiting && Grave == val && Dead == val2)
				{
					Room = room;
					ReturnPoint = val3;
					Respawn(revived: true);
				}
				else if (num == 3 && InChamber && !Waiting && !RescueComplete && Grave == val)
				{
					Cancel();
				}
				else if (num == 4 && InChamber && !Waiting && Grave == val)
				{
					lastServer = Time.unscaledTime;
				}
				else if (num == 7 && InChamber && !RescueComplete && Grave == val && Dead == val2)
				{
					float value = pkg.ReadSingle();
					Revival.Receive(value, pkg.ReadDouble(), Time.unscaledTime);
				}
				else if (num == 6 && InChamber && !Waiting && Grave == val && Dead == val2)
				{
					RescueComplete = true;
					StopHold();
					Chamber.HideBody();
				}
			}
			catch (Exception e)
			{
				Plugin.Error(e);
			}
		}

		private static void Enter(Player p, ZDOID grave, ZDOID dead, Vector3 room, Vector3 back)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			landing = null;
			Grave = grave;
			Dead = dead;
			Room = room;
			ReturnPoint = back;
			p.m_customData["branchofyore.helresurrection.return"] = string.Join("|", back.x.ToString("R", CultureInfo.InvariantCulture), back.y.ToString("R", CultureInfo.InvariantCulture), back.z.ToString("R", CultureInfo.InvariantCulture));
			UseInteraction.Reset();
			Chamber.Create(room, dead);
			InChamber = true;
			ChamberEntered = Time.unscaledTime;
			StopHold();
			Move(p, room + (Waiting ? new Vector3(0f, 1f, 1f) : new Vector3(0f, 1f, -4f)));
			lastServer = Time.unscaledTime;
		}

		public static void Respawn(bool revived = false)
		{
			//IL_00a6: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			if (!Waiting)
			{
				return;
			}
			if (revived)
			{
				Player localPlayer = Player.m_localPlayer;
				if (Object.op_Implicit((Object)(object)localPlayer))
				{
					Plugin.Data((Component?)(object)localPlayer).Set("branchofyore.helresurrection.waiting", false);
				}
				StopHold();
				RespawnGesture.Reset();
				Revival.Reset();
				Waiting = false;
				RescueComplete = (SpawningInHel = true);
				RevivePoint = Room + new Vector3(0f, 1.2f, 1f);
				Chamber.HideBody();
				AllowRespawn = true;
				try
				{
					Game.instance.RequestRespawn(0f, true);
					return;
				}
				finally
				{
					AllowRespawn = false;
				}
			}
			Network.Send(4, Grave);
			Player localPlayer2 = Player.m_localPlayer;
			if (Object.op_Implicit((Object)(object)localPlayer2))
			{
				Plugin.Data((Component?)(object)localPlayer2).Set("branchofyore.helresurrection.waiting", false);
				if (ReturnPoint.HasValue)
				{
					Move(localPlayer2, ReturnPoint.Value);
				}
				localPlayer2.m_customData.Remove("branchofyore.helresurrection.return");
			}
			Reset();
			AllowRespawn = true;
			try
			{
				Game.instance.RequestRespawn(0f, true);
			}
			finally
			{
				AllowRespawn = false;
			}
			if (!revived)
			{
				RevivePoint = null;
			}
		}

		public static void Spawned(Player player)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			if (SpawningInHel && InChamber && ReturnPoint.HasValue)
			{
				Move(player, Room + new Vector3(0f, 1.2f, 1f));
				RevivePoint = null;
				landing = null;
				SpawningInHel = false;
				Waiting = false;
				RescueComplete = true;
				Vector3 value = ReturnPoint.Value;
				player.m_customData["branchofyore.helresurrection.return"] = string.Join("|", value.x.ToString("R", CultureInfo.InvariantCulture), value.y.ToString("R", CultureInfo.InvariantCulture), value.z.ToString("R", CultureInfo.InvariantCulture));
				Chamber.HideBody();
				ChamberEntered = Time.unscaledTime;
				RitualAudio.Awaken(Grave, ((Component)player).transform.position);
				wakePending = true;
				nextWake = Time.unscaledTime + 0.25f;
				wakeDeadline = Time.unscaledTime + 10f;
				Network.Send(6, Grave);
			}
			else
			{
				RevivePoint = null;
				if (!InChamber || !RescueComplete)
				{
					Recover(player);
				}
			}
		}

		private static void Land(Player player, Vector3 point)
		{
			//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 = point;
			landingStarted = Time.unscaledTime;
			Move(player, point);
		}

		public static void Cancel()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (Waiting)
			{
				Respawn();
				return;
			}
			ZDOID grave = Grave;
			bool inChamber = InChamber;
			Player localPlayer = Player.m_localPlayer;
			if (Object.op_Implicit((Object)(object)localPlayer) && ReturnPoint.HasValue)
			{
				Land(localPlayer, ReturnPoint.Value);
				localPlayer.m_customData.Remove("branchofyore.helresurrection.return");
			}
			Reset();
			if (inChamber)
			{
				Network.Send(5, grave);
			}
		}

		public static void PrepareLogout()
		{
			//IL_001f: 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)
			Player localPlayer = Player.m_localPlayer;
			if (Waiting || InChamber)
			{
				Network.Send(Waiting ? 4 : 5, Grave);
				if (Object.op_Implicit((Object)(object)localPlayer))
				{
					if (Waiting)
					{
						ZDO? obj = Plugin.Data((Component?)(object)localPlayer);
						if (obj != null)
						{
							obj.Set("branchofyore.helresurrection.waiting", false);
						}
					}
					if (ReturnPoint.HasValue)
					{
						Move(localPlayer, ReturnPoint.Value);
					}
				}
			}
			Reset();
			RevivePoint = null;
			landing = null;
		}

		public static void Reset()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			ChamberMusic.Leave();
			wakePending = false;
			UseInteraction.Reset();
			StopHold();
			Waiting = (InChamber = (RescueComplete = (SpawningInHel = false)));
			Grave = (Dead = ZDOID.None);
			ReturnPoint = null;
			Chamber.Destroy();
			RespawnGesture.Reset();
			Revival.Reset();
			nextSend = 0f;
			DeathStarted = (ChamberEntered = -1f);
		}

		private static bool MenuOpen()
		{
			if (!Menu.IsVisible() && !InventoryGui.IsVisible() && !Console.IsVisible() && !TextInput.IsVisible() && (!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Minimap.IsOpen())
			{
				return !Application.isFocused;
			}
			return true;
		}

		public static void Tick()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: 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_0332: 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_041e: 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_03d1: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (wakePending && InChamber && RescueComplete && !SpawningInHel && Object.op_Implicit((Object)(object)localPlayer) && !((Character)localPlayer).IsDead())
			{
				if (Time.unscaledTime > wakeDeadline)
				{
					wakePending = false;
				}
				else if (Time.unscaledTime >= nextWake)
				{
					nextWake = Time.unscaledTime + 0.25f;
					Network.Send(6, Grave);
				}
			}
			if (SpawningInHel)
			{
				return;
			}
			if (landing.HasValue && Object.op_Implicit((Object)(object)localPlayer))
			{
				if (!((Character)localPlayer).IsDead() && !InChamber)
				{
					Move(localPlayer, landing.Value);
					if ((Time.unscaledTime - landingStarted > 0.75f && ZNetScene.instance.IsAreaReady(landing.Value)) || Time.unscaledTime - landingStarted > 15f)
					{
						landing = null;
					}
					return;
				}
				landing = null;
			}
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				if (InChamber || Waiting)
				{
					Reset();
				}
				return;
			}
			if (!InChamber && !Waiting)
			{
				Recover(localPlayer);
			}
			if (Waiting)
			{
				if (!((Character)localPlayer).IsDead())
				{
					Reset();
					return;
				}
				if (InChamber)
				{
					Move(localPlayer, Room + new Vector3(0f, 1f, 1f));
				}
				if (RespawnGesture.Step(Input.GetKey((KeyCode)114), !MenuOpen(), Time.unscaledTime))
				{
					Respawn();
				}
				else if (Time.unscaledTime >= nextSend)
				{
					nextSend = Time.unscaledTime + 0.5f;
					Network.Send(0, Grave);
				}
				return;
			}
			if (InChamber && ((Character)localPlayer).IsDead())
			{
				Cancel();
				return;
			}
			if (TryExitPortal())
			{
				return;
			}
			if (InChamber && RescueComplete)
			{
				StopHold();
				if (Vector3.Distance(((Component)localPlayer).transform.position, Room) > 18f)
				{
					Cancel();
				}
				return;
			}
			GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject();
			TombStone val = (Object.op_Implicit((Object)(object)hoverObject) ? hoverObject.GetComponentInParent<TombStone>() : null);
			ZDO dead;
			ZDOID val2 = (InChamber ? Grave : ((Object.op_Implicit((Object)(object)val) && Network.Eligible(Plugin.Data((Component?)(object)val), out dead)) ? Plugin.Data((Component?)(object)val).m_uid : ZDOID.None));
			bool flag = (InChamber ? (Vector3.Distance(((Component)localPlayer).transform.position, Room + new Vector3(0f, 1f, 1f)) <= 3f) : (Object.op_Implicit((Object)(object)val) && Vector3.Distance(((Component)localPlayer).transform.position, ((Component)val).transform.position) <= 4f));
			bool flag2 = !((Character)localPlayer).IsDead() && !((Character)localPlayer).IsTeleporting() && !MenuOpen() && flag && val2 != ZDOID.None;
			bool num;
			if (!InChamber)
			{
				num = UseInteraction.Tick(localPlayer, val, flag2);
			}
			else
			{
				if (!flag2)
				{
					goto IL_03d9;
				}
				num = UseInteraction.Down;
			}
			if (!num)
			{
				goto IL_03d9;
			}
			if (!holding || praying != val2)
			{
				BeginHold(val2);
			}
			else if (Time.unscaledTime >= nextEmote && !((Character)localPlayer).InEmote())
			{
				localPlayer.StartEmote(InChamber ? "kneel" : "despair", true);
				nextEmote = Time.unscaledTime + 1f;
			}
			Progress = (InChamber ? ReceivedProgress : Mathf.Clamp01((Time.unscaledTime - holdStart) / 4f));
			if (Time.unscaledTime >= nextSend)
			{
				nextSend = Time.unscaledTime + 0.2f;
				Network.Send((!InChamber) ? 1 : 2, val2);
			}
			goto IL_040c;
			IL_03d9:
			StopHold();
			if (InChamber && Time.unscaledTime >= nextSend)
			{
				nextSend = Time.unscaledTime + 0.3f;
				Network.Send(3, Grave);
			}
			goto IL_040c;
			IL_040c:
			if (InChamber && (Vector3.Distance(((Component)localPlayer).transform.position, Room) > 18f || Time.unscaledTime - lastServer > 12f))
			{
				Cancel();
			}
		}

		internal static void WakeSoundConfirmed(ZDOID grave)
		{
			//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)
			if (wakePending && Grave == grave)
			{
				wakePending = false;
			}
		}

		private static void BeginHold(ZDOID target)
		{
			//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)
			StopHold();
			holding = true;
			praying = target;
			holdStart = Time.unscaledTime;
			Player.m_localPlayer.StartEmote(InChamber ? "kneel" : "despair", true);
			nextEmote = Time.unscaledTime + 1f;
			RitualAudio.Start(InChamber);
		}

		public static void StopHold()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0081: 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)
			RitualAudio.End();
			bool num = holding;
			ZDOID val = praying;
			holding = false;
			praying = ZDOID.None;
			Progress = 0f;
			if (!Waiting)
			{
				Revival.Reset();
			}
			if (num)
			{
				if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					AccessTools.Method(typeof(Player), "StopEmote", (Type[])null, (Type[])null).Invoke(Player.m_localPlayer, null);
				}
				Network.Send(InChamber ? 3 : 5, InChamber ? Grave : val);
			}
		}

		public static bool TryExitPortal()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (!InChamber || Waiting || !ReturnPoint.HasValue || !Object.op_Implicit((Object)(object)localPlayer) || ((Character)localPlayer).IsDead() || ((Character)localPlayer).IsTeleporting())
			{
				return false;
			}
			if (Time.unscaledTime - ChamberEntered < 1f || !Chamber.InExitPortal(((Component)localPlayer).transform.position))
			{
				return false;
			}
			Cancel();
			return true;
		}
	}
	public sealed class HelAtmosphere : MonoBehaviour
	{
		private bool applied;

		private bool fog;

		private FogMode mode;

		private Color color;

		private float density;

		private float start;

		private float end;

		private void OnPreRender()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0080: Unknown result type (might be due to invalid IL or missing references)
			if (Client.InChamber && Object.op_Implicit((Object)(object)Chamber.Root) && !applied)
			{
				fog = RenderSettings.fog;
				mode = RenderSettings.fogMode;
				color = RenderSettings.fogColor;
				density = RenderSettings.fogDensity;
				start = RenderSettings.fogStartDistance;
				end = RenderSettings.fogEndDistance;
				applied = true;
				RenderSettings.fog = true;
				RenderSettings.fogMode = (FogMode)3;
				RenderSettings.fogColor = new Color(0.065f, 0.012f, 0.016f);
				RenderSettings.fogDensity = 0.065f;
			}
		}

		private void OnPostRender()
		{
			Restore();
		}

		private void OnDisable()
		{
			Restore();
		}

		private void Restore()
		{
			//IL_0015: 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)
			if (applied)
			{
				RenderSettings.fog = fog;
				RenderSettings.fogMode = mode;
				RenderSettings.fogColor = color;
				RenderSettings.fogDensity = density;
				RenderSettings.fogStartDistance = start;
				RenderSettings.fogEndDistance = end;
				applied = false;
			}
		}
	}
	public sealed class HelFigure : MonoBehaviour, Hoverable, Interactable, IDestructible
	{
		private readonly List<Object> owned = new List<Object>();

		private readonly Dictionary<Transform, Transform> map = new Dictionary<Transform, Transform>();

		private Transform sourceRoot;

		private Transform head;

		private Transform chest;

		private Transform[] bones;

		private Quaternion headRest;

		private Quaternion chestRest;

		private Vector3 chestPosition;

		private SkinnedMeshRenderer body;

		private float nextTalk;

		private AudioSource? dialogue;

		private static AssetBundle? avatarBundle;

		private readonly List<(Transform shoulder, Transform elbow, Transform hand, Vector3 target, Vector3 pole, Quaternion rest)> restingArms = new List<(Transform, Transform, Transform, Vector3, Vector3, Quaternion)>();

		public int WingTriangles { get; private set; }

		public bool Female { get; private set; }

		public bool Speaking
		{
			get
			{
				if (Object.op_Implicit((Object)(object)dialogue))
				{
					return dialogue.isPlaying;
				}
				return false;
			}
		}

		public float SpeechVolume
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)dialogue))
				{
					return 0f;
				}
				return dialogue.volume;
			}
		}

		public Player? GazeTarget { get; private set; }

		public float GazeYaw { get; private set; }

		public float GazePitch { get; private set; }

		public bool ImportedAvatar { get; private set; }

		public Transform? LeftPalm { get; private set; }

		public Transform? RightPalm { get; private set; }

		public string GetHoverName()
		{
			return "Hel";
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public string GetHoverText()
		{
			if (!Client.InChamber || Client.Waiting)
			{
				return "";
			}
			return "Hel\n[<color=yellow>" + UseInteraction.KeyLabel + "</color>] Talk";
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			//IL_004e: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer || !Client.InChamber || Client.Waiting || ((Character)user).IsDead() || Time.unscaledTime < nextTalk || !Object.op_Implicit((Object)(object)Chat.instance))
			{
				return false;
			}
			MeshCollider component = ((Component)this).GetComponent<MeshCollider>();
			Vector3 position = ((Component)user).transform.position;
			Vector3 val;
			if (!Object.op_Implicit((Object)(object)component))
			{
				val = ((Component)this).transform.position;
			}
			else
			{
				Bounds bounds = ((Collider)component).bounds;
				val = ((Bounds)(ref bounds)).ClosestPoint(((Component)user).transform.position);
			}
			if (Vector3.Distance(position, val) > 4f)
			{
				return false;
			}
			if (!Object.op_Implicit((Object)(object)dialogue))
			{
				dialogue = ((Component)this).gameObject.AddComponent<AudioSource>();
				dialogue.playOnAwake = false;
				dialogue.loop = false;
				dialogue.spatialBlend = 0f;
				dialogue.clip = ChamberMusic.LoadWav("HelResurrection.Voice.wav", "Hel dialogue");
				owned.Add((Object)(object)dialogue.clip);
				dialogue.outputAudioMixerGroup = null;
			}
			dialogue.volume = Mathf.Clamp01(AudioMan.GetSFXVolume());
			dialogue.Play();
			nextTalk = Time.unscaledTime + Mathf.Max(2f, dialogue.clip.length);
			Chat.instance.SetNpcText(((Component)this).gameObject, head.position - ((Component)this).transform.position + Vector3.up * 0.4f, 15f, 5f, "Hel", "Go now. Your time has not yet come.", false);
			return true;
		}

		public static HelFigure Create(Transform room)
		{
			//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)
			GameObject val = new GameObject("HelOnThrone");
			val.transform.SetParent(room, false);
			HelFigure helFigure = val.AddComponent<HelFigure>();
			helFigure.Build();
			helFigure.BuildBodyTarget();
			return helFigure;
		}

		private Transform CopyBone(Transform source)
		{
			//IL_002d: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)source == (Object)(object)sourceRoot)
			{
				return ((Component)this).transform;
			}
			if (map.TryGetValue(source, out Transform value))
			{
				return value;
			}
			Transform transform = new GameObject(((Object)source).name).transform;
			transform.SetParent(CopyBone(source.parent), false);
			transform.localPosition = source.localPosition;
			transform.localRotation = source.localRotation;
			transform.localScale = source.localScale;
			map.Add(source, transform);
			return transform;
		}

		private Material Material(Material original, Color? tint = null)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(original);
			owned.Add((Object)(object)val);
			if (tint.HasValue && val.HasProperty("_Color"))
			{
				val.SetColor("_Color", tint.Value);
			}
			return val;
		}

		private void Build()
		{
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: 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_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: 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_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_060a: Unknown result type (might be due to invalid IL or missing references)
			//IL_061c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: 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)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: 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_0482: 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_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f3: 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_04ff: Unknown result type (might be due to invalid IL or missing references)
			if (BuildImportedAvatar())
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("Player");
			sourceRoot = prefab.transform;
			VisEquipment componentInChildren = prefab.GetComponentInChildren<VisEquipment>(true);
			SkinnedMeshRenderer bodyModel = componentInChildren.m_bodyModel;
			bones = bodyModel.bones.Select(CopyBone).ToArray();
			Transform val = CopyBone(((Component)bodyModel).transform);
			body = ((Component)val).gameObject.AddComponent<SkinnedMeshRenderer>();
			body.sharedMesh = componentInChildren.m_models[1].m_mesh;
			Female = true;
			body.bones = bones;
			body.rootBone = CopyBone(bodyModel.rootBone);
			body.updateWhenOffscreen = true;
			Material[] array = ((Renderer)bodyModel).sharedMaterials.Select((Material m) => Material(m)).ToArray();
			string[] array2 = new string[2] { "_MainTex", "_SkinBumpMap" };
			foreach (string text in array2)
			{
				if (componentInChildren.m_models[1].m_baseMaterial.HasProperty(text))
				{
					array[0].SetTexture(text, componentInChildren.m_models[1].m_baseMaterial.GetTexture(text));
				}
			}
			Material[] array3 = array;
			foreach (Material val2 in array3)
			{
				if (val2.HasProperty("_SkinColor"))
				{
					val2.SetColor("_SkinColor", new Color(0.88f, 0.9f, 0.9f));
				}
				if (val2.HasProperty("_HairColor"))
				{
					val2.SetColor("_HairColor", new Color(0.045f, 0.045f, 0.055f));
				}
			}
			((Renderer)body).sharedMaterials = array;
			Matrix4x4[] bindposes = body.sharedMesh.bindposes;
			foreach (int item in from i in Enumerable.Range(0, bones.Length)
				orderby Depth(bones[i])
				select i)
			{
				Matrix4x4 val3 = ((Component)body).transform.localToWorldMatrix * ((Matrix4x4)(ref bindposes[item])).inverse;
				bones[item].SetPositionAndRotation(Vector4.op_Implicit(((Matrix4x4)(ref val3)).GetColumn(3)), Quaternion.LookRotation(Vector4.op_Implicit(((Matrix4x4)(ref val3)).GetColumn(2)), Vector4.op_Implicit(((Matrix4x4)(ref val3)).GetColumn(1))));
			}
			Attach("ArmorMageChest", componentInChildren, hair: false);
			Attach("ArmorMageLegs", componentInChildren, hair: false);
			Attach("CapeFeather", componentInChildren, hair: false);
			Attach("Hair6", componentInChildren, hair: true);
			head = Bone("Head");
			chest = Bone("Spine2");
			int[] array4 = new int[2] { -1, 1 };
			foreach (int num2 in array4)
			{
				string text2 = ((num2 < 0) ? "Left" : "Right");
				Aim(Bone(text2 + "UpLeg"), Bone(text2 + "Leg"), new Vector3((float)num2 * 0.12f, 0f, 1f));
				Aim(Bone(text2 + "Leg"), Bone(text2 + "Foot"), Vector3.down);
				Aim(Bone