plugins/Jork.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Audio;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Jork")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Jork")]
[assembly: AssemblyTitle("Jork")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 Jork
{
	internal static class Effects
	{
		public static StatusEffect JorkSE;

		public static StatusEffect CooldownSE;

		private static KeyCode s_tipFor = (KeyCode)0;

		private static string s_tip;

		private static readonly FieldRef<StatusEffect, float> s_time = AccessTools.FieldRefAccess<StatusEffect, float>("m_time");

		public static void Create()
		{
			JorkSE = Make("SE_Jorking", "$se_jork", Icons.Load("se_jork.png"), 0f);
			CooldownSE = Make("SE_JorkCooldown", "$se_jork_cd", Icons.Load("se_jork_cd.png"), 30f);
		}

		private static StatusEffect Make(string id, string name, Sprite icon, float ttl)
		{
			StatusEffect obj = ScriptableObject.CreateInstance<StatusEffect>();
			((Object)obj).name = id;
			obj.m_name = name;
			obj.m_icon = icon ?? Icons.Fallback();
			obj.m_ttl = ttl;
			return obj;
		}

		public static void Destroy()
		{
			StatusEffect[] array = (StatusEffect[])(object)new StatusEffect[2] { JorkSE, CooldownSE };
			foreach (StatusEffect val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if ((Object)(object)val.m_icon != (Object)null)
				{
					if ((Object)(object)val.m_icon.texture != (Object)null)
					{
						Object.Destroy((Object)(object)val.m_icon.texture);
					}
					Object.Destroy((Object)(object)val.m_icon);
				}
				Object.Destroy((Object)(object)val);
			}
			JorkSE = (CooldownSE = null);
		}

		public static void RemoveFrom(Player p)
		{
			SEMan sEMan = ((Character)p).GetSEMan();
			if (sEMan == null)
			{
				return;
			}
			StatusEffect[] array = (StatusEffect[])(object)new StatusEffect[2] { JorkSE, CooldownSE };
			foreach (StatusEffect val in array)
			{
				StatusEffect val2 = (((Object)(object)val != (Object)null) ? sEMan.GetStatusEffect(val.NameHash()) : null);
				if ((Object)(object)val2 != (Object)null)
				{
					sEMan.RemoveStatusEffect(val2, true);
				}
			}
		}

		public static void Tick(Player p)
		{
			//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_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)
			if ((Object)(object)JorkSE == (Object)null)
			{
				return;
			}
			SEMan sEMan = ((Character)p).GetSEMan();
			if (sEMan != null)
			{
				StatusEffect val = sEMan.GetStatusEffect(JorkSE.NameHash());
				if (Jorking.Active && (Object)(object)val == (Object)null)
				{
					val = sEMan.AddStatusEffect(JorkSE, false, 0, 0f, (short)(-1));
				}
				else if (!Jorking.Active && (Object)(object)val != (Object)null)
				{
					sEMan.RemoveStatusEffect(val, true);
				}
				if (Jorking.Active && (Object)(object)val != (Object)null && s_tipFor != Plugin.Key.Value)
				{
					s_tipFor = Plugin.Key.Value;
					s_tip = "$se_jork_tip [<color=yellow>" + ((object)Unsafe.As<KeyCode, KeyCode>(ref s_tipFor)/*cast due to .constrained prefix*/).ToString() + "</color>]";
				}
				if (Jorking.Active && (Object)(object)val != (Object)null)
				{
					val.m_tooltip = s_tip;
				}
				StatusEffect val2 = sEMan.GetStatusEffect(CooldownSE.NameHash());
				bool flag = !Jorking.Active && Jorking.CooldownLeft > 0f;
				if (flag && (Object)(object)val2 == (Object)null)
				{
					val2 = sEMan.AddStatusEffect(CooldownSE, false, 0, 0f, (short)(-1));
				}
				else if (!flag && (Object)(object)val2 != (Object)null)
				{
					sEMan.RemoveStatusEffect(val2, true);
					return;
				}
				if (!((Object)(object)val2 == (Object)null))
				{
					val2.m_ttl = Mathf.Max(Plugin.Cooldown.Value, Jorking.CooldownLeft);
					s_time.Invoke(val2) = Mathf.Max(0f, val2.m_ttl - Jorking.CooldownLeft - 0.1f);
					val2.m_tooltip = "$se_jork_cd_tip";
				}
			}
		}
	}
	internal static class Icons
	{
		public static Sprite Load(string file)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			string text = Path.Combine(Plugin.Dir, "icons", file);
			if (!File.Exists(text))
			{
				Plugin.Log.LogWarning((object)("Missing icon " + text));
				return null;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true)
			{
				name = Path.GetFileNameWithoutExtension(file)
			};
			if (!ImageConversion.LoadImage(val, File.ReadAllBytes(text)))
			{
				Plugin.Log.LogWarning((object)("Unreadable icon " + text));
				return null;
			}
			((Texture)val).wrapMode = (TextureWrapMode)1;
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
		}

		public static Sprite Fallback()
		{
			//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_0017: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_0078: 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)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				name = "jork_fallback"
			};
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.93f, 0.72f, 0.58f, 1f);
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(32f, 32f));
					val.SetPixel(j, i, (num < 26.88f) ? val2 : Color.clear);
				}
			}
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 100f);
		}
	}
	internal struct JorkPose
	{
		public float Master;

		public float Crouch;

		public float Thrust;

		public float PelvisPitch;

		public float SpinePitch;

		public float SpineYaw;

		public float SpineRoll;

		public float HeadPitch;

		public float HeadYaw;

		public float HeadRoll;

		public float RightArm;

		public float StrokePos;

		public float StrokeLen;

		public float WristRoll;

		public float Squeeze;

		public float LeftArm;

		public float LeftToHead;

		public float Shudder;
	}
	internal static class JorkAnim
	{
		public const float IntroSeconds = 1.3f;

		public static float Rate(float tOn, bool finishing, float tFinish)
		{
			float num = Mathf.Lerp(Plugin.RateStart.Value, Plugin.RateEnd.Value, Speed(tOn));
			if (finishing)
			{
				num = Mathf.Lerp(num, Plugin.RateEnd.Value * 1.2f, S(0f, 0.35f, tFinish));
			}
			return num;
		}

		public static float Speed(float tOn)
		{
			return S(0f, Mathf.Max(0.2f, Plugin.RampSeconds.Value), tOn - 1.3f + 0.3f);
		}

		public static float Intensity(float tOn)
		{
			return S(0f, Mathf.Max(0.5f, Plugin.BuildUpSeconds.Value), tOn - 1.3f);
		}

		public static float Glance(float tOn, out float side)
		{
			side = 1f;
			if (!Plugin.Glances.Value)
			{
				return 0f;
			}
			float num = tOn - 1.3f - 5f;
			if (num < 0f)
			{
				return 0f;
			}
			int num2 = Mathf.FloorToInt(num / 9f);
			side = (((num2 & 1) == 0) ? (-1f) : 1f);
			return Window(num - (float)num2 * 9f, 0f, 1.5f);
		}

		public static JorkPose At(float tOn, float phase, float time, bool finishing, float tFinish)
		{
			JorkPose result = default(JorkPose);
			float value = Plugin.Crouch.Value;
			float num = Intensity(tOn);
			float num2 = StrokeAt(phase);
			float num3 = Mathf.Sin(phase * MathF.PI * 2f);
			float num4 = Mathf.Sin(time * MathF.PI * 2f * 0.25f);
			result.Master = S(0f, 0.3f, tOn);
			float headYaw = -42f * Window(tOn, 0.1f, 0.55f) + 42f * Window(tOn, 0.55f, 1f);
			float num5 = S(0.25f, 1.1f, tOn);
			result.RightArm = S(0.6f, 1.15f, tOn);
			result.LeftArm = S(0.45f, 1f, tOn);
			float num6 = S(1f, 1.8f, tOn);
			result.Crouch = value * num5 * (1f + 0.3f * num) + 0.007f * num6 * (0.5f + num) * num3;
			result.Thrust = 0.014f * num6 * num * (num2 - 0.5f);
			result.PelvisPitch = -4f * num6 * num * (num2 - 0.5f);
			result.SpinePitch = num5 * (3f + 2f * num) + 2f * num6 * num3 + 1.2f * (1f + num) * num4;
			result.SpineYaw = num5 * -5f + 2f * num6 * num3;
			result.SpineRoll = 1.5f * num * Mathf.Sin(time * 1.3f);
			result.HeadPitch = num5 * Mathf.Lerp(8f, 0f - Plugin.HeadTilt.Value, S(0.2f, 1f, num)) + 2f * num6 * num3;
			result.HeadYaw = headYaw;
			result.HeadRoll = 5f * num * Mathf.Sin(time * 0.7f);
			result.StrokePos = num2;
			result.StrokeLen = Plugin.Stroke.Value * Mathf.Lerp(1f, 0.8f, Speed(tOn)) * num6;
			result.WristRoll = 2f * num6 * num3;
			result.Squeeze = 7f * num2 * num6;
			result.LeftToHead = (Plugin.HandBehindHead.Value ? S(0.5f, 0.75f, num) : 0f);
			float side;
			float num7 = Glance(tOn, out side);
			if (num7 > 0f)
			{
				result.HeadYaw += 55f * side * num7;
				result.HeadPitch = Mathf.Lerp(result.HeadPitch, 4f, num7);
				result.HeadRoll *= 1f - num7;
				result.SpineYaw += 10f * side * num7;
				result.LeftToHead *= 1f - 0.6f * num7;
			}
			if (!finishing)
			{
				return result;
			}
			float num8 = S(0.5f, 0.65f, tFinish);
			result.StrokePos = Mathf.Lerp(result.StrokePos, 1f, num8);
			result.WristRoll *= 1f - num8;
			result.Squeeze = Mathf.Lerp(result.Squeeze, 14f, num8);
			float num9 = Window(tFinish, 0.5f, 1.7f);
			result.Shudder = num8 * Mathf.Exp((0f - Mathf.Max(0f, tFinish - 0.6f)) * 2.2f);
			result.Crouch += 0.045f * num9;
			result.Thrust = Mathf.Lerp(result.Thrust, 0.03f, num9);
			result.PelvisPitch = Mathf.Lerp(result.PelvisPitch, -9f, num9);
			result.HeadPitch = Mathf.Lerp(result.HeadPitch, 0f - Plugin.HeadTilt.Value - 14f, S(0f, 0.6f, tFinish));
			result.SpinePitch = Mathf.Lerp(result.SpinePitch, -5f, num9);
			result.HeadYaw *= 1f - S(0f, 0.3f, tFinish);
			float num10 = S(1.4f, 2f, tFinish);
			result.SpinePitch = Mathf.Lerp(result.SpinePitch, 16f, num10);
			result.HeadPitch = Mathf.Lerp(result.HeadPitch, 30f, num10);
			result.HeadRoll *= 1f - num10;
			result.Crouch = Mathf.Lerp(result.Crouch, value * 0.6f, num10);
			result.LeftToHead *= 1f - S(1.3f, 1.8f, tFinish);
			result.RightArm *= 1f - S(1.7f, 2.3f, tFinish);
			result.LeftArm *= 1f - S(1.8f, 2.4f, tFinish);
			result.Master *= 1f - S(2.1f, 2.6f, tFinish);
			return result;
		}

		public static float StrokeAt(float phase)
		{
			float num = ((phase < 0.4f) ? (phase / 0.4f) : (1f - (phase - 0.4f) / 0.6f));
			return num * num * (3f - 2f * num);
		}

		public static float S(float a, float b, float x)
		{
			float num = Mathf.Clamp01((x - a) / (b - a));
			return num * num * (3f - 2f * num);
		}

		public static float Window(float x, float a, float b)
		{
			if (x <= a || x >= b)
			{
				return 0f;
			}
			float num = (x - a) / (b - a);
			float num2 = Mathf.Min(1f, 2.2f * Mathf.Sin(num * MathF.PI));
			return num2 * num2 * (3f - 2f * num2);
		}
	}
	internal class JorkBody : MonoBehaviour
	{
		private static readonly Dictionary<Character, JorkBody> s_of = new Dictionary<Character, JorkBody>();

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

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

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

		private Player m_player;

		private ZNetView m_nview;

		private JorkState m_state;

		private float m_tOn;

		private float m_tFinish;

		private float m_phase;

		private float m_abortWeight;

		private bool m_aborting;

		private bool m_feetCaptured;

		private JorkPose m_pose;

		private Vector3 m_footL;

		private Vector3 m_footR;

		private Transform m_plantFrame;

		private Vector3 m_animFootL;

		private Vector3 m_animFootR;

		private Quaternion m_animFootRotL;

		private Quaternion m_animFootRotR;

		private bool m_stepL;

		private bool m_stepR;

		private bool m_stuck;

		private Quaternion m_footRotL;

		private Quaternion m_footRotR;

		private GameObject m_hiddenRight;

		private GameObject m_hiddenLeft;

		private AudioSource[] m_audio;

		private int m_nextAudio;

		private bool m_splurted;

		private VisEquipment m_vis;

		private string m_shaftText;

		private Vector3 m_shaftBase;

		private static readonly FieldRef<Character, Rigidbody> s_groundBody = AccessTools.FieldRefAccess<Character, Rigidbody>("m_lastGroundBody");

		private Vector3 m_fistBias;

		public static float ProbeMin = 9f;

		public static float ProbeMax;

		public static float ProbeMiss;

		public static float ProbeArm;

		public static Vector3 ProbeFist;

		public static Vector3 ProbeErr;

		public static int ProbeN;

		public static bool ViaZdo = false;

		private static readonly HumanBodyBones[] s_bones;

		private readonly Transform[] m_t = (Transform[])(object)new Transform[20];

		private readonly Quaternion[] m_before = (Quaternion[])(object)new Quaternion[20];

		private readonly Quaternion[] m_after = (Quaternion[])(object)new Quaternion[20];

		private Transform[] m_all;

		private Animator m_allFor;

		private Quaternion[] m_base;

		private Quaternion[] m_written;

		private Vector3 m_baseHips;

		private Vector3 m_writtenHips;

		private bool m_wrote;

		private readonly Quaternion[] m_saved = (Quaternion[])(object)new Quaternion[3];

		private readonly Quaternion[] m_saveBuf = (Quaternion[])(object)new Quaternion[3];

		private static readonly HumanBodyBones[] s_right;

		private static readonly HumanBodyBones[] s_left;

		private static float StuckSeconds => Mathf.Max(30f, Plugin.MaxSeconds.Value + 5f);

		public bool Playing => m_pose.Master * (m_aborting ? m_abortWeight : 1f) > 0.001f;

		public static JorkBody Of(Character c)
		{
			if (!((Object)(object)c != (Object)null) || !s_of.TryGetValue(c, out var value))
			{
				return null;
			}
			return value;
		}

		public static void Attach(Player p)
		{
			if ((Object)(object)p != (Object)null && (Object)(object)((Component)p).GetComponent<JorkBody>() == (Object)null)
			{
				((Component)p).gameObject.AddComponent<JorkBody>();
			}
		}

		private void Awake()
		{
			m_player = ((Component)this).GetComponent<Player>();
			m_nview = ((Component)this).GetComponent<ZNetView>();
			m_vis = ((Component)this).GetComponent<VisEquipment>();
			if ((Object)(object)m_player != (Object)null)
			{
				s_of[(Character)(object)m_player] = this;
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)m_player != (Object)null && s_of.TryGetValue((Character)(object)m_player, out var value) && (Object)(object)value == (Object)(object)this)
			{
				s_of.Remove((Character)(object)m_player);
			}
			Hide(right: false, left: false);
			if (m_audio == null)
			{
				return;
			}
			AudioSource[] audio = m_audio;
			foreach (AudioSource val in audio)
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
				}
			}
		}

		private JorkState SourceState()
		{
			if ((Object)(object)m_player == (Object)(object)Player.m_localPlayer && !ViaZdo)
			{
				return Jorking.State;
			}
			if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid())
			{
				return JorkState.Off;
			}
			int num = m_nview.GetZDO().GetInt("jork_state", 0);
			if (num != 1)
			{
				m_stuck = false;
				if (num != 2)
				{
					return JorkState.Off;
				}
				return JorkState.Finish;
			}
			if (m_state == JorkState.On && m_tOn > StuckSeconds)
			{
				m_stuck = true;
			}
			if (!m_stuck)
			{
				return JorkState.On;
			}
			return JorkState.Off;
		}

		private void Update()
		{
			if ((Object)(object)m_player == (Object)null)
			{
				return;
			}
			JorkState jorkState = ((!((Character)m_player).IsDead()) ? SourceState() : JorkState.Off);
			float deltaTime = Time.deltaTime;
			if (jorkState != m_state)
			{
				switch (jorkState)
				{
				case JorkState.On:
					m_tOn = 0f;
					m_phase = 0f;
					m_aborting = false;
					m_feetCaptured = false;
					break;
				case JorkState.Finish:
					m_tFinish = 0f;
					if (m_state != JorkState.On)
					{
						m_tOn = 1.3f + Plugin.BuildUpSeconds.Value;
						m_aborting = false;
						m_feetCaptured = false;
					}
					break;
				default:
					if (Playing)
					{
						m_aborting = true;
						m_abortWeight = 1f;
					}
					break;
				}
				m_state = jorkState;
			}
			if (m_state == JorkState.On)
			{
				m_tOn += deltaTime;
			}
			else if (m_state == JorkState.Finish)
			{
				m_tFinish += deltaTime;
			}
			if (m_aborting)
			{
				m_abortWeight = Mathf.MoveTowards(m_abortWeight, 0f, deltaTime * 4f);
				if (m_abortWeight <= 0f)
				{
					m_aborting = false;
					m_pose = default(JorkPose);
				}
			}
			if (m_state != JorkState.Off || m_aborting)
			{
				float phase = m_phase;
				m_phase = Mathf.Repeat(m_phase + deltaTime * JorkAnim.Rate(m_tOn, m_state == JorkState.Finish, m_tFinish), 1f);
				if (!m_aborting)
				{
					m_pose = JorkAnim.At(m_tOn, m_phase, Time.time, m_state == JorkState.Finish, m_tFinish);
					Sounds(phase, m_phase);
				}
			}
			else
			{
				m_pose = default(JorkPose);
			}
			bool flag = Playing && !m_aborting;
			Hide(flag && m_pose.RightArm > 0.05f, flag && m_pose.LeftArm > 0.05f);
		}

		private void Sounds(float before, float now)
		{
			bool flag = m_state == JorkState.Finish;
			if (!flag)
			{
				m_splurted = false;
			}
			if (m_audio == null)
			{
				m_audio = (AudioSource[])(object)new AudioSource[3]
				{
					Sfx.MakeSource(((Component)this).gameObject),
					Sfx.MakeSource(((Component)this).gameObject),
					Sfx.MakeSource(((Component)this).gameObject)
				};
			}
			if (flag && !m_splurted && m_tFinish >= 0.55f && m_tOn > 1.3f)
			{
				m_splurted = true;
				Sfx.Play(NextAudio(), Sfx.Splurts, 1f, 1f);
			}
			if (m_tOn < 1.1999999f || (flag && m_tFinish > 0.55f) || m_pose.StrokeLen < 0.02f)
			{
				return;
			}
			float num = JorkAnim.Intensity(m_tOn);
			if (Sfx.Strokes.Length != 0)
			{
				float num2 = JorkAnim.Rate(m_tOn, flag, m_tFinish);
				float num3 = Mathf.Clamp(num2 / 5.660377f, 0.85f, 1.25f);
				float cue = Mathf.Repeat(0.4f - 0.065f / num3 * num2, 1f);
				if (Crossed(before, now, cue))
				{
					Sfx.Play(NextAudio(), Sfx.Strokes, 0.8f + 0.2f * num, num3, 0.04f);
				}
			}
			else
			{
				float pitch = (flag ? 1.08f : 1f);
				if (before < 0.4f && now >= 0.4f)
				{
					Sfx.Play(NextAudio(), Sfx.Faps, 0.7f + 0.3f * num, pitch);
				}
				else if (now < before)
				{
					Sfx.Play(NextAudio(), Sfx.Squishes, 0.5f + 0.25f * num, pitch);
				}
			}
		}

		private AudioSource NextAudio()
		{
			return m_audio[m_nextAudio++ % m_audio.Length];
		}

		private static bool Crossed(float before, float now, float cue)
		{
			if (!(now >= before))
			{
				if (!(cue > before))
				{
					return cue <= now;
				}
				return true;
			}
			if (before < cue)
			{
				return cue <= now;
			}
			return false;
		}

		private void Hide(bool right, bool left)
		{
			VisEquipment vis = m_vis;
			Swap(ref m_hiddenRight, right, ((Object)(object)vis != (Object)null) ? s_rightItem.Invoke(vis) : null);
			Swap(ref m_hiddenLeft, left, ((Object)(object)vis != (Object)null) ? s_leftItem.Invoke(vis) : null);
		}

		private static void Swap(ref GameObject hidden, bool hide, GameObject item)
		{
			if (hide)
			{
				if ((Object)(object)item != (Object)null && item.activeSelf)
				{
					if ((Object)(object)hidden != (Object)null && (Object)(object)hidden != (Object)(object)item)
					{
						hidden.SetActive(true);
					}
					item.SetActive(false);
					hidden = item;
				}
			}
			else if ((Object)(object)hidden != (Object)null)
			{
				hidden.SetActive(true);
				hidden = null;
			}
		}

		private void Bones(Animator anim)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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)
			if (!((Object)(object)m_allFor == (Object)(object)anim) || m_all == null)
			{
				List<Transform> list = new List<Transform>();
				HumanBodyBones[] array = s_bones;
				foreach (HumanBodyBones val in array)
				{
					list.Add(anim.GetBoneTransform(val));
				}
				array = s_right;
				foreach (HumanBodyBones val2 in array)
				{
					list.Add(anim.GetBoneTransform(val2));
				}
				array = s_left;
				foreach (HumanBodyBones val3 in array)
				{
					list.Add(anim.GetBoneTransform(val3));
				}
				m_all = list.ToArray();
				m_base = (Quaternion[])(object)new Quaternion[m_all.Length];
				m_written = (Quaternion[])(object)new Quaternion[m_all.Length];
				m_allFor = anim;
				m_wrote = false;
			}
		}

		private void Refresh()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_003f: 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)
			for (int i = 0; i < m_all.Length; i++)
			{
				Transform val = m_all[i];
				if (!((Object)(object)val == (Object)null))
				{
					if (m_wrote && val.localRotation == m_written[i])
					{
						val.localRotation = m_base[i];
					}
					else
					{
						m_base[i] = val.localRotation;
					}
				}
			}
			Transform val2 = m_all[0];
			if ((Object)(object)val2 != (Object)null)
			{
				if (m_wrote && val2.localPosition == m_writtenHips)
				{
					val2.localPosition = m_baseHips;
				}
				else
				{
					m_baseHips = val2.localPosition;
				}
			}
		}

		private void Written()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < m_all.Length; i++)
			{
				if ((Object)(object)m_all[i] != (Object)null)
				{
					m_written[i] = m_all[i].localRotation;
				}
			}
			if ((Object)(object)m_all[0] != (Object)null)
			{
				m_writtenHips = m_all[0].localPosition;
			}
			m_wrote = true;
		}

		public void Pose()
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: 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_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_0c83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c89: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ccf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0942: Unknown result type (might be due to invalid IL or missing references)
			//IL_0947: Unknown result type (might be due to invalid IL or missing references)
			//IL_094c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0957: Unknown result type (might be due to invalid IL or missing references)
			//IL_095e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0968: Unknown result type (might be due to invalid IL or missing references)
			//IL_096d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0974: Unknown result type (might be due to invalid IL or missing references)
			//IL_097e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0983: Unknown result type (might be due to invalid IL or missing references)
			//IL_098a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0994: Unknown result type (might be due to invalid IL or missing references)
			//IL_0999: Unknown result type (might be due to invalid IL or missing references)
			//IL_099e: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fb: 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_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0512: Unknown result type (might be due to invalid IL or missing references)
			//IL_0517: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e2: 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_05ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0610: 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_062f: 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_064c: 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_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c03: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c05: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c4: 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_06d2: 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_06e0: 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_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_071a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0728: Unknown result type (might be due to invalid IL or missing references)
			//IL_073d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0742: Unknown result type (might be due to invalid IL or missing references)
			//IL_0759: Unknown result type (might be due to invalid IL or missing references)
			//IL_075e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a59: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a63: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a79: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a80: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a94: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aeb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b42: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b63: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b69: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b84: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b89: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d7e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d84: 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_07ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e3: 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_0802: Unknown result type (might be due to invalid IL or missing references)
			//IL_0810: Unknown result type (might be due to invalid IL or missing references)
			//IL_0825: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Unknown result type (might be due to invalid IL or missing references)
			//IL_0878: Unknown result type (might be due to invalid IL or missing references)
			//IL_087d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0882: 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_0889: Unknown result type (might be due to invalid IL or missing references)
			//IL_088d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0897: Unknown result type (might be due to invalid IL or missing references)
			//IL_089b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ce: Unknown result type (might be due to invalid IL or missing references)
			float num = m_pose.Master * (m_aborting ? m_abortWeight : 1f);
			if (num <= 0.001f && !m_wrote)
			{
				return;
			}
			Animator val = s_animator.Invoke((Character)(object)m_player);
			if ((Object)(object)val == (Object)null || !val.isHuman)
			{
				return;
			}
			Bones(val);
			Refresh();
			if (num <= 0.001f)
			{
				m_wrote = false;
				return;
			}
			for (int i = 0; i < s_bones.Length; i++)
			{
				m_t[i] = m_all[i];
				m_before[i] = (((Object)(object)m_t[i] != (Object)null) ? m_t[i].rotation : Quaternion.identity);
			}
			Transform val2 = m_t[0];
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)m_player).transform;
			JorkPose p = m_pose;
			Vector3 position = val2.position;
			if ((Object)(object)m_t[16] != (Object)null && (Object)(object)m_t[19] != (Object)null)
			{
				m_animFootL = m_t[16].position;
				m_animFootRotL = m_t[16].rotation;
				m_animFootR = m_t[19].position;
				m_animFootRotR = m_t[19].rotation;
				if (!m_feetCaptured || m_pose.Master < 0.95f)
				{
					CaptureFeet();
				}
			}
			val2.position += -transform.up * (p.Crouch + 0.012f * shake(1f)) + transform.forward * p.Thrust;
			val2.rotation = Quaternion.AngleAxis(p.PelvisPitch, transform.right) * val2.rotation;
			float num2 = p.SpinePitch + 3f * shake(2f);
			float spineYaw = p.SpineYaw;
			float num3 = p.SpineRoll + 2f * shake(3f);
			Turn(m_t[1], transform, num2 * 0.35f, spineYaw * 0.3f, num3 * 0.3f);
			Turn(m_t[2], transform, num2 * (((Object)(object)m_t[3] != (Object)null) ? 0.35f : 0.65f), spineYaw * 0.4f, num3 * 0.4f);
			Turn(m_t[3], transform, num2 * 0.3f, spineYaw * 0.3f, num3 * 0.3f);
			float num4 = p.HeadPitch + 4f * shake(4f);
			float headYaw = p.HeadYaw;
			float num5 = p.HeadRoll + 4f * shake(5f);
			Turn(m_t[4], transform, num4 * 0.3f, headYaw * 0.4f, num5 * 0.3f);
			Turn(m_t[5], transform, num4 * 0.7f, headYaw * 0.6f, num5 * 0.7f);
			Vector3 val5;
			if (p.RightArm > 0.001f && (Object)(object)m_t[7] != (Object)null && (Object)(object)m_t[8] != (Object)null && (Object)(object)m_t[9] != (Object)null)
			{
				Vector3 val3 = Quaternion.AngleAxis(0f - Plugin.ShaftPitch.Value, transform.right) * transform.forward;
				if (m_shaftText != Plugin.ShaftBase.Value)
				{
					m_shaftText = Plugin.ShaftBase.Value;
					m_shaftBase = Plugin.Vec(m_shaftText, new Vector3(0.05f, 0.06f, 0.11f));
				}
				Vector3 val4 = FromHips(transform, val2, m_shaftBase) + val3 * (0.03f + p.StrokePos * p.StrokeLen);
				val5 = Vector3.ProjectOnPlane(transform.up, val3);
				val5 = -((Vector3)(ref val5)).normalized * 0.95f - transform.right * 0.15f;
				Vector3 normalized = ((Vector3)(ref val5)).normalized;
				Vector3 pole = m_t[7].position + transform.right * 0.35f - transform.forward * (0.3f - 0.12f * p.StrokePos) - transform.up * 0.25f;
				Turn(m_t[6], transform, 0f, -6f * (p.StrokePos - 0.5f), 0f);
				ReachAssist(val, val4, p.RightArm);
				Quaternion[] saved = Save(7, 9);
				Vector3 val6 = transform.right * m_fistBias.x + transform.up * m_fistBias.y + transform.forward * m_fistBias.z;
				Vector3 target = val4 + transform.right * 0.05f + val6;
				SolveTwoBone(m_t[7], m_t[8], m_t[9], target, pole);
				Orient(val, m_t[9], m_t[8], (HumanBodyBones)45, (HumanBodyBones)39, normalized, val3);
				m_t[9].rotation = Quaternion.AngleAxis(p.WristRoll, val3) * m_t[9].rotation;
				Restore(7, 9, saved, p.RightArm);
				Curl(val, right: true, (Plugin.FingerCurl.Value + p.Squeeze) * p.RightArm * num);
				if (FistCenter(val, out var c))
				{
					Vector3 val7 = val4 - c;
					Vector3 val8 = default(Vector3);
					((Vector3)(ref val8))..ctor(Vector3.Dot(val7, transform.right), Vector3.Dot(val7, transform.up), Vector3.Dot(val7, transform.forward));
					float num6 = Vector3.Distance(m_t[7].position, m_t[8].position) + Vector3.Distance(m_t[8].position, m_t[9].position);
					bool flag = Vector3.Distance(m_t[7].position, val4) < 0.97f * (num6 + Vector3.Distance(m_t[9].position, c));
					if (p.RightArm > 0.95f && num > 0.95f && flag)
					{
						m_fistBias = Vector3.ClampMagnitude(m_fistBias + val8 * (1f - Mathf.Exp((0f - Time.deltaTime) * 15f)), 0.18f);
					}
					if ((Object)(object)m_player == (Object)(object)Player.m_localPlayer)
					{
						float num7 = Vector3.Distance(m_t[7].position, m_t[8].position) + Vector3.Distance(m_t[8].position, m_t[9].position);
						float num8 = Vector3.Distance(m_t[7].position, val4) / num7;
						ProbeMin = Mathf.Min(ProbeMin, num8);
						ProbeMax = Mathf.Max(ProbeMax, num8);
						ProbeMiss = Mathf.Max(ProbeMiss, ((Vector3)(ref val7)).magnitude);
						ProbeArm = num7;
						Vector3 val9 = c - val2.position;
						ProbeFist += new Vector3(Vector3.Dot(val9, transform.right), Vector3.Dot(val9, transform.up), Vector3.Dot(val9, transform.forward));
						ProbeErr -= val8;
						ProbeN++;
					}
				}
			}
			if (p.LeftArm > 0.001f && (Object)(object)m_t[11] != (Object)null && (Object)(object)m_t[12] != (Object)null && (Object)(object)m_t[13] != (Object)null)
			{
				Vector3 val10 = FromHips(transform, val2, new Vector3(-0.2f, 0.06f, -0.02f));
				Vector3 val11 = m_t[11].position - transform.right * 0.45f - transform.forward * 0.15f - transform.up * 0.2f;
				val5 = transform.forward * 0.55f - transform.up * 0.7f + transform.right * 0.35f;
				Vector3 normalized2 = ((Vector3)(ref val5)).normalized;
				Vector3 target2 = val10;
				Vector3 pole2 = val11;
				Vector3 fingers = normalized2;
				Vector3 thumb = transform.forward;
				if (p.LeftToHead > 0.001f && (Object)(object)m_t[5] != (Object)null)
				{
					Transform obj = m_t[5];
					Quaternion val12 = obj.rotation * Quaternion.Inverse(m_before[5]);
					Vector3 val13 = obj.position + val12 * (-transform.forward * 0.13f + transform.up * 0.06f - transform.right * 0.03f);
					Vector3 val14 = m_t[11].position - transform.right * 0.5f + transform.up * 0.35f + transform.forward * 0.05f;
					float leftToHead = p.LeftToHead;
					Vector3 val15 = transform.up * (Mathf.Sin(leftToHead * MathF.PI) * 0.12f) - transform.right * (Mathf.Sin(leftToHead * MathF.PI) * 0.1f);
					target2 = Vector3.Lerp(val10, val13, leftToHead) + val15;
					pole2 = Vector3.Lerp(val11, val14, leftToHead);
					val5 = transform.right * 0.9f + transform.up * 0.3f;
					fingers = Vector3.Slerp(normalized2, ((Vector3)(ref val5)).normalized, leftToHead);
					thumb = Vector3.Slerp(transform.forward, -transform.up, leftToHead);
				}
				Quaternion[] saved2 = Save(11, 13);
				SolveTwoBone(m_t[11], m_t[12], m_t[13], target2, pole2);
				Orient(val, m_t[13], m_t[12], (HumanBodyBones)30, (HumanBodyBones)24, fingers, thumb);
				Restore(11, 13, saved2, p.LeftArm);
				Curl(val, right: false, Mathf.Lerp(18f, 30f, p.LeftToHead) * p.LeftArm * num);
			}
			Plant(m_t[14], m_t[15], m_t[16], transform, ref m_footL, ref m_footRotL, ref m_stepL, m_animFootL, m_animFootRotL, -1f);
			Plant(m_t[17], m_t[18], m_t[19], transform, ref m_footR, ref m_footRotR, ref m_stepR, m_animFootR, m_animFootRotR, 1f);
			if (num < 0.999f)
			{
				for (int j = 0; j < s_bones.Length; j++)
				{
					m_after[j] = (((Object)(object)m_t[j] != (Object)null) ? m_t[j].rotation : Quaternion.identity);
				}
				Vector3 position2 = val2.position;
				val2.position = Vector3.Lerp(position, position2, num);
				for (int k = 0; k < s_bones.Length; k++)
				{
					if ((Object)(object)m_t[k] != (Object)null)
					{
						m_t[k].rotation = Quaternion.Slerp(m_before[k], m_after[k], num);
					}
				}
			}
			Written();
			float shake(float seed)
			{
				return (Mathf.PerlinNoise(Time.time * 15f, seed) - 0.5f) * 2f * p.Shudder;
			}
		}

		private void CaptureFeet()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			Rigidbody val = s_groundBody.Invoke((Character)(object)m_player);
			m_plantFrame = (((Object)(object)val != (Object)null) ? ((Component)val).transform : null);
			m_footL = ToFrame(m_animFootL);
			m_footRotL = ToFrame(m_animFootRotL);
			m_footR = ToFrame(m_animFootR);
			m_footRotR = ToFrame(m_animFootRotR);
			m_stepL = (m_stepR = false);
			m_feetCaptured = true;
		}

		private Vector3 ToFrame(Vector3 world)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_plantFrame != (Object)null))
			{
				return world;
			}
			return m_plantFrame.InverseTransformPoint(world);
		}

		private Quaternion ToFrame(Quaternion world)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_plantFrame != (Object)null))
			{
				return world;
			}
			return Quaternion.Inverse(m_plantFrame.rotation) * world;
		}

		private Vector3 FromFrame(Vector3 v)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_plantFrame != (Object)null))
			{
				return v;
			}
			return m_plantFrame.TransformPoint(v);
		}

		private Quaternion FromFrame(Quaternion q)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_plantFrame != (Object)null))
			{
				return q;
			}
			return m_plantFrame.rotation * q;
		}

		private void Plant(Transform upper, Transform lower, Transform foot, Transform t, ref Vector3 planted, ref Quaternion plantedRot, ref bool stepping, Vector3 animPos, Quaternion animRot, float side)
		{
			//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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0072: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			if (!m_feetCaptured || (Object)(object)upper == (Object)null || (Object)(object)lower == (Object)null || (Object)(object)foot == (Object)null)
			{
				return;
			}
			Vector3 val = FromFrame(planted);
			Quaternion val2 = FromFrame(plantedRot);
			if (!stepping && (Vector3.Distance(val, animPos) > 0.2f || Quaternion.Angle(val2, animRot) > 30f))
			{
				stepping = true;
			}
			if (stepping)
			{
				float deltaTime = Time.deltaTime;
				val = Vector3.MoveTowards(val, animPos, deltaTime * 1.6f);
				val2 = Quaternion.RotateTowards(val2, animRot, deltaTime * 360f);
				if (Vector3.Distance(val, animPos) < 0.01f && Quaternion.Angle(val2, animRot) < 2f)
				{
					stepping = false;
				}
				planted = ToFrame(val);
				plantedRot = ToFrame(val2);
			}
			Vector3 pole = upper.position + t.forward * 0.6f + t.right * (0.32f * side) - t.up * 0.3f;
			SolveTwoBone(upper, lower, foot, val, pole);
			foot.rotation = val2;
		}

		private Quaternion[] Save(int from, int to)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			for (int i = from; i <= to; i++)
			{
				m_saveBuf[i - from] = m_t[i].rotation;
			}
			return m_saveBuf;
		}

		private void Restore(int from, int to, Quaternion[] saved, float weight)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (!(weight >= 0.999f))
			{
				int num = to - from + 1;
				for (int i = 0; i < num; i++)
				{
					m_saved[i] = m_t[from + i].rotation;
				}
				for (int j = 0; j < num; j++)
				{
					m_t[from + j].rotation = Quaternion.Slerp(saved[j], m_saved[j], weight);
				}
			}
		}

		private static void Turn(Transform bone, Transform t, float pitch, float yaw, float roll)
		{
			//IL_000d: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (!((Object)(object)bone == (Object)null))
			{
				bone.rotation = Quaternion.AngleAxis(yaw, t.up) * Quaternion.AngleAxis(pitch, t.right) * Quaternion.AngleAxis(0f - roll, t.forward) * bone.rotation;
			}
		}

		private void ReachAssist(Animator anim, Vector3 grip, float weight)
		{
			//IL_002d: 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_004c: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: 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_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_019f: 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_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: 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_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: 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_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_02f4: Unknown result type (might be due to invalid IL or missing references)
			Transform val = m_t[7];
			Transform boneTransform = anim.GetBoneTransform((HumanBodyBones)45);
			if ((Object)(object)val == (Object)null || (Object)(object)boneTransform == (Object)null)
			{
				return;
			}
			float num = Vector3.Distance(m_t[7].position, m_t[8].position) + Vector3.Distance(m_t[8].position, m_t[9].position);
			float num2 = 0.96f * (num + Vector3.Distance(m_t[9].position, boneTransform.position) * 0.9f);
			Transform val2 = (((Object)(object)m_t[3] != (Object)null) ? m_t[3] : m_t[2]);
			Quaternion val3 = (((Object)(object)val2 != (Object)null) ? val2.rotation : Quaternion.identity);
			Quaternion val4 = (((Object)(object)m_t[6] != (Object)null) ? m_t[6].rotation : Quaternion.identity);
			float num3 = 0f;
			float num4 = 0f;
			for (int i = 0; i < 8; i++)
			{
				float num5 = Vector3.Distance(val.position, grip) - num2;
				if (num5 <= 0.003f)
				{
					break;
				}
				Transform val5;
				float num6;
				if ((Object)(object)m_t[6] != (Object)null && num3 < 20f)
				{
					val5 = m_t[6];
					num6 = 20f - num3;
				}
				else
				{
					if (!((Object)(object)val2 != (Object)null) || !(num4 < 28f))
					{
						break;
					}
					val5 = val2;
					num6 = 28f - num4;
				}
				Vector3 val6 = val.position - val5.position;
				Vector3 val7 = grip - val5.position;
				Vector3 val8 = Vector3.Cross(val6, val7);
				if (((Vector3)(ref val8)).sqrMagnitude < 1E-08f || ((Vector3)(ref val6)).sqrMagnitude < 1E-06f)
				{
					break;
				}
				float num7 = Mathf.Min(new float[3]
				{
					num6,
					6f,
					57.29578f * num5 / ((Vector3)(ref val6)).magnitude
				});
				if (num7 < 0.05f)
				{
					break;
				}
				val5.rotation = Quaternion.AngleAxis(num7, ((Vector3)(ref val8)).normalized) * val5.rotation;
				if ((Object)(object)val5 == (Object)(object)m_t[6])
				{
					num3 += num7;
				}
				else
				{
					num4 += num7;
				}
			}
			float num8 = Mathf.Clamp01(weight * 1.5f);
			if (!(num8 >= 0.999f) && (!(num3 <= 0f) || !(num4 <= 0f)))
			{
				Quaternion val9 = (((Object)(object)val2 != (Object)null) ? val2.rotation : Quaternion.identity);
				Quaternion val10 = (((Object)(object)m_t[6] != (Object)null) ? m_t[6].rotation : Quaternion.identity);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.rotation = Quaternion.Slerp(val3, val9, num8);
				}
				if ((Object)(object)m_t[6] != (Object)null)
				{
					m_t[6].rotation = Quaternion.Slerp(val4, val10, num8);
				}
			}
		}

		private static bool FistCenter(Animator anim, out Vector3 c)
		{
			//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_001a: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			c = Vector3.zero;
			int num = 0;
			HumanBodyBones[] array = s_right;
			foreach (HumanBodyBones val in array)
			{
				Transform boneTransform = anim.GetBoneTransform(val);
				if (!((Object)(object)boneTransform == (Object)null))
				{
					c += boneTransform.position;
					num++;
				}
			}
			if (num < 6)
			{
				return false;
			}
			c /= (float)num;
			return true;
		}

		private static Vector3 FromHips(Transform t, Transform hips, Vector3 o)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			return hips.position + t.right * o.x + t.up * o.y + t.forward * o.z;
		}

		private static void Orient(Animator anim, Transform hand, Transform lower, HumanBodyBones middle, HumanBodyBones thumbBone, Vector3 fingers, Vector3 thumb)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00bb: 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)
			//IL_00c4: 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)
			Transform boneTransform = anim.GetBoneTransform(middle);
			Vector3 val = (((Object)(object)boneTransform != (Object)null) ? (boneTransform.position - hand.position) : (hand.position - lower.position));
			if (((Vector3)(ref val)).sqrMagnitude < 1E-08f)
			{
				return;
			}
			hand.rotation = Quaternion.FromToRotation(((Vector3)(ref val)).normalized, fingers) * hand.rotation;
			Transform boneTransform2 = anim.GetBoneTransform(thumbBone);
			if (!((Object)(object)boneTransform2 == (Object)null))
			{
				Vector3 val2 = Vector3.ProjectOnPlane(boneTransform2.position - hand.position, fingers);
				Vector3 val3 = Vector3.ProjectOnPlane(thumb, fingers);
				if (((Vector3)(ref val2)).sqrMagnitude > 1E-06f && ((Vector3)(ref val3)).sqrMagnitude > 1E-06f)
				{
					hand.rotation = Quaternion.AngleAxis(Vector3.SignedAngle(val2, val3, fingers), fingers) * hand.rotation;
				}
			}
		}

		private static void Curl(Animator anim, bool right, float degrees)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			Transform boneTransform = anim.GetBoneTransform((HumanBodyBones)(right ? 18 : 17));
			Transform boneTransform2 = anim.GetBoneTransform((HumanBodyBones)(right ? 39 : 24));
			Transform boneTransform3 = anim.GetBoneTransform((HumanBodyBones)(right ? 45 : 30));
			Transform boneTransform4 = anim.GetBoneTransform((HumanBodyBones)(right ? 42 : 27));
			Transform boneTransform5 = anim.GetBoneTransform((HumanBodyBones)(right ? 51 : 36));
			if ((Object)(object)boneTransform == (Object)null || (Object)(object)boneTransform2 == (Object)null || (Object)(object)boneTransform3 == (Object)null || (Object)(object)boneTransform4 == (Object)null || (Object)(object)boneTransform5 == (Object)null)
			{
				return;
			}
			Vector3 val = boneTransform3.position - boneTransform.position;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			val = boneTransform4.position - boneTransform5.position;
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			val = Vector3.Cross(normalized, normalized2);
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			if (Vector3.Dot(val2, boneTransform2.position - boneTransform.position) < 0f)
			{
				val2 = -val2;
			}
			val = Vector3.Cross(normalized, val2);
			Vector3 normalized3 = ((Vector3)(ref val)).normalized;
			HumanBodyBones[] array = (right ? s_right : s_left);
			foreach (HumanBodyBones val3 in array)
			{
				Transform boneTransform6 = anim.GetBoneTransform(val3);
				if ((Object)(object)boneTransform6 != (Object)null)
				{
					boneTransform6.rotation = Quaternion.AngleAxis(degrees, normalized3) * boneTransform6.rotation;
				}
			}
		}

		private static void SolveTwoBone(Transform a, Transform b, Transform c, Vector3 target, Vector3 pole)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_012c: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: 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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector3.Distance(a.position, b.position);
			float num2 = Vector3.Distance(b.position, c.position);
			Vector3 val = target - a.position;
			float num3 = Mathf.Clamp(((Vector3)(ref val)).magnitude, Mathf.Abs(num - num2) + 0.001f, num + num2 - 0.001f);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			float num4 = (num * num - num2 * num2 + num3 * num3) / (2f * num3);
			float num5 = Mathf.Sqrt(Mathf.Max(0f, num * num - num4 * num4));
			Vector3 val2 = Vector3.ProjectOnPlane(pole - a.position, normalized);
			if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f)
			{
				val2 = Vector3.ProjectOnPlane(b.position - a.position, normalized);
			}
			((Vector3)(ref val2)).Normalize();
			Vector3 val3 = a.position + normalized * num4 + val2 * num5;
			a.rotation = Quaternion.FromToRotation(b.position - a.position, val3 - a.position) * a.rotation;
			b.rotation = Quaternion.FromToRotation(c.position - b.position, a.position + normalized * num3 - b.position) * b.rotation;
		}

		static JorkBody()
		{
			HumanBodyBones[] array = new HumanBodyBones[20];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			s_bones = (HumanBodyBones[])(object)array;
			HumanBodyBones[] array2 = new HumanBodyBones[12];
			RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			s_right = (HumanBodyBones[])(object)array2;
			HumanBodyBones[] array3 = new HumanBodyBones[12];
			RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			s_left = (HumanBodyBones[])(object)array3;
		}
	}
	[HarmonyPatch(typeof(CharacterAnimEvent), "CustomLateUpdate")]
	[HarmonyAfter(new string[] { "lekinox.pipicacamod" })]
	internal static class JorkPosePatch
	{
		private static readonly FieldRef<CharacterAnimEvent, Character> s_character = AccessTools.FieldRefAccess<CharacterAnimEvent, Character>("m_character");

		private static void Postfix(CharacterAnimEvent __instance)
		{
			Character val = s_character.Invoke(__instance);
			if (val is Player)
			{
				JorkBody.Of(val)?.Pose();
			}
		}
	}
	[HarmonyPatch(typeof(Player), "Awake")]
	internal static class PlayerAwakePatch
	{
		private static void Postfix(Player __instance)
		{
			if (!Plugin.Headless)
			{
				JorkBody.Attach(__instance);
			}
		}
	}
	public enum JorkState
	{
		Off,
		On,
		Finish
	}
	internal static class Jorking
	{
		public const string ZdoState = "jork_state";

		public const float FinishSeconds = 2.6f;

		public const float HoldSeconds = 1f;

		private const string KeyCooldown = "jork_cd";

		public static JorkState State;

		public static float CooldownLeft;

		public static bool HoldOverride;

		private static float s_finishLeft;

		private static float s_since;

		private static float s_lastHealth;

		private static float s_textAcc;

		private static float s_textAt;

		private static Player s_for;

		private static float s_saveAt;

		private static JorkState s_published;

		private static readonly FieldRef<Character, Rigidbody> s_groundBody = AccessTools.FieldRefAccess<Character, Rigidbody>("m_lastGroundBody");

		public static bool Active => State == JorkState.On;

		public static bool Busy => State != JorkState.Off;

		public static void Bind(Player p)
		{
			if ((Object)(object)p != (Object)(object)s_for)
			{
				Load(p);
			}
		}

		public static void Load(Player p)
		{
			s_for = p;
			string value;
			float result;
			float num = ((p.m_customData.TryGetValue("jork_cd", out value) && float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out result)) ? result : 0f);
			CooldownLeft = (float.IsNaN(num) ? 0f : Mathf.Clamp(num, 0f, Plugin.Cooldown.Value));
			Reset();
			s_published = (JorkState)(-1);
		}

		public static void Reset()
		{
			State = JorkState.Off;
			HoldOverride = false;
			s_since = 0f;
		}

		public static float CooldownToSave()
		{
			if (State != JorkState.On || !(s_since >= 1f))
			{
				return CooldownLeft;
			}
			return Mathf.Max(CooldownLeft, Plugin.Cooldown.Value);
		}

		public static void Save()
		{
			if ((Object)(object)s_for != (Object)null)
			{
				s_for.m_customData["jork_cd"] = CooldownToSave().ToString("0.#", CultureInfo.InvariantCulture);
			}
		}

		public static void Tick(Player p, bool held)
		{
			Bind(p);
			float deltaTime = Time.deltaTime;
			if (State != JorkState.On)
			{
				CooldownLeft = Mathf.Max(0f, CooldownLeft - deltaTime);
			}
			if (State == JorkState.Finish)
			{
				s_finishLeft -= deltaTime;
				if (s_finishLeft <= 0f || !CanKeepGoing(p))
				{
					State = JorkState.Off;
				}
			}
			else if (State == JorkState.On)
			{
				s_since += deltaTime;
				if (!CanKeepGoing(p))
				{
					Abort(p, null);
				}
				else if (Plugin.CancelOnHit.Value && ((Character)p).GetHealth() < Mathf.Min(s_lastHealth, ((Character)p).GetMaxHealth()) - 0.5f)
				{
					Abort(p, "$msg_jork_interrupted");
				}
				else if (!held && !HoldOverride)
				{
					if (s_since < 1f)
					{
						Abort(p, null);
					}
					else
					{
						Finish(p, "$msg_jork_done");
					}
				}
				else if (s_since >= Plugin.MaxSeconds.Value)
				{
					Finish(p, "$msg_jork_done");
				}
				else if (s_since >= 1f)
				{
					Heal(p, deltaTime);
				}
				else
				{
					s_lastHealth = ((Character)p).GetHealth();
				}
			}
			if (Time.time > s_saveAt)
			{
				s_saveAt = Time.time + 2f;
				Save();
			}
			Publish(p);
		}

		private static void Heal(Player p, float dt)
		{
			((Character)p).UseStamina(Plugin.StaminaPerSecond.Value * dt);
			float health = ((Character)p).GetHealth();
			if (health < ((Character)p).GetMaxHealth())
			{
				((Character)p).Heal(Plugin.HealPerSecond.Value * dt, false);
				s_textAcc += ((Character)p).GetHealth() - health;
			}
			if (Plugin.ShowHealText.Value && Time.time > s_textAt)
			{
				s_textAt = Time.time + 1f;
				if (s_textAcc >= 0.5f)
				{
					HealText(p, s_textAcc);
				}
				s_textAcc = 0f;
			}
			s_lastHealth = ((Character)p).GetHealth();
			if (p.GetStamina() <= 0.01f)
			{
				Finish(p, "$msg_jork_tired");
			}
			else if (Plugin.StopAtFullHealth.Value && ((Character)p).GetHealth() >= ((Character)p).GetMaxHealth())
			{
				Finish(p, "$msg_jork_done");
			}
		}

		public static bool CanGo(Player p)
		{
			if ((Object)(object)p != (Object)null && !((Character)p).IsDead() && !((Character)p).IsSwimming() && !((Character)p).IsAttached() && !((Character)p).InBed() && !((Character)p).IsTeleporting() && !((Character)p).InCutscene() && ((Character)p).IsOnGround() && !((Character)p).InEmote())
			{
				return !ArmBusy(p);
			}
			return false;
		}

		private static bool ArmBusy(Player p)
		{
			ZNetView component = ((Component)p).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return false;
			}
			ZDO zDO = component.GetZDO();
			if (!(zDO.GetFloat("caca_pee_hold", 0f) > 0.5f))
			{
				return zDO.GetFloat("caca_pee", 0f) > 0.001f;
			}
			return true;
		}

		private static bool StandingStill(Player p)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Character)p).GetVelocity();
			Rigidbody val2 = s_groundBody.Invoke((Character)(object)p);
			if ((Object)(object)val2 != (Object)null)
			{
				val -= val2.GetPointVelocity(((Component)p).transform.position);
			}
			val.y = 0f;
			if (!p.m_autoRun)
			{
				return ((Vector3)(ref val)).sqrMagnitude < 0.25f;
			}
			return false;
		}

		private static bool CanKeepGoing(Player p)
		{
			if ((Object)(object)p != (Object)null && !((Character)p).IsDead() && !((Character)p).IsSwimming() && !((Character)p).IsAttached() && !((Character)p).InBed() && !((Character)p).IsTeleporting() && !((Character)p).InCutscene())
			{
				return !((Character)p).InEmote();
			}
			return false;
		}

		public static void TryOnCommand(Player p, bool force = false)
		{
			if (State == JorkState.On)
			{
				if (HoldOverride)
				{
					Finish(p, "$msg_jork_done");
				}
			}
			else if (State != JorkState.Finish)
			{
				if (!force && CooldownLeft > 0f)
				{
					((Character)p).Message((MessageType)2, "$msg_jork_cooldown (" + Mathf.CeilToInt(CooldownLeft) + " s)", 0, (Sprite)null, false);
					return;
				}
				if (!force && p.GetStamina() < Plugin.MinStamina.Value)
				{
					((Character)p).Message((MessageType)2, "$msg_jork_tired", 0, (Sprite)null, false);
					return;
				}
				if (!CanGo(p))
				{
					((Character)p).Message((MessageType)2, "$msg_jork_nothere", 0, (Sprite)null, false);
					return;
				}
				if (!StandingStill(p))
				{
					((Character)p).Message((MessageType)2, "$msg_jork_still", 0, (Sprite)null, false);
					return;
				}
				State = JorkState.On;
				s_since = 0f;
				s_lastHealth = ((Character)p).GetHealth();
				s_textAcc = 0f;
				s_textAt = Time.time + 1f;
				Plugin.Log.LogInfo((object)("Jork start (health " + ((Character)p).GetHealth().ToString("0") + ", stamina " + p.GetStamina().ToString("0") + ")"));
			}
		}

		public static void Finish(Player p, string message)
		{
			if (State == JorkState.On)
			{
				End(p, message);
				State = JorkState.Finish;
				HoldOverride = false;
				s_finishLeft = 2.6f;
			}
		}

		public static void Abort(Player p, string message)
		{
			if (State != JorkState.Off)
			{
				if (State == JorkState.On)
				{
					End(p, message);
				}
				State = JorkState.Off;
				HoldOverride = false;
			}
		}

		private static void End(Player p, string message)
		{
			if (s_since >= 1f)
			{
				CooldownLeft = Mathf.Max(0f, Plugin.Cooldown.Value);
			}
			if ((Object)(object)p != (Object)null)
			{
				if (s_textAcc >= 0.5f && Plugin.ShowHealText.Value)
				{
					HealText(p, s_textAcc);
				}
				if (message != null)
				{
					((Character)p).Message((MessageType)2, message, 0, (Sprite)null, false);
				}
			}
			s_textAcc = 0f;
			Save();
			Plugin.Log.LogInfo((object)("Jork end" + ((message != null) ? (" (" + message + ")") : "")));
		}

		private static void HealText(Player p, float amount)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)DamageText.instance != (Object)null)
			{
				DamageText.instance.ShowText((TextType)4, ((Character)p).GetTopPoint(), amount, true);
			}
		}

		public static void Publish(Player p)
		{
			if (State != s_published)
			{
				ZNetView component = ((Component)p).GetComponent<ZNetView>();
				if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner())
				{
					component.GetZDO().Set("jork_state", (int)State);
					s_published = State;
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerProfile), "SavePlayerData")]
	internal static class JorkSavePatch
	{
		private static void Prefix(Player player)
		{
			if ((Object)(object)player != (Object)null && (Object)(object)player == (Object)(object)Player.m_localPlayer)
			{
				Jorking.Save();
			}
		}
	}
	[HarmonyPatch(typeof(Player), "SetControls")]
	internal static class JorkControlsPatch
	{
		private static void Prefix(Player __instance, ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun, ref bool dodge)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (Jorking.Busy && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				if ((((Vector3)(ref movedir)).sqrMagnitude > 0.01f) | attack | secondaryAttack | block | jump | dodge | autoRun)
				{
					Jorking.Abort(__instance, null);
					return;
				}
				movedir = Vector3.zero;
				attackHold = (secondaryAttackHold = (blockHold = (crouch = (run = false))));
			}
		}
	}
	[BepInPlugin("cyntrex.Jork", "Jork", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "cyntrex.Jork";

		public const string ModName = "Jork";

		public const string Version = "1.0.0";

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		internal static ConfigEntry<KeyCode> Key;

		internal static ConfigEntry<float> HealPerSecond;

		internal static ConfigEntry<float> StaminaPerSecond;

		internal static ConfigEntry<float> MinStamina;

		internal static ConfigEntry<float> Cooldown;

		internal static ConfigEntry<float> MaxSeconds;

		internal static ConfigEntry<float> Volume;

		internal static ConfigEntry<bool> StopAtFullHealth;

		internal static ConfigEntry<bool> CancelOnHit;

		internal static ConfigEntry<bool> ShowHealText;

		internal static ConfigEntry<float> RateStart;

		internal static ConfigEntry<float> RateEnd;

		internal static ConfigEntry<float> RampSeconds;

		internal static ConfigEntry<float> BuildUpSeconds;

		internal static ConfigEntry<float> Stroke;

		internal static ConfigEntry<float> FingerCurl;

		internal static ConfigEntry<float> HeadTilt;

		internal static ConfigEntry<float> Crouch;

		internal static ConfigEntry<float> ShaftPitch;

		internal static ConfigEntry<bool> Glances;

		internal static ConfigEntry<bool> HandBehindHead;

		internal static ConfigEntry<string> ShaftBase;

		private Harmony _harmony;

		private DateTime _configStamp;

		private float _nextConfigCheck;

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

		private static string s_dir;

		public static string Dir
		{
			get
			{
				if (s_dir != null)
				{
					return s_dir;
				}
				string location = typeof(Plugin).Assembly.Location;
				if (!string.IsNullOrEmpty(location))
				{
					return s_dir = Path.GetDirectoryName(location);
				}
				string[] array = new string[2]
				{
					Path.Combine(Paths.BepInExRootPath, "scripts"),
					Paths.PluginPath
				};
				foreach (string path in array)
				{
					if (Directory.Exists(path))
					{
						string[] files = Directory.GetFiles(path, "se_jork.png", SearchOption.AllDirectories);
						if (files.Length != 0)
						{
							return s_dir = Path.GetDirectoryName(Path.GetDirectoryName(files[0]));
						}
					}
				}
				return s_dir = Path.Combine(Paths.BepInExRootPath, "scripts");
			}
		}

		public static bool Headless => (int)SystemInfo.graphicsDeviceType == 4;

		private ConfigEntry<float> Ranged(string section, string key, float value, string description, float min, float max)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			return ((BaseUnityPlugin)this).Config.Bind<float>(section, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>()));
		}

		private void Awake()
		{
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Key = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Key", (KeyCode)106, "Hold to jork; let go to finish.");
			HealPerSecond = Ranged("Jork", "HealPerSecond", 5f, "Health regenerated per second while jorking.", 0f, 100f);
			StaminaPerSecond = Ranged("Jork", "StaminaPerSecond", 5f, "Stamina used per second while jorking.", 0f, 100f);
			MinStamina = Ranged("Jork", "MinStamina", 5f, "Stamina needed to start.", 0f, 500f);
			Cooldown = Ranged("Jork", "Cooldown", 30f, "Seconds before you can jork again, counted from when you stop.", 0f, 3600f);
			MaxSeconds = Ranged("Jork", "MaxSeconds", 20f, "Longest you can keep at it: the finish comes on its own after this many seconds.", 1f, 600f);
			StopAtFullHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("Jork", "StopAtFullHealth", false, "Finish on its own once health is full.");
			CancelOnHit = ((BaseUnityPlugin)this).Config.Bind<bool>