Decompiled source of HelResurrection v0.3.44

plugins/HelResurrection/HelResurrection.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using 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.44.0")]
[assembly: AssemblyInformationalVersion("0.3.44")]
[assembly: AssemblyProduct("HelResurrection")]
[assembly: AssemblyTitle("HelResurrection")]
[assembly: AssemblyVersion("0.3.44.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_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				if (Client.Waiting && Client.InChamber)
				{
					Vector3 val = AltarPosition(Client.AltarSlot);
					((Component)__instance).transform.position = Client.Room + val + new Vector3(4f, 3f, -6f);
					((Component)__instance).transform.rotation = Quaternion.LookRotation(Client.Room + val - ((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);
				}
			}
		}

		[HarmonyPatch(typeof(Player), "GetComfortLevel")]
		private static class Comfort
		{
			private static void Postfix(Player __instance, ref int __result)
			{
				if (Client.InChamber && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && !Client.Waiting)
				{
					__result = 1;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "InShelter")]
		private static class Shelter
		{
			private static void Postfix(Player __instance, ref bool __result)
			{
				if (Client.InChamber && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && !Client.Waiting)
				{
					__result = true;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")]
		private static class Warmth
		{
			private static void Prefix(Player __instance)
			{
				//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_0039: Unknown result type (might be due to invalid IL or missing references)
				if (Client.InChamber && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && !Client.Waiting && Contains(((Component)__instance).transform.position, Client.Room))
				{
					((Character)__instance).OnNearFire(((Component)__instance).transform.position);
				}
			}
		}

		public static GameObject? Root;

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

		private static readonly Dictionary<ZDOID, GameObject> bodies = new Dictionary<ZDOID, GameObject>();

		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, -19.5f);

		private static readonly Dictionary<Renderer, bool> hiddenWaitingRenderers = new Dictionary<Renderer, bool>();

		public static Vector3 AltarPosition(int slot)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3((slot % 2 == 0) ? (-5.2f) : 5.2f, 1f, (float)(-11 + slot / 2 * 5));
		}

		public static bool Contains(Vector3 point, Vector3 center)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = point - center;
			if (Mathf.Abs(val.x) < 14f && Mathf.Abs(val.z) < 22f && val.y > -0.5f)
			{
				return val.y < 14f;
			}
			return false;
		}

		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_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: 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_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0565: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05df: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_063a: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_066d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: 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_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c0: 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_06e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_070b: Unknown result type (might be due to invalid IL or missing references)
			//IL_071f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0733: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Unknown result type (might be due to invalid IL or missing references)
			//IL_0770: Unknown result type (might be due to invalid IL or missing references)
			//IL_0784: Unknown result type (might be due to invalid IL or missing references)
			//IL_0798: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0845: Unknown result type (might be due to invalid IL or missing references)
			//IL_085a: 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_08b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0906: Unknown result type (might be due to invalid IL or missing references)
			//IL_0944: 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_095f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0974: Unknown result type (might be due to invalid IL or missing references)
			//IL_0993: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a28: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3c: 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(28f, 1f, 44f), new Color(0.09f, 0.085f, 0.085f));
			Block("Roof", new Vector3(0f, 12f, 0f), new Vector3(28f, 1f, 44f), new Color(0.025f, 0.025f, 0.03f));
			Block("Back", new Vector3(0f, 6f, 22f), new Vector3(28f, 12f, 1f), new Color(0.04f, 0.035f, 0.04f));
			Block("Front", new Vector3(0f, 6f, -22f), new Vector3(28f, 12f, 1f), new Color(0.04f, 0.035f, 0.04f));
			Block("Left", new Vector3(-14f, 6f, 0f), new Vector3(1f, 12f, 44f), new Color(0.04f, 0.035f, 0.04f));
			Block("Right", new Vector3(14f, 6f, 0f), new Vector3(1f, 12f, 44f), new Color(0.04f, 0.035f, 0.04f));
			for (int i = 0; i < 10; i++)
			{
				Vector3 val = AltarPosition(i) - new Vector3(0f, 1f, 1f);
				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));
				foreach (Transform item in (from Transform t in (IEnumerable)Root.transform
					where ((Object)t).name == "AltarStep" || ((Object)t).name == "AltarBase" || ((Object)t).name == "SoulSlab" || ((Object)t).name == "HeadStone"
					select t).Skip(i * 4))
				{
					item.localPosition += val;
				}
			}
			for (int num = -1; num <= 1; num += 2)
			{
				for (int num2 = 0; num2 < 3; num2++)
				{
					float num3 = -5 + num2 * 5;
					Block("PillarFoot", new Vector3((float)(num * 6), 0.25f, num3), new Vector3(1.7f, 0.5f, 1.7f), new Color(0.12f, 0.14f, 0.16f));
					Block("Pillar", new Vector3((float)(num * 6), 3.1f, num3), new Vector3(1.1f, 5.8f, 1.1f), new Color(0.16f, 0.18f, 0.2f));
					Block("PillarCrown", new Vector3((float)(num * 6), 6.1f, num3), new Vector3(1.7f, 0.45f, 1.7f), new Color(0.13f, 0.15f, 0.18f));
				}
				Block("GatePost", new Vector3((float)num * 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)num * 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)(num * -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 num4 = -1; num4 <= 1; num4 += 2)
			{
				Block("ThroneArm", new Vector3((float)num4 * 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)num4 * 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)(num4 * -18));
				Block("EmberChannel", new Vector3((float)(num4 * 4), 0.025f, 0f), new Vector3(0.16f, 0.04f, 14f), new Color(0.65f, 0.075f, 0.015f));
			}
			for (int num5 = 0; num5 < 6; num5++)
			{
				Block("ProcessionalStone", new Vector3(0f, 0.018f, -7f + (float)num5 * 1.1f), new Vector3(2.3f, 0.035f, 0.85f), new Color(0.18f, 0.2f, 0.22f));
			}
			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 component = val2.GetComponent<Light>();
			component.color = new Color(0.8f, 0.42f, 0.32f);
			component.range = 12f;
			component.intensity = 1.6f;
			component.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 component2 = val3.GetComponent<Light>();
			component2.color = new Color(1f, 0.13f, 0.035f);
			component2.range = 8f;
			component2.intensity = 0.8f;
			component2.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 component3 = val4.GetComponent<Light>();
			component3.color = new Color(0.45f, 0.48f, 0.55f);
			component3.range = 4f;
			component3.intensity = 3f;
			component3.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>();
			}
			foreach (Transform item2 in from Transform t in (IEnumerable)Root.transform
				where ((Object)t).name.StartsWith("Throne")
				select t)
			{
				item2.localPosition += Vector3.forward * 10f;
			}
			AddHallDetails();
			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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			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)
				{
					GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, val.transform, false);
					MonoBehaviour[] componentsInChildren2 = val3.GetComponentsInChildren<MonoBehaviour>(true);
					foreach (MonoBehaviour obj in componentsInChildren2)
					{
						((Behaviour)obj).enabled = false;
						Object.Destroy((Object)(object)obj);
					}
					((Object)val3).name = "HelFire_" + ((Object)val2).name;
					val3.transform.localPosition = Vector3.zero;
					val3.transform.localRotation = Quaternion.identity;
					val3.transform.localScale = Vector3.one * 0.8f;
					val3.SetActive(true);
					ParticleSystem[] componentsInChildren3 = val3.GetComponentsInChildren<ParticleSystem>(true);
					foreach (ParticleSystem obj2 in componentsInChildren3)
					{
						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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Root) || !Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				return;
			}
			UpdateWaitingVisuals();
			KeyValuePair<ZDOID, GameObject>[] array = bodies.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				KeyValuePair<ZDOID, GameObject> keyValuePair = array[i];
				if (!Client.Souls.ContainsKey(keyValuePair.Key))
				{
					Object.Destroy((Object)(object)keyValuePair.Value);
					bodies.Remove(keyValuePair.Key);
				}
			}
			foreach (Client.Soul value in Client.Souls.Values)
			{
				if (!bodies.ContainsKey(value.Grave))
				{
					CreateBody(value);
				}
			}
		}

		private static void CreateBody(Client.Soul soul)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: 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_025c: 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_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Expected O, but got Unknown
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: 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_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: 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_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: 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_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_03be: 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_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Unknown result type (might be due to invalid IL or missing references)
			//IL_071d: 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_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: 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_06a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Expected O, but got Unknown
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0738: Unknown result type (might be due to invalid IL or missing references)
			//IL_075c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0774: Unknown result type (might be due to invalid IL or missing references)
			//IL_0785: Unknown result type (might be due to invalid IL or missing references)
			//IL_0793: Unknown result type (might be due to invalid IL or missing references)
			//IL_0798: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: 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_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07db: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0811: Unknown result type (might be due to invalid IL or missing references)
			//IL_0823: Unknown result type (might be due to invalid IL or missing references)
			//IL_082e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Unknown result type (might be due to invalid IL or missing references)
			//IL_0842: Unknown result type (might be due to invalid IL or missing references)
			//IL_0847: Unknown result type (might be due to invalid IL or missing references)
			//IL_0857: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = ZNetScene.instance.FindInstance(soul.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;
						MeshRenderer component = val13.GetComponent<MeshRenderer>();
						((Renderer)component).sharedMaterials = ((Renderer)val9).sharedMaterials;
						Player component2 = val.GetComponent<Player>();
						ZDO? obj = Plugin.Data((Component?)(object)component2);
						Vector3 val14 = ((obj != null) ? obj.GetVec3(ZDOVars.s_hairColor, Object.op_Implicit((Object)(object)component2) ? component2.GetHairColor() : Vector3.one) : Vector3.one);
						MaterialPropertyBlock val15 = new MaterialPropertyBlock();
						((Renderer)val9).GetPropertyBlock(val15);
						val15.SetColor("_HairColor", new Color(val14.x, val14.y, val14.z, 1f));
						((Renderer)component).SetPropertyBlock(val15);
						for (int num6 = 0; num6 < ((Renderer)val9).sharedMaterials.Length; num6++)
						{
							((Renderer)val9).GetPropertyBlock(val15, num6);
							val15.SetColor("_HairColor", new Color(val14.x, val14.y, val14.z, 1f));
							((Renderer)component).SetPropertyBlock(val15, num6);
						}
					}
				}
			}
			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 val16 in array3)
			{
				((Bounds)(ref bounds)).Encapsulate(val16.bounds);
			}
			Vector3 val17 = 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 val18 = val2.transform.TransformPoint(val8.Value);
				Vector3 val19 = val2.transform.TransformPoint(val17);
				if (val18.z < val19.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 val20 in array3)
			{
				((Bounds)(ref bounds)).Encapsulate(val20.bounds);
			}
			float num7 = 2.15f / Mathf.Max(0.1f, ((Bounds)(ref bounds)).size.z);
			val2.transform.localScale = Vector3.one * Mathf.Min(1f, num7);
			bounds = componentsInChildren2[0].bounds;
			array3 = componentsInChildren2;
			foreach (Renderer val21 in array3)
			{
				((Bounds)(ref bounds)).Encapsulate(val21.bounds);
			}
			Vector3 val22 = Root.transform.position + AltarPosition(soul.Slot);
			Transform transform = val2.transform;
			transform.position += new Vector3(val22.x - ((Bounds)(ref bounds)).center.x, Root.transform.position.y + 1.04f - ((Bounds)(ref bounds)).min.y, val22.z - ((Bounds)(ref bounds)).center.z);
			bodies[soul.Grave] = val2;
			static int Depth(Transform bone)
			{
				int num8 = 0;
				Transform parent = bone.parent;
				while (Object.op_Implicit((Object)(object)parent))
				{
					num8++;
					parent = parent.parent;
				}
				return num8;
			}
		}

		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()
		{
			RestoreWaitingVisuals();
			if (Object.op_Implicit((Object)(object)Root))
			{
				Object.Destroy((Object)(object)Root);
			}
			Root = null;
			bodies.Clear();
			foreach (Object asset in Assets)
			{
				if (Object.op_Implicit(asset))
				{
					Object.Destroy(asset);
				}
			}
			Assets.Clear();
			stoneMaterial = null;
			stoneMesh = null;
		}

		public static void HideBody(ZDOID? grave = null)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Root))
			{
				return;
			}
			KeyValuePair<ZDOID, GameObject>[] array = bodies.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				KeyValuePair<ZDOID, GameObject> keyValuePair = array[i];
				if (!grave.HasValue || keyValuePair.Key == grave.Value)
				{
					keyValuePair.Value.SetActive(false);
					Object.Destroy((Object)(object)keyValuePair.Value);
					bodies.Remove(keyValuePair.Key);
					Client.Souls.Remove(keyValuePair.Key);
				}
			}
		}

		private static void AddHallDetails()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: 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_0235: 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_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: 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_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: 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_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_0637: 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_065f: Unknown result type (might be due to invalid IL or missing references)
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0430: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: 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_06da: Unknown result type (might be due to invalid IL or missing references)
			//IL_078e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0793: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07be: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07de: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0753: Unknown result type (might be due to invalid IL or missing references)
			foreach (Transform item in ((IEnumerable)Root.transform).Cast<Transform>())
			{
				if (((Object)item).name.StartsWith("Gate") || ((Object)item).name == "SealedGate")
				{
					item.localPosition += Vector3.forward * 10f;
				}
				if (((Object)item).name.StartsWith("Pillar"))
				{
					Vector3 localPosition = item.localPosition;
					localPosition.x = Mathf.Sign(localPosition.x) * 11f;
					item.localPosition = localPosition;
				}
				if (((Object)item).name == "HelFaceLight" || ((Object)item).name == "ThroneGlow")
				{
					item.localPosition += Vector3.forward * 10f;
				}
			}
			for (int i = -1; i <= 1; i += 2)
			{
				for (int j = 0; j < 5; j++)
				{
					float num = -16 + j * 8;
					Block("HallColumn", new Vector3((float)(i * 11), 5.5f, num), new Vector3(0.9f, 11f, 0.9f), new Color(0.1f, 0.12f, 0.15f));
					Block("HallCapital", new Vector3((float)(i * 11), 10.7f, num), new Vector3(1.8f, 0.55f, 1.8f), new Color(0.22f, 0.23f, 0.24f));
					Block("VaultRib", new Vector3((float)(i * 7), 11f, num), new Vector3(8f, 0.45f, 0.5f), new Color(0.1f, 0.11f, 0.13f)).transform.localRotation = Quaternion.Euler(0f, 0f, (float)(i * 12));
					Block("WallButtress", new Vector3((float)i * 13.2f, 4f, num), new Vector3(1.1f, 8f, 1.4f), new Color(0.12f, 0.1f, 0.13f));
					Block("WallNiche", new Vector3((float)i * 13.4f, 5f, num), new Vector3(0.15f, 3.8f, 2.2f), new Color(0.015f, 0.022f, 0.045f));
					if (j == 1 || j == 3)
					{
						Block("RunePlinth", new Vector3((float)(i * 10), 1f, num), new Vector3(0.5f, 2f, 0.5f), new Color(0.12f, 0.15f, 0.2f));
						AddFire(new Vector3((float)(i * 10), 2.2f, num));
						GameObject val = new GameObject("Hall soul flame", new Type[1] { typeof(Light) });
						val.transform.SetParent(Root.transform, false);
						val.transform.localPosition = new Vector3((float)(i * 10), 2.8f, num);
						Light component = val.GetComponent<Light>();
						component.color = new Color(1f, 0.48f, 0.2f);
						component.range = 18f;
						component.intensity = 3f;
						component.shadows = (LightShadows)0;
						component.renderMode = (LightRenderMode)1;
					}
					Block("NicheFrameTop", new Vector3((float)i * 13.25f, 7f, num), new Vector3(0.3f, 0.3f, 2.7f), new Color(0.2f, 0.14f, 0.13f));
					Block("NicheFrameBottom", new Vector3((float)i * 13.25f, 3f, num), new Vector3(0.3f, 0.3f, 2.7f), new Color(0.2f, 0.14f, 0.13f));
					for (int k = -1; k <= 1; k += 2)
					{
						Block("NicheFrameSide", new Vector3((float)i * 13.25f, 5f, num + (float)k * 1.3f), new Vector3(0.3f, 4f, 0.25f), new Color(0.2f, 0.14f, 0.13f));
					}
					for (int l = 0; l < 3; l++)
					{
						Block("WallRune", new Vector3((float)i * 13.15f, 4.1f + (float)l * 0.75f, num), new Vector3(0.07f, 0.5f, 0.09f), new Color(0.6f, 0.16f, 0.045f)).transform.localRotation = Quaternion.Euler((float)((l % 2 == 0) ? 35 : (-35)), 0f, 0f);
					}
				}
			}
			for (int m = 0; m < 14; m++)
			{
				float num2 = -18f + (float)m * 2.3f;
				Block("HallProcessionalStone", new Vector3(0f, 0.018f, num2), new Vector3(3f, 0.035f, 1.8f), new Color(0.14f, 0.15f, 0.18f));
				for (int n = -1; n <= 1; n += 2)
				{
					Block("FloorRune", new Vector3((float)n * 2.2f, 0.035f, num2), new Vector3(0.12f, 0.02f, 0.5f), new Color(0.4f, 0.12f, 0.025f));
				}
			}
			for (int num3 = -1; num3 <= 1; num3 += 2)
			{
				Block("ThroneGuardianBase", new Vector3((float)(num3 * 4), 0.5f, 17f), new Vector3(1.5f, 1f, 1.5f), new Color(0.08f, 0.09f, 0.11f));
				Block("ThroneGuardianSpire", new Vector3((float)(num3 * 4), 3.7f, 17f), new Vector3(0.7f, 5.8f, 0.7f), new Color(0.16f, 0.15f, 0.18f)).transform.localRotation = Quaternion.Euler(0f, 0f, (float)(num3 * -8));
			}
			for (int num4 = -1; num4 <= 1; num4 += 2)
			{
				Block("ThroneRelief", new Vector3((float)(num4 * 6), 4f, 21.2f), new Vector3(3.2f, 5f, 0.3f), new Color(0.12f, 0.075f, 0.08f));
				for (int num5 = 0; num5 < 4; num5++)
				{
					Block("ThroneReliefCarving", new Vector3((float)(num4 * 6), 2.5f + (float)num5, 21f), new Vector3(2f, 0.12f, 0.15f), new Color(0.25f, 0.12f, 0.09f)).transform.localRotation = Quaternion.Euler(0f, 0f, (float)(num4 * ((num5 % 2 == 0) ? 20 : (-20))));
				}
			}
			GameObject val2 = new GameObject("HelWarmCozyArea", new Type[1] { typeof(BoxCollider) });
			val2.transform.SetParent(Root.transform, false);
			val2.transform.localPosition = new Vector3(0f, 4f, 0f);
			BoxCollider component2 = val2.GetComponent<BoxCollider>();
			component2.size = new Vector3(27f, 9f, 43f);
			((Collider)component2).isTrigger = true;
			val2.AddComponent<EffectArea>().m_type = (Type)67;
		}

		private static void AddRitualBrazier(Vector3 point)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_0146: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: 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_0262: 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_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			Block("RitualFireAltarBase", point + Vector3.up * 0.18f, new Vector3(1.3f, 0.36f, 1.3f), new Color(0.12f, 0.075f, 0.075f));
			Block("RitualFireAltarStem", point + Vector3.up * 0.8f, new Vector3(0.65f, 1.25f, 0.65f), new Color(0.15f, 0.11f, 0.1f));
			GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2);
			((Object)obj).name = "RitualFireBowl";
			obj.transform.SetParent(Root.transform, false);
			obj.transform.localPosition = point + Vector3.up * 1.4f;
			obj.transform.localScale = new Vector3(1.25f, 0.14f, 1.25f);
			Material val = new Material(stoneMaterial);
			val.color = new Color(0.23f, 0.11f, 0.065f);
			obj.GetComponent<Renderer>().sharedMaterial = val;
			Assets.Add((Object)(object)val);
			Material sharedMaterial = Block("RitualCoals", point + Vector3.up * 1.57f, new Vector3(0.86f, 0.08f, 0.86f), new Color(0.9f, 0.18f, 0.025f)).GetComponent<Renderer>().sharedMaterial;
			if (sharedMaterial.HasProperty("_EmissionColor"))
			{
				sharedMaterial.EnableKeyword("_EMISSION");
				sharedMaterial.SetColor("_EmissionColor", new Color(0.8f, 0.08f, 0.005f));
			}
			for (int i = 0; i < 4; i++)
			{
				float num = (float)i * (float)Math.PI * 0.5f;
				Block("BrazierCrown", point + new Vector3(Mathf.Sin(num) * 0.5f, 1.7f, Mathf.Cos(num) * 0.5f), new Vector3(0.14f, 0.5f, 0.14f), new Color(0.24f, 0.14f, 0.08f)).transform.localRotation = Quaternion.Euler(Mathf.Cos(num) * -12f, 0f, Mathf.Sin(num) * 12f);
			}
			AddFire(point + Vector3.up * 1.66f);
			GameObject val2 = new GameObject("RitualFireLight", new Type[1] { typeof(Light) });
			val2.transform.SetParent(Root.transform, false);
			val2.transform.localPosition = point + Vector3.up * 2f;
			Light component = val2.GetComponent<Light>();
			component.color = new Color(1f, 0.18f, 0.035f);
			component.range = 9f;
			component.intensity = 1.8f;
		}

		private static void UpdateWaitingVisuals()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			HashSet<Renderer> hashSet = new HashSet<Renderer>();
			foreach (Client.Soul value in Client.Souls.Values)
			{
				GameObject val = ZNetScene.instance.FindInstance(value.Dead);
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val2 in componentsInChildren)
				{
					hashSet.Add(val2);
					if (!hiddenWaitingRenderers.ContainsKey(val2))
					{
						hiddenWaitingRenderers.Add(val2, val2.forceRenderingOff);
					}
					val2.forceRenderingOff = true;
				}
			}
			KeyValuePair<Renderer, bool>[] array = hiddenWaitingRenderers.ToArray();
			for (int i = 0; i < array.Length; i++)
			{
				KeyValuePair<Renderer, bool> keyValuePair = array[i];
				if (!Object.op_Implicit((Object)(object)keyValuePair.Key))
				{
					hiddenWaitingRenderers.Remove(keyValuePair.Key);
				}
				else if (!hashSet.Contains(keyValuePair.Key))
				{
					Player componentInParent = ((Component)keyValuePair.Key).GetComponentInParent<Player>();
					if (Object.op_Implicit((Object)(object)componentInParent) && ((Character)componentInParent).IsDead() && Contains(((Component)componentInParent).transform.position, Client.Room))
					{
						keyValuePair.Key.forceRenderingOff = true;
						continue;
					}
					keyValuePair.Key.forceRenderingOff = keyValuePair.Value;
					hiddenWaitingRenderers.Remove(keyValuePair.Key);
				}
			}
		}

		private static void RestoreWaitingVisuals()
		{
			foreach (KeyValuePair<Renderer, bool> hiddenWaitingRenderer in hiddenWaitingRenderers)
			{
				if (Object.op_Implicit((Object)(object)hiddenWaitingRenderer.Key))
				{
					hiddenWaitingRenderer.Key.forceRenderingOff = hiddenWaitingRenderer.Value;
				}
			}
			hiddenWaitingRenderers.Clear();
		}
	}
	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 Chamber.Contains(((Component)player).transform.position, Client.Room);
			}
			return false;
		}
	}
	public static class Client
	{
		public sealed class Soul
		{
			public ZDOID Grave;

			public ZDOID Dead;

			public int Slot;

			public string Name = "Viking";
		}

		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 readonly Dictionary<ZDOID, Soul> Souls = new Dictionary<ZDOID, Soul>();

		public static int AltarSlot;

		private static float nextMembership;

		private static ZDOID wakeGrave;

		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_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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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_00dd: 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_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: 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_02a0: 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_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			if (sender != Network.ServerId || pkg.GetArray().Length > 4096)
			{
				return;
			}
			try
			{
				int num = pkg.ReadInt();
				if (num == 8)
				{
					int num2 = pkg.ReadInt();
					if (num2 < 0 || num2 > 10)
					{
						return;
					}
					Dictionary<ZDOID, Soul> dictionary = new Dictionary<ZDOID, Soul>();
					for (int i = 0; i < num2; i++)
					{
						Soul soul = new Soul
						{
							Grave = pkg.ReadZDOID(),
							Dead = pkg.ReadZDOID(),
							Slot = pkg.ReadInt(),
							Name = pkg.ReadString()
						};
						if (soul.Slot < 0 || soul.Slot >= 10)
						{
							return;
						}
						dictionary[soul.Grave] = soul;
					}
					Souls.Clear();
					{
						foreach (KeyValuePair<ZDOID, Soul> item in dictionary)
						{
							Souls[item.Key] = item.Value;
						}
						return;
					}
				}
				ZDOID val = pkg.ReadZDOID();
				ZDOID val2 = pkg.ReadZDOID();
				Vector3 room = pkg.ReadVector3();
				Vector3 val3 = pkg.ReadVector3();
				int num3 = pkg.ReadInt();
				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, num3);
					}
				}
				else if (num == 1 && !((Character)localPlayer).IsDead() && !InChamber && praying == val)
				{
					Enter(localPlayer, val, val2, room, val3, num3);
				}
				else if (num == 2 && Waiting && Grave == val && Dead == val2)
				{
					Room = room;
					AltarSlot = num3;
					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(val);
				}
				else if (num == 11 && InChamber && !Waiting)
				{
					lastServer = Time.unscaledTime;
				}
			}
			catch (Exception e)
			{
				Plugin.Error(e);
			}
		}

		private static void Enter(Player p, ZDOID grave, ZDOID dead, Vector3 room, Vector3 back, int slot)
		{
			//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_00a0: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			landing = null;
			Grave = grave;
			Dead = dead;
			Room = room;
			ReturnPoint = back;
			AltarSlot = slot;
			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 + (Vector3)(Waiting ? Chamber.AltarPosition(slot) : new Vector3(0f, 1f, -16f)));
			if (!Waiting)
			{
				Chamber.Root.GetComponentInChildren<HelFigure>().WelcomeRescuer();
			}
			lastServer = Time.unscaledTime;
		}

		public static void Respawn(bool revived = false)
		{
			//IL_00ba: 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_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)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			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 + Chamber.AltarPosition(AltarSlot) + Vector3.up * 0.2f;
				Chamber.HideBody(Grave);
				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_002e: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)