Decompiled source of Get Up u Coward v0.1.8

BepInEx/plugins/GetUpUCoward/GetUpUCoward.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GetUpUCoward.Core;
using HarmonyLib;
using Jotunn.Extensions;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

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

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace GetUpUCoward
{
	[DefaultExecutionOrder(10000)]
	public sealed class CrawlPose : MonoBehaviour
	{
		private sealed class Limb
		{
			internal Transform Upper;

			internal Transform Lower;

			internal Transform End;

			internal bool Arm;

			internal float Side;

			internal Quaternion EndFrameOffset;

			internal bool OrientEnd;

			internal bool Planted;

			internal Transform? Surface;

			internal Vector3 Contact;

			internal Vector3 InputEnd;

			internal Vector3 InputPole;

			internal Vector3 AssistGoal;

			internal Vector3 AssistPole;

			internal Quaternion InputEndRotation;

			internal Quaternion AssistEndRotation;
		}

		private DownedPlayer state;

		private Animator animator;

		private Transform hips;

		private Transform head;

		private Transform? spine;

		private Transform? chest;

		private Transform? neck;

		private Transform[] bones;

		private Quaternion[] inputRot;

		private Vector3[] inputPos;

		private Quaternion[] referenceRot;

		private CrawlPoseRestore restorer;

		private readonly List<Limb> limbs = new List<Limb>();

		private float weight;

		private float phase;

		private float motion;

		private float groundOffset;

		private float bodyScale = 1f;

		private float travelDirection = 1f;

		private Vector3 groundNormal = Vector3.up;

		private bool ready;

		private bool hadOutput;

		private bool warned;

		private Vector3 lastPosition;

		private float assistWeight;

		private bool hadAssistPatient;

		private Vector3 assistDirection = Vector3.forward;

		private Vector3 assistContact;

		private readonly List<KeyValuePair<Renderer, bool>> hiddenGear = new List<KeyValuePair<Renderer, bool>>();

		private static readonly int GroundMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "terrain", "piece", "Default_small", "vehicle" });

		internal void Initialize(DownedPlayer player)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			state = player;
			lastPosition = ((Component)player).transform.position;
		}

		private bool Setup()
		{
			//IL_0163: 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)
			animator = GameAccess.Animator.Invoke((Character)(object)state.Player);
			if ((Object)(object)animator == (Object)null || !animator.isHuman || (Object)(object)((Component)animator).transform == (Object)(object)((Component)this).transform || !((Component)animator).transform.IsChildOf(((Component)this).transform))
			{
				if (!warned)
				{
					warned = true;
					Plugin.Log.LogWarning((object)"Crawl pose requires the vanilla humanoid avatar. Downed gameplay remains active.");
				}
				return false;
			}
			hips = animator.GetBoneTransform((HumanBodyBones)0);
			head = animator.GetBoneTransform((HumanBodyBones)10);
			spine = animator.GetBoneTransform((HumanBodyBones)7);
			chest = animator.GetBoneTransform((HumanBodyBones)8);
			neck = animator.GetBoneTransform((HumanBodyBones)9);
			limbs.Clear();
			AddLimb((HumanBodyBones)13, (HumanBodyBones)15, (HumanBodyBones)17, arm: true, -1f);
			AddLimb((HumanBodyBones)14, (HumanBodyBones)16, (HumanBodyBones)18, arm: true, 1f);
			AddLimb((HumanBodyBones)1, (HumanBodyBones)3, (HumanBodyBones)5, arm: false, -1f);
			AddLimb((HumanBodyBones)2, (HumanBodyBones)4, (HumanBodyBones)6, arm: false, 1f);
			if ((Object)(object)hips == (Object)null || (Object)(object)head == (Object)null || limbs.Count != 4)
			{
				return false;
			}
			bodyScale = Mathf.Clamp(Vector3.Distance(hips.position, head.position) / 0.65f, 0.75f, 1.35f);
			List<Transform> list = new List<Transform>
			{
				((Component)animator).transform,
				hips
			};
			AddAffected(list, spine);
			AddAffected(list, chest);
			AddAffected(list, neck);
			AddAffected(list, head);
			AddAffected(list, animator.GetBoneTransform((HumanBodyBones)11));
			AddAffected(list, animator.GetBoneTransform((HumanBodyBones)12));
			foreach (Limb limb in limbs)
			{
				AddAffected(list, limb.Upper);
				AddAffected(list, limb.Lower);
				AddAffected(list, limb.End);
			}
			bones = list.ToArray();
			inputRot = (Quaternion[])(object)new Quaternion[bones.Length];
			inputPos = (Vector3[])(object)new Vector3[bones.Length];
			CacheReferencePose();
			restorer = ((Component)this).gameObject.GetComponent<CrawlPoseRestore>() ?? ((Component)this).gameObject.AddComponent<CrawlPoseRestore>();
			restorer.Initialize(this);
			ready = true;
			return true;
		}

		private static void AddAffected(List<Transform> affected, Transform? bone)
		{
			if ((Object)(object)bone != (Object)null && !affected.Contains(bone))
			{
				affected.Add(bone);
			}
		}

		private void CacheReferencePose()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002f: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, Quaternion> dictionary = new Dictionary<string, Quaternion>();
			SkeletonBone[] skeleton = animator.avatar.humanDescription.skeleton;
			if (skeleton != null)
			{
				SkeletonBone[] array = skeleton;
				foreach (SkeletonBone val in array)
				{
					dictionary[val.name] = val.rotation;
				}
			}
			referenceRot = (Quaternion[])(object)new Quaternion[bones.Length];
			for (int j = 0; j < bones.Length; j++)
			{
				inputRot[j] = bones[j].localRotation;
				referenceRot[j] = (dictionary.TryGetValue(((Object)bones[j]).name, out var value) ? value : inputRot[j]);
			}
			SkinnedMeshRenderer[] componentsInChildren = ((Component)animator).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val2 in componentsInChildren)
			{
				if ((Object)(object)val2.sharedMesh == (Object)null)
				{
					continue;
				}
				Transform[] array2 = val2.bones;
				Matrix4x4[] bindposes = val2.sharedMesh.bindposes;
				if (array2.Length != bindposes.Length)
				{
					continue;
				}
				Dictionary<Transform, int> dictionary2 = new Dictionary<Transform, int>();
				for (int k = 0; k < array2.Length; k++)
				{
					if ((Object)(object)array2[k] != (Object)null)
					{
						dictionary2[array2[k]] = k;
					}
				}
				for (int l = 1; l < bones.Length; l++)
				{
					if (!dictionary.ContainsKey(((Object)bones[l]).name) && (Object)(object)bones[l].parent != (Object)null && dictionary2.TryGetValue(bones[l], out var value2) && dictionary2.TryGetValue(bones[l].parent, out var value3))
					{
						Quaternion[] array3 = referenceRot;
						int num = l;
						Matrix4x4 val3 = bindposes[value3] * ((Matrix4x4)(ref bindposes[value2])).inverse;
						array3[num] = ((Matrix4x4)(ref val3)).rotation;
					}
				}
			}
			try
			{
				for (int m = 1; m < bones.Length; m++)
				{
					bones[m].localRotation = referenceRot[m];
				}
				foreach (Limb limb in limbs)
				{
					HumanBodyBones val4 = (HumanBodyBones)((!limb.Arm) ? ((limb.Side < 0f) ? 19 : 20) : ((limb.Side < 0f) ? 30 : 45));
					Transform boneTransform = animator.GetBoneTransform(val4);
					if ((Object)(object)boneTransform == (Object)null)
					{
						continue;
					}
					Vector3 val5 = boneTransform.position - limb.End.position;
					Vector3 val6 = ((Component)animator).transform.up;
					if (limb.Arm)
					{
						Transform boneTransform2 = animator.GetBoneTransform((HumanBodyBones)((limb.Side < 0f) ? 27 : 42));
						Transform boneTransform3 = animator.GetBoneTransform((HumanBodyBones)((limb.Side < 0f) ? 36 : 51));
						if ((Object)(object)boneTransform2 == (Object)null || (Object)(object)boneTransform3 == (Object)null)
						{
							continue;
						}
						val6 = Vector3.Cross(boneTransform2.position - limb.End.position, boneTransform3.position - limb.End.position) * limb.Side;
					}
					if (!(((Vector3)(ref val5)).sqrMagnitude < 1E-06f) && !(((Vector3)(ref val6)).sqrMagnitude < 1E-06f))
					{
						limb.EndFrameOffset = Quaternion.Inverse(Quaternion.LookRotation(val5, val6)) * limb.End.rotation;
						limb.OrientEnd = true;
					}
				}
			}
			finally
			{
				for (int n = 1; n < bones.Length; n++)
				{
					bones[n].localRotation = inputRot[n];
				}
			}
		}

		private void AddLimb(HumanBodyBones upper, HumanBodyBones lower, HumanBodyBones end, bool arm, float side)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Transform boneTransform = animator.GetBoneTransform(upper);
			Transform boneTransform2 = animator.GetBoneTransform(lower);
			Transform boneTransform3 = animator.GetBoneTransform(end);
			if ((Object)(object)boneTransform != (Object)null && (Object)(object)boneTransform2 != (Object)null && (Object)(object)boneTransform3 != (Object)null)
			{
				limbs.Add(new Limb
				{
					Upper = boneTransform,
					Lower = boneTransform2,
					End = boneTransform3,
					Arm = arm,
					Side = side
				});
			}
		}

		private void LateUpdate()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_013d: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0603: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Unknown result type (might be due to invalid IL or missing references)
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			//IL_065a: Unknown result type (might be due to invalid IL or missing references)
			//IL_065f: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0773: Unknown result type (might be due to invalid IL or missing references)
			//IL_0778: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06af: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Unknown result type (might be due to invalid IL or missing references)
			//IL_074e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Unknown result type (might be due to invalid IL or missing references)
			//IL_0757: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_078f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0794: Unknown result type (might be due to invalid IL or missing references)
			//IL_0799: Unknown result type (might be due to invalid IL or missing references)
			//IL_079d: Unknown result type (might be due to invalid IL or missing references)
			//IL_079f: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0802: Unknown result type (might be due to invalid IL or missing references)
			//IL_0807: Unknown result type (might be due to invalid IL or missing references)
			//IL_080c: Unknown result type (might be due to invalid IL or missing references)
			//IL_081c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0821: Unknown result type (might be due to invalid IL or missing references)
			//IL_0829: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)state == (Object)null || (Object)(object)state.Player == (Object)null)
			{
				return;
			}
			bool isDown = state.IsDown;
			if (isDown)
			{
				assistWeight = 0f;
				hadAssistPatient = false;
			}
			else if (UpdateAssisting())
			{
				return;
			}
			if (!ready && (!isDown || !Setup()))
			{
				return;
			}
			weight = Mathf.MoveTowards(weight, isDown ? 1f : 0f, Time.deltaTime / (isDown ? 0.25f : 0.4f));
			if (weight <= 0f)
			{
				lastPosition = ((Component)this).transform.position;
				return;
			}
			for (int i = 0; i < bones.Length; i++)
			{
				inputRot[i] = bones[i].localRotation;
				inputPos[i] = bones[i].localPosition;
			}
			Vector3 up = Vector3.up;
			Vector3 forward = ((Component)this).transform.forward;
			Vector3 right = ((Component)this).transform.right;
			Vector3 val = Vector3.ProjectOnPlane(((Component)this).transform.position - lastPosition, up);
			float num = Mathf.Min(((Vector3)(ref val)).magnitude, Plugin.CrawlSpeed.Value * Mathf.Max(Time.deltaTime, 0.01f) * 2f);
			lastPosition = ((Component)this).transform.position;
			float num2 = ((Vector3.Dot(val, forward) < -0.001f) ? (-1f) : 1f);
			travelDirection = Mathf.MoveTowards(travelDirection, num2, Time.deltaTime * 6f);
			phase = Mathf.Repeat(phase + num * 5.7f * travelDirection, (float)Math.PI * 2f);
			motion = Mathf.MoveTowards(motion, (num > 0.001f) ? 1f : 0f, Time.deltaTime * 5f);
			Vector3 val2 = Ground(((Component)this).transform.position + up * 0.8f, out var normal);
			normal = Vector3.RotateTowards(up, normal, 0.61086524f, 0f);
			float num3 = 1f - Mathf.Exp(-12f * Time.deltaTime);
			Vector3 val3 = Vector3.Slerp(groundNormal, normal, num3);
			groundNormal = ((Vector3)(ref val3)).normalized;
			groundOffset = Mathf.Lerp(groundOffset, Mathf.Clamp(val2.y - ((Component)this).transform.position.y, -0.55f, 0.5f), num3);
			normal = groundNormal;
			val2 = ((Component)this).transform.position + up * groundOffset;
			Quaternion val4 = Quaternion.FromToRotation(up, normal);
			Vector3 val5 = val4 * forward;
			Vector3 val6 = val4 * right;
			for (int j = 1; j < bones.Length; j++)
			{
				bones[j].localRotation = Quaternion.Slerp(bones[j].localRotation, referenceRot[j], weight);
			}
			Transform transform = ((Component)animator).transform;
			float num4 = Mathf.Sin(phase) * motion;
			Quaternion val7 = Quaternion.AngleAxis(num4 * 2f, val5) * Quaternion.LookRotation(val5, normal) * Quaternion.Euler(88f, 0f, 0f);
			transform.rotation = Quaternion.Slerp(transform.rotation, val7, weight);
			Vector3 val8 = val2 + normal * ((0.18f + Mathf.Sin(phase * 2f) * 0.008f * motion) * bodyScale) + val6 * (num4 * 0.012f * bodyScale);
			transform.position += (val8 - hips.position) * weight;
			Bend(spine, -3f, val6, weight);
			Bend(chest, -7f, val6, weight);
			Bend(chest, (0f - num4) * 2f, normal, weight);
			Bend(neck, -28f, val6, weight);
			Bend(head, -30f, val6, weight);
			foreach (Limb limb in limbs)
			{
				float num5 = phase + ((limb.Side < 0f) ? ((float)Math.PI) : 0f) + (limb.Arm ? 0f : ((float)Math.PI));
				float num6 = Mathf.Sin(num5) * motion;
				float num7 = (Vector3.Distance(limb.Upper.position, limb.Lower.position) + Vector3.Distance(limb.Lower.position, limb.End.position)) * (limb.Arm ? (0.42f + num6 * 0.2f) : (-0.86f + num6 * 0.13f));
				Vector3 val9 = limb.Upper.position + val5 * num7 + val6 * (limb.Side * (limb.Arm ? 0.06f : 0.11f) * bodyScale);
				Vector3 normal2;
				Transform surface;
				Vector3 val10 = Ground(val9 + normal * 0.7f, out normal2, out surface);
				float num8 = (limb.Arm ? 0.055f : 0.065f) * bodyScale;
				val9 = val10 + normal2 * num8;
				float num9 = Mathf.Cos(num5) * travelDirection;
				float num10 = Mathf.Max(0f, num9) * motion;
				val9 += normal * (num10 * (limb.Arm ? 0.065f : 0.045f) * bodyScale);
				if (!(num9 < 0f) || !(motion > 0.05f))
				{
					limb.Planted = false;
				}
				else
				{
					if (!limb.Planted)
					{
						limb.Surface = surface;
						limb.Contact = (((Object)(object)surface != (Object)null) ? surface.InverseTransformPoint(val9) : val9);
						limb.Planted = true;
					}
					Vector3 val11 = (((Object)(object)limb.Surface != (Object)null) ? limb.Surface.TransformPoint(limb.Contact) : limb.Contact);
					float num11 = Vector3.Distance(val11, val9) / bodyScale;
					float num12 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.18f, 0.34f, num11));
					float num13 = Mathf.SmoothStep(0f, 1f, (0f - num9) * 4f) * motion * (1f - num12);
					val9 = Vector3.Lerp(val9, val11, num13);
					if (num11 > 0.35f)
					{
						limb.Planted = false;
					}
				}
				Vector3 pole = val6 * limb.Side - normal * (limb.Arm ? 0.35f : 0.1f);
				SolveLimb(limb, val9, pole, weight);
				if (limb.OrientEnd)
				{
					Quaternion val12 = Quaternion.LookRotation(limb.Arm ? (val5 + val6 * (limb.Side * 0.12f)) : (-val5), limb.Arm ? normal : (-normal)) * limb.EndFrameOffset;
					limb.End.rotation = Quaternion.Slerp(limb.End.rotation, val12, weight);
				}
			}
			hadOutput = true;
		}

		private DownedPlayer? FindPatient()
		{
			ZNetView view = state.View;
			if ((Object)(object)view == (Object)null || !view.IsValid())
			{
				return null;
			}
			long owner = view.GetZDO().GetOwner();
			if (owner == 0L)
			{
				return null;
			}
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (!((Object)(object)allPlayer == (Object)(object)state.Player))
				{
					DownedPlayer component = ((Component)allPlayer).GetComponent<DownedPlayer>();
					if (!((Object)(object)component == (Object)null) && component.IsDown && !(component.Remaining <= 0f) && component.Rescuer == owner && (!((Object)(object)state.Player == (Object)(object)Player.m_localPlayer) || RescueInput.IsChanneling(component)) && RescueRules.Eligible(state.Player, component))
					{
						return component;
					}
				}
			}
			return null;
		}

		private bool UpdateAssisting()
		{
			//IL_0059: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00bb: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_058a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_064a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0737: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0767: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_077c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_063a: Unknown result type (might be due to invalid IL or missing references)
			//IL_063f: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0644: Unknown result type (might be due to invalid IL or missing references)
			//IL_0688: Unknown result type (might be due to invalid IL or missing references)
			//IL_068a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0684: Unknown result type (might be due to invalid IL or missing references)
			//IL_0697: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0802: Unknown result type (might be due to invalid IL or missing references)
			//IL_0809: Unknown result type (might be due to invalid IL or missing references)
			//IL_080e: Unknown result type (might be due to invalid IL or missing references)
			//IL_069e: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06af: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0845: Unknown result type (might be due to invalid IL or missing references)
			//IL_084c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0853: Unknown result type (might be due to invalid IL or missing references)
			//IL_0858: Unknown result type (might be due to invalid IL or missing references)
			//IL_085c: Unknown result type (might be due to invalid IL or missing references)
			//IL_085e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0884: Unknown result type (might be due to invalid IL or missing references)
			//IL_088b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0892: Unknown result type (might be due to invalid IL or missing references)
			//IL_0819: Unknown result type (might be due to invalid IL or missing references)
			//IL_081b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Unknown result type (might be due to invalid IL or missing references)
			//IL_083c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0841: Unknown result type (might be due to invalid IL or missing references)
			Player player = state.Player;
			if (((Character)player).IsDead() || ((Character)player).IsTeleporting() || ((Character)player).InAttack() || ((Character)player).InDodge())
			{
				assistWeight = 0f;
				hadAssistPatient = false;
				return false;
			}
			DownedPlayer downedPlayer = FindPatient();
			if ((Object)(object)downedPlayer != (Object)null)
			{
				Vector3 val = Vector3.ProjectOnPlane(((Component)downedPlayer).transform.position - ((Component)this).transform.position, Vector3.up);
				if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
				{
					assistDirection = ((Vector3)(ref val)).normalized;
				}
				assistContact = ((Component)downedPlayer).transform.position + ((Component)downedPlayer).transform.forward * 0.35f + Vector3.up * 0.32f;
			}
			if (!ready && ((Object)(object)downedPlayer == (Object)null || !Setup()))
			{
				return false;
			}
			bool flag = (Object)(object)downedPlayer != (Object)null;
			float num = ((flag == hadAssistPatient) ? Time.deltaTime : 0f);
			hadAssistPatient = flag;
			assistWeight = Mathf.MoveTowards(assistWeight, flag ? 1f : 0f, num / (flag ? 0.65f : 0.55f));
			if (assistWeight <= 0f)
			{
				return false;
			}
			weight = 0f;
			lastPosition = ((Component)this).transform.position;
			for (int i = 0; i < bones.Length; i++)
			{
				inputRot[i] = bones[i].localRotation;
				inputPos[i] = bones[i].localPosition;
			}
			foreach (Limb limb2 in limbs)
			{
				limb2.InputEnd = limb2.End.position;
				limb2.InputEndRotation = limb2.End.rotation;
				limb2.InputPole = limb2.Lower.position - limb2.Upper.position;
			}
			for (int j = 1; j < bones.Length; j++)
			{
				bones[j].localRotation = referenceRot[j];
			}
			Ground(((Component)this).transform.position + Vector3.up * 0.8f, out var normal);
			normal = Vector3.RotateTowards(Vector3.up, normal, (float)Math.PI / 6f, 0f);
			Vector3 normal2 = Vector3.ProjectOnPlane(assistDirection, normal);
			Vector3 normalized = ((Vector3)(ref normal2)).normalized;
			normal2 = Vector3.Cross(normal, normalized);
			Vector3 normalized2 = ((Vector3)(ref normal2)).normalized;
			Transform transform = ((Component)animator).transform;
			transform.rotation = Quaternion.LookRotation(normalized, normal);
			Limb limb = limbs.Find((Limb limb2) => !limb2.Arm && limb2.Side < 0f);
			float num2 = Vector3.Distance(limb.Upper.position, limb.Lower.position);
			Vector3 val2 = ((Component)this).transform.position - normalized * (0.04f * bodyScale) - normalized2 * (0.13f * bodyScale);
			Vector3 val3 = Ground(val2 + Vector3.up * 0.8f, out normal2) + normal * (0.055f * bodyScale);
			Vector3 val4 = val3 + normal * num2 + hips.position - limb.Upper.position;
			transform.position += val4 - hips.position;
			Bend(spine, 8f, normalized2, 1f);
			Bend(chest, 10f, normalized2, 1f);
			Bend(neck, 6f, normalized2, 1f);
			Bend(head, 2f, normalized2, 1f);
			float num3 = (float)(GameAccess.NetworkMilliseconds % 1000000) / 1000f * (float)Math.PI * 2f;
			foreach (Limb limb3 in limbs)
			{
				Vector3 goal;
				Vector3 val5;
				if (limb3.Arm)
				{
					float num4 = Mathf.Sin(num3 + limb3.Side * (float)Math.PI * 0.5f);
					goal = assistContact + normalized2 * (limb3.Side * 0.11f * bodyScale) + normal * (num4 * 0.025f * bodyScale) + normalized * (num4 * 0.035f * bodyScale);
					val5 = normalized2 * limb3.Side - normal * 0.6f;
				}
				else
				{
					bool num5 = limb3.Side < 0f;
					float num6 = Vector3.Distance(limb3.Upper.position, limb3.Lower.position);
					float num7 = Vector3.Distance(limb3.Lower.position, limb3.End.position);
					Vector3 val6 = (num5 ? (val3 - normalized * Mathf.Sqrt(Mathf.Max(0.001f, num7 * num7 - 0.0004f * bodyScale * bodyScale))) : (limb3.Upper.position + normalized * (num6 * 0.97f)));
					goal = Ground(val6 + Vector3.up * 0.8f, out normal2) + normal * (0.075f * bodyScale);
					val5 = (num5 ? (val3 - limb3.Upper.position) : normalized);
				}
				SolveLimb(limb3, goal, val5, 1f);
				if (limb3.OrientEnd)
				{
					bool flag2 = !limb3.Arm && limb3.Side < 0f;
					Quaternion rotation = Quaternion.LookRotation(flag2 ? (-normalized) : normalized, flag2 ? (-normal) : normal) * limb3.EndFrameOffset;
					limb3.End.rotation = rotation;
				}
				limb3.AssistGoal = limb3.End.position;
				limb3.AssistPole = val5;
				limb3.AssistEndRotation = limb3.End.rotation;
			}
			float num8 = Mathf.SmoothStep(0f, 1f, assistWeight);
			for (int num9 = 0; num9 < bones.Length; num9++)
			{
				bones[num9].localRotation = Quaternion.Slerp(inputRot[num9], bones[num9].localRotation, num8);
				bones[num9].localPosition = Vector3.Lerp(inputPos[num9], bones[num9].localPosition, num8);
			}
			foreach (Limb limb4 in limbs)
			{
				float num10 = Mathf.SmoothStep(0f, 1f, limb4.Arm ? Mathf.InverseLerp(0.18f, 1f, assistWeight) : Mathf.InverseLerp(0f, 0.8f, assistWeight));
				Vector3 val7 = Vector3.Lerp(limb4.InputEnd, limb4.AssistGoal, num10);
				if (!limb4.Arm)
				{
					val7 += normal * (Mathf.Sin(num10 * (float)Math.PI) * 0.055f * bodyScale);
				}
				Vector3 pole = Vector3.Lerp(limb4.InputPole, limb4.AssistPole, num8);
				SolveLimb(limb4, val7, pole, 1f, Mathf.Lerp(0.999f, 0.95f, num8));
				limb4.End.rotation = Quaternion.Slerp(limb4.InputEndRotation, limb4.AssistEndRotation, num10);
			}
			VisEquipment val8 = GameAccess.VisualEquipment.Invoke((Humanoid)(object)player);
			if ((Object)(object)val8 != (Object)null)
			{
				HideHeldModel(GameAccess.HeldLeft.Invoke(val8));
				HideHeldModel(GameAccess.HeldRight.Invoke(val8));
			}
			hadOutput = true;
			return true;
		}

		private void HideHeldModel(GameObject? item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return;
			}
			Renderer[] componentsInChildren = item.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				bool flag = false;
				foreach (KeyValuePair<Renderer, bool> item2 in hiddenGear)
				{
					if ((Object)(object)item2.Key == (Object)(object)val)
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					hiddenGear.Add(new KeyValuePair<Renderer, bool>(val, val.enabled));
					val.enabled = false;
				}
			}
		}

		private static void Bend(Transform? bone, float angle, Vector3 axis, float blend)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bone != (Object)null)
			{
				bone.rotation = Quaternion.Slerp(bone.rotation, Quaternion.AngleAxis(angle, axis) * bone.rotation, blend);
			}
		}

		private Vector3 Ground(Vector3 origin, out Vector3 normal)
		{
			//IL_0001: 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)
			Transform surface;
			return Ground(origin, out normal, out surface);
		}

		private Vector3 Ground(Vector3 origin, out Vector3 normal, out Transform? surface)
		{
			//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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			normal = Vector3.up;
			surface = null;
			Vector3 point = default(Vector3);
			((Vector3)(ref point))..ctor(origin.x, ((Component)this).transform.position.y, origin.z);
			float num = float.MaxValue;
			RaycastHit[] array = Physics.RaycastAll(origin, Vector3.down, 2.5f, GroundMask, (QueryTriggerInteraction)1);
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val = array[i];
				if (!((Object)(object)((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Character>() == (Object)(object)state.Player) && !(((RaycastHit)(ref val)).distance >= num))
				{
					num = ((RaycastHit)(ref val)).distance;
					point = ((RaycastHit)(ref val)).point;
					normal = ((RaycastHit)(ref val)).normal;
					surface = ((Component)((RaycastHit)(ref val)).collider).transform;
				}
			}
			return point;
		}

		private static void SolveLimb(Limb limb, Vector3 goal, Vector3 pole, float blend, float extension = 0.95f)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_008f: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = limb.Upper.position;
			float num = Vector3.Distance(position, limb.Lower.position);
			float num2 = Vector3.Distance(limb.Lower.position, limb.End.position);
			Vector3 val = goal - position;
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f) && !(num < 0.001f) && !(num2 < 0.001f))
			{
				float num3 = Mathf.Clamp(((Vector3)(ref val)).magnitude, Mathf.Abs(num - num2) + 0.001f, (num + num2) * extension);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				Vector3 val2 = Vector3.ProjectOnPlane(pole, normalized);
				Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
				if (((Vector3)(ref normalized2)).sqrMagnitude < 0.01f)
				{
					val2 = Vector3.Cross(normalized, Vector3.forward);
					normalized2 = ((Vector3)(ref val2)).normalized;
				}
				float num4 = Mathf.Clamp((num * num + num3 * num3 - num2 * num2) / (2f * num * num3), -1f, 1f);
				Vector3 val3 = position + normalized * (num4 * num) + normalized2 * (Mathf.Sqrt(Mathf.Max(0f, 1f - num4 * num4)) * num);
				Quaternion val4 = Quaternion.FromToRotation(limb.Lower.position - position, val3 - position) * limb.Upper.rotation;
				limb.Upper.rotation = Quaternion.Slerp(limb.Upper.rotation, val4, blend);
				Vector3 val5 = position + normalized * num3;
				Quaternion val6 = Quaternion.FromToRotation(limb.End.position - limb.Lower.position, val5 - limb.Lower.position) * limb.Lower.rotation;
				limb.Lower.rotation = Quaternion.Slerp(limb.Lower.rotation, val6, blend);
			}
		}

		internal void RestoreBeforeGameUpdate()
		{
			//IL_0088: 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)
			foreach (KeyValuePair<Renderer, bool> item in hiddenGear)
			{
				if ((Object)(object)item.Key != (Object)null)
				{
					item.Key.enabled = item.Value;
				}
			}
			hiddenGear.Clear();
			if (!hadOutput)
			{
				return;
			}
			for (int i = 0; i < bones.Length; i++)
			{
				if (!((Object)(object)bones[i] == (Object)null))
				{
					bones[i].localRotation = inputRot[i];
					bones[i].localPosition = inputPos[i];
				}
			}
			hadOutput = false;
		}

		private void OnDisable()
		{
			RestoreBeforeGameUpdate();
			weight = (assistWeight = 0f);
			hadAssistPatient = false;
		}

		private void OnDestroy()
		{
			RestoreBeforeGameUpdate();
			if ((Object)(object)restorer != (Object)null)
			{
				Object.Destroy((Object)(object)restorer);
			}
		}
	}
	[DefaultExecutionOrder(-10000)]
	public sealed class CrawlPoseRestore : MonoBehaviour
	{
		private CrawlPose? pose;

		internal void Initialize(CrawlPose owner)
		{
			pose = owner;
		}

		private void Update()
		{
			if ((Object)(object)pose != (Object)null)
			{
				pose.RestoreBeforeGameUpdate();
			}
		}

		private void FixedUpdate()
		{
			if ((Object)(object)pose != (Object)null)
			{
				pose.RestoreBeforeGameUpdate();
			}
		}

		private void OnDisable()
		{
			if ((Object)(object)pose != (Object)null)
			{
				pose.RestoreBeforeGameUpdate();
			}
		}
	}
	[DefaultExecutionOrder(11000)]
	public sealed class DownedHud : MonoBehaviour
	{
		private RectTransform? panel;

		private Hud? owner;

		private TMP_Text title;

		private TMP_Text subtitle;

		private TMP_Text clock;

		private TMP_Text clockLabel;

		private TMP_Text action;

		private TMP_Text hint;

		private TMP_Text percent;

		private RawImage stateIcon;

		private RawImage actionIcon;

		private Image bleedFill;

		private Image actionFill;

		private Image nativeBlood;

		private Image nativeHold;

		private Color bloodColor;

		private Color holdColor;

		private CanvasGroup group;

		private const float Width = 600f;

		private const float Height = 188f;

		private static readonly Color Gold = new Color(1f, 0.79f, 0.39f);

		private static readonly Color Parchment = new Color(0.91f, 0.87f, 0.75f);

		private static readonly Color Muted = new Color(0.7f, 0.65f, 0.53f);

		private void LateUpdate()
		{
			Hud instance = Hud.instance;
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)instance == (Object)null || (Object)(object)localPlayer == (Object)null)
			{
				Release();
				return;
			}
			if ((Object)(object)owner != (Object)(object)instance)
			{
				Release();
			}
			DownedPlayer component = ((Component)localPlayer).GetComponent<DownedPlayer>();
			DownedPlayer target = RescueInput.Target;
			bool flag = component?.IsDown ?? false;
			if (((Character)localPlayer).IsDead() || !instance.IsVisible() || Menu.IsVisible() || (!flag && ((Object)(object)target == (Object)null || !target.IsDown)))
			{
				if ((Object)(object)panel != (Object)null)
				{
					((Component)panel).gameObject.SetActive(false);
				}
				return;
			}
			if ((Object)(object)panel == (Object)null)
			{
				Create(instance);
			}
			if (!((Component)panel).gameObject.activeSelf)
			{
				((Component)panel).gameObject.SetActive(true);
				group.alpha = 0f;
			}
			group.alpha = Mathf.MoveTowards(group.alpha, 1f, Time.unscaledDeltaTime * 8f);
			FitToHud();
			Present(flag ? component : target, flag, ZNet.GetUID());
		}

		private void Create(Hud hud)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0130: 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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: 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_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			owner = hud;
			panel = Rect("GetUpUCoward.Hud", hud.m_rootObject.transform, 0f, 0f, 600f, 188f);
			RectTransform? obj = panel;
			RectTransform? obj2 = panel;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.15f);
			obj2.anchorMax = val;
			obj.anchorMin = val;
			panel.pivot = new Vector2(0.5f, 0f);
			panel.anchoredPosition = Vector2.zero;
			group = ((Component)panel).gameObject.AddComponent<CanvasGroup>();
			group.interactable = false;
			group.blocksRaycasts = false;
			Picture("ImageGen frame", (Transform)(object)panel, 0f, 0f, 600f, 188f, HudIcons.Frame);
			stateIcon = Picture("State icon", (Transform)(object)panel, 26f, 23f, 66f, 57f, HudIcons.Downed);
			title = Text("Title", 104f, 17f, 348f, 43f, 32f, Gold, norse: true);
			subtitle = Text("Context", 105f, 57f, 345f, 22f, 16f, Parchment);
			subtitle.richText = false;
			clock = Text("Countdown", 462f, 23f, 107f, 34f, 29f, Parchment);
			clock.alignment = (TextAlignmentOptions)4100;
			clockLabel = Text("Countdown label", 453f, 58f, 116f, 19f, 12f, Muted);
			clockLabel.alignment = (TextAlignmentOptions)4100;
			clockLabel.text = "BLEEDOUT";
			nativeBlood = ((Component)hud.m_healthBarFast.m_bar).GetComponent<Image>();
			nativeHold = ((Component)hud.m_staminaBar2Fast.m_bar).GetComponent<Image>();
			bloodColor = ((Graphic)nativeBlood).color;
			holdColor = ((Graphic)nativeHold).color;
			bleedFill = Meter("Bleedout", 30f, 89f, 540f, 12f, hud.m_healthBarFast);
			actionIcon = Picture("Action icon", (Transform)(object)panel, 28f, 113f, 32f, 32f, HudIcons.GiveUp);
			action = Text("Action", 71f, 108f, 444f, 27f, 18f, Parchment);
			percent = Text("Progress", 518f, 110f, 51f, 24f, 16f, Gold);
			percent.alignment = (TextAlignmentOptions)4100;
			hint = Text("Hint", 71f, 136f, 498f, 22f, 14f, Muted);
			actionFill = Meter("Hold progress", 30f, 161f, 540f, 12f, hud.m_staminaBar2Fast);
			group.alpha = 0f;
			Plugin.Log.LogDebug((object)("Created native HUD with fonts " + ((Object)title.font).name + " / " + ((Object)action.font).name));
		}

		private void FitToHud()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0022: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = (RectTransform)((Transform)panel).parent;
			float[] obj = new float[3] { 1f, 0f, 0f };
			Rect rect = val.rect;
			obj[1] = (((Rect)(ref rect)).width - 32f) / 600f;
			rect = val.rect;
			obj[2] = ((Rect)(ref rect)).height * 0.32f / 188f;
			float num = Mathf.Min(obj);
			((Transform)panel).localScale = Vector3.one * Mathf.Max(0.1f, num);
		}

		private void Present(DownedPlayer state, bool self, long peer)
		{
			//IL_0134: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: 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_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			bool flag = state.Rescuer != 0;
			bool flag2 = flag && !self && state.Rescuer != peer;
			bool flag3 = self && state.GiveUpProgress > 0f;
			float num = (flag3 ? state.GiveUpProgress : (flag ? state.Progress : 0f));
			title.text = ((!self) ? "Help them up" : (flag ? "Help is here" : "You are downed"));
			subtitle.text = ((!self) ? state.Player.GetPlayerName() : (flag ? "A friend is helping you to your feet" : "Hold on. A friend can still reach you."));
			stateIcon.texture = (Texture)(object)(flag ? HudIcons.Revive : HudIcons.Downed);
			int num2 = Mathf.Max(0, Mathf.CeilToInt(state.Remaining));
			clock.text = num2 / 60 + ":" + (num2 % 60).ToString("00");
			bool flag4 = state.Remaining <= 10f;
			((Graphic)clock).color = (Color)(flag4 ? new Color(1f, 0.43f, 0.29f) : Parchment);
			((Graphic)bleedFill).color = (flag4 ? Color.Lerp(bloodColor, new Color(1f, 0.6f, 0.36f), 0.25f + 0.25f * Mathf.Sin(Time.unscaledTime * 4f)) : bloodColor);
			Fill(bleedFill, state.Remaining / Mathf.Max(1f, state.Duration));
			actionIcon.texture = (Texture)(object)((self && (!flag || flag3)) ? HudIcons.GiveUp : HudIcons.Revive);
			action.text = ((!self) ? (flag2 ? "Another Viking is helping" : ("Hold " + BoundKey("Use", "JoyUse") + " to revive")) : (flag3 ? "Accepting your fate..." : (flag ? "Being revived..." : ("Hold " + BoundKey("Jump", "JoyJump") + " to give up"))));
			hint.text = ((!self) ? (flag2 ? "One rescuer at a time" : (flag ? "Keep holding. Stay close and face them." : "Stay close and face your fallen friend")) : (flag3 ? "Release to keep fighting" : (flag ? ("Hold " + BoundKey("Jump", "JoyJump") + " if you choose to give up") : "Move to crawl toward safety")));
			((Graphic)actionFill).color = holdColor;
			((Graphic)percent).color = Gold;
			percent.text = ((num > 0f) ? (Mathf.Min(99, Mathf.FloorToInt(num * 100f)) + "%") : "");
			Fill(actionFill, num);
		}

		private TMP_Text Text(string name, float x, float y, float width, float height, float size, Color color, bool norse = false)
		{
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = ((Component)Rect(name, (Transform)(object)panel, x, y, width, height)).gameObject.AddComponent<TextMeshProUGUI>();
			TMP_Text hoverName = (TMP_Text)(object)owner.m_hoverName;
			((TMP_Text)val).font = (norse ? GUIManager.Instance.TMP_Norse : hoverName.font);
			if ((Object)(object)((TMP_Text)val).font == (Object)null)
			{
				((TMP_Text)val).font = hoverName.font;
			}
			((TMP_Text)val).fontSharedMaterial = (norse ? ((TMP_Asset)((TMP_Text)val).font).material : hoverName.fontSharedMaterial);
			((TMP_Text)val).spriteAsset = hoverName.spriteAsset;
			((TMP_Text)val).fontSize = size;
			((TMP_Text)val).enableAutoSizing = true;
			((TMP_Text)val).fontSizeMin = size * 0.85f;
			((TMP_Text)val).fontSizeMax = size;
			((Graphic)val).color = color;
			((TMP_Text)val).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)val).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)val).overflowMode = (TextOverflowModes)1;
			((TMP_Text)val).richText = true;
			((Graphic)val).raycastTarget = false;
			return (TMP_Text)(object)val;
		}

		private static string BoundKey(string keyboard, string gamepad)
		{
			string boundKeyString = ZInput.instance.GetBoundKeyString(ZInput.IsGamepadActive() ? gamepad : keyboard, false);
			return "<color=#FFCA64>[" + boundKeyString + "]</color>";
		}

		private Image Meter(string name, float x, float y, float width, float height, GuiBar native)
		{
			//IL_0067: 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_011d: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			RectTransform parent = Rect(name, (Transform)(object)panel, x, y, width, height);
			Transform parent2 = ((Component)native).transform.parent;
			Transform obj = parent2.Find("darken");
			Image val = ((obj != null) ? ((Component)obj).GetComponent<Image>() : null);
			if ((Object)(object)val != (Object)null)
			{
				CopyAppearance(val, Solid(Rect("Shadow", (Transform)(object)parent, -4f, -4f, width + 8f, height + 8f), ((Graphic)val).color));
			}
			Transform obj2 = parent2.Find("border");
			Image val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<Image>() : null);
			Image destination = Solid(Rect("Border", (Transform)(object)parent, -2f, -2f, width + 4f, height + 4f), new Color(0.06f, 0.06f, 0.06f, 0.48f));
			if ((Object)(object)val2 != (Object)null)
			{
				CopyAppearance(val2, destination);
			}
			RectTransform val3 = Rect("Track", (Transform)(object)parent, 0f, 0f, width, height);
			Image destination2 = Solid(val3, new Color(0f, 0f, 0f, 0.484f));
			Transform obj3 = parent2.Find("bkg");
			Image val4 = ((obj3 != null) ? ((Component)obj3).GetComponent<Image>() : null);
			if ((Object)(object)val4 != (Object)null)
			{
				CopyAppearance(val4, destination2);
			}
			RectTransform obj4 = Rect("Fill", (Transform)(object)val3, 0f, 0f, width, height);
			obj4.anchorMin = Vector2.zero;
			obj4.anchorMax = Vector2.one;
			Vector2 offsetMin = (obj4.offsetMax = Vector2.zero);
			obj4.offsetMin = offsetMin;
			Image val5 = Solid(obj4, Color.white);
			CopyAppearance(((Component)native.m_bar).GetComponent<Image>(), val5, height);
			return val5;
		}

		private static void CopyAppearance(Image source, Image destination, float height = 0f)
		{
			//IL_0025: 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)
			destination.sprite = source.sprite;
			((Graphic)destination).material = ((height > 0f) ? null : ((Graphic)source).material);
			((Graphic)destination).color = ((Graphic)source).color;
			destination.type = source.type;
			destination.fillCenter = source.fillCenter;
			destination.pixelsPerUnitMultiplier = source.pixelsPerUnitMultiplier;
			if (height > 0f)
			{
				destination.type = (Type)0;
				destination.fillCenter = true;
			}
		}

		private static void Fill(Image image, float value)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)image).rectTransform.anchorMax = new Vector2(Mathf.Clamp01(value), 1f);
			((Component)image).gameObject.SetActive(value > 0f);
		}

		private static RectTransform Rect(string name, Transform parent, float x, float y, float width, float height)
		{
			//IL_0014: 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_002b: 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_0054: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }).transform;
			((Transform)val).SetParent(parent, false);
			((Component)val).gameObject.layer = ((Component)parent).gameObject.layer;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0f, 1f);
			val.anchorMax = val2;
			val.anchorMin = val2;
			val.pivot = new Vector2(0f, 1f);
			val.anchoredPosition = new Vector2(x, 0f - y);
			val.sizeDelta = new Vector2(width, height);
			return val;
		}

		private static Image Solid(RectTransform rect, Color color)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Image obj = ((Component)rect).gameObject.AddComponent<Image>();
			((Graphic)obj).color = color;
			((Graphic)obj).raycastTarget = false;
			return obj;
		}

		private static RawImage Picture(string name, Transform parent, float x, float y, float width, float height, Texture2D texture)
		{
			RawImage obj = ((Component)Rect(name, parent, x, y, width, height)).gameObject.AddComponent<RawImage>();
			obj.texture = (Texture)(object)texture;
			((Graphic)obj).raycastTarget = false;
			return obj;
		}

		private void Release()
		{
			if ((Object)(object)panel != (Object)null)
			{
				((Component)panel).gameObject.SetActive(false);
				Object.Destroy((Object)(object)((Component)panel).gameObject);
			}
			panel = null;
			owner = null;
		}

		private void OnDisable()
		{
			Release();
		}

		private void OnDestroy()
		{
			Release();
		}
	}
	public sealed class DownedPlayer : MonoBehaviour
	{
		internal const string SaveKey = "com.dominic.getupucoward.downed.v1";

		internal const string RpcName = "com.dominic.getupucoward.rescue.v1";

		private const string DownKey = "com.dominic.getupucoward.down";

		private const string EpisodeKey = "com.dominic.getupucoward.episode";

		private const string RemainingKey = "com.dominic.getupucoward.remaining";

		private const string DurationKey = "com.dominic.getupucoward.duration";

		private const string StampKey = "com.dominic.getupucoward.stamp";

		private const string ProgressKey = "com.dominic.getupucoward.progress";

		private const string RescuerKey = "com.dominic.getupucoward.rescuer";

		private const string ReviveDurationKey = "com.dominic.getupucoward.reviveDuration";

		internal readonly DownedSession Session = new DownedSession();

		internal Player Player;

		internal ZNetView View;

		private bool initialized;

		private bool restored;

		private bool applied;

		private bool previousSkipTarget;

		private bool handsHidden;

		private float speed;

		private float walkSpeed;

		private float runSpeed;

		private float crouchSpeed;

		private float swimSpeed;

		private float nextPublish;

		private float nextStatusClear;

		internal bool FinalDeath { get; private set; }

		internal float GiveUpProgress { get; private set; }

		internal bool Owns
		{
			get
			{
				if ((Object)(object)View != (Object)null && View.IsValid())
				{
					return View.IsOwner();
				}
				return false;
			}
		}

		internal bool IsDown
		{
			get
			{
				if (initialized && (Object)(object)View != (Object)null && View.IsValid() && !FinalDeath)
				{
					if (!Owns)
					{
						return View.GetZDO().GetBool("com.dominic.getupucoward.down", false);
					}
					return Session.Phase == SessionPhase.Downed;
				}
				return false;
			}
		}

		internal string Episode
		{
			get
			{
				if (!Owns)
				{
					return View.GetZDO().GetString("com.dominic.getupucoward.episode", "");
				}
				return Session.Episode;
			}
		}

		internal float Duration
		{
			get
			{
				if (!Owns)
				{
					return View.GetZDO().GetFloat("com.dominic.getupucoward.duration", 60f);
				}
				return (float)Session.Duration;
			}
		}

		internal float Remaining
		{
			get
			{
				if (!Owns)
				{
					return Mathf.Clamp(View.GetZDO().GetFloat("com.dominic.getupucoward.remaining", 0f) - Mathf.Max(0f, (float)(GameAccess.NetworkMilliseconds - View.GetZDO().GetLong("com.dominic.getupucoward.stamp", GameAccess.NetworkMilliseconds)) / 1000f), 0f, Duration);
				}
				return (float)Session.Remaining;
			}
		}

		internal float Progress
		{
			get
			{
				if (!Owns)
				{
					return View.GetZDO().GetFloat("com.dominic.getupucoward.progress", 0f);
				}
				return (float)(Session.ReviveElapsed / Session.ReviveDuration);
			}
		}

		internal long Rescuer
		{
			get
			{
				if (!Owns)
				{
					return View.GetZDO().GetLong("com.dominic.getupucoward.rescuer", 0L);
				}
				return Session.Rescuer;
			}
		}

		internal static DownedPlayer? Get(Character? character)
		{
			if ((Object)(object)character != (Object)null)
			{
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val != null)
				{
					return ((Component)val).GetComponent<DownedPlayer>();
				}
			}
			return null;
		}

		internal static bool Down(Character? character)
		{
			return Get(character)?.IsDown ?? false;
		}

		internal void Initialize(Player player)
		{
			if (!initialized)
			{
				Player = player;
				View = GameAccess.View.Invoke((Character)(object)player);
				if (!((Object)(object)View == (Object)null))
				{
					View.Register<ZDOID, string, int>("com.dominic.getupucoward.rescue.v1", (Action<long, ZDOID, string, int>)ReceiveRescue);
					initialized = true;
					(((Component)this).gameObject.GetComponent<CrawlPose>() ?? ((Component)this).gameObject.AddComponent<CrawlPose>()).Initialize(this);
				}
			}
		}

		internal void Enter()
		{
			if (Owns && !((Character)Player).IsDead() && !FinalDeath && Session.Enter(Plugin.Bleedout.Value, Plugin.ReviveTime.Value))
			{
				restored = true;
				ApplyDownedSettings();
				((Character)Player).SetHealth(1f);
				ClearHarmfulEffects();
				Save();
				Publish();
				Plugin.Log.LogInfo((object)$"{Player.GetPlayerName()} is downed ({Session.Remaining:0}s).");
			}
		}

		private void Update()
		{
			if (!initialized || !View.IsValid())
			{
				return;
			}
			if (Owns && !restored)
			{
				restored = true;
				if (Player.m_customData.TryGetValue("com.dominic.getupucoward.downed.v1", out var value))
				{
					if (Session.Restore(value, Plugin.ReviveTime.Value))
					{
						ApplyDownedSettings();
						((Character)Player).SetHealth(1f);
						ClearHarmfulEffects();
						Publish();
					}
					else
					{
						Player.m_customData.Remove("com.dominic.getupucoward.downed.v1");
						Plugin.Log.LogWarning((object)"Discarded invalid saved downed state.");
					}
				}
			}
			if (IsDown && !applied)
			{
				ApplyDownedSettings();
			}
			else if (!IsDown && applied)
			{
				RestoreSettings();
			}
			if (!Owns || !IsDown)
			{
				return;
			}
			bool rescuerEligible = Session.Rescuer != 0L && RescueRules.EligiblePeer(Session.Rescuer, this);
			switch (Session.Tick(Time.deltaTime, Time.timeAsDouble, rescuerEligible))
			{
			case TickResult.Died:
				FinishDeath();
				return;
			case TickResult.Revived:
				Revive();
				return;
			}
			if ((Object)(object)Player == (Object)(object)Player.m_localPlayer && GameAccess.CanTakeInput(Player) && (ZInput.GetButton("Jump") || ZInput.GetButton("JoyJump")))
			{
				GiveUpProgress += Time.deltaTime / Plugin.GiveUpTime.Value;
			}
			else
			{
				GiveUpProgress = 0f;
			}
			if (GiveUpProgress >= 1f)
			{
				Session.Die();
				FinishDeath();
				return;
			}
			if (Time.time >= nextStatusClear)
			{
				nextStatusClear = Time.time + 0.5f;
				ClearHarmfulEffects();
			}
			if (Time.time >= nextPublish)
			{
				nextPublish = Time.time + 0.1f;
				Publish();
			}
		}

		private void ReceiveRescue(long sender, ZDOID reviverId, string episode, int action)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (!Owns || !IsDown)
			{
				return;
			}
			Player val = GameAccess.FindPlayer(reviverId);
			if ((Object)(object)val == (Object)null || GameAccess.View.Invoke((Character)(object)val).GetZDO().GetOwner() != sender)
			{
				return;
			}
			switch (action)
			{
			case 0:
				Session.Cancel(sender, episode);
				break;
			case 1:
				if (RescueRules.Eligible(val, this))
				{
					Session.Request(sender, episode, Time.timeAsDouble);
				}
				break;
			}
			Publish();
		}

		internal void Save()
		{
			if (Owns && restored)
			{
				if (Session.Phase == SessionPhase.Downed && !FinalDeath)
				{
					Player.m_customData["com.dominic.getupucoward.downed.v1"] = Session.Serialize();
				}
				else
				{
					Player.m_customData.Remove("com.dominic.getupucoward.downed.v1");
				}
			}
		}

		private void Publish()
		{
			if (Owns)
			{
				ZDO zDO = View.GetZDO();
				bool flag = Session.Phase == SessionPhase.Downed && !FinalDeath;
				zDO.Set("com.dominic.getupucoward.episode", flag ? Session.Episode : "");
				zDO.Set("com.dominic.getupucoward.remaining", flag ? ((float)Session.Remaining) : 0f);
				zDO.Set("com.dominic.getupucoward.duration", (float)Session.Duration);
				zDO.Set("com.dominic.getupucoward.stamp", GameAccess.NetworkMilliseconds);
				zDO.Set("com.dominic.getupucoward.progress", flag ? ((float)(Session.ReviveElapsed / Session.ReviveDuration)) : 0f);
				zDO.Set("com.dominic.getupucoward.rescuer", flag ? Session.Rescuer : 0);
				zDO.Set("com.dominic.getupucoward.reviveDuration", (float)Session.ReviveDuration);
				zDO.Set("com.dominic.getupucoward.down", flag);
			}
		}

		private void Revive()
		{
			RestoreSettings();
			Player.m_customData.Remove("com.dominic.getupucoward.downed.v1");
			Publish();
			((Character)Player).SetHealth(Mathf.Clamp(((Character)Player).GetMaxHealth() * Plugin.ReviveHealth.Value, 1f, ((Character)Player).GetMaxHealth()));
			Plugin.Log.LogInfo((object)(Player.GetPlayerName() + " was revived."));
		}

		private void FinishDeath()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			if (!FinalDeath)
			{
				FinalDeath = true;
				Player.m_customData.Remove("com.dominic.getupucoward.downed.v1");
				RestoreSettings();
				Publish();
				if (GameAccess.LastHit.Invoke((Character)(object)Player) == null)
				{
					GameAccess.LastHit.Invoke((Character)(object)Player) = new HitData();
				}
				((Character)Player).SetHealth(0f);
				GameAccess.CheckDeath((Character)(object)Player);
				Plugin.Log.LogInfo((object)(Player.GetPlayerName() + " bled out or gave up; normal death invoked."));
			}
		}

		private void ApplyDownedSettings()
		{
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			if (applied)
			{
				return;
			}
			applied = true;
			previousSkipTarget = ((Character)Player).m_aiSkipTarget;
			((Character)Player).m_aiSkipTarget = true;
			if (Owns)
			{
				RescueInput.CancelCurrent();
				speed = ((Character)Player).m_speed;
				walkSpeed = ((Character)Player).m_walkSpeed;
				runSpeed = ((Character)Player).m_runSpeed;
				crouchSpeed = ((Character)Player).m_crouchSpeed;
				swimSpeed = ((Character)Player).m_swimSpeed;
				((Character)Player).m_speed = (((Character)Player).m_walkSpeed = (((Character)Player).m_runSpeed = (((Character)Player).m_crouchSpeed = (((Character)Player).m_swimSpeed = Plugin.CrawlSpeed.Value))));
				GameAccess.SetCrouch(Player, crouch: false);
				GameAccess.StopEmote(Player);
				((Character)Player).AttachStop();
				Player.StopDoodadControl();
				Attack val = GameAccess.CurrentAttack.Invoke((Humanoid)(object)Player);
				if (val != null)
				{
					val.Stop();
				}
				GameAccess.CurrentAttack.Invoke((Humanoid)(object)Player) = null;
				Player.SetControls(Vector3.zero, false, false, false, false, false, false, false, false, false, false, false);
				handsHidden = ((Humanoid)Player).HideHandItems(false, false);
				GameObject val2 = GameAccess.PlacementGhost.Invoke(Player);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.SetActive(false);
				}
			}
		}

		private void RestoreSettings()
		{
			if (!applied)
			{
				return;
			}
			applied = false;
			((Character)Player).m_aiSkipTarget = previousSkipTarget;
			if (Owns)
			{
				((Character)Player).m_speed = speed;
				((Character)Player).m_walkSpeed = walkSpeed;
				((Character)Player).m_runSpeed = runSpeed;
				((Character)Player).m_crouchSpeed = crouchSpeed;
				((Character)Player).m_swimSpeed = swimSpeed;
				if (handsHidden && !FinalDeath)
				{
					GameAccess.ShowHands(Player);
				}
			}
			GiveUpProgress = 0f;
		}

		private void ClearHarmfulEffects()
		{
			SEMan sEMan = ((Character)Player).GetSEMan();
			StatusEffect[] array = sEMan.GetStatusEffects().ToArray();
			foreach (StatusEffect val in array)
			{
				if (!(val is SE_Burning) && !(val is SE_Poison) && !(val is SE_Smoke))
				{
					SE_Stats val2 = (SE_Stats)(object)((val is SE_Stats) ? val : null);
					if (val2 == null || (!(val2.m_healthPerTick < 0f) && !(val2.m_healthOverTime < 0f)))
					{
						continue;
					}
				}
				sEMan.RemoveStatusEffect(val, true);
			}
		}

		private void OnDestroy()
		{
			if (initialized && (Object)(object)Player != (Object)null)
			{
				RestoreSettings();
			}
		}
	}
	internal static class GameAccess
	{
		private delegate void CheckDeathDelegate(Character character);

		private delegate bool TakeInputDelegate(Player player);

		private delegate void SetCrouchDelegate(Player player, bool crouch);

		private delegate void StopEmoteDelegate(Player player);

		private delegate void ShowHandsDelegate(Humanoid humanoid, bool onlyRightHand, bool animation);

		internal static readonly FieldRef<Character, ZNetView> View = AccessTools.FieldRefAccess<Character, ZNetView>("m_nview");

		internal static readonly FieldRef<Character, Animator> Animator = AccessTools.FieldRefAccess<Character, Animator>("m_animator");

		internal static readonly FieldRef<Character, bool> IsDead = AccessTools.FieldRefAccess<Character, bool>("m_isDead");

		internal static readonly FieldRef<Character, HitData> LastHit = AccessTools.FieldRefAccess<Character, HitData>("m_lastHit");

		internal static readonly FieldRef<MonsterAI, Character> Target = AccessTools.FieldRefAccess<MonsterAI, Character>("m_targetCreature");

		internal static readonly FieldRef<Player, GameObject> PlacementGhost = AccessTools.FieldRefAccess<Player, GameObject>("m_placementGhost");

		internal static readonly FieldRef<Humanoid, Attack> CurrentAttack = AccessTools.FieldRefAccess<Humanoid, Attack>("m_currentAttack");

		internal static readonly FieldRef<Humanoid, VisEquipment> VisualEquipment = AccessTools.FieldRefAccess<Humanoid, VisEquipment>("m_visEquipment");

		internal static readonly FieldRef<VisEquipment, GameObject> HeldLeft = AccessTools.FieldRefAccess<VisEquipment, GameObject>("m_leftItemInstance");

		internal static readonly FieldRef<VisEquipment, GameObject> HeldRight = AccessTools.FieldRefAccess<VisEquipment, GameObject>("m_rightItemInstance");

		private static readonly CheckDeathDelegate CheckDeathCall = AccessTools.MethodDelegate<CheckDeathDelegate>(AccessTools.Method(typeof(Character), "CheckDeath", (Type[])null, (Type[])null), (object)null, true);

		private static readonly TakeInputDelegate TakeInputCall = AccessTools.MethodDelegate<TakeInputDelegate>(AccessTools.Method(typeof(Player), "TakeInput", (Type[])null, (Type[])null), (object)null, true);

		private static readonly SetCrouchDelegate SetCrouchCall = AccessTools.MethodDelegate<SetCrouchDelegate>(AccessTools.Method(typeof(Player), "SetCrouch", (Type[])null, (Type[])null), (object)null, true);

		private static readonly StopEmoteDelegate StopEmoteCall = AccessTools.MethodDelegate<StopEmoteDelegate>(AccessTools.Method(typeof(Player), "StopEmote", (Type[])null, (Type[])null), (object)null, true);

		private static readonly ShowHandsDelegate ShowHandsCall = AccessTools.MethodDelegate<ShowHandsDelegate>(AccessTools.Method(typeof(Humanoid), "ShowHandItems", (Type[])null, (Type[])null), (object)null, true);

		internal static long NetworkMilliseconds
		{
			get
			{
				if (!((Object)(object)ZNet.instance == (Object)null))
				{
					return (long)(ZNet.instance.GetTimeSeconds() * 1000.0);
				}
				return 0L;
			}
		}

		internal static void CheckDeath(Character player)
		{
			CheckDeathCall(player);
		}

		internal static bool CanTakeInput(Player player)
		{
			if (TakeInputCall(player))
			{
				return !Hud.InRadial();
			}
			return false;
		}

		internal static void SetCrouch(Player player, bool crouch)
		{
			SetCrouchCall(player, crouch);
		}

		internal static void StopEmote(Player player)
		{
			StopEmoteCall(player);
		}

		internal static void ShowHands(Player player)
		{
			ShowHandsCall((Humanoid)(object)player, onlyRightHand: false, animation: false);
		}

		internal static Player? FindPlayer(ZDOID id)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				ZNetView val = View.Invoke((Character)(object)allPlayer);
				if ((Object)(object)val != (Object)null && val.IsValid() && val.GetZDO().m_uid == id)
				{
					return allPlayer;
				}
			}
			return null;
		}
	}
	internal static class HudIcons
	{
		private static readonly Func<Texture2D, byte[], bool, bool> LoadPng = (Func<Texture2D, byte[], bool, bool>)Delegate.CreateDelegate(typeof(Func<Texture2D, byte[], bool, bool>), typeof(ImageConversion).GetMethod("LoadImage", new Type[3]
		{
			typeof(Texture2D),
			typeof(byte[]),
			typeof(bool)
		}) ?? throw new MissingMethodException("Unity ImageConversion.LoadImage(byte[]) is unavailable."));

		internal static Texture2D Downed { get; private set; } = null;

		internal static Texture2D Revive { get; private set; } = null;

		internal static Texture2D GiveUp { get; private set; } = null;

		internal static Texture2D Frame { get; private set; } = null;

		internal static void Load()
		{
			Downed = Read("downed");
			Revive = Read("revive");
			GiveUp = Read("give-up");
			Frame = Read("norse-frame");
			Plugin.Log.LogInfo((object)"Loaded 3 embedded ImageGen HUD icons and the Norse HUD frame.");
		}

		private static Texture2D Read(string name)
		{
			//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_0063: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			string text = "GetUpUCoward.Icons." + name + ".png";
			using Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream(text) ?? throw new InvalidOperationException("Missing embedded HUD icon: " + text);
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				name = "GetUpUCoward." + name,
				filterMode = (FilterMode)1,
				wrapMode = (TextureWrapMode)1,
				hideFlags = (HideFlags)61
			};
			if (LoadPng(val, memoryStream.ToArray(), arg3: true))
			{
				return val;
			}
			Object.Destroy((Object)(object)val);
			throw new InvalidOperationException("Could not decode HUD icon: " + text);
		}

		internal static void Dispose()
		{
			if ((Object)(object)Downed != (Object)null)
			{
				Object.Destroy((Object)(object)Downed);
			}
			if ((Object)(object)Revive != (Object)null)
			{
				Object.Destroy((Object)(object)Revive);
			}
			if ((Object)(object)GiveUp != (Object)null)
			{
				Obje