Decompiled source of UmamusumeSemibots v1.0.0

UmamusumeSemiBots.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JigglePhysicsPlugin;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UmamusumeSemiBots;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UmamusumeSemiBots")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UmamusumeSemiBots")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4c8636a0-95bd-4967-9e4e-37630d6c4ea6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public class SmolSpectateAnimator : MonoBehaviour
{
	public Animator animator;

	public PlayerDeathHead deathHead;

	private static readonly int ParamIdle = Animator.StringToHash("Idle");

	private static readonly int ParamCharge = Animator.StringToHash("Charging");

	private static readonly int ParamJump = Animator.StringToHash("Jump");

	private static readonly int ParamChargePct = Animator.StringToHash("ChargeAmount");

	private Traverse<bool> _spectatedField;

	private Traverse<bool> _chargingField;

	private Traverse<float> _chargeAmtField;

	private Traverse<float> _chargeMaxField;

	private bool _wasCharging;

	private bool _ragdollActivated;

	private bool _spectateActivated;

	private float _fallbackTimer = -1f;

	private const float FallbackDelay = 0.1f;

	public bool IsRagdolling => _ragdollActivated && !_spectateActivated;

	public void Init()
	{
		Traverse val = Traverse.Create((object)deathHead);
		_spectatedField = val.Field<bool>("spectated");
		_chargingField = val.Field<bool>("spectatedJumpCharging");
		_chargeAmtField = val.Field<float>("spectatedJumpChargeAmount");
		_chargeMaxField = val.Field<float>("spectatedJumpChargeAmountMax");
		((Behaviour)this).enabled = true;
	}

	private void Update()
	{
		if ((Object)(object)deathHead == (Object)null)
		{
			return;
		}
		if (_fallbackTimer > 0f)
		{
			_fallbackTimer -= Time.deltaTime;
			if (_fallbackTimer <= 0f)
			{
				_fallbackTimer = -1f;
				if (!_spectateActivated && !_ragdollActivated)
				{
					EnableRagdollMode();
				}
			}
		}
		if (_spectateActivated && !_ragdollActivated && !((Object)(object)animator == (Object)null))
		{
			bool value = _chargingField.Value;
			float value2 = _chargeAmtField.Value;
			float value3 = _chargeMaxField.Value;
			animator.SetFloat(ParamChargePct, (value3 > 0f) ? (value2 / value3) : 0f);
			if (value)
			{
				animator.SetBool(ParamCharge, true);
				animator.SetBool(ParamIdle, false);
				_wasCharging = true;
			}
			else if (_wasCharging)
			{
				animator.SetBool(ParamCharge, false);
				animator.SetTrigger(ParamJump);
				_wasCharging = false;
			}
			else
			{
				animator.SetBool(ParamIdle, true);
				animator.SetBool(ParamCharge, false);
			}
		}
	}

	public void EnableSpectateMode()
	{
		_spectateActivated = true;
		_ragdollActivated = false;
		_wasCharging = false;
		_fallbackTimer = -1f;
		TearDownRagdoll();
		if ((Object)(object)animator != (Object)null)
		{
			animator.runtimeAnimatorController = CustomModelSwapMod.SmolSpectateController;
			((Behaviour)animator).enabled = true;
		}
	}

	private void TearDownRagdoll()
	{
		CharacterJoint[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<CharacterJoint>(true);
		foreach (CharacterJoint val in componentsInChildren)
		{
			Object.Destroy((Object)(object)val);
		}
		ConfigurableJoint[] componentsInChildren2 = ((Component)this).gameObject.GetComponentsInChildren<ConfigurableJoint>(true);
		foreach (ConfigurableJoint val2 in componentsInChildren2)
		{
			Object.Destroy((Object)(object)val2);
		}
		Rigidbody[] componentsInChildren3 = ((Component)this).gameObject.GetComponentsInChildren<Rigidbody>(true);
		foreach (Rigidbody val3 in componentsInChildren3)
		{
			Object.Destroy((Object)(object)val3);
		}
		CapsuleCollider[] componentsInChildren4 = ((Component)this).gameObject.GetComponentsInChildren<CapsuleCollider>(true);
		foreach (CapsuleCollider val4 in componentsInChildren4)
		{
			Object.Destroy((Object)(object)val4);
		}
	}

	public void EnableRagdollMode()
	{
		if (!_ragdollActivated)
		{
			_ragdollActivated = true;
			_spectateActivated = false;
			if ((Object)(object)animator != (Object)null)
			{
				((Behaviour)animator).enabled = false;
				animator.runtimeAnimatorController = null;
			}
			ActivateRagdoll();
		}
	}

	private void ActivateRagdoll()
	{
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0310: Invalid comparison between Unknown and I4
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a5: 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_04bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_04db: 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_0532: Unknown result type (might be due to invalid IL or missing references)
		//IL_053c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0541: Unknown result type (might be due to invalid IL or missing references)
		//IL_0545: Unknown result type (might be due to invalid IL or missing references)
		//IL_0550: Unknown result type (might be due to invalid IL or missing references)
		//IL_055a: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ef: 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_0403: Unknown result type (might be due to invalid IL or missing references)
		//IL_040d: Unknown result type (might be due to invalid IL or missing references)
		Animator smolAnim = ((Component)this).gameObject.GetComponent<Animator>() ?? ((Component)this).gameObject.GetComponentInChildren<Animator>(true);
		if ((Object)(object)smolAnim != (Object)null)
		{
			((Behaviour)smolAnim).enabled = false;
		}
		if ((Object)(object)smolAnim != (Object)null && smolAnim.isHuman)
		{
			HumanBodyBones[] array = new HumanBodyBones[12];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			HumanBodyBones[] array2 = (HumanBodyBones[])(object)array;
			int layer = LayerMask.NameToLayer("Default");
			HumanBodyBones[] array3 = array2;
			foreach (HumanBodyBones val in array3)
			{
				Transform boneTransform = smolAnim.GetBoneTransform(val);
				if ((Object)(object)boneTransform != (Object)null)
				{
					((Component)boneTransform).gameObject.layer = layer;
				}
			}
			Dictionary<HumanBodyBones, Rigidbody> dictionary = new Dictionary<HumanBodyBones, Rigidbody>();
			HumanBodyBones[] array4 = array2;
			foreach (HumanBodyBones val2 in array4)
			{
				Transform boneTransform2 = smolAnim.GetBoneTransform(val2);
				if (!((Object)(object)boneTransform2 == (Object)null))
				{
					Rigidbody val3 = ((Component)boneTransform2).gameObject.AddComponent<Rigidbody>();
					val3.mass = (((int)val2 == 0) ? 0.05f : 0.01f);
					val3.drag = 2f;
					val3.angularDrag = 3f;
					val3.interpolation = (RigidbodyInterpolation)1;
					val3.collisionDetectionMode = (CollisionDetectionMode)0;
					val3.maxAngularVelocity = 7f;
					CapsuleCollider val4 = ((Component)boneTransform2).gameObject.AddComponent<CapsuleCollider>();
					val4.radius = 0.04f;
					val4.height = 0.1f;
					dictionary[val2] = val3;
				}
			}
			List<CapsuleCollider> list = (from b in dictionary.Keys
				select smolAnim.GetBoneTransform(b) into t
				where (Object)(object)t != (Object)null
				select ((Component)t).GetComponent<CapsuleCollider>() into c
				where (Object)(object)c != (Object)null
				select c).ToList();
			for (int k = 0; k < list.Count; k++)
			{
				for (int l = k + 1; l < list.Count; l++)
				{
					Physics.IgnoreCollision((Collider)(object)list[k], (Collider)(object)list[l]);
				}
			}
			Collider[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<Collider>();
			foreach (CapsuleCollider item in list)
			{
				Collider[] array5 = componentsInChildren;
				foreach (Collider val5 in array5)
				{
					Physics.IgnoreCollision((Collider)(object)item, val5);
				}
			}
			HumanBodyBones[] array6 = array2;
			foreach (HumanBodyBones val6 in array6)
			{
				if ((int)val6 == 0)
				{
					continue;
				}
				Transform boneTransform3 = smolAnim.GetBoneTransform(val6);
				if (!((Object)(object)boneTransform3 == (Object)null) && dictionary.TryGetValue(val6, out var _))
				{
					CharacterJoint val7 = ((Component)boneTransform3).gameObject.AddComponent<CharacterJoint>();
					Rigidbody val8 = null;
					Transform parent = boneTransform3.parent;
					while ((Object)(object)parent != (Object)null && (Object)(object)val8 == (Object)null)
					{
						val8 = ((Component)parent).GetComponent<Rigidbody>();
						parent = parent.parent;
					}
					if ((Object)(object)val8 != (Object)null)
					{
						((Joint)val7).connectedBody = val8;
					}
					SoftJointLimit val9 = default(SoftJointLimit);
					((SoftJointLimit)(ref val9)).limit = 30f;
					SoftJointLimit val10 = val9;
					val9 = default(SoftJointLimit);
					((SoftJointLimit)(ref val9)).limit = -30f;
					SoftJointLimit lowTwistLimit = val9;
					val7.highTwistLimit = val10;
					val7.lowTwistLimit = lowTwistLimit;
					val7.swing1Limit = val10;
					val7.swing2Limit = val10;
					val7.enableProjection = true;
					val7.projectionDistance = 0.01f;
					val7.projectionAngle = 5f;
				}
			}
			if (dictionary.TryGetValue((HumanBodyBones)0, out var value2))
			{
				Rigidbody val11 = ((Component)deathHead).GetComponent<Rigidbody>() ?? ((Component)deathHead).GetComponentInChildren<Rigidbody>();
				if ((Object)(object)val11 != (Object)null)
				{
					ConfigurableJoint val12 = ((Component)value2).gameObject.AddComponent<ConfigurableJoint>();
					((Joint)val12).autoConfigureConnectedAnchor = false;
					((Joint)val12).axis = Vector3.right;
					val12.secondaryAxis = Vector3.up;
					((Joint)val12).anchor = Vector3.zero;
					((Joint)val12).connectedAnchor = new Vector3(0f, 0f, 0f);
					((Joint)val12).connectedBody = val11;
					val12.xMotion = (ConfigurableJointMotion)0;
					val12.yMotion = (ConfigurableJointMotion)0;
					val12.zMotion = (ConfigurableJointMotion)0;
					val12.angularXMotion = (ConfigurableJointMotion)2;
					val12.angularYMotion = (ConfigurableJointMotion)2;
					val12.angularZMotion = (ConfigurableJointMotion)2;
					Vector3 val13 = Vector3.ClampMagnitude(val11.velocity * 0.3f, 3f);
					value2.AddForce(val13, (ForceMode)2);
					value2.AddTorque(Random.insideUnitSphere * 0.5f, (ForceMode)2);
				}
			}
		}
		else
		{
			Rigidbody val14 = ((Component)this).gameObject.AddComponent<Rigidbody>();
			val14.mass = 0.5f;
			val14.drag = 2f;
			val14.angularDrag = 4f;
			Rigidbody val15 = Traverse.Create((object)deathHead).Field("physGrabObject").GetValue<PhysGrabObject>()?.rb;
			if ((Object)(object)val15 != (Object)null)
			{
				Vector3 val16 = Vector3.ClampMagnitude(val15.velocity * 0.3f, 3f);
				val14.AddForce(val16, (ForceMode)2);
			}
		}
	}

	public void Reset()
	{
		_ragdollActivated = false;
		_spectateActivated = false;
		_wasCharging = false;
		_fallbackTimer = -1f;
		if ((Object)(object)animator != (Object)null)
		{
			animator.runtimeAnimatorController = null;
			((Behaviour)animator).enabled = false;
		}
	}

	public void StartFallbackTimer()
	{
		_fallbackTimer = 0.1f;
	}
}
namespace UmamusumeSemiBots;

[Serializable]
public class BlendShapeExpression
{
	public class SmolFaceData
	{
		public Vector2 eyeOffset = Vector2.zero;

		public Vector2 eyebrowOffset = Vector2.zero;

		public Vector2 mouthOffset = Vector2.zero;

		public Vector2 talkingMouthOffset = Vector2.zero;

		public Vector2 blinkOffset = Vector2.zero;
	}

	public string name;

	public Dictionary<string, float> shapes;

	public SmolFaceData smolFace = new SmolFaceData();

	public string talkingBlendShape;

	public float talkingMaxValue;

	public string blinkBlendShapeLeft;

	public string blinkBlendShapeRight;

	public float blinkClosedValue;

	public BlendShapeExpression(string name, Dictionary<string, float> shapes, string talkingBlendShape = "", float talkingMaxValue = 100f, string blinkBlendShapeLeft = "", string blinkBlendShapeRight = "", float blinkClosedValue = 100f)
	{
		this.name = name;
		this.shapes = shapes;
		this.talkingBlendShape = talkingBlendShape;
		this.talkingMaxValue = talkingMaxValue;
		this.blinkBlendShapeLeft = blinkBlendShapeLeft;
		this.blinkBlendShapeRight = blinkBlendShapeRight;
		this.blinkClosedValue = blinkClosedValue;
	}
}
public class ModdedModelExpression : MonoBehaviour
{
	public bool isLocalPlayer;

	public PlayerAvatar avatar;

	public PlayerAvatar avatarForVoice;

	public BlendShapeExpression[] expressions = new BlendShapeExpression[6];

	public string defaultTalkingBlendShape = "";

	public float defaultTalkingMaxValue = 100f;

	public string defaultBlinkBlendShapeLeft = "";

	public string defaultBlinkBlendShapeRight = "";

	public float defaultBlinkClosedValue = 100f;

	private int _activeIndex = -1;

	private SkinnedMeshRenderer _bodyMesh;

	private Dictionary<string, int> _blendShapeMap = new Dictionary<string, int>();

	private Dictionary<int, float> _currentWeights = new Dictionary<int, float>();

	private float[] _targetWeights;

	private int[] _allIndices;

	private HashSet<int> _reservedIndices = new HashSet<int>();

	private int _talkingBsIndex = -1;

	private float _talkingMaxValue = 100f;

	private float _talkingCurrentWeight = 0f;

	private const float TALK_SPEED = 25f;

	private int _blinkBsIndexLeft = -1;

	private int _blinkBsIndexRight = -1;

	private float _blinkClosedValue = 100f;

	private float _blinkCurrentWeight = 0f;

	private float _blinkTimer = 0f;

	private bool _isBlinking = false;

	private const float BLINK_SPEED = 25f;

	private const float EXPR_SPEED = 20f;

	private static FieldInfo _voiceChatFetchedField;

	private static FieldInfo _voiceChatField;

	private static FieldInfo _clipLoudnessField;

	private static FieldInfo _overrideNoTalkField;

	private PlayerVoiceChat _cachedVoiceChat = null;

	private bool _voiceCacheResolved = false;

	private Coroutine _applyCoroutine;

	public int ActiveIndex => _activeIndex;

	public float BlinkCurrentWeight => _blinkCurrentWeight;

	public float DefaultBlinkClosedValue => _blinkClosedValue;

	public void ReserveBlendShapeIndices(params int[] indices)
	{
		foreach (int num in indices)
		{
			if (num >= 0)
			{
				_reservedIndices.Add(num);
			}
		}
	}

	private void OnEnable()
	{
		if (!((Object)(object)_bodyMesh != (Object)null) || _applyCoroutine != null)
		{
			return;
		}
		if (_allIndices != null)
		{
			for (int i = 0; i < _allIndices.Length; i++)
			{
				int num = _allIndices[i];
				_currentWeights[num] = _bodyMesh.GetBlendShapeWeight(num);
			}
		}
		_applyCoroutine = ((MonoBehaviour)this).StartCoroutine(ApplyLoop());
	}

	private void OnDisable()
	{
		if (_applyCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(_applyCoroutine);
			_applyCoroutine = null;
		}
		_blinkTimer = 0f;
		_isBlinking = false;
	}

	private void OnDestroy()
	{
		if (_applyCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(_applyCoroutine);
			_applyCoroutine = null;
		}
		if ((Object)(object)_bodyMesh != (Object)null)
		{
			foreach (KeyValuePair<int, float> currentWeight in _currentWeights)
			{
				if (!_reservedIndices.Contains(currentWeight.Key))
				{
					_bodyMesh.SetBlendShapeWeight(currentWeight.Key, 0f);
				}
			}
			if (_blinkBsIndexLeft >= 0)
			{
				_bodyMesh.SetBlendShapeWeight(_blinkBsIndexLeft, 0f);
			}
			if (_blinkBsIndexRight >= 0)
			{
				_bodyMesh.SetBlendShapeWeight(_blinkBsIndexRight, 0f);
			}
		}
		_blinkTimer = 0f;
		_isBlinking = false;
		_blinkCurrentWeight = 0f;
	}

	public void Initialize(SkinnedMeshRenderer bodyMesh)
	{
		_bodyMesh = bodyMesh;
		if (!((Object)(object)_bodyMesh == (Object)null))
		{
			if (_voiceChatFetchedField == null)
			{
				_voiceChatFetchedField = typeof(PlayerAvatar).GetField("voiceChatFetched", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			}
			if (_voiceChatField == null)
			{
				_voiceChatField = typeof(PlayerAvatar).GetField("voiceChat", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			}
			if (_clipLoudnessField == null)
			{
				_clipLoudnessField = typeof(PlayerVoiceChat).GetField("clipLoudness", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			}
			if (_overrideNoTalkField == null)
			{
				_overrideNoTalkField = typeof(PlayerVoiceChat).GetField("overrideNoTalkAnimationTimer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			}
			Mesh sharedMesh = _bodyMesh.sharedMesh;
			int blendShapeCount = sharedMesh.blendShapeCount;
			_targetWeights = new float[blendShapeCount];
			_allIndices = new int[blendShapeCount];
			for (int i = 0; i < blendShapeCount; i++)
			{
				string blendShapeName = sharedMesh.GetBlendShapeName(i);
				_blendShapeMap[blendShapeName] = i;
				_currentWeights[i] = 0f;
				_allIndices[i] = i;
			}
			ResolveTalkingBlendShape();
			ResolveBlinkBlendShape();
			if (_applyCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(_applyCoroutine);
			}
			_applyCoroutine = ((MonoBehaviour)this).StartCoroutine(ApplyLoop());
		}
	}

	public void ReceiveExpression(int index)
	{
		_activeIndex = ((_activeIndex == index) ? (-1) : index);
		ResolveTalkingBlendShape();
		ResolveBlinkBlendShape();
	}

	private void ResolveTalkingBlendShape()
	{
		int talkingBsIndex = _talkingBsIndex;
		if (_talkingBsIndex >= 0)
		{
			_reservedIndices.Remove(_talkingBsIndex);
		}
		_talkingBsIndex = -1;
		string text = ((_activeIndex >= 0 && _activeIndex < 6 && expressions[_activeIndex] != null && !string.IsNullOrEmpty(expressions[_activeIndex].talkingBlendShape)) ? expressions[_activeIndex].talkingBlendShape : defaultTalkingBlendShape);
		float talkingMaxValue = ((_activeIndex >= 0 && _activeIndex < 6 && expressions[_activeIndex] != null) ? expressions[_activeIndex].talkingMaxValue : defaultTalkingMaxValue);
		if (string.IsNullOrEmpty(text))
		{
			return;
		}
		if (_blendShapeMap.TryGetValue(text, out var value))
		{
			_talkingBsIndex = value;
			_talkingMaxValue = talkingMaxValue;
		}
		else
		{
			foreach (KeyValuePair<string, int> item in _blendShapeMap)
			{
				if (item.Key.Contains(text))
				{
					_talkingBsIndex = item.Value;
					_talkingMaxValue = talkingMaxValue;
					break;
				}
			}
		}
		if (_talkingBsIndex >= 0)
		{
			_reservedIndices.Add(_talkingBsIndex);
		}
		if (_talkingBsIndex != talkingBsIndex)
		{
			if (talkingBsIndex >= 0)
			{
				_bodyMesh.SetBlendShapeWeight(talkingBsIndex, 0f);
			}
			_talkingCurrentWeight = 0f;
		}
	}

	private void ResolveBlinkBlendShape()
	{
		int blinkBsIndexLeft = _blinkBsIndexLeft;
		int blinkBsIndexRight = _blinkBsIndexRight;
		if (_blinkBsIndexLeft >= 0)
		{
			_reservedIndices.Remove(_blinkBsIndexLeft);
		}
		if (_blinkBsIndexRight >= 0)
		{
			_reservedIndices.Remove(_blinkBsIndexRight);
		}
		_blinkBsIndexLeft = (_blinkBsIndexRight = -1);
		bool flag = _activeIndex >= 0 && _activeIndex < 6 && expressions[_activeIndex] != null && !string.IsNullOrEmpty(expressions[_activeIndex].blinkBlendShapeLeft);
		string text = (flag ? expressions[_activeIndex].blinkBlendShapeLeft : defaultBlinkBlendShapeLeft);
		string text2 = (flag ? expressions[_activeIndex].blinkBlendShapeRight : defaultBlinkBlendShapeRight);
		_blinkClosedValue = (flag ? expressions[_activeIndex].blinkClosedValue : defaultBlinkClosedValue);
		if (!string.IsNullOrEmpty(text))
		{
			if (_blendShapeMap.TryGetValue(text, out var value))
			{
				_blinkBsIndexLeft = value;
			}
			else
			{
				foreach (KeyValuePair<string, int> item in _blendShapeMap)
				{
					if (item.Key.Contains(text))
					{
						_blinkBsIndexLeft = item.Value;
						break;
					}
				}
			}
		}
		if (!string.IsNullOrEmpty(text2))
		{
			if (_blendShapeMap.TryGetValue(text2, out var value2))
			{
				_blinkBsIndexRight = value2;
			}
			else
			{
				foreach (KeyValuePair<string, int> item2 in _blendShapeMap)
				{
					if (item2.Key.Contains(text2))
					{
						_blinkBsIndexRight = item2.Value;
						break;
					}
				}
			}
		}
		if (_blinkBsIndexLeft >= 0)
		{
			_reservedIndices.Add(_blinkBsIndexLeft);
		}
		if (_blinkBsIndexRight >= 0)
		{
			_reservedIndices.Add(_blinkBsIndexRight);
		}
		if (_blinkBsIndexLeft != blinkBsIndexLeft || _blinkBsIndexRight != blinkBsIndexRight)
		{
			if (blinkBsIndexLeft >= 0)
			{
				_bodyMesh.SetBlendShapeWeight(blinkBsIndexLeft, 0f);
			}
			if (blinkBsIndexRight >= 0)
			{
				_bodyMesh.SetBlendShapeWeight(blinkBsIndexRight, 0f);
			}
			_blinkCurrentWeight = 0f;
			_isBlinking = false;
			_blinkTimer = Random.Range(1f, 3f);
		}
	}

	public void OnLocalExpressionInput(int expressionSlot)
	{
		int num = expressionSlot - 1;
		if (num >= 0 && num < 6 && expressions[num] != null)
		{
			if (!GameManager.Multiplayer())
			{
				((Component)avatar).GetComponent<ModdedModelPlayerAvatar>().SetExpressionRPC(num);
				return;
			}
			avatar.photonView.RPC("SetExpressionRPC", (RpcTarget)0, new object[1] { num });
		}
	}

	private IEnumerator ApplyLoop()
	{
		WaitForEndOfFrame eof = new WaitForEndOfFrame();
		while (true)
		{
			yield return eof;
			ApplyBlendShapes();
		}
	}

	private void ApplyBlendShapes()
	{
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_bodyMesh == (Object)null || _targetWeights == null)
		{
			return;
		}
		float deltaTime = Time.deltaTime;
		for (int i = 0; i < _targetWeights.Length; i++)
		{
			_targetWeights[i] = 0f;
		}
		if (_activeIndex >= 0 && _activeIndex < 6 && expressions[_activeIndex] != null)
		{
			foreach (KeyValuePair<string, float> shape in expressions[_activeIndex].shapes)
			{
				if (_blendShapeMap.TryGetValue(shape.Key, out var value))
				{
					_targetWeights[value] = shape.Value;
					continue;
				}
				foreach (KeyValuePair<string, int> item in _blendShapeMap)
				{
					if (item.Key.Contains(shape.Key))
					{
						_targetWeights[item.Value] = shape.Value;
					}
				}
			}
		}
		for (int j = 0; j < _allIndices.Length; j++)
		{
			int num = _allIndices[j];
			if (_reservedIndices.Contains(num))
			{
				continue;
			}
			float num2 = _currentWeights[num];
			float num3 = _targetWeights[num];
			if (Mathf.Abs(num2 - num3) < 0.01f)
			{
				if (num2 != num3)
				{
					_currentWeights[num] = num3;
					_bodyMesh.SetBlendShapeWeight(num, num3);
				}
			}
			else
			{
				float num4 = Mathf.Lerp(num2, num3, 20f * deltaTime);
				_currentWeights[num] = num4;
				_bodyMesh.SetBlendShapeWeight(num, num4);
			}
		}
		if (_talkingBsIndex >= 0 && (Object)(object)avatarForVoice != (Object)null)
		{
			if (!_voiceCacheResolved && _voiceChatFetchedField != null && (bool)_voiceChatFetchedField.GetValue(avatarForVoice))
			{
				object obj = this;
				obj = (object)((!(_voiceChatField != null)) ? ((PlayerVoiceChat)null) : ((PlayerVoiceChat)_voiceChatField.GetValue(avatarForVoice)));
				((ModdedModelExpression)obj)._cachedVoiceChat = (PlayerVoiceChat)obj;
				_voiceCacheResolved = (Object)(object)_cachedVoiceChat != (Object)null;
			}
			float num5 = 0f;
			if ((Object)(object)_cachedVoiceChat != (Object)null && _clipLoudnessField != null && _overrideNoTalkField != null)
			{
				float num6 = (float)_clipLoudnessField.GetValue(_cachedVoiceChat);
				float num7 = (float)_overrideNoTalkField.GetValue(_cachedVoiceChat);
				if (num6 > 0.005f && num7 <= 0f)
				{
					num5 = Mathf.Clamp01(num6 * 5f) * _talkingMaxValue;
				}
			}
			_talkingCurrentWeight = Mathf.Lerp(_talkingCurrentWeight, num5, 25f * deltaTime);
			_bodyMesh.SetBlendShapeWeight(_talkingBsIndex, _talkingCurrentWeight);
		}
		if (_blinkBsIndexLeft < 0 && _blinkBsIndexRight < 0)
		{
			return;
		}
		_blinkTimer -= deltaTime;
		if (_blinkTimer <= 0f && !_isBlinking)
		{
			_isBlinking = true;
		}
		if (_isBlinking)
		{
			_blinkCurrentWeight = Mathf.Lerp(_blinkCurrentWeight, _blinkClosedValue, 25f * deltaTime);
			if (_blinkCurrentWeight >= _blinkClosedValue * 0.95f)
			{
				_isBlinking = false;
				_blinkTimer = Random.Range(3f, 6f);
			}
		}
		else
		{
			_blinkCurrentWeight = Mathf.Lerp(_blinkCurrentWeight, 0f, 25f * deltaTime);
		}
		if (_blinkBsIndexLeft >= 0)
		{
			_bodyMesh.SetBlendShapeWeight(_blinkBsIndexLeft, _blinkCurrentWeight);
		}
		if (_blinkBsIndexRight >= 0)
		{
			_bodyMesh.SetBlendShapeWeight(_blinkBsIndexRight, _blinkCurrentWeight);
		}
	}

	public void SetExpression(int index)
	{
		if (_activeIndex != index)
		{
			_activeIndex = index;
			ResolveTalkingBlendShape();
			ResolveBlinkBlendShape();
		}
	}

	public void ForceSetExpression(int index)
	{
		_activeIndex = index;
		ResolveTalkingBlendShape();
		ResolveBlinkBlendShape();
	}
}
public class ModdedModelIK : MonoBehaviour
{
	public PlayerAvatarLeftArm leftArmSource;

	public PlayerAvatarRightArm rightArmSource;

	public PlayerEyes eyesSource;

	public PlayerAvatarVisuals visualsSource;

	public bool isLocalPlayer;

	private Animator _animator;

	private SkinnedMeshRenderer _bodyMesh;

	private Transform _modelHead;

	private Transform _modelNeck;

	private PlayerAvatarVisuals _visuals;

	private FlashlightController _flashlightController;

	private GameObject _flashlightFollowPoint;

	private MapToolController _mapToolController;

	private GameObject _mapToolFollowPoint;

	private Transform _cachedRightHandBone;

	private Transform _cachedWristBone;

	private Transform[] _cachedFingerBones;

	private bool[] _isProximalBone;

	public bool ikDisabled = false;

	private Transform _leftIKTarget;

	private float _leftWeight = 0f;

	private Transform _rightIKTarget;

	private float _rightWeight = 0f;

	private float _rightHintWeight = 0f;

	private Transform _rightElbowHint;

	private Transform _leftElbowHint;

	private Transform _leftIKProxy;

	private Transform _rightIKProxy;

	private Transform _cachedSmolRightHandBone;

	private GameObject _beamOriginOverride;

	private Transform[] _cachedSmolRightFingerBones;

	private Transform[] _cachedSmolLeftFingerBones;

	private bool _smolFingerBonesInitialized = false;

	private const float SMOL_FINGER_CURL_DAMPING = 0.4f;

	public bool skipFlashlightSetup = false;

	public float smolLookAtOffset = -0.4f;

	private Vector3 _rightIKSmoothedPos;

	private Quaternion _rightIKSmoothedRot = Quaternion.identity;

	private const float RIGHT_IK_SMOOTH = 15f;

	private const float WEIGHT_SPEED = 8f;

	private Vector3 _headLookTarget;

	private float _fingerOpenWeight = 0f;

	private const float FINGER_SPEED = 8f;

	private static readonly Quaternion[] FingerBoneRots = (Quaternion[])(object)new Quaternion[15]
	{
		Quaternion.Euler(8f, 22f, -20f),
		Quaternion.Euler(-9f, 0f, 4f),
		Quaternion.Euler(-7f, 92f, 67f),
		Quaternion.Euler(-3f, 4f, -11f),
		Quaternion.Euler(-1f, 10f, 0f),
		Quaternion.Euler(4f, 98f, 72f),
		Quaternion.Euler(-5f, -2f, 0f),
		Quaternion.Euler(-4f, 6f, -3f),
		Quaternion.Euler(11f, 109f, 87f),
		Quaternion.Euler(-4f, -6f, 8f),
		Quaternion.Euler(-15f, 2f, 0f),
		Quaternion.Euler(20f, 118f, 118f),
		Quaternion.Euler(-33f, -4f, -52f),
		Quaternion.Euler(6f, 5f, 24f),
		Quaternion.Euler(-139f, -68f, -48f)
	};

	private static readonly Quaternion WristPalmOffset = Quaternion.Euler(-55f, 180f, 20f);

	private static readonly Quaternion LeftIKProxyOffset = Quaternion.Euler(0f, 0f, 45f);

	private Transform[] _cachedLeftFingerBones;

	private float _leftFingerOpenWeight = 0f;

	private static readonly HumanBodyBones[] LeftFingerBones;

	private static readonly Quaternion[] LeftFingerBoneRots;

	private static readonly Quaternion[] SmolRightFingerBoneRots;

	private static readonly Quaternion[] SmolLeftFingerBoneRots;

	private Transform _cachedSmolRightWristBone;

	private float _eyeXLeft;

	private float _eyeXRight;

	private float _eyeYLeft;

	private float _eyeYRight;

	private const float EYE_SMOOTH = 12f;

	private Coroutine _eyeCoroutine;

	private int _bsEyeXR = -1;

	private int _bsEyeXL = -1;

	private int _bsEyeYR = -1;

	private int _bsEyeYL = -1;

	private static FieldInfo _fcStateField;

	private static FieldInfo _animInCrawlField;

	private static FieldInfo _mapActiveField;

	private static FieldInfo _lookAtActiveField;

	public static Vector3 mapToolPositionOffset;

	public static Vector3 mapToolRotationOffset;

	public static Vector3 mapSmolToolPositionOffset;

	public static Vector3 mapSmolToolRotationOffset;

	private static readonly HumanBodyBones[] SmolRightFingerBones;

	private static readonly HumanBodyBones[] SmolLeftFingerBones;

	private PlayerAvatarVisuals _leftArmVisuals;

	private PlayerAvatarVisuals _rightArmVisuals;

	private static readonly HumanBodyBones[] RightFingerBones;

	private void Awake()
	{
		_animator = ((Component)this).GetComponent<Animator>() ?? ((Component)this).GetComponentInChildren<Animator>(true);
	}

	public void Initialize()
	{
		//IL_0481: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Expected O, but got Unknown
		//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b1: Expected O, but got Unknown
		//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04db: Expected O, but got Unknown
		//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0506: Expected O, but got Unknown
		//IL_0458: Unknown result type (might be due to invalid IL or missing references)
		//IL_0463: Unknown result type (might be due to invalid IL or missing references)
		//IL_046d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0472: Unknown result type (might be due to invalid IL or missing references)
		//IL_0477: Unknown result type (might be due to invalid IL or missing references)
		//IL_0669: Unknown result type (might be due to invalid IL or missing references)
		//IL_0673: Expected O, but got Unknown
		//IL_069d: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b0: Expected O, but got Unknown
		//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fe: 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_0617: Unknown result type (might be due to invalid IL or missing references)
		//IL_061e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_animator == (Object)null || !_animator.isHuman)
		{
			return;
		}
		_modelHead = _animator.GetBoneTransform((HumanBodyBones)10);
		_cachedRightHandBone = _animator.GetBoneTransform((HumanBodyBones)18);
		_cachedWristBone = _cachedRightHandBone;
		_modelNeck = _animator.GetBoneTransform((HumanBodyBones)9);
		_cachedFingerBones = (Transform[])(object)new Transform[RightFingerBones.Length];
		_isProximalBone = new bool[RightFingerBones.Length];
		for (int i = 0; i < RightFingerBones.Length; i++)
		{
			_cachedFingerBones[i] = _animator.GetBoneTransform(RightFingerBones[i]);
			_isProximalBone[i] = (int)RightFingerBones[i] == 42 || (int)RightFingerBones[i] == 45 || (int)RightFingerBones[i] == 48 || (int)RightFingerBones[i] == 51 || (int)RightFingerBones[i] == 39;
		}
		_visuals = visualsSource;
		if (_fcStateField == null)
		{
			_fcStateField = typeof(FlashlightController).GetField("currentState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		if (_animInCrawlField == null)
		{
			_animInCrawlField = typeof(PlayerAvatarVisuals).GetField("animInCrawl", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		if (_mapActiveField == null && (Object)(object)rightArmSource?.mapToolController != (Object)null)
		{
			_mapActiveField = ((object)rightArmSource.mapToolController).GetType().GetField("Active", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		if (_lookAtActiveField == null)
		{
			_lookAtActiveField = typeof(PlayerEyes).GetField("lookAtActive", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		_leftArmVisuals = leftArmSource?.playerAvatar?.playerAvatarVisuals;
		_rightArmVisuals = rightArmSource?.playerAvatar?.playerAvatarVisuals;
		_cachedLeftFingerBones = (Transform[])(object)new Transform[LeftFingerBones.Length];
		for (int j = 0; j < LeftFingerBones.Length; j++)
		{
			_cachedLeftFingerBones[j] = _animator.GetBoneTransform(LeftFingerBones[j]);
		}
		_bodyMesh = null;
		Transform val = null;
		val = ((Component)this).transform.Find("Body");
		if ((Object)(object)val == (Object)null)
		{
			SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val2 in componentsInChildren)
			{
				if (!IsUnderSmol(((Component)val2).transform) && ((Object)val2).name == "Body")
				{
					val = ((Component)val2).transform;
					break;
				}
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			SkinnedMeshRenderer[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val3 in componentsInChildren2)
			{
				if (!IsUnderSmol(((Component)val3).transform))
				{
					val = ((Component)val3).transform;
					break;
				}
			}
		}
		if ((Object)(object)val != (Object)null)
		{
			_bodyMesh = ((Component)val).GetComponent<SkinnedMeshRenderer>();
			if ((Object)(object)_bodyMesh != (Object)null)
			{
				Mesh sharedMesh = _bodyMesh.sharedMesh;
				for (int m = 0; m < sharedMesh.blendShapeCount; m++)
				{
					string blendShapeName = sharedMesh.GetBlendShapeName(m);
					if (blendShapeName.Contains("Eye_20_R"))
					{
						_bsEyeXR = m;
					}
					else if (blendShapeName.Contains("Eye_20_L"))
					{
						_bsEyeXL = m;
					}
					else if (blendShapeName.Contains("Eye_21_L"))
					{
						_bsEyeYL = m;
					}
					else if (blendShapeName.Contains("Eye_21_R"))
					{
						_bsEyeYR = m;
					}
				}
			}
		}
		if ((Object)(object)_modelHead != (Object)null)
		{
			_headLookTarget = _modelHead.position + ((Component)this).transform.forward * 2f;
		}
		GameObject val4 = new GameObject("IK_RightElbowHint");
		val4.transform.SetParent(((Component)this).transform, false);
		_rightElbowHint = val4.transform;
		GameObject val5 = new GameObject("IK_LeftElbowHint");
		val5.transform.SetParent(((Component)this).transform, false);
		_leftElbowHint = val5.transform;
		GameObject val6 = new GameObject("LeftHandIKProxy");
		val6.transform.SetParent(((Component)this).transform, false);
		_leftIKProxy = val6.transform;
		GameObject val7 = new GameObject("RightHandIKProxy");
		val7.transform.SetParent(((Component)this).transform, false);
		_rightIKProxy = val7.transform;
		if (_eyeCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(_eyeCoroutine);
		}
		_eyeCoroutine = ((MonoBehaviour)this).StartCoroutine(EyeUpdateLoop());
		if (!isLocalPlayer && !skipFlashlightSetup)
		{
			_flashlightController = ((Component)((Component)this).transform.root).GetComponentInChildren<FlashlightController>(true);
			if ((Object)(object)_flashlightController != (Object)null)
			{
				_flashlightFollowPoint = new GameObject("FlashlightFollowPoint");
				_flashlightFollowPoint.transform.SetParent(_animator.GetBoneTransform((HumanBodyBones)10), false);
				string modelDisplayName = GetModelDisplayName(ModdedModelPlayerAvatar.LocalModelID);
				Vector2 value;
				Vector2 val8 = (Vector2)(UmaModelCrouchData.FlashlightOffsets.TryGetValue(modelDisplayName, out value) ? value : new Vector2(-0.13f, 0.365f));
				_flashlightFollowPoint.transform.localPosition = new Vector3(-0.12f, val8.x, val8.y);
				_flashlightController.FollowTransformClient = _flashlightFollowPoint.transform;
			}
		}
		MapToolController componentInChildren = ((Component)((Component)this).transform.root).GetComponentInChildren<MapToolController>(true);
		if ((Object)(object)componentInChildren != (Object)null)
		{
			_mapToolFollowPoint = new GameObject("MapToolFollowPoint");
			_mapToolFollowPoint.transform.SetParent(_animator.GetBoneTransform((HumanBodyBones)10), false);
			_mapToolFollowPoint.transform.localPosition = mapToolPositionOffset;
			_mapToolFollowPoint.transform.localEulerAngles = mapToolRotationOffset;
			componentInChildren.FollowTransformClient = _mapToolFollowPoint.transform;
		}
	}

	private static string GetModelDisplayName(int modelID)
	{
		if (modelID < 0 || modelID >= CustomModelSwapMod.ModelPrefabs.Count)
		{
			return "";
		}
		GameObject obj = CustomModelSwapMod.ModelPrefabs[modelID];
		return ((obj != null) ? ((Object)obj).name : null) ?? "";
	}

	private bool IsUnderSmol(Transform t)
	{
		Transform parent = t.parent;
		while ((Object)(object)parent != (Object)null && (Object)(object)parent != (Object)(object)((Component)this).transform)
		{
			if (((Object)parent).name == "Smol")
			{
				return true;
			}
			parent = parent.parent;
		}
		return false;
	}

	private void OnEnable()
	{
		if ((Object)(object)_bodyMesh != (Object)null && _eyeCoroutine == null)
		{
			_eyeCoroutine = ((MonoBehaviour)this).StartCoroutine(EyeUpdateLoop());
		}
	}

	private void OnDisable()
	{
		if (_eyeCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(_eyeCoroutine);
			_eyeCoroutine = null;
		}
		if ((Object)(object)_beamOriginOverride != (Object)null)
		{
			Object.Destroy((Object)(object)_beamOriginOverride);
			_beamOriginOverride = null;
		}
		_cachedSmolRightHandBone = null;
		_smolFingerBonesInitialized = false;
		_cachedSmolRightWristBone = null;
		_cachedSmolRightFingerBones = null;
		_cachedSmolLeftFingerBones = null;
		if ((Object)(object)_bodyMesh != (Object)null)
		{
			if (_bsEyeXR >= 0)
			{
				_bodyMesh.SetBlendShapeWeight(_bsEyeXR, 0f);
			}
			if (_bsEyeXL >= 0)
			{
				_bodyMesh.SetBlendShapeWeight(_bsEyeXL, 0f);
			}
			if (_bsEyeYL >= 0)
			{
				_bodyMesh.SetBlendShapeWeight(_bsEyeYL, 0f);
			}
			if (_bsEyeYR >= 0)
			{
				_bodyMesh.SetBlendShapeWeight(_bsEyeYR, 0f);
			}
		}
	}

	private void Update()
	{
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		bool animInCrawl = (Object)(object)_rightArmVisuals != (Object)null && _animInCrawlField != null && (bool)_animInCrawlField.GetValue(_rightArmVisuals);
		bool flag = ModdedModelPlayerAvatar._isTumblingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isTumblingField.GetValue(visualsSource.playerAvatar);
		bool flag2 = ModdedModelPlayerAvatar._isCrawlingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isCrawlingField.GetValue(visualsSource.playerAvatar);
		bool isSmol = flag || flag2;
		UpdateSmolBeamOrigin(isSmol);
		UpdateLeftArm(animInCrawl);
		UpdateRightArm(animInCrawl);
		UpdateMapToolFollowPoint();
		UpdateGrabberAimTarget();
		bool flag3 = (Object)(object)_rightIKTarget != (Object)null && _rightHintWeight > 0f;
		_fingerOpenWeight = Mathf.MoveTowards(_fingerOpenWeight, flag3 ? 1f : 0f, 8f * Time.deltaTime);
		if ((Object)(object)_visuals != (Object)null && (Object)(object)_visuals.headUpTransform != (Object)null && (Object)(object)_modelHead != (Object)null)
		{
			_headLookTarget = Vector3.Lerp(_headLookTarget, _modelHead.position + _visuals.headUpTransform.forward * 2f, 15f * Time.deltaTime);
		}
		bool flag4 = (Object)(object)_leftIKTarget != (Object)null && _leftWeight > 0.01f;
		_leftFingerOpenWeight = Mathf.MoveTowards(_leftFingerOpenWeight, flag4 ? 1f : 0f, 8f * Time.deltaTime);
	}

	private void UpdateMapToolFollowPoint()
	{
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_mapToolFollowPoint == (Object)null)
		{
			return;
		}
		bool flag = ModdedModelPlayerAvatar._isTumblingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isTumblingField.GetValue(visualsSource.playerAvatar);
		bool flag2 = ModdedModelPlayerAvatar._isCrawlingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isCrawlingField.GetValue(visualsSource.playerAvatar);
		if (flag || flag2)
		{
			Transform val = ((Component)_animator).transform.Find("Smol");
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			Animator val2 = ((Component)val).GetComponent<Animator>() ?? ((Component)val).GetComponentInChildren<Animator>(true);
			if ((Object)(object)val2 != (Object)null && val2.isHuman)
			{
				Transform boneTransform = val2.GetBoneTransform((HumanBodyBones)10);
				if ((Object)(object)boneTransform != (Object)null && (Object)(object)_mapToolFollowPoint.transform.parent != (Object)(object)boneTransform)
				{
					_mapToolFollowPoint.transform.SetParent(boneTransform, false);
					_mapToolFollowPoint.transform.localPosition = mapSmolToolPositionOffset;
					_mapToolFollowPoint.transform.localEulerAngles = mapSmolToolRotationOffset;
				}
			}
		}
		else
		{
			Animator animator = _animator;
			Transform val3 = ((animator != null) ? animator.GetBoneTransform((HumanBodyBones)10) : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)_mapToolFollowPoint.transform.parent != (Object)(object)val3)
			{
				_mapToolFollowPoint.transform.SetParent(val3, false);
				_mapToolFollowPoint.transform.localPosition = mapToolPositionOffset;
				_mapToolFollowPoint.transform.localEulerAngles = mapToolRotationOffset;
			}
		}
	}

	private IEnumerator EyeUpdateLoop()
	{
		WaitForEndOfFrame endOfFrame = new WaitForEndOfFrame();
		while (true)
		{
			yield return endOfFrame;
			UpdateEyes();
		}
	}

	private void UpdateGrabberAimTarget()
	{
		if ((Object)(object)rightArmSource == (Object)null)
		{
			return;
		}
		bool flag = ModdedModelPlayerAvatar._isTumblingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isTumblingField.GetValue(visualsSource.playerAvatar);
		bool flag2 = ModdedModelPlayerAvatar._isCrawlingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isCrawlingField.GetValue(visualsSource.playerAvatar);
		if (flag || flag2)
		{
			Animator animator = _animator;
			Transform val = ((animator != null) ? ((Component)animator).transform.Find("Smol") : null);
			Animator val2 = ((val != null) ? ((Component)val).GetComponent<Animator>() : null) ?? ((val != null) ? ((Component)val).GetComponentInChildren<Animator>(true) : null);
			if ((Object)(object)val2 != (Object)null && val2.isHuman)
			{
				Transform boneTransform = val2.GetBoneTransform((HumanBodyBones)18);
				if ((Object)(object)boneTransform != (Object)null)
				{
					rightArmSource.grabberAimTarget = boneTransform;
				}
			}
		}
		else
		{
			Animator animator2 = _animator;
			Transform val3 = ((animator2 != null) ? animator2.GetBoneTransform((HumanBodyBones)18) : null);
			if ((Object)(object)val3 != (Object)null)
			{
				rightArmSource.grabberAimTarget = val3;
			}
		}
	}

	private void UpdateSmolBeamOrigin(bool isSmol)
	{
		//IL_0160: 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_013d: Expected O, but got Unknown
		if (isLocalPlayer)
		{
			return;
		}
		PhysGrabBeam val = rightArmSource?.physGrabBeam;
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		PhysGrabBeam component = ((Component)val).GetComponent<PhysGrabBeam>();
		if ((Object)(object)component == (Object)null)
		{
			return;
		}
		if ((Object)(object)component.PhysGrabPointOrigin != (Object)null && !((Component)component.PhysGrabPointOrigin).gameObject.activeInHierarchy)
		{
			component.PhysGrabPointOrigin = null;
		}
		if (isSmol)
		{
			if ((Object)(object)_cachedSmolRightHandBone == (Object)null)
			{
				Animator animator = _animator;
				Transform val2 = ((animator != null) ? ((Component)animator).transform.Find("Smol") : null);
				Animator val3 = ((val2 != null) ? ((Component)val2).GetComponent<Animator>() : null) ?? ((val2 != null) ? ((Component)val2).GetComponentInChildren<Animator>(true) : null);
				if ((Object)(object)val3 != (Object)null && val3.isHuman)
				{
					_cachedSmolRightHandBone = val3.GetBoneTransform((HumanBodyBones)18);
				}
			}
			if ((Object)(object)_cachedSmolRightHandBone != (Object)null)
			{
				if ((Object)(object)_beamOriginOverride == (Object)null)
				{
					_beamOriginOverride = new GameObject("SmolBeamOrigin");
				}
				_beamOriginOverride.transform.SetParent(_cachedSmolRightHandBone, false);
				_beamOriginOverride.transform.localPosition = Vector3.zero;
				component.PhysGrabPointOrigin = _beamOriginOverride.transform;
			}
		}
		else
		{
			Animator animator2 = _animator;
			Transform val4 = ((animator2 != null) ? animator2.GetBoneTransform((HumanBodyBones)18) : null);
			if ((Object)(object)val4 != (Object)null)
			{
				component.PhysGrabPointOrigin = val4;
			}
			if ((Object)(object)_beamOriginOverride != (Object)null)
			{
				Object.Destroy((Object)(object)_beamOriginOverride);
				_beamOriginOverride = null;
			}
			_cachedSmolRightHandBone = null;
		}
	}

	private void LateUpdate()
	{
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: 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_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_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: 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_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_032f: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: 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_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b8: 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_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_animator == (Object)null || !_animator.isHuman)
		{
			return;
		}
		bool flag = ModdedModelPlayerAvatar._isTumblingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isTumblingField.GetValue(visualsSource.playerAvatar);
		bool flag2 = ModdedModelPlayerAvatar._isCrawlingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isCrawlingField.GetValue(visualsSource.playerAvatar);
		if (flag || flag2)
		{
			EnsureSmolFingerBonesCached();
			if (_fingerOpenWeight > 0f && (Object)(object)_cachedSmolRightWristBone != (Object)null)
			{
				Quaternion val = Quaternion.LookRotation(((Component)this).transform.forward, ((Component)this).transform.up) * WristPalmOffset;
				_cachedSmolRightWristBone.rotation = Quaternion.Slerp(_cachedSmolRightWristBone.rotation, val, _fingerOpenWeight);
			}
			if (_fingerOpenWeight > 0f && _cachedSmolRightFingerBones != null)
			{
				for (int i = 0; i < _cachedSmolRightFingerBones.Length; i++)
				{
					if (!((Object)(object)_cachedSmolRightFingerBones[i] == (Object)null))
					{
						_cachedSmolRightFingerBones[i].localRotation = Quaternion.Slerp(_cachedSmolRightFingerBones[i].localRotation, SmolRightFingerBoneRots[i], _fingerOpenWeight);
					}
				}
			}
			if (!(_leftFingerOpenWeight > 0f) || _cachedSmolLeftFingerBones == null)
			{
				return;
			}
			for (int j = 0; j < _cachedSmolLeftFingerBones.Length; j++)
			{
				if (!((Object)(object)_cachedSmolLeftFingerBones[j] == (Object)null))
				{
					_cachedSmolLeftFingerBones[j].localRotation = Quaternion.Slerp(_cachedSmolLeftFingerBones[j].localRotation, SmolLeftFingerBoneRots[j], _leftFingerOpenWeight);
				}
			}
			return;
		}
		_smolFingerBonesInitialized = false;
		if (_fingerOpenWeight > 0f && (Object)(object)_rightIKTarget != (Object)null && (Object)(object)_cachedWristBone != (Object)null)
		{
			Quaternion val2 = Quaternion.LookRotation(((Component)this).transform.forward, ((Component)this).transform.up) * WristPalmOffset;
			_cachedWristBone.rotation = Quaternion.Slerp(_cachedWristBone.rotation, val2, _fingerOpenWeight);
		}
		if (_fingerOpenWeight <= 0f)
		{
			return;
		}
		for (int k = 0; k < _cachedFingerBones.Length; k++)
		{
			if (!((Object)(object)_cachedFingerBones[k] == (Object)null))
			{
				_cachedFingerBones[k].localRotation = Quaternion.Slerp(_cachedFingerBones[k].localRotation, FingerBoneRots[k], _fingerOpenWeight);
			}
		}
		if (!(_leftFingerOpenWeight > 0f))
		{
			return;
		}
		for (int l = 0; l < _cachedLeftFingerBones.Length; l++)
		{
			if (!((Object)(object)_cachedLeftFingerBones[l] == (Object)null))
			{
				_cachedLeftFingerBones[l].localRotation = Quaternion.Slerp(_cachedLeftFingerBones[l].localRotation, LeftFingerBoneRots[l], _leftFingerOpenWeight);
			}
		}
	}

	private void UpdateLeftArm(bool animInCrawl)
	{
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: 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_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: 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_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)leftArmSource == (Object)null || (Object)(object)leftArmSource.flashlightController == (Object)null)
		{
			_leftIKTarget = null;
			return;
		}
		FlashlightController flashlightController = leftArmSource.flashlightController;
		int num = ((_fcStateField != null) ? ((int)_fcStateField.GetValue(flashlightController)) : 0);
		bool flag = num > 0 && num < 5 && !animInCrawl;
		_leftIKTarget = ((!flag) ? null : (isLocalPlayer ? flashlightController.FollowTransformLocal : flashlightController.FollowTransformClient));
		if ((Object)(object)_leftIKTarget != (Object)null && (Object)(object)_leftIKProxy != (Object)null)
		{
			_leftIKProxy.position = _leftIKTarget.position + _leftIKTarget.right * -0.05f;
			_leftIKProxy.rotation = _leftIKTarget.rotation * LeftIKProxyOffset;
			_leftIKTarget = _leftIKProxy;
		}
		if ((Object)(object)_leftElbowHint != (Object)null && (Object)(object)_leftIKTarget != (Object)null)
		{
			Vector3 val = (((Component)this).transform.position + _leftIKTarget.position) * 0.5f;
			_leftElbowHint.position = val + ((Component)this).transform.right * -0.5f + ((Component)this).transform.forward * -0.2f;
		}
	}

	private void UpdateRightArm(bool animInCrawl)
	{
		//IL_0722: Unknown result type (might be due to invalid IL or missing references)
		//IL_0727: Unknown result type (might be due to invalid IL or missing references)
		//IL_072f: Unknown result type (might be due to invalid IL or missing references)
		//IL_073a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0744: Unknown result type (might be due to invalid IL or missing references)
		//IL_0749: Unknown result type (might be due to invalid IL or missing references)
		//IL_0754: 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_0763: Unknown result type (might be due to invalid IL or missing references)
		//IL_0768: Unknown result type (might be due to invalid IL or missing references)
		//IL_076a: Unknown result type (might be due to invalid IL or missing references)
		//IL_076c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0770: Unknown result type (might be due to invalid IL or missing references)
		//IL_0775: Unknown result type (might be due to invalid IL or missing references)
		//IL_077d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0791: Unknown result type (might be due to invalid IL or missing references)
		//IL_07cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_07dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0805: Unknown result type (might be due to invalid IL or missing references)
		//IL_080a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0815: Unknown result type (might be due to invalid IL or missing references)
		//IL_081f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0824: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		//IL_0387: Unknown result type (might be due to invalid IL or missing references)
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_040c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_041c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0426: Unknown result type (might be due to invalid IL or missing references)
		//IL_042b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Unknown result type (might be due to invalid IL or missing references)
		//IL_043b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0445: Unknown result type (might be due to invalid IL or missing references)
		//IL_044a: 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_045f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0464: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0600: Unknown result type (might be due to invalid IL or missing references)
		//IL_0608: Unknown result type (might be due to invalid IL or missing references)
		//IL_0612: Unknown result type (might be due to invalid IL or missing references)
		//IL_061d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0627: Unknown result type (might be due to invalid IL or missing references)
		//IL_062c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0631: Unknown result type (might be due to invalid IL or missing references)
		//IL_0636: Unknown result type (might be due to invalid IL or missing references)
		//IL_063e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0652: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0690: Unknown result type (might be due to invalid IL or missing references)
		//IL_069b: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_06af: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0702: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_034c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Unknown result type (might be due to invalid IL or missing references)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		//IL_0366: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: 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_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)rightArmSource == (Object)null)
		{
			_rightIKTarget = null;
			return;
		}
		PhysGrabBeam physGrabBeam = rightArmSource.physGrabBeam;
		MapToolController mapToolController = rightArmSource.mapToolController;
		if ((Object)(object)mapToolController != (Object)null && _mapActiveField != null && (bool)_mapActiveField.GetValue(mapToolController))
		{
			bool flag = ModdedModelPlayerAvatar._isTumblingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isTumblingField.GetValue(visualsSource.playerAvatar);
			bool flag2 = ModdedModelPlayerAvatar._isCrawlingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isCrawlingField.GetValue(visualsSource.playerAvatar);
			bool flag3 = flag || flag2;
			Transform val = (isLocalPlayer ? mapToolController.FollowTransform : mapToolController.FollowTransformClient);
			if ((Object)(object)val != (Object)null && (Object)(object)_rightIKProxy != (Object)null)
			{
				if (flag3)
				{
					Animator animator = _animator;
					Transform val2 = ((animator != null) ? ((Component)animator).transform.Find("Smol") : null);
					Animator val3 = ((val2 != null) ? ((Component)val2).GetComponent<Animator>() : null) ?? ((val2 != null) ? ((Component)val2).GetComponentInChildren<Animator>(true) : null);
					Transform val4 = ((val3 != null && val3.isHuman) ? val3.GetBoneTransform((HumanBodyBones)18) : null);
					if ((Object)(object)val4 != (Object)null)
					{
						Transform boneTransform = val3.GetBoneTransform((HumanBodyBones)14);
						Vector3 val5 = val.position;
						if ((Object)(object)boneTransform != (Object)null)
						{
							float num = 0.3f;
							Vector3 val6 = val5 - boneTransform.position;
							if (((Vector3)(ref val6)).magnitude > num)
							{
								val5 = boneTransform.position + ((Vector3)(ref val6)).normalized * num;
							}
						}
						val5 += ((Component)this).transform.right * 0.12f + ((Component)this).transform.forward * 0.08f;
						_rightIKProxy.position = val5;
						_rightIKProxy.rotation = val.rotation;
					}
					else
					{
						_rightIKProxy.position = val.position + (((Component)this).transform.position - val.position) * 0.4f;
						_rightIKProxy.rotation = val.rotation;
					}
					_rightIKTarget = _rightIKProxy;
					_rightHintWeight = 1f;
					if ((Object)(object)_rightElbowHint != (Object)null)
					{
						Vector3 val7 = (((Component)this).transform.position + _rightIKProxy.position) * 0.5f;
						_rightElbowHint.position = val7 + ((Component)this).transform.right * 2f + ((Component)this).transform.forward * 0.3f + ((Component)this).transform.up * -0.1f;
					}
					return;
				}
				_rightIKProxy.position = val.position + val.right * 0.05f;
				_rightIKProxy.rotation = val.rotation;
				_rightIKTarget = _rightIKProxy;
			}
			else
			{
				_rightIKTarget = rightArmSource.grabberTransformTarget;
			}
			_rightHintWeight = 1f;
			if ((Object)(object)_rightElbowHint != (Object)null && (Object)(object)_rightIKTarget != (Object)null)
			{
				Vector3 val8 = (((Component)this).transform.position + _rightIKTarget.position) * 0.5f;
				_rightElbowHint.position = val8 + ((Component)this).transform.right * 0.5f + ((Component)this).transform.forward * -0.2f;
			}
		}
		else if ((Object)(object)physGrabBeam != (Object)null && (Object)(object)physGrabBeam.lineRenderer != (Object)null && ((Renderer)physGrabBeam.lineRenderer).enabled)
		{
			bool flag4 = ModdedModelPlayerAvatar._isTumblingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isTumblingField.GetValue(visualsSource.playerAvatar);
			bool flag5 = ModdedModelPlayerAvatar._isCrawlingField != null && (Object)(object)visualsSource?.playerAvatar != (Object)null && (bool)ModdedModelPlayerAvatar._isCrawlingField.GetValue(visualsSource.playerAvatar);
			if (flag4 || flag5)
			{
				Animator animator2 = _animator;
				Transform val9 = ((animator2 != null) ? ((Component)animator2).transform.Find("Smol") : null);
				Animator val10 = ((val9 != null) ? ((Component)val9).GetComponent<Animator>() : null) ?? ((val9 != null) ? ((Component)val9).GetComponentInChildren<Animator>(true) : null);
				Transform val11 = ((val10 != null && val10.isHuman) ? val10.GetBoneTransform((HumanBodyBones)14) : null);
				Vector3 val12 = physGrabBeam.PhysGrabPointPuller.position;
				if ((Object)(object)val11 != (Object)null)
				{
					float num2 = 0.3f;
					Vector3 val13 = val12 - val11.position;
					if (((Vector3)(ref val13)).magnitude > num2)
					{
						val12 = val11.position + ((Vector3)(ref val13)).normalized * num2;
					}
				}
				val12 += ((Component)this).transform.right * 0.12f + ((Component)this).transform.forward * 0.08f;
				_rightIKProxy.position = val12;
				_rightIKProxy.rotation = physGrabBeam.PhysGrabPointPuller.rotation;
				_rightIKTarget = _rightIKProxy;
				_rightHintWeight = 1f;
				if ((Object)(object)_rightElbowHint != (Object)null)
				{
					Vector3 val14 = (((Component)this).transform.position + _rightIKProxy.position) * 0.5f;
					_rightElbowHint.position = val14 + ((Component)this).transform.right * 2f + ((Component)this).transform.forward * 0.3f + ((Component)this).transform.up * -0.1f;
				}
			}
			else
			{
				float num3 = 0.6f;
				Vector3 position = physGrabBeam.PhysGrabPointPuller.position;
				Vector3 val15 = ((Component)this).transform.position + ((Component)this).transform.up * 1.2f + ((Component)this).transform.forward * 0.3f;
				Vector3 position2 = Vector3.Lerp(position, val15, num3);
				_rightIKProxy.position = position2;
				_rightIKProxy.rotation = physGrabBeam.PhysGrabPointPuller.rotation;
				_rightIKTarget = _rightIKProxy;
				_rightHintWeight = 1f;
				if ((Object)(object)_rightElbowHint != (Object)null)
				{
					Vector3 val16 = (((Component)this).transform.position + _rightIKTarget.position) * 0.5f;
					_rightElbowHint.position = val16 + ((Component)this).transform.right * 3f + ((Component)this).transform.forward * -0.3f;
				}
			}
		}
		else
		{
			_rightIKTarget = null;
			_rightHintWeight = 0f;
		}
	}

	private void OnAnimatorIK(int layerIndex)
	{
		//IL_00b5: 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_0164: 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_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_037f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_0384: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_animator == (Object)null) && !ikDisabled)
		{
			float num = (((Object)(object)_leftIKTarget != (Object)null) ? 1f : 0f);
			_leftWeight = Mathf.MoveTowards(_leftWeight, num, 8f * Time.deltaTime);
			_animator.SetIKPositionWeight((AvatarIKGoal)2, _leftWeight);
			_animator.SetIKRotationWeight((AvatarIKGoal)2, _leftWeight * 0.6f);
			if ((Object)(object)_leftIKTarget != (Object)null && _leftWeight > 0f)
			{
				_animator.SetIKPosition((AvatarIKGoal)2, _leftIKTarget.position);
				_animator.SetIKRotation((AvatarIKGoal)2, _leftIKTarget.rotation);
			}
			float num2 = (((Object)(object)_rightIKTarget != (Object)null) ? 1f : 0f);
			_rightWeight = Mathf.MoveTowards(_rightWeight, num2, 8f * Time.deltaTime);
			_animator.SetIKPositionWeight((AvatarIKGoal)3, _rightWeight);
			_animator.SetIKRotationWeight((AvatarIKGoal)3, _rightWeight * 0.8f);
			if ((Object)(object)_rightIKTarget != (Object)null && _rightWeight > 0f)
			{
				_rightIKSmoothedPos = Vector3.Lerp(_rightIKSmoothedPos, _rightIKTarget.position, 15f * Time.deltaTime);
				_rightIKSmoothedRot = Quaternion.Slerp(_rightIKSmoothedRot, _rightIKTarget.rotation, 15f * Time.deltaTime);
				_animator.SetIKPosition((AvatarIKGoal)3, _rightIKSmoothedPos);
				_animator.SetIKRotation((AvatarIKGoal)3, _rightIKSmoothedRot);
			}
			else if ((Object)(object)_rightIKTarget != (Object)null)
			{
				_rightIKSmoothedPos = _rightIKTarget.position;
				_rightIKSmoothedRot = _rightIKTarget.rotation;
			}
			_animator.SetIKHintPositionWeight((AvatarIKHint)3, _rightWeight);
			if ((Object)(object)_rightElbowHint != (Object)null)
			{
				_animator.SetIKHintPosition((AvatarIKHint)3, _rightElbowHint.position);
			}
			_animator.SetIKHintPositionWeight((AvatarIKHint)2, _leftWeight);
			if ((Object)(object)_leftElbowHint != (Object)null && (Object)(object)_leftIKTarget != (Object)null)
			{
				_animator.SetIKHintPosition((AvatarIKHint)2, _leftElbowHint.position);
			}
			if ((Object)(object)_visuals != (Object)null && (Object)(object)_visuals.headUpTransform != (Object)null)
			{
				Vector3 lookAtPosition = (Vector3)(((Object)(object)visualsSource != (Object)null && !visualsSource.isMenuAvatar && ModdedModelPlayerAvatar._isTumblingField != null && ModdedModelPlayerAvatar._isCrawlingField != null && ((bool)ModdedModelPlayerAvatar._isTumblingField.GetValue(visualsSource.playerAvatar ?? PlayerAvatar.instance) || (bool)ModdedModelPlayerAvatar._isCrawlingField.GetValue(visualsSource.playerAvatar ?? PlayerAvatar.instance))) ? new Vector3(_headLookTarget.x, _headLookTarget.y + smolLookAtOffset, _headLookTarget.z) : _headLookTarget);
				_animator.SetLookAtWeight(1f, 0.1f, 0.8f, 0f, 0.5f);
				_animator.SetLookAtPosition(lookAtPosition);
			}
			else
			{
				_animator.SetLookAtWeight(0f);
			}
		}
	}

	private void UpdateEyes()
	{
		//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_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_bodyMesh == (Object)null || (Object)(object)eyesSource == (Object)null || ikDisabled || _bsEyeXR < 0 || _bsEyeXL < 0 || _bsEyeYL < 0 || _bsEyeYR < 0 || (Object)(object)_modelHead == (Object)null)
		{
			return;
		}
		bool flag = false;
		Vector3 val;
		if (!isLocalPlayer)
		{
			flag = _lookAtActiveField != null && (bool)_lookAtActiveField.GetValue(eyesSource);
			val = eyesSource.lookAt.position;
		}
		else
		{
			PhysGrabBeam val2 = rightArmSource?.physGrabBeam;
			if ((Object)(object)val2 != (Object)null && (Object)(object)val2.lineRenderer != (Object)null && ((Renderer)val2.lineRenderer).enabled && (Object)(object)val2.PhysGrabPoint != (Object)null)
			{
				val = val2.PhysGrabPoint.position;
				flag = true;
			}
			else
			{
				val = _modelHead.position + _modelHead.forward * 2f;
			}
		}
		float num = 0f;
		float num2 = 0f;
		if (flag)
		{
			Transform modelHead = _modelHead;
			Vector3 val3 = val - _modelHead.position;
			Vector3 val4 = modelHead.InverseTransformDirection(((Vector3)(ref val3)).normalized);
			num = Mathf.Clamp(val4.x * 3f, -1f, 1f) * 100f;
			num2 = Mathf.Clamp(val4.y * 3f, -1f, 1f) * 100f;
		}
		float num3 = (flag ? 12f : 6f);
		_eyeXLeft = Mathf.Lerp(_eyeXLeft, num, num3 * Time.deltaTime);
		_eyeXRight = Mathf.Lerp(_eyeXRight, num, num3 * Time.deltaTime);
		_eyeYLeft = Mathf.Lerp(_eyeYLeft, num2, num3 * Time.deltaTime);
		_eyeYRight = Mathf.Lerp(_eyeYRight, 0f - num2, num3 * Time.deltaTime);
		_bodyMesh.SetBlendShapeWeight(_bsEyeXR, _eyeXRight);
		_bodyMesh.SetBlendShapeWeight(_bsEyeXL, _eyeXLeft);
		_bodyMesh.SetBlendShapeWeight(_bsEyeYL, _eyeYLeft);
		_bodyMesh.SetBlendShapeWeight(_bsEyeYR, _eyeYRight);
	}

	private void EnsureSmolFingerBonesCached()
	{
		if (_smolFingerBonesInitialized)
		{
			return;
		}
		Animator animator = _animator;
		Transform val = ((animator != null) ? ((Component)animator).transform.Find("Smol") : null);
		Animator val2 = ((val != null) ? ((Component)val).GetComponent<Animator>() : null) ?? ((val != null) ? ((Component)val).GetComponentInChildren<Animator>(true) : null);
		if (!((Object)(object)val2 == (Object)null) && val2.isHuman)
		{
			_cachedSmolRightFingerBones = (Transform[])(object)new Transform[SmolRightFingerBones.Length];
			for (int i = 0; i < SmolRightFingerBones.Length; i++)
			{
				_cachedSmolRightFingerBones[i] = val2.GetBoneTransform(SmolRightFingerBones[i]);
			}
			_cachedSmolLeftFingerBones = (Transform[])(object)new Transform[SmolLeftFingerBones.Length];
			for (int j = 0; j < SmolLeftFingerBones.Length; j++)
			{
				_cachedSmolLeftFingerBones[j] = val2.GetBoneTransform(SmolLeftFingerBones[j]);
			}
			_cachedSmolRightWristBone = val2.GetBoneTransform((HumanBodyBones)18);
			_smolFingerBonesInitialized = true;
		}
	}

	public SkinnedMeshRenderer GetBodyMesh()
	{
		return _bodyMesh;
	}

	public int[] GetEyeIndices()
	{
		return new int[4] { _bsEyeXR, _bsEyeXL, _bsEyeYL, _bsEyeYR };
	}

	static ModdedModelIK()
	{
		//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_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_004e: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//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_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: 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_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: 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_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0371: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_038d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0404: Unknown result type (might be due to invalid IL or missing references)
		//IL_041a: Unknown result type (might be due to invalid IL or missing references)
		//IL_041f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_043a: Unknown result type (might be due to invalid IL or missing references)
		//IL_045b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0460: Unknown result type (might be due to invalid IL or missing references)
		//IL_0476: Unknown result type (might be due to invalid IL or missing references)
		//IL_047b: 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_0496: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0500: Unknown result type (might be due to invalid IL or missing references)
		//IL_0505: Unknown result type (might be due to invalid IL or missing references)
		//IL_0519: 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_0532: Unknown result type (might be due to invalid IL or missing references)
		//IL_0537: Unknown result type (might be due to invalid IL or missing references)
		//IL_054b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0550: Unknown result type (might be due to invalid IL or missing references)
		HumanBodyBones[] array = new HumanBodyBones[15];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		LeftFingerBones = (HumanBodyBones[])(object)array;
		LeftFingerBoneRots = (Quaternion[])(object)new Quaternion[15]
		{
			Quaternion.Euler(-8f, -22f, 20f),
			Quaternion.Euler(9f, 0f, -4f),
			Quaternion.Euler(7f, -92f, -67f),
			Quaternion.Euler(3f, -4f, 11f),
			Quaternion.Euler(1f, -10f, 0f),
			Quaternion.Euler(-4f, -98f, -72f),
			Quaternion.Euler(5f, 2f, 0f),
			Quaternion.Euler(4f, -6f, 3f),
			Quaternion.Euler(-11f, -109f, -87f),
			Quaternion.Euler(4f, 6f, -8f),
			Quaternion.Euler(15f, -2f, 0f),
			Quaternion.Euler(-20f, -118f, -118f),
			Quaternion.Euler(33f, 4f, 52f),
			Quaternion.Euler(-6f, -5f, -24f),
			Quaternion.Euler(139f, 68f, 48f)
		};
		SmolRightFingerBoneRots = (Quaternion[])(object)new Quaternion[6]
		{
			Quaternion.Euler(-28.792f, 13.271f, -39.382f),
			Quaternion.Euler(-130.415f, -84.483f, -38.841f),
			Quaternion.Euler(18.745f, 24.927f, -26.415f),
			Quaternion.Euler(-6.426f, 93.257f, 71.569f),
			Quaternion.Euler(14.019f, 19.227f, -13.157f),
			Quaternion.Euler(8.981f, 97.646f, 79.716f)
		};
		SmolLeftFingerBoneRots = (Quaternion[])(object)new Quaternion[6]
		{
			Quaternion.Euler(33f, 4f, 52f),
			Quaternion.Euler(-6f, -5f, -24f),
			Quaternion.Euler(-8f, -22f, 20f),
			Quaternion.Euler(9f, 0f, -4f),
			Quaternion.Euler(5f, 2f, 0f),
			Quaternion.Euler(4f, -6f, 3f)
		};
		mapToolPositionOffset = new Vector3(0.1f, -0.4f, 0.3f);
		mapToolRotationOffset = new Vector3(300f, 20f, 0f);
		mapSmolToolPositionOffset = new Vector3(0f, 0.5f, -0.3f);
		mapSmolToolRotationOffset = new Vector3(60f, 180f, 180f);
		HumanBodyBones[] array2 = new HumanBodyBones[6];
		RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		SmolRightFingerBones = (HumanBodyBones[])(object)array2;
		HumanBodyBones[] array3 = new HumanBodyBones[6];
		RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		SmolLeftFingerBones = (HumanBodyBones[])(object)array3;
		HumanBodyBones[] array4 = new HumanBodyBones[15];
		RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		RightFingerBones = (HumanBodyBones[])(object)array4;
	}
}
public class ModdedSmolExpression : MonoBehaviour
{
	public Renderer meshRenderer;

	public PlayerAvatar avatar;

	private static readonly int OffsetID = Shader.PropertyToID("_MainTex_ST");

	private static readonly int EmissionOffsetID = Shader.PropertyToID("_Emissive_Tex_ST");

	public Vector2 defaultEyeOffset = Vector2.zero;

	public Vector2 defaultEyebrowOffset = Vector2.zero;

	public Vector2 defaultMouthOffset = Vector2.zero;

	public Vector2 defaultTalkingMouthOffset = new Vector2(0.5f, 0f);

	private Material _matEyes;

	private Material _matEyebrows;

	private Material _matMouth;

	private bool _matsInitialized = false;

	private BlendShapeExpression.SmolFaceData _currentFace = null;

	private bool _isTalking = false;

	public Vector2 defaultBlinkOffset = new Vector2(0f, -0.25f);

	public ModdedModelExpression modelExpression;

	private Material _matBlink;

	private float _lastBlinkWeight = -1f;

	private static FieldInfo _voiceChatFetchedField;

	private static FieldInfo _voiceChatField;

	private static FieldInfo _clipLoudnessField;

	private void EnsureMaterials()
	{
		if (!_matsInitialized && !((Object)(object)meshRenderer == (Object)null))
		{
			Material[] materials = meshRenderer.materials;
			if (materials.Length > 3)
			{
				_matEyes = materials[1];
				_matEyebrows = materials[2];
				_matMouth = materials[3];
				_matBlink = materials[1];
				_matsInitialized = true;
			}
		}
	}

	private void Update()
	{
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Expected O, but got Unknown
		if ((Object)(object)avatar == (Object)null)
		{
			return;
		}
		EnsureMaterials();
		if (_voiceChatFetchedField == null)
		{
			_voiceChatFetchedField = typeof(PlayerAvatar).GetField("voiceChatFetched", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		if (_voiceChatField == null)
		{
			_voiceChatField = typeof(PlayerAvatar).GetField("voiceChat", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		if (_clipLoudnessField == null)
		{
			_clipLoudnessField = typeof(PlayerVoiceChat).GetField("clipLoudness", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		bool flag = _voiceChatFetchedField != null && (bool)_voiceChatFetchedField.GetValue(avatar);
		float num = 0f;
		if (flag && _voiceChatField != null)
		{
			PlayerVoiceChat val = (PlayerVoiceChat)_voiceChatField.GetValue(avatar);
			if ((Object)(object)val != (Object)null && _clipLoudnessField != null)
			{
				num = (float)_clipLoudnessField.GetValue(val);
			}
		}
		bool flag2 = num > 0.02f;
		if (flag2 != _isTalking)
		{
			_isTalking = flag2;
			ApplyMouth();
		}
		ApplyBlinkOffset();
	}

	public void ReceiveExpression(int index, BlendShapeExpression[] expressions)
	{
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)meshRenderer == (Object)null)
		{
			return;
		}
		EnsureMaterials();
		if (_matsInitialized)
		{
			if (index < 0 || index >= expressions.Length || expressions[index]?.smolFace == null)
			{
				_currentFace = null;
				SetOffset(_matEyebrows, defaultEyebrowOffset);
			}
			else
			{
				_currentFace = expressions[index].smolFace;
				SetOffset(_matEyebrows, _currentFace.eyebrowOffset);
			}
			_lastBlinkWeight = -1f;
			ApplyMouth();
		}
	}

	private void ApplyBlinkOffset()
	{
		//IL_008f: 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_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)modelExpression == (Object)null) && _matsInitialized)
		{
			float defaultBlinkClosedValue = modelExpression.DefaultBlinkClosedValue;
			float blinkCurrentWeight = modelExpression.BlinkCurrentWeight;
			float num = ((defaultBlinkClosedValue > 0f) ? Mathf.Clamp01(blinkCurrentWeight / defaultBlinkClosedValue) : 0f);
			if (!(Mathf.Abs(num - _lastBlinkWeight) < 0.005f))
			{
				_lastBlinkWeight = num;
				Vector2 val = ((_currentFace != null) ? _currentFace.eyeOffset : defaultEyeOffset);
				Vector2 val2 = ((_currentFace != null) ? _currentFace.blinkOffset : defaultBlinkOffset);
				SetOffset(_matEyes, (num >= 0.5f) ? val2 : val);
			}
		}
	}

	private void ApplyMouth()
	{
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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_0049: 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_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		if (_matsInitialized)
		{
			SetOffset(offset: (_currentFace == null) ? ((_isTalking && defaultTalkingMouthOffset != Vector2.zero) ? defaultTalkingMouthOffset : defaultMouthOffset) : ((!_isTalking || !(_currentFace.talkingMouthOffset != Vector2.zero)) ? _currentFace.mouthOffset : _currentFace.talkingMouthOffset), mat: _matMouth);
		}
	}

	private void SetOffset(Material mat, Vector2 offset)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: 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_0032: 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_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)mat == (Object)null))
		{
			Vector4 vector = mat.GetVector(OffsetID);
			mat.SetVector(OffsetID, new Vector4(vector.x, vector.y, offset.x, offset.y));
			if (mat.HasProperty(EmissionOffsetID))
			{
				Vector4 vector2 = mat.GetVector(EmissionOffsetID);
				mat.SetVector(EmissionOffsetID, new Vector4(vector2.x, vector2.y, offset.x, offset.y));
			}
		}
	}
}
public class ModdedSmolIK : MonoBehaviour
{
	public PlayerAvatarVisuals visualsSource;

	public PlayerEyes eyesSource;

	public bool isLocalPlayer;

	private Animator _animator;

	private static FieldInfo _lookAtActiveField;

	private static FieldInfo _lookAtField;

	public void Initialize()
	{
		_animator = ((Component)this).GetComponent<Animator>();
		if (_lookAtActiveField == null)
		{
			_lookAtActiveField = typeof(PlayerEyes).GetField("lookAtActive", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
		if (_lookAtField == null)
		{
			_lookAtField = typeof(PlayerEyes).GetField("lookAt", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		}
	}

	private void OnAnimatorIK(int layerIndex)
	{
		if (!((Object)(object)_animator == (Object)null))
		{
			UpdateHeadLookAt();
		}
	}

	private void UpdateHeadLookAt()
	{
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Expected O, but got Unknown
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknow

JigglePhysicsPlugin.dll

Decompiled 5 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.LowLevel;
using UnityEngine.PlayerLoop;
using UnityEngine.Serialization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("JigglePhysicsPlugin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JigglePhysicsPlugin")]
[assembly: AssemblyTitle("JigglePhysicsPlugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 JigglePhysicsPlugin
{
	public static class CachedSphereCollider
	{
		private class DestroyListener : MonoBehaviour
		{
			private void OnDestroy()
			{
				_hasSphere = false;
			}
		}

		private static bool _hasSphere;

		private static SphereCollider _sphereCollider;

		public static void StartPass()
		{
			if (TryGet(out var collider))
			{
				((Collider)collider).enabled = true;
			}
		}

		public static void FinishedPass()
		{
			if (TryGet(out var collider))
			{
				((Collider)collider).enabled = false;
			}
		}

		public static bool TryGet(out SphereCollider collider)
		{
			//IL_0040: 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_004f: Expected O, but got Unknown
			if (_hasSphere)
			{
				collider = _sphereCollider;
				return true;
			}
			try
			{
				GameObject val = new GameObject("JiggleBoneSphereCollider", new Type[2]
				{
					typeof(SphereCollider),
					typeof(DestroyListener)
				})
				{
					hideFlags = (HideFlags)61
				};
				if (Application.isPlaying)
				{
					Object.DontDestroyOnLoad((Object)(object)val);
				}
				_sphereCollider = val.GetComponent<SphereCollider>();
				collider = _sphereCollider;
				((Collider)collider).enabled = false;
				_hasSphere = true;
				return true;
			}
			catch
			{
				if ((Object)(object)_sphereCollider != (Object)null)
				{
					if (Application.isPlaying)
					{
						Object.Destroy((Object)(object)((Component)_sphereCollider).gameObject);
					}
					else
					{
						Object.DestroyImmediate((Object)(object)((Component)_sphereCollider).gameObject);
					}
				}
				_hasSphere = false;
				collider = null;
				throw;
			}
		}
	}
	public class JiggleBone
	{
		private readonly bool hasTransform;

		private readonly PositionSignal targetAnimatedBoneSignal;

		private Vector3 currentFixedAnimatedBonePosition;

		public readonly JiggleBone parent;

		private JiggleBone child;

		private Quaternion boneRotationChangeCheck;

		private Vector3 bonePositionChangeCheck;

		private Quaternion lastValidPoseBoneRotation;

		private float projectionAmount;

		private Vector3 lastValidPoseBoneLocalPosition;

		private float normalizedIndex;

		public readonly Transform transform;

		private readonly PositionSignal particleSignal;

		private Vector3 workingPosition;

		private Vector3? preTeleportPosition;

		private Vector3 extrapolatedPosition;

		private float GetLengthToParent()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (parent == null)
			{
				return 0.1f;
			}
			return Vector3.Distance(currentFixedAnimatedBonePosition, parent.currentFixedAnimatedBonePosition);
		}

		public JiggleBone(Transform transform, JiggleBone parent, float projectionAmount = 1f)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			this.transform = transform;
			this.parent = parent;
			this.projectionAmount = projectionAmount;
			Vector3 startPosition;
			if ((Object)(object)transform != (Object)null)
			{
				lastValidPoseBoneRotation = transform.localRotation;
				lastValidPoseBoneLocalPosition = transform.localPosition;
				startPosition = transform.position;
			}
			else
			{
				startPosition = GetProjectedPosition();
			}
			targetAnimatedBoneSignal = new PositionSignal(startPosition, Time.timeAsDouble);
			particleSignal = new PositionSignal(startPosition, Time.timeAsDouble);
			hasTransform = (Object)(object)transform != (Object)null;
			if (parent != null)
			{
				this.parent.child = this;
			}
		}

		public void CalculateNormalizedIndex()
		{
			int num = 0;
			JiggleBone jiggleBone = this;
			while (jiggleBone.parent != null)
			{
				jiggleBone = jiggleBone.parent;
				num++;
			}
			int num2 = 0;
			jiggleBone = this;
			while (jiggleBone.child != null)
			{
				jiggleBone = jiggleBone.child;
				num2++;
			}
			int num3 = num + num2;
			float num4 = (float)num / (float)num3;
			normalizedIndex = num4;
		}

		public void VerletPass(JiggleSettingsData jiggleSettings, Vector3 wind, double time)
		{
			//IL_0009: 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)
			//IL_004b: 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_006b: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			currentFixedAnimatedBonePosition = targetAnimatedBoneSignal.SamplePosition(time);
			if (parent == null)
			{
				workingPosition = currentFixedAnimatedBonePosition;
				particleSignal.SetPosition(workingPosition, time);
			}
			else
			{
				Vector3 localSpaceVelocity = particleSignal.GetCurrent() - particleSignal.GetPrevious() - (parent.particleSignal.GetCurrent() - parent.particleSignal.GetPrevious());
				workingPosition = NextPhysicsPosition(particleSignal.GetCurrent(), particleSignal.GetPrevious(), localSpaceVelocity, Time.fixedDeltaTime, jiggleSettings.gravityMultiplier, jiggleSettings.friction, jiggleSettings.airDrag);
				workingPosition += wind * (Time.fixedDeltaTime * jiggleSettings.airDrag);
			}
		}

		public void CollisionPreparePass(JiggleSettingsData jiggleSettings)
		{
			//IL_0004: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			workingPosition = ConstrainLengthBackwards(workingPosition, jiggleSettings.lengthElasticity * jiggleSettings.lengthElasticity * 0.5f);
		}

		public void ConstraintPass(JiggleSettingsData jiggleSettings)
		{
			//IL_0014: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (parent != null)
			{
				workingPosition = ConstrainAngle(workingPosition, jiggleSettings.angleElasticity * jiggleSettings.angleElasticity, jiggleSettings.elasticitySoften);
				workingPosition = ConstrainLength(workingPosition, jiggleSettings.lengthElasticity * jiggleSettings.lengthElasticity);
			}
		}

		public void CollisionPass(JiggleSettingsBase jiggleSettings, List<Collider> colliders)
		{
			//IL_006d: 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_0080: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if (colliders.Count == 0 || !CachedSphereCollider.TryGet(out var collider))
			{
				return;
			}
			Vector3 val = default(Vector3);
			float num = default(float);
			foreach (Collider collider2 in colliders)
			{
				collider.radius = jiggleSettings.GetRadius(normalizedIndex);
				if (!(collider.radius <= 0f) && Physics.ComputePenetration((Collider)(object)collider, workingPosition, Quaternion.identity, collider2, ((Component)collider2).transform.position, ((Component)collider2).transform.rotation, ref val, ref num))
				{
					workingPosition += val * num;
				}
			}
		}

		public void SignalWritePosition(double time)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			particleSignal.SetPosition(workingPosition, time);
		}

		private Vector3 GetProjectedPosition()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003e: 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)
			Vector3 position = parent.transform.position;
			return parent.transform.TransformPoint(parent.GetParentTransform().InverseTransformPoint(position) * projectionAmount);
		}

		private Vector3 GetTransformPosition()
		{
			//IL_001f: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!hasTransform)
			{
				return GetProjectedPosition();
			}
			return transform.position;
		}

		private Transform GetParentTransform()
		{
			if (parent != null)
			{
				return parent.transform;
			}
			return transform.parent;
		}

		private void CacheAnimationPosition()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (!hasTransform)
			{
				targetAnimatedBoneSignal.SetPosition(GetProjectedPosition(), Time.timeAsDouble);
				return;
			}
			targetAnimatedBoneSignal.SetPosition(transform.position, Time.timeAsDouble);
			lastValidPoseBoneRotation = transform.localRotation;
			lastValidPoseBoneLocalPosition = transform.localPosition;
		}

		private Vector3 ConstrainLengthBackwards(Vector3 newPosition, float elasticity)
		{
			//IL_0013: 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_001f: 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_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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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)
			if (child == null)
			{
				return newPosition;
			}
			Vector3 val = newPosition - child.workingPosition;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			return Vector3.Lerp(newPosition, child.workingPosition + normalized * child.GetLengthToParent(), elasticity);
		}

		private Vector3 ConstrainLength(Vector3 newPosition, float elasticity)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			//IL_001b: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = newPosition - parent.workingPosition;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			return Vector3.Lerp(newPosition, parent.workingPosition + normalized * GetLengthToParent(), elasticity);
		}

		public void MatchAnimationInstantly()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			double timeAsDouble = Time.timeAsDouble;
			Vector3 transformPosition = GetTransformPosition();
			targetAnimatedBoneSignal.FlattenSignal(timeAsDouble, transformPosition);
			particleSignal.FlattenSignal(timeAsDouble, transformPosition);
		}

		public void PrepareTeleport()
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			preTeleportPosition = GetTransformPosition();
		}

		public void FinishTeleport()
		{
			//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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (!preTeleportPosition.HasValue)
			{
				MatchAnimationInstantly();
				return;
			}
			Vector3 transformPosition = GetTransformPosition();
			Vector3 val = transformPosition - preTeleportPosition.Value;
			targetAnimatedBoneSignal.FlattenSignal(Time.timeAsDouble, transformPosition);
			particleSignal.OffsetSignal(val);
			workingPosition += val;
		}

		private Vector3 ConstrainAngleBackward(Vector3 newPosition, float elasticity, float elasticitySoften)
		{
			//IL_0034: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_008e: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0021: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			if (child == null || child.child == null)
			{
				return newPosition;
			}
			Vector3 val = child.child.currentFixedAnimatedBonePosition - child.currentFixedAnimatedBonePosition;
			Vector3 val2 = child.child.workingPosition - child.workingPosition;
			Quaternion val3 = Quaternion.FromToRotation(val, val2);
			Vector3 val4 = newPosition - child.workingPosition;
			Vector3 val5 = val3 * val4;
			Debug.DrawLine(newPosition, child.workingPosition + val5, Color.cyan);
			float num = Vector3.Distance(newPosition, child.workingPosition + val5);
			num /= child.GetLengthToParent();
			num = Mathf.Clamp01(num);
			num = Mathf.Pow(num, elasticitySoften * 2f);
			return Vector3.Lerp(newPosition, child.workingPosition + val5, elasticity * num);
		}

		private Vector3 ConstrainAngle(Vector3 newPosition, float elasticity, float elasticitySoften)
		{
			//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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_0098: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_00b3: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if (!hasTransform && projectionAmount == 0f)
			{
				return newPosition;
			}
			Vector3 val;
			Vector3 val2;
			if (parent.parent == null)
			{
				val = parent.currentFixedAnimatedBonePosition + (parent.currentFixedAnimatedBonePosition - currentFixedAnimatedBonePosition);
				val2 = val;
			}
			else
			{
				val2 = parent.parent.workingPosition;
				val = parent.parent.currentFixedAnimatedBonePosition;
			}
			Vector3 val3 = parent.currentFixedAnimatedBonePosition - val;
			Vector3 val4 = parent.workingPosition - val2;
			Quaternion val5 = Quaternion.FromToRotation(val3, val4);
			Vector3 val6 = currentFixedAnimatedBonePosition - val;
			Vector3 val7 = val5 * val6;
			float num = Vector3.Distance(newPosition, val2 + val7);
			num /= GetLengthToParent();
			num = Mathf.Clamp01(num);
			num = Mathf.Pow(num, elasticitySoften * 2f);
			return Vector3.Lerp(newPosition, val2 + val7, elasticity * num);
		}

		public static Vector3 NextPhysicsPosition(Vector3 newPosition, Vector3 previousPosition, Vector3 localSpaceVelocity, float deltaTime, float gravityMultiplier, float friction, float airFriction)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			float num = deltaTime * deltaTime;
			Vector3 val = newPosition - previousPosition - localSpaceVelocity;
			return newPosition + val * (1f - airFriction) + localSpaceVelocity * (1f - friction) + Physics.gravity * (gravityMultiplier * num);
		}

		public void DebugDraw(Color simulateColor, Color targetColor, bool interpolated)
		{
			//IL_0039: 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_0017: 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_0027: 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_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)
			if (parent != null)
			{
				if (interpolated)
				{
					Debug.DrawLine(extrapolatedPosition, parent.extrapolatedPosition, simulateColor, 0f, false);
				}
				else
				{
					Debug.DrawLine(workingPosition, parent.workingPosition, simulateColor, 0f, false);
				}
				Debug.DrawLine(currentFixedAnimatedBonePosition, parent.currentFixedAnimatedBonePosition, targetColor, 0f, false);
			}
		}

		public Vector3 DeriveFinalSolvePosition(Vector3 offset)
		{
			//IL_0002: 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)
			//IL_0013: 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_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_0026: Unknown result type (might be due to invalid IL or missing references)
			extrapolatedPosition = offset + particleSignal.SamplePosition(Time.timeAsDouble);
			return extrapolatedPosition;
		}

		public Vector3 GetCachedSolvePosition()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return extrapolatedPosition;
		}

		public void PrepareBone()
		{
			//IL_000d: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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)
			if (hasTransform)
			{
				if (boneRotationChangeCheck == transform.localRotation)
				{
					transform.localRotation = lastValidPoseBoneRotation;
				}
				if (bonePositionChangeCheck == transform.localPosition)
				{
					transform.localPosition = lastValidPoseBoneLocalPosition;
				}
			}
			CacheAnimationPosition();
		}

		public void OnDrawGizmos(JiggleSettingsBase jiggleSettings)
		{
			//IL_0036: 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_0087: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)transform != (Object)null && child != null && (Object)(object)child.transform != (Object)null)
			{
				Gizmos.DrawLine(transform.position, child.transform.position);
			}
			if ((Object)(object)transform != (Object)null && child != null && (Object)(object)child.transform == (Object)null)
			{
				Gizmos.DrawLine(transform.position, child.GetProjectedPosition());
			}
			if ((Object)(object)transform != (Object)null && (Object)(object)jiggleSettings != (Object)null)
			{
				Gizmos.DrawWireSphere(transform.position, jiggleSettings.GetRadius(normalizedIndex));
			}
			if ((Object)(object)transform == (Object)null && (Object)(object)jiggleSettings != (Object)null)
			{
				Gizmos.DrawWireSphere(GetProjectedPosition(), jiggleSettings.GetRadius(normalizedIndex));
			}
		}

		public void PoseBone(float blend)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0050: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_0093: 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_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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00b5: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			if (child != null)
			{
				Vector3 val = Vector3.Lerp(targetAnimatedBoneSignal.SamplePosition(Time.timeAsDouble), extrapolatedPosition, blend);
				Vector3 val2 = Vector3.Lerp(child.targetAnimatedBoneSignal.SamplePosition(Time.timeAsDouble), child.extrapolatedPosition, blend);
				if (parent != null)
				{
					transform.position = val;
				}
				Vector3 transformPosition = child.GetTransformPosition();
				Vector3 val3 = transformPosition - transform.position;
				Vector3 val4 = val2 - val;
				Quaternion val5 = Quaternion.FromToRotation(val3, val4);
				transform.rotation = val5 * transform.rotation;
			}
			if (hasTransform)
			{
				boneRotationChangeCheck = transform.localRotation;
				bonePositionChangeCheck = transform.localPosition;
			}
		}
	}
	[DefaultExecutionOrder(200)]
	public class JiggleRigBuilder : MonoBehaviour
	{
		[SerializeField]
		[Tooltip("The root bone from which an individual JiggleRig will be constructed. The JiggleRig encompasses all children of the specified root.")]
		[FormerlySerializedAs("target")]
		private Transform rootTransform;

		[Tooltip("The settings that the rig should update with, create them using the Create->JigglePhysics->Settings menu option.")]
		public JiggleSettingsBase jiggleSettings;

		[SerializeField]
		[Tooltip("The list of transforms to ignore during the jiggle. Each bone listed will also ignore all the children of the specified bone.")]
		private List<Transform> ignoredTransforms;

		public List<Collider> colliders;

		[Tooltip("An air force that is applied to the entire rig, this is useful to plug in some wind volumes from external sources.")]
		public Vector3 wind;

		[Tooltip("Level of detail manager. This system will control how the jiggle rig saves performance cost.")]
		public JiggleRigLOD levelOfDetail;

		[Tooltip("Draws some simple lines to show what the simulation is doing. Generally this should be disabled.")]
		[SerializeField]
		private bool debugDraw;

		private JiggleSettingsData data;

		private bool initialized;

		[HideInInspector]
		protected List<JiggleBone> simulatedPoints;

		private double accumulation;

		private bool dirtyFromEnable = false;

		private bool wasLODActive = true;

		public static float maxCatchupTime => Time.fixedDeltaTime * 4f;

		private bool NeedsCollisions => colliders.Count != 0;

		public Transform GetRootTransform()
		{
			return rootTransform;
		}

		public void PrepareBone(Vector3 position, JiggleRigLOD jiggleRigLOD)
		{
			//IL_0014: 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)
			if (!initialized)
			{
				throw new UnityException("JiggleRig was never initialized. Please call JiggleRig.Initialize() if you're going to manually timestep.");
			}
			foreach (JiggleBone simulatedPoint in simulatedPoints)
			{
				simulatedPoint.PrepareBone();
			}
			data = jiggleSettings.GetData();
			data = (((Object)(object)jiggleRigLOD != (Object)null) ? jiggleRigLOD.AdjustJiggleSettingsData(position, data) : data);
		}

		public void MatchAnimationInstantly()
		{
			foreach (JiggleBone simulatedPoint in simulatedPoints)
			{
				simulatedPoint.MatchAnimationInstantly();
			}
		}

		public void UpdateJiggle(Vector3 wind, double time)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			foreach (JiggleBone simulatedPoint in simulatedPoints)
			{
				simulatedPoint.VerletPass(data, wind, time);
			}
			if (NeedsCollisions)
			{
				for (int num = simulatedPoints.Count - 1; num >= 0; num--)
				{
					simulatedPoints[num].CollisionPreparePass(data);
				}
			}
			foreach (JiggleBone simulatedPoint2 in simulatedPoints)
			{
				simulatedPoint2.ConstraintPass(data);
			}
			if (NeedsCollisions)
			{
				foreach (JiggleBone simulatedPoint3 in simulatedPoints)
				{
					simulatedPoint3.CollisionPass(jiggleSettings, colliders);
				}
			}
			foreach (JiggleBone simulatedPoint4 in simulatedPoints)
			{
				simulatedPoint4.SignalWritePosition(time);
			}
		}

		public void DeriveFinalSolve()
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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)
			Vector3 val = simulatedPoints[0].DeriveFinalSolvePosition(Vector3.zero);
			Vector3 offset = simulatedPoints[0].transform.position - val;
			foreach (JiggleBone simulatedPoint in simulatedPoints)
			{
				simulatedPoint.DeriveFinalSolvePosition(offset);
			}
		}

		public void Pose(bool debugDraw)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			DeriveFinalSolve();
			foreach (JiggleBone simulatedPoint in simulatedPoints)
			{
				simulatedPoint.PoseBone(data.blend);
				if (debugDraw)
				{
					simulatedPoint.DebugDraw(Color.red, Color.blue, interpolated: true);
				}
			}
		}

		public void PrepareTeleport()
		{
			foreach (JiggleBone simulatedPoint in simulatedPoints)
			{
				simulatedPoint.PrepareTeleport();
			}
		}

		public void FinishTeleport()
		{
			foreach (JiggleBone simulatedPoint in simulatedPoints)
			{
				simulatedPoint.FinishTeleport();
			}
		}

		protected virtual void CreateSimulatedPoints(ICollection<JiggleBone> outputPoints, ICollection<Transform> ignoredTransforms, Transform currentTransform, JiggleBone parentJiggleBone)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			JiggleBone jiggleBone = new JiggleBone(currentTransform, parentJiggleBone);
			outputPoints.Add(jiggleBone);
			if (currentTransform.childCount == 0)
			{
				if (jiggleBone.parent == null)
				{
					if ((Object)(object)jiggleBone.transform.parent == (Object)null)
					{
						throw new UnityException("Can't have a singular jiggle bone with no parents. That doesn't even make sense!");
					}
					outputPoints.Add(new JiggleBone(null, jiggleBone));
				}
				else
				{
					outputPoints.Add(new JiggleBone(null, jiggleBone));
				}
				return;
			}
			for (int i = 0; i < currentTransform.childCount; i++)
			{
				if (!ignoredTransforms.Contains(currentTransform.GetChild(i)))
				{
					CreateSimulatedPoints(outputPoints, ignoredTransforms, currentTransform.GetChild(i), jiggleBone);
				}
			}
		}

		private void Awake()
		{
			Initialize();
		}

		private void OnEnable()
		{
			JiggleRigHandler.AddBuilder(this);
			dirtyFromEnable = true;
		}

		private void OnDisable()
		{
			JiggleRigHandler.RemoveBuilder(this);
			PrepareTeleport();
		}

		public void Initialize()
		{
			accumulation = 0.0;
			simulatedPoints = new List<JiggleBone>();
			if ((Object)(object)rootTransform == (Object)null)
			{
				return;
			}
			CreateSimulatedPoints(simulatedPoints, ignoredTransforms, rootTransform, null);
			foreach (JiggleBone simulatedPoint in simulatedPoints)
			{
				simulatedPoint.CalculateNormalizedIndex();
			}
			initialized = true;
		}

		public virtual void Advance(float deltaTime)
		{
			//IL_001b: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)levelOfDetail != (Object)null && !levelOfDetail.CheckActive(((Component)this).transform.position))
			{
				if (wasLODActive)
				{
					PrepareTeleport();
				}
				wasLODActive = false;
				return;
			}
			if (!wasLODActive)
			{
				FinishTeleport();
			}
			PrepareBone(((Component)this).transform.position, levelOfDetail);
			if (dirtyFromEnable)
			{
				FinishTeleport();
				dirtyFromEnable = false;
			}
			accumulation = Math.Min(accumulation + (double)deltaTime, maxCatchupTime);
			while (accumulation > (double)Time.fixedDeltaTime)
			{
				accumulation -= Time.fixedDeltaTime;
				double time = Time.timeAsDouble - accumulation;
				UpdateJiggle(wind, time);
			}
			Pose(debugDraw);
			wasLODActive = true;
		}

		private void OnDrawGizmos()
		{
			if (!initialized || simulatedPoints == null)
			{
				Initialize();
			}
			foreach (JiggleBone simulatedPoint in simulatedPoints)
			{
				simulatedPoint.OnDrawGizmos(jiggleSettings);
			}
		}

		private void OnValidate()
		{
			if ((Object)(object)rootTransform == (Object)null)
			{
				rootTransform = ((Component)this).transform;
			}
			if (!Application.isPlaying)
			{
				Initialize();
			}
		}
	}
	public static class JiggleRigHandler
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UpdateFunction <0>__UpdateJiggleRigs;
		}

		private static bool initialized = false;

		private static HashSet<JiggleRigBuilder> builders = new HashSet<JiggleRigBuilder>();

		private static void Initialize()
		{
			//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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (!initialized)
			{
				PlayerLoopSystem currentPlayerLoop = PlayerLoop.GetCurrentPlayerLoop();
				PlayerLoopSystem self = currentPlayerLoop;
				PlayerLoopSystem systemToInject = default(PlayerLoopSystem);
				object obj = <>O.<0>__UpdateJiggleRigs;
				if (obj == null)
				{
					UpdateFunction val = UpdateJiggleRigs;
					<>O.<0>__UpdateJiggleRigs = val;
					obj = (object)val;
				}
				systemToInject.updateDelegate = (UpdateFunction)obj;
				systemToInject.type = typeof(JiggleRigHandler);
				currentPlayerLoop = self.InjectAt<PostLateUpdate>(systemToInject);
				PlayerLoop.SetPlayerLoop(currentPlayerLoop);
				initialized = true;
			}
		}

		private static void UpdateJiggleRigs()
		{
			CachedSphereCollider.StartPass();
			foreach (JiggleRigBuilder builder in builders)
			{
				builder.Advance(Time.deltaTime);
			}
			CachedSphereCollider.FinishedPass();
		}

		public static void AddBuilder(JiggleRigBuilder builder)
		{
			builders.Add(builder);
			Initialize();
		}

		public static void RemoveBuilder(JiggleRigBuilder builder)
		{
			builders.Remove(builder);
		}

		private static PlayerLoopSystem InjectAt<T>(this PlayerLoopSystem self, PlayerLoopSystem systemToInject)
		{
			//IL_0001: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00b3: 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_00ec: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			int num = FindIndexOfSubsystem<T>(self.subSystemList);
			if (num == -1)
			{
				throw new UnityException($"Failed to find PlayerLoopSystem with type{typeof(T)}");
			}
			List<PlayerLoopSystem> list = new List<PlayerLoopSystem>(self.subSystemList[num].subSystemList);
			foreach (PlayerLoopSystem item2 in list)
			{
				if (item2.type != typeof(JiggleRigBuilder))
				{
					continue;
				}
				Debug.LogWarning((object)$"Tried to inject a PlayerLoopSystem ({systemToInject.type}) more than once! Ignoring the second injection.");
				return self;
			}
			PlayerLoopSystem item = default(PlayerLoopSystem);
			object obj = <>O.<0>__UpdateJiggleRigs;
			if (obj == null)
			{
				UpdateFunction val = UpdateJiggleRigs;
				<>O.<0>__UpdateJiggleRigs = val;
				obj = (object)val;
			}
			item.updateDelegate = (UpdateFunction)obj;
			item.type = typeof(JiggleRigHandler);
			list.Insert(0, item);
			self.subSystemList[num].subSystemList = list.ToArray();
			return self;
		}

		private static int FindIndexOfSubsystem<T>(PlayerLoopSystem[] list, int index = -1)
		{
			if (list == null)
			{
				return -1;
			}
			for (int i = 0; i < list.Length; i++)
			{
				if (list[i].type == typeof(T))
				{
					return i;
				}
			}
			return -1;
		}
	}
	public abstract class JiggleRigLOD : ScriptableObject
	{
		public abstract bool CheckActive(Vector3 position);

		public abstract JiggleSettingsData AdjustJiggleSettingsData(Vector3 position, JiggleSettingsData data);
	}
	[CreateAssetMenu(fileName = "JiggleRigSimpleLOD", menuName = "JigglePhysics/JiggleRigSimpleLOD", order = 1)]
	public class JiggleRigSimpleLOD : JiggleRigLOD
	{
		[Tooltip("Distance to disable the jiggle rig")]
		[SerializeField]
		private float distance;

		[Tooltip("Level of detail manager. This system will control how the jiggle rig saves performance cost.")]
		[SerializeField]
		private float blend;

		[NonSerialized]
		private Camera currentCamera;

		[NonSerialized]
		private Transform cameraTransform;

		private bool TryGetCamera(out Camera camera)
		{
			if ((Object)(object)currentCamera == (Object)null || !((Component)currentCamera).CompareTag("MainCamera"))
			{
				currentCamera = Camera.main;
			}
			camera = currentCamera;
			return (Object)(object)currentCamera != (Object)null;
		}

		public override bool CheckActive(Vector3 position)
		{
			//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)
			if (!TryGetCamera(out var camera))
			{
				return false;
			}
			return Vector3.Distance(((Component)camera).transform.position, position) < distance;
		}

		public override JiggleSettingsData AdjustJiggleSettingsData(Vector3 position, JiggleSettingsData data)
		{
			//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)
			if (!TryGetCamera(out var camera))
			{
				return data;
			}
			float num = (Vector3.Distance(((Component)camera).transform.position, position) - distance + blend) / blend;
			num = Mathf.Clamp01(1f - num);
			data.blend = num;
			return data;
		}
	}
	public struct JiggleSettingsData
	{
		public float gravityMultiplier;

		public float friction;

		public float angleElasticity;

		public float blend;

		public float airDrag;

		public float lengthElasticity;

		public float elasticitySoften;

		public float radiusMultiplier;

		public static JiggleSettingsData Lerp(JiggleSettingsData a, JiggleSettingsData b, float t)
		{
			JiggleSettingsData result = default(JiggleSettingsData);
			result.gravityMultiplier = Mathf.Lerp(a.gravityMultiplier, b.gravityMultiplier, t);
			result.friction = Mathf.Lerp(a.friction, b.friction, t);
			result.angleElasticity = Mathf.Lerp(a.angleElasticity, b.angleElasticity, t);
			result.blend = Mathf.Lerp(a.blend, b.blend, t);
			result.airDrag = Mathf.Lerp(a.airDrag, b.airDrag, t);
			result.lengthElasticity = Mathf.Lerp(a.lengthElasticity, b.lengthElasticity, t);
			result.elasticitySoften = Mathf.Lerp(a.elasticitySoften, b.elasticitySoften, t);
			result.radiusMultiplier = Mathf.Lerp(a.radiusMultiplier, b.radiusMultiplier, t);
			return result;
		}
	}
	[CreateAssetMenu(fileName = "JiggleSettings", menuName = "JigglePhysics/Settings", order = 1)]
	public class JiggleSettings : JiggleSettingsBase
	{
		[SerializeField]
		[Range(0f, 2f)]
		[Tooltip("How much gravity to apply to the simulation, it is a multiplier of the Physics.gravity setting.")]
		private float gravityMultiplier = 1f;

		[SerializeField]
		[Range(0f, 1f)]
		[Tooltip("How much mechanical friction to apply, this is specifically how quickly oscillations come to rest.")]
		private float friction = 0.4f;

		[SerializeField]
		[Range(0f, 1f)]
		[Tooltip("How much angular force is applied to bring it to the target shape.")]
		private float angleElasticity = 0.4f;

		[SerializeField]
		[Range(0f, 1f)]
		[Tooltip("How much of the simulation should be expressed. A value of 0 would make the jiggle have zero effect. A value of 1 gives the full movement as intended. 0.5 would ")]
		private float blend = 1f;

		[FormerlySerializedAs("airFriction")]
		[HideInInspector]
		[SerializeField]
		[Range(0f, 1f)]
		[Tooltip("How much jiggled objects should get dragged behind by moving through the air. Or how \"thick\" the air is.")]
		private float airDrag = 0.1f;

		[HideInInspector]
		[SerializeField]
		[Range(0f, 1f)]
		[Tooltip("How rigidly the rig holds its length. Low values cause lots of squash and stretch!")]
		private float lengthElasticity = 0.8f;

		[HideInInspector]
		[SerializeField]
		[Range(0f, 1f)]
		[Tooltip("How much to allow free bone motion before engaging elasticity.")]
		private float elasticitySoften = 0f;

		[HideInInspector]
		[SerializeField]
		[Tooltip("How much radius points have, only used for collisions. Set to 0 to disable collisions")]
		private float radiusMultiplier = 0f;

		[HideInInspector]
		[SerializeField]
		[Tooltip("How the radius is expressed as a curve along the bone chain from root to child.")]
		private AnimationCurve radiusCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2]
		{
			new Keyframe(0f, 1f),
			new Keyframe(1f, 0f)
		});

		public override JiggleSettingsData GetData()
		{
			JiggleSettingsData result = default(JiggleSettingsData);
			result.gravityMultiplier = gravityMultiplier;
			result.friction = friction;
			result.airDrag = airDrag;
			result.blend = blend;
			result.angleElasticity = angleElasticity;
			result.elasticitySoften = elasticitySoften;
			result.lengthElasticity = lengthElasticity;
			result.radiusMultiplier = radiusMultiplier;
			return result;
		}

		public void SetData(JiggleSettingsData data)
		{
			gravityMultiplier = data.gravityMultiplier;
			friction = data.friction;
			angleElasticity = data.angleElasticity;
			blend = data.blend;
			airDrag = data.airDrag;
			lengthElasticity = data.lengthElasticity;
			elasticitySoften = data.elasticitySoften;
			radiusMultiplier = data.radiusMultiplier;
		}

		public override float GetRadius(float normalizedIndex)
		{
			return radiusMultiplier * radiusCurve.Evaluate(normalizedIndex);
		}

		public void SetRadiusCurve(AnimationCurve curve)
		{
			radiusCurve = curve;
		}
	}
	public class JiggleSettingsBase : ScriptableObject
	{
		public virtual JiggleSettingsData GetData()
		{
			return default(JiggleSettingsData);
		}

		public virtual float GetRadius(float normalizedIndex)
		{
			return 0f;
		}
	}
	[CreateAssetMenu(fileName = "JiggleSettingsBlend", menuName = "JigglePhysics/Blend Settings", order = 1)]
	public class JiggleSettingsBlend : JiggleSettingsBase
	{
		[Tooltip("The list of jiggle settings to blend between.")]
		public List<JiggleSettings> blendSettings;

		[Range(0f, 1f)]
		[Tooltip("A value from 0 to 1 that linearly blends between all of the blendSettings.")]
		public float normalizedBlend;

		public override JiggleSettingsData GetData()
		{
			int num = blendSettings.Count - 1;
			float num2 = Mathf.Clamp01(normalizedBlend);
			int num3 = Mathf.Clamp(Mathf.FloorToInt(num2 * (float)num), 0, num);
			int index = Mathf.Clamp(Mathf.FloorToInt(num2 * (float)num) + 1, 0, num);
			return JiggleSettingsData.Lerp(blendSettings[num3].GetData(), blendSettings[index].GetData(), Mathf.Clamp01(num2 * (float)num - (float)num3));
		}

		public override float GetRadius(float normalizedIndex)
		{
			float num = Mathf.Clamp01(normalizedBlend);
			int num2 = Mathf.FloorToInt(num * (float)blendSettings.Count);
			int num3 = Mathf.FloorToInt(num * (float)blendSettings.Count) + 1;
			return Mathf.Lerp(blendSettings[Mathf.Clamp(num2, 0, blendSettings.Count - 1)].GetRadius(normalizedIndex), blendSettings[Mathf.Clamp(num3, 0, blendSettings.Count - 1)].GetRadius(normalizedIndex), Mathf.Clamp01(num * (float)blendSettings.Count - (float)num2));
		}
	}
	[BepInPlugin("1.Waga.JigglePhysicsPlugin", "JigglePhysicsPlugin", "1.1.2")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony;

		private static Plugin instance;

		private void Awake()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			instance = this;
			_harmony = new Harmony("JigglePhysicsPlugin");
			_harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"JigglePhysicsPlugin loaded!");
		}

		public static void Log(string message)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)message);
		}
	}
	public class PositionSignal
	{
		private struct Frame
		{
			public Vector3 position;

			public double time;
		}

		private Frame previousFrame;

		private Frame currentFrame;

		public PositionSignal(Vector3 startPosition, double time)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			currentFrame = (previousFrame = new Frame
			{
				position = startPosition,
				time = time
			});
		}

		public void SetPosition(Vector3 position, double time)
		{
			//IL_0018: 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)
			previousFrame = currentFrame;
			currentFrame = new Frame
			{
				position = position,
				time = time
			};
		}

		public void OffsetSignal(Vector3 offset)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			previousFrame = new Frame
			{
				position = previousFrame.position + offset,
				time = previousFrame.time
			};
			currentFrame = new Frame
			{
				position = currentFrame.position + offset,
				time = previousFrame.time
			};
		}

		public void FlattenSignal(double time, Vector3 position)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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)
			previousFrame = new Frame
			{
				position = position,
				time = time - (double)(JiggleRigBuilder.maxCatchupTime * 2f)
			};
			currentFrame = new Frame
			{
				position = position,
				time = time - (double)JiggleRigBuilder.maxCatchupTime
			};
		}

		public Vector3 GetCurrent()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return currentFrame.position;
		}

		public Vector3 GetPrevious()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return previousFrame.position;
		}

		public Vector3 SamplePosition(double time)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			double num = currentFrame.time - previousFrame.time;
			if (num == 0.0)
			{
				return previousFrame.position;
			}
			double num2 = (time - previousFrame.time) / num;
			return Vector3.Lerp(previousFrame.position, currentFrame.position, (float)num2);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "JigglePhysicsPlugin";

		public const string PLUGIN_NAME = "JigglePhysicsPlugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}