Decompiled source of Everest v1.3.0

BepInEx/plugins/Everest.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.CompilerServices;
using Everest.Accessories;
using Everest.Api;
using Everest.Core;
using Everest.UI;
using Everest.Utilities;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Photon.Pun;
using Photon.Realtime;
using Steamworks;
using TMPro;
using Unity.Collections;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Jobs;
using UnityEngine.LowLevel;
using UnityEngine.Networking;
using UnityEngine.Pool;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Steven \ud83c\udf80")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.0.0")]
[assembly: AssemblyInformationalVersion("1.3.0+45548023644f0e6779b7bca9afd7baf5050fea4f")]
[assembly: AssemblyProduct("Everest")]
[assembly: AssemblyTitle("Everest")]
[assembly: AssemblyVersion("1.3.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
namespace Everest
{
	[BepInPlugin("com.steven.peak.everest", "Everest", "1.3.0")]
	public class EverestPlugin : BaseUnityPlugin
	{
		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <Awake>d__1 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public EverestPlugin <>4__this;

			private Stopwatch <stopwatch>5__2;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//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)
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_017c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				//IL_0188: Unknown result type (might be due to invalid IL or missing references)
				//IL_01da: Unknown result type (might be due to invalid IL or missing references)
				//IL_01df: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0238: Unknown result type (might be due to invalid IL or missing references)
				//IL_023d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0244: Unknown result type (might be due to invalid IL or missing references)
				//IL_0140: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0201: Unknown result type (might be due to invalid IL or missing references)
				//IL_0205: Unknown result type (might be due to invalid IL or missing references)
				//IL_020a: 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_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_021e: Unknown result type (might be due to invalid IL or missing references)
				//IL_021f: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				EverestPlugin everestPlugin = <>4__this;
				try
				{
					UniTask val;
					Awaiter awaiter;
					switch (num)
					{
					default:
						Instance = everestPlugin;
						<stopwatch>5__2 = new Stopwatch();
						<stopwatch>5__2.Start();
						ConfigHandler.Initialize();
						if (ConfigHandler.Enabled)
						{
							if (ConfigHandler.AllowUploads)
							{
								new Harmony("com.steven.peak.everest").PatchAll();
							}
							else
							{
								LogInfo("Uploads are disabled in the configuration. Patching skipped.");
							}
							JsonConvert.DefaultSettings = () => new JsonSerializerSettings
							{
								Converters = new List<JsonConverter> { (JsonConverter)(object)new Vector3Converter() },
								ReferenceLoopHandling = (ReferenceLoopHandling)1
							};
							if (!PlayerLoopHelper.IsInjectedUniTaskPlayerLoop())
							{
								PlayerLoopSystem currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop();
								PlayerLoopHelper.Initialize(ref currentPlayerLoop, (InjectPlayerLoopTimings)65535);
							}
							SceneManager.activeSceneChanged += everestPlugin.OnActiveSceneChanged;
							if (ConfigHandler.ShowToasts)
							{
								new GameObject("Everest UI Manager").AddComponent<ToastController>();
							}
							val = SkeletonManager.LoadComputeShaderAsync();
							awaiter = ((UniTask)(ref val)).GetAwaiter();
							if (!((Awaiter)(ref awaiter)).IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter;
								((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <Awake>d__1>(ref awaiter, ref this);
								return;
							}
							goto IL_0139;
						}
						LogInfo("Everest is disabled in the configuration. Exiting...");
						goto end_IL_000e;
					case 0:
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_0139;
					case 1:
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_0197;
					case 2:
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_01f5;
					case 3:
						{
							awaiter = <>u__1;
							<>u__1 = default(Awaiter);
							num = (<>1__state = -1);
							break;
						}
						IL_0197:
						((Awaiter)(ref awaiter)).GetResult();
						val = AccessoryManager.Initialize();
						awaiter = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 2);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <Awake>d__1>(ref awaiter, ref this);
							return;
						}
						goto IL_01f5;
						IL_01f5:
						((Awaiter)(ref awaiter)).GetResult();
						val = TombstoneHandler.Initialize();
						awaiter = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 3);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <Awake>d__1>(ref awaiter, ref this);
							return;
						}
						break;
						IL_0139:
						((Awaiter)(ref awaiter)).GetResult();
						val = SkeletonManager.LoadSkeletonPrefabAsync();
						awaiter = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 1);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <Awake>d__1>(ref awaiter, ref this);
							return;
						}
						goto IL_0197;
					}
					((Awaiter)(ref awaiter)).GetResult();
					<stopwatch>5__2.Stop();
					LogInfo($"Everest Initialized in {(float)<stopwatch>5__2.ElapsedMilliseconds / 1000f} seconds.");
					end_IL_000e:;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<stopwatch>5__2 = null;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				<stopwatch>5__2 = null;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <GetServerStatus>d__3 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskVoidMethodBuilder <>t__builder;

			public EverestPlugin <>4__this;

			private Awaiter<ServerStatusResponse> <>u__1;

			private void MoveNext()
			{
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: 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_0154: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				EverestPlugin everestPlugin = <>4__this;
				try
				{
					Awaiter<ServerStatusResponse> awaiter;
					if (num != 0)
					{
						awaiter = EverestClient.RetrieveServerStatusAsync(((BaseUnityPlugin)everestPlugin).Info.Metadata.Version.ToString()).GetAwaiter();
						if (!awaiter.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<ServerStatusResponse>, <GetServerStatus>d__3>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter<ServerStatusResponse>);
						num = (<>1__state = -1);
					}
					ServerStatusResponse result = awaiter.GetResult();
					LogInfo("Everest Server Status: " + (result?.status ?? "offline"));
					StringBuilder stringBuilder = new StringBuilder();
					stringBuilder.AppendLine("Everest Server Status: " + (result?.status ?? "offline"));
					if (!string.IsNullOrEmpty(result?.messageOfTheDay))
					{
						LogInfo("Message of the Day: " + result.messageOfTheDay);
						stringBuilder.AppendLine(result.messageOfTheDay);
					}
					if (!string.IsNullOrEmpty(result?.updateInfo))
					{
						LogInfo("Update available: " + result.updateInfo);
						stringBuilder.AppendLine(result.updateInfo);
					}
					Color color = ((!(result.status == "online")) ? Color.red : (string.IsNullOrEmpty(result.updateInfo) ? Color.green : Color.yellow));
					ToastController.Instance.Toast(stringBuilder.ToString(), color, 7f, 3f);
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		public static EverestPlugin Instance;

		[AsyncStateMachine(typeof(<Awake>d__1))]
		private UniTask Awake()
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			<Awake>d__1 <Awake>d__ = default(<Awake>d__1);
			<Awake>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<Awake>d__.<>4__this = this;
			<Awake>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <Awake>d__.<>t__builder)).Start<<Awake>d__1>(ref <Awake>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <Awake>d__.<>t__builder)).Task;
		}

		private void OnActiveSceneChanged(Scene oldScene, Scene newScene)
		{
			//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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			if (((Scene)(ref newScene)).name.ToLower() == "airport")
			{
				UniTaskVoid serverStatus = GetServerStatus();
				((UniTaskVoid)(ref serverStatus)).Forget();
			}
			if (((Scene)(ref newScene)).name.ToLower().StartsWith("level_") || ((Scene)(ref newScene)).name == "WilIsland")
			{
				LogInfo("Game scene loaded. Spawning Skeleton Manager...");
				new GameObject("Skeleton Manager").AddComponent<SkeletonManager>();
				if (ConfigHandler.ShowSkeletonNametags)
				{
					LogInfo("Spawning Skeleton UI Controller...");
					new GameObject("Skeleton UI Controller").AddComponent<SkeletonUIController>();
				}
			}
		}

		[AsyncStateMachine(typeof(<GetServerStatus>d__3))]
		private UniTaskVoid GetServerStatus()
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			<GetServerStatus>d__3 <GetServerStatus>d__ = default(<GetServerStatus>d__3);
			<GetServerStatus>d__.<>t__builder = AsyncUniTaskVoidMethodBuilder.Create();
			<GetServerStatus>d__.<>4__this = this;
			<GetServerStatus>d__.<>1__state = -1;
			((AsyncUniTaskVoidMethodBuilder)(ref <GetServerStatus>d__.<>t__builder)).Start<<GetServerStatus>d__3>(ref <GetServerStatus>d__);
			return ((AsyncUniTaskVoidMethodBuilder)(ref <GetServerStatus>d__.<>t__builder)).Task;
		}

		internal static void LogDebug(string message)
		{
			Instance.Log(message, (LogLevel)32);
		}

		internal static void LogInfo(string message)
		{
			Instance.Log(message, (LogLevel)16);
		}

		internal static void LogWarning(string message)
		{
			Instance.Log(message, (LogLevel)4);
		}

		internal static void LogError(string message)
		{
			Instance.Log(message, (LogLevel)2);
		}

		internal static void LogError(Exception ex)
		{
			Instance.Log(ex.Message + "\n" + ex.StackTrace, (LogLevel)2);
		}

		private void Log(string message, LogLevel logLevel)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.Log(logLevel, (object)message);
		}
	}
}
namespace Everest.Utilities
{
	public class FontUtility
	{
		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <GetFont>d__1 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder<TMP_FontAsset> <>t__builder;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: 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_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				TMP_FontAsset font;
				try
				{
					Awaiter awaiter;
					if (num == 0)
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_00be;
					}
					if (!Object.op_Implicit((Object)(object)_font))
					{
						goto IL_00c5;
					}
					font = _font;
					goto end_IL_0007;
					IL_00be:
					((Awaiter)(ref awaiter)).GetResult();
					goto IL_00c5;
					IL_00c5:
					while (true)
					{
						if ((Object)(object)_font == (Object)null)
						{
							if ((Object)(object)GUIManager.instance != (Object)null && (Object)(object)GUIManager.instance.heroDayText != (Object)null)
							{
								_font = ((TMP_Text)GUIManager.instance.heroDayText).font;
								continue;
							}
							UniTask val = UniTask.Delay(100, false, (PlayerLoopTiming)8, default(CancellationToken), false);
							awaiter = ((UniTask)(ref val)).GetAwaiter();
							if (!((Awaiter)(ref awaiter)).IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter;
								<>t__builder.AwaitUnsafeOnCompleted<Awaiter, <GetFont>d__1>(ref awaiter, ref this);
								return;
							}
							goto IL_00be;
						}
						font = _font;
						break;
					}
					end_IL_0007:;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<>t__builder.SetException(exception);
					return;
				}
				<>1__state = -2;
				<>t__builder.SetResult(font);
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				<>t__builder.SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private static TMP_FontAsset _font;

		[AsyncStateMachine(typeof(<GetFont>d__1))]
		public static UniTask<TMP_FontAsset> GetFont()
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			<GetFont>d__1 <GetFont>d__ = default(<GetFont>d__1);
			<GetFont>d__.<>t__builder = AsyncUniTaskMethodBuilder<TMP_FontAsset>.Create();
			<GetFont>d__.<>1__state = -1;
			<GetFont>d__.<>t__builder.Start<<GetFont>d__1>(ref <GetFont>d__);
			return <GetFont>d__.<>t__builder.Task;
		}
	}
	public enum SkeletonBodypart
	{
		Hip,
		Hip_L,
		Leg_L,
		Knee_L,
		Foot_L,
		Hip_R,
		Leg_R,
		Knee_R,
		Foot_R,
		Mid,
		Torso,
		Head,
		Arm_L,
		Elbow_L,
		Hand_L,
		Arm_R,
		Elbow_R,
		Hand_R
	}
	public class SkeletonTransformHelper
	{
		private static readonly Vector3 _scoutLocalPosition = Vector3.zero;

		private static readonly Quaternion _scoutLocalRotation = Quaternion.Euler(0f, -1.707547E-06f, 0f);

		private static readonly Vector3 _scoutLocalScale = Vector3.one * 0.3307868f;

		private static readonly Vector3 _armatureLocalPosition = Vector3.zero;

		private static readonly Quaternion _armatureLocalRotation = Quaternion.Euler(-90f, 0f, 0f);

		public static Vector3 GetHipWorldPosition(Vector3 parentWorldPosition, Vector3 parentWorldRotation, Vector3 hipLocalPosition)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			Matrix4x4 val = Matrix4x4.TRS(parentWorldPosition, Quaternion.Euler(parentWorldRotation), Vector3.one);
			Matrix4x4 val2 = Matrix4x4.TRS(_scoutLocalPosition, _scoutLocalRotation, _scoutLocalScale);
			Matrix4x4 val3 = Matrix4x4.TRS(_armatureLocalPosition, _armatureLocalRotation, Vector3.one);
			Matrix4x4 val4 = val * val2 * val3;
			return ((Matrix4x4)(ref val4)).MultiplyPoint3x4(hipLocalPosition);
		}
	}
	public class Vector3Converter : JsonConverter<Vector3>
	{
		public override bool CanRead => true;

		public override bool CanWrite => true;

		public override Vector3 ReadJson(JsonReader reader, Type objectType, Vector3 existingValue, bool hasExistingValue, JsonSerializer serializer)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if ((int)reader.TokenType != 1)
			{
				throw new JsonException();
			}
			Vector3 zero = Vector3.zero;
			while (reader.Read())
			{
				if ((int)reader.TokenType == 13)
				{
					return zero;
				}
				switch (reader.Value as string)
				{
				case "x":
					zero.x = (float)reader.ReadAsDouble().Value;
					break;
				case "y":
					zero.y = (float)reader.ReadAsDouble().Value;
					break;
				case "z":
					zero.z = (float)reader.ReadAsDouble().Value;
					break;
				}
			}
			throw new JsonException();
		}

		public override void WriteJson(JsonWriter writer, Vector3 value, JsonSerializer serializer)
		{
			//IL_0012: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			writer.WriteStartObject();
			writer.WritePropertyName("x");
			writer.WriteValue(value.x);
			writer.WritePropertyName("y");
			writer.WriteValue(value.y);
			writer.WritePropertyName("z");
			writer.WriteValue(value.z);
			writer.WriteEndObject();
		}
	}
}
namespace Everest.UI
{
	internal class SkeletonNametag : MonoBehaviour
	{
		private TextMeshProUGUI _text;

		private string _nickname;

		private DateTime _timestamp;

		private float _timeSinceLastUpdate;

		public CanvasGroup CanvasGroup { get; private set; }

		public void Initialize(string nickname, DateTime timestamp)
		{
			_nickname = nickname;
			_timestamp = timestamp;
			((Object)((Component)this).gameObject).name = _nickname;
			UpdateText();
			_timeSinceLastUpdate = 0f;
		}

		private void Awake()
		{
			CanvasGroup = ((Component)this).GetComponent<CanvasGroup>();
			_text = ((Component)this).GetComponent<TextMeshProUGUI>();
		}

		private void Update()
		{
			if (ConfigHandler.ShowTimeSinceDeath)
			{
				if (_timeSinceLastUpdate >= 1f)
				{
					UpdateText();
					_timeSinceLastUpdate = 0f;
				}
				else
				{
					_timeSinceLastUpdate += Time.deltaTime;
				}
			}
		}

		private void UpdateText()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine(_nickname);
			if (ConfigHandler.ShowTimeSinceDeath)
			{
				stringBuilder.Append("Died " + CreateFormattedTime(_timestamp) + " ago");
			}
			((TMP_Text)_text).text = stringBuilder.ToString();
		}

		private string CreateFormattedTime(DateTime timestamp)
		{
			TimeSpan timeSpan = DateTime.UtcNow - timestamp;
			if (timeSpan.TotalHours >= 1.0)
			{
				return $"{(int)timeSpan.TotalHours}h {timeSpan.Minutes}m {(ConfigHandler.ShowSecondsAlways ? $"{timeSpan.Seconds}s" : string.Empty)}";
			}
			if (timeSpan.TotalMinutes >= 1.0)
			{
				return $"{timeSpan.Minutes}m {timeSpan.Seconds}s";
			}
			return $"{timeSpan.Seconds} seconds";
		}
	}
	internal class SkeletonUIController : MonoBehaviour
	{
		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <Awake>d__14 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskVoidMethodBuilder <>t__builder;

			public SkeletonUIController <>4__this;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: 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_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				SkeletonUIController skeletonUIController = <>4__this;
				try
				{
					Awaiter awaiter;
					if (num != 0)
					{
						EverestPlugin.LogInfo("Initializing Skeleton UI Controller...");
						skeletonUIController._playerCamera = Camera.main;
						skeletonUIController._maxDistanceSquared = skeletonUIController._maxDistance * skeletonUIController._maxDistance;
						skeletonUIController._minDistanceSquared = skeletonUIController._minDistance * skeletonUIController._minDistance;
						UniTask val = skeletonUIController.PrepareTemplateNametag();
						awaiter = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <Awake>d__14>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
					}
					((Awaiter)(ref awaiter)).GetResult();
					skeletonUIController._nametagPool = new ObjectPool<SkeletonNametag>((Func<SkeletonNametag>)skeletonUIController.CreateTextObject, (Action<SkeletonNametag>)delegate(SkeletonNametag obj)
					{
						((Component)obj).gameObject.SetActive(true);
					}, (Action<SkeletonNametag>)delegate(SkeletonNametag obj)
					{
						((Component)obj).gameObject.SetActive(false);
					}, (Action<SkeletonNametag>)delegate(SkeletonNametag obj)
					{
						Object.Destroy((Object)(object)obj);
					}, false, 5, 20);
					EverestPlugin.LogInfo("Skeleton UI Controller Initialized!");
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <PrepareTemplateNametag>d__17 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public SkeletonUIController <>4__this;

			private GameObject <templateObject>5__2;

			private TextMeshProUGUI <textComponent>5__3;

			private TextMeshProUGUI <>7__wrap3;

			private Awaiter<TMP_FontAsset> <>u__1;

			private void MoveNext()
			{
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Expected O, but got Unknown
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_0194: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				SkeletonUIController skeletonUIController = <>4__this;
				try
				{
					Awaiter<TMP_FontAsset> awaiter;
					if (num != 0)
					{
						Canvas obj = ((Component)skeletonUIController).gameObject.AddComponent<Canvas>();
						obj.renderMode = (RenderMode)0;
						((Component)obj).gameObject.AddComponent<CanvasScaler>();
						<templateObject>5__2 = new GameObject("Template");
						<templateObject>5__2.transform.SetParent(((Component)skeletonUIController).transform, false);
						<textComponent>5__3 = <templateObject>5__2.AddComponent<TextMeshProUGUI>();
						((TMP_Text)<textComponent>5__3).fontSize = 24f;
						((TMP_Text)<textComponent>5__3).alignment = (TextAlignmentOptions)514;
						((Graphic)<textComponent>5__3).color = ConfigHandler.NametagColor;
						((TMP_Text)<textComponent>5__3).textWrappingMode = (TextWrappingModes)0;
						<>7__wrap3 = <textComponent>5__3;
						awaiter = FontUtility.GetFont().GetAwaiter();
						if (!awaiter.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<TMP_FontAsset>, <PrepareTemplateNametag>d__17>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter<TMP_FontAsset>);
						num = (<>1__state = -1);
					}
					TMP_FontAsset result = awaiter.GetResult();
					((TMP_Text)<>7__wrap3).font = result;
					<>7__wrap3 = null;
					((TMP_Text)<textComponent>5__3).outlineColor = Color32.op_Implicit(ConfigHandler.NametagOutlineColor);
					((TMP_Text)<textComponent>5__3).outlineWidth = ConfigHandler.NametagOutlineWidth;
					<templateObject>5__2.AddComponent<CanvasGroup>();
					RectTransform component = <templateObject>5__2.GetComponent<RectTransform>();
					component.anchorMin = Vector2.zero;
					component.anchorMax = Vector2.zero;
					component.pivot = new Vector2(0.5f, 0f);
					component.sizeDelta = new Vector2(200f, 100f);
					skeletonUIController._nametagTemplate = <templateObject>5__2.AddComponent<SkeletonNametag>();
					<templateObject>5__2.SetActive(false);
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<templateObject>5__2 = null;
					<textComponent>5__3 = null;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				<templateObject>5__2 = null;
				<textComponent>5__3 = null;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private Camera _playerCamera;

		private float _maxDistance = ConfigHandler.MaxDistanceForVisibleNametag;

		private float _minDistance = ConfigHandler.MinDistanceForVisibleNametag;

		private float _maxViewAngle = ConfigHandler.MaxAngleForVisibleNametag;

		private float _textVerticalOffset = 0.6f;

		private AnimationCurve _textScaleCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
		{
			new Keyframe(0f, 0.8f),
			new Keyframe(0.2f, 1.2f),
			new Keyframe(1f, 2f)
		});

		private float _minTextScale = ConfigHandler.MinNametagSize;

		private float _maxTextScale = ConfigHandler.MaxNametagSize;

		private float _maxDistanceSquared;

		private float _minDistanceSquared;

		private SkeletonNametag _nametagTemplate;

		private Transform _canvasTransform;

		private ObjectPool<SkeletonNametag> _nametagPool;

		private Dictionary<Skeleton, SkeletonNametag> _activeTextElements = new Dictionary<Skeleton, SkeletonNametag>();

		[AsyncStateMachine(typeof(<Awake>d__14))]
		private UniTaskVoid Awake()
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			<Awake>d__14 <Awake>d__ = default(<Awake>d__14);
			<Awake>d__.<>t__builder = AsyncUniTaskVoidMethodBuilder.Create();
			<Awake>d__.<>4__this = this;
			<Awake>d__.<>1__state = -1;
			((AsyncUniTaskVoidMethodBuilder)(ref <Awake>d__.<>t__builder)).Start<<Awake>d__14>(ref <Awake>d__);
			return ((AsyncUniTaskVoidMethodBuilder)(ref <Awake>d__.<>t__builder)).Task;
		}

		private void LateUpdate()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_0184: Unknown result type (might be due to invalid IL or missing references)
			HashSet<Skeleton> hashSet = new HashSet<Skeleton>();
			foreach (Skeleton allActiveSkeleton in Skeleton.AllActiveSkeletons)
			{
				Vector3 position = allActiveSkeleton.HeadBone.position;
				Vector3 val = position - ((Component)_playerCamera).transform.position;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				if (sqrMagnitude > _maxDistanceSquared)
				{
					continue;
				}
				float num = Vector3.Angle(((Component)_playerCamera).transform.forward, val);
				if (!(num > _maxViewAngle))
				{
					hashSet.Add(allActiveSkeleton);
					float num2 = 1f - Mathf.InverseLerp(_minDistanceSquared, _maxDistanceSquared, sqrMagnitude);
					float num3 = 1f - Mathf.InverseLerp(0f, _maxViewAngle, num);
					float alpha = num2 * num3;
					if (!_activeTextElements.TryGetValue(allActiveSkeleton, out var value))
					{
						value = _nametagPool.Get();
						_activeTextElements[allActiveSkeleton] = value;
						value.Initialize(allActiveSkeleton.Nickname, allActiveSkeleton.Timestamp);
					}
					Vector3 position2 = _playerCamera.WorldToScreenPoint(position + Vector3.up * _textVerticalOffset);
					((Component)value).transform.position = position2;
					value.CanvasGroup.alpha = alpha;
					float num4 = Mathf.InverseLerp(_minDistanceSquared, _maxDistanceSquared, sqrMagnitude);
					float num5 = _textScaleCurve.Evaluate(num4);
					num5 = Mathf.Clamp(num5, _minTextScale, _maxTextScale);
					((Component)value).transform.localScale = new Vector3(num5, num5, 1f);
				}
			}
			CleanupPool(_activeTextElements, _nametagPool, hashSet);
		}

		private void CleanupPool(Dictionary<Skeleton, SkeletonNametag> activeElements, ObjectPool<SkeletonNametag> pool, HashSet<Skeleton> processedSkeletons)
		{
			List<Skeleton> list = new List<Skeleton>();
			foreach (KeyValuePair<Skeleton, SkeletonNametag> activeElement in activeElements)
			{
				if (!processedSkeletons.Contains(activeElement.Key))
				{
					pool.Release(activeElement.Value);
					list.Add(activeElement.Key);
				}
			}
			foreach (Skeleton item in list)
			{
				activeElements.Remove(item);
			}
		}

		[AsyncStateMachine(typeof(<PrepareTemplateNametag>d__17))]
		private UniTask PrepareTemplateNametag()
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			<PrepareTemplateNametag>d__17 <PrepareTemplateNametag>d__ = default(<PrepareTemplateNametag>d__17);
			<PrepareTemplateNametag>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<PrepareTemplateNametag>d__.<>4__this = this;
			<PrepareTemplateNametag>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <PrepareTemplateNametag>d__.<>t__builder)).Start<<PrepareTemplateNametag>d__17>(ref <PrepareTemplateNametag>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <PrepareTemplateNametag>d__.<>t__builder)).Task;
		}

		private SkeletonNametag CreateTextObject()
		{
			return Object.Instantiate<SkeletonNametag>(_nametagTemplate, ((Component)this).transform);
		}
	}
	public class ToastController : MonoBehaviour
	{
		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <ClearToast>d__6 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			public ToastController <>4__this;

			public float duration;

			public CancellationToken cancellationToken;

			public float fadeTime;

			private float <timeElapsed>5__2;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: 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_014d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: 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_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_012a: 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)
				int num = <>1__state;
				ToastController toastController = <>4__this;
				try
				{
					Awaiter awaiter;
					if (num == 0)
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_0097;
					}
					if (num == 1)
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
						goto IL_015c;
					}
					UniTask val;
					if (!((Object)(object)toastController.textMesh == (Object)null))
					{
						val = UniTask.Delay((int)(duration * 1000f), false, (PlayerLoopTiming)8, cancellationToken, false);
						awaiter = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <ClearToast>d__6>(ref awaiter, ref this);
							return;
						}
						goto IL_0097;
					}
					goto end_IL_000e;
					IL_0163:
					if (<timeElapsed>5__2 < fadeTime)
					{
						<timeElapsed>5__2 += Time.deltaTime;
						float num2 = Mathf.Clamp01(<timeElapsed>5__2 / fadeTime);
						((TMP_Text)toastController.textMesh).alpha = Mathf.Lerp(1f, 0f, num2);
						val = UniTask.NextFrame(cancellationToken, false);
						awaiter = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 1);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <ClearToast>d__6>(ref awaiter, ref this);
							return;
						}
						goto IL_015c;
					}
					goto end_IL_000e;
					IL_0097:
					((Awaiter)(ref awaiter)).GetResult();
					if (!cancellationToken.IsCancellationRequested)
					{
						<timeElapsed>5__2 = 0f;
						goto IL_0163;
					}
					goto end_IL_000e;
					IL_015c:
					((Awaiter)(ref awaiter)).GetResult();
					goto IL_0163;
					end_IL_000e:;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <FindFontEventually>d__7 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskVoidMethodBuilder <>t__builder;

			public ToastController <>4__this;

			private TextMeshProUGUI <>7__wrap1;

			private Awaiter<TMP_FontAsset> <>u__1;

			private void MoveNext()
			{
				//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_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: 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)
				int num = <>1__state;
				ToastController toastController = <>4__this;
				try
				{
					Awaiter<TMP_FontAsset> awaiter;
					if (num != 0)
					{
						<>7__wrap1 = toastController.textMesh;
						awaiter = FontUtility.GetFont().GetAwaiter();
						if (!awaiter.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<TMP_FontAsset>, <FindFontEventually>d__7>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter<TMP_FontAsset>);
						num = (<>1__state = -1);
					}
					TMP_FontAsset result = awaiter.GetResult();
					((TMP_Text)<>7__wrap1).font = result;
					<>7__wrap1 = null;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		public static ToastController Instance;

		private TextMeshProUGUI textMesh;

		private CancellationTokenSource cancellationTokenSource;

		private void Awake()
		{
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)this);
		}

		private void Start()
		{
			//IL_000f: 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_0054: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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)
			EverestPlugin.LogInfo("Initializing Toast Controller...");
			Canvas val = new GameObject("canvas").AddComponent<Canvas>();
			((Component)val).transform.SetParent(((Component)this).transform);
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 32767;
			((Component)val).gameObject.AddComponent<CanvasScaler>();
			GameObject val2 = new GameObject("text");
			val2.transform.SetParent(((Component)val).transform, false);
			RectTransform obj = val2.AddComponent<RectTransform>();
			obj.sizeDelta = new Vector2(1000f, 100f);
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(0f, 1f);
			obj.pivot = new Vector2(0f, 1f);
			obj.anchoredPosition = new Vector2(5f, -20f);
			textMesh = val2.AddComponent<TextMeshProUGUI>();
			((TMP_Text)textMesh).fontSize = 26f;
			((TMP_Text)textMesh).fontSizeMin = 26f;
			((TMP_Text)textMesh).fontSizeMax = 26f;
			EverestPlugin.LogInfo("Toast Controller Initialized!");
			UniTaskVoid val3 = FindFontEventually();
			((UniTaskVoid)(ref val3)).Forget();
		}

		public void Toast(string text, Color color, float duration = 2f, float fadeTime = 1f)
		{
			//IL_0043: 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)
			cancellationTokenSource?.Cancel();
			cancellationTokenSource?.Dispose();
			if (!((Object)(object)textMesh == (Object)null))
			{
				((TMP_Text)textMesh).text = text;
				((Graphic)textMesh).color = color;
				((TMP_Text)textMesh).alpha = 1f;
				cancellationTokenSource = new CancellationTokenSource();
				UniTaskExtensions.Forget(ClearToast(duration, fadeTime, cancellationTokenSource.Token));
			}
		}

		[AsyncStateMachine(typeof(<ClearToast>d__6))]
		private UniTask ClearToast(float duration, float fadeTime = 1f, CancellationToken cancellationToken = default(CancellationToken))
		{
			//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_0049: Unknown result type (might be due to invalid IL or missing references)
			<ClearToast>d__6 <ClearToast>d__ = default(<ClearToast>d__6);
			<ClearToast>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create();
			<ClearToast>d__.<>4__this = this;
			<ClearToast>d__.duration = duration;
			<ClearToast>d__.fadeTime = fadeTime;
			<ClearToast>d__.cancellationToken = cancellationToken;
			<ClearToast>d__.<>1__state = -1;
			((AsyncUniTaskMethodBuilder)(ref <ClearToast>d__.<>t__builder)).Start<<ClearToast>d__6>(ref <ClearToast>d__);
			return ((AsyncUniTaskMethodBuilder)(ref <ClearToast>d__.<>t__builder)).Task;
		}

		[AsyncStateMachine(typeof(<FindFontEventually>d__7))]
		private UniTaskVoid FindFontEventually()
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			<FindFontEventually>d__7 <FindFontEventually>d__ = default(<FindFontEventually>d__7);
			<FindFontEventually>d__.<>t__builder = AsyncUniTaskVoidMethodBuilder.Create();
			<FindFontEventually>d__.<>4__this = this;
			<FindFontEventually>d__.<>1__state = -1;
			((AsyncUniTaskVoidMethodBuilder)(ref <FindFontEventually>d__.<>t__builder)).Start<<FindFontEventually>d__7>(ref <FindFontEventually>d__);
			return ((AsyncUniTaskVoidMethodBuilder)(ref <FindFontEventually>d__.<>t__builder)).Task;
		}
	}
}
namespace Everest.Patches
{
	[HarmonyPatch(typeof(Character), "RPCA_Die")]
	public class CharacterDeathPatch
	{
		private static void Prefix(Character __instance)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance != (Object)(object)Character.localCharacter))
			{
				EverestPlugin.LogInfo("Whoops, you died!");
				string steamId = GetSteamId();
				string authTicket = GetAuthTicket();
				int mapId = GetMapId();
				int mapSegment = GetMapSegment();
				bool isNearCampfire = CheckForCampfire(__instance);
				bool isNearCrashSite = CheckForBingBong(__instance);
				Vector3 position = ((Component)__instance).transform.position;
				Quaternion rotation = ((Component)__instance).transform.rotation;
				Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
				(Vector3[] localPositions, Vector3[] localRotations) tuple = GenerateLocalTransformData(__instance);
				Vector3[] item = tuple.localPositions;
				Vector3[] item2 = tuple.localRotations;
				UniTaskVoid val = EverestClient.SubmitDeathAsync(new SubmissionRequest
				{
					SteamId = steamId,
					AuthSessionTicket = authTicket,
					MapId = mapId,
					MapSegment = mapSegment,
					IsNearCampfire = isNearCampfire,
					IsNearCrashSite = isNearCrashSite,
					GlobalPosition = position,
					GlobalRotation = eulerAngles,
					BoneLocalPositions = item,
					BoneLocalRotations = item2
				});
				((UniTaskVoid)(ref val)).Forget();
			}
		}

		private static string GetSteamId()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			CSteamID steamID = SteamUser.GetSteamID();
			return ((object)(CSteamID)(ref steamID)).ToString();
		}

		private static int GetMapId()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return GameHandler.GetService<NextLevelService>().Data.Value.CurrentLevelIndex;
		}

		private static int GetMapSegment()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected I4, but got Unknown
			return (int)Singleton<MapHandler>.Instance.GetCurrentSegment();
		}

		private static string GetAuthTicket()
		{
			return SteamAuthTicketService.GetSteamAuthTicket().Item1;
		}

		private static bool CheckForCampfire(Character character)
		{
			//IL_003a: 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)
			foreach (Campfire item in from x in Object.FindObjectsByType<Campfire>((FindObjectsSortMode)0)
				where (int)x.advanceToSegment > 0
				select x)
			{
				if (Vector3.Distance(character.Center, ((Component)item).transform.position) < item.moraleBoostRadius)
				{
					return true;
				}
			}
			return false;
		}

		private static bool CheckForBingBong(Character character)
		{
			//IL_003b: 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)
			SingleItemSpawner val = (from SingleItemSpawner in Object.FindObjectsByType<SingleItemSpawner>((FindObjectsSortMode)0)
				where ((Object)SingleItemSpawner.prefab).name == "BingBong"
				select SingleItemSpawner).FirstOrDefault();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			return Vector3.Distance(character.Center, ((Component)val).transform.position) < 50f;
		}

		private static (Vector3[] localPositions, Vector3[] localRotations) GenerateLocalTransformData(Character character)
		{
			if ((Object)(object)character == (Object)null)
			{
				return (null, null);
			}
			List<Transform> source = (from x in ((Component)((Component)character).transform).GetComponentsInChildren<Transform>()
				where Enum.GetNames(typeof(SkeletonBodypart)).Contains(((Object)x).name)
				select x).ToList();
			Vector3[] item = source.Select((Transform bone) => bone.localPosition).ToArray();
			Vector3[] item2 = source.Select(delegate(Transform bone)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				Quaternion localRotation = bone.localRotation;
				return ((Quaternion)(ref localRotation)).eulerAngles;
			}).ToArray();
			return (item, item2);
		}
	}
}
namespace Everest.Core
{
	public static class ConfigHandler
	{
		private static ConfigFile config;

		private static ConfigEntry<bool> enabled;

		private static ConfigEntry<int> maxSkeletons;

		private static ConfigEntry<bool> allowUploads;

		private static ConfigEntry<bool> hideFloaters;

		private static ConfigEntry<bool> excludeNearCrashSite;

		private static ConfigEntry<bool> excludeNearCampfires;

		private static ConfigEntry<bool> showToasts;

		private static ConfigEntry<int> skeletonDrawDistance;

		private static ConfigEntry<float> cullingUpdateFrequency;

		private static ConfigEntry<int> maxVisibleSkeletons;

		private static ConfigEntry<bool> showSkeletonNametags;

		private static ConfigEntry<bool> showTimeSinceDeath;

		private static ConfigEntry<bool> showSecondsAlways;

		private static ConfigEntry<float> maxDistanceForVisibleNametag;

		private static ConfigEntry<float> minDistanceForVisibleNametag;

		private static ConfigEntry<float> maxAngleForVisibleNametag;

		private static ConfigEntry<float> maxNametagSize;

		private static ConfigEntry<float> minNametagSize;

		private static ConfigEntry<Color> nametagColor;

		private static ConfigEntry<float> nametagOutlineWidth;

		private static ConfigEntry<Color> nametagOutlineColor;

		public static bool Enabled => enabled.Value;

		public static int MaxSkeletons => maxSkeletons.Value;

		public static bool AllowUploads => allowUploads.Value;

		public static bool HideFloaters => hideFloaters.Value;

		public static bool ExcludeNearCrashSite => excludeNearCrashSite.Value;

		public static bool ExcludeNearCampfires => excludeNearCampfires.Value;

		public static bool ShowToasts => showToasts.Value;

		public static int SkeletonDrawDistance => skeletonDrawDistance.Value;

		public static float CullingUpdateFrequency => cullingUpdateFrequency.Value;

		public static int MaxVisibleSkeletons => maxVisibleSkeletons.Value;

		public static bool ShowSkeletonNametags => showSkeletonNametags.Value;

		public static bool ShowTimeSinceDeath => showTimeSinceDeath.Value;

		public static bool ShowSecondsAlways => showSecondsAlways.Value;

		public static float MaxDistanceForVisibleNametag => maxDistanceForVisibleNametag.Value;

		public static float MinDistanceForVisibleNametag => minDistanceForVisibleNametag.Value;

		public static float MaxAngleForVisibleNametag => maxAngleForVisibleNametag.Value;

		public static float MaxNametagSize => maxNametagSize.Value;

		public static float MinNametagSize => minNametagSize.Value;

		public static Color NametagColor => nametagColor.Value;

		public static float NametagOutlineWidth => nametagOutlineWidth.Value;

		public static Color NametagOutlineColor => nametagOutlineColor.Value;

		public static void Initialize()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			config = new ConfigFile(Path.Combine(Paths.ConfigPath, "Everest.cfg"), true);
			enabled = config.Bind<bool>("General", "Enabled", true, "Enable or disable the Everest plugin.");
			maxSkeletons = config.Bind<int>("General", "MaxSkeletons", 100, "Number of skeletons to spawn.");
			allowUploads = config.Bind<bool>("General", "AllowUploads", true, "Allow uploading your own skeletons.");
			hideFloaters = config.Bind<bool>("General", "HideFloaters", true, "Attempt to hide skeletons that are floating in the air without a valid ground position.");
			excludeNearCrashSite = config.Bind<bool>("General", "ExcludeNearCrashSite", false, "Exclude skeletons that are near the crash site.");
			excludeNearCampfires = config.Bind<bool>("General", "ExcludeNearCampfires", false, "Exclude skeletons that are near campfires.");
			skeletonDrawDistance = config.Bind<int>("Performance", "SkeletonDrawDistance", 150, "Maximum distance (in units) at which skeletons are drawn.");
			cullingUpdateFrequency = config.Bind<float>("Performance", "CullingUpdateFrequency", 1f, "Frequency (in seconds) at which the culling system updates. Lower values may improve responsiveness decrease performance.");
			maxVisibleSkeletons = config.Bind<int>("Performance", "MaxVisibleSkeletons", 100, "Maximum number of skeletons that can be visible at once.");
			showToasts = config.Bind<bool>("UI", "ShowToasts", true, "Enable or disable toast notifications in the UI.");
			showSkeletonNametags = config.Bind<bool>("UI", "ShowSkeletonNametags", true, "Enable or disable skeleton nametags.");
			showTimeSinceDeath = config.Bind<bool>("UI", "ShowTimeSinceDeath", true, "Enable or disable showing the time since death in skeleton nametags.");
			showSecondsAlways = config.Bind<bool>("UI", "ShowSecondsAlways", false, "Always show seconds in the time since death, even for recent deaths.");
			maxDistanceForVisibleNametag = config.Bind<float>("UI", "MaxDistanceForVisibleNametag", 8f, "Maximum distance at which skeleton nametags are visible.");
			minDistanceForVisibleNametag = config.Bind<float>("UI", "MinDistanceForVisibleNametag", 3f, "Minimum distance at which skeleton nametags are visible.");
			maxAngleForVisibleNametag = config.Bind<float>("UI", "MaxAngleForVisibleNametag", 25f, "Maximum angle (in degrees) from the camera at which skeleton nametags are visible.");
			maxNametagSize = config.Bind<float>("UI", "MaxNametagSize", 2.5f, "Maximum size of skeleton nametags.");
			minNametagSize = config.Bind<float>("UI", "MinNametagSize", 1.2f, "Minimum size of skeleton nametags.");
			nametagColor = config.Bind<Color>("UI", "NametagColor", Color.white, "Color of skeleton nametags.");
			nametagOutlineWidth = config.Bind<float>("UI", "NametagOutlineWidth", 0.05f, "Width of the outline around skeleton nametags.");
			nametagOutlineColor = config.Bind<Color>("UI", "NametagOutlineColor", Color.black, "Color of the outline around skeleton nametags.");
			EverestPlugin.LogInfo("Configuration loaded successfully.");
			EverestPlugin.LogInfo($"Enabled: {Enabled}");
			if (Enabled)
			{
				EverestPlugin.LogInfo($"Max Skeletons: {MaxSkeletons}");
				EverestPlugin.LogInfo($"Allow Uploads: {AllowUploads}");
				EverestPlugin.LogInfo($"Hide Floaters: {HideFloaters}");
				EverestPlugin.LogInfo($"Exclude Near Crash Site: {ExcludeNearCrashSite}");
				EverestPlugin.LogInfo($"Exclude Near Campfires: {ExcludeNearCampfires}");
				EverestPlugin.LogInfo($"Skeleton Draw Distance: {SkeletonDrawDistance}");
				EverestPlugin.LogInfo($"Culling Update Frequency: {CullingUpdateFrequency} seconds");
				EverestPlugin.LogInfo($"Max Visible Skeletons: {maxVisibleSkeletons.Value}");
				EverestPlugin.LogInfo($"Show Toasts: {ShowToasts}");
				EverestPlugin.LogInfo($"Show Skeleton Nametags: {ShowSkeletonNametags}");
				if (ShowSkeletonNametags)
				{
					EverestPlugin.LogInfo($"Show Time Since Death: {ShowTimeSinceDeath}");
					EverestPlugin.LogInfo($"Show Seconds Always: {ShowSecondsAlways}");
					EverestPlugin.LogInfo($"Max Distance For Visible Nametag: {MaxDistanceForVisibleNametag}");
					EverestPlugin.LogInfo($"Min Distance For Visible Nametag: {MinDistanceForVisibleNametag}");
					EverestPlugin.LogInfo($"Max Angle For Visible Nametag: {MaxAngleForVisibleNametag}");
					EverestPlugin.LogInfo($"Max Nametag Size: {MaxNametagSize}");
					EverestPlugin.LogInfo($"Min Nametag Size: {MinNametagSize}");
					EverestPlugin.LogInfo($"Nametag Color: {NametagColor}");
					EverestPlugin.LogInfo($"Nametag Outline Width: {NametagOutlineWidth}");
					EverestPlugin.LogInfo($"Nametag Outline Color: {NametagOutlineColor}");
				}
			}
		}
	}
	public class Skeleton : MonoBehaviour
	{
		private struct PoseSkeletonJob : IJobParallelForTransform
		{
			public NativeArray<Vector3> Positions;

			public NativeArray<Vector3> Rotations;

			public void Execute(int index, TransformAccess transform)
			{
				//IL_0009: 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_001a: Unknown result type (might be due to invalid IL or missing references)
				((TransformAccess)(ref transform)).SetLocalPositionAndRotation(Positions[index], Quaternion.Euler(Rotations[index]));
			}
		}

		[CompilerGenerated]
		private sealed class <>c__DisplayClass22_0
		{
			public JobHandle handle;

			internal bool <Initialize>b__0()
			{
				return ((JobHandle)(ref handle)).IsCompleted;
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <Initialize>d__22 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskVoidMethodBuilder <>t__builder;

			public Skeleton <>4__this;

			public SkeletonData data;

			private NativeArray<Vector3> <positions>5__2;

			private NativeArray<Vector3> <rotations>5__3;

			private TransformAccessArray <transformAccessArray>5__4;

			private Awaiter <>u__1;

			private void MoveNext()
			{
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: 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_0125: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0143: 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)
				int num = <>1__state;
				Skeleton skeleton = <>4__this;
				try
				{
					Awaiter awaiter;
					if (num != 0)
					{
						<>c__DisplayClass22_0 <>c__DisplayClass22_ = new <>c__DisplayClass22_0();
						skeleton.Nickname = data.nickname;
						((Object)((Component)skeleton).gameObject).name = skeleton.Nickname;
						skeleton.Timestamp = DateTime.Parse(data.timestamp);
						skeleton.TryAddAccessory(data.steam_id);
						((Component)skeleton).transform.SetPositionAndRotation(data.global_position, Quaternion.Euler(data.global_rotation));
						<positions>5__2 = ArrayExtensions.ToNativeArray<Vector3>(data.bone_local_positions, (Allocator)3);
						<rotations>5__3 = ArrayExtensions.ToNativeArray<Vector3>(data.bone_local_rotations, (Allocator)3);
						PoseSkeletonJob poseSkeletonJob = new PoseSkeletonJob
						{
							Positions = <positions>5__2,
							Rotations = <rotations>5__3
						};
						<transformAccessArray>5__4 = new TransformAccessArray(skeleton.Bones, -1);
						<>c__DisplayClass22_.handle = IJobParallelForTransformExtensions.ScheduleByRef<PoseSkeletonJob>(ref poseSkeletonJob, <transformAccessArray>5__4, default(JobHandle));
						UniTask val = UniTask.WaitUntil((Func<bool>)(() => ((JobHandle)(ref <>c__DisplayClass22_.handle)).IsCompleted), (PlayerLoopTiming)8, default(CancellationToken), false);
						awaiter = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <Initialize>d__22>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter);
						num = (<>1__state = -1);
					}
					((Awaiter)(ref awaiter)).GetResult();
					<positions>5__2.Dispose();
					<rotations>5__3.Dispose();
					((TransformAccessArray)(ref <transformAccessArray>5__4)).Dispose();
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		private List<SkeletonAccessory> _accessories = new List<SkeletonAccessory>();

		public static List<Skeleton> AllActiveSkeletons { get; private set; } = new List<Skeleton>();


		public Transform HeadBone => Bones[11];

		public string Nickname { get; private set; }

		public DateTime Timestamp { get; private set; }

		public Transform[] Bones { get; private set; }

		private void Awake()
		{
			Bones = (from x in ((Component)((Component)this).transform).GetComponentsInChildren<Transform>()
				where Enum.GetNames(typeof(SkeletonBodypart)).Contains(((Object)x).name)
				select x).ToArray();
		}

		private void OnEnable()
		{
			AllActiveSkeletons.Add(this);
		}

		private void OnDisable()
		{
			RemoveAccessories();
			AllActiveSkeletons.Remove(this);
		}

		[AsyncStateMachine(typeof(<Initialize>d__22))]
		public UniTaskVoid Initialize(SkeletonData data)
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			<Initialize>d__22 <Initialize>d__ = default(<Initialize>d__22);
			<Initialize>d__.<>t__builder = AsyncUniTaskVoidMethodBuilder.Create();
			<Initialize>d__.<>4__this = this;
			<Initialize>d__.data = data;
			<Initialize>d__.<>1__state = -1;
			((AsyncUniTaskVoidMethodBuilder)(ref <Initialize>d__.<>t__builder)).Start<<Initialize>d__22>(ref <Initialize>d__);
			return ((AsyncUniTaskVoidMethodBuilder)(ref <Initialize>d__.<>t__builder)).Task;
		}

		private void TryAddAccessory(string steamId)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(steamId) && AccessoryManager.TryGetAccessoryForSteamId(steamId, out var accessory))
			{
				((Component)accessory).transform.SetParent(TransformExtensions.FindChildRecursive(((Component)this).transform, accessory.bone));
				((Component)accessory).transform.SetLocalPositionAndRotation(accessory.localPosition, accessory.localRotation);
				((Component)accessory).transform.localScale = Vector3.one;
				_accessories.Add(accessory);
			}
		}

		public void RemoveAccessories()
		{
			foreach (SkeletonAccessory accessory in _accessories)
			{
				if ((Object)(object)accessory != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)accessory).gameObject);
				}
			}
			_accessories.Clear();
		}
	}
	public class SkeletonManager : MonoBehaviourPun
	{
		private struct CullableSkeleton
		{
			public Skeleton Instance;

			public SkeletonData Data;

			public CullableSkeleton(SkeletonData data)
			{
				Instance = null;
				Data = data;
			}
		}

		private struct DistanceCullingResult : IComparable<DistanceCullingResult>
		{
			public uint index;

			public float distance;

			public int CompareTo(DistanceCullingResult other)
			{
				return distance.CompareTo(other.distance);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <GetResultCountAsync>d__23 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder<int> <>t__builder;

			public SkeletonManager <>4__this;

			private Awaiter<AsyncGPUReadbackRequest> <>u__1;

			private void MoveNext()
			{
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: 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_0049: 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_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				SkeletonManager skeletonManager = <>4__this;
				int result2;
				try
				{
					Awaiter<AsyncGPUReadbackRequest> awaiter;
					if (num != 0)
					{
						ComputeBuffer.CopyCount(skeletonManager._resultsBuffer, skeletonManager._countBuffer, 0);
						awaiter = UnityAsyncExtensions.GetAwaiter(AsyncGPUReadback.Request(skeletonManager._countBuffer, (Action<AsyncGPUReadbackRequest>)null));
						if (!awaiter.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							<>t__builder.AwaitUnsafeOnCompleted<Awaiter<AsyncGPUReadbackRequest>, <GetResultCountAsync>d__23>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(Awaiter<AsyncGPUReadbackRequest>);
						num = (<>1__state = -1);
					}
					AsyncGPUReadbackRequest result = awaiter.GetResult();
					if (((AsyncGPUReadbackRequest)(ref result)).hasError)
					{
						EverestPlugin.LogError("GPU count readback error.");
						result2 = 0;
					}
					else
					{
						result2 = ((AsyncGPUReadbackRequest)(ref result)).GetData<int>(0)[0];
					}
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<>t__builder.SetException(exception);
					return;
				}
				<>1__state = -2;
				<>t__builder.SetResult(result2);
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				<>t__builder.SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <GetSkeletonDataAsync>d__28 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder<SkeletonData[]> <>t__builder;

			public SkeletonManager <>4__this;

			private Awaiter<SkeletonData[]> <>u__1;

			private void MoveNext()
			{
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cc: 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_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: 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)
				int num = <>1__state;
				SkeletonManager skeletonManager = <>4__this;
				SkeletonData[] result;
				try
				{
					Awaiter<SkeletonData[]> awaiter;
					SkeletonData[] array;
					if (num != 0)
					{
						if (num != 1)
						{
							array = new SkeletonData[0];
							if (PhotonNetwork.IsMasterClient)
							{
								awaiter = skeletonManager.RetrieveSkeletonDatasAsHostAsync().GetAwaiter();
								if (!awaiter.IsCompleted)
								{
									num = (<>1__state = 0);
									<>u__1 = awaiter;
									<>t__builder.AwaitUnsafeOnCompleted<Awaiter<SkeletonData[]>, <GetSkeletonDataAsync>d__28>(ref awaiter, ref this);
									return;
								}
								goto IL_0081;
							}
							awaiter = skeletonManager.RetrieveSkeletonDatasAsClientAsync().GetAwaiter();
							if (!awaiter.IsCompleted)
							{
								num = (<>1__state = 1);
								<>u__1 = awaiter;
								<>t__builder.AwaitUnsafeOnCompleted<Awaiter<SkeletonData[]>, <GetSkeletonDataAsync>d__28>(ref awaiter, ref this);
								return;
							}
						}
						else
						{
							awaiter = <>u__1;
							<>u__1 = default(Awaiter<SkeletonData[]>);
							num = (<>1__state = -1);
						}
						array = awaiter.GetResult();
						goto IL_00eb;
					}
					awaiter = <>u__1;
					<>u__1 = default(Awaiter<SkeletonData[]>);
					num = (<>1__state = -1);
					goto IL_0081;
					IL_0081:
					array = awaiter.GetResult();
					goto IL_00eb;
					IL_00eb:
					result = array;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<>t__builder.SetException(exception);
					return;
				}
				<>1__state = -2;
				<>t__builder.SetResult(result);
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				<>t__builder.SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <HandleDistanceCullingAsync>d__21 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskVoidMethodBuilder <>t__builder;

			public SkeletonManager <>4__this;

			private int <resultsCount>5__2;

			private Awaiter<int> <>u__1;

			private Awaiter<AsyncGPUReadbackRequest> <>u__2;

			private void MoveNext()
			{
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: Unknown result type (might be due to invalid IL or missing references)
				//IL_0158: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_007f: 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_0119: 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)
				//IL_0171: Unknown result type (might be due to invalid IL or missing references)
				//IL_0176: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_0138: 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_0199: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				SkeletonManager skeletonManager = <>4__this;
				try
				{
					Awaiter<AsyncGPUReadbackRequest> awaiter;
					Awaiter<int> awaiter2;
					if (num != 0)
					{
						if (num == 1)
						{
							awaiter = <>u__2;
							<>u__2 = default(Awaiter<AsyncGPUReadbackRequest>);
							num = (<>1__state = -1);
							goto IL_016f;
						}
						skeletonManager._isCulling = true;
						_distanceCheckShader.SetVector("_PlayerPosition", Vector4.op_Implicit(((Component)Camera.main).transform.position));
						skeletonManager._resultsBuffer.SetCounterValue(0u);
						_distanceCheckShader.Dispatch(skeletonManager._kernelIndex, Mathf.CeilToInt((float)skeletonManager._totalSkeletonCount / 256f), 1, 1);
						awaiter2 = skeletonManager.GetResultCountAsync().GetAwaiter();
						if (!awaiter2.IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter2;
							((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<int>, <HandleDistanceCullingAsync>d__21>(ref awaiter2, ref this);
							return;
						}
					}
					else
					{
						awaiter2 = <>u__1;
						<>u__1 = default(Awaiter<int>);
						num = (<>1__state = -1);
					}
					int result = awaiter2.GetResult();
					<resultsCount>5__2 = result;
					if (<resultsCount>5__2 != 0)
					{
						awaiter = UnityAsyncExtensions.GetAwaiter(AsyncGPUReadback.Request(skeletonManager._resultsBuffer, <resultsCount>5__2 * Marshal.SizeOf(typeof(DistanceCullingResult)), 0, (Action<AsyncGPUReadbackRequest>)null));
						if (!awaiter.IsCompleted)
						{
							num = (<>1__state = 1);
							<>u__2 = awaiter;
							((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<AsyncGPUReadbackRequest>, <HandleDistanceCullingAsync>d__21>(ref awaiter, ref this);
							return;
						}
						goto IL_016f;
					}
					skeletonManager.ProcessCullingResults();
					skeletonManager._isCulling = false;
					goto end_IL_000e;
					IL_016f:
					AsyncGPUReadbackRequest result2 = awaiter.GetResult();
					if (((AsyncGPUReadbackRequest)(ref result2)).hasError)
					{
						EverestPlugin.LogError("GPU Readback error");
						skeletonManager._isCulling = false;
					}
					else
					{
						DistanceCullingResult[] array = ((AsyncGPUReadbackRequest)(ref result2)).GetData<DistanceCullingResult>(0).ToArray();
						Array.Sort(array);
						int count = Math.Min(<resultsCount>5__2, ConfigHandler.MaxVisibleSkeletons);
						skeletonManager._objectsInRange.UnionWith(from x in array.Take(count)
							select x.index);
						skeletonManager.ProcessCullingResults();
						skeletonManager._objectsInRange.Clear();
						skeletonManager._isCulling = false;
					}
					end_IL_000e:;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <LoadComputeShaderAsync>d__25 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			private AssetBundle <assetBundle>5__2;

			private AssetBundleCreateRequestAwaiter <>u__1;

			private Awaiter<Object> <>u__2;

			private Awaiter <>u__3;

			private void MoveNext()
			{
				//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_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: 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_0110: Unknown result type (might be due to invalid IL or missing references)
				//IL_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Unknown result type (might be due to invalid IL or missing references)
				//IL_0157: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_016c: 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_0064: 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)
				int num = <>1__state;
				try
				{
					AssetBundleCreateRequestAwaiter awaiter3;
					Awaiter<Object> awaiter2;
					Awaiter awaiter;
					Object result;
					UniTask val;
					AssetBundle result2;
					switch (num)
					{
					default:
					{
						EverestPlugin.LogInfo("Loading compute shader...");
						Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Everest.Resources.computeshader.bundle");
						if (manifestResourceStream != null)
						{
							awaiter3 = UnityAsyncExtensions.GetAwaiter(AssetBundle.LoadFromStreamAsync(manifestResourceStream));
							if (!((AssetBundleCreateRequestAwaiter)(ref awaiter3)).IsCompleted)
							{
								num = (<>1__state = 0);
								<>u__1 = awaiter3;
								((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<AssetBundleCreateRequestAwaiter, <LoadComputeShaderAsync>d__25>(ref awaiter3, ref this);
								return;
							}
							goto IL_0099;
						}
						EverestPlugin.LogError("Compute Shader AssetBundle not found in resources.");
						goto end_IL_0007;
					}
					case 0:
						awaiter3 = <>u__1;
						<>u__1 = default(AssetBundleCreateRequestAwaiter);
						num = (<>1__state = -1);
						goto IL_0099;
					case 1:
						awaiter2 = <>u__2;
						<>u__2 = default(Awaiter<Object>);
						num = (<>1__state = -1);
						goto IL_011f;
					case 2:
						{
							awaiter = <>u__3;
							<>u__3 = default(Awaiter);
							num = (<>1__state = -1);
							break;
						}
						IL_011f:
						result = awaiter2.GetResult();
						_distanceCheckShader = (ComputeShader)(object)((result is ComputeShader) ? result : null);
						val = UnityAsyncExtensions.ToUniTask((AsyncOperation)(object)<assetBundle>5__2.UnloadAsync(false), (IProgress<float>)null, (PlayerLoopTiming)8, default(CancellationToken), false);
						awaiter = ((UniTask)(ref val)).GetAwaiter();
						if (!((Awaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 2);
							<>u__3 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <LoadComputeShaderAsync>d__25>(ref awaiter, ref this);
							return;
						}
						break;
						IL_0099:
						result2 = ((AssetBundleCreateRequestAwaiter)(ref awaiter3)).GetResult();
						<assetBundle>5__2 = result2;
						awaiter2 = UnityAsyncExtensions.ToUniTask(<assetBundle>5__2.LoadAssetAsync("Assets/Everest/distancethreshold.compute"), (IProgress<float>)null, (PlayerLoopTiming)8, default(CancellationToken), false).GetAwaiter();
						if (!awaiter2.IsCompleted)
						{
							num = (<>1__state = 1);
							<>u__2 = awaiter2;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<Object>, <LoadComputeShaderAsync>d__25>(ref awaiter2, ref this);
							return;
						}
						goto IL_011f;
					}
					((Awaiter)(ref awaiter)).GetResult();
					EverestPlugin.LogInfo($"Compute Shader prefab loaded: {(Object)(object)_distanceCheckShader != (Object)null}");
					end_IL_0007:;
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					<assetBundle>5__2 = null;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				<assetBundle>5__2 = null;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <LoadSkeletonPrefabAsync>d__26 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder <>t__builder;

			private ResourceRequestAwaiter <>u__1;

			private void MoveNext()
			{
				//IL_0051: 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_005d: 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_0037: 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)
				int num = <>1__state;
				try
				{
					ResourceRequestAwaiter awaiter;
					if (num != 0)
					{
						EverestPlugin.LogInfo("Loading skeleton prefab...");
						awaiter = UnityAsyncExtensions.GetAwaiter(Resources.LoadAsync<GameObject>("Skeleton"));
						if (!((ResourceRequestAwaiter)(ref awaiter)).IsCompleted)
						{
							num = (<>1__state = 0);
							<>u__1 = awaiter;
							((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<ResourceRequestAwaiter, <LoadSkeletonPrefabAsync>d__26>(ref awaiter, ref this);
							return;
						}
					}
					else
					{
						awaiter = <>u__1;
						<>u__1 = default(ResourceRequestAwaiter);
						num = (<>1__state = -1);
					}
					Object result = ((ResourceRequestAwaiter)(ref awaiter)).GetResult();
					GameObject val = (GameObject)(object)((result is GameObject) ? result : null);
					if ((Object)(object)val == (Object)null)
					{
						EverestPlugin.LogError("Skeleton prefab not found in Resources.");
					}
					else
					{
						_skeletonPrefab = Object.Instantiate<GameObject>(val).AddComponent<Skeleton>();
						Object.DontDestroyOnLoad((Object)(object)_skeletonPrefab);
						SFX_PlayOneShot[] componentsInChildren = ((Component)_skeletonPrefab).GetComponentsInChildren<SFX_PlayOneShot>();
						for (int i = 0; i < componentsInChildren.Length; i++)
						{
							Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
						}
						((Component)_skeletonPrefab).gameObject.SetActive(false);
						EverestPlugin.LogInfo($"Skeleton prefab loaded: {(Object)(object)_skeletonPrefab != (Object)null}");
					}
				}
				catch (Exception exception)
				{
					<>1__state = -2;
					((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception);
					return;
				}
				<>1__state = -2;
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult();
			}

			void IAsyncStateMachine.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				this.MoveNext();
			}

			[DebuggerHidden]
			private void SetStateMachine(IAsyncStateMachine stateMachine)
			{
				((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine);
			}

			void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine)
			{
				//ILSpy generated this explicit interface implementation from .override directive in SetStateMachine
				this.SetStateMachine(stateMachine);
			}
		}

		[StructLayout(LayoutKind.Auto)]
		[CompilerGenerated]
		private struct <RetrieveSkeletonDatasAsClientAsync>d__30 : IAsyncStateMachine
		{
			public int <>1__state;

			public AsyncUniTaskMethodBuilder<SkeletonData[]> <>t__builder;

			public SkeletonManager <>4__this;

			private int <attempts>