using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using DestinyScript; using FistVR; using H3MP; using H3MP.Scripts; using OtherLoader; using RootMotion; using RootMotion.FinalIK; using RootMotion1.FinalIK; using UnityEditor; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.Serialization; using UnityEngine.UI; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace JerryComponent { internal class AircraftSeat : FVRInteractiveObject { public static Dictionary currentSeat = new Dictionary(); public FVRViveHand hand; public GameObject SitPos; public GameObject EjectPos; public Transform _setPos; private FVRMovementManager _playerMovement; public bool isplayerrotated = false; public override void SimpleInteraction(FVRViveHand hand) { //IL_0075: 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_00d6: Unknown result type (might be due to invalid IL or missing references) ((FVRInteractiveObject)this).SimpleInteraction(hand); if (hand.IsThisTheRightHand) { hand = hand.OtherHand; } if ((Object)(object)this.hand == (Object)null) { if (currentSeat.ContainsKey(hand)) { currentSeat[hand].RemoveHand(); } currentSeat.Add(hand, this); this.hand = hand; hand.MovementManager.TeleportToPoint(SitPos.transform.position, false, SitPos.transform.localEulerAngles); } else if ((Object)(object)hand == (Object)(object)this.hand) { RemoveHand(); if ((Object)(object)EjectPos != (Object)null) { ((Component)hand.MovementManager).transform.position = EjectPos.transform.position; } } } private void Awake() { _playerMovement = Object.FindObjectOfType(); } public void Update() { //IL_0023: 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_0065: 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_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_00b6: 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) if ((Object)(object)hand != (Object)null) { if (Vector3.Distance(((Component)hand.MovementManager).transform.position, ((Component)this).transform.position) > 25f) { RemoveHand(); } ((Component)hand.MovementManager).transform.position = SitPos.transform.position; Vector3 eulerAngles = ((Component)hand.MovementManager).transform.eulerAngles; ((Component)hand.MovementManager).transform.eulerAngles = Vector3.Lerp(((Component)hand.MovementManager).transform.eulerAngles, eulerAngles, 0.2f * Time.deltaTime); PlayerForwardFollowSet(); isplayerrotated = true; if (GM.CurrentPlayerBody.GetPlayerHealth() <= 0f) { RemoveHand(); } if (((Component)hand.MovementManager).transform.position.y < GM.CurrentSceneSettings.CatchHeight) { RemoveHand(); } } } private void PlayerForwardFollowSet() { //IL_0017: 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_0031: Unknown result type (might be due to invalid IL or missing references) ((Component)_playerMovement).transform.rotation = Quaternion.RotateTowards(((Component)_playerMovement).transform.rotation, ((Component)_setPos).transform.rotation, 5f); } public void RemoveHand() { //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (currentSeat.ContainsKey(hand)) { currentSeat.Remove(hand); } hand = null; if (isplayerrotated) { ((Component)_playerMovement).transform.eulerAngles = new Vector3(0f, 0f, 0f); isplayerrotated = false; } } private void OnDestroy() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) ((Component)_playerMovement).transform.eulerAngles = new Vector3(0f, 0f, 0f); } } public class Blink : MonoBehaviour { public SkinnedMeshRenderer skin; private float blendOne = 0f; private float blendSpeed = 100f; private bool blinked; private float nextTime; private float rate = 5f; private void Start() { ((MonoBehaviour)this).InvokeRepeating("blinkeyes25", 5.02f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes50", 5.04f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes75", 5.06f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes100", 5.08f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes0", 5.1f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes25", 5.12f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes50", 5.14f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes75", 5.16f, 5f); } public void blinkeyes25() { skin.SetBlendShapeWeight(0, 25f); } public void blinkeyes50() { skin.SetBlendShapeWeight(0, 50f); } public void blinkeyes75() { skin.SetBlendShapeWeight(0, 75f); } public void blinkeyes100() { skin.SetBlendShapeWeight(0, 100f); } public void openeyes0() { skin.SetBlendShapeWeight(0, 75f); } public void openeyes25() { skin.SetBlendShapeWeight(0, 50f); } public void openeyes50() { skin.SetBlendShapeWeight(0, 25f); } public void openeyes75() { skin.SetBlendShapeWeight(0, 0f); } private void Update() { } } public class DeathCamera : MonoBehaviour { public bool spawned = true; public bool isdead = true; public GameObject cam; public GameObject cam2; public GameObject camholderpos; public GameObject camholderrot; private void Start() { cam.SetActive(false); spawned = true; } private void Update() { //IL_002e: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) if (isdead) { cam.SetActive(true); ((Component)GM.CurrentMovementManager).transform.eulerAngles = cam2.transform.eulerAngles; camholderpos.transform.localPosition = -((Component)GM.CurrentPlayerBody.Head).gameObject.transform.localPosition; spawned = false; } if (!isdead) { cam.SetActive(false); if (!spawned) { ((Component)GM.CurrentMovementManager).transform.position = GM.CurrentSceneSettings.DeathResetPoint.position; spawned = true; } ((Component)GM.CurrentMovementManager).transform.eulerAngles = new Vector3(0f, ((Component)GM.CurrentMovementManager).transform.eulerAngles.y, 0f); } } private void OnDestroy() { cam.SetActive(false); } } } namespace JerryLegsIK { public class FOOTIK : MonoBehaviour { private Animator _animator; public LayerMask _layerMask; private Ray _ray; public Vector3 footOffset; [Range(0f, 1f)] public float rightFootPosWeight = 1f; [Range(0f, 1f)] public float rightFootRotWeight = 1f; [Range(0f, 1f)] public float leftFootPosWeight = 1f; [Range(0f, 1f)] public float leftFootRotWeight = 1f; public bool isOnGround; private void Start() { _animator = ((Component)this).GetComponent(); } private void OnAnimatorIK(int layerIndex) { //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_000e: 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_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_0026: 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_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_0071: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) Vector3 iKPosition = _animator.GetIKPosition((AvatarIKGoal)1); RaycastHit val = default(RaycastHit); if (Physics.Raycast(iKPosition + Vector3.up, Vector3.down, ref val, 1.2f, LayerMask.op_Implicit(_layerMask))) { _animator.SetIKPositionWeight((AvatarIKGoal)1, rightFootPosWeight); _animator.SetIKPosition((AvatarIKGoal)1, ((RaycastHit)(ref val)).point + footOffset); Quaternion val2 = Quaternion.LookRotation(Vector3.ProjectOnPlane(((Component)this).transform.forward, ((RaycastHit)(ref val)).normal), ((RaycastHit)(ref val)).normal); _animator.SetIKRotationWeight((AvatarIKGoal)1, rightFootRotWeight); _animator.SetIKRotation((AvatarIKGoal)1, val2); isOnGround = true; } else { _animator.SetIKPositionWeight((AvatarIKGoal)1, 0f); isOnGround = false; } Vector3 iKPosition2 = _animator.GetIKPosition((AvatarIKGoal)0); if (Physics.Raycast(iKPosition2 + Vector3.up, Vector3.down, ref val, 1.2f, LayerMask.op_Implicit(_layerMask))) { _animator.SetIKPositionWeight((AvatarIKGoal)0, leftFootPosWeight); _animator.SetIKPosition((AvatarIKGoal)0, ((RaycastHit)(ref val)).point + footOffset); Quaternion val3 = Quaternion.LookRotation(Vector3.ProjectOnPlane(((Component)this).transform.forward, ((RaycastHit)(ref val)).normal), ((RaycastHit)(ref val)).normal); _animator.SetIKRotationWeight((AvatarIKGoal)0, leftFootPosWeight); _animator.SetIKRotation((AvatarIKGoal)0, val3); } else { _animator.SetIKPositionWeight((AvatarIKGoal)0, 0f); } } } } namespace JerryComponent { public class FacialExpressionCustom : MonoBehaviour { public SkinnedMeshRenderer skin; public GameObject fecube; public int num; private float blendOne = 0f; private float blendSpeed = 100f; private bool blinked; private float nextTime; private float rate = 5f; private void Start() { ((MonoBehaviour)this).InvokeRepeating("blinkeyes25", 5.02f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes50", 5.04f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes75", 5.06f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes100", 5.08f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes0", 5.1f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes25", 5.12f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes50", 5.14f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes75", 5.16f, 5f); } public void blinkeyes25() { skin.SetBlendShapeWeight(num, 25f); } public void blinkeyes50() { skin.SetBlendShapeWeight(num, 50f); } public void blinkeyes75() { skin.SetBlendShapeWeight(num, 75f); } public void blinkeyes100() { skin.SetBlendShapeWeight(num, 100f); } public void openeyes0() { skin.SetBlendShapeWeight(num, 75f); } public void openeyes25() { skin.SetBlendShapeWeight(num, 50f); } public void openeyes50() { skin.SetBlendShapeWeight(num, 25f); } public void openeyes75() { skin.SetBlendShapeWeight(num, 0f); } private void Update() { //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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_028a: 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_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: 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_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: 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_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0571: Unknown result type (might be due to invalid IL or missing references) //IL_0514: 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_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_0663: Unknown result type (might be due to invalid IL or missing references) //IL_0668: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_06e0: Unknown result type (might be due to invalid IL or missing references) //IL_06e5: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) //IL_068b: 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_0703: Unknown result type (might be due to invalid IL or missing references) //IL_0708: Unknown result type (might be due to invalid IL or missing references) //IL_07dc: Unknown result type (might be due to invalid IL or missing references) //IL_07e1: Unknown result type (might be due to invalid IL or missing references) //IL_0781: Unknown result type (might be due to invalid IL or missing references) //IL_0786: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_085f: Unknown result type (might be due to invalid IL or missing references) //IL_07ff: Unknown result type (might be due to invalid IL or missing references) //IL_0804: Unknown result type (might be due to invalid IL or missing references) //IL_08d8: Unknown result type (might be due to invalid IL or missing references) //IL_08dd: Unknown result type (might be due to invalid IL or missing references) //IL_087d: Unknown result type (might be due to invalid IL or missing references) //IL_0882: Unknown result type (might be due to invalid IL or missing references) //IL_0956: Unknown result type (might be due to invalid IL or missing references) //IL_095b: Unknown result type (might be due to invalid IL or missing references) //IL_08fb: Unknown result type (might be due to invalid IL or missing references) //IL_0900: Unknown result type (might be due to invalid IL or missing references) //IL_09d4: Unknown result type (might be due to invalid IL or missing references) //IL_09d9: Unknown result type (might be due to invalid IL or missing references) //IL_0979: Unknown result type (might be due to invalid IL or missing references) //IL_097e: Unknown result type (might be due to invalid IL or missing references) //IL_0a52: Unknown result type (might be due to invalid IL or missing references) //IL_0a57: Unknown result type (might be due to invalid IL or missing references) //IL_09f7: Unknown result type (might be due to invalid IL or missing references) //IL_09fc: Unknown result type (might be due to invalid IL or missing references) //IL_0ad0: Unknown result type (might be due to invalid IL or missing references) //IL_0ad5: Unknown result type (might be due to invalid IL or missing references) //IL_0a75: Unknown result type (might be due to invalid IL or missing references) //IL_0a7a: Unknown result type (might be due to invalid IL or missing references) //IL_0b4e: Unknown result type (might be due to invalid IL or missing references) //IL_0b53: Unknown result type (might be due to invalid IL or missing references) //IL_0af3: Unknown result type (might be due to invalid IL or missing references) //IL_0af8: Unknown result type (might be due to invalid IL or missing references) //IL_0bcc: Unknown result type (might be due to invalid IL or missing references) //IL_0bd1: Unknown result type (might be due to invalid IL or missing references) //IL_0b71: Unknown result type (might be due to invalid IL or missing references) //IL_0b76: Unknown result type (might be due to invalid IL or missing references) //IL_0c4a: Unknown result type (might be due to invalid IL or missing references) //IL_0c4f: Unknown result type (might be due to invalid IL or missing references) //IL_0bef: Unknown result type (might be due to invalid IL or missing references) //IL_0bf4: Unknown result type (might be due to invalid IL or missing references) //IL_0cc8: Unknown result type (might be due to invalid IL or missing references) //IL_0ccd: Unknown result type (might be due to invalid IL or missing references) //IL_0c6d: Unknown result type (might be due to invalid IL or missing references) //IL_0c72: Unknown result type (might be due to invalid IL or missing references) //IL_0d46: Unknown result type (might be due to invalid IL or missing references) //IL_0d4b: Unknown result type (might be due to invalid IL or missing references) //IL_0ceb: Unknown result type (might be due to invalid IL or missing references) //IL_0cf0: Unknown result type (might be due to invalid IL or missing references) //IL_0dc4: Unknown result type (might be due to invalid IL or missing references) //IL_0dc9: Unknown result type (might be due to invalid IL or missing references) //IL_0d69: Unknown result type (might be due to invalid IL or missing references) //IL_0d6e: Unknown result type (might be due to invalid IL or missing references) //IL_0de7: Unknown result type (might be due to invalid IL or missing references) //IL_0dec: Unknown result type (might be due to invalid IL or missing references) if (fecube.transform.localEulerAngles.x < 0.5f) { skin.SetBlendShapeWeight(0, 0f); skin.SetBlendShapeWeight(1, 0f); skin.SetBlendShapeWeight(2, 0f); skin.SetBlendShapeWeight(3, 0f); skin.SetBlendShapeWeight(4, 0f); skin.SetBlendShapeWeight(5, 0f); skin.SetBlendShapeWeight(6, 0f); skin.SetBlendShapeWeight(7, 0f); skin.SetBlendShapeWeight(8, 0f); skin.SetBlendShapeWeight(9, 0f); skin.SetBlendShapeWeight(10, 0f); skin.SetBlendShapeWeight(11, 0f); skin.SetBlendShapeWeight(12, 0f); skin.SetBlendShapeWeight(13, 0f); skin.SetBlendShapeWeight(14, 0f); skin.SetBlendShapeWeight(15, 0f); skin.SetBlendShapeWeight(16, 0f); skin.SetBlendShapeWeight(17, 0f); skin.SetBlendShapeWeight(18, 0f); skin.SetBlendShapeWeight(19, 0f); skin.SetBlendShapeWeight(20, 0f); skin.SetBlendShapeWeight(21, 0f); skin.SetBlendShapeWeight(22, 0f); skin.SetBlendShapeWeight(23, 0f); skin.SetBlendShapeWeight(24, 0f); } if (fecube.transform.localEulerAngles.x > 0.5f) { skin.SetBlendShapeWeight(num, 0f); if (fecube.transform.localEulerAngles.x > 0.5f && fecube.transform.localEulerAngles.x < 1.5f) { skin.SetBlendShapeWeight(0, 100f); skin.SetBlendShapeWeight(1, 0f); } if (fecube.transform.localEulerAngles.x > 1.5f && fecube.transform.localEulerAngles.x < 2.5f) { skin.SetBlendShapeWeight(0, 0f); skin.SetBlendShapeWeight(1, 100f); skin.SetBlendShapeWeight(2, 0f); } if (fecube.transform.localEulerAngles.x > 2.5f && fecube.transform.localEulerAngles.x < 3.5f) { skin.SetBlendShapeWeight(1, 0f); skin.SetBlendShapeWeight(2, 100f); skin.SetBlendShapeWeight(3, 0f); } if (fecube.transform.localEulerAngles.x > 3.5f && fecube.transform.localEulerAngles.x < 4.5f) { skin.SetBlendShapeWeight(2, 0f); skin.SetBlendShapeWeight(3, 100f); skin.SetBlendShapeWeight(4, 0f); } if (fecube.transform.localEulerAngles.x > 4.5f && fecube.transform.localEulerAngles.x < 5.5f) { skin.SetBlendShapeWeight(3, 0f); skin.SetBlendShapeWeight(4, 100f); skin.SetBlendShapeWeight(5, 0f); } if (fecube.transform.localEulerAngles.x > 5.5f && fecube.transform.localEulerAngles.x < 6.5f) { skin.SetBlendShapeWeight(4, 0f); skin.SetBlendShapeWeight(5, 100f); skin.SetBlendShapeWeight(6, 0f); } if (fecube.transform.localEulerAngles.x > 6.5f && fecube.transform.localEulerAngles.x < 7.5f) { skin.SetBlendShapeWeight(5, 0f); skin.SetBlendShapeWeight(6, 100f); skin.SetBlendShapeWeight(7, 0f); } if (fecube.transform.localEulerAngles.x > 7.5f && fecube.transform.localEulerAngles.x < 8.5f) { skin.SetBlendShapeWeight(6, 0f); skin.SetBlendShapeWeight(7, 100f); skin.SetBlendShapeWeight(8, 0f); } if (fecube.transform.localEulerAngles.x > 8.5f && fecube.transform.localEulerAngles.x < 9.5f) { skin.SetBlendShapeWeight(7, 0f); skin.SetBlendShapeWeight(8, 100f); skin.SetBlendShapeWeight(9, 0f); } if (fecube.transform.localEulerAngles.x > 9.5f && fecube.transform.localEulerAngles.x < 10.5f) { skin.SetBlendShapeWeight(8, 0f); skin.SetBlendShapeWeight(9, 100f); skin.SetBlendShapeWeight(10, 0f); } if (fecube.transform.localEulerAngles.x > 10.5f && fecube.transform.localEulerAngles.x < 11.5f) { skin.SetBlendShapeWeight(9, 0f); skin.SetBlendShapeWeight(10, 100f); skin.SetBlendShapeWeight(11, 0f); } if (fecube.transform.localEulerAngles.x > 11.5f && fecube.transform.localEulerAngles.x < 12.5f) { skin.SetBlendShapeWeight(10, 0f); skin.SetBlendShapeWeight(11, 100f); skin.SetBlendShapeWeight(12, 0f); } if (fecube.transform.localEulerAngles.x > 12.5f && fecube.transform.localEulerAngles.x < 13.5f) { skin.SetBlendShapeWeight(11, 0f); skin.SetBlendShapeWeight(12, 100f); skin.SetBlendShapeWeight(13, 0f); } if (fecube.transform.localEulerAngles.x > 13.5f && fecube.transform.localEulerAngles.x < 14.5f) { skin.SetBlendShapeWeight(12, 0f); skin.SetBlendShapeWeight(13, 100f); skin.SetBlendShapeWeight(14, 0f); } if (fecube.transform.localEulerAngles.x > 14.5f && fecube.transform.localEulerAngles.x < 15.5f) { skin.SetBlendShapeWeight(13, 0f); skin.SetBlendShapeWeight(14, 100f); skin.SetBlendShapeWeight(15, 0f); } if (fecube.transform.localEulerAngles.x > 15.5f && fecube.transform.localEulerAngles.x < 16.5f) { skin.SetBlendShapeWeight(14, 0f); skin.SetBlendShapeWeight(15, 100f); skin.SetBlendShapeWeight(16, 0f); } if (fecube.transform.localEulerAngles.x > 16.5f && fecube.transform.localEulerAngles.x < 17.5f) { skin.SetBlendShapeWeight(15, 0f); skin.SetBlendShapeWeight(16, 100f); skin.SetBlendShapeWeight(17, 0f); } if (fecube.transform.localEulerAngles.x > 17.5f && fecube.transform.localEulerAngles.x < 18.5f) { skin.SetBlendShapeWeight(16, 0f); skin.SetBlendShapeWeight(17, 100f); skin.SetBlendShapeWeight(18, 0f); } if (fecube.transform.localEulerAngles.x > 18.5f && fecube.transform.localEulerAngles.x < 19.5f) { skin.SetBlendShapeWeight(17, 0f); skin.SetBlendShapeWeight(18, 100f); skin.SetBlendShapeWeight(19, 0f); } if (fecube.transform.localEulerAngles.x > 19.5f && fecube.transform.localEulerAngles.x < 20.5f) { skin.SetBlendShapeWeight(18, 0f); skin.SetBlendShapeWeight(19, 100f); skin.SetBlendShapeWeight(20, 0f); } if (fecube.transform.localEulerAngles.x > 20.5f && fecube.transform.localEulerAngles.x < 21.5f) { skin.SetBlendShapeWeight(19, 0f); skin.SetBlendShapeWeight(20, 100f); skin.SetBlendShapeWeight(21, 0f); } if (fecube.transform.localEulerAngles.x > 21.5f && fecube.transform.localEulerAngles.x < 22.5f) { skin.SetBlendShapeWeight(20, 0f); skin.SetBlendShapeWeight(21, 100f); skin.SetBlendShapeWeight(22, 0f); } if (fecube.transform.localEulerAngles.x > 22.5f && fecube.transform.localEulerAngles.x < 23.5f) { skin.SetBlendShapeWeight(21, 0f); skin.SetBlendShapeWeight(22, 100f); skin.SetBlendShapeWeight(23, 0f); } if (fecube.transform.localEulerAngles.x > 23.5f && fecube.transform.localEulerAngles.x < 24.5f) { skin.SetBlendShapeWeight(22, 0f); skin.SetBlendShapeWeight(23, 100f); skin.SetBlendShapeWeight(24, 0f); } if (fecube.transform.localEulerAngles.x > 24.5f && fecube.transform.localEulerAngles.x < 25.5f) { skin.SetBlendShapeWeight(23, 0f); skin.SetBlendShapeWeight(24, 100f); skin.SetBlendShapeWeight(25, 0f); } } } } } namespace DestinyScript1 { public class HPR : MonoBehaviour { [Header("需要跟随VR设备的位置")] [Tooltip("(可选)头部的VR头显跟随与旋转位置")] public GameObject _head; public GameObject _neck; [Tooltip("双手跟随VR手柄的位置")] public Transform _ZuoShouWeiZhi; [Tooltip("双手跟随VR手柄的位置")] public Transform _YouShouWeiZhi; [Tooltip("(可选)VRIk脚本, 用来替换手部IK跟随位置")] public VRIK _VRIKCon; [Tooltip("(如果VRIK 为空 此处可以不添加)手部IK跟踪位置: 0 = VR手柄跟踪位, 1 = 武器抓握, 2 = 弹匣抓握, 3 = 护木抓握, 4 = 枪栓抓握,5 = 手枪滑套抓握, 6 = 子弹抓握, 7 = 手雷抓握, 8 = 手枪战术握法, 9 = 机枪机匣盖抓握位置")] public Transform[] _leftHandTarget; [Tooltip("(如果VRIK 为空 此处可以不添加)手部IK跟踪位置: 0 = VR手柄跟踪位, 1 = 武器抓握, 2 = 弹匣抓握, 3 = 护木抓握, 4 = 枪栓抓握,5 = 手枪滑套抓握, 6 = 子弹抓握, 7 = 手雷抓握, 8 = 手枪战术握法, 9 = 机枪机匣盖抓握位置")] public Transform[] _rightHandTarget; [Header("(可选)移动动画控制器")] public Animator playerAnime; [Header("(可选)左右手动画控制器")] public Animator leftHandAT; public Animator rightHandAT; [Header("移动动画float过渡条件名称")] public string AnimatorControllerName_X; public string AnimatorControllerName_Y; [Header("(如果左右手动画控制器为空 此处可以为空)动画bool过渡条件名称")] public string _gun; public string _mag; public string _grab; public string _bolt; public string _slide; public string _ammo; public string _trigger; public string _grenade; public string _HGCB; [Header("双手手指动画开关控制")] public AngryNoob_FingerTracking _leftFingerTraking; public AngryNoob_FingerTracking _ringtFingerTraking; public PlayerBody _h3mpbody; private GameObject _player; private FVRViveHand leftHand; private FVRViveHand rightHand; private FVRInteractiveObject _gameObejctOnHands; private bool _leftContinuousGrip = false; private bool _rightContinuousGrip = false; private bool _gripCut = false; private bool _fier; private void Awake() { _player = ((Component)Object.FindObjectOfType()).gameObject; } private void Start() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown GameManager.OnPlayerBodyInit += new OnPlayerBodyInitDelegate(OnPlayerBodyInit); if ((Object)(object)Mod.managerObject == (Object)null) { leftHand = ((Component)_player.transform.Find("Controller (left)")).GetComponent(); rightHand = ((Component)_player.transform.Find("Controller (right)")).GetComponent(); } else if ((Object)(object)GameManager.currentPlayerBody == (Object)(object)_h3mpbody) { leftHand = ((Component)_player.transform.Find("Controller (left)")).GetComponent(); rightHand = ((Component)_player.transform.Find("Controller (right)")).GetComponent(); } else { Object.Destroy((Object)(object)this); } } public void OnPlayerBodyInit(FVRPlayerBody playerBody) { leftHand = ((Component)playerBody.LeftHand).GetComponent(); rightHand = ((Component)playerBody.RightHand).GetComponent(); } private void Update() { if ((Object)(object)leftHand != (Object)null) { HandFollow(leftHand, rightHand, _leftFingerTraking, ref _leftContinuousGrip, leftHandAT, rightHandAT, _leftHandTarget, _ZuoShouWeiZhi); HandFollow(rightHand, leftHand, _ringtFingerTraking, ref _rightContinuousGrip, rightHandAT, leftHandAT, _rightHandTarget, _YouShouWeiZhi); if ((Object)(object)_head != (Object)null && (Object)(object)_neck != (Object)null) { HeadFollowPlayerBody(); } if ((Object)(object)playerAnime != (Object)null) { PlayerAnimC(); } } } private void HeadFollowPlayerBody() { //IL_0016: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) _head.transform.position = GM.CurrentPlayerBody.Head.position; _neck.transform.rotation = GM.CurrentPlayerBody.Head.rotation; if (leftHand.Input.Secondary2AxisInputAxes.x >= 0.01f || leftHand.Input.Secondary2AxisInputAxes.y >= 0.01f || rightHand.Input.Secondary2AxisInputAxes.x >= 0.01f || rightHand.Input.Secondary2AxisInputAxes.y >= 0.01f) { Vector3 forward = _head.transform.forward; forward.y = 0f; ((Component)this).transform.rotation = Quaternion.LookRotation(forward, Vector3.up); } } private void HandFollow(FVRViveHand _hands, FVRViveHand _otherHand, AngryNoob_FingerTracking _fingerT, ref bool _Grip, Animator _handAnimator, Animator _otherHandAnim, Transform[] _handTarget, Transform _handPos) { //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_hands.CurrentInteractable != (Object)null) { _gameObejctOnHands = ((Component)_hands.CurrentInteractable).GetComponent(); _fingerT._handGrap = true; if ((Object)(object)_gameObejctOnHands.PoseOverride_Touch == (Object)null && _hands.m_timeGripButtonHasBeenHeld > 0f && !_Grip) { _Grip = true; } if ((Object)(object)_handAnimator != (Object)null) { HandsAnimationControll(_handAnimator, _otherHandAnim, _handTarget, _hands, _otherHand); } if ((Object)(object)_gameObejctOnHands.PoseOverride_Touch != (Object)null && !_Grip) { _handPos.position = _gameObejctOnHands.PoseOverride_Touch.position; _handPos.rotation = _gameObejctOnHands.PoseOverride_Touch.rotation; } else if ((Object)(object)_gameObejctOnHands.PoseOverride_Touch != (Object)null && _Grip) { _handPos.position = ((Component)_hands).transform.position; _handPos.rotation = ((Component)_hands).transform.rotation; } else if (HandAnimControll(_otherHand) == 2 || HandAnimControll(_otherHand) == 9) { _handPos.position = ((Component)_hands.CurrentInteractable).gameObject.transform.position; _handPos.rotation = ((Component)_hands.CurrentInteractable).gameObject.transform.rotation; } else { _handPos.position = ((Component)_hands.CurrentInteractable).gameObject.transform.position; _handPos.rotation = ((Component)_hands).transform.rotation; } return; } if ((Object)(object)_otherHand.CurrentInteractable != (Object)null && (Object)(object)_hands.CurrentInteractable == (Object)null && DoubleHandMasturbating(_otherHand)) { _fingerT._handGrap = true; return; } _gameObejctOnHands = null; if ((Object)(object)_handAnimator != (Object)null) { _handAnimator.SetBool(_gun, false); _handAnimator.SetBool(_bolt, false); _handAnimator.SetBool(_grab, false); _handAnimator.SetBool(_mag, false); _handAnimator.SetBool(_slide, false); _handAnimator.SetBool(_ammo, false); _handAnimator.SetBool(_grenade, false); _handAnimator.SetBool(_trigger, false); _handAnimator.SetBool(_HGCB, false); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hands).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.leftArm.target = _handTarget[0]; } else { _VRIKCon.solver.rightArm.target = _handTarget[0]; } } _fingerT._handGrap = false; _Grip = false; _handPos.position = ((Component)_hands).transform.position; _handPos.rotation = ((Component)_hands).transform.rotation; } private void HandsAnimationControll(Animator _handAnimator, Animator _otherHandAnim, Transform[] _handFollowPos, FVRViveHand _hand, FVRViveHand _otherHand) { switch (HandAnimControll(_otherHand)) { case 1: _handAnimator.SetBool(_gun, false); _handAnimator.SetBool(_trigger, false); _handAnimator.SetBool(_grenade, false); _handAnimator.SetBool(_grab, false); _handAnimator.SetBool(_HGCB, false); _handAnimator.SetBool(_bolt, false); _handAnimator.SetBool(_slide, false); _handAnimator.SetBool(_ammo, false); _handAnimator.SetBool(_mag, true); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hand).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.leftArm.target = _handFollowPos[2]; } else { _VRIKCon.solver.rightArm.target = _handFollowPos[2]; } break; case 2: _handAnimator.SetBool(_mag, false); _handAnimator.SetBool(_trigger, false); _handAnimator.SetBool(_grenade, false); _handAnimator.SetBool(_HGCB, false); _handAnimator.SetBool(_bolt, false); _handAnimator.SetBool(_gun, false); _handAnimator.SetBool(_slide, false); _handAnimator.SetBool(_ammo, false); _handAnimator.SetBool(_grab, true); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hand).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.leftArm.target = _handFollowPos[3]; } else { _VRIKCon.solver.rightArm.target = _handFollowPos[3]; } break; case 3: _handAnimator.SetBool(_mag, false); _handAnimator.SetBool(_grenade, false); _handAnimator.SetBool(_HGCB, false); _handAnimator.SetBool(_bolt, false); _handAnimator.SetBool(_grab, false); _handAnimator.SetBool(_slide, false); _handAnimator.SetBool(_ammo, false); _handAnimator.SetBool(_gun, true); _handAnimator.SetBool(_trigger, HandGunFier(_hand)); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hand).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.leftArm.target = _handFollowPos[1]; } else { _VRIKCon.solver.rightArm.target = _handFollowPos[1]; } break; case 4: _handAnimator.SetBool(_mag, false); _handAnimator.SetBool(_trigger, false); _handAnimator.SetBool(_grenade, false); _handAnimator.SetBool(_HGCB, false); _handAnimator.SetBool(_grab, false); _handAnimator.SetBool(_gun, false); _handAnimator.SetBool(_slide, false); _handAnimator.SetBool(_ammo, false); _handAnimator.SetBool(_bolt, true); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hand).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.leftArm.target = _handFollowPos[1]; } else { _VRIKCon.solver.rightArm.target = _handFollowPos[1]; } break; case 5: _handAnimator.SetBool(_mag, false); _handAnimator.SetBool(_trigger, false); _handAnimator.SetBool(_HGCB, false); _handAnimator.SetBool(_grenade, false); _handAnimator.SetBool(_grab, false); _handAnimator.SetBool(_gun, false); _handAnimator.SetBool(_bolt, false); _handAnimator.SetBool(_ammo, false); _handAnimator.SetBool(_slide, true); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hand).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.leftArm.target = _handFollowPos[5]; } else { _VRIKCon.solver.rightArm.target = _handFollowPos[5]; } break; case 6: _handAnimator.SetBool(_ammo, false); _handAnimator.SetBool(_trigger, false); _handAnimator.SetBool(_HGCB, false); _handAnimator.SetBool(_grenade, false); _handAnimator.SetBool(_grab, false); _handAnimator.SetBool(_gun, false); _handAnimator.SetBool(_slide, false); _handAnimator.SetBool(_bolt, false); _handAnimator.SetBool(_mag, true); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hand).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.leftArm.target = _handFollowPos[2]; } else { _VRIKCon.solver.rightArm.target = _handFollowPos[2]; } break; case 7: _handAnimator.SetBool(_ammo, false); _handAnimator.SetBool(_HGCB, false); _handAnimator.SetBool(_trigger, false); _handAnimator.SetBool(_grab, false); _handAnimator.SetBool(_gun, false); _handAnimator.SetBool(_slide, false); _handAnimator.SetBool(_bolt, false); _handAnimator.SetBool(_mag, false); _handAnimator.SetBool(_grenade, true); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hand).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.leftArm.target = _handFollowPos[7]; } else { _VRIKCon.solver.rightArm.target = _handFollowPos[7]; } break; case 8: _otherHandAnim.SetBool(_ammo, false); _handAnimator.SetBool(_trigger, HandGunFier(_hand)); _otherHandAnim.SetBool(_trigger, false); _otherHandAnim.SetBool(_grab, false); _otherHandAnim.SetBool(_gun, false); _otherHandAnim.SetBool(_slide, false); _otherHandAnim.SetBool(_bolt, false); _otherHandAnim.SetBool(_mag, false); _otherHandAnim.SetBool(_grenade, false); _otherHandAnim.SetBool(_HGCB, true); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hand).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.rightArm.target = _handFollowPos[8]; } else { _VRIKCon.solver.leftArm.target = _handFollowPos[8]; } break; case 9: _handAnimator.SetBool(_ammo, false); _handAnimator.SetBool(_HGCB, false); _handAnimator.SetBool(_trigger, false); _handAnimator.SetBool(_grab, false); _handAnimator.SetBool(_gun, false); _handAnimator.SetBool(_slide, false); _handAnimator.SetBool(_bolt, false); _handAnimator.SetBool(_grenade, false); _handAnimator.SetBool(_mag, true); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hand).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.leftArm.target = _handFollowPos[9]; } else { _VRIKCon.solver.rightArm.target = _handFollowPos[9]; } break; default: _handAnimator.SetBool(_gun, false); _handAnimator.SetBool(_trigger, false); _handAnimator.SetBool(_grenade, false); _handAnimator.SetBool(_bolt, false); _handAnimator.SetBool(_grab, false); _handAnimator.SetBool(_slide, false); _handAnimator.SetBool(_ammo, false); _handAnimator.SetBool(_gun, true); if ((Object)(object)_VRIKCon != (Object)null && ((Object)((Component)_hand).transform).name == ((Object)((Component)leftHand).transform).name) { _VRIKCon.solver.leftArm.target = _handFollowPos[1]; } else { _VRIKCon.solver.rightArm.target = _handFollowPos[1]; } break; } } private int HandAnimControll(FVRViveHand _otherHand) { int result = 1; if (typeof(FVRFireArm).IsAssignableFrom(((object)_gameObejctOnHands).GetType())) { result = 3; } if (typeof(FVRFireArm).IsAssignableFrom(((object)_gameObejctOnHands).GetType()) && DoubleHandMasturbating(_otherHand) && (Object)(object)_otherHand.CurrentInteractable == (Object)null) { result = 8; } if ((object)typeof(FVRFireArmMagazine) == ((object)_gameObejctOnHands).GetType()) { result = 1; } if ((object)typeof(ClosedBoltHandle) == ((object)_gameObejctOnHands).GetType() || (object)typeof(ClosedBolt) == ((object)_gameObejctOnHands).GetType() || (object)typeof(BoltActionRifle_Handle) == ((object)_gameObejctOnHands).GetType() || (object)typeof(OpenBoltChargingHandle) == ((object)_gameObejctOnHands).GetType() || (object)typeof(OpenBoltReceiverBolt) == ((object)_gameObejctOnHands).GetType()) { result = 4; } if ((object)typeof(FVRAlternateGrip) == ((object)_gameObejctOnHands).GetType() || (object)typeof(TubeFedShotgunHandle) == ((object)_gameObejctOnHands).GetType()) { result = 2; } if ((object)typeof(FVRFireArmRound) == ((object)_gameObejctOnHands).GetType()) { result = 6; } if ((object)typeof(HandgunSlide) == ((object)_gameObejctOnHands).GetType()) { result = 5; } if ((object)typeof(PinnedGrenade) == ((object)_gameObejctOnHands).GetType() || (object)typeof(FVRCappedGrenade) == ((object)_gameObejctOnHands).GetType()) { result = 7; } if ((object)typeof(FVRFireArmTopCover) == ((object)_gameObejctOnHands).GetType()) { result = 9; } return result; } private bool HandGunFier(FVRViveHand _hand) { if (_hand.Input.TriggerFloat >= 0.7f) { _fier = true; } else { _fier = false; } return _fier; } private bool DoubleHandMasturbating(FVRViveHand _otherHand) { if (HandsDistance() <= 0.15f && (Object)(object)_otherHand.CurrentInteractable == (Object)null && _otherHand.Input.TriggerDown) { _gripCut = !_gripCut; } if (HandsDistance() > 0.22f) { _gripCut = false; } return _gripCut; } private float HandsDistance() { //IL_000b: 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) return Vector3.Distance(GM.CurrentMovementManager.LeftHand.position, GM.CurrentMovementManager.RightHand.position); } private void PlayerAnimC() { playerAnime.SetFloat(AnimatorControllerName_X, leftHand.Input.Secondary2AxisInputAxes.x); playerAnime.SetFloat(AnimatorControllerName_Y, leftHand.Input.Secondary2AxisInputAxes.y); } public void OnDestroy() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown GameManager.OnPlayerBodyInit -= new OnPlayerBodyInitDelegate(OnPlayerBodyInit); } } } namespace JerryComponent { public class IKMoving : MonoBehaviour { public Animator _MovementIK; public GameObject LR; public GameObject LR2; public float smooth = 0.28f; public float smooth2 = 0.3f; private void Start() { } private void Update() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) if (_MovementIK.GetBool("IsMoving")) { LR.transform.localPosition = new Vector3(0f, 0f, _MovementIK.GetFloat("D_Y") * smooth); LR2.transform.localPosition = new Vector3(_MovementIK.GetFloat("D_X") * smooth, 0f, 0f); LR2.transform.localScale = new Vector3(0.3f, 1f, 1f); } else if (!_MovementIK.GetBool("IsMoving")) { LR.transform.localPosition = new Vector3(0f, 0f, 0f); LR2.transform.localPosition = new Vector3(0f, 0f, 0f); LR2.transform.localScale = new Vector3(1f, 1f, 1f); } } } } namespace JerryLegsIK { public class Jump : MonoBehaviour { public Animator animatorjump; public FOOTIK footjump; public bool isJumppin; private void Start() { animatorjump = ((Component)this).GetComponent(); } private void Update() { if (!footjump.isOnGround) { animatorjump.SetBool("IsJumping", true); animatorjump.updateMode = (AnimatorUpdateMode)0; isJumppin = true; } if (footjump.isOnGround) { animatorjump.SetBool("IsJumping", false); animatorjump.updateMode = (AnimatorUpdateMode)1; isJumppin = false; } } } public class Kick : MonoBehaviour { public GameObject RotKick; public Animator _AnimateK; public Transform _KHandL; public Transform _KHandR; private Vector3 previousposL; private Vector3 previousposR; private Vector3 nextposL; private Vector3 nextposR; public float speedL; public float speedR; private float timer = 0f; private void Start() { } private void Update() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00ad: 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) previousposL = _KHandL.localPosition; previousposR = _KHandR.localPosition; speedL = Vector3.Magnitude(previousposL - nextposL) / Time.deltaTime; speedR = Vector3.Magnitude(previousposR - nextposR) / Time.deltaTime; nextposL = previousposL; nextposR = previousposR; timer += Time.deltaTime; if (timer >= 3f && RotKick.transform.localEulerAngles.x >= 45f && speedL >= 4f && speedR >= 4f) { _AnimateK.SetTrigger("Kick2"); timer = 0f; Debug.Log((object)"is kicking"); } } } } namespace JerryComponent { public class MouthSyncing : MonoBehaviour { private AudioClip micRecord; private string device; public SkinnedMeshRenderer smr; public int mopen; private string microphoneName; private float mouthClosedV = 0.0011f; private float smileFrownV = 0.0701f; private float partialOpenV = 0.0201f; private float normalOpenv = 0.0301f; private int pitchSwap = 1; private float lastActiveTime; private float lastChosenMouth; private float talkDuration = 0.05f; private float silenceDuration = 0.25f; private void Awake() { lastChosenMouth = Time.deltaTime; InitializeMicrophone(); } private void Start() { } private void InitializeMicrophone() { string[] devices = Microphone.devices; foreach (string text in devices) { Debug.Log((object)("Microphone detected: " + text)); } if (Microphone.devices.Length != 0) { microphoneName = Microphone.devices[0]; micRecord = Microphone.Start(microphoneName, true, 1, 44100); } else { Debug.Log((object)"No microphones detected at all!"); } } private void Update() { if ((Object)(object)smr == (Object)null) { return; } if (Microphone.IsRecording(microphoneName)) { float[] array = new float[16]; micRecord.GetData(array, Microphone.GetPosition(microphoneName)); float num = 0f; int num2 = 0; for (int i = 1; i < array.Length; i++) { num += Mathf.Abs(array[i]); if (array[i - 1] < 0f && array[i] > 0f) { num2++; } } num /= (float)array.Length; float num3 = num2; if (num < mouthClosedV) { smr.SetBlendShapeWeight(mopen, 0f); } else if (num < partialOpenV) { smr.SetBlendShapeWeight(mopen, 20f); } else if (num < normalOpenv) { smr.SetBlendShapeWeight(mopen, 40f); } else { smr.SetBlendShapeWeight(mopen, 60f); } lastActiveTime = Time.time; if (Time.time - lastChosenMouth > talkDuration) { lastChosenMouth = Time.time; } } if (Time.time - lastActiveTime > silenceDuration) { smr.SetBlendShapeWeight(mopen, 0f); } } } public class NeckRot : MonoBehaviour { public GameObject Geo; public WaggleJoint WJ; private void Start() { } private void Update() { //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_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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) if (Geo.transform.localEulerAngles.x < 10f || Geo.transform.localEulerAngles.x > 350f) { WJ.springApproachRate = 0.05f; } else if ((Geo.transform.localEulerAngles.x > 10f && Geo.transform.localEulerAngles.x < 15f) || (Geo.transform.localEulerAngles.x < 350f && Geo.transform.localEulerAngles.x > 345f)) { WJ.springApproachRate = 0.5f; } else if ((Geo.transform.localEulerAngles.x > 15f && Geo.transform.localEulerAngles.x < 180f) || (Geo.transform.localEulerAngles.x < 345f && Geo.transform.localEulerAngles.x > 180f)) { WJ.springApproachRate = 0.99f; } } } public class PassOut : MonoBehaviour { private GM gm; public SkinnedMeshRenderer skin; public int mouth2; public int eye3; public int eye2; private void Start() { gm = GameObject.Find("_GameManager(Clone)").GetComponent(); } private void Update() { if (Time.frameCount % 30 == 0) { PassedOut(); Wake(); } } public void PassedOut() { float blendShapeWeight = skin.GetBlendShapeWeight(eye3); if (gm.m_isDead && blendShapeWeight == 0f) { skin.SetBlendShapeWeight(eye2, 100f); skin.SetBlendShapeWeight(mouth2, 50f); } } public void Wake() { if (!gm.m_isDead) { skin.SetBlendShapeWeight(eye2, 0f); skin.SetBlendShapeWeight(mouth2, 0f); } } } public class PlayerCrouch : MonoBehaviour { public GameObject crouch; [SerializeField] private Transform body; public Ray ray; public float rayLength; [SerializeField] private LayerMask terrainLayer; public float rayStartYOffset = 0f; public float rayMul; public float dis; public RaycastHit rayhit; private void Start() { } private void Update() { //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_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_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_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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) ray = new Ray(body.position + Vector3.up * rayStartYOffset, Vector3.down); Physics.Raycast(ray, ref rayhit, rayLength, ((LayerMask)(ref terrainLayer)).value); if (((RaycastHit)(ref rayhit)).distance > 0.6f) { dis = 0.6f * rayMul; crouch.transform.localEulerAngles = new Vector3(dis, 0f, 0f); } else { dis = ((RaycastHit)(ref rayhit)).distance * rayMul; crouch.transform.localEulerAngles = new Vector3(dis, 0f, 0f); } if (crouch.transform.localEulerAngles.x > 60f) { crouch.transform.localEulerAngles = new Vector3(60f, 0f, 0f); } else if (crouch.transform.localEulerAngles.x < 0f) { crouch.transform.localEulerAngles = new Vector3(0f, 0f, 0f); } } } public class RotateAlong : MonoBehaviour { public GameObject rotGeo; public GameObject alongGeo; private void Start() { } private void Update() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) alongGeo.transform.eulerAngles = rotGeo.transform.eulerAngles; } } public class SnapToPoint : MonoBehaviour { public Transform pointSpapTo; private void Start() { } private void Update() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)pointSpapTo != (Object)null) { ((Component)this).gameObject.transform.position = ((Component)pointSpapTo).transform.position; ((Component)this).gameObject.transform.eulerAngles = ((Component)pointSpapTo).transform.eulerAngles; } } } public class SnapToPointRigidbody : MonoBehaviour { public Transform snapTo; [NonSerialized] private Rigidbody body; public float snapTime = 2f; [NonSerialized] private float dropTimer; public void Start() { body = ((Component)this).GetComponent(); } public void FixedUpdate() { //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_00ae: 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_006b: 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_00f6: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) dropTimer += Time.deltaTime / (snapTime / 2f); body.isKinematic = dropTimer > 1f; if (dropTimer > 1f) { ((Component)this).transform.position = snapTo.position; ((Component)this).transform.rotation = snapTo.rotation; return; } float num = Mathf.Pow(35f, dropTimer); body.velocity = Vector3.Lerp(body.velocity, Vector3.zero, Time.fixedDeltaTime * 4f); if (body.useGravity) { body.AddForce(-Physics.gravity); } ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, snapTo.position, Time.fixedDeltaTime * num * 3f); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, snapTo.rotation, Time.fixedDeltaTime * num * 2f); } } public class TakingDamage : MonoBehaviour { private ParticleSystem ps; private FVRPlayerBody pbh; public SkinnedMeshRenderer skin; public int num; public int eye2; public int mouth; public int mouth2; public int eye3; private void Start() { ps = GameObject.Find("DamagePSystemLight").GetComponent(); pbh = GameObject.Find("[CameraRig]Fixed").GetComponent(); } private void Update() { if (Time.frameCount % 10 == 0) { Blinkeyes100(); Openeyes75(); } } private void Blinkeyes100() { if ((float)ps.particleCount > 0f) { skin.SetBlendShapeWeight(eye3, 0f); skin.SetBlendShapeWeight(num, 100f); skin.SetBlendShapeWeight(mouth, 50f); } } public void Openeyes75() { if ((float)ps.particleCount <= 0f) { skin.SetBlendShapeWeight(num, 0f); skin.SetBlendShapeWeight(mouth, 0f); } } } } namespace JerryLegsIK { public class VRMAP : MonoBehaviour { public Transform vrTarget; public Transform rigTarget; public Vector3 trackingPositionOffset; public Vector3 trackingRotationOffset; public void Map() { //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_0029: 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_0039: Unknown result type (might be due to invalid IL or missing references) rigTarget.position = vrTarget.TransformPoint(trackingPositionOffset); rigTarget.rotation = vrTarget.rotation * Quaternion.Euler(trackingRotationOffset); } private void Start() { } private void Update() { } } public class VRRIG : MonoBehaviour { public VRMAP head; public Transform headConstraint; public Vector3 headBodyOffset; private void Start() { //IL_0008: 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_001d: Unknown result type (might be due to invalid IL or missing references) headBodyOffset = ((Component)this).transform.position - headConstraint.position; } private void Update() { //IL_000d: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.position = headConstraint.position + headBodyOffset; Transform transform = ((Component)this).transform; Vector3 val = Vector3.ProjectOnPlane(headConstraint.up, Vector3.up); transform.forward = ((Vector3)(ref val)).normalized; head.Map(); } } public class VRanimatorcontroller : MonoBehaviour { public float speedTreshold = 0.1f; [Range(0f, 1f)] public float smoothing = 1f; private Animator animator; private Vector3 previouspos; private VRRIG vrRig; public Jump jumppin; private void Start() { //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) animator = ((Component)this).GetComponent(); vrRig = ((Component)this).GetComponent(); previouspos = vrRig.head.vrTarget.position; } private void Update() { //IL_0011: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_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_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) Vector3 val = (vrRig.head.vrTarget.position - previouspos) / Time.deltaTime; val.y = 0f; Vector3 val2 = ((Component)this).transform.InverseTransformDirection(val); previouspos = vrRig.head.vrTarget.position; float @float = animator.GetFloat("D_X"); float float2 = animator.GetFloat("D_Y"); animator.SetBool("IsMoving", ((Vector3)(ref val2)).magnitude > speedTreshold); animator.SetFloat("D_X", Mathf.Lerp(@float, Mathf.Clamp(val2.x, -99f, 99f), smoothing)); animator.SetFloat("D_Y", Mathf.Lerp(float2, Mathf.Clamp(val2.z, -99f, 99f), smoothing)); } } } namespace JerryComponent { public class control_component : MonoBehaviour { public GameObject Comp; public GameObject Comp2; public GameObject Rot; private void Start() { } private void Update() { //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) if (Rot.transform.localEulerAngles.x >= 45f) { Comp.SetActive(false); Comp2.SetActive(true); } else { Comp.SetActive(true); Comp2.SetActive(false); } } } public class controll_component : MonoBehaviour { public GameObject Comp; public GameObject Rot; private void Start() { } private void Update() { //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_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) if (Rot.transform.localEulerAngles.y > 10f && Rot.transform.localEulerAngles.y < -10f) { Comp.SetActive(false); } else { Comp.SetActive(true); } } } } public class CameraController : MonoBehaviour { public GameObject mTarget; public Vector3 mDistance; public float mSpeed = 5f; private void Update() { //IL_0017: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) ((Component)((Component)this).GetComponent()).transform.LookAt(mTarget.transform.position); ((Component)((Component)this).GetComponent()).transform.position = ((Component)((Component)this).GetComponent()).transform.position + mSpeed * Time.deltaTime * (mTarget.transform.position + mDistance - ((Component)((Component)this).GetComponent()).transform.position); } } public class IdleUpdate : StateMachineBehaviour { private float mIdleRayCast = 0.5f; public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { ((Component)animator).GetComponent().DisablePlant((AvatarIKGoal)0, 2f); ((Component)animator).GetComponent().DisablePlant((AvatarIKGoal)1, 2f); } public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { FootPlacementData footPlacementData = ((Component)animator).GetComponents()[0]; FootPlacementData footPlacementData2 = ((Component)animator).GetComponents()[1]; if ((Object)(object)footPlacementData != (Object)null) { if (((AnimatorStateInfo)(ref stateInfo)).normalizedTime > 0.25f) { footPlacementData.mExtraRayDistanceCheck = mIdleRayCast; } else { footPlacementData.mExtraRayDistanceCheck = 0f; } } if ((Object)(object)footPlacementData2 != (Object)null) { if (((AnimatorStateInfo)(ref stateInfo)).normalizedTime > 0.25f) { footPlacementData2.mExtraRayDistanceCheck = mIdleRayCast; } else { footPlacementData2.mExtraRayDistanceCheck = 0f; } } } } public class InputController : MonoBehaviour { public float Speed = 4f; public float TurnSpeed = 1f; public Camera mCam; protected Vector3 mLeftVec = new Vector3(-1f, 0f, 0f); protected Vector3 mFwdVec = new Vector3(0f, 0f, 1f); protected Vector3 mGOFwdVec = new Vector3(0f, 0f, 1f); protected Animator mAnim; protected float mTimePassed = 0f; protected int mMove = Animator.StringToHash("move"); protected int mSpeed = Animator.StringToHash("speed"); protected bool mMecFPActive = true; protected GUIStyle mStyle; private void Start() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) mStyle = new GUIStyle(); mAnim = ((Component)this).GetComponent(); mStyle.normal.textColor = new Color(0.5f, 0f, 0.75f, 1f); mStyle.fontSize = 20; } private void OnGUI() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(0f, 0f, 100f, 100f), "Use W, A, S, D to move around\nPress R to activate/deactivate Mec Foot Placer\nHold L to run", mStyle); } private void Update() { //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_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_00b4: 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_00c4: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) Animator obj = mAnim; AnimatorStateInfo currentAnimatorStateInfo = mAnim.GetCurrentAnimatorStateInfo(0); float normalizedTime = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime; AnimatorStateInfo currentAnimatorStateInfo2 = mAnim.GetCurrentAnimatorStateInfo(0); obj.SetFloat("time", normalizedTime - Mathf.Floor(((AnimatorStateInfo)(ref currentAnimatorStateInfo2)).normalizedTime)); if (!Input.anyKey) { float @float = mAnim.GetFloat(mSpeed); @float -= 1.5f * Time.deltaTime; if (@float < 0f) { @float = 0f; mAnim.SetBool(mMove, false); } mAnim.SetFloat(mSpeed, @float); return; } bool flag = false; Vector3 val = ((Component)mCam).transform.rotation * mFwdVec; val.y = 0f; Vector3 val2 = ((Component)mCam).transform.rotation * mLeftVec; val2.y = 0f; mGOFwdVec = ((Component)this).gameObject.transform.rotation * new Vector3(0f, 0f, 1f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0f, 0f, 0f); float num = 1f; float num2 = 0f; if (Input.GetKey((KeyCode)97)) { val3 += val2; flag = true; } if (Input.GetKey((KeyCode)100)) { val3 -= val2; flag = true; } if (Input.GetKey((KeyCode)119)) { val3 += val; flag = true; } if (Input.GetKey((KeyCode)115)) { val3 -= val; flag = true; } if (Input.GetKey((KeyCode)108)) { float float2 = mAnim.GetFloat(mSpeed); if (flag) { float2 += Time.deltaTime; if (float2 > 1f) { float2 = 1f; } } else { float2 -= 2f * Time.deltaTime; if (float2 < 0f) { float2 = 0f; } } mAnim.SetFloat(mSpeed, float2); } else { float float3 = mAnim.GetFloat(mSpeed); float3 -= Time.deltaTime; if (float3 < 0f) { float3 = 0f; } mAnim.SetFloat(mSpeed, float3); } if (Input.GetKey((KeyCode)281) && mTimePassed > 0.1f) { Time.timeScale -= 0.1f; if (Time.timeScale < 0f) { Time.timeScale = 0f; } mTimePassed = 0f; Debug.Log((object)Time.timeScale); } if (Input.GetKey((KeyCode)280) && mTimePassed > 0.1f) { Time.timeScale += 0.1f; mTimePassed = 0f; Debug.Log((object)Time.timeScale); } if (Input.GetKeyDown((KeyCode)114)) { mMecFPActive = !mMecFPActive; ((Component)this).GetComponent().SetActive((AvatarIKGoal)0, mMecFPActive); ((Component)this).GetComponent().SetActive((AvatarIKGoal)1, mMecFPActive); } if (flag) { num = Vector3.Cross(mGOFwdVec, val3).y; if (num != 0f) { num /= Mathf.Abs(num); } num2 = Vector3.Angle(mGOFwdVec, val3); num2 *= TurnSpeed * Time.deltaTime; ((Component)this).gameObject.transform.Rotate(new Vector3(0f, num, 0f), num2, (Space)0); mAnim.SetBool(mMove, true); } else if (mAnim.GetFloat("speed") <= 0f) { mAnim.SetBool(mMove, false); } mTimePassed += Time.deltaTime; } } public class LocomotionUpdate : StateMachineBehaviour { public override void OnStateEnter(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { ((Component)animator).GetComponent().EnablePlant((AvatarIKGoal)0, 2f); ((Component)animator).GetComponent().EnablePlant((AvatarIKGoal)1, 2f); } public override void OnStateUpdate(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) { float @float = animator.GetFloat("speed"); float num = ((AnimatorStateInfo)(ref animatorStateInfo)).normalizedTime - Mathf.Floor(((AnimatorStateInfo)(ref animatorStateInfo)).normalizedTime); float num2 = 0.5f - 0.25f * @float; FootPlacementData[] components = ((Component)animator).GetComponents(); FootPlacementData footPlacementData = null; for (byte b = 0; b < components.Length; b++) { switch (components[b].mFootID) { case FootPlacementData.LimbID.LEFT_FOOT: footPlacementData = components[b]; if ((double)num > 0.5 && num < 0.5f + num2) { footPlacementData.mExtraRayDistanceCheck = 0.7f; } else { footPlacementData.mExtraRayDistanceCheck = -0.2f; } break; case FootPlacementData.LimbID.RIGHT_FOOT: footPlacementData = components[b]; if (num < num2) { footPlacementData.mExtraRayDistanceCheck = 0.7f; } else { footPlacementData.mExtraRayDistanceCheck = -0.2f; } break; case FootPlacementData.LimbID.LEFT_HAND: footPlacementData = components[b]; break; case FootPlacementData.LimbID.RIGHT_HAND: footPlacementData = components[b]; break; } footPlacementData.mTransitionTime = 0.15f - 0.1f * @float; } } } public class PelvisSet : StateMachineBehaviour { public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { ((Component)animator).GetComponent().mAdjustPelvisVertically = true; } } public class PelvisUnset : StateMachineBehaviour { public override void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { ((Component)animator).GetComponent().mAdjustPelvisVertically = false; } } public class FootPlacementData : MonoBehaviour { public enum LimbID { LEFT_FOOT, RIGHT_FOOT, LEFT_HAND, RIGHT_HAND } public enum Target { FOOT, TOE, HEEL } public LimbID mFootID = LimbID.LEFT_FOOT; public bool mPlantFoot = true; public Vector3 mForwardVector = new Vector3(0f, 0f, 1f); public Vector3 mIKHintOffset = new Vector3(0f, 0f, 0f); public Vector3 mUpVector = new Vector3(0f, 1f, 0f); public float mFootOffsetDist = 0.5f; public float mFootLength = 0.22f; public float mFootHalfWidth = 0.05f; public float mFootHeight = 0.1f; public float mFootRotationLimit = 45f; public float mTransitionTime = 0.2f; public float mExtraRayDistanceCheck = 0f; public bool mSetExtraRaydistanceCheckAutomatically = false; public float mErrorThreshold = 0.05f; public float mExtraRayDistanceCheckMin = 0f; public float mExtraRayDistanceCheckMax = 2f; protected bool mFootPlantIsOnTransition = false; protected float mFootPlantBlendSpeed; protected Vector3 mTargetPos = new Vector3(0f, 0f, 0f); protected Vector3 mTargetToePos = new Vector3(0f, 0f, 0f); protected Vector3 mTargetHeelPos = new Vector3(0f, 0f, 0f); protected Vector3 mRotatedFwdVec; protected Vector3 mRotatedIKHintOffset; protected float mTargetFootWeight = 0f; protected float mCurrentFootWeight = 0f; protected float mGoalBlendSpeed = 0f; protected float mPlantBlendFactor = 0f; private Vector3 mFootPlantedPos; private Quaternion mFootPlantedRot; private bool mFootPlanted = false; private Vector3 mPreviousFootPos = Vector3.zero; public void SetTargetPos(Target target, Vector3 target_pos) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0033: 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) switch (target) { case Target.FOOT: mTargetPos = target_pos; break; case Target.TOE: mTargetToePos = target_pos; break; case Target.HEEL: mTargetHeelPos = target_pos; break; } } public Vector3 GetTargetPos(Target target) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(target switch { Target.FOOT => mTargetPos, Target.TOE => mTargetToePos, Target.HEEL => mTargetHeelPos, _ => Vector3.zero, }); } public void CalculateRotatedFwdVec() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_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) AvatarIKGoal val = (AvatarIKGoal)0; switch (mFootID) { case LimbID.RIGHT_FOOT: val = (AvatarIKGoal)1; break; case LimbID.LEFT_HAND: val = (AvatarIKGoal)2; break; case LimbID.RIGHT_HAND: val = (AvatarIKGoal)3; break; } float num = 0f; Quaternion iKRotation = ((Component)this).GetComponent().GetIKRotation(val); num = ((Quaternion)(ref iKRotation)).eulerAngles.y * (float)Math.PI / 180f; Quaternion val2 = default(Quaternion); ((Quaternion)(ref val2))..ctor(0f, Mathf.Sin(num * 0.5f), 0f, Mathf.Cos(num * 0.5f)); if (mFootPlanted && mPlantFoot) { num = ((Quaternion)(ref mFootPlantedRot)).eulerAngles.y * (float)Math.PI / 180f; val2 = Quaternion.Slerp(val2, new Quaternion(0f, Mathf.Sin(num * 0.5f), 0f, Mathf.Cos(num * 0.5f)), mPlantBlendFactor); } mRotatedFwdVec = val2 * ((Vector3)(ref mForwardVector)).normalized; } public Vector3 GetRotatedFwdVec() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return mRotatedFwdVec; } public void CalculateRotatedIKHint() { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation = ((Component)this).transform.rotation; float num = ((Quaternion)(ref rotation)).eulerAngles.y * (float)Math.PI / 180f; Quaternion val = default(Quaternion); ((Quaternion)(ref val))..ctor(0f, Mathf.Sin(num * 0.5f), 0f, Mathf.Cos(num * 0.5f)); mRotatedIKHintOffset = val * mIKHintOffset; } public Vector3 GetRotatedIKHint() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return mRotatedIKHintOffset; } public void SetTargetFootWeight(float weight) { mTargetFootWeight = weight; } public float GetTargetFootWeight() { return mTargetFootWeight; } public void SetCurrentFootWeight(float weight) { mCurrentFootWeight = weight; } public float GetCurrentFootWeight() { return mCurrentFootWeight; } public void SetGoalBlendSpeed(float speed) { mGoalBlendSpeed = speed; } public float GetGoalBlendSpeed() { return mGoalBlendSpeed; } public float GetPlantBlendFactor() { return mPlantBlendFactor; } public void SetPlantBlendFactor(float factor) { mPlantBlendFactor = factor; } public void EnablePlantBlend(float blend_speed) { mFootPlantBlendSpeed = Mathf.Abs(blend_speed); mFootPlantIsOnTransition = true; } public void DisablePlantBlend(float blend_speed) { mFootPlantBlendSpeed = 0f - Mathf.Abs(blend_speed); mFootPlantIsOnTransition = true; } public float GetFootPlantBlendSpeed() { return mFootPlantBlendSpeed; } public void PlantBlendTransitionEnded() { mFootPlantIsOnTransition = false; } public bool IsPlantOnTransition() { return mFootPlantIsOnTransition; } public void SetFootPlanted(bool planted) { mFootPlanted = planted; } public bool GetFootPlanted() { return mFootPlanted; } public void SetPlantedPos(Vector3 planted_pos) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) mFootPlantedPos = planted_pos; } public Vector3 GetPlantedPos() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return mFootPlantedPos; } public void SetPlantedRot(Quaternion planted_rot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) mFootPlantedRot = planted_rot; } public Quaternion GetPlantedRot() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return mFootPlantedRot; } private void Start() { //IL_001b: 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_0056: 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_0046: 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) Animator component = ((Component)this).GetComponent(); if (!((Object)(object)component == (Object)null)) { HumanBodyBones val = (HumanBodyBones)5; switch (mFootID) { case LimbID.RIGHT_FOOT: val = (HumanBodyBones)6; break; case LimbID.RIGHT_HAND: val = (HumanBodyBones)18; break; case LimbID.LEFT_HAND: val = (HumanBodyBones)17; break; } mPreviousFootPos = component.GetBoneTransform(val).position; } } protected bool IsErrorHigh(HumanBodyBones bone, Vector3 current_position, Vector3 previous_pos) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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) Vector3 val = previous_pos - current_position; float magnitude = ((Vector3)(ref val)).magnitude; float num = mErrorThreshold; if (Time.deltaTime < 0.033f) { num = mErrorThreshold * 30f * Time.deltaTime; } if (magnitude > num) { return true; } return false; } private void OnAnimatorIK() { //IL_002c: 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_0066: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (!mSetExtraRaydistanceCheckAutomatically) { return; } Animator component = ((Component)this).GetComponent(); if (!((Object)(object)component == (Object)null)) { HumanBodyBones val = (HumanBodyBones)5; switch (mFootID) { case LimbID.RIGHT_FOOT: val = (HumanBodyBones)6; break; case LimbID.RIGHT_HAND: val = (HumanBodyBones)18; break; case LimbID.LEFT_HAND: val = (HumanBodyBones)17; break; } if (IsErrorHigh(val, component.GetBoneTransform(val).position, mPreviousFootPos)) { mExtraRayDistanceCheck = mExtraRayDistanceCheckMin; } else { mExtraRayDistanceCheck = mExtraRayDistanceCheckMax; } mPreviousFootPos = component.GetBoneTransform(val).position; } } } public class MecFootPlacer : MonoBehaviour { public bool mAdjustPelvisVertically = false; public bool mDampPelvis = false; public float mMaxLegLength = 1f; public float mMinLegLength = 0.2f; public float mPelvisAdjustmentSpeed = 1f; public string[] mLayersToIgnore; protected FootPlacementData mLeftFoot = null; protected FootPlacementData mRightFoot = null; protected FootPlacementData mLeftHand = null; protected FootPlacementData mRightHand = null; protected Animator mAnim; protected LayerMask mLayerMask = LayerMask.op_Implicit(-1); private const float mEpsilon = 0.005f; private float mCurrentRootVertError = 0f; private float mTargetRootVertError = 0f; private float mCurrentPelvisSpeed = 0f; private Vector3 mLeftFootContact_Ontransition_Disable; private Vector3 mLeftToeContact_Ontransition_Disable; private Vector3 mLeftHeelContact_Ontransition_Disable; private Vector3 mRightFootContact_Ontransition_Disable; private Vector3 mRightToeContact_Ontransition_Disable; private Vector3 mRightHeelContact_Ontransition_Disable; private Vector3 mLeftHandContact_Ontransition_Disable; private Vector3 mLeftHandToeContact_Ontransition_Disable; private Vector3 mLeftHandHeelContact_Ontransition_Disable; private Vector3 mRightHandContact_Ontransition_Disable; private Vector3 mRightHandToeContact_Ontransition_Disable; private Vector3 mRightHandHeelContact_Ontransition_Disable; private bool mRootPosLeftRightFoot = false; private bool mLeftFootActive = true; private bool mRightFootActive = true; private bool mLeftHandActive = true; private bool mRightHandActive = true; public void SetActive(AvatarIKGoal foot_id, bool active) { //IL_0001: 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_0045: Invalid comparison between Unknown and I4 //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Invalid comparison between Unknown and I4 //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Invalid comparison between Unknown and I4 //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) if ((int)foot_id == 0) { if ((Object)(object)mLeftFoot == (Object)null) { return; } if (active && !mLeftFootActive) { ResetIKParams(foot_id); } mLeftFootActive = active; } if ((int)foot_id == 1) { if ((Object)(object)mRightFoot == (Object)null) { return; } if (active && !mRightFootActive) { ResetIKParams(foot_id); } mRightFootActive = active; } if ((int)foot_id == 2) { if ((Object)(object)mRightHand == (Object)null) { return; } if (active && !mLeftHandActive) { ResetIKParams(foot_id); } mLeftHandActive = active; } if ((int)foot_id == 3 && !((Object)(object)mRightHand == (Object)null)) { if (active && !mRightHandActive) { ResetIKParams(foot_id); } mRightHandActive = active; } } public bool IsActive(AvatarIKGoal foot_id) { //IL_0001: 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_0016: Invalid comparison between Unknown and I4 //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 if ((int)foot_id == 0) { return mLeftFootActive; } if ((int)foot_id == 1) { return mRightFootActive; } if ((int)foot_id == 2) { return mLeftHandActive; } if ((int)foot_id == 3) { return mRightHandActive; } return false; } public void SetLayerMask(LayerMask layer_mask) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) mLayerMask = layer_mask; } public LayerMask GetLayerMask() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return mLayerMask; } public float GetPlantBlendWeight(AvatarIKGoal foot_id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected I4, but got Unknown FootPlacementData footPlacementData; switch ((int)foot_id) { case 0: footPlacementData = mLeftFoot; break; case 1: footPlacementData = mRightFoot; break; case 2: footPlacementData = mLeftHand; break; case 3: footPlacementData = mRightHand; break; default: return -1f; } return footPlacementData.GetPlantBlendFactor(); } public void SetPlantBlendWeight(AvatarIKGoal foot_id, float weight) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected I4, but got Unknown FootPlacementData footPlacementData; switch ((int)foot_id) { default: return; case 0: footPlacementData = mLeftFoot; break; case 1: footPlacementData = mRightFoot; break; case 2: footPlacementData = mLeftHand; break; case 3: footPlacementData = mRightHand; break; } footPlacementData.SetPlantBlendFactor(weight); } public void EnablePlant(AvatarIKGoal foot_id, float blend_speed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected I4, but got Unknown FootPlacementData footPlacementData; switch ((int)foot_id) { default: return; case 0: footPlacementData = mLeftFoot; break; case 1: footPlacementData = mRightFoot; break; case 2: footPlacementData = mLeftHand; break; case 3: footPlacementData = mRightHand; break; } footPlacementData.EnablePlantBlend(blend_speed); } public void DisablePlant(AvatarIKGoal foot_id, float blend_speed) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected I4, but got Unknown FootPlacementData footPlacementData; switch ((int)foot_id) { default: return; case 0: footPlacementData = mLeftFoot; break; case 1: footPlacementData = mRightFoot; break; case 2: footPlacementData = mLeftHand; break; case 3: footPlacementData = mRightHand; break; } footPlacementData.DisablePlantBlend(blend_speed); } private void ResetIKParams(AvatarIKGoal foot_id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Invalid comparison between Unknown and I4 //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_0057: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00b4: 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_00c4: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Invalid comparison between Unknown and I4 //IL_00f8: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_01a3: 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_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_02af: Invalid comparison between Unknown and I4 //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_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0322: 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_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0342: 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_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0382: 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_038c: Unknown result type (might be due to invalid IL or missing references) if ((int)foot_id == 0) { Vector3 position = mAnim.GetBoneTransform((HumanBodyBones)5).position; mLeftFoot.SetTargetFootWeight(0f); mLeftFoot.SetCurrentFootWeight(0f); mLeftFoot.SetGoalBlendSpeed(0f); mLeftFoot.SetFootPlanted(planted: false); mLeftFootContact_Ontransition_Disable = position; mLeftToeContact_Ontransition_Disable = mLeftFoot.mUpVector * mLeftFoot.mFootOffsetDist + mLeftFoot.GetRotatedFwdVec() * mLeftFoot.mFootLength; mLeftHeelContact_Ontransition_Disable = position + new Quaternion(0f, 0.7071f, 0f, 0.7071f) * mLeftFoot.GetRotatedFwdVec() * mLeftFoot.mFootHalfWidth; } if ((int)foot_id == 1) { Vector3 position2 = mAnim.GetBoneTransform((HumanBodyBones)6).position; mRightFoot.SetTargetFootWeight(0f); mRightFoot.SetCurrentFootWeight(0f); mRightFoot.SetGoalBlendSpeed(0f); mRightFoot.SetFootPlanted(planted: false); mRightFootContact_Ontransition_Disable = position2; mRightToeContact_Ontransition_Disable = mRightFoot.mUpVector * mRightFoot.mFootOffsetDist + mRightFoot.GetRotatedFwdVec() * mRightFoot.mFootLength; mRightHeelContact_Ontransition_Disable = position2 + new Quaternion(0f, 0.7017f, 0f, 0.7071f) * mRightFoot.GetRotatedFwdVec() * mRightFoot.mFootHalfWidth; } if ((int)foot_id == 2) { Vector3 position3 = mAnim.GetBoneTransform((HumanBodyBones)17).position; mLeftHand.SetTargetFootWeight(0f); mLeftHand.SetCurrentFootWeight(0f); mLeftHand.SetGoalBlendSpeed(0f); mLeftHand.SetFootPlanted(planted: false); mLeftHandContact_Ontransition_Disable = position3; mLeftHandToeContact_Ontransition_Disable = mLeftHand.mUpVector * mLeftHand.mFootOffsetDist + mLeftHand.GetRotatedFwdVec() * mLeftHand.mFootLength; mLeftHandHeelContact_Ontransition_Disable = position3 + new Quaternion(0f, 0.7017f, 0f, 0.7071f) * mLeftHand.GetRotatedFwdVec() * mLeftHand.mFootHalfWidth; } if ((int)foot_id == 3) { Vector3 position4 = mAnim.GetBoneTransform((HumanBodyBones)18).position; mRightHand.SetTargetFootWeight(0f); mRightHand.SetCurrentFootWeight(0f); mRightHand.SetGoalBlendSpeed(0f); mRightHand.SetFootPlanted(planted: false); mRightHandContact_Ontransition_Disable = position4; mRightHandToeContact_Ontransition_Disable = mRightHand.mUpVector * mRightHand.mFootOffsetDist + mRightHand.GetRotatedFwdVec() * mRightHand.mFootLength; mRightHandHeelContact_Ontransition_Disable = position4 + new Quaternion(0f, 0.7017f, 0f, 0.7071f) * mRightHand.GetRotatedFwdVec() * mRightHand.mFootHalfWidth; } } protected void SetIKWeight(AvatarIKGoal foot_id, float target_weight, float transition_time) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected I4, but got Unknown switch ((int)foot_id) { case 0: if (Mathf.Abs(target_weight - mLeftFoot.GetTargetFootWeight()) > 0.005f) { if (transition_time != 0f) { mLeftFoot.SetGoalBlendSpeed((target_weight - mLeftFoot.GetCurrentFootWeight()) / transition_time); } else { mLeftFoot.SetGoalBlendSpeed(0.1f); mLeftFoot.SetCurrentFootWeight(target_weight); } } mLeftFoot.SetTargetFootWeight(target_weight); break; case 1: if (Mathf.Abs(target_weight - mRightFoot.GetTargetFootWeight()) > 0.005f) { if (transition_time != 0f) { mRightFoot.SetGoalBlendSpeed((target_weight - mRightFoot.GetCurrentFootWeight()) / transition_time); } else { mRightFoot.SetGoalBlendSpeed(0.1f); mRightFoot.SetCurrentFootWeight(target_weight); } } mRightFoot.SetTargetFootWeight(target_weight); break; case 2: if (Mathf.Abs(target_weight - mLeftHand.GetTargetFootWeight()) > 0.005f) { if (transition_time != 0f) { mLeftHand.SetGoalBlendSpeed((target_weight - mLeftHand.GetCurrentFootWeight()) / transition_time); } else { mLeftHand.SetGoalBlendSpeed(0.1f); mLeftHand.SetCurrentFootWeight(target_weight); } } mLeftHand.SetTargetFootWeight(target_weight); break; case 3: if (Mathf.Abs(target_weight - mRightHand.GetTargetFootWeight()) > 0.005f) { if (transition_time != 0f) { mRightHand.SetGoalBlendSpeed((target_weight - mRightHand.GetCurrentFootWeight()) / transition_time); } else { mRightHand.SetGoalBlendSpeed(0.1f); mRightHand.SetCurrentFootWeight(target_weight); } } mRightHand.SetTargetFootWeight(target_weight); break; } } protected void CalculateIKGoalWeights(AvatarIKGoal foot_id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected I4, but got Unknown FootPlacementData footPlacementData; switch ((int)foot_id) { default: return; case 0: footPlacementData = mLeftFoot; break; case 1: footPlacementData = mRightFoot; break; case 2: footPlacementData = mLeftHand; break; case 3: footPlacementData = mRightHand; break; } float num = Mathf.Sign(footPlacementData.GetTargetFootWeight() - footPlacementData.GetCurrentFootWeight()); footPlacementData.SetCurrentFootWeight(footPlacementData.GetCurrentFootWeight() + footPlacementData.GetGoalBlendSpeed() * Time.deltaTime); if (num * Mathf.Sign(footPlacementData.GetTargetFootWeight() - footPlacementData.GetCurrentFootWeight()) < 1f || Mathf.Abs(footPlacementData.GetCurrentFootWeight() - footPlacementData.GetTargetFootWeight()) < 0.005f) { footPlacementData.SetCurrentFootWeight(footPlacementData.GetTargetFootWeight()); } else if (footPlacementData.GetCurrentFootWeight() > 1f || footPlacementData.GetCurrentFootWeight() < 0f) { footPlacementData.SetCurrentFootWeight(Mathf.Clamp(footPlacementData.GetTargetFootWeight(), 0f, 1f)); } } protected void CheckForLimits(AvatarIKGoal foot_id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected I4, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_0102: 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_0083: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00d2: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) FootPlacementData footPlacementData; switch ((int)foot_id) { default: return; case 0: footPlacementData = mLeftFoot; break; case 1: footPlacementData = mRightFoot; break; case 2: footPlacementData = mLeftHand; break; case 3: footPlacementData = mRightHand; break; } Vector3 zero = Vector3.zero; Vector3 rotatedFwdVec = footPlacementData.GetRotatedFwdVec(); if (Vector3.Angle(rotatedFwdVec, footPlacementData.GetTargetPos(FootPlacementData.Target.TOE)) > footPlacementData.mFootRotationLimit) { zero = footPlacementData.mUpVector * footPlacementData.mFootLength * Mathf.Tan(footPlacementData.mFootRotationLimit * ((float)Math.PI / 180f)); if (Vector3.Angle(footPlacementData.mUpVector, footPlacementData.GetTargetPos(FootPlacementData.Target.TOE)) > 90f) { zero = -zero; } footPlacementData.SetTargetPos(FootPlacementData.Target.TOE, rotatedFwdVec * footPlacementData.mFootLength + zero); } Quaternion val = default(Quaternion); ((Quaternion)(ref val))..ctor(0f, 0.7071f, 0f, 0.7071f); if (Vector3.Angle(val * rotatedFwdVec, footPlacementData.GetTargetPos(FootPlacementData.Target.HEEL)) > footPlacementData.mFootRotationLimit) { zero = footPlacementData.mUpVector * footPlacementData.mFootHalfWidth * Mathf.Tan(footPlacementData.mFootRotationLimit * ((float)Math.PI / 180f)); if (Vector3.Angle(footPlacementData.mUpVector, footPlacementData.GetTargetPos(FootPlacementData.Target.HEEL)) > 90f) { zero = -zero; } footPlacementData.SetTargetPos(FootPlacementData.Target.HEEL, val * rotatedFwdVec * footPlacementData.mFootHalfWidth + zero); } } protected void UpdateFootPlantBlendWeights(AvatarIKGoal foot_id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected I4, but got Unknown FootPlacementData footPlacementData; switch ((int)foot_id) { default: return; case 0: footPlacementData = mLeftFoot; break; case 1: footPlacementData = mRightFoot; break; case 2: footPlacementData = mLeftHand; break; case 3: footPlacementData = mRightHand; break; } if (!footPlacementData.IsPlantOnTransition()) { return; } footPlacementData.SetPlantBlendFactor(footPlacementData.GetPlantBlendFactor() + footPlacementData.GetFootPlantBlendSpeed() * Time.deltaTime); if (footPlacementData.GetFootPlantBlendSpeed() > 0f) { if (footPlacementData.GetPlantBlendFactor() > 1f) { footPlacementData.SetPlantBlendFactor(1f); footPlacementData.PlantBlendTransitionEnded(); } } else if (footPlacementData.GetPlantBlendFactor() < 0f) { footPlacementData.SetPlantBlendFactor(0f); footPlacementData.PlantBlendTransitionEnded(); } } protected void FindContactPoints(AvatarIKGoal foot_id) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0026: Expected I4, but got Unknown //IL_0060: 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_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_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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: 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_01ea: Expected I4, but got Unknown //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_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_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected I4, but got Unknown //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: 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_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: 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_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026f: 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_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Expected I4, but got Unknown //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0406: 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) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: 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_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Expected I4, but got Unknown //IL_0463: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048b: 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_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: 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_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: 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_02f9: 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_0320: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Expected I4, but got Unknown //IL_0335: 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_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0636: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_0642: Unknown result type (might be due to invalid IL or missing references) //IL_0647: Unknown result type (might be due to invalid IL or missing references) //IL_064e: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_065f: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04e5: Unknown result type (might be due to invalid IL or missing references) //IL_0672: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_067a: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Unknown result type (might be due to invalid IL or missing references) //IL_0691: Unknown result type (might be due to invalid IL or missing references) //IL_0665: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_0591: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059a: 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_05bb: Expected I4, but got Unknown //IL_05c3: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_05da: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: 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_04ff: 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_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0536: Unknown result type (might be due to invalid IL or missing references) //IL_053b: 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_0546: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_060d: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0586: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) Vector3 iKPosition = mAnim.GetIKPosition(foot_id); bool flag = true; FootPlacementData footPlacementData; switch ((int)foot_id) { default: return; case 0: footPlacementData = mLeftFoot; break; case 1: footPlacementData = mRightFoot; break; case 2: footPlacementData = mLeftHand; break; case 3: footPlacementData = mRightHand; break; } RaycastHit val = default(RaycastHit); if (Physics.Raycast(iKPosition + footPlacementData.mUpVector * footPlacementData.mFootOffsetDist, -footPlacementData.mUpVector, ref val, footPlacementData.mFootOffsetDist + footPlacementData.mFootHeight + footPlacementData.mExtraRayDistanceCheck, LayerMask.op_Implicit(mLayerMask))) { SetIKWeight(foot_id, 1f, footPlacementData.mTransitionTime); Vector3 val2 = ((RaycastHit)(ref val)).point; if (footPlacementData.mPlantFoot && footPlacementData.GetFootPlanted() && Physics.Raycast(footPlacementData.GetPlantedPos() + footPlacementData.mUpVector * footPlacementData.mFootOffsetDist, -footPlacementData.mUpVector, ref val, footPlacementData.mFootOffsetDist + footPlacementData.mFootHeight + footPlacementData.mExtraRayDistanceCheck, LayerMask.op_Implicit(mLayerMask))) { val2 = Vector3.Lerp(val2, ((RaycastHit)(ref val)).point, footPlacementData.GetPlantBlendFactor()); } footPlacementData.SetTargetPos(FootPlacementData.Target.FOOT, val2); switch ((int)foot_id) { case 0: mLeftFootContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.FOOT); break; case 1: mRightFootContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.FOOT); break; case 2: mLeftHandContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.FOOT); break; case 3: mRightHandContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.FOOT); break; } flag = true; } else { SetIKWeight(foot_id, 0f, footPlacementData.mTransitionTime); footPlacementData.SetTargetPos(FootPlacementData.Target.FOOT, Vector3.Lerp(iKPosition, (Vector3)((int)foot_id switch { 0 => mLeftFootContact_Ontransition_Disable, 1 => mRightFootContact_Ontransition_Disable, 2 => mLeftHandContact_Ontransition_Disable, 3 => mRightHandContact_Ontransition_Disable, _ => Vector3.zero, }), footPlacementData.GetCurrentFootWeight())); flag = false; } if (Physics.Raycast(iKPosition + footPlacementData.mUpVector * footPlacementData.mFootOffsetDist + footPlacementData.GetRotatedFwdVec() * footPlacementData.mFootLength, -footPlacementData.mUpVector, ref val, footPlacementData.mFootOffsetDist + footPlacementData.mFootLength + footPlacementData.mExtraRayDistanceCheck, LayerMask.op_Implicit(mLayerMask)) && flag) { Vector3 val3 = ((RaycastHit)(ref val)).point; if (footPlacementData.mPlantFoot && footPlacementData.GetFootPlanted() && Physics.Raycast(footPlacementData.GetPlantedPos() + footPlacementData.mUpVector * footPlacementData.mFootOffsetDist + footPlacementData.GetRotatedFwdVec() * footPlacementData.mFootLength, -footPlacementData.mUpVector, ref val, footPlacementData.mFootOffsetDist + footPlacementData.mFootLength + footPlacementData.mExtraRayDistanceCheck, LayerMask.op_Implicit(mLayerMask))) { val3 = Vector3.Lerp(val3, ((RaycastHit)(ref val)).point, footPlacementData.GetPlantBlendFactor()); } footPlacementData.SetTargetPos(FootPlacementData.Target.TOE, val3 - footPlacementData.GetTargetPos(FootPlacementData.Target.FOOT)); switch ((int)foot_id) { case 0: mLeftToeContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.TOE); break; case 1: mRightToeContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.TOE); break; case 2: mLeftHandToeContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.TOE); break; case 3: mRightHandToeContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.TOE); break; } } else { Vector3 val4 = (Vector3)((int)foot_id switch { 0 => mLeftToeContact_Ontransition_Disable, 1 => mRightToeContact_Ontransition_Disable, 2 => mLeftHandToeContact_Ontransition_Disable, 3 => mRightHandToeContact_Ontransition_Disable, _ => Vector3.zero, }); footPlacementData.SetTargetPos(FootPlacementData.Target.TOE, Vector3.Slerp(footPlacementData.GetRotatedFwdVec() * footPlacementData.mFootLength, val4, footPlacementData.GetCurrentFootWeight())); } Quaternion val5 = default(Quaternion); ((Quaternion)(ref val5))..ctor(0f, 0.7071f, 0f, 0.7071f); Vector3 val6 = iKPosition + footPlacementData.mUpVector * footPlacementData.mFootOffsetDist; Vector3 val7 = val5 * footPlacementData.GetRotatedFwdVec(); if (Physics.Raycast(val6 + ((Vector3)(ref val7)).normalized * footPlacementData.mFootHalfWidth, -footPlacementData.mUpVector, ref val, footPlacementData.mFootOffsetDist + footPlacementData.mFootLength + footPlacementData.mExtraRayDistanceCheck, LayerMask.op_Implicit(mLayerMask)) && flag) { Vector3 val8 = ((RaycastHit)(ref val)).point; if (footPlacementData.mPlantFoot && footPlacementData.GetFootPlanted()) { Vector3 val9 = footPlacementData.GetPlantedPos() + footPlacementData.mUpVector * footPlacementData.mFootOffsetDist; Vector3 val10 = val5 * footPlacementData.GetRotatedFwdVec(); if (Physics.Raycast(val9 + ((Vector3)(ref val10)).normalized * footPlacementData.mFootHalfWidth, -footPlacementData.mUpVector, ref val, footPlacementData.mFootOffsetDist + footPlacementData.mFootLength + footPlacementData.mExtraRayDistanceCheck, LayerMask.op_Implicit(mLayerMask))) { val8 = Vector3.Lerp(val8, ((RaycastHit)(ref val)).point, footPlacementData.GetPlantBlendFactor()); } } footPlacementData.SetTargetPos(FootPlacementData.Target.HEEL, val8 - footPlacementData.GetTargetPos(FootPlacementData.Target.FOOT)); switch ((int)foot_id) { case 0: mLeftHeelContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.HEEL); break; case 1: mRightHeelContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.HEEL); break; case 2: mLeftHandHeelContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.HEEL); break; case 3: mRightHeelContact_Ontransition_Disable = footPlacementData.GetTargetPos(FootPlacementData.Target.HEEL); break; default: { Vector3 val4 = Vector3.zero; break; } } } else { Vector3 val4 = (Vector3)((int)foot_id switch { 0 => mLeftHeelContact_Ontransition_Disable, 1 => mRightHeelContact_Ontransition_Disable, 2 => mLeftHandHeelContact_Ontransition_Disable, 3 => mRightHandHeelContact_Ontransition_Disable, _ => Vector3.zero, }); footPlacementData.SetTargetPos(FootPlacementData.Target.HEEL, Vector3.Slerp(val5 * footPlacementData.GetRotatedFwdVec() * footPlacementData.mFootHalfWidth, val4, footPlacementData.GetCurrentFootWeight())); } } protected void RootPositioningCheck() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_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_00b3: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_040f: 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_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04be: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Unknown result type (might be due to invalid IL or missing references) //IL_033c: 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_0352: 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_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: 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_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: 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_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0273: 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_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) AnimateRootVertError(); if (mAdjustPelvisVertically) { Vector3 val = mAnim.GetBoneTransform((HumanBodyBones)2).position - mAnim.GetIKPosition((AvatarIKGoal)1); float magnitude = ((Vector3)(ref val)).magnitude; FootPlacementData footPlacementData = mRightFoot; mRootPosLeftRightFoot = true; Vector3 val2 = mAnim.GetBoneTransform((HumanBodyBones)1).position - mAnim.GetIKPosition((AvatarIKGoal)0); float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; Vector3 val3 = mAnim.GetBoneTransform((HumanBodyBones)2).position - mAnim.GetIKPosition((AvatarIKGoal)1); if (sqrMagnitude > ((Vector3)(ref val3)).sqrMagnitude) { Vector3 val4 = mAnim.GetBoneTransform((HumanBodyBones)1).position - mAnim.GetIKPosition((AvatarIKGoal)0); magnitude = ((Vector3)(ref val4)).magnitude; footPlacementData = mLeftFoot; mRootPosLeftRightFoot = false; } if (magnitude > mMaxLegLength) { mTargetRootVertError = magnitude - mMaxLegLength; float num = 0f; float num2 = 0f; Vector3 val5 = mAnim.GetBoneTransform((HumanBodyBones)1).position - (mAnim.GetIKPosition((AvatarIKGoal)0) + mLeftFoot.mUpVector * mTargetRootVertError); float magnitude2 = ((Vector3)(ref val5)).magnitude; if (magnitude2 < mMinLegLength) { num = mMinLegLength - magnitude2; } Vector3 val6 = mAnim.GetBoneTransform((HumanBodyBones)2).position - (mAnim.GetIKPosition((AvatarIKGoal)1) + mLeftFoot.mUpVector * mTargetRootVertError); magnitude2 = ((Vector3)(ref val6)).magnitude; if (magnitude2 < mMinLegLength) { num2 = mMinLegLength - magnitude2; } if (num2 != 0f || num != 0f) { if (num2 > num) { mTargetRootVertError -= num2; } else { mTargetRootVertError -= num; } } } else { mTargetRootVertError = 0f; mCurrentPelvisSpeed = 0f; } mAnim.SetIKPosition((AvatarIKGoal)0, mAnim.GetIKPosition((AvatarIKGoal)0) + footPlacementData.mUpVector * mCurrentRootVertError); mAnim.SetIKPosition((AvatarIKGoal)1, mAnim.GetIKPosition((AvatarIKGoal)1) + footPlacementData.mUpVector * mCurrentRootVertError); mAnim.SetIKPosition((AvatarIKGoal)2, mAnim.GetIKPosition((AvatarIKGoal)2) + footPlacementData.mUpVector * mCurrentRootVertError); mAnim.SetIKPosition((AvatarIKGoal)3, mAnim.GetIKPosition((AvatarIKGoal)3) + footPlacementData.mUpVector * mCurrentRootVertError); return; } mTargetRootVertError = 0f; mCurrentPelvisSpeed = 0f; if (Mathf.Abs(mCurrentRootVertError) >= 0.005f) { if (mRootPosLeftRightFoot) { mAnim.SetIKPosition((AvatarIKGoal)0, mAnim.GetIKPosition((AvatarIKGoal)0) + mRightFoot.mUpVector * mCurrentRootVertError); mAnim.SetIKPosition((AvatarIKGoal)1, mAnim.GetIKPosition((AvatarIKGoal)1) + mRightFoot.mUpVector * mCurrentRootVertError); mAnim.SetIKPosition((AvatarIKGoal)2, mAnim.GetIKPosition((AvatarIKGoal)2) + mRightFoot.mUpVector * mCurrentRootVertError); mAnim.SetIKPosition((AvatarIKGoal)3, mAnim.GetIKPosition((AvatarIKGoal)3) + mRightFoot.mUpVector * mCurrentRootVertError); } else { mAnim.SetIKPosition((AvatarIKGoal)0, mAnim.GetIKPosition((AvatarIKGoal)0) + mRightFoot.mUpVector * mCurrentRootVertError); mAnim.SetIKPosition((AvatarIKGoal)1, mAnim.GetIKPosition((AvatarIKGoal)1) + mRightFoot.mUpVector * mCurrentRootVertError); mAnim.SetIKPosition((AvatarIKGoal)2, mAnim.GetIKPosition((AvatarIKGoal)2) + mRightFoot.mUpVector * mCurrentRootVertError); mAnim.SetIKPosition((AvatarIKGoal)3, mAnim.GetIKPosition((AvatarIKGoal)3) + mRightFoot.mUpVector * mCurrentRootVertError); } } } protected void AnimateRootVertError() { float num = Mathf.Abs(mCurrentRootVertError - mTargetRootVertError); if (num < 0.005f) { mCurrentRootVertError = mTargetRootVertError; mCurrentPelvisSpeed = 0f; return; } float num2 = Mathf.Sign(mTargetRootVertError - mCurrentRootVertError); if (mDampPelvis) { if (num < mTargetRootVertError * 0.3f) { mCurrentPelvisSpeed -= mPelvisAdjustmentSpeed * Time.deltaTime; if (mCurrentPelvisSpeed < mPelvisAdjustmentSpeed * 0.5f) { mCurrentPelvisSpeed = mPelvisAdjustmentSpeed * 0.5f; } mCurrentRootVertError += num2 * mCurrentPelvisSpeed * Time.deltaTime; } else { mCurrentRootVertError += num2 * mPelvisAdjustmentSpeed * Time.deltaTime; } } else { mCurrentRootVertError += num2 * mPelvisAdjustmentSpeed * Time.deltaTime; mCurrentPelvisSpeed = 0f; } if (Mathf.Sign(mTargetRootVertError - mCurrentRootVertError) * num2 <= 0f) { mCurrentRootVertError = mTargetRootVertError; } } public void FootPlacement(AvatarIKGoal foot_id) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected I4, but got Unknown //IL_00c1: 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_00cd: 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_00db: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: 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_018d: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: 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_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Invalid comparison between Unknown and I4 //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_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_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: 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_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_0328: 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_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) FootPlacementData footPlacementData = null; switch ((int)foot_id) { default: return; case 0: if (!mLeftFootActive) { return; } footPlacementData = mLeftFoot; break; case 1: if (!mRightFootActive) { return; } footPlacementData = mRightFoot; break; case 2: if (!mLeftHandActive) { return; } footPlacementData = mLeftHand; break; case 3: if (!mRightHandActive) { return; } footPlacementData = mRightHand; break; } ((Vector3)(ref footPlacementData.mUpVector)).Normalize(); ((Vector3)(ref footPlacementData.mForwardVector)).Normalize(); footPlacementData.CalculateRotatedIKHint(); footPlacementData.CalculateRotatedFwdVec(); footPlacementData.SetTargetPos(FootPlacementData.Target.FOOT, mAnim.GetIKPosition(foot_id)); UpdateFootPlantBlendWeights(foot_id); FindContactPoints(foot_id); CheckForLimits(foot_id); CalculateIKGoalWeights(foot_id); mAnim.SetIKRotationWeight(foot_id, footPlacementData.GetCurrentFootWeight()); float num = Vector3.Angle(footPlacementData.GetRotatedFwdVec(), footPlacementData.mForwardVector); Quaternion val = default(Quaternion); ((Quaternion)(ref val))..ctor(0f, 0.7071f, 0f, 0.7071f); Quaternion val2 = Quaternion.FromToRotation(footPlacementData.mForwardVector, footPlacementData.GetTargetPos(FootPlacementData.Target.TOE)); Vector3 eulerAngles = ((Quaternion)(ref val2)).eulerAngles; eulerAngles.z = 0f; Quaternion val3 = Quaternion.Euler(eulerAngles); if ((num > 90f && num < 180f) || (num > 270f && num < 360f)) { Quaternion val4 = Quaternion.FromToRotation(footPlacementData.GetTargetPos(FootPlacementData.Target.HEEL), val * footPlacementData.GetRotatedFwdVec()); eulerAngles = ((Quaternion)(ref val4)).eulerAngles; } else { Quaternion val5 = Quaternion.FromToRotation(val * footPlacementData.GetRotatedFwdVec(), footPlacementData.GetTargetPos(FootPlacementData.Target.HEEL)); eulerAngles = ((Quaternion)(ref val5)).eulerAngles; } eulerAngles.x = 0f; eulerAngles.y = 0f; val3 *= Quaternion.Euler(eulerAngles); mAnim.SetIKRotation(foot_id, val3); Vector3 zero = Vector3.zero; if ((int)foot_id == 0) { zero = mAnim.GetBoneTransform((HumanBodyBones)3).position - mAnim.GetIKPosition((AvatarIKGoal)0); mAnim.SetIKHintPositionWeight((AvatarIKHint)0, footPlacementData.GetCurrentFootWeight()); mAnim.SetIKHintPosition((AvatarIKHint)0, footPlacementData.GetTargetPos(FootPlacementData.Target.TOE) + footPlacementData.GetTargetPos(FootPlacementData.Target.FOOT) + footPlacementData.GetRotatedIKHint() + zero); } if ((int)foot_id == 1) { zero = mAnim.GetBoneTransform((HumanBodyBones)4).position - mAnim.GetBoneTransform((HumanBodyBones)6).position; mAnim.SetIKHintPositionWeight((AvatarIKHint)1, footPlacementData.GetCurrentFootWeight()); mAnim.SetIKHintPosition((AvatarIKHint)1, footPlacementData.GetTargetPos(FootPlacementData.Target.TOE) + footPlacementData.GetTargetPos(FootPlacementData.Target.FOOT) + footPlacementData.GetRotatedIKHint() + zero); } Vector3 val6 = footPlacementData.GetTargetPos(FootPlacementData.Target.FOOT) + footPlacementData.mUpVector * footPlacementData.mFootHeight; mAnim.SetIKPositionWeight(foot_id, footPlacementData.GetCurrentFootWeight()); mAnim.SetIKPosition(foot_id, val6); if (footPlacementData.GetCurrentFootWeight() <= 0f) { footPlacementData.SetFootPlanted(planted: false); } else if (footPlacementData.mPlantFoot && !footPlacementData.GetFootPlanted() && Mathf.Abs(footPlacementData.GetTargetFootWeight() - footPlacementData.GetCurrentFootWeight()) < 0.005f) { footPlacementData.SetPlantedPos(mAnim.GetIKPosition(foot_id)); footPlacementData.SetPlantedRot(mAnim.GetIKRotation(foot_id)); footPlacementData.SetFootPlanted(planted: true); } } private void UpdateLayerMask() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) for (byte b = 0; b < mLayersToIgnore.Length; b++) { int num = LayerMask.NameToLayer(mLayersToIgnore[b]); if (num != -1) { mLayerMask = LayerMask.op_Implicit(LayerMask.op_Implicit(mLayerMask) & ~Mathf.RoundToInt(Mathf.Pow(2f, (float)num))); } } } private void Start() { mAnim = ((Component)this).GetComponent(); bool flag = false; bool flag2 = false; bool flag3 = false; bool flag4 = false; FootPlacementData[] components = ((Component)this).GetComponents(); for (byte b = 0; b < components.Length; b++) { switch (components[b].mFootID) { case FootPlacementData.LimbID.LEFT_FOOT: flag = true; mLeftFoot = components[b]; break; case FootPlacementData.LimbID.RIGHT_FOOT: flag2 = true; mRightFoot = components[b]; break; case FootPlacementData.LimbID.RIGHT_HAND: flag4 = true; mLeftHand = components[b]; break; case FootPlacementData.LimbID.LEFT_HAND: flag3 = true; mRightHand = components[b]; break; } if (flag && flag2 && flag3 && flag4) { break; } } } private void OnAnimatorIK() { UpdateLayerMask(); if ((Object)(object)mLeftFoot != (Object)null) { FootPlacement((AvatarIKGoal)0); } if ((Object)(object)mRightFoot != (Object)null) { FootPlacement((AvatarIKGoal)1); } if ((Object)(object)mLeftHand != (Object)null) { FootPlacement((AvatarIKGoal)2); } if ((Object)(object)mRightHand != (Object)null) { FootPlacement((AvatarIKGoal)3); } RootPositioningCheck(); } private void LateUpdate() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (mCurrentRootVertError != 0f) { if (mRootPosLeftRightFoot) { Transform boneTransform = mAnim.GetBoneTransform((HumanBodyBones)0); boneTransform.position -= mRightFoot.mUpVector * mCurrentRootVertError; } else { Transform boneTransform2 = mAnim.GetBoneTransform((HumanBodyBones)0); boneTransform2.position -= mLeftFoot.mUpVector * mCurrentRootVertError; } } } } namespace JerryComponent { internal class HandFollowing : MonoBehaviour { public string handAnimaControName_Gun; public string handAnimaControName_Mag; private GameObject _player; private GameObject _POLeft; private GameObject _PORight; private FVRViveHand leftHand; private FVRViveHand rightHand; public Transform _ZuoShouWeiZhi; public Transform _YouShouWeiZhi; private void Start() { _player = ((Component)Object.FindObjectOfType()).gameObject; leftHand = ((Component)_player.transform.Find("Controller (left)")).GetComponent(); rightHand = ((Component)_player.transform.Find("Controller (right)")).GetComponent(); } private void Update() { HandFollow(); } private void HandFollow() { //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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) if ((Object)(object)leftHand.CurrentInteractable != (Object)null) { if ((Object)(object)((Component)leftHand.CurrentInteractable).GetComponent().PoseOverride_Touch != (Object)null) { _ZuoShouWeiZhi.position = ((Component)leftHand.CurrentInteractable).GetComponent().PoseOverride_Touch.position; _ZuoShouWeiZhi.rotation = ((Component)leftHand.CurrentInteractable).GetComponent().PoseOverride_Touch.rotation; ((Component)_ZuoShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Mag, false); ((Component)_ZuoShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Gun, true); } else { _ZuoShouWeiZhi.position = ((Component)leftHand.CurrentInteractable).gameObject.transform.position; _ZuoShouWeiZhi.rotation = GM.CurrentMovementManager.LeftHand.rotation; ((Component)_ZuoShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Mag, true); ((Component)_ZuoShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Gun, false); } } else { _ZuoShouWeiZhi.position = GM.CurrentMovementManager.LeftHand.position; _ZuoShouWeiZhi.rotation = GM.CurrentMovementManager.LeftHand.rotation; ((Component)_ZuoShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Mag, false); ((Component)_ZuoShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Gun, false); } if (!((Object)(object)rightHand.CurrentInteractable != (Object)null)) { _YouShouWeiZhi.position = GM.CurrentMovementManager.RightHand.position; _YouShouWeiZhi.rotation = GM.CurrentMovementManager.RightHand.rotation; ((Component)_YouShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Mag, false); ((Component)_YouShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Gun, false); } else if ((Object)(object)((Component)rightHand.CurrentInteractable).GetComponent().PoseOverride_Touch != (Object)null) { _YouShouWeiZhi.position = ((Component)rightHand.CurrentInteractable).gameObject.GetComponent().PoseOverride_Touch.position; _YouShouWeiZhi.rotation = ((Component)rightHand.CurrentInteractable).gameObject.GetComponent().PoseOverride_Touch.rotation; ((Component)_YouShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Mag, false); ((Component)_YouShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Gun, true); } else { _YouShouWeiZhi.position = ((Component)rightHand.CurrentInteractable).gameObject.transform.position; _YouShouWeiZhi.rotation = GM.CurrentMovementManager.RightHand.rotation; ((Component)_YouShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Mag, true); ((Component)_YouShouWeiZhi).GetComponentInChildren().SetBool(handAnimaControName_Gun, false); } } } } public class FaceUpdate : MonoBehaviour { public AnimationClip[] animations; private Animator anim; public float delayWeight; private float current = 0f; private void Start() { anim = ((Component)this).GetComponent(); } private void Update() { if (Input.GetMouseButton(0)) { current = 1f; } else { current = Mathf.Lerp(current, 0f, delayWeight); } anim.SetLayerWeight(1, current); } } [RequireComponent(typeof(Animator))] public class IdleChanger : MonoBehaviour { private Animator anim; private AnimatorStateInfo currentState; private AnimatorStateInfo previousState; public bool _random = false; public float _threshold = 0.5f; public float _interval = 2f; private void Start() { //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) anim = ((Component)this).GetComponent(); currentState = anim.GetCurrentAnimatorStateInfo(0); previousState = currentState; ((MonoBehaviour)this).StartCoroutine("RandomChange"); } private void Update() { //IL_0072: 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_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_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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown("up") || Input.GetButton("Jump")) { anim.SetBool("Next", true); } if (Input.GetKeyDown("down")) { anim.SetBool("Back", true); } if (anim.GetBool("Next")) { currentState = anim.GetCurrentAnimatorStateInfo(0); if (((AnimatorStateInfo)(ref previousState)).nameHash != ((AnimatorStateInfo)(ref currentState)).nameHash) { anim.SetBool("Next", false); previousState = currentState; } } if (anim.GetBool("Back")) { currentState = anim.GetCurrentAnimatorStateInfo(0); if (((AnimatorStateInfo)(ref previousState)).nameHash != ((AnimatorStateInfo)(ref currentState)).nameHash) { anim.SetBool("Back", false); previousState = currentState; } } } private void OnGUI() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) GUI.Box(new Rect((float)(Screen.width - 110), 10f, 100f, 90f), "Change Motion"); if (GUI.Button(new Rect((float)(Screen.width - 100), 40f, 80f, 20f), "Next")) { anim.SetBool("Next", true); } if (GUI.Button(new Rect((float)(Screen.width - 100), 70f, 80f, 20f), "Back")) { anim.SetBool("Back", true); } } private IEnumerator RandomChange() { while (true) { if (_random) { float num = Random.Range(-1f, 1f); if (num <= 0f - _threshold) { anim.SetBool("Back", true); } else if (num >= _threshold) { anim.SetBool("Next", true); } } yield return (object)new WaitForSeconds(_interval); } } } public class SceneLoader : MonoBehaviour { private void OnGUI() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) GUI.Box(new Rect(10f, (float)(Screen.height - 100), 100f, 90f), "Change Scene"); if (GUI.Button(new Rect(20f, (float)(Screen.height - 70), 80f, 20f), "Next")) { LoadNextScene(); } if (GUI.Button(new Rect(20f, (float)(Screen.height - 40), 80f, 20f), "Back")) { LoadPreScene(); } } private void LoadPreScene() { int num = Application.loadedLevel + 1; if (num <= 1) { num = Application.levelCount; } Application.LoadLevel(num); } private void LoadNextScene() { int num = Application.loadedLevel + 1; if (num >= Application.levelCount) { num = 1; } Application.LoadLevel(num); } } public class ThirdPersonCamera : MonoBehaviour { public float smooth = 3f; private Transform standardPos; private Transform frontPos; private Transform jumpPos; private bool bQuickSwitch = false; private void Start() { //IL_0074: 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) standardPos = GameObject.Find("CamPos").transform; if (Object.op_Implicit((Object)(object)GameObject.Find("FrontPos"))) { frontPos = GameObject.Find("FrontPos").transform; } if (Object.op_Implicit((Object)(object)GameObject.Find("JumpPos"))) { jumpPos = GameObject.Find("JumpPos").transform; } ((Component)this).transform.position = standardPos.position; ((Component)this).transform.forward = standardPos.forward; } private void FixedUpdate() { if (Input.GetButton("Fire1")) { setCameraPositionFrontView(); } else if (Input.GetButton("Fire2")) { setCameraPositionJumpView(); } else { setCameraPositionNormalView(); } } private void setCameraPositionNormalView() { //IL_0084: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0067: Unknown result type (might be due to invalid IL or missing references) if (!bQuickSwitch) { ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, standardPos.position, Time.fixedDeltaTime * smooth); ((Component)this).transform.forward = Vector3.Lerp(((Component)this).transform.forward, standardPos.forward, Time.fixedDeltaTime * smooth); } else { ((Component)this).transform.position = standardPos.position; ((Component)this).transform.forward = standardPos.forward; bQuickSwitch = false; } } private void setCameraPositionFrontView() { //IL_0014: 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) bQuickSwitch = true; ((Component)this).transform.position = frontPos.position; ((Component)this).transform.forward = frontPos.forward; } private void setCameraPositionJumpView() { //IL_0014: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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) bQuickSwitch = false; ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, jumpPos.position, Time.fixedDeltaTime * smooth); ((Component)this).transform.forward = Vector3.Lerp(((Component)this).transform.forward, jumpPos.forward, Time.fixedDeltaTime * smooth); } } [RequireComponent(typeof(Animator))] [RequireComponent(typeof(CapsuleCollider))] [RequireComponent(typeof(Rigidbody))] public class UnityChanControlScriptWithRgidBody : MonoBehaviour { public float animSpeed = 1.5f; public float lookSmoother = 3f; public bool useCurves = true; public float useCurvesHeight = 0.5f; public float forwardSpeed = 7f; public float backwardSpeed = 2f; public float rotateSpeed = 2f; public float jumpPower = 3f; private CapsuleCollider col; private Rigidbody rb; private Vector3 velocity; private float orgColHight; private Vector3 orgVectColCenter; private Animator anim; private AnimatorStateInfo currentBaseState; private GameObject cameraObject; private static int idleState = Animator.StringToHash("Base Layer.Idle"); private static int locoState = Animator.StringToHash("Base Layer.Locomotion"); private static int jumpState = Animator.StringToHash("Base Layer.Jump"); private static int restState = Animator.StringToHash("Base Layer.Rest"); private void Start() { //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) anim = ((Component)this).GetComponent(); col = ((Component)this).GetComponent(); rb = ((Component)this).GetComponent(); cameraObject = GameObject.FindWithTag("MainCamera"); orgColHight = col.height; orgVectColCenter = col.center; } private void FixedUpdate() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_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_0090: 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_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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) float axis = Input.GetAxis("Horizontal"); float axis2 = Input.GetAxis("Vertical"); anim.SetFloat("Speed", axis2); anim.SetFloat("Direction", axis); anim.speed = animSpeed; currentBaseState = anim.GetCurrentAnimatorStateInfo(0); rb.useGravity = true; velocity = new Vector3(0f, 0f, axis2); velocity = ((Component)this).transform.TransformDirection(velocity); if ((double)axis2 > 0.1) { velocity *= forwardSpeed; } else if ((double)axis2 < -0.1) { velocity *= backwardSpeed; } if (Input.GetButtonDown("Jump") && ((AnimatorStateInfo)(ref currentBaseState)).nameHash == locoState && !anim.IsInTransition(0)) { rb.AddForce(Vector3.up * jumpPower, (ForceMode)2); anim.SetBool("Jump", true); } Transform transform = ((Component)this).transform; transform.localPosition += velocity * Time.fixedDeltaTime; ((Component)this).transform.Rotate(0f, axis * rotateSpeed, 0f); if (((AnimatorStateInfo)(ref currentBaseState)).nameHash == locoState) { if (useCurves) { resetCollider(); } } else if (((AnimatorStateInfo)(ref currentBaseState)).nameHash == jumpState) { cameraObject.SendMessage("setCameraPositionJumpView"); if (anim.IsInTransition(0)) { return; } if (useCurves) { float @float = anim.GetFloat("JumpHeight"); float float2 = anim.GetFloat("GravityControl"); if (float2 > 0f) { rb.useGravity = false; } Ray val = default(Ray); ((Ray)(ref val))..ctor(((Component)this).transform.position + Vector3.up, -Vector3.up); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, ref val2)) { if (((RaycastHit)(ref val2)).distance > useCurvesHeight) { col.height = orgColHight - @float; float num = orgVectColCenter.y + @float; col.center = new Vector3(0f, num, 0f); } else { resetCollider(); } } } anim.SetBool("Jump", false); } else if (((AnimatorStateInfo)(ref currentBaseState)).nameHash == idleState) { if (useCurves) { resetCollider(); } if (Input.GetButtonDown("Jump")) { anim.SetBool("Rest", true); } } else if (((AnimatorStateInfo)(ref currentBaseState)).nameHash == restState && !anim.IsInTransition(0)) { anim.SetBool("Rest", false); } } private void resetCollider() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) col.height = orgColHight; col.center = orgVectColCenter; } } namespace RootMotion { public class TQ { public Vector3 t; public Quaternion q; public TQ(Vector3 translation, Quaternion rotation) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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) t = translation; q = rotation; } } public class AvatarUtility { public static Quaternion GetPostRotation(Avatar avatar, AvatarIKGoal avatarIKGoal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected I4, but got Unknown //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_0064: Unknown result type (might be due to invalid IL or missing references) int num = (int)HumanIDFromAvatarIKGoal(avatarIKGoal); if (num == 55) { throw new InvalidOperationException("Invalid human id."); } MethodInfo method = typeof(Avatar).GetMethod("GetPostRotation", BindingFlags.Instance | BindingFlags.NonPublic); if ((object)method == null) { throw new InvalidOperationException("Cannot find GetPostRotation method."); } return (Quaternion)method.Invoke(avatar, new object[1] { num }); } public static TQ GetIKGoalTQ(Avatar avatar, float humanScale, AvatarIKGoal avatarIKGoal, TQ bodyPositionRotation, TQ boneTQ) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected I4, but got Unknown //IL_0081: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Invalid comparison between Unknown and I4 //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_0110: 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_011a: 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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) int num = (int)HumanIDFromAvatarIKGoal(avatarIKGoal); if (num == 55) { throw new InvalidOperationException("Invalid human id."); } MethodInfo method = typeof(Avatar).GetMethod("GetAxisLength", BindingFlags.Instance | BindingFlags.NonPublic); if ((object)method == null) { throw new InvalidOperationException("Cannot find GetAxisLength method."); } MethodInfo method2 = typeof(Avatar).GetMethod("GetPostRotation", BindingFlags.Instance | BindingFlags.NonPublic); if ((object)method2 == null) { throw new InvalidOperationException("Cannot find GetPostRotation method."); } Quaternion val = (Quaternion)method2.Invoke(avatar, new object[1] { num }); TQ tQ = new TQ(boneTQ.t, boneTQ.q * val); if ((int)avatarIKGoal == 0 || (int)avatarIKGoal == 1) { float num2 = (float)method.Invoke(avatar, new object[1] { num }); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(num2, 0f, 0f); tQ.t += tQ.q * val2; } Quaternion val3 = Quaternion.Inverse(bodyPositionRotation.q); tQ.t = val3 * (tQ.t - bodyPositionRotation.t); tQ.q = val3 * tQ.q; tQ.t /= humanScale; tQ.q = Quaternion.LookRotation(tQ.q * Vector3.forward, tQ.q * Vector3.up); return tQ; } public static HumanBodyBones HumanIDFromAvatarIKGoal(AvatarIKGoal avatarIKGoal) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected I4, but got Unknown //IL_0020: 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_002f: 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_003d: 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_0044: Unknown result type (might be due to invalid IL or missing references) HumanBodyBones result = (HumanBodyBones)55; switch ((int)avatarIKGoal) { case 0: result = (HumanBodyBones)5; break; case 1: result = (HumanBodyBones)6; break; case 2: result = (HumanBodyBones)17; break; case 3: result = (HumanBodyBones)18; break; } return result; } } public static class BakerUtilities { public static void ReduceKeyframes(AnimationCurve curve, float maxError) { if (!(maxError <= 0f)) { curve.keys = GetReducedKeyframes(curve, maxError); } } public static Keyframe[] GetReducedKeyframes(AnimationCurve curve, float maxError) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) Keyframe[] array = curve.keys; int num = 1; while (num < array.Length - 1 && array.Length > 2) { Keyframe[] array2 = (Keyframe[])(object)new Keyframe[array.Length - 1]; int num2 = 0; for (int i = 0; i < array.Length; i++) { if (num != i) { ref Keyframe reference = ref array2[num2]; reference = new Keyframe(((Keyframe)(ref array[i])).time, ((Keyframe)(ref array[i])).value, ((Keyframe)(ref array[i])).inTangent, ((Keyframe)(ref array[i])).outTangent); num2++; } } AnimationCurve val = new AnimationCurve(); val.keys = array2; float num3 = Mathf.Abs(val.Evaluate(((Keyframe)(ref array[num])).time) - ((Keyframe)(ref array[num])).value); float num4 = ((Keyframe)(ref array[num])).time + (((Keyframe)(ref array[num - 1])).time - ((Keyframe)(ref array[num])).time) * 0.5f; float num5 = ((Keyframe)(ref array[num])).time + (((Keyframe)(ref array[num + 1])).time - ((Keyframe)(ref array[num])).time) * 0.5f; float num6 = Mathf.Abs(val.Evaluate(num4) - curve.Evaluate(num4)); float num7 = Mathf.Abs(val.Evaluate(num5) - curve.Evaluate(num5)); if (num3 < maxError && num6 < maxError && num7 < maxError) { array = array2; } else { num++; } } return array; } public static void SetLoopFrame(float time, AnimationCurve curve) { Keyframe[] keys = curve.keys; ((Keyframe)(ref keys[^1])).value = ((Keyframe)(ref keys[0])).value; float inTangent = Mathf.Lerp(((Keyframe)(ref keys[0])).inTangent, ((Keyframe)(ref keys[^1])).inTangent, 0.5f); ((Keyframe)(ref keys[0])).inTangent = inTangent; ((Keyframe)(ref keys[^1])).inTangent = inTangent; float outTangent = Mathf.Lerp(((Keyframe)(ref keys[0])).outTangent, ((Keyframe)(ref keys[^1])).outTangent, 0.5f); ((Keyframe)(ref keys[0])).outTangent = outTangent; ((Keyframe)(ref keys[^1])).outTangent = outTangent; ((Keyframe)(ref keys[^1])).time = time; curve.keys = keys; } public static void SetTangentMode(AnimationCurve curve) { if (curve.length >= 2) { for (int i = 1; i < curve.length - 1; i++) { AnimationUtility.SetKeyLeftTangentMode(curve, i, (TangentMode)4); AnimationUtility.SetKeyRightTangentMode(curve, i, (TangentMode)4); } } } public static Quaternion EnsureQuaternionContinuity(Quaternion lastQ, Quaternion q) { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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) Quaternion val = default(Quaternion); ((Quaternion)(ref val))..ctor(0f - q.x, 0f - q.y, 0f - q.z, 0f - q.w); Quaternion val2 = default(Quaternion); ((Quaternion)(ref val2))..ctor(Mathf.Lerp(lastQ.x, q.x, 0.5f), Mathf.Lerp(lastQ.y, q.y, 0.5f), Mathf.Lerp(lastQ.z, q.z, 0.5f), Mathf.Lerp(lastQ.w, q.w, 0.5f)); Quaternion val3 = default(Quaternion); ((Quaternion)(ref val3))..ctor(Mathf.Lerp(lastQ.x, val.x, 0.5f), Mathf.Lerp(lastQ.y, val.y, 0.5f), Mathf.Lerp(lastQ.z, val.z, 0.5f), Mathf.Lerp(lastQ.w, val.w, 0.5f)); float num = Quaternion.Angle(lastQ, val2); float num2 = Quaternion.Angle(lastQ, val3); return (!(num2 < num)) ? q : val; } } [Serializable] public class BakerHumanoidQT { private Transform transform; private string Qx; private string Qy; private string Qz; private string Qw; private string Tx; private string Ty; private string Tz; public AnimationCurve rotX; public AnimationCurve rotY; public AnimationCurve rotZ; public AnimationCurve rotW; public AnimationCurve posX; public AnimationCurve posY; public AnimationCurve posZ; private AvatarIKGoal goal; private Quaternion lastQ; private bool lastQSet; public BakerHumanoidQT(string name) { Qx = name + "Q.x"; Qy = name + "Q.y"; Qz = name + "Q.z"; Qw = name + "Q.w"; Tx = name + "T.x"; Ty = name + "T.y"; Tz = name + "T.z"; Reset(); } public BakerHumanoidQT(Transform transform, AvatarIKGoal goal, string name) { //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) this.transform = transform; this.goal = goal; Qx = name + "Q.x"; Qy = name + "Q.y"; Qz = name + "Q.z"; Qw = name + "Q.w"; Tx = name + "T.x"; Ty = name + "T.y"; Tz = name + "T.z"; Reset(); } public void Reset() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) rotX = new AnimationCurve(); rotY = new AnimationCurve(); rotZ = new AnimationCurve(); rotW = new AnimationCurve(); posX = new AnimationCurve(); posY = new AnimationCurve(); posZ = new AnimationCurve(); lastQ = Quaternion.identity; lastQSet = false; } public void SetIKKeyframes(float time, Avatar avatar, Transform root, float humanScale, Vector3 bodyPosition, Quaternion bodyRotation) { //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_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_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_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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_0092: Unknown result type (might be due to invalid IL or missing references) Vector3 val = transform.position; Quaternion val2 = transform.rotation; if ((Object)(object)root.parent != (Object)null) { val = root.parent.InverseTransformPoint(val); val2 = Quaternion.Inverse(root.parent.rotation) * val2; } TQ iKGoalTQ = AvatarUtility.GetIKGoalTQ(avatar, humanScale, goal, new TQ(bodyPosition, bodyRotation), new TQ(val, val2)); Quaternion val3 = iKGoalTQ.q; if (lastQSet) { val3 = BakerUtilities.EnsureQuaternionContinuity(lastQ, iKGoalTQ.q); } lastQ = val3; lastQSet = true; rotX.AddKey(time, val3.x); rotY.AddKey(time, val3.y); rotZ.AddKey(time, val3.z); rotW.AddKey(time, val3.w); Vector3 t = iKGoalTQ.t; posX.AddKey(time, t.x); posY.AddKey(time, t.y); posZ.AddKey(time, t.z); } public void SetKeyframes(float time, Vector3 pos, Quaternion rot) { rotX.AddKey(time, rot.x); rotY.AddKey(time, rot.y); rotZ.AddKey(time, rot.z); rotW.AddKey(time, rot.w); posX.AddKey(time, pos.x); posY.AddKey(time, pos.y); posZ.AddKey(time, pos.z); } public void MoveLastKeyframes(float time) { MoveLastKeyframe(time, rotX); MoveLastKeyframe(time, rotY); MoveLastKeyframe(time, rotZ); MoveLastKeyframe(time, rotW); MoveLastKeyframe(time, posX); MoveLastKeyframe(time, posY); MoveLastKeyframe(time, posZ); } public void SetLoopFrame(float time) { BakerUtilities.SetLoopFrame(time, rotX); BakerUtilities.SetLoopFrame(time, rotY); BakerUtilities.SetLoopFrame(time, rotZ); BakerUtilities.SetLoopFrame(time, rotW); BakerUtilities.SetLoopFrame(time, posX); BakerUtilities.SetLoopFrame(time, posY); BakerUtilities.SetLoopFrame(time, posZ); } private void MoveLastKeyframe(float time, AnimationCurve curve) { Keyframe[] keys = curve.keys; ((Keyframe)(ref keys[^1])).time = time; curve.keys = keys; } public void MultiplyLength(AnimationCurve curve, float mlp) { Keyframe[] keys = curve.keys; for (int i = 0; i < keys.Length; i++) { ref Keyframe reference = ref keys[i]; ((Keyframe)(ref reference)).time = ((Keyframe)(ref reference)).time * mlp; } curve.keys = keys; } public void SetCurves(ref AnimationClip clip, float maxError, float lengthMlp) { MultiplyLength(rotX, lengthMlp); MultiplyLength(rotY, lengthMlp); MultiplyLength(rotZ, lengthMlp); MultiplyLength(rotW, lengthMlp); MultiplyLength(posX, lengthMlp); MultiplyLength(posY, lengthMlp); MultiplyLength(posZ, lengthMlp); BakerUtilities.ReduceKeyframes(rotX, maxError); BakerUtilities.ReduceKeyframes(rotY, maxError); BakerUtilities.ReduceKeyframes(rotZ, maxError); BakerUtilities.ReduceKeyframes(rotW, maxError); BakerUtilities.ReduceKeyframes(posX, maxError); BakerUtilities.ReduceKeyframes(posY, maxError); BakerUtilities.ReduceKeyframes(posZ, maxError); BakerUtilities.SetTangentMode(rotX); BakerUtilities.SetTangentMode(rotY); BakerUtilities.SetTangentMode(rotZ); BakerUtilities.SetTangentMode(rotW); clip.SetCurve(string.Empty, typeof(Animator), Qx, rotX); clip.SetCurve(string.Empty, typeof(Animator), Qy, rotY); clip.SetCurve(string.Empty, typeof(Animator), Qz, rotZ); clip.SetCurve(string.Empty, typeof(Animator), Qw, rotW); clip.SetCurve(string.Empty, typeof(Animator), Tx, posX); clip.SetCurve(string.Empty, typeof(Animator), Ty, posY); clip.SetCurve(string.Empty, typeof(Animator), Tz, posZ); } } [Serializable] public class BakerMuscle { public AnimationCurve curve; private int muscleIndex = -1; private string propertyName; public BakerMuscle(int muscleIndex) { this.muscleIndex = muscleIndex; propertyName = MuscleNameToPropertyName(HumanTrait.MuscleName[muscleIndex]); Reset(); } private string MuscleNameToPropertyName(string n) { return n switch { "Left Index 1 Stretched" => "LeftHand.Index.1 Stretched", "Left Index 2 Stretched" => "LeftHand.Index.2 Stretched", "Left Index 3 Stretched" => "LeftHand.Index.3 Stretched", "Left Middle 1 Stretched" => "LeftHand.Middle.1 Stretched", "Left Middle 2 Stretched" => "LeftHand.Middle.2 Stretched", "Left Middle 3 Stretched" => "LeftHand.Middle.3 Stretched", "Left Ring 1 Stretched" => "LeftHand.Ring.1 Stretched", "Left Ring 2 Stretched" => "LeftHand.Ring.2 Stretched", "Left Ring 3 Stretched" => "LeftHand.Ring.3 Stretched", "Left Little 1 Stretched" => "LeftHand.Little.1 Stretched", "Left Little 2 Stretched" => "LeftHand.Little.2 Stretched", "Left Little 3 Stretched" => "LeftHand.Little.3 Stretched", "Left Thumb 1 Stretched" => "LeftHand.Thumb.1 Stretched", "Left Thumb 2 Stretched" => "LeftHand.Thumb.2 Stretched", "Left Thumb 3 Stretched" => "LeftHand.Thumb.3 Stretched", "Left Index Spread" => "LeftHand.Index.Spread", "Left Middle Spread" => "LeftHand.Middle.Spread", "Left Ring Spread" => "LeftHand.Ring.Spread", "Left Little Spread" => "LeftHand.Little.Spread", "Left Thumb Spread" => "LeftHand.Thumb.Spread", "Right Index 1 Stretched" => "RightHand.Index.1 Stretched", "Right Index 2 Stretched" => "RightHand.Index.2 Stretched", "Right Index 3 Stretched" => "RightHand.Index.3 Stretched", "Right Middle 1 Stretched" => "RightHand.Middle.1 Stretched", "Right Middle 2 Stretched" => "RightHand.Middle.2 Stretched", "Right Middle 3 Stretched" => "RightHand.Middle.3 Stretched", "Right Ring 1 Stretched" => "RightHand.Ring.1 Stretched", "Right Ring 2 Stretched" => "RightHand.Ring.2 Stretched", "Right Ring 3 Stretched" => "RightHand.Ring.3 Stretched", "Right Little 1 Stretched" => "RightHand.Little.1 Stretched", "Right Little 2 Stretched" => "RightHand.Little.2 Stretched", "Right Little 3 Stretched" => "RightHand.Little.3 Stretched", "Right Thumb 1 Stretched" => "RightHand.Thumb.1 Stretched", "Right Thumb 2 Stretched" => "RightHand.Thumb.2 Stretched", "Right Thumb 3 Stretched" => "RightHand.Thumb.3 Stretched", "Right Index Spread" => "RightHand.Index.Spread", "Right Middle Spread" => "RightHand.Middle.Spread", "Right Ring Spread" => "RightHand.Ring.Spread", "Right Little Spread" => "RightHand.Little.Spread", "Right Thumb Spread" => "RightHand.Thumb.Spread", _ => n, }; } public void MultiplyLength(AnimationCurve curve, float mlp) { Keyframe[] keys = curve.keys; for (int i = 0; i < keys.Length; i++) { ref Keyframe reference = ref keys[i]; ((Keyframe)(ref reference)).time = ((Keyframe)(ref reference)).time * mlp; } curve.keys = keys; } public void SetCurves(ref AnimationClip clip, float maxError, float lengthMlp) { MultiplyLength(curve, lengthMlp); BakerUtilities.ReduceKeyframes(curve, maxError); clip.SetCurve(string.Empty, typeof(Animator), propertyName, curve); } public void Reset() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown curve = new AnimationCurve(); } public void SetKeyframe(float time, float[] muscles) { curve.AddKey(time, muscles[muscleIndex]); } public void SetLoopFrame(float time) { BakerUtilities.SetLoopFrame(time, curve); } } [Serializable] public class BakerTransform { public Transform transform; public AnimationCurve posX; public AnimationCurve posY; public AnimationCurve posZ; public AnimationCurve rotX; public AnimationCurve rotY; public AnimationCurve rotZ; public AnimationCurve rotW; private string relativePath; private bool recordPosition; private Vector3 relativePosition; private bool isRootNode; private Quaternion relativeRotation; public BakerTransform(Transform transform, Transform root, bool recordPosition, bool isRootNode) { this.transform = transform; this.recordPosition = recordPosition || isRootNode; this.isRootNode = isRootNode; relativePath = string.Empty; relativePath = AnimationUtility.CalculateTransformPath(transform, root); Reset(); } public void SetRelativeSpace(Vector3 position, Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) relativePosition = position; relativeRotation = rotation; } public void SetCurves(ref AnimationClip clip) { if (recordPosition) { clip.SetCurve(relativePath, typeof(Transform), "localPosition.x", posX); clip.SetCurve(relativePath, typeof(Transform), "localPosition.y", posY); clip.SetCurve(relativePath, typeof(Transform), "localPosition.z", posZ); } clip.SetCurve(relativePath, typeof(Transform), "localRotation.x", rotX); clip.SetCurve(relativePath, typeof(Transform), "localRotation.y", rotY); clip.SetCurve(relativePath, typeof(Transform), "localRotation.z", rotZ); clip.SetCurve(relativePath, typeof(Transform), "localRotation.w", rotW); if (isRootNode) { AddRootMotionCurves(ref clip); } clip.EnsureQuaternionContinuity(); } private void AddRootMotionCurves(ref AnimationClip clip) { if (recordPosition) { clip.SetCurve("", typeof(Animator), "MotionT.x", posX); clip.SetCurve("", typeof(Animator), "MotionT.y", posY); clip.SetCurve("", typeof(Animator), "MotionT.z", posZ); } clip.SetCurve("", typeof(Animator), "MotionQ.x", rotX); clip.SetCurve("", typeof(Animator), "MotionQ.y", rotY); clip.SetCurve("", typeof(Animator), "MotionQ.z", rotZ); clip.SetCurve("", typeof(Animator), "MotionQ.w", rotW); } public void Reset() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown posX = new AnimationCurve(); posY = new AnimationCurve(); posZ = new AnimationCurve(); rotX = new AnimationCurve(); rotY = new AnimationCurve(); rotZ = new AnimationCurve(); rotW = new AnimationCurve(); } public void ReduceKeyframes(float maxError) { BakerUtilities.ReduceKeyframes(rotX, maxError); BakerUtilities.ReduceKeyframes(rotY, maxError); BakerUtilities.ReduceKeyframes(rotZ, maxError); BakerUtilities.ReduceKeyframes(rotW, maxError); BakerUtilities.ReduceKeyframes(posX, maxError); BakerUtilities.ReduceKeyframes(posY, maxError); BakerUtilities.ReduceKeyframes(posZ, maxError); } public void SetKeyframes(float time) { //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_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_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_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_00ad: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) if (recordPosition) { Vector3 val = transform.localPosition; if (isRootNode) { val = transform.position - relativePosition; } posX.AddKey(time, val.x); posY.AddKey(time, val.y); posZ.AddKey(time, val.z); } Quaternion val2 = transform.localRotation; if (isRootNode) { val2 = Quaternion.Inverse(relativeRotation) * transform.rotation; } rotX.AddKey(time, val2.x); rotY.AddKey(time, val2.y); rotZ.AddKey(time, val2.z); rotW.AddKey(time, val2.w); } public void AddLoopFrame(float time) { if (recordPosition && !isRootNode) { posX.AddKey(time, ((Keyframe)(ref posX.keys[0])).value); posY.AddKey(time, ((Keyframe)(ref posY.keys[0])).value); posZ.AddKey(time, ((Keyframe)(ref posZ.keys[0])).value); } rotX.AddKey(time, ((Keyframe)(ref rotX.keys[0])).value); rotY.AddKey(time, ((Keyframe)(ref rotY.keys[0])).value); rotZ.AddKey(time, ((Keyframe)(ref rotZ.keys[0])).value); rotW.AddKey(time, ((Keyframe)(ref rotW.keys[0])).value); } } } namespace RootMotion.Demos { public class FKOffset : MonoBehaviour { [Serializable] public class Offset { [HideInInspector] public string name; public HumanBodyBones bone; public Vector3 rotationOffset; private Transform t; public void Apply(Animator animator) { //IL_0015: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)t == (Object)null) { t = animator.GetBoneTransform(bone); } if (!((Object)(object)t == (Object)null)) { Transform obj = t; obj.localRotation *= Quaternion.Euler(rotationOffset); } } } public Offset[] offsets; private Animator animator; private void Start() { animator = ((Component)this).GetComponent(); } private void LateUpdate() { Offset[] array = offsets; foreach (Offset offset in array) { offset.Apply(animator); } } private void OnDrawGizmosSelected() { Offset[] array = offsets; foreach (Offset offset in array) { offset.name = ((object)(HumanBodyBones)(ref offset.bone)).ToString(); } } } } namespace RootMotion1.FinalIK { [HelpURL("http://www.root-motion.com/finalikdox/html/page4.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/Biped IK")] public class BipedIK : SolverManager { public BipedReferences references = new BipedReferences(); public BipedIKSolvers solvers = new BipedIKSolvers(); [ContextMenu("User Manual")] private void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page4.html"); } [ContextMenu("Scrpt Reference")] private void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_biped_i_k.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public float GetIKPositionWeight(AvatarIKGoal goal) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return GetGoalIK(goal).GetIKPositionWeight(); } public float GetIKRotationWeight(AvatarIKGoal goal) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return GetGoalIK(goal).GetIKRotationWeight(); } public void SetIKPositionWeight(AvatarIKGoal goal, float weight) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) GetGoalIK(goal).SetIKPositionWeight(weight); } public void SetIKRotationWeight(AvatarIKGoal goal, float weight) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) GetGoalIK(goal).SetIKRotationWeight(weight); } public void SetIKPosition(AvatarIKGoal goal, Vector3 IKPosition) { //IL_0002: 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) GetGoalIK(goal).SetIKPosition(IKPosition); } public void SetIKRotation(AvatarIKGoal goal, Quaternion IKRotation) { //IL_0002: 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) GetGoalIK(goal).SetIKRotation(IKRotation); } public Vector3 GetIKPosition(AvatarIKGoal goal) { //IL_0002: 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_0013: Unknown result type (might be due to invalid IL or missing references) return GetGoalIK(goal).GetIKPosition(); } public Quaternion GetIKRotation(AvatarIKGoal goal) { //IL_0002: 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_0013: Unknown result type (might be due to invalid IL or missing references) return GetGoalIK(goal).GetIKRotation(); } public void SetLookAtWeight(float weight, float bodyWeight, float headWeight, float eyesWeight, float clampWeight, float clampWeightHead, float clampWeightEyes) { solvers.lookAt.SetLookAtWeight(weight, bodyWeight, headWeight, eyesWeight, clampWeight, clampWeightHead, clampWeightEyes); } public void SetLookAtPosition(Vector3 lookAtPosition) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) solvers.lookAt.SetIKPosition(lookAtPosition); } public void SetSpinePosition(Vector3 spinePosition) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) solvers.spine.SetIKPosition(spinePosition); } public void SetSpineWeight(float weight) { solvers.spine.SetIKPositionWeight(weight); } public IKSolverLimb GetGoalIK(AvatarIKGoal goal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected I4, but got Unknown return (int)goal switch { 0 => solvers.leftFoot, 1 => solvers.rightFoot, 2 => solvers.leftHand, 3 => solvers.rightHand, _ => null, }; } public void InitiateBipedIK() { InitiateSolver(); } public void UpdateBipedIK() { UpdateSolver(); } public void SetToDefaults() { IKSolverLimb[] limbs = solvers.limbs; foreach (IKSolverLimb iKSolverLimb in limbs) { iKSolverLimb.SetIKPositionWeight(0f); iKSolverLimb.SetIKRotationWeight(0f); iKSolverLimb.bendModifier = IKSolverLimb.BendModifier.Animation; iKSolverLimb.bendModifierWeight = 1f; } solvers.leftHand.maintainRotationWeight = 0f; solvers.rightHand.maintainRotationWeight = 0f; solvers.spine.SetIKPositionWeight(0f); solvers.spine.tolerance = 0f; solvers.spine.maxIterations = 2; solvers.spine.useRotationLimits = false; solvers.aim.SetIKPositionWeight(0f); solvers.aim.tolerance = 0f; solvers.aim.maxIterations = 2; SetLookAtWeight(0f, 0.5f, 1f, 1f, 0.5f, 0.7f, 0.5f); } protected override void FixTransforms() { solvers.lookAt.FixTransforms(); for (int i = 0; i < solvers.limbs.Length; i++) { solvers.limbs[i].FixTransforms(); } } protected override void InitiateSolver() { string errorMessage = ""; if (BipedReferences.SetupError(references, ref errorMessage)) { Warning.Log(errorMessage, references.root); return; } solvers.AssignReferences(references); if (solvers.spine.bones.Length > 1) { solvers.spine.Initiate(((Component)this).transform); } solvers.lookAt.Initiate(((Component)this).transform); solvers.aim.Initiate(((Component)this).transform); IKSolverLimb[] limbs = solvers.limbs; foreach (IKSolverLimb iKSolverLimb in limbs) { iKSolverLimb.Initiate(((Component)this).transform); } solvers.pelvis.Initiate(references.pelvis); } protected override void UpdateSolver() { for (int i = 0; i < solvers.limbs.Length; i++) { solvers.limbs[i].MaintainBend(); solvers.limbs[i].MaintainRotation(); } solvers.pelvis.Update(); if (solvers.spine.bones.Length > 1) { solvers.spine.Update(); } solvers.aim.Update(); solvers.lookAt.Update(); for (int j = 0; j < solvers.limbs.Length; j++) { solvers.limbs[j].Update(); } } public void LogWarning(string message) { Warning.Log(message, ((Component)this).transform); } } [Serializable] public class BipedIKSolvers { public IKSolverLimb leftFoot = new IKSolverLimb((AvatarIKGoal)0); public IKSolverLimb rightFoot = new IKSolverLimb((AvatarIKGoal)1); public IKSolverLimb leftHand = new IKSolverLimb((AvatarIKGoal)2); public IKSolverLimb rightHand = new IKSolverLimb((AvatarIKGoal)3); public IKSolverFABRIK spine = new IKSolverFABRIK(); public IKSolverLookAt lookAt = new IKSolverLookAt(); public IKSolverAim aim = new IKSolverAim(); public Constraints pelvis = new Constraints(); private IKSolverLimb[] _limbs; private IKSolver[] _ikSolvers; public IKSolverLimb[] limbs { get { if (_limbs == null || (_limbs != null && _limbs.Length != 4)) { _limbs = new IKSolverLimb[4] { leftFoot, rightFoot, leftHand, rightHand }; } return _limbs; } } public IKSolver[] ikSolvers { get { if (_ikSolvers == null || (_ikSolvers != null && _ikSolvers.Length != 7)) { _ikSolvers = new IKSolver[7] { leftFoot, rightFoot, leftHand, rightHand, spine, lookAt, aim }; } return _ikSolvers; } } public void AssignReferences(BipedReferences references) { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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) leftHand.SetChain(references.leftUpperArm, references.leftForearm, references.leftHand, references.root); rightHand.SetChain(references.rightUpperArm, references.rightForearm, references.rightHand, references.root); leftFoot.SetChain(references.leftThigh, references.leftCalf, references.leftFoot, references.root); rightFoot.SetChain(references.rightThigh, references.rightCalf, references.rightFoot, references.root); spine.SetChain(references.spine, references.root); lookAt.SetChain(references.spine, references.head, references.eyes, references.root); aim.SetChain(references.spine, references.root); leftFoot.goal = (AvatarIKGoal)0; rightFoot.goal = (AvatarIKGoal)1; leftHand.goal = (AvatarIKGoal)2; rightHand.goal = (AvatarIKGoal)3; } } [Serializable] public abstract class Constraint { public Transform transform; public float weight; public bool isValid => (Object)(object)transform != (Object)null; public abstract void UpdateConstraint(); } [Serializable] public class ConstraintPosition : Constraint { public Vector3 position; public ConstraintPosition() { } public ConstraintPosition(Transform transform) { base.transform = transform; } public override void UpdateConstraint() { //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_0043: Unknown result type (might be due to invalid IL or missing references) if (!(weight <= 0f) && base.isValid) { transform.position = Vector3.Lerp(transform.position, position, weight); } } } [Serializable] public class ConstraintPositionOffset : Constraint { public Vector3 offset; private Vector3 defaultLocalPosition; private Vector3 lastLocalPosition; private bool initiated; private bool positionChanged => transform.localPosition != lastLocalPosition; public ConstraintPositionOffset() { } public ConstraintPositionOffset(Transform transform) { base.transform = transform; } public override void UpdateConstraint() { //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_004a: 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_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_0096: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!(weight <= 0f) && base.isValid) { if (!initiated) { defaultLocalPosition = transform.localPosition; lastLocalPosition = transform.localPosition; initiated = true; } if (positionChanged) { defaultLocalPosition = transform.localPosition; } transform.localPosition = defaultLocalPosition; Transform obj = transform; obj.position += offset * weight; lastLocalPosition = transform.localPosition; } } } [Serializable] public class ConstraintRotation : Constraint { public Quaternion rotation; public ConstraintRotation() { } public ConstraintRotation(Transform transform) { base.transform = transform; } public override void UpdateConstraint() { //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_0043: Unknown result type (might be due to invalid IL or missing references) if (!(weight <= 0f) && base.isValid) { transform.rotation = Quaternion.Slerp(transform.rotation, rotation, weight); } } } [Serializable] public class ConstraintRotationOffset : Constraint { public Quaternion offset; private Quaternion defaultRotation; private Quaternion defaultLocalRotation; private Quaternion lastLocalRotation; private Quaternion defaultTargetLocalRotation; private bool initiated; private bool rotationChanged => transform.localRotation != lastLocalRotation; public ConstraintRotationOffset() { } public ConstraintRotationOffset(Transform transform) { base.transform = transform; } public override void UpdateConstraint() { //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_004a: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!(weight <= 0f) && base.isValid) { if (!initiated) { defaultLocalRotation = transform.localRotation; lastLocalRotation = transform.localRotation; initiated = true; } if (rotationChanged) { defaultLocalRotation = transform.localRotation; } transform.localRotation = defaultLocalRotation; transform.rotation = Quaternion.Slerp(transform.rotation, offset, weight); lastLocalRotation = transform.localRotation; } } } [Serializable] public class Constraints { public Transform transform; public Transform target; public Vector3 positionOffset; public Vector3 position; [Range(0f, 1f)] public float positionWeight; public Vector3 rotationOffset; public Vector3 rotation; [Range(0f, 1f)] public float rotationWeight; public bool IsValid() { return (Object)(object)transform != (Object)null; } public void Initiate(Transform transform) { //IL_000a: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) this.transform = transform; position = transform.position; rotation = transform.eulerAngles; } public void Update() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_009e: 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_00ea: 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_0100: Unknown result type (might be due to invalid IL or missing references) if (IsValid()) { if ((Object)(object)target != (Object)null) { position = target.position; } Transform obj = transform; obj.position += positionOffset; if (positionWeight > 0f) { transform.position = Vector3.Lerp(transform.position, position, positionWeight); } if ((Object)(object)target != (Object)null) { rotation = target.eulerAngles; } transform.rotation = Quaternion.Euler(rotationOffset) * transform.rotation; if (rotationWeight > 0f) { transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(rotation), rotationWeight); } } } } [Serializable] public class Finger { [Serializable] public enum DOF { One, Three } [Tooltip("Master Weight for the finger.")] [Range(0f, 1f)] public float weight = 1f; [Tooltip("The weight of rotating the finger tip and bending the finger to the target.")] [Range(0f, 1f)] public float rotationWeight = 1f; [Tooltip("Rotational degrees of freedom. When set to 'One' the fingers will be able to be rotated only around a single axis. When 3, all 3 axes are free to rotate around.")] public DOF rotationDOF; [Tooltip("If enabled, keeps bone1 twist angle fixed relative to bone2.")] public bool fixBone1Twist; [Tooltip("The first bone of the finger.")] public Transform bone1; [Tooltip("The second bone of the finger.")] public Transform bone2; [Tooltip("The (optional) third bone of the finger. This can be ignored for thumbs.")] public Transform bone3; [Tooltip("The fingertip object. If your character doesn't have tip bones, you can create an empty GameObject and parent it to the last bone in the finger. Place it to the tip of the finger.")] public Transform tip; [Tooltip("The IK target (optional, can use IKPosition and IKRotation directly).")] public Transform target; private IKSolverLimb solver; private Quaternion bone3RelativeToTarget; private Vector3 bone3DefaultLocalPosition; private Quaternion bone3DefaultLocalRotation; private Vector3 bone1Axis; private Vector3 tipAxis; private Vector3 bone1TwistAxis; private Vector3 defaultBendNormal; public bool initiated { get; private set; } public Vector3 IKPosition { get { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return solver.IKPosition; } set { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) solver.IKPosition = value; } } public Quaternion IKRotation { get { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return solver.IKRotation; } set { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) solver.IKRotation = value; } } public bool IsValid(ref string errorMessage) { if ((Object)(object)bone1 == (Object)null || (Object)(object)bone2 == (Object)null || (Object)(object)tip == (Object)null) { errorMessage = "One of the bones in the Finger Rig is null, can not initiate solvers."; return false; } return true; } public void Initiate(Transform hand, int index) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_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_009d: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_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_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: 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_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) initiated = false; string errorMessage = string.Empty; if (!IsValid(ref errorMessage)) { Warning.Log(errorMessage, hand); return; } solver = new IKSolverLimb(); solver.IKPositionWeight = weight; solver.bendModifier = IKSolverLimb.BendModifier.Target; solver.bendModifierWeight = 1f; Vector3 val = Vector3.Cross(tip.position - bone1.position, bone2.position - bone1.position); defaultBendNormal = -((Vector3)(ref val)).normalized; solver.bendNormal = defaultBendNormal; Vector3 val2 = Vector3.Cross(bone2.position - bone1.position, tip.position - bone1.position); bone1Axis = Quaternion.Inverse(bone1.rotation) * val2; tipAxis = Quaternion.Inverse(tip.rotation) * val2; Vector3 val3 = bone2.position - bone1.position; Vector3 val4 = -Vector3.Cross(tip.position - bone1.position, bone2.position - bone1.position); Vector3.OrthoNormalize(ref val3, ref val4); bone1TwistAxis = Quaternion.Inverse(bone1.rotation) * val4; IKPosition = tip.position; IKRotation = tip.rotation; if ((Object)(object)bone3 != (Object)null) { bone3RelativeToTarget = Quaternion.Inverse(IKRotation) * bone3.rotation; bone3DefaultLocalPosition = bone3.localPosition; bone3DefaultLocalRotation = bone3.localRotation; } solver.SetChain(bone1, bone2, tip, hand); solver.Initiate(hand); initiated = true; } public void FixTransforms() { //IL_004a: 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) if (initiated && !(weight <= 0f)) { solver.FixTransforms(); if ((Object)(object)bone3 != (Object)null) { bone3.localPosition = bone3DefaultLocalPosition; bone3.localRotation = bone3DefaultLocalRotation; } } } public void StoreDefaultLocalState() { //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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (initiated) { solver.StoreDefaultLocalState(); if ((Object)(object)bone3 != (Object)null) { bone3DefaultLocalPosition = bone3.localPosition; bone3DefaultLocalRotation = bone3.localRotation; } } } public void Update(float masterWeight) { //IL_0054: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_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_00aa: 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_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if (!initiated) { return; } float num = weight * masterWeight; if (num <= 0f) { return; } solver.target = target; if ((Object)(object)target != (Object)null) { IKPosition = target.position; IKRotation = target.rotation; } if (rotationDOF == DOF.One) { Quaternion val = Quaternion.FromToRotation(IKRotation * tipAxis, bone1.rotation * bone1Axis); IKRotation = val * IKRotation; } if ((Object)(object)bone3 != (Object)null) { if (num * rotationWeight >= 1f) { bone3.rotation = IKRotation * bone3RelativeToTarget; } else { bone3.rotation = Quaternion.Lerp(bone3.rotation, IKRotation * bone3RelativeToTarget, num * rotationWeight); } } solver.IKPositionWeight = num; solver.IKRotationWeight = rotationWeight; solver.Update(); if (fixBone1Twist) { Quaternion rotation = bone2.rotation; Quaternion val2 = Quaternion.LookRotation(bone1.rotation * bone1TwistAxis, bone2.position - bone1.position); Vector3 val3 = Quaternion.Inverse(val2) * solver.bendNormal; float num2 = Mathf.Atan2(val3.x, val3.z) * 57.29578f; bone1.rotation = Quaternion.AngleAxis(num2, bone2.position - bone1.position) * bone1.rotation; bone2.rotation = rotation; } } } public class FingerRig : SolverManager { [Tooltip("The master weight for all fingers.")] [Range(0f, 1f)] public float weight = 1f; public Finger[] fingers = new Finger[0]; public bool initiated { get; private set; } public bool IsValid(ref string errorMessage) { Finger[] array = fingers; foreach (Finger finger in array) { if (!finger.IsValid(ref errorMessage)) { return false; } } return true; } [ContextMenu("Auto-detect")] public void AutoDetect() { fingers = new Finger[0]; for (int i = 0; i < ((Component)this).transform.childCount; i++) { Transform[] array = (Transform[])(object)new Transform[0]; AddChildrenRecursive(((Component)this).transform.GetChild(i), ref array); if (array.Length == 3 || array.Length == 4) { Finger finger = new Finger(); finger.bone1 = array[0]; finger.bone2 = array[1]; if (array.Length == 3) { finger.tip = array[2]; } else { finger.bone3 = array[2]; finger.tip = array[3]; } finger.weight = 1f; Array.Resize(ref fingers, fingers.Length + 1); fingers[fingers.Length - 1] = finger; } } } public void AddFinger(Transform bone1, Transform bone2, Transform bone3, Transform tip, Transform target = null) { Finger finger = new Finger(); finger.bone1 = bone1; finger.bone2 = bone2; finger.bone3 = bone3; finger.tip = tip; finger.target = target; Array.Resize(ref fingers, fingers.Length + 1); fingers[fingers.Length - 1] = finger; initiated = false; finger.Initiate(((Component)this).transform, fingers.Length - 1); if (fingers[fingers.Length - 1].initiated) { initiated = true; } } public void RemoveFinger(int index) { if ((float)index < 0f || index >= fingers.Length) { Warning.Log("RemoveFinger index out of bounds.", ((Component)this).transform); return; } if (fingers.Length == 1) { fingers = new Finger[0]; return; } Finger[] array = new Finger[fingers.Length - 1]; int num = 0; for (int i = 0; i < fingers.Length; i++) { if (i != index) { array[num] = fingers[i]; num++; } } fingers = array; } private void AddChildrenRecursive(Transform parent, ref Transform[] array) { Array.Resize(ref array, array.Length + 1); array[array.Length - 1] = parent; if (parent.childCount == 1) { AddChildrenRecursive(parent.GetChild(0), ref array); } } protected override void InitiateSolver() { initiated = true; for (int i = 0; i < fingers.Length; i++) { fingers[i].Initiate(((Component)this).transform, i); if (!fingers[i].initiated) { initiated = false; } } } public void UpdateFingerSolvers() { Finger[] array = fingers; foreach (Finger finger in array) { finger.Update(weight); } } public void FixFingerTransforms() { if (!(weight <= 0f)) { Finger[] array = fingers; foreach (Finger finger in array) { finger.FixTransforms(); } } } public void StoreDefaultLocalState() { Finger[] array = fingers; foreach (Finger finger in array) { finger.StoreDefaultLocalState(); } } protected override void UpdateSolver() { UpdateFingerSolvers(); } protected override void FixTransforms() { if (!(weight <= 0f)) { FixFingerTransforms(); } } } public abstract class Grounder : MonoBehaviour { public delegate void GrounderDelegate(); [Tooltip("The master weight. Use this to fade in/out the grounding effect.")] [Range(0f, 1f)] public float weight = 1f; [Tooltip("The Grounding solver. Not to confuse with IK solvers.")] public Grounding solver = new Grounding(); public GrounderDelegate OnPreGrounder; public GrounderDelegate OnPostGrounder; public bool initiated { get; protected set; } public abstract void ResetPosition(); protected Vector3 GetSpineOffsetTarget() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; for (int i = 0; i < solver.legs.Length; i++) { val += GetLegSpineBendVector(solver.legs[i]); } return val; } protected void LogWarning(string message) { Warning.Log(message, ((Component)this).transform); } private Vector3 GetLegSpineBendVector(Grounding.Leg leg) { //IL_0003: 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_0014: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 legSpineTangent = GetLegSpineTangent(leg); float num = (Vector3.Dot(solver.root.forward, ((Vector3)(ref legSpineTangent)).normalized) + 1f) * 0.5f; Vector3 val = leg.IKPosition - leg.transform.position; float magnitude = ((Vector3)(ref val)).magnitude; return legSpineTangent * magnitude * num; } private Vector3 GetLegSpineTangent(Grounding.Leg leg) { //IL_0007: 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_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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0090: 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_0089: 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) Vector3 result = leg.transform.position - solver.root.position; if (!solver.rotateSolver || solver.root.up == Vector3.up) { return new Vector3(result.x, 0f, result.z); } Vector3 up = solver.root.up; Vector3.OrthoNormalize(ref up, ref result); return result; } protected abstract void OpenUserManual(); protected abstract void OpenScriptReference(); } [HelpURL("http://www.root-motion.com/finalikdox/html/page9.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Grounder/Grounder Biped")] public class GrounderBipedIK : Grounder { [Tooltip("The BipedIK componet.")] public BipedIK ik; [Tooltip("The amount of spine bending towards upward slopes.")] public float spineBend = 7f; [Tooltip("The interpolation speed of spine bending.")] public float spineSpeed = 3f; private Transform[] feet = (Transform[])(object)new Transform[2]; private Quaternion[] footRotations = (Quaternion[])(object)new Quaternion[2]; private Vector3 animatedPelvisLocalPosition; private Vector3 solvedPelvisLocalPosition; private Vector3 spineOffset; private float lastWeight; [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page9.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_grounder_biped_i_k.html"); } public override void ResetPosition() { //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) solver.Reset(); spineOffset = Vector3.zero; } private bool IsReadyToInitiate() { if ((Object)(object)ik == (Object)null) { return false; } if (!ik.solvers.leftFoot.initiated) { return false; } if (!ik.solvers.rightFoot.initiated) { return false; } return true; } private void Update() { weight = Mathf.Clamp(weight, 0f, 1f); if (!(weight <= 0f) && !base.initiated && IsReadyToInitiate()) { Initiate(); } } private void Initiate() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) feet = (Transform[])(object)new Transform[2]; footRotations = (Quaternion[])(object)new Quaternion[2]; feet[0] = ik.references.leftFoot; feet[1] = ik.references.rightFoot; ref Quaternion reference = ref footRotations[0]; reference = Quaternion.identity; ref Quaternion reference2 = ref footRotations[1]; reference2 = Quaternion.identity; IKSolverFABRIK spine = ik.solvers.spine; spine.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(spine.OnPreUpdate, new IKSolver.UpdateDelegate(OnSolverUpdate)); IKSolverLimb rightFoot = ik.solvers.rightFoot; rightFoot.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(rightFoot.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostSolverUpdate)); animatedPelvisLocalPosition = ik.references.pelvis.localPosition; solver.Initiate(ik.references.root, feet); base.initiated = true; } private void OnDisable() { if (base.initiated) { ik.solvers.leftFoot.IKPositionWeight = 0f; ik.solvers.rightFoot.IKPositionWeight = 0f; } } private void OnSolverUpdate() { //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) if (!((Behaviour)this).enabled) { return; } if (weight <= 0f) { if (lastWeight <= 0f) { return; } OnDisable(); } lastWeight = weight; if (OnPreGrounder != null) { OnPreGrounder(); } if (ik.references.pelvis.localPosition != solvedPelvisLocalPosition) { animatedPelvisLocalPosition = ik.references.pelvis.localPosition; } else { ik.references.pelvis.localPosition = animatedPelvisLocalPosition; } solver.Update(); Transform pelvis = ik.references.pelvis; pelvis.position += solver.pelvis.IKOffset * weight; SetLegIK(ik.solvers.leftFoot, 0); SetLegIK(ik.solvers.rightFoot, 1); if (spineBend != 0f && ik.references.spine.Length > 0) { spineSpeed = Mathf.Clamp(spineSpeed, 0f, spineSpeed); Vector3 val = GetSpineOffsetTarget() * weight; spineOffset = Vector3.Lerp(spineOffset, val * spineBend, Time.deltaTime * spineSpeed); Quaternion rotation = ik.references.leftUpperArm.rotation; Quaternion rotation2 = ik.references.rightUpperArm.rotation; Vector3 up = solver.up; Quaternion val2 = Quaternion.FromToRotation(up, up + spineOffset); ik.references.spine[0].rotation = val2 * ik.references.spine[0].rotation; ik.references.leftUpperArm.rotation = rotation; ik.references.rightUpperArm.rotation = rotation2; ik.solvers.lookAt.SetDirty(); } if (OnPostGrounder != null) { OnPostGrounder(); } } private void SetLegIK(IKSolverLimb limb, int index) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) ref Quaternion reference = ref footRotations[index]; reference = feet[index].rotation; limb.IKPosition = solver.legs[index].IKPosition; limb.IKPositionWeight = weight; } private void OnPostSolverUpdate() { //IL_0036: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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) if (!(weight <= 0f) && ((Behaviour)this).enabled) { for (int i = 0; i < feet.Length; i++) { feet[i].rotation = Quaternion.Slerp(Quaternion.identity, solver.legs[i].rotationOffset, weight) * footRotations[i]; } solvedPelvisLocalPosition = ik.references.pelvis.localPosition; } } private void OnDestroy() { if (base.initiated && (Object)(object)ik != (Object)null) { IKSolverFABRIK spine = ik.solvers.spine; spine.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(spine.OnPreUpdate, new IKSolver.UpdateDelegate(OnSolverUpdate)); IKSolverLimb rightFoot = ik.solvers.rightFoot; rightFoot.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(rightFoot.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostSolverUpdate)); } } } [HelpURL("https://www.youtube.com/watch?v=9MiZiaJorws&index=6&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Grounder/Grounder Full Body Biped")] public class GrounderFBBIK : Grounder { [Serializable] public class SpineEffector { [Tooltip("The type of the effector.")] public FullBodyBipedEffector effectorType; [Tooltip("The weight of horizontal bend offset towards the slope.")] public float horizontalWeight = 1f; [Tooltip("The vertical bend offset weight.")] public float verticalWeight; public SpineEffector() { } public SpineEffector(FullBodyBipedEffector effectorType, float horizontalWeight, float verticalWeight) { this.effectorType = effectorType; this.horizontalWeight = horizontalWeight; this.verticalWeight = verticalWeight; } } [Tooltip("Reference to the FBBIK componet.")] public FullBodyBipedIK ik; [Tooltip("The amount of spine bending towards upward slopes.")] public float spineBend = 2f; [Tooltip("The interpolation speed of spine bending.")] public float spineSpeed = 3f; public SpineEffector[] spine = new SpineEffector[0]; private Transform[] feet = (Transform[])(object)new Transform[2]; private Vector3 spineOffset; private bool firstSolve; [ContextMenu("TUTORIAL VIDEO")] private void OpenTutorial() { Application.OpenURL("https://www.youtube.com/watch?v=9MiZiaJorws&index=6&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6"); } [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page9.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_grounder_f_b_b_i_k.html"); } public override void ResetPosition() { //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) solver.Reset(); spineOffset = Vector3.zero; } private bool IsReadyToInitiate() { if ((Object)(object)ik == (Object)null) { return false; } if (!ik.solver.initiated) { return false; } return true; } private void Update() { firstSolve = true; weight = Mathf.Clamp(weight, 0f, 1f); if (!(weight <= 0f) && !base.initiated && IsReadyToInitiate()) { Initiate(); } } private void FixedUpdate() { firstSolve = true; } private void LateUpdate() { firstSolve = true; } private void Initiate() { ik.solver.leftLegMapping.maintainRotationWeight = 1f; ik.solver.rightLegMapping.maintainRotationWeight = 1f; feet = (Transform[])(object)new Transform[2]; feet[0] = ik.solver.leftFootEffector.bone; feet[1] = ik.solver.rightFootEffector.bone; IKSolverFullBodyBiped iKSolverFullBodyBiped = ik.solver; iKSolverFullBodyBiped.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(iKSolverFullBodyBiped.OnPreUpdate, new IKSolver.UpdateDelegate(OnSolverUpdate)); solver.Initiate(ik.references.root, feet); base.initiated = true; } private void OnSolverUpdate() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_016c: 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_0199: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) if (!firstSolve) { return; } firstSolve = false; if (!((Behaviour)this).enabled || weight <= 0f) { return; } if (OnPreGrounder != null) { OnPreGrounder(); } solver.Update(); Transform pelvis = ik.references.pelvis; pelvis.position += solver.pelvis.IKOffset * weight; SetLegIK(ik.solver.leftFootEffector, solver.legs[0]); SetLegIK(ik.solver.rightFootEffector, solver.legs[1]); if (spineBend != 0f) { spineSpeed = Mathf.Clamp(spineSpeed, 0f, spineSpeed); Vector3 val = GetSpineOffsetTarget() * weight; spineOffset = Vector3.Lerp(spineOffset, val * spineBend, Time.deltaTime * spineSpeed); Vector3 val2 = ik.references.root.up * ((Vector3)(ref spineOffset)).magnitude; for (int i = 0; i < spine.Length; i++) { IKEffector effector = ik.solver.GetEffector(spine[i].effectorType); effector.positionOffset += spineOffset * spine[i].horizontalWeight + val2 * spine[i].verticalWeight; } } if (OnPostGrounder != null) { OnPostGrounder(); } } private void SetLegIK(IKEffector effector, Grounding.Leg leg) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) effector.positionOffset += (leg.IKPosition - effector.bone.position) * weight; effector.bone.rotation = Quaternion.Slerp(Quaternion.identity, leg.rotationOffset, weight) * effector.bone.rotation; } private void OnDrawGizmosSelected() { if ((Object)(object)ik == (Object)null) { ik = ((Component)this).GetComponent(); } if ((Object)(object)ik == (Object)null) { ik = ((Component)this).GetComponentInParent(); } if ((Object)(object)ik == (Object)null) { ik = ((Component)this).GetComponentInChildren(); } } private void OnDestroy() { if (base.initiated && (Object)(object)ik != (Object)null) { IKSolverFullBodyBiped iKSolverFullBodyBiped = ik.solver; iKSolverFullBodyBiped.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(iKSolverFullBodyBiped.OnPreUpdate, new IKSolver.UpdateDelegate(OnSolverUpdate)); } } } [HelpURL("http://www.root-motion.com/finalikdox/html/page9.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Grounder/Grounder IK")] public class GrounderIK : Grounder { public IK[] legs; [Tooltip("The pelvis transform. Common ancestor of all the legs.")] public Transform pelvis; [Tooltip("The root Transform of the character, with the rigidbody and the collider.")] public Transform characterRoot; [Tooltip("The weight of rotating the character root to the ground normal (range: 0 - 1).")] [Range(0f, 1f)] public float rootRotationWeight; [Tooltip("The speed of rotating the character root to the ground normal (range: 0 - inf).")] public float rootRotationSpeed = 5f; [Tooltip("The maximum angle of root rotation (range: 0 - 90).")] public float maxRootRotationAngle = 45f; private Transform[] feet = (Transform[])(object)new Transform[0]; private Quaternion[] footRotations = (Quaternion[])(object)new Quaternion[0]; private Vector3 animatedPelvisLocalPosition; private Vector3 solvedPelvisLocalPosition; private int solvedFeet; private bool solved; private float lastWeight; private Rigidbody characterRootRigidbody; [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page9.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_grounder_i_k.html"); } public override void ResetPosition() { solver.Reset(); } private bool IsReadyToInitiate() { if ((Object)(object)pelvis == (Object)null) { return false; } if (legs.Length == 0) { return false; } IK[] array = legs; foreach (IK iK in array) { if ((Object)(object)iK == (Object)null) { return false; } if (iK is FullBodyBipedIK) { LogWarning("GrounderIK does not support FullBodyBipedIK, use CCDIK, FABRIK, LimbIK or TrigonometricIK instead. If you want to use FullBodyBipedIK, use the GrounderFBBIK component."); return false; } if (iK is FABRIKRoot) { LogWarning("GrounderIK does not support FABRIKRoot, use CCDIK, FABRIK, LimbIK or TrigonometricIK instead."); return false; } if (iK is AimIK) { LogWarning("GrounderIK does not support AimIK, use CCDIK, FABRIK, LimbIK or TrigonometricIK instead."); return false; } } return true; } private void OnDisable() { if (!base.initiated) { return; } for (int i = 0; i < legs.Length; i++) { if ((Object)(object)legs[i] != (Object)null) { legs[i].GetIKSolver().IKPositionWeight = 0f; } } } private void Update() { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_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_00e6: 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_018e: 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_01a0: 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_0164: 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) weight = Mathf.Clamp(weight, 0f, 1f); if (weight <= 0f) { return; } solved = false; if (base.initiated) { rootRotationWeight = Mathf.Clamp(rootRotationWeight, 0f, 1f); rootRotationSpeed = Mathf.Clamp(rootRotationSpeed, 0f, rootRotationSpeed); if ((Object)(object)characterRoot != (Object)null && rootRotationSpeed > 0f && rootRotationWeight > 0f && solver.isGrounded) { Vector3 val = solver.GetLegsPlaneNormal(); if (rootRotationWeight < 1f) { val = Vector3.Slerp(Vector3.up, val, rootRotationWeight); } Quaternion val2 = Quaternion.FromToRotation(((Component)this).transform.up, Vector3.up) * characterRoot.rotation; Quaternion val3 = Quaternion.RotateTowards(val2, Quaternion.FromToRotation(((Component)this).transform.up, val) * characterRoot.rotation, maxRootRotationAngle); if ((Object)(object)characterRootRigidbody == (Object)null) { characterRoot.rotation = Quaternion.Lerp(characterRoot.rotation, val3, Time.deltaTime * rootRotationSpeed); } else { characterRootRigidbody.MoveRotation(Quaternion.Lerp(characterRoot.rotation, val3, Time.deltaTime * rootRotationSpeed)); } } } else if (IsReadyToInitiate()) { Initiate(); } } private void Initiate() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) feet = (Transform[])(object)new Transform[legs.Length]; footRotations = (Quaternion[])(object)new Quaternion[legs.Length]; for (int i = 0; i < feet.Length; i++) { ref Quaternion reference = ref footRotations[i]; reference = Quaternion.identity; } for (int j = 0; j < legs.Length; j++) { IKSolver.Point[] points = legs[j].GetIKSolver().GetPoints(); feet[j] = points[^1].transform; IKSolver iKSolver = legs[j].GetIKSolver(); iKSolver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(iKSolver.OnPreUpdate, new IKSolver.UpdateDelegate(OnSolverUpdate)); IKSolver iKSolver2 = legs[j].GetIKSolver(); iKSolver2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(iKSolver2.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostSolverUpdate)); } animatedPelvisLocalPosition = pelvis.localPosition; solver.Initiate(((Component)this).transform, feet); for (int k = 0; k < legs.Length; k++) { if (legs[k] is LegIK) { solver.legs[k].invertFootCenter = true; } } characterRootRigidbody = ((Component)characterRoot).GetComponent(); base.initiated = true; } private void OnSolverUpdate() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) if (!((Behaviour)this).enabled) { return; } if (weight <= 0f) { if (lastWeight <= 0f) { return; } OnDisable(); } lastWeight = weight; if (!solved) { if (OnPreGrounder != null) { OnPreGrounder(); } if (pelvis.localPosition != solvedPelvisLocalPosition) { animatedPelvisLocalPosition = pelvis.localPosition; } else { pelvis.localPosition = animatedPelvisLocalPosition; } solver.Update(); for (int i = 0; i < legs.Length; i++) { SetLegIK(i); } Transform obj = pelvis; obj.position += solver.pelvis.IKOffset * weight; solved = true; solvedFeet = 0; if (OnPostGrounder != null) { OnPostGrounder(); } } } private void SetLegIK(int index) { //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_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0061: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) ref Quaternion reference = ref footRotations[index]; reference = feet[index].rotation; if (legs[index] is LegIK) { (legs[index].GetIKSolver() as IKSolverLeg).IKRotation = Quaternion.Slerp(Quaternion.identity, solver.legs[index].rotationOffset, weight) * footRotations[index]; (legs[index].GetIKSolver() as IKSolverLeg).IKRotationWeight = 1f; } legs[index].GetIKSolver().IKPosition = solver.legs[index].IKPosition; legs[index].GetIKSolver().IKPositionWeight = weight; } private void OnPostSolverUpdate() { //IL_0063: 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_0080: 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_0096: 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) if (weight <= 0f || !((Behaviour)this).enabled) { return; } solvedFeet++; if (solvedFeet >= feet.Length) { solved = false; for (int i = 0; i < feet.Length; i++) { feet[i].rotation = Quaternion.Slerp(Quaternion.identity, solver.legs[i].rotationOffset, weight) * footRotations[i]; } solvedPelvisLocalPosition = pelvis.localPosition; } } private void OnDestroy() { if (!base.initiated) { return; } IK[] array = legs; foreach (IK iK in array) { if ((Object)(object)iK != (Object)null) { IKSolver iKSolver = iK.GetIKSolver(); iKSolver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(iKSolver.OnPreUpdate, new IKSolver.UpdateDelegate(OnSolverUpdate)); IKSolver iKSolver2 = iK.GetIKSolver(); iKSolver2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(iKSolver2.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostSolverUpdate)); } } } } [HelpURL("http://www.root-motion.com/finalikdox/html/page9.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Grounder/Grounder Quadruped")] public class GrounderQuadruped : Grounder { public struct Foot { public IKSolver solver; public Transform transform; public Quaternion rotation; public Grounding.Leg leg; public Foot(IKSolver solver, Transform transform) { //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) this.solver = solver; this.transform = transform; leg = null; rotation = transform.rotation; } } [Tooltip("The Grounding solver for the forelegs.")] public Grounding forelegSolver = new Grounding(); [Tooltip("The weight of rotating the character root to the ground angle (range: 0 - 1).")] [Range(0f, 1f)] public float rootRotationWeight = 0.5f; [Tooltip("The maximum angle of rotating the quadruped downwards (going downhill, range: -90 - 0).")] [Range(-90f, 0f)] public float minRootRotation = -25f; [Tooltip("The maximum angle of rotating the quadruped upwards (going uphill, range: 0 - 90).")] [Range(0f, 90f)] public float maxRootRotation = 45f; [Tooltip("The speed of interpolating the character root rotation (range: 0 - inf).")] public float rootRotationSpeed = 5f; [Tooltip("The maximum IK offset for the legs (range: 0 - inf).")] public float maxLegOffset = 0.5f; [Tooltip("The maximum IK offset for the forelegs (range: 0 - inf).")] public float maxForeLegOffset = 0.5f; [Tooltip("The weight of maintaining the head's rotation as it was before solving the Grounding (range: 0 - 1).")] [Range(0f, 1f)] public float maintainHeadRotationWeight = 0.5f; [Tooltip("The root Transform of the character, with the rigidbody and the collider.")] public Transform characterRoot; [Tooltip("The pelvis transform. Common ancestor of both legs and the spine.")] public Transform pelvis; [Tooltip("The last bone in the spine that is the common parent for both forelegs.")] public Transform lastSpineBone; [Tooltip("The head (optional, if you intend to maintain it's rotation).")] public Transform head; public IK[] legs; public IK[] forelegs; [HideInInspector] public Vector3 gravity = Vector3.down; private Foot[] feet = new Foot[0]; private Vector3 animatedPelvisLocalPosition; private Quaternion animatedPelvisLocalRotation; private Quaternion animatedHeadLocalRotation; private Vector3 solvedPelvisLocalPosition; private Quaternion solvedPelvisLocalRotation; private Quaternion solvedHeadLocalRotation; private int solvedFeet; private bool solved; private float angle; private Transform forefeetRoot; private Quaternion headRotation; private float lastWeight; private Rigidbody characterRootRigidbody; [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page9.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_grounder_quadruped.html"); } public override void ResetPosition() { solver.Reset(); forelegSolver.Reset(); } private bool IsReadyToInitiate() { if ((Object)(object)pelvis == (Object)null) { return false; } if ((Object)(object)lastSpineBone == (Object)null) { return false; } if (legs.Length == 0) { return false; } if (forelegs.Length == 0) { return false; } if ((Object)(object)characterRoot == (Object)null) { return false; } if (!IsReadyToInitiateLegs(legs)) { return false; } if (!IsReadyToInitiateLegs(forelegs)) { return false; } return true; } private bool IsReadyToInitiateLegs(IK[] ikComponents) { foreach (IK iK in ikComponents) { if ((Object)(object)iK == (Object)null) { return false; } if (iK is FullBodyBipedIK) { LogWarning("GrounderIK does not support FullBodyBipedIK, use CCDIK, FABRIK, LimbIK or TrigonometricIK instead. If you want to use FullBodyBipedIK, use the GrounderFBBIK component."); return false; } if (iK is FABRIKRoot) { LogWarning("GrounderIK does not support FABRIKRoot, use CCDIK, FABRIK, LimbIK or TrigonometricIK instead."); return false; } if (iK is AimIK) { LogWarning("GrounderIK does not support AimIK, use CCDIK, FABRIK, LimbIK or TrigonometricIK instead."); return false; } } return true; } private void OnDisable() { if (!base.initiated) { return; } for (int i = 0; i < feet.Length; i++) { if (feet[i].solver != null) { feet[i].solver.IKPositionWeight = 0f; } } } private void Update() { weight = Mathf.Clamp(weight, 0f, 1f); if (!(weight <= 0f)) { solved = false; if (!base.initiated && IsReadyToInitiate()) { Initiate(); } } } private void Initiate() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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) feet = new Foot[legs.Length + forelegs.Length]; Transform[] array = InitiateFeet(legs, ref feet, 0); Transform[] array2 = InitiateFeet(forelegs, ref feet, legs.Length); animatedPelvisLocalPosition = pelvis.localPosition; animatedPelvisLocalRotation = pelvis.localRotation; if ((Object)(object)head != (Object)null) { animatedHeadLocalRotation = head.localRotation; } forefeetRoot = new GameObject().transform; forefeetRoot.parent = ((Component)this).transform; ((Object)forefeetRoot).name = "Forefeet Root"; solver.Initiate(((Component)this).transform, array); forelegSolver.Initiate(forefeetRoot, array2); for (int i = 0; i < array.Length; i++) { feet[i].leg = solver.legs[i]; } for (int j = 0; j < array2.Length; j++) { feet[j + legs.Length].leg = forelegSolver.legs[j]; } characterRootRigidbody = ((Component)characterRoot).GetComponent(); base.initiated = true; } private Transform[] InitiateFeet(IK[] ikComponents, ref Foot[] f, int indexOffset) { Transform[] array = (Transform[])(object)new Transform[ikComponents.Length]; for (int i = 0; i < ikComponents.Length; i++) { IKSolver.Point[] points = ikComponents[i].GetIKSolver().GetPoints(); ref Foot reference = ref f[i + indexOffset]; reference = new Foot(ikComponents[i].GetIKSolver(), points[^1].transform); array[i] = f[i + indexOffset].transform; IKSolver iKSolver = f[i + indexOffset].solver; iKSolver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(iKSolver.OnPreUpdate, new IKSolver.UpdateDelegate(OnSolverUpdate)); IKSolver iKSolver2 = f[i + indexOffset].solver; iKSolver2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(iKSolver2.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostSolverUpdate)); } return array; } private void LateUpdate() { if (!(weight <= 0f)) { rootRotationWeight = Mathf.Clamp(rootRotationWeight, 0f, 1f); minRootRotation = Mathf.Clamp(minRootRotation, -90f, maxRootRotation); maxRootRotation = Mathf.Clamp(maxRootRotation, minRootRotation, 90f); rootRotationSpeed = Mathf.Clamp(rootRotationSpeed, 0f, rootRotationSpeed); maxLegOffset = Mathf.Clamp(maxLegOffset, 0f, maxLegOffset); maxForeLegOffset = Mathf.Clamp(maxForeLegOffset, 0f, maxForeLegOffset); maintainHeadRotationWeight = Mathf.Clamp(maintainHeadRotationWeight, 0f, 1f); RootRotation(); } } private void RootRotation() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_005a: 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_0066: 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_0070: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a3: 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_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_016b: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) if (!(rootRotationWeight <= 0f) && !(rootRotationSpeed <= 0f)) { solver.rotateSolver = true; forelegSolver.rotateSolver = true; Vector3 forward = characterRoot.forward; Vector3 val = -gravity; Vector3.OrthoNormalize(ref val, ref forward); Quaternion val2 = Quaternion.LookRotation(forward, -gravity); RaycastHit rootHit = forelegSolver.rootHit; Vector3 point = ((RaycastHit)(ref rootHit)).point; RaycastHit rootHit2 = solver.rootHit; Vector3 val3 = point - ((RaycastHit)(ref rootHit2)).point; Vector3 val4 = Quaternion.Inverse(val2) * val3; float num = Mathf.Atan2(val4.y, val4.z) * 57.29578f; num = Mathf.Clamp(num * rootRotationWeight, minRootRotation, maxRootRotation); angle = Mathf.Lerp(angle, num, Time.deltaTime * rootRotationSpeed); if ((Object)(object)characterRootRigidbody == (Object)null) { characterRoot.rotation = Quaternion.Slerp(characterRoot.rotation, Quaternion.AngleAxis(0f - angle, characterRoot.right) * val2, weight); } else { characterRootRigidbody.MoveRotation(Quaternion.Slerp(characterRoot.rotation, Quaternion.AngleAxis(0f - angle, characterRoot.right) * val2, weight)); } } } private void OnSolverUpdate() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00d9: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: 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_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_028a: 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_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) if (!((Behaviour)this).enabled) { return; } if (weight <= 0f) { if (lastWeight <= 0f) { return; } OnDisable(); } lastWeight = weight; if (solved) { return; } if (OnPreGrounder != null) { OnPreGrounder(); } if (pelvis.localPosition != solvedPelvisLocalPosition) { animatedPelvisLocalPosition = pelvis.localPosition; } else { pelvis.localPosition = animatedPelvisLocalPosition; } if (pelvis.localRotation != solvedPelvisLocalRotation) { animatedPelvisLocalRotation = pelvis.localRotation; } else { pelvis.localRotation = animatedPelvisLocalRotation; } if ((Object)(object)head != (Object)null) { if (head.localRotation != solvedHeadLocalRotation) { animatedHeadLocalRotation = head.localRotation; } else { head.localRotation = animatedHeadLocalRotation; } } for (int i = 0; i < feet.Length; i++) { feet[i].rotation = feet[i].transform.rotation; } if ((Object)(object)head != (Object)null) { headRotation = head.rotation; } UpdateForefeetRoot(); solver.Update(); forelegSolver.Update(); Transform obj = pelvis; obj.position += solver.pelvis.IKOffset * weight; Vector3 val = lastSpineBone.position - pelvis.position; Vector3 val2 = lastSpineBone.position + forelegSolver.root.up * Mathf.Clamp(forelegSolver.pelvis.heightOffset, float.NegativeInfinity, 0f) - solver.root.up * solver.pelvis.heightOffset; Vector3 val3 = val2 - pelvis.position; Quaternion val4 = Quaternion.FromToRotation(val, val3); pelvis.rotation = Quaternion.Slerp(Quaternion.identity, val4, weight) * pelvis.rotation; for (int j = 0; j < feet.Length; j++) { SetFootIK(feet[j], (j >= 2) ? maxForeLegOffset : maxLegOffset); } solved = true; solvedFeet = 0; if (OnPostGrounder != null) { OnPostGrounder(); } } private void UpdateForefeetRoot() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_002c: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_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_0066: 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_0074: 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_0092: 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_00a3: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; for (int i = 0; i < forelegSolver.legs.Length; i++) { val += forelegSolver.legs[i].transform.position; } val /= (float)forelegs.Length; Vector3 val2 = val - ((Component)this).transform.position; Vector3 up = ((Component)this).transform.up; Vector3 val3 = val2; Vector3.OrthoNormalize(ref up, ref val3); forefeetRoot.position = ((Component)this).transform.position + ((Vector3)(ref val3)).normalized * ((Vector3)(ref val2)).magnitude; } private void SetFootIK(Foot foot, float maxOffset) { //IL_0008: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = foot.leg.IKPosition - foot.transform.position; foot.solver.IKPosition = foot.transform.position + Vector3.ClampMagnitude(val, maxOffset); foot.solver.IKPositionWeight = weight; } private void OnPostSolverUpdate() { //IL_0065: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f || !((Behaviour)this).enabled) { return; } solvedFeet++; if (solvedFeet >= feet.Length) { for (int i = 0; i < feet.Length; i++) { feet[i].transform.rotation = Quaternion.Slerp(Quaternion.identity, feet[i].leg.rotationOffset, weight) * feet[i].rotation; } if ((Object)(object)head != (Object)null) { head.rotation = Quaternion.Lerp(head.rotation, headRotation, maintainHeadRotationWeight * weight); } solvedPelvisLocalPosition = pelvis.localPosition; solvedPelvisLocalRotation = pelvis.localRotation; if ((Object)(object)head != (Object)null) { solvedHeadLocalRotation = head.localRotation; } } } private void OnDestroy() { if (base.initiated) { DestroyLegs(legs); DestroyLegs(forelegs); } } private void DestroyLegs(IK[] ikComponents) { foreach (IK iK in ikComponents) { if ((Object)(object)iK != (Object)null) { IKSolver iKSolver = iK.GetIKSolver(); iKSolver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(iKSolver.OnPreUpdate, new IKSolver.UpdateDelegate(OnSolverUpdate)); IKSolver iKSolver2 = iK.GetIKSolver(); iKSolver2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(iKSolver2.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostSolverUpdate)); } } } } [HelpURL("https://www.youtube.com/watch?v=9MiZiaJorws&index=6&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Grounder/Grounder VRIK")] public class GrounderVRIK : Grounder { [Tooltip("Reference to the VRIK componet.")] public VRIK ik; private Transform[] feet = (Transform[])(object)new Transform[2]; [ContextMenu("TUTORIAL VIDEO")] private void OpenTutorial() { Application.OpenURL("https://www.youtube.com/watch?v=9MiZiaJorws&index=6&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6"); } [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page9.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_grounder_v_r_i_k.html"); } public override void ResetPosition() { solver.Reset(); } private bool IsReadyToInitiate() { if ((Object)(object)ik == (Object)null) { return false; } if (!ik.solver.initiated) { return false; } return true; } private void Update() { weight = Mathf.Clamp(weight, 0f, 1f); if (!(weight <= 0f) && !base.initiated && IsReadyToInitiate()) { Initiate(); } } private void Initiate() { feet = (Transform[])(object)new Transform[2]; feet[0] = ik.references.leftFoot; feet[1] = ik.references.rightFoot; IKSolverVR iKSolverVR = ik.solver; iKSolverVR.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(iKSolverVR.OnPreUpdate, new IKSolver.UpdateDelegate(OnSolverUpdate)); IKSolverVR iKSolverVR2 = ik.solver; iKSolverVR2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(iKSolverVR2.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostSolverUpdate)); solver.Initiate(ik.references.root, feet); base.initiated = true; } private void OnSolverUpdate() { //IL_0058: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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) if (((Behaviour)this).enabled && !(weight <= 0f)) { if (OnPreGrounder != null) { OnPreGrounder(); } solver.Update(); Transform pelvis = ik.references.pelvis; pelvis.position += solver.pelvis.IKOffset * weight; ik.solver.AddPositionOffset(IKSolverVR.PositionOffset.LeftFoot, (solver.legs[0].IKPosition - ik.references.leftFoot.position) * weight); ik.solver.AddPositionOffset(IKSolverVR.PositionOffset.RightFoot, (solver.legs[1].IKPosition - ik.references.rightFoot.position) * weight); if (OnPostGrounder != null) { OnPostGrounder(); } } } private void SetLegIK(IKSolverVR.PositionOffset positionOffset, Transform bone, Grounding.Leg leg) { //IL_000e: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) ik.solver.AddPositionOffset(positionOffset, (leg.IKPosition - bone.position) * weight); } private void OnPostSolverUpdate() { //IL_0011: 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_002e: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) ik.references.leftFoot.rotation = Quaternion.Slerp(Quaternion.identity, solver.legs[0].rotationOffset, weight) * ik.references.leftFoot.rotation; ik.references.rightFoot.rotation = Quaternion.Slerp(Quaternion.identity, solver.legs[1].rotationOffset, weight) * ik.references.rightFoot.rotation; } private void OnDrawGizmosSelected() { if ((Object)(object)ik == (Object)null) { ik = ((Component)this).GetComponent(); } if ((Object)(object)ik == (Object)null) { ik = ((Component)this).GetComponentInParent(); } if ((Object)(object)ik == (Object)null) { ik = ((Component)this).GetComponentInChildren(); } } private void OnDestroy() { if (base.initiated && (Object)(object)ik != (Object)null) { IKSolverVR iKSolverVR = ik.solver; iKSolverVR.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(iKSolverVR.OnPreUpdate, new IKSolver.UpdateDelegate(OnSolverUpdate)); IKSolverVR iKSolverVR2 = ik.solver; iKSolverVR2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(iKSolverVR2.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostSolverUpdate)); } } } [Serializable] public class Grounding { [Serializable] public enum Quality { Fastest, Simple, Best } public class Leg { public Quaternion rotationOffset = Quaternion.identity; public bool invertFootCenter; private Grounding grounding; private float lastTime; private float deltaTime; private Vector3 lastPosition; private Quaternion toHitNormal; private Quaternion r; private Vector3 up = Vector3.up; private bool doOverrideFootPosition; private Vector3 overrideFootPosition; private Vector3 transformPosition; public bool isGrounded { get; private set; } public Vector3 IKPosition { get; private set; } public bool initiated { get; private set; } public float heightFromGround { get; private set; } public Vector3 velocity { get; private set; } public Transform transform { get; private set; } public float IKOffset { get; private set; } public RaycastHit heelHit { get; private set; } public RaycastHit capsuleHit { get; private set; } public RaycastHit GetHitPoint { get { //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_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_002a: Unknown result type (might be due to invalid IL or missing references) if (grounding.quality == Quality.Best) { return capsuleHit; } return heelHit; } } public float stepHeightFromGround => Mathf.Clamp(heightFromGround, 0f - grounding.maxStep, grounding.maxStep); private float rootYOffset => grounding.GetVerticalOffset(transformPosition, grounding.root.position - up * grounding.heightOffset); public void SetFootPosition(Vector3 position) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) doOverrideFootPosition = true; overrideFootPosition = position; } public void Initiate(Grounding grounding, Transform transform) { //IL_0017: 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_0023: 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) initiated = false; this.grounding = grounding; this.transform = transform; up = Vector3.up; IKPosition = transform.position; rotationOffset = Quaternion.identity; initiated = true; OnEnable(); } public void OnEnable() { //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) if (initiated) { lastPosition = transform.position; lastTime = Time.deltaTime; } } public void Reset() { //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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) lastPosition = transform.position; lastTime = Time.deltaTime; IKOffset = 0f; IKPosition = transform.position; rotationOffset = Quaternion.identity; } public void Process() { //IL_0048: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0144: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0493: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0239: 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_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0254: 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_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: 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_0285: 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_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: 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_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: 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_0352: 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_035b: Unknown result type (might be due to invalid IL or missing references) if (!initiated || grounding.maxStep <= 0f) { return; } transformPosition = ((!doOverrideFootPosition) ? transform.position : overrideFootPosition); doOverrideFootPosition = false; deltaTime = Time.time - lastTime; lastTime = Time.time; if (deltaTime == 0f) { return; } up = grounding.up; heightFromGround = float.PositiveInfinity; velocity = (transformPosition - lastPosition) / deltaTime; lastPosition = transformPosition; Vector3 val = velocity * grounding.prediction; if (grounding.footRadius <= 0f) { grounding.quality = Quality.Fastest; } isGrounded = false; RaycastHit val13; Vector3 normal; RaycastHit val14; Vector3 point4; RaycastHit val15; switch (grounding.quality) { case Quality.Fastest: { RaycastHit raycastHit3 = GetRaycastHit(val); SetFootToPoint(((RaycastHit)(ref raycastHit3)).normal, ((RaycastHit)(ref raycastHit3)).point); if ((Object)(object)((RaycastHit)(ref raycastHit3)).collider != (Object)null) { isGrounded = true; } break; } case Quality.Simple: { heelHit = GetRaycastHit(Vector3.zero); Vector3 val4 = grounding.GetFootCenterOffset(); if (invertFootCenter) { val4 = -val4; } RaycastHit raycastHit = GetRaycastHit(val4 + val); RaycastHit raycastHit2 = GetRaycastHit(grounding.root.right * grounding.footRadius * 0.5f); RaycastHit val5 = heelHit; if ((Object)(object)((RaycastHit)(ref val5)).collider != (Object)null || (Object)(object)((RaycastHit)(ref raycastHit)).collider != (Object)null || (Object)(object)((RaycastHit)(ref raycastHit2)).collider != (Object)null) { isGrounded = true; } Vector3 point = ((RaycastHit)(ref raycastHit)).point; RaycastHit val6 = heelHit; Vector3 val7 = point - ((RaycastHit)(ref val6)).point; Vector3 point2 = ((RaycastHit)(ref raycastHit2)).point; RaycastHit val8 = heelHit; Vector3 val9 = Vector3.Cross(val7, point2 - ((RaycastHit)(ref val8)).point); Vector3 val10 = ((Vector3)(ref val9)).normalized; if (Vector3.Dot(val10, up) < 0f) { val10 = -val10; } Vector3 planeNormal = val10; RaycastHit val11 = heelHit; Vector3 point3 = ((RaycastHit)(ref val11)).point; RaycastHit val12 = heelHit; SetFootToPlane(planeNormal, point3, ((RaycastHit)(ref val12)).point); break; } case Quality.Best: { heelHit = GetRaycastHit((!invertFootCenter) ? Vector3.zero : (-grounding.GetFootCenterOffset())); capsuleHit = GetCapsuleHit(val); RaycastHit val2 = heelHit; if (!((Object)(object)((RaycastHit)(ref val2)).collider != (Object)null)) { RaycastHit val3 = capsuleHit; if (!((Object)(object)((RaycastHit)(ref val3)).collider != (Object)null)) { goto IL_0332; } } isGrounded = true; goto IL_0332; } IL_0332: val13 = capsuleHit; normal = ((RaycastHit)(ref val13)).normal; val14 = capsuleHit; point4 = ((RaycastHit)(ref val14)).point; val15 = heelHit; SetFootToPlane(normal, point4, ((RaycastHit)(ref val15)).point); break; } float num = stepHeightFromGround; if (!grounding.rootGrounded) { num = 0f; } IKOffset = Interp.LerpValue(IKOffset, num, grounding.footSpeed, grounding.footSpeed); IKOffset = Mathf.Lerp(IKOffset, num, deltaTime * grounding.footSpeed); float verticalOffset = grounding.GetVerticalOffset(transformPosition, grounding.root.position); float num2 = Mathf.Clamp(grounding.maxStep - verticalOffset, 0f, grounding.maxStep); IKOffset = Mathf.Clamp(IKOffset, 0f - num2, IKOffset); RotateFoot(); IKPosition = transformPosition - up * IKOffset; float footRotationWeight = grounding.footRotationWeight; rotationOffset = ((!(footRotationWeight >= 1f)) ? Quaternion.Slerp(Quaternion.identity, r, footRotationWeight) : r); } private RaycastHit GetCapsuleHit(Vector3 offsetFromHeel) { //IL_0003: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_0049: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00cb: 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_00cf: 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_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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_021c: 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_0208: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) RaycastHit result = default(RaycastHit); Vector3 val = grounding.GetFootCenterOffset(); if (invertFootCenter) { val = -val; } Vector3 val2 = transformPosition + val; if (grounding.overstepFallsDown) { ((RaycastHit)(ref result)).point = val2 - up * grounding.maxStep; } else { ((RaycastHit)(ref result)).point = new Vector3(val2.x, grounding.root.position.y, val2.z); } ((RaycastHit)(ref result)).normal = up; Vector3 val3 = val2 + grounding.maxStep * up; Vector3 val4 = val3 + offsetFromHeel; if (Physics.CapsuleCast(val3, val4, grounding.footRadius, -up, ref result, grounding.maxStep * 2f, LayerMask.op_Implicit(grounding.layers), (QueryTriggerInteraction)1) && float.IsNaN(((RaycastHit)(ref result)).point.x)) { ((RaycastHit)(ref result)).point = val2 - up * grounding.maxStep * 2f; ((RaycastHit)(ref result)).normal = up; } if (((RaycastHit)(ref result)).point == Vector3.zero && ((RaycastHit)(ref result)).normal == Vector3.zero) { if (grounding.overstepFallsDown) { ((RaycastHit)(ref result)).point = val2 - up * grounding.maxStep; } else { ((RaycastHit)(ref result)).point = new Vector3(val2.x, grounding.root.position.y, val2.z); } } return result; } private RaycastHit GetRaycastHit(Vector3 offsetFromHeel) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0015: 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_0079: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) RaycastHit result = default(RaycastHit); Vector3 val = transformPosition + offsetFromHeel; if (grounding.overstepFallsDown) { ((RaycastHit)(ref result)).point = val - up * grounding.maxStep; } else { ((RaycastHit)(ref result)).point = new Vector3(val.x, grounding.root.position.y, val.z); } ((RaycastHit)(ref result)).normal = up; if (grounding.maxStep <= 0f) { return result; } Physics.Raycast(val + grounding.maxStep * up, -up, ref result, grounding.maxStep * 2f, LayerMask.op_Implicit(grounding.layers), (QueryTriggerInteraction)1); if (((RaycastHit)(ref result)).point == Vector3.zero && ((RaycastHit)(ref result)).normal == Vector3.zero) { if (grounding.overstepFallsDown) { ((RaycastHit)(ref result)).point = val - up * grounding.maxStep; } else { ((RaycastHit)(ref result)).point = new Vector3(val.x, grounding.root.position.y, val.z); } } return result; } private Vector3 RotateNormal(Vector3 normal) { //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_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_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_0042: Unknown result type (might be due to invalid IL or missing references) if (grounding.quality == Quality.Best) { return normal; } return Vector3.RotateTowards(up, normal, grounding.maxFootRotationAngle * ((float)Math.PI / 180f), deltaTime); } private void SetFootToPoint(Vector3 normal, Vector3 point) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0014: 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) toHitNormal = Quaternion.FromToRotation(up, RotateNormal(normal)); heightFromGround = GetHeightFromGround(point); } private void SetFootToPlane(Vector3 planeNormal, Vector3 planePoint, Vector3 heelHitPoint) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_004a: 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_0052: 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) planeNormal = RotateNormal(planeNormal); toHitNormal = Quaternion.FromToRotation(up, planeNormal); Vector3 hitPoint = V3Tools.LineToPlane(transformPosition + up * grounding.maxStep, -up, planeNormal, planePoint); heightFromGround = GetHeightFromGround(hitPoint); float num = GetHeightFromGround(heelHitPoint); heightFromGround = Mathf.Clamp(heightFromGround, float.NegativeInfinity, num); } private float GetHeightFromGround(Vector3 hitPoint) { //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) return grounding.GetVerticalOffset(transformPosition, hitPoint) - rootYOffset; } private void RotateFoot() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_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) Quaternion rotationOffsetTarget = GetRotationOffsetTarget(); r = Quaternion.Slerp(r, rotationOffsetTarget, deltaTime * grounding.footRotationSpeed); } private Quaternion GetRotationOffsetTarget() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0063: Unknown result type (might be due to invalid IL or missing references) if (grounding.maxFootRotationAngle <= 0f) { return Quaternion.identity; } if (grounding.maxFootRotationAngle >= 180f) { return toHitNormal; } return Quaternion.RotateTowards(Quaternion.identity, toHitNormal, grounding.maxFootRotationAngle); } } public class Pelvis { private Grounding grounding; private Vector3 lastRootPosition; private float damperF; private bool initiated; private float lastTime; public Vector3 IKOffset { get; private set; } public float heightOffset { get; private set; } public void Initiate(Grounding grounding) { this.grounding = grounding; initiated = true; OnEnable(); } public void Reset() { //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_0028: Unknown result type (might be due to invalid IL or missing references) lastRootPosition = ((Component)grounding.root).transform.position; lastTime = Time.deltaTime; IKOffset = Vector3.zero; heightOffset = 0f; } public void OnEnable() { //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) if (initiated) { lastRootPosition = ((Component)grounding.root).transform.position; lastTime = Time.time; } } public void Process(float lowestOffset, float highestOffset, bool isGrounded) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_0117: Unknown result type (might be due to invalid IL or missing references) if (!initiated) { return; } float num = Time.time - lastTime; lastTime = Time.time; if (!(num <= 0f)) { float num2 = lowestOffset + highestOffset; if (!grounding.rootGrounded) { num2 = 0f; } heightOffset = Mathf.Lerp(heightOffset, num2, num * grounding.pelvisSpeed); Vector3 p = grounding.root.position - lastRootPosition; lastRootPosition = grounding.root.position; damperF = Interp.LerpValue(damperF, (!isGrounded) ? 0f : 1f, 1f, 10f); heightOffset -= grounding.GetVerticalOffset(p, Vector3.zero) * grounding.pelvisDamper * damperF; IKOffset = grounding.up * heightOffset; } } } [Tooltip("Layers to ground the character to. Make sure to exclude the layer of the character controller.")] public LayerMask layers; [Tooltip("Max step height. Maximum vertical distance of Grounding from the root of the character.")] public float maxStep = 0.5f; [Tooltip("The height offset of the root.")] public float heightOffset; [Tooltip("The speed of moving the feet up/down.")] public float footSpeed = 2.5f; [Tooltip("CapsuleCast radius. Should match approximately with the size of the feet.")] public float footRadius = 0.15f; [Tooltip("Offset of the foot center along character forward axis.")] [HideInInspector] public float footCenterOffset; [Tooltip("Amount of velocity based prediction of the foot positions.")] public float prediction = 0.05f; [Tooltip("Weight of rotating the feet to the ground normal offset.")] [Range(0f, 1f)] public float footRotationWeight = 1f; [Tooltip("Speed of slerping the feet to their grounded rotations.")] public float footRotationSpeed = 7f; [Tooltip("Max Foot Rotation Angle. Max angular offset from the foot's rotation.")] [Range(0f, 90f)] public float maxFootRotationAngle = 45f; [Tooltip("If true, solver will rotate with the character root so the character can be grounded for example to spherical planets. For performance reasons leave this off unless needed.")] public bool rotateSolver; [Tooltip("The speed of moving the character up/down.")] public float pelvisSpeed = 5f; [Tooltip("Used for smoothing out vertical pelvis movement (range 0 - 1).")] [Range(0f, 1f)] public float pelvisDamper; [Tooltip("The weight of lowering the pelvis to the lowest foot.")] public float lowerPelvisWeight = 1f; [Tooltip("The weight of lifting the pelvis to the highest foot. This is useful when you don't want the feet to go too high relative to the body when crouching.")] public float liftPelvisWeight; [Tooltip("The radius of the spherecast from the root that determines whether the character root is grounded.")] public float rootSphereCastRadius = 0.1f; [Tooltip("If false, keeps the foot that is over a ledge at the root level. If true, lowers the overstepping foot and body by the 'Max Step' value.")] public bool overstepFallsDown = true; [Tooltip("The raycasting quality. Fastest is a single raycast per foot, Simple is three raycasts, Best is one raycast and a capsule cast per foot.")] public Quality quality = Quality.Best; private bool initiated; public Leg[] legs { get; private set; } public Pelvis pelvis { get; private set; } public bool isGrounded { get; private set; } public Transform root { get; private set; } public RaycastHit rootHit { get; private set; } public bool rootGrounded { get { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = rootHit; return ((RaycastHit)(ref val)).distance < maxStep * 2f; } } public Vector3 up => (!useRootRotation) ? Vector3.up : root.up; private bool useRootRotation { get { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!rotateSolver) { return false; } if (root.up == Vector3.up) { return false; } return true; } } public RaycastHit GetRootHit(float maxDistanceMlp = 10f) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0015: 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_003e: 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_005a: 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) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00fa: 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_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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) RaycastHit result = default(RaycastHit); Vector3 val = up; Vector3 val2 = Vector3.zero; Leg[] array = legs; foreach (Leg leg in array) { val2 += leg.transform.position; } val2 /= (float)legs.Length; ((RaycastHit)(ref result)).point = val2 - val * maxStep * 10f; float num = maxDistanceMlp + 1f; ((RaycastHit)(ref result)).distance = maxStep * num; if (maxStep <= 0f) { return result; } if (quality != Quality.Best) { Physics.Raycast(val2 + val * maxStep, -val, ref result, maxStep * num, LayerMask.op_Implicit(layers), (QueryTriggerInteraction)1); } else { Physics.SphereCast(val2 + val * maxStep, rootSphereCastRadius, -up, ref result, maxStep * num, LayerMask.op_Implicit(layers), (QueryTriggerInteraction)1); } return result; } public bool IsValid(ref string errorMessage) { if ((Object)(object)root == (Object)null) { errorMessage = "Root transform is null. Can't initiate Grounding."; return false; } if (legs == null) { errorMessage = "Grounding legs is null. Can't initiate Grounding."; return false; } if (pelvis == null) { errorMessage = "Grounding pelvis is null. Can't initiate Grounding."; return false; } if (legs.Length == 0) { errorMessage = "Grounding has 0 legs. Can't initiate Grounding."; return false; } return true; } public void Initiate(Transform root, Transform[] feet) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) this.root = root; initiated = false; rootHit = default(RaycastHit); if (legs == null) { legs = new Leg[feet.Length]; } if (legs.Length != feet.Length) { legs = new Leg[feet.Length]; } for (int i = 0; i < feet.Length; i++) { if (legs[i] == null) { legs[i] = new Leg(); } } if (pelvis == null) { pelvis = new Pelvis(); } string errorMessage = string.Empty; if (!IsValid(ref errorMessage)) { Warning.Log(errorMessage, root); } else if (Application.isPlaying) { for (int j = 0; j < feet.Length; j++) { legs[j].Initiate(this, feet[j]); } pelvis.Initiate(this); initiated = true; } } public void Update() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) if (!initiated) { return; } if (LayerMask.op_Implicit(layers) == 0) { LogWarning("Grounding layers are set to nothing. Please add a ground layer."); } maxStep = Mathf.Clamp(maxStep, 0f, maxStep); footRadius = Mathf.Clamp(footRadius, 0.0001f, maxStep); pelvisDamper = Mathf.Clamp(pelvisDamper, 0f, 1f); rootSphereCastRadius = Mathf.Clamp(rootSphereCastRadius, 0.0001f, rootSphereCastRadius); maxFootRotationAngle = Mathf.Clamp(maxFootRotationAngle, 0f, 90f); prediction = Mathf.Clamp(prediction, 0f, prediction); footSpeed = Mathf.Clamp(footSpeed, 0f, footSpeed); rootHit = GetRootHit(); float num = float.NegativeInfinity; float num2 = float.PositiveInfinity; isGrounded = false; Leg[] array = legs; foreach (Leg leg in array) { leg.Process(); if (leg.IKOffset > num) { num = leg.IKOffset; } if (leg.IKOffset < num2) { num2 = leg.IKOffset; } if (leg.isGrounded) { isGrounded = true; } } num = Mathf.Max(num, 0f); num2 = Mathf.Min(num2, 0f); pelvis.Process((0f - num) * lowerPelvisWeight, (0f - num2) * liftPelvisWeight, isGrounded); } public Vector3 GetLegsPlaneNormal() { //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_001e: 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_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_0085: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_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_0062: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) if (!initiated) { return Vector3.up; } Vector3 val = up; Vector3 val2 = val; for (int i = 0; i < legs.Length; i++) { Vector3 val3 = legs[i].IKPosition - root.position; Vector3 val4 = val; Vector3 val5 = val3; Vector3.OrthoNormalize(ref val4, ref val5); Quaternion val6 = Quaternion.FromToRotation(val5, val3); val2 = val6 * val2; } return val2; } public void Reset() { if (Application.isPlaying) { pelvis.Reset(); Leg[] array = legs; foreach (Leg leg in array) { leg.Reset(); } } } public void LogWarning(string message) { Warning.Log(message, root); } public float GetVerticalOffset(Vector3 p1, Vector3 p2) { //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_001d: 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_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_0029: Unknown result type (might be due to invalid IL or missing references) if (useRootRotation) { return (Quaternion.Inverse(root.rotation) * (p1 - p2)).y; } return p1.y - p2.y; } public Vector3 Flatten(Vector3 v) { //IL_003d: 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_000d: 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_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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (useRootRotation) { Vector3 val = v; Vector3 val2 = root.up; Vector3.OrthoNormalize(ref val2, ref val); return Vector3.Project(v, val); } v.y = 0f; return v; } public Vector3 GetFootCenterOffset() { //IL_0007: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) return root.forward * footRadius + root.forward * footCenterOffset; } } [HelpURL("https://www.youtube.com/watch?v=wT8fViZpLmQ&index=3&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/Aim IK")] public class AimIK : IK { public IKSolverAim solver = new IKSolverAim(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page1.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_aim_i_k.html"); } [ContextMenu("TUTORIAL VIDEO")] private void OpenSetupTutorial() { Application.OpenURL("https://www.youtube.com/watch?v=wT8fViZpLmQ"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public override IKSolver GetIKSolver() { return solver; } } [HelpURL("http://www.root-motion.com/finalikdox/html/page2.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/Arm IK")] public class ArmIK : IK { public IKSolverArm solver = new IKSolverArm(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page2.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_arm_i_k.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public override IKSolver GetIKSolver() { return solver; } } [HelpURL("http://www.root-motion.com/finalikdox/html/page5.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/CCD IK")] public class CCDIK : IK { public IKSolverCCD solver = new IKSolverCCD(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page5.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_c_c_d_i_k.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public override IKSolver GetIKSolver() { return solver; } } [HelpURL("http://www.root-motion.com/finalikdox/html/page6.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/FABRIK")] public class FABRIK : IK { public IKSolverFABRIK solver = new IKSolverFABRIK(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page6.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_f_a_b_r_i_k.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public override IKSolver GetIKSolver() { return solver; } } [HelpURL("http://www.root-motion.com/finalikdox/html/page7.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/FABRIK Root")] public class FABRIKRoot : IK { public IKSolverFABRIKRoot solver = new IKSolverFABRIKRoot(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page7.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_f_a_b_r_i_k_root.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public override IKSolver GetIKSolver() { return solver; } } [HelpURL("https://www.youtube.com/watch?v=7__IafZGwvI&index=1&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/Full Body Biped IK")] public class FullBodyBipedIK : IK { public BipedReferences references = new BipedReferences(); public IKSolverFullBodyBiped solver = new IKSolverFullBodyBiped(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page8.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_full_body_biped_i_k.html"); } [ContextMenu("TUTORIAL VIDEO (SETUP)")] private void OpenSetupTutorial() { Application.OpenURL("https://www.youtube.com/watch?v=7__IafZGwvI"); } [ContextMenu("TUTORIAL VIDEO (INSPECTOR)")] private void OpenInspectorTutorial() { Application.OpenURL("https://www.youtube.com/watch?v=tgRMsTphjJo"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public void SetReferences(BipedReferences references, Transform rootNode) { this.references = references; solver.SetToReferences(this.references, rootNode); } public override IKSolver GetIKSolver() { return solver; } public bool ReferencesError(ref string errorMessage) { if (BipedReferences.SetupError(references, ref errorMessage)) { return true; } if (references.spine.Length == 0) { errorMessage = "References has no spine bones assigned, can not initiate the solver."; return true; } if ((Object)(object)solver.rootNode == (Object)null) { errorMessage = "Root Node bone is null, can not initiate the solver."; return true; } if ((Object)(object)solver.rootNode != (Object)(object)references.pelvis) { bool flag = false; for (int i = 0; i < references.spine.Length; i++) { if ((Object)(object)solver.rootNode == (Object)(object)references.spine[i]) { flag = true; break; } } if (!flag) { errorMessage = "The Root Node has to be one of the bones in the Spine or the Pelvis, can not initiate the solver."; return true; } } return false; } public bool ReferencesWarning(ref string warningMessage) { //IL_0024: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0067: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c5: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) if (BipedReferences.SetupWarning(references, ref warningMessage)) { return true; } Vector3 val = references.rightUpperArm.position - references.leftUpperArm.position; Vector3 val2 = solver.rootNode.position - references.leftUpperArm.position; float num = Vector3.Dot(((Vector3)(ref val)).normalized, ((Vector3)(ref val2)).normalized); if (num > 0.95f) { warningMessage = "The root node, the left upper arm and the right upper arm bones should ideally form a triangle that is as close to equilateral as possible. Currently the root node bone seems to be very close to the line between the left upper arm and the right upper arm bones. This might cause unwanted behaviour like the spine turning upside down when pulled by a hand effector.Please set the root node bone to be one of the lower bones in the spine."; return true; } Vector3 val3 = references.rightThigh.position - references.leftThigh.position; Vector3 val4 = solver.rootNode.position - references.leftThigh.position; num = Vector3.Dot(((Vector3)(ref val3)).normalized, ((Vector3)(ref val4)).normalized); if (num > 0.95f) { warningMessage = "The root node, the left thigh and the right thigh bones should ideally form a triangle that is as close to equilateral as possible. Currently the root node bone seems to be very close to the line between the left thigh and the right thigh bones. This might cause unwanted behaviour like the hip turning upside down when pulled by an effector.Please set the root node bone to be one of the higher bones in the spine."; return true; } return false; } [ContextMenu("Reinitiate")] private void Reinitiate() { SetReferences(references, solver.rootNode); } [ContextMenu("Auto-detect References")] private void AutoDetectReferences() { references = new BipedReferences(); BipedReferences.AutoDetectReferences(ref references, ((Component)this).transform, new BipedReferences.AutoDetectParams(legsParentInSpine: true, includeEyes: false)); solver.rootNode = IKSolverFullBodyBiped.DetectRootNodeBone(references); solver.SetToReferences(references, solver.rootNode); } } public abstract class IK : SolverManager { public abstract IKSolver GetIKSolver(); protected override void UpdateSolver() { if (!GetIKSolver().initiated) { InitiateSolver(); } if (GetIKSolver().initiated) { GetIKSolver().Update(); } } protected override void InitiateSolver() { if (!GetIKSolver().initiated) { GetIKSolver().Initiate(((Component)this).transform); } } protected override void FixTransforms() { if (GetIKSolver().initiated) { GetIKSolver().FixTransforms(); } } protected abstract void OpenUserManual(); protected abstract void OpenScriptReference(); } public class IKExecutionOrder : MonoBehaviour { [Tooltip("The IK components, assign in the order in which you wish to update them.")] public IK[] IKComponents; [Tooltip("Optional. Assign it if you are using 'Animate Physics' as the Update Mode.")] public Animator animator; private bool fixedFrame; private bool animatePhysics { get { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 if ((Object)(object)animator == (Object)null) { return false; } return (int)animator.updateMode == 1; } } private void Start() { for (int i = 0; i < IKComponents.Length; i++) { ((Behaviour)IKComponents[i]).enabled = false; } } private void Update() { if (!animatePhysics) { FixTransforms(); } } private void FixedUpdate() { fixedFrame = true; if (animatePhysics) { FixTransforms(); } } private void LateUpdate() { if (!animatePhysics || fixedFrame) { for (int i = 0; i < IKComponents.Length; i++) { IKComponents[i].GetIKSolver().Update(); } fixedFrame = false; } } private void FixTransforms() { for (int i = 0; i < IKComponents.Length; i++) { if (IKComponents[i].fixTransforms) { IKComponents[i].GetIKSolver().FixTransforms(); } } } } [HelpURL("http://www.root-motion.com/finalikdox/html/page11.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/Leg IK")] public class LegIK : IK { public IKSolverLeg solver = new IKSolverLeg(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page11.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_leg_i_k.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public override IKSolver GetIKSolver() { return solver; } } [HelpURL("http://www.root-motion.com/finalikdox/html/page12.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/Limb IK")] public class LimbIK : IK { public IKSolverLimb solver = new IKSolverLimb(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page12.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_limb_i_k.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public override IKSolver GetIKSolver() { return solver; } } [HelpURL("http://www.root-motion.com/finalikdox/html/page13.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/Look At IK")] public class LookAtIK : IK { public IKSolverLookAt solver = new IKSolverLookAt(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page13.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_look_at_i_k.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public override IKSolver GetIKSolver() { return solver; } } [HelpURL("http://www.root-motion.com/finalikdox/html/page15.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/Trigonometric IK")] public class TrigonometricIK : IK { public IKSolverTrigonometric solver = new IKSolverTrigonometric(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page15.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_trigonometric_i_k.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public override IKSolver GetIKSolver() { return solver; } } [AddComponentMenu("Scripts/RootMotion.FinalIK/IK/VR IK")] public class VRIK : IK { [Serializable] public class References { public Transform root; public Transform pelvis; public Transform spine; [Tooltip("Optional")] public Transform chest; [Tooltip("Optional")] public Transform neck; public Transform head; [Tooltip("Optional")] public Transform leftShoulder; public Transform leftUpperArm; public Transform leftForearm; public Transform leftHand; [Tooltip("Optional")] public Transform rightShoulder; public Transform rightUpperArm; public Transform rightForearm; public Transform rightHand; [Tooltip("VRIK also supports legless characters.If you do not wish to use legs, leave all leg references empty.")] public Transform leftThigh; [Tooltip("VRIK also supports legless characters.If you do not wish to use legs, leave all leg references empty.")] public Transform leftCalf; [Tooltip("VRIK also supports legless characters.If you do not wish to use legs, leave all leg references empty.")] public Transform leftFoot; [Tooltip("Optional")] public Transform leftToes; [Tooltip("VRIK also supports legless characters.If you do not wish to use legs, leave all leg references empty.")] public Transform rightThigh; [Tooltip("VRIK also supports legless characters.If you do not wish to use legs, leave all leg references empty.")] public Transform rightCalf; [Tooltip("VRIK also supports legless characters.If you do not wish to use legs, leave all leg references empty.")] public Transform rightFoot; [Tooltip("Optional")] public Transform rightToes; public bool isFilled { get { if ((Object)(object)root == (Object)null || (Object)(object)pelvis == (Object)null || (Object)(object)spine == (Object)null || (Object)(object)head == (Object)null || (Object)(object)leftUpperArm == (Object)null || (Object)(object)leftForearm == (Object)null || (Object)(object)leftHand == (Object)null || (Object)(object)rightUpperArm == (Object)null || (Object)(object)rightForearm == (Object)null || (Object)(object)rightHand == (Object)null) { return false; } if ((Object)(object)leftThigh == (Object)null && (Object)(object)leftCalf == (Object)null && (Object)(object)leftFoot == (Object)null && (Object)(object)rightThigh == (Object)null && (Object)(object)rightCalf == (Object)null && (Object)(object)rightFoot == (Object)null) { return true; } if ((Object)(object)leftThigh == (Object)null || (Object)(object)leftCalf == (Object)null || (Object)(object)leftFoot == (Object)null || (Object)(object)rightThigh == (Object)null || (Object)(object)rightCalf == (Object)null || (Object)(object)rightFoot == (Object)null) { return false; } return true; } } public bool isEmpty { get { if ((Object)(object)root != (Object)null || (Object)(object)pelvis != (Object)null || (Object)(object)spine != (Object)null || (Object)(object)chest != (Object)null || (Object)(object)neck != (Object)null || (Object)(object)head != (Object)null || (Object)(object)leftShoulder != (Object)null || (Object)(object)leftUpperArm != (Object)null || (Object)(object)leftForearm != (Object)null || (Object)(object)leftHand != (Object)null || (Object)(object)rightShoulder != (Object)null || (Object)(object)rightUpperArm != (Object)null || (Object)(object)rightForearm != (Object)null || (Object)(object)rightHand != (Object)null || (Object)(object)leftThigh != (Object)null || (Object)(object)leftCalf != (Object)null || (Object)(object)leftFoot != (Object)null || (Object)(object)leftToes != (Object)null || (Object)(object)rightThigh != (Object)null || (Object)(object)rightCalf != (Object)null || (Object)(object)rightFoot != (Object)null || (Object)(object)rightToes != (Object)null) { return false; } return true; } } public Transform[] GetTransforms() { return (Transform[])(object)new Transform[22] { root, pelvis, spine, chest, neck, head, leftShoulder, leftUpperArm, leftForearm, leftHand, rightShoulder, rightUpperArm, rightForearm, rightHand, leftThigh, leftCalf, leftFoot, leftToes, rightThigh, rightCalf, rightFoot, rightToes }; } public static bool AutoDetectReferences(Transform root, out References references) { references = new References(); Animator componentInChildren = ((Component)root).GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null || !componentInChildren.isHuman) { Debug.LogWarning((object)"VRIK needs a Humanoid Animator to auto-detect biped references. Please assign references manually."); return false; } references.root = root; references.pelvis = componentInChildren.GetBoneTransform((HumanBodyBones)0); references.spine = componentInChildren.GetBoneTransform((HumanBodyBones)7); references.chest = componentInChildren.GetBoneTransform((HumanBodyBones)8); references.neck = componentInChildren.GetBoneTransform((HumanBodyBones)9); references.head = componentInChildren.GetBoneTransform((HumanBodyBones)10); references.leftShoulder = componentInChildren.GetBoneTransform((HumanBodyBones)11); references.leftUpperArm = componentInChildren.GetBoneTransform((HumanBodyBones)13); references.leftForearm = componentInChildren.GetBoneTransform((HumanBodyBones)15); references.leftHand = componentInChildren.GetBoneTransform((HumanBodyBones)17); references.rightShoulder = componentInChildren.GetBoneTransform((HumanBodyBones)12); references.rightUpperArm = componentInChildren.GetBoneTransform((HumanBodyBones)14); references.rightForearm = componentInChildren.GetBoneTransform((HumanBodyBones)16); references.rightHand = componentInChildren.GetBoneTransform((HumanBodyBones)18); references.leftThigh = componentInChildren.GetBoneTransform((HumanBodyBones)1); references.leftCalf = componentInChildren.GetBoneTransform((HumanBodyBones)3); references.leftFoot = componentInChildren.GetBoneTransform((HumanBodyBones)5); references.leftToes = componentInChildren.GetBoneTransform((HumanBodyBones)19); references.rightThigh = componentInChildren.GetBoneTransform((HumanBodyBones)2); references.rightCalf = componentInChildren.GetBoneTransform((HumanBodyBones)4); references.rightFoot = componentInChildren.GetBoneTransform((HumanBodyBones)6); references.rightToes = componentInChildren.GetBoneTransform((HumanBodyBones)20); return true; } } [ContextMenuItem("Auto-detect References", "AutoDetectReferences")] [Tooltip("Bone mapping. Right-click on the component header and select 'Auto-detect References' of fill in manually if not a Humanoid character. Chest, neck, shoulder and toe bones are optional. VRIK also supports legless characters. If you do not wish to use legs, leave all leg references empty.")] public References references = new References(); [Tooltip("The VRIK solver.")] public IKSolverVR solver = new IKSolverVR(); [ContextMenu("User Manual")] protected override void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page16.html"); } [ContextMenu("Scrpt Reference")] protected override void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_v_r_i_k.html"); } [ContextMenu("TUTORIAL VIDEO (STEAMVR SETUP)")] private void OpenSetupTutorial() { Application.OpenURL("https://www.youtube.com/watch?v=6Pfx7lYQiIA&feature=youtu.be"); } [ContextMenu("Auto-detect References")] public void AutoDetectReferences() { References.AutoDetectReferences(((Component)this).transform, out references); } [ContextMenu("Guess Hand Orientations")] public void GuessHandOrientations() { solver.GuessHandOrientations(references, onlyIfZero: false); } public override IKSolver GetIKSolver() { return solver; } protected override void InitiateSolver() { if (references.isEmpty) { AutoDetectReferences(); } if (references.isFilled) { solver.SetToReferences(references); } base.InitiateSolver(); } protected override void UpdateSolver() { //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) if ((Object)(object)references.root != (Object)null && references.root.localScale == Vector3.zero) { Debug.LogError((object)"VRIK Root Transform's scale is zero, can not update VRIK. Make sure you have not calibrated the character to a zero scale.", (Object)(object)((Component)this).transform); ((Behaviour)this).enabled = false; } else { base.UpdateSolver(); } } } [Serializable] public class FABRIKChain { public FABRIK ik; [Range(0f, 1f)] public float pull = 1f; [Range(0f, 1f)] public float pin = 1f; public int[] children = new int[0]; public bool IsValid(ref string message) { if ((Object)(object)ik == (Object)null) { message = "IK unassigned in FABRIKChain."; return false; } if (!ik.solver.IsValid(ref message)) { return false; } return true; } public void Initiate() { ((Behaviour)ik).enabled = false; } public void Stage1(FABRIKChain[] chain) { //IL_006a: 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) for (int i = 0; i < children.Length; i++) { chain[children[i]].Stage1(chain); } if (children.Length == 0) { ik.solver.SolveForward(ik.solver.GetIKPosition()); } else { ik.solver.SolveForward(GetCentroid(chain)); } } public void Stage2(Vector3 rootPosition, FABRIKChain[] chain) { //IL_000c: 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) ik.solver.SolveBackward(rootPosition); for (int i = 0; i < children.Length; i++) { chain[children[i]].Stage2(ik.solver.bones[ik.solver.bones.Length - 1].transform.position, chain); } } private Vector3 GetCentroid(FABRIKChain[] chain) { //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_0022: 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_0126: 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_0066: 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_007e: 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_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_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_00d6: 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_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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_0100: Unknown result type (might be due to invalid IL or missing references) Vector3 iKPosition = ik.solver.GetIKPosition(); if (pin >= 1f) { return iKPosition; } float num = 0f; for (int i = 0; i < children.Length; i++) { num += chain[children[i]].pull; } if (num <= 0f) { return iKPosition; } if (num < 1f) { num = 1f; } Vector3 val = iKPosition; for (int j = 0; j < children.Length; j++) { Vector3 val2 = chain[children[j]].ik.solver.bones[0].solverPosition - iKPosition; float num2 = chain[children[j]].pull / num; val += val2 * num2; } if (pin <= 0f) { return val; } return val + (iKPosition - val) * pin; } } public class FBBIKArmBending : MonoBehaviour { public FullBodyBipedIK ik; public Vector3 bendDirectionOffsetLeft; public Vector3 bendDirectionOffsetRight; public Vector3 characterSpaceBendOffsetLeft; public Vector3 characterSpaceBendOffsetRight; private Quaternion leftHandTargetRotation; private Quaternion rightHandTargetRotation; private bool initiated; private void LateUpdate() { //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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ik == (Object)null)) { if (!initiated) { IKSolverFullBodyBiped solver = ik.solver; solver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostFBBIK)); initiated = true; } if ((Object)(object)ik.solver.leftHandEffector.target != (Object)null) { Vector3 left = Vector3.left; ik.solver.leftArmChain.bendConstraint.direction = ik.solver.leftHandEffector.target.rotation * left + ik.solver.leftHandEffector.target.rotation * bendDirectionOffsetLeft + ((Component)ik).transform.rotation * characterSpaceBendOffsetLeft; ik.solver.leftArmChain.bendConstraint.weight = 1f; } if ((Object)(object)ik.solver.rightHandEffector.target != (Object)null) { Vector3 right = Vector3.right; ik.solver.rightArmChain.bendConstraint.direction = ik.solver.rightHandEffector.target.rotation * right + ik.solver.rightHandEffector.target.rotation * bendDirectionOffsetRight + ((Component)ik).transform.rotation * characterSpaceBendOffsetRight; ik.solver.rightArmChain.bendConstraint.weight = 1f; } } } private void OnPostFBBIK() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ik == (Object)null)) { if ((Object)(object)ik.solver.leftHandEffector.target != (Object)null) { ik.references.leftHand.rotation = ik.solver.leftHandEffector.target.rotation; } if ((Object)(object)ik.solver.rightHandEffector.target != (Object)null) { ik.references.rightHand.rotation = ik.solver.rightHandEffector.target.rotation; } } } private void OnDestroy() { if ((Object)(object)ik != (Object)null) { IKSolverFullBodyBiped solver = ik.solver; solver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostFBBIK)); } } } public class FBBIKHeadEffector : MonoBehaviour { [Serializable] public class BendBone { [Tooltip("Assign spine and/or neck bones.")] public Transform transform; [Tooltip("The weight of rotating this bone.")] [Range(0f, 1f)] public float weight = 0.5f; private Quaternion defaultLocalRotation = Quaternion.identity; public BendBone() { }//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) public BendBone(Transform transform, float weight) { //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) this.transform = transform; this.weight = weight; } public void StoreDefaultLocalState() { //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) defaultLocalRotation = transform.localRotation; } public void FixTransforms() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) transform.localRotation = defaultLocalRotation; } } [Tooltip("Reference to the FBBIK component.")] public FullBodyBipedIK ik; [LargeHeader("Position")] [Tooltip("Master weight for positioning the head.")] [Range(0f, 1f)] public float positionWeight = 1f; [Tooltip("The weight of moving the body along with the head")] [Range(0f, 1f)] public float bodyWeight = 0.8f; [Tooltip("The weight of moving the thighs along with the head")] [Range(0f, 1f)] public float thighWeight = 0.8f; [Tooltip("If false, hands will not pull the head away if they are too far. Disabling this will improve performance significantly.")] public bool handsPullBody = true; [LargeHeader("Rotation")] [Tooltip("The weight of rotating the head bone after solving")] [Range(0f, 1f)] public float rotationWeight = 0f; [Tooltip("Clamping the rotation of the body")] [Range(0f, 1f)] public float bodyClampWeight = 0.5f; [Tooltip("Clamping the rotation of the head")] [Range(0f, 1f)] public float headClampWeight = 0.5f; [Tooltip("The master weight of bending/twisting the spine to the rotation of the head effector. This is similar to CCD, but uses the rotation of the head effector not the position.")] [Range(0f, 1f)] public float bendWeight = 1f; [Tooltip("The bones to use for bending.")] public BendBone[] bendBones = new BendBone[0]; [LargeHeader("CCD")] [Tooltip("Optional. The master weight of the CCD (Cyclic Coordinate Descent) IK effect that bends the spine towards the head effector before FBBIK solves.")] [Range(0f, 1f)] public float CCDWeight = 1f; [Tooltip("The weight of rolling the bones in towards the target")] [Range(0f, 1f)] public float roll = 0f; [Tooltip("Smoothing the CCD effect.")] [Range(0f, 1000f)] public float damper = 500f; [Tooltip("Bones to use for the CCD pass. Assign spine and/or neck bones.")] public Transform[] CCDBones = (Transform[])(object)new Transform[0]; [LargeHeader("Stretching")] [Tooltip("Stretching the spine/neck to help reach the target. This is useful for making sure the head stays locked relative to the VR headset. NB! Stretching is done after FBBIK has solved so if you have the hand effectors pinned and spine bones included in the 'Stretch Bones', the hands might become offset from their target positions.")] [Range(0f, 1f)] public float postStretchWeight = 1f; [Tooltip("Stretch magnitude limit.")] public float maxStretch = 0.1f; [Tooltip("If > 0, dampers the stretching effect.")] public float stretchDamper = 0f; [Tooltip("If true, will fix head position to this Transform no matter what. Good for making sure the head will not budge away from the VR headset")] public bool fixHead; [Tooltip("Bones to use for stretching. The more bones you add, the less noticable the effect.")] public Transform[] stretchBones = (Transform[])(object)new Transform[0]; [LargeHeader("Chest Direction")] public Vector3 chestDirection = Vector3.forward; [Range(0f, 1f)] public float chestDirectionWeight = 1f; public Transform[] chestBones = (Transform[])(object)new Transform[0]; public IKSolver.UpdateDelegate OnPostHeadEffectorFK; private Vector3 offset; private Vector3 headToBody; private Vector3 shoulderCenterToHead; private Vector3 headToLeftThigh; private Vector3 headToRightThigh; private Vector3 leftShoulderPos; private Vector3 rightShoulderPos; private float shoulderDist; private float leftShoulderDist; private float rightShoulderDist; private Quaternion chestRotation; private Quaternion headRotationRelativeToRoot; private Quaternion[] ccdDefaultLocalRotations = (Quaternion[])(object)new Quaternion[0]; private Vector3 headLocalPosition; private Quaternion headLocalRotation; private Vector3[] stretchLocalPositions = (Vector3[])(object)new Vector3[0]; private Quaternion[] stretchLocalRotations = (Quaternion[])(object)new Quaternion[0]; private Vector3[] chestLocalPositions = (Vector3[])(object)new Vector3[0]; private Quaternion[] chestLocalRotations = (Quaternion[])(object)new Quaternion[0]; private int bendBonesCount; private int ccdBonesCount; private int stretchBonesCount; private int chestBonesCount; private void Start() { //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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) IKSolverFullBodyBiped solver = ik.solver; solver.OnPreRead = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPreRead, new IKSolver.UpdateDelegate(OnPreRead)); IKSolverFullBodyBiped solver2 = ik.solver; solver2.OnPreIteration = (IKSolver.IterationDelegate)Delegate.Combine(solver2.OnPreIteration, new IKSolver.IterationDelegate(Iterate)); IKSolverFullBodyBiped solver3 = ik.solver; solver3.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver3.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostUpdate)); IKSolverFullBodyBiped solver4 = ik.solver; solver4.OnStoreDefaultLocalState = (IKSolver.UpdateDelegate)Delegate.Combine(solver4.OnStoreDefaultLocalState, new IKSolver.UpdateDelegate(OnStoreDefaultLocalState)); IKSolverFullBodyBiped solver5 = ik.solver; solver5.OnFixTransforms = (IKSolver.UpdateDelegate)Delegate.Combine(solver5.OnFixTransforms, new IKSolver.UpdateDelegate(OnFixTransforms)); OnStoreDefaultLocalState(); headRotationRelativeToRoot = Quaternion.Inverse(ik.references.root.rotation) * ik.references.head.rotation; } private void OnStoreDefaultLocalState() { //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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) BendBone[] array = bendBones; for (int i = 0; i < array.Length; i++) { array[i]?.StoreDefaultLocalState(); } ccdDefaultLocalRotations = (Quaternion[])(object)new Quaternion[CCDBones.Length]; for (int j = 0; j < CCDBones.Length; j++) { if ((Object)(object)CCDBones[j] != (Object)null) { ref Quaternion reference = ref ccdDefaultLocalRotations[j]; reference = CCDBones[j].localRotation; } } headLocalPosition = ik.references.head.localPosition; headLocalRotation = ik.references.head.localRotation; stretchLocalPositions = (Vector3[])(object)new Vector3[stretchBones.Length]; stretchLocalRotations = (Quaternion[])(object)new Quaternion[stretchBones.Length]; for (int k = 0; k < stretchBones.Length; k++) { if ((Object)(object)stretchBones[k] != (Object)null) { ref Vector3 reference2 = ref stretchLocalPositions[k]; reference2 = stretchBones[k].localPosition; ref Quaternion reference3 = ref stretchLocalRotations[k]; reference3 = stretchBones[k].localRotation; } } chestLocalPositions = (Vector3[])(object)new Vector3[chestBones.Length]; chestLocalRotations = (Quaternion[])(object)new Quaternion[chestBones.Length]; for (int l = 0; l < chestBones.Length; l++) { if ((Object)(object)chestBones[l] != (Object)null) { ref Vector3 reference4 = ref chestLocalPositions[l]; reference4 = chestBones[l].localPosition; ref Quaternion reference5 = ref chestLocalRotations[l]; reference5 = chestBones[l].localRotation; } } bendBonesCount = bendBones.Length; ccdBonesCount = CCDBones.Length; stretchBonesCount = stretchBones.Length; chestBonesCount = chestBones.Length; } private void OnFixTransforms() { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) if (!((Behaviour)this).enabled) { return; } BendBone[] array = bendBones; for (int i = 0; i < array.Length; i++) { array[i]?.FixTransforms(); } for (int j = 0; j < CCDBones.Length; j++) { if ((Object)(object)CCDBones[j] != (Object)null) { CCDBones[j].localRotation = ccdDefaultLocalRotations[j]; } } ik.references.head.localPosition = headLocalPosition; ik.references.head.localRotation = headLocalRotation; for (int k = 0; k < stretchBones.Length; k++) { if ((Object)(object)stretchBones[k] != (Object)null) { stretchBones[k].localPosition = stretchLocalPositions[k]; stretchBones[k].localRotation = stretchLocalRotations[k]; } } for (int l = 0; l < chestBones.Length; l++) { if ((Object)(object)chestBones[l] != (Object)null) { chestBones[l].localPosition = chestLocalPositions[l]; chestBones[l].localRotation = chestLocalRotations[l]; } } } private void OnPreRead() { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_012b: 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_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) if (((Behaviour)this).enabled && ((Component)this).gameObject.activeInHierarchy && ik.solver.iterations != 0) { ik.solver.FABRIKPass = handsPullBody; if (bendBonesCount != bendBones.Length || ccdBonesCount != CCDBones.Length || stretchBonesCount != stretchBones.Length || chestBonesCount != chestBones.Length) { OnStoreDefaultLocalState(); } ChestDirection(); SpineBend(); CCDPass(); offset = ((Component)this).transform.position - ik.references.head.position; shoulderDist = Vector3.Distance(ik.references.leftUpperArm.position, ik.references.rightUpperArm.position); leftShoulderDist = Vector3.Distance(ik.references.head.position, ik.references.leftUpperArm.position); rightShoulderDist = Vector3.Distance(ik.references.head.position, ik.references.rightUpperArm.position); headToBody = ik.solver.rootNode.position - ik.references.head.position; headToLeftThigh = ik.references.leftThigh.position - ik.references.head.position; headToRightThigh = ik.references.rightThigh.position - ik.references.head.position; leftShoulderPos = ik.references.leftUpperArm.position + offset * bodyWeight; rightShoulderPos = ik.references.rightUpperArm.position + offset * bodyWeight; chestRotation = Quaternion.LookRotation(ik.references.head.position - ik.references.leftUpperArm.position, ik.references.rightUpperArm.position - ik.references.leftUpperArm.position); if (OnPostHeadEffectorFK != null) { OnPostHeadEffectorFK(); } } } private void SpineBend() { //IL_0041: 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_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_0066: 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_0070: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) float num = bendWeight * ik.solver.IKPositionWeight; if (num <= 0f || bendBones.Length == 0) { return; } Quaternion rotation = ((Component)this).transform.rotation * Quaternion.Inverse(ik.references.root.rotation * headRotationRelativeToRoot); rotation = QuaTools.ClampRotation(rotation, bodyClampWeight, 2); float num2 = 1f / (float)bendBones.Length; for (int i = 0; i < bendBones.Length; i++) { if ((Object)(object)bendBones[i].transform != (Object)null) { bendBones[i].transform.rotation = Quaternion.Lerp(Quaternion.identity, rotation, num2 * bendBones[i].weight * num) * bendBones[i].transform.rotation; } } } private void CCDPass() { //IL_004a: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_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_0102: Unknown result type (might be due to invalid IL or missing references) float num = CCDWeight * ik.solver.IKPositionWeight; if (!(num <= 0f)) { for (int num2 = CCDBones.Length - 1; num2 > -1; num2--) { Quaternion val = Quaternion.FromToRotation(ik.references.head.position - CCDBones[num2].position, ((Component)this).transform.position - CCDBones[num2].position) * CCDBones[num2].rotation; float num3 = Mathf.Lerp((float)((CCDBones.Length - num2) / CCDBones.Length), 1f, roll); float num4 = Quaternion.Angle(Quaternion.identity, val); num4 = Mathf.Lerp(0f, num4, (damper - num4) / damper); CCDBones[num2].rotation = Quaternion.RotateTowards(CCDBones[num2].rotation, val, num4 * num * num3); } } } private void Iterate(int iteration) { //IL_0047: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0070: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_0130: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: 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_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_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_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_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) if (((Behaviour)this).enabled && ((Component)this).gameObject.activeInHierarchy && ik.solver.iterations != 0) { Vector3 position = ((Component)this).transform.position; Vector3 val = leftShoulderPos - ((Component)this).transform.position; leftShoulderPos = position + ((Vector3)(ref val)).normalized * leftShoulderDist; Vector3 position2 = ((Component)this).transform.position; Vector3 val2 = rightShoulderPos - ((Component)this).transform.position; rightShoulderPos = position2 + ((Vector3)(ref val2)).normalized * rightShoulderDist; Solve(ref leftShoulderPos, ref rightShoulderPos, shoulderDist); LerpSolverPosition(ik.solver.leftShoulderEffector, leftShoulderPos, positionWeight * ik.solver.IKPositionWeight, ik.solver.leftShoulderEffector.positionOffset); LerpSolverPosition(ik.solver.rightShoulderEffector, rightShoulderPos, positionWeight * ik.solver.IKPositionWeight, ik.solver.rightShoulderEffector.positionOffset); Quaternion to = Quaternion.LookRotation(((Component)this).transform.position - leftShoulderPos, rightShoulderPos - leftShoulderPos); Quaternion val3 = QuaTools.FromToRotation(chestRotation, to); Vector3 val4 = val3 * headToBody; LerpSolverPosition(ik.solver.bodyEffector, ((Component)this).transform.position + val4, positionWeight * ik.solver.IKPositionWeight, ik.solver.bodyEffector.positionOffset - ik.solver.pullBodyOffset); Quaternion val5 = Quaternion.Lerp(Quaternion.identity, val3, thighWeight); Vector3 val6 = val5 * headToLeftThigh; Vector3 val7 = val5 * headToRightThigh; LerpSolverPosition(ik.solver.leftThighEffector, ((Component)this).transform.position + val6, positionWeight * ik.solver.IKPositionWeight, ik.solver.bodyEffector.positionOffset - ik.solver.pullBodyOffset + ik.solver.leftThighEffector.positionOffset); LerpSolverPosition(ik.solver.rightThighEffector, ((Component)this).transform.position + val7, positionWeight * ik.solver.IKPositionWeight, ik.solver.bodyEffector.positionOffset - ik.solver.pullBodyOffset + ik.solver.rightThighEffector.positionOffset); } } private void OnPostUpdate() { //IL_003c: 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_004c: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (((Behaviour)this).enabled && ((Component)this).gameObject.activeInHierarchy) { PostStretching(); Quaternion rotation = QuaTools.FromToRotation(ik.references.head.rotation, ((Component)this).transform.rotation); rotation = QuaTools.ClampRotation(rotation, headClampWeight, 2); ik.references.head.rotation = Quaternion.Lerp(Quaternion.identity, rotation, rotationWeight * ik.solver.IKPositionWeight) * ik.references.head.rotation; } } private void ChestDirection() { //IL_002d: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0099: 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_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) float num = chestDirectionWeight * ik.solver.IKPositionWeight; if (num <= 0f) { return; } bool changed = false; chestDirection = V3Tools.ClampDirection(chestDirection, ik.references.root.forward, 0.45f, 2, out changed); if (!(chestDirection == Vector3.zero)) { Quaternion val = Quaternion.FromToRotation(ik.references.root.forward, chestDirection); val = Quaternion.Lerp(Quaternion.identity, val, num * (1f / (float)chestBones.Length)); Transform[] array = chestBones; foreach (Transform val2 in array) { val2.rotation = val * val2.rotation; } } } private void PostStretching() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //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) float num = postStretchWeight * ik.solver.IKPositionWeight; if (num > 0f) { Vector3 val = Vector3.ClampMagnitude(((Component)this).transform.position - ik.references.head.position, maxStretch); val *= num; stretchDamper = Mathf.Max(stretchDamper, 0f); if (stretchDamper > 0f) { val /= (1f + ((Vector3)(ref val)).magnitude) * (1f + stretchDamper); } for (int i = 0; i < stretchBones.Length; i++) { if ((Object)(object)stretchBones[i] != (Object)null) { Transform obj = stretchBones[i]; obj.position += val / (float)stretchBones.Length; } } } if (fixHead && ik.solver.IKPositionWeight > 0f) { ik.references.head.position = ((Component)this).transform.position; } } private void LerpSolverPosition(IKEffector effector, Vector3 position, float weight, Vector3 offset) { //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_0029: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) effector.GetNode(ik.solver).solverPosition = Vector3.Lerp(effector.GetNode(ik.solver).solverPosition, position + offset, weight); } private void Solve(ref Vector3 pos1, ref Vector3 pos2, float nominalDistance) { //IL_0002: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) Vector3 val = pos2 - pos1; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude != nominalDistance && magnitude != 0f) { float num = 1f; num *= 1f - nominalDistance / magnitude; Vector3 val2 = val * num * 0.5f; pos1 += val2; pos2 -= val2; } } private void OnDestroy() { if ((Object)(object)ik != (Object)null) { IKSolverFullBodyBiped solver = ik.solver; solver.OnPreRead = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPreRead, new IKSolver.UpdateDelegate(OnPreRead)); IKSolverFullBodyBiped solver2 = ik.solver; solver2.OnPreIteration = (IKSolver.IterationDelegate)Delegate.Remove(solver2.OnPreIteration, new IKSolver.IterationDelegate(Iterate)); IKSolverFullBodyBiped solver3 = ik.solver; solver3.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver3.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostUpdate)); IKSolverFullBodyBiped solver4 = ik.solver; solver4.OnStoreDefaultLocalState = (IKSolver.UpdateDelegate)Delegate.Remove(solver4.OnStoreDefaultLocalState, new IKSolver.UpdateDelegate(OnStoreDefaultLocalState)); IKSolverFullBodyBiped solver5 = ik.solver; solver5.OnFixTransforms = (IKSolver.UpdateDelegate)Delegate.Remove(solver5.OnFixTransforms, new IKSolver.UpdateDelegate(OnFixTransforms)); } } } [Serializable] public class FBIKChain { [Serializable] public class ChildConstraint { public float pushElasticity = 0f; public float pullElasticity = 0f; [SerializeField] private Transform bone1; [SerializeField] private Transform bone2; private float crossFade; private float inverseCrossFade; private int chain1Index; private int chain2Index; public float nominalDistance { get; private set; } public bool isRigid { get; private set; } public ChildConstraint(Transform bone1, Transform bone2, float pushElasticity = 0f, float pullElasticity = 0f) { this.bone1 = bone1; this.bone2 = bone2; this.pushElasticity = pushElasticity; this.pullElasticity = pullElasticity; } public void Initiate(IKSolverFullBody solver) { chain1Index = solver.GetChainIndex(bone1); chain2Index = solver.GetChainIndex(bone2); OnPreSolve(solver); } public void OnPreSolve(IKSolverFullBody solver) { //IL_001b: 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) nominalDistance = Vector3.Distance(solver.chain[chain1Index].nodes[0].transform.position, solver.chain[chain2Index].nodes[0].transform.position); isRigid = pushElasticity <= 0f && pullElasticity <= 0f; if (isRigid) { float num = solver.chain[chain1Index].pull - solver.chain[chain2Index].pull; crossFade = 1f - (0.5f + num * 0.5f); } else { crossFade = 0.5f; } inverseCrossFade = 1f - crossFade; } public void Solve(IKSolverFullBody solver) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (pushElasticity >= 1f && pullElasticity >= 1f) { return; } Vector3 val = solver.chain[chain2Index].nodes[0].solverPosition - solver.chain[chain1Index].nodes[0].solverPosition; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude != nominalDistance && magnitude != 0f) { float num = 1f; if (!isRigid) { float num2 = ((!(magnitude > nominalDistance)) ? pushElasticity : pullElasticity); num = 1f - num2; } num *= 1f - nominalDistance / magnitude; Vector3 val2 = val * num; IKSolver.Node obj = solver.chain[chain1Index].nodes[0]; obj.solverPosition += val2 * crossFade; IKSolver.Node obj2 = solver.chain[chain2Index].nodes[0]; obj2.solverPosition -= val2 * inverseCrossFade; } } } [Serializable] public enum Smoothing { None, Exponential, Cubic } [Range(0f, 1f)] public float pin; [Range(0f, 1f)] public float pull = 1f; [Range(0f, 1f)] public float push; [Range(-1f, 1f)] public float pushParent; [Range(0f, 1f)] public float reach = 0.1f; public Smoothing reachSmoothing = Smoothing.Exponential; public Smoothing pushSmoothing = Smoothing.Exponential; public IKSolver.Node[] nodes = new IKSolver.Node[0]; public int[] children = new int[0]; public ChildConstraint[] childConstraints = new ChildConstraint[0]; public IKConstraintBend bendConstraint = new IKConstraintBend(); private float rootLength; private bool initiated; private float length; private float distance; private IKSolver.Point p; private float reachForce; private float pullParentSum; private float[] crossFades; private float sqrMag1; private float sqrMag2; private float sqrMagDif; private const float maxLimbLength = 0.99999f; public FBIKChain() { } public FBIKChain(float pin, float pull, params Transform[] nodeTransforms) { this.pin = pin; this.pull = pull; SetNodes(nodeTransforms); children = new int[0]; } public void SetNodes(params Transform[] boneTransforms) { nodes = new IKSolver.Node[boneTransforms.Length]; for (int i = 0; i < boneTransforms.Length; i++) { nodes[i] = new IKSolver.Node(boneTransforms[i]); } } public int GetNodeIndex(Transform boneTransform) { for (int i = 0; i < nodes.Length; i++) { if ((Object)(object)nodes[i].transform == (Object)(object)boneTransform) { return i; } } return -1; } public bool IsValid(ref string message) { if (nodes.Length == 0) { message = "FBIK chain contains no nodes."; return false; } IKSolver.Node[] array = nodes; foreach (IKSolver.Node node in array) { if ((Object)(object)node.transform == (Object)null) { message = "Node transform is null in FBIK chain."; return false; } } return true; } public void Initiate(IKSolverFullBody solver) { //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) initiated = false; IKSolver.Node[] array = nodes; foreach (IKSolver.Node node in array) { node.solverPosition = node.transform.position; } CalculateBoneLengths(solver); ChildConstraint[] array2 = childConstraints; foreach (ChildConstraint childConstraint in array2) { childConstraint.Initiate(solver); } if (nodes.Length == 3) { bendConstraint.SetBones(nodes[0].transform, nodes[1].transform, nodes[2].transform); bendConstraint.Initiate(solver); } crossFades = new float[children.Length]; initiated = true; } public void ReadPose(IKSolverFullBody solver, bool fullBody) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) if (!initiated) { return; } for (int i = 0; i < nodes.Length; i++) { nodes[i].solverPosition = nodes[i].transform.position + nodes[i].offset; } CalculateBoneLengths(solver); if (!fullBody) { return; } for (int j = 0; j < childConstraints.Length; j++) { childConstraints[j].OnPreSolve(solver); } if (children.Length > 0) { float num = nodes[nodes.Length - 1].effectorPositionWeight; for (int k = 0; k < children.Length; k++) { num += solver.chain[children[k]].nodes[0].effectorPositionWeight * solver.chain[children[k]].pull; } num = Mathf.Clamp(num, 1f, float.PositiveInfinity); for (int l = 0; l < children.Length; l++) { crossFades[l] = solver.chain[children[l]].nodes[0].effectorPositionWeight * solver.chain[children[l]].pull / num; } } pullParentSum = 0f; for (int m = 0; m < children.Length; m++) { pullParentSum += solver.chain[children[m]].pull; } pullParentSum = Mathf.Clamp(pullParentSum, 1f, float.PositiveInfinity); if (nodes.Length == 3) { reachForce = reach * Mathf.Clamp(nodes[2].effectorPositionWeight, 0f, 1f); } else { reachForce = 0f; } if (push > 0f && nodes.Length > 1) { distance = Vector3.Distance(nodes[0].transform.position, nodes[nodes.Length - 1].transform.position); } } private void CalculateBoneLengths(IKSolverFullBody solver) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) length = 0f; for (int i = 0; i < nodes.Length - 1; i++) { nodes[i].length = Vector3.Distance(nodes[i].transform.position, nodes[i + 1].transform.position); length += nodes[i].length; if (nodes[i].length == 0f) { Warning.Log("Bone " + ((Object)nodes[i].transform).name + " - " + ((Object)nodes[i + 1].transform).name + " length is zero, can not solve.", nodes[i].transform); return; } } for (int j = 0; j < children.Length; j++) { FBIKChain obj = solver.chain[children[j]]; Vector3 val = solver.chain[children[j]].nodes[0].transform.position - nodes[nodes.Length - 1].transform.position; obj.rootLength = ((Vector3)(ref val)).magnitude; if (solver.chain[children[j]].rootLength == 0f) { return; } } if (nodes.Length == 3) { sqrMag1 = nodes[0].length * nodes[0].length; sqrMag2 = nodes[1].length * nodes[1].length; sqrMagDif = sqrMag1 - sqrMag2; } } public void Reach(IKSolverFullBody solver) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_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_009e: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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) if (!initiated) { return; } for (int i = 0; i < children.Length; i++) { solver.chain[children[i]].Reach(solver); } if (reachForce <= 0f) { return; } Vector3 val = nodes[2].solverPosition - nodes[0].solverPosition; if (!(val == Vector3.zero)) { float magnitude = ((Vector3)(ref val)).magnitude; Vector3 val2 = val / magnitude * length; float num = Mathf.Clamp(magnitude / length, 1f - reachForce, 1f + reachForce) - 1f; num = Mathf.Clamp(num + reachForce, -1f, 1f); switch (reachSmoothing) { case Smoothing.Exponential: num *= num; break; case Smoothing.Cubic: num *= num * num; break; } Vector3 val3 = val2 * Mathf.Clamp(num, 0f, magnitude); IKSolver.Node obj = nodes[0]; obj.solverPosition += val3 * (1f - nodes[0].effectorPositionWeight); IKSolver.Node obj2 = nodes[2]; obj2.solverPosition += val3; } } public Vector3 Push(IKSolverFullBody solver) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_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_0043: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_00b5: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_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_0183: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; for (int i = 0; i < children.Length; i++) { val += solver.chain[children[i]].Push(solver) * solver.chain[children[i]].pushParent; } IKSolver.Node obj = nodes[nodes.Length - 1]; obj.solverPosition += val; if (nodes.Length < 2) { return Vector3.zero; } if (push <= 0f) { return Vector3.zero; } Vector3 val2 = nodes[2].solverPosition - nodes[0].solverPosition; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude == 0f) { return Vector3.zero; } float num = 1f - magnitude / distance; if (num <= 0f) { return Vector3.zero; } switch (pushSmoothing) { case Smoothing.Exponential: num *= num; break; case Smoothing.Cubic: num *= num * num; break; } Vector3 val3 = -val2 * num * push; IKSolver.Node obj2 = nodes[0]; obj2.solverPosition += val3; return val3; } public void SolveTrigonometric(IKSolverFullBody solver, bool calculateBendDirection = false) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_00a5: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) if (!initiated) { return; } for (int i = 0; i < children.Length; i++) { solver.chain[children[i]].SolveTrigonometric(solver, calculateBendDirection); } if (nodes.Length == 3) { Vector3 val = nodes[2].solverPosition - nodes[0].solverPosition; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude != 0f) { float num = Mathf.Clamp(magnitude, 0f, length * 0.99999f); Vector3 direction = val / magnitude * num; Vector3 bendDirection = ((!calculateBendDirection || !bendConstraint.initiated) ? (nodes[1].solverPosition - nodes[0].solverPosition) : bendConstraint.GetDir(solver)); Vector3 dirToBendPoint = GetDirToBendPoint(direction, bendDirection, num); nodes[1].solverPosition = nodes[0].solverPosition + dirToBendPoint; } } } public void Stage1(IKSolverFullBody solver) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_009a: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < children.Length; i++) { solver.chain[children[i]].Stage1(solver); } if (children.Length == 0) { ForwardReach(nodes[nodes.Length - 1].solverPosition); return; } Vector3 val = nodes[nodes.Length - 1].solverPosition; SolveChildConstraints(solver); for (int j = 0; j < children.Length; j++) { Vector3 val2 = solver.chain[children[j]].nodes[0].solverPosition; if (solver.chain[children[j]].rootLength > 0f) { val2 = SolveFABRIKJoint(nodes[nodes.Length - 1].solverPosition, solver.chain[children[j]].nodes[0].solverPosition, solver.chain[children[j]].rootLength); } if (pullParentSum > 0f) { val += (val2 - nodes[nodes.Length - 1].solverPosition) * (solver.chain[children[j]].pull / pullParentSum); } } ForwardReach(Vector3.Lerp(val, nodes[nodes.Length - 1].solverPosition, pin)); } public void Stage2(IKSolverFullBody solver, Vector3 position) { //IL_0002: 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) BackwardReach(position); int num = Mathf.Clamp(solver.iterations, 2, 4); if (childConstraints.Length > 0) { for (int i = 0; i < num; i++) { SolveConstraintSystems(solver); } } for (int j = 0; j < children.Length; j++) { solver.chain[children[j]].Stage2(solver, nodes[nodes.Length - 1].solverPosition); } } public void SolveConstraintSystems(IKSolverFullBody solver) { SolveChildConstraints(solver); for (int i = 0; i < children.Length; i++) { SolveLinearConstraint(nodes[nodes.Length - 1], solver.chain[children[i]].nodes[0], crossFades[i], solver.chain[children[i]].rootLength); } } private Vector3 SolveFABRIKJoint(Vector3 pos1, Vector3 pos2, float length) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) Vector3 val = pos1 - pos2; return pos2 + ((Vector3)(ref val)).normalized * length; } protected Vector3 GetDirToBendPoint(Vector3 direction, Vector3 bendDirection, float directionMagnitude) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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_0052: 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_0068: 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_006e: Unknown result type (might be due to invalid IL or missing references) float num = (directionMagnitude * directionMagnitude + sqrMagDif) / 2f / directionMagnitude; float num2 = (float)Math.Sqrt(Mathf.Clamp(sqrMag1 - num * num, 0f, float.PositiveInfinity)); if (direction == Vector3.zero) { return Vector3.zero; } return Quaternion.LookRotation(direction, bendDirection) * new Vector3(0f, num2, num); } private void SolveChildConstraints(IKSolverFullBody solver) { for (int i = 0; i < childConstraints.Length; i++) { childConstraints[i].Solve(solver); } } private void SolveLinearConstraint(IKSolver.Node node1, IKSolver.Node node2, float crossFade, float distance) { //IL_0002: 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_0038: 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_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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) Vector3 val = node2.solverPosition - node1.solverPosition; float magnitude = ((Vector3)(ref val)).magnitude; if (distance != magnitude && magnitude != 0f) { Vector3 val2 = val * (1f - distance / magnitude); node1.solverPosition += val2 * crossFade; node2.solverPosition -= val2 * (1f - crossFade); } } public void ForwardReach(Vector3 position) { //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_003a: 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_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) nodes[nodes.Length - 1].solverPosition = position; for (int num = nodes.Length - 2; num > -1; num--) { nodes[num].solverPosition = SolveFABRIKJoint(nodes[num].solverPosition, nodes[num + 1].solverPosition, nodes[num].length); } } private void BackwardReach(Vector3 position) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (rootLength > 0f) { position = SolveFABRIKJoint(nodes[0].solverPosition, position, rootLength); } nodes[0].solverPosition = position; for (int i = 1; i < nodes.Length; i++) { nodes[i].solverPosition = SolveFABRIKJoint(nodes[i].solverPosition, nodes[i - 1].solverPosition, nodes[i - 1].length); } } } [Serializable] public class IKConstraintBend { public Transform bone1; public Transform bone2; public Transform bone3; public Transform bendGoal; public Vector3 direction = Vector3.right; public Quaternion rotationOffset; [Range(0f, 1f)] public float weight = 0f; public Vector3 defaultLocalDirection; public Vector3 defaultChildDirection; [NonSerialized] public float clampF = 0.505f; private int chainIndex1; private int nodeIndex1; private int chainIndex2; private int nodeIndex2; private int chainIndex3; private int nodeIndex3; private bool limbOrientationsSet; public bool initiated { get; private set; } public IKConstraintBend() { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) public IKConstraintBend(Transform bone1, Transform bone2, Transform bone3) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) SetBones(bone1, bone2, bone3); } public bool IsValid(IKSolverFullBody solver, Warning.Logger logger) { if ((Object)(object)bone1 == (Object)null || (Object)(object)bone2 == (Object)null || (Object)(object)bone3 == (Object)null) { logger?.Invoke("Bend Constraint contains a null reference."); return false; } if (solver.GetPoint(bone1) == null) { logger?.Invoke("Bend Constraint is referencing to a bone '" + ((Object)bone1).name + "' that does not excist in the Node Chain."); return false; } if (solver.GetPoint(bone2) == null) { logger?.Invoke("Bend Constraint is referencing to a bone '" + ((Object)bone2).name + "' that does not excist in the Node Chain."); return false; } if (solver.GetPoint(bone3) == null) { logger?.Invoke("Bend Constraint is referencing to a bone '" + ((Object)bone3).name + "' that does not excist in the Node Chain."); return false; } return true; } public void SetBones(Transform bone1, Transform bone2, Transform bone3) { this.bone1 = bone1; this.bone2 = bone2; this.bone3 = bone3; } public void Initiate(IKSolverFullBody solver) { //IL_0054: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) solver.GetChainAndNodeIndexes(bone1, out chainIndex1, out nodeIndex1); solver.GetChainAndNodeIndexes(bone2, out chainIndex2, out nodeIndex2); solver.GetChainAndNodeIndexes(bone3, out chainIndex3, out nodeIndex3); direction = OrthoToBone1(solver, OrthoToLimb(solver, bone2.position - bone1.position)); if (!limbOrientationsSet) { defaultLocalDirection = Quaternion.Inverse(bone1.rotation) * direction; Vector3 val = bone3.position - bone1.position; Vector3 val2 = Vector3.Cross(((Vector3)(ref val)).normalized, direction); defaultChildDirection = Quaternion.Inverse(bone3.rotation) * val2; } initiated = true; } public void SetLimbOrientation(Vector3 upper, Vector3 lower, Vector3 last) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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) if (upper == Vector3.zero) { Debug.LogError((object)"Attempting to set limb orientation to Vector3.zero axis"); } if (lower == Vector3.zero) { Debug.LogError((object)"Attempting to set limb orientation to Vector3.zero axis"); } if (last == Vector3.zero) { Debug.LogError((object)"Attempting to set limb orientation to Vector3.zero axis"); } defaultLocalDirection = ((Vector3)(ref upper)).normalized; defaultChildDirection = ((Vector3)(ref last)).normalized; limbOrientationsSet = true; } public void LimitBend(float solverWeight, float positionWeight) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) if (initiated) { Vector3 val = bone1.rotation * -defaultLocalDirection; Vector3 val2 = bone3.position - bone2.position; bool changed = false; Vector3 val3 = V3Tools.ClampDirection(val2, val, clampF * solverWeight, 0, out changed); Quaternion rotation = bone3.rotation; if (changed) { Quaternion val4 = Quaternion.FromToRotation(val2, val3); bone2.rotation = val4 * bone2.rotation; } if (positionWeight > 0f) { Vector3 val5 = bone2.position - bone1.position; Vector3 val6 = bone3.position - bone2.position; Vector3.OrthoNormalize(ref val5, ref val6); Quaternion val7 = Quaternion.FromToRotation(val6, val); bone2.rotation = Quaternion.Lerp(bone2.rotation, val7 * bone2.rotation, positionWeight * solverWeight); } if (changed || positionWeight > 0f) { bone3.rotation = rotation; } } } public Vector3 GetDir(IKSolverFullBody solver) { //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_003d: 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_005f: 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_01ef: 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_00bc: 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_00cd: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0070: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) if (!initiated) { return Vector3.zero; } float num = weight * solver.IKPositionWeight; if ((Object)(object)bendGoal != (Object)null) { Vector3 val = bendGoal.position - solver.GetNode(chainIndex1, nodeIndex1).solverPosition; if (val != Vector3.zero) { direction = val; } } if (num >= 1f) { return ((Vector3)(ref direction)).normalized; } Vector3 val2 = solver.GetNode(chainIndex3, nodeIndex3).solverPosition - solver.GetNode(chainIndex1, nodeIndex1).solverPosition; Quaternion val3 = Quaternion.FromToRotation(bone3.position - bone1.position, val2); Vector3 val4 = val3 * (bone2.position - bone1.position); if (solver.GetNode(chainIndex3, nodeIndex3).effectorRotationWeight > 0f) { Vector3 val5 = -Vector3.Cross(val2, solver.GetNode(chainIndex3, nodeIndex3).solverRotation * defaultChildDirection); val4 = Vector3.Lerp(val4, val5, solver.GetNode(chainIndex3, nodeIndex3).effectorRotationWeight); } if (rotationOffset != Quaternion.identity) { Quaternion val6 = Quaternion.FromToRotation(rotationOffset * val2, val2); val4 = val6 * rotationOffset * val4; } if (num <= 0f) { return val4; } return Vector3.Lerp(val4, ((Vector3)(ref direction)).normalized, num); } private Vector3 OrthoToLimb(IKSolverFullBody solver, Vector3 tangent) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector3 val = solver.GetNode(chainIndex3, nodeIndex3).solverPosition - solver.GetNode(chainIndex1, nodeIndex1).solverPosition; Vector3.OrthoNormalize(ref val, ref tangent); return tangent; } private Vector3 OrthoToBone1(IKSolverFullBody solver, Vector3 tangent) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector3 val = solver.GetNode(chainIndex2, nodeIndex2).solverPosition - solver.GetNode(chainIndex1, nodeIndex1).solverPosition; Vector3.OrthoNormalize(ref val, ref tangent); return tangent; } } [Serializable] public class IKEffector { public Transform bone; public Transform target; [Range(0f, 1f)] public float positionWeight; [Range(0f, 1f)] public float rotationWeight; public Vector3 position = Vector3.zero; public Quaternion rotation = Quaternion.identity; public Vector3 positionOffset; public bool effectChildNodes = true; [Range(0f, 1f)] public float maintainRelativePositionWeight; public Transform[] childBones = (Transform[])(object)new Transform[0]; public Transform planeBone1; public Transform planeBone2; public Transform planeBone3; public Quaternion planeRotationOffset = Quaternion.identity; private float posW; private float rotW; private Vector3[] localPositions = (Vector3[])(object)new Vector3[0]; private bool usePlaneNodes; private Quaternion animatedPlaneRotation = Quaternion.identity; private Vector3 animatedPosition; private bool firstUpdate; private int chainIndex = -1; private int nodeIndex = -1; private int plane1ChainIndex; private int plane1NodeIndex = -1; private int plane2ChainIndex = -1; private int plane2NodeIndex = -1; private int plane3ChainIndex = -1; private int plane3NodeIndex = -1; private int[] childChainIndexes = new int[0]; private int[] childNodeIndexes = new int[0]; public bool isEndEffector { get; private set; } public IKEffector() { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) public IKEffector(Transform bone, Transform[] childBones) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) this.bone = bone; this.childBones = childBones; } public IKSolver.Node GetNode(IKSolverFullBody solver) { return solver.chain[chainIndex].nodes[nodeIndex]; } public void PinToBone(float positionWeight, float rotationWeight) { //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_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) position = bone.position; this.positionWeight = Mathf.Clamp(positionWeight, 0f, 1f); rotation = bone.rotation; this.rotationWeight = Mathf.Clamp(rotationWeight, 0f, 1f); } public bool IsValid(IKSolver solver, ref string message) { if ((Object)(object)bone == (Object)null) { message = "IK Effector bone is null."; return false; } if (solver.GetPoint(bone) == null) { message = "IK Effector is referencing to a bone '" + ((Object)bone).name + "' that does not excist in the Node Chain."; return false; } Transform[] array = childBones; foreach (Transform val in array) { if ((Object)(object)val == (Object)null) { message = "IK Effector contains a null reference."; return false; } } Transform[] array2 = childBones; foreach (Transform val2 in array2) { if (solver.GetPoint(val2) == null) { message = "IK Effector is referencing to a bone '" + ((Object)val2).name + "' that does not excist in the Node Chain."; return false; } } if ((Object)(object)planeBone1 != (Object)null && solver.GetPoint(planeBone1) == null) { message = "IK Effector is referencing to a bone '" + ((Object)planeBone1).name + "' that does not excist in the Node Chain."; return false; } if ((Object)(object)planeBone2 != (Object)null && solver.GetPoint(planeBone2) == null) { message = "IK Effector is referencing to a bone '" + ((Object)planeBone2).name + "' that does not excist in the Node Chain."; return false; } if ((Object)(object)planeBone3 != (Object)null && solver.GetPoint(planeBone3) == null) { message = "IK Effector is referencing to a bone '" + ((Object)planeBone3).name + "' that does not excist in the Node Chain."; return false; } return true; } public void Initiate(IKSolverFullBody solver) { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) position = bone.position; rotation = bone.rotation; animatedPlaneRotation = Quaternion.identity; solver.GetChainAndNodeIndexes(bone, out chainIndex, out nodeIndex); childChainIndexes = new int[childBones.Length]; childNodeIndexes = new int[childBones.Length]; for (int i = 0; i < childBones.Length; i++) { solver.GetChainAndNodeIndexes(childBones[i], out childChainIndexes[i], out childNodeIndexes[i]); } localPositions = (Vector3[])(object)new Vector3[childBones.Length]; usePlaneNodes = false; if ((Object)(object)planeBone1 != (Object)null) { solver.GetChainAndNodeIndexes(planeBone1, out plane1ChainIndex, out plane1NodeIndex); if ((Object)(object)planeBone2 != (Object)null) { solver.GetChainAndNodeIndexes(planeBone2, out plane2ChainIndex, out plane2NodeIndex); if ((Object)(object)planeBone3 != (Object)null) { solver.GetChainAndNodeIndexes(planeBone3, out plane3ChainIndex, out plane3NodeIndex); usePlaneNodes = true; } } isEndEffector = true; } else { isEndEffector = false; } } public void ResetOffset(IKSolverFullBody solver) { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) solver.GetNode(chainIndex, nodeIndex).offset = Vector3.zero; for (int i = 0; i < childChainIndexes.Length; i++) { solver.GetNode(childChainIndexes[i], childNodeIndexes[i]).offset = Vector3.zero; } } public void SetToTarget() { //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_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) if (!((Object)(object)target == (Object)null)) { position = target.position; rotation = target.rotation; } } public void OnPreSolve(IKSolverFullBody solver) { //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_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_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: 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_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0283: 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_0298: Unknown result type (might be due to invalid IL or missing references) positionWeight = Mathf.Clamp(positionWeight, 0f, 1f); rotationWeight = Mathf.Clamp(rotationWeight, 0f, 1f); maintainRelativePositionWeight = Mathf.Clamp(maintainRelativePositionWeight, 0f, 1f); posW = positionWeight * solver.IKPositionWeight; rotW = rotationWeight * solver.IKPositionWeight; solver.GetNode(chainIndex, nodeIndex).effectorPositionWeight = posW; solver.GetNode(chainIndex, nodeIndex).effectorRotationWeight = rotW; solver.GetNode(chainIndex, nodeIndex).solverRotation = rotation; if (float.IsInfinity(positionOffset.x) || float.IsInfinity(positionOffset.y) || float.IsInfinity(positionOffset.z)) { Debug.LogError((object)"Invalid IKEffector.positionOffset (contains Infinity)! Please make sure not to set IKEffector.positionOffset to infinite values.", (Object)(object)bone); } if (float.IsNaN(positionOffset.x) || float.IsNaN(positionOffset.y) || float.IsNaN(positionOffset.z)) { Debug.LogError((object)"Invalid IKEffector.positionOffset (contains NaN)! Please make sure not to set IKEffector.positionOffset to NaN values.", (Object)(object)bone); } if (((Vector3)(ref positionOffset)).sqrMagnitude > 1E+10f) { Debug.LogError((object)"Additive effector positionOffset detected in Full Body IK (extremely large value). Make sure you are not circularily adding to effector positionOffset each frame.", (Object)(object)bone); } if (float.IsInfinity(position.x) || float.IsInfinity(position.y) || float.IsInfinity(position.z)) { Debug.LogError((object)"Invalid IKEffector.position (contains Infinity)!"); } IKSolver.Node node = solver.GetNode(chainIndex, nodeIndex); node.offset += positionOffset * solver.IKPositionWeight; if (effectChildNodes && solver.iterations > 0) { for (int i = 0; i < childBones.Length; i++) { ref Vector3 reference = ref localPositions[i]; reference = ((Component)childBones[i]).transform.position - ((Component)bone).transform.position; IKSolver.Node node2 = solver.GetNode(childChainIndexes[i], childNodeIndexes[i]); node2.offset += positionOffset * solver.IKPositionWeight; } } if (usePlaneNodes && maintainRelativePositionWeight > 0f) { animatedPlaneRotation = Quaternion.LookRotation(planeBone2.position - planeBone1.position, planeBone3.position - planeBone1.position); } firstUpdate = true; } public void OnPostWrite() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) positionOffset = Vector3.zero; } private Quaternion GetPlaneRotation(IKSolverFullBody solver) { //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_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_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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0088: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) Vector3 solverPosition = solver.GetNode(plane1ChainIndex, plane1NodeIndex).solverPosition; Vector3 solverPosition2 = solver.GetNode(plane2ChainIndex, plane2NodeIndex).solverPosition; Vector3 solverPosition3 = solver.GetNode(plane3ChainIndex, plane3NodeIndex).solverPosition; Vector3 val = solverPosition2 - solverPosition; Vector3 val2 = solverPosition3 - solverPosition; if (val == Vector3.zero) { Warning.Log("Make sure you are not placing 2 or more FBBIK effectors of the same chain to exactly the same position.", bone); return Quaternion.identity; } return Quaternion.LookRotation(val, val2); } public void Update(IKSolverFullBody solver) { //IL_005c: 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_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_0014: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) if (firstUpdate) { animatedPosition = bone.position + solver.GetNode(chainIndex, nodeIndex).offset; firstUpdate = false; } solver.GetNode(chainIndex, nodeIndex).solverPosition = Vector3.Lerp(GetPosition(solver, out planeRotationOffset), position, posW); if (effectChildNodes) { for (int i = 0; i < childBones.Length; i++) { solver.GetNode(childChainIndexes[i], childNodeIndexes[i]).solverPosition = Vector3.Lerp(solver.GetNode(childChainIndexes[i], childNodeIndexes[i]).solverPosition, solver.GetNode(chainIndex, nodeIndex).solverPosition + localPositions[i], posW); } } } private Vector3 GetPosition(IKSolverFullBody solver, out Quaternion planeRotationOffset) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00bb: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_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_0104: Unknown result type (might be due to invalid IL or missing references) planeRotationOffset = Quaternion.identity; if (!isEndEffector) { return solver.GetNode(chainIndex, nodeIndex).solverPosition; } if (maintainRelativePositionWeight <= 0f) { return animatedPosition; } Vector3 val = bone.position; Vector3 val2 = val - planeBone1.position; planeRotationOffset = GetPlaneRotation(solver) * Quaternion.Inverse(animatedPlaneRotation); val = solver.GetNode(plane1ChainIndex, plane1NodeIndex).solverPosition + planeRotationOffset * val2; planeRotationOffset = Quaternion.Lerp(Quaternion.identity, planeRotationOffset, maintainRelativePositionWeight); return Vector3.Lerp(animatedPosition, val + solver.GetNode(chainIndex, nodeIndex).offset, maintainRelativePositionWeight); } } [Serializable] public class IKMapping { [Serializable] public class BoneMap { public Transform transform; public int chainIndex = -1; public int nodeIndex = -1; public Vector3 defaultLocalPosition; public Quaternion defaultLocalRotation; public Vector3 localSwingAxis; public Vector3 localTwistAxis; public Vector3 planePosition; public Vector3 ikPosition; public Quaternion defaultLocalTargetRotation; private Quaternion maintainRotation; public float length; public Quaternion animatedRotation; private Transform planeBone1; private Transform planeBone2; private Transform planeBone3; private int plane1ChainIndex = -1; private int plane1NodeIndex = -1; private int plane2ChainIndex = -1; private int plane2NodeIndex = -1; private int plane3ChainIndex = -1; private int plane3NodeIndex = -1; public Vector3 swingDirection => transform.rotation * localSwingAxis; public bool isNodeBone => nodeIndex != -1; private Quaternion lastAnimatedTargetRotation { get { //IL_0007: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (planeBone1.position == planeBone3.position) { return Quaternion.identity; } return Quaternion.LookRotation(planeBone2.position - planeBone1.position, planeBone3.position - planeBone1.position); } } public void Initiate(Transform transform, IKSolverFullBody solver) { this.transform = transform; solver.GetChainAndNodeIndexes(transform, out chainIndex, out nodeIndex); } public void StoreDefaultLocalState() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) defaultLocalPosition = transform.localPosition; defaultLocalRotation = transform.localRotation; } public void FixTransform(bool position) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (position) { transform.localPosition = defaultLocalPosition; } transform.localRotation = defaultLocalRotation; } public void SetLength(BoneMap nextBone) { //IL_0008: 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) length = Vector3.Distance(transform.position, nextBone.transform.position); } public void SetLocalSwingAxis(BoneMap swingTarget) { SetLocalSwingAxis(swingTarget, this); } public void SetLocalSwingAxis(BoneMap bone1, BoneMap bone2) { //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_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) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) localSwingAxis = Quaternion.Inverse(transform.rotation) * (bone1.transform.position - bone2.transform.position); } public void SetLocalTwistAxis(Vector3 twistDirection, Vector3 normalDirection) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3.OrthoNormalize(ref normalDirection, ref twistDirection); localTwistAxis = Quaternion.Inverse(transform.rotation) * twistDirection; } public void SetPlane(IKSolverFullBody solver, Transform planeBone1, Transform planeBone2, Transform planeBone3) { this.planeBone1 = planeBone1; this.planeBone2 = planeBone2; this.planeBone3 = planeBone3; solver.GetChainAndNodeIndexes(planeBone1, out plane1ChainIndex, out plane1NodeIndex); solver.GetChainAndNodeIndexes(planeBone2, out plane2ChainIndex, out plane2NodeIndex); solver.GetChainAndNodeIndexes(planeBone3, out plane3ChainIndex, out plane3NodeIndex); UpdatePlane(rotation: true, position: true); } public void UpdatePlane(bool rotation, bool position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0020: 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_0038: 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_0052: Unknown result type (might be due to invalid IL or missing references) Quaternion val = lastAnimatedTargetRotation; if (rotation) { defaultLocalTargetRotation = QuaTools.RotationToLocalSpace(transform.rotation, val); } if (position) { planePosition = Quaternion.Inverse(val) * (transform.position - planeBone1.position); } } public void SetIKPosition() { //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) ikPosition = transform.position; } public void MaintainRotation() { //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) maintainRotation = transform.rotation; } public void SetToIKPosition() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) transform.position = ikPosition; } public void FixToNode(IKSolverFullBody solver, float weight, IKSolver.Node fixNode = null) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (fixNode == null) { fixNode = solver.GetNode(chainIndex, nodeIndex); } if (weight >= 1f) { transform.position = fixNode.solverPosition; } else { transform.position = Vector3.Lerp(transform.position, fixNode.solverPosition, weight); } } public Vector3 GetPlanePosition(IKSolverFullBody solver) { //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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: Unknown result type (might be due to invalid IL or missing references) return solver.GetNode(plane1ChainIndex, plane1NodeIndex).solverPosition + GetTargetRotation(solver) * planePosition; } public void PositionToPlane(IKSolverFullBody solver) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) transform.position = GetPlanePosition(solver); } public void RotateToPlane(IKSolverFullBody solver, float weight) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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_003d: 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_0044: 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) Quaternion val = GetTargetRotation(solver) * defaultLocalTargetRotation; if (weight >= 1f) { transform.rotation = val; } else { transform.rotation = Quaternion.Lerp(transform.rotation, val, weight); } } public void Swing(Vector3 swingTarget, float weight) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Swing(swingTarget, transform.position, weight); } public void Swing(Vector3 pos1, Vector3 pos2, float weight) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0033: 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) //IL_0064: 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) Quaternion val = Quaternion.FromToRotation(transform.rotation * localSwingAxis, pos1 - pos2) * transform.rotation; if (weight >= 1f) { transform.rotation = val; } else { transform.rotation = Quaternion.Lerp(transform.rotation, val, weight); } } public void Twist(Vector3 twistDirection, Vector3 normalDirection, float weight) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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_0067: 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) Vector3.OrthoNormalize(ref normalDirection, ref twistDirection); Quaternion val = Quaternion.FromToRotation(transform.rotation * localTwistAxis, twistDirection) * transform.rotation; if (weight >= 1f) { transform.rotation = val; } else { transform.rotation = Quaternion.Lerp(transform.rotation, val, weight); } } public void RotateToMaintain(float weight) { //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) if (!(weight <= 0f)) { transform.rotation = Quaternion.Lerp(transform.rotation, maintainRotation, weight); } } public void RotateToEffector(IKSolverFullBody solver, float weight) { //IL_007a: 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_0097: 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 (!isNodeBone) { return; } float num = weight * solver.GetNode(chainIndex, nodeIndex).effectorRotationWeight; if (!(num <= 0f)) { if (num >= 1f) { transform.rotation = solver.GetNode(chainIndex, nodeIndex).solverRotation; } else { transform.rotation = Quaternion.Lerp(transform.rotation, solver.GetNode(chainIndex, nodeIndex).solverRotation, num); } } } private Quaternion GetTargetRotation(IKSolverFullBody solver) { //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_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_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_0049: 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_0060: 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_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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) Vector3 solverPosition = solver.GetNode(plane1ChainIndex, plane1NodeIndex).solverPosition; Vector3 solverPosition2 = solver.GetNode(plane2ChainIndex, plane2NodeIndex).solverPosition; Vector3 solverPosition3 = solver.GetNode(plane3ChainIndex, plane3NodeIndex).solverPosition; if (solverPosition == solverPosition3) { return Quaternion.identity; } return Quaternion.LookRotation(solverPosition2 - solverPosition, solverPosition3 - solverPosition); } } public virtual bool IsValid(IKSolver solver, ref string message) { return true; } public virtual void Initiate(IKSolverFullBody solver) { } protected bool BoneIsValid(Transform bone, IKSolver solver, ref string message, Warning.Logger logger = null) { if ((Object)(object)bone == (Object)null) { message = "IKMappingLimb contains a null reference."; logger?.Invoke(message); return false; } if (solver.GetPoint(bone) == null) { message = "IKMappingLimb is referencing to a bone '" + ((Object)bone).name + "' that does not excist in the Node Chain."; logger?.Invoke(message); return false; } return true; } protected Vector3 SolveFABRIKJoint(Vector3 pos1, Vector3 pos2, float length) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) Vector3 val = pos1 - pos2; return pos2 + ((Vector3)(ref val)).normalized * length; } } [Serializable] public class IKMappingBone : IKMapping { public Transform bone; [Range(0f, 1f)] public float maintainRotationWeight = 1f; private BoneMap boneMap = new BoneMap(); public IKMappingBone() { } public IKMappingBone(Transform bone) { this.bone = bone; } public override bool IsValid(IKSolver solver, ref string message) { if (!base.IsValid(solver, ref message)) { return false; } if ((Object)(object)bone == (Object)null) { message = "IKMappingBone's bone is null."; return false; } return true; } public void StoreDefaultLocalState() { boneMap.StoreDefaultLocalState(); } public void FixTransforms() { boneMap.FixTransform(position: false); } public override void Initiate(IKSolverFullBody solver) { if (boneMap == null) { boneMap = new BoneMap(); } boneMap.Initiate(bone, solver); } public void ReadPose() { boneMap.MaintainRotation(); } public void WritePose(float solverWeight) { boneMap.RotateToMaintain(solverWeight * maintainRotationWeight); } } [Serializable] public class IKMappingLimb : IKMapping { [Serializable] public enum BoneMapType { Parent, Bone1, Bone2, Bone3 } public Transform parentBone; public Transform bone1; public Transform bone2; public Transform bone3; [Range(0f, 1f)] public float maintainRotationWeight; [Range(0f, 1f)] public float weight = 1f; [NonSerialized] public bool updatePlaneRotations = true; private BoneMap boneMapParent = new BoneMap(); private BoneMap boneMap1 = new BoneMap(); private BoneMap boneMap2 = new BoneMap(); private BoneMap boneMap3 = new BoneMap(); public IKMappingLimb() { } public IKMappingLimb(Transform bone1, Transform bone2, Transform bone3, Transform parentBone = null) { SetBones(bone1, bone2, bone3, parentBone); } public override bool IsValid(IKSolver solver, ref string message) { if (!base.IsValid(solver, ref message)) { return false; } if (!BoneIsValid(bone1, solver, ref message)) { return false; } if (!BoneIsValid(bone2, solver, ref message)) { return false; } if (!BoneIsValid(bone3, solver, ref message)) { return false; } return true; } public BoneMap GetBoneMap(BoneMapType boneMap) { switch (boneMap) { case BoneMapType.Parent: if ((Object)(object)parentBone == (Object)null) { Warning.Log("This limb does not have a parent (shoulder) bone", bone1); } return boneMapParent; case BoneMapType.Bone1: return boneMap1; case BoneMapType.Bone2: return boneMap2; default: return boneMap3; } } public void SetLimbOrientation(Vector3 upper, Vector3 lower) { //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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_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_00ad: 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) boneMap1.defaultLocalTargetRotation = Quaternion.Inverse(Quaternion.Inverse(bone1.rotation) * Quaternion.LookRotation(bone2.position - bone1.position, bone1.rotation * -upper)); boneMap2.defaultLocalTargetRotation = Quaternion.Inverse(Quaternion.Inverse(bone2.rotation) * Quaternion.LookRotation(bone3.position - bone2.position, bone2.rotation * -lower)); } public void SetBones(Transform bone1, Transform bone2, Transform bone3, Transform parentBone = null) { this.bone1 = bone1; this.bone2 = bone2; this.bone3 = bone3; this.parentBone = parentBone; } public void StoreDefaultLocalState() { if ((Object)(object)parentBone != (Object)null) { boneMapParent.StoreDefaultLocalState(); } boneMap1.StoreDefaultLocalState(); boneMap2.StoreDefaultLocalState(); boneMap3.StoreDefaultLocalState(); } public void FixTransforms() { if ((Object)(object)parentBone != (Object)null) { boneMapParent.FixTransform(position: false); } boneMap1.FixTransform(position: true); boneMap2.FixTransform(position: false); boneMap3.FixTransform(position: false); } public override void Initiate(IKSolverFullBody solver) { if (boneMapParent == null) { boneMapParent = new BoneMap(); } if (boneMap1 == null) { boneMap1 = new BoneMap(); } if (boneMap2 == null) { boneMap2 = new BoneMap(); } if (boneMap3 == null) { boneMap3 = new BoneMap(); } if ((Object)(object)parentBone != (Object)null) { boneMapParent.Initiate(parentBone, solver); } boneMap1.Initiate(bone1, solver); boneMap2.Initiate(bone2, solver); boneMap3.Initiate(bone3, solver); boneMap1.SetPlane(solver, boneMap1.transform, boneMap2.transform, boneMap3.transform); boneMap2.SetPlane(solver, boneMap2.transform, boneMap3.transform, boneMap1.transform); if ((Object)(object)parentBone != (Object)null) { boneMapParent.SetLocalSwingAxis(boneMap1); } } public void ReadPose() { boneMap1.UpdatePlane(updatePlaneRotations, position: true); boneMap2.UpdatePlane(updatePlaneRotations, position: false); weight = Mathf.Clamp(weight, 0f, 1f); boneMap3.MaintainRotation(); } public void WritePose(IKSolverFullBody solver, bool fullBody) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return; } if (fullBody) { if ((Object)(object)parentBone != (Object)null) { boneMapParent.Swing(solver.GetNode(boneMap1.chainIndex, boneMap1.nodeIndex).solverPosition, weight); } boneMap1.FixToNode(solver, weight); } boneMap1.RotateToPlane(solver, weight); boneMap2.RotateToPlane(solver, weight); boneMap3.RotateToMaintain(maintainRotationWeight * weight * solver.IKPositionWeight); boneMap3.RotateToEffector(solver, weight); } } [Serializable] public class IKMappingSpine : IKMapping { public Transform[] spineBones; public Transform leftUpperArmBone; public Transform rightUpperArmBone; public Transform leftThighBone; public Transform rightThighBone; [Range(1f, 3f)] public int iterations = 3; [Range(0f, 1f)] public float twistWeight = 1f; private int rootNodeIndex; private BoneMap[] spine = new BoneMap[0]; private BoneMap leftUpperArm = new BoneMap(); private BoneMap rightUpperArm = new BoneMap(); private BoneMap leftThigh = new BoneMap(); private BoneMap rightThigh = new BoneMap(); private bool useFABRIK; public IKMappingSpine() { } public IKMappingSpine(Transform[] spineBones, Transform leftUpperArmBone, Transform rightUpperArmBone, Transform leftThighBone, Transform rightThighBone) { SetBones(spineBones, leftUpperArmBone, rightUpperArmBone, leftThighBone, rightThighBone); } public override bool IsValid(IKSolver solver, ref string message) { if (!base.IsValid(solver, ref message)) { return false; } Transform[] array = spineBones; foreach (Transform val in array) { if ((Object)(object)val == (Object)null) { message = "Spine bones contains a null reference."; return false; } } int num = 0; for (int j = 0; j < spineBones.Length; j++) { if (solver.GetPoint(spineBones[j]) != null) { num++; } } if (num == 0) { message = "IKMappingSpine does not contain any nodes."; return false; } if ((Object)(object)leftUpperArmBone == (Object)null) { message = "IKMappingSpine is missing the left upper arm bone."; return false; } if ((Object)(object)rightUpperArmBone == (Object)null) { message = "IKMappingSpine is missing the right upper arm bone."; return false; } if ((Object)(object)leftThighBone == (Object)null) { message = "IKMappingSpine is missing the left thigh bone."; return false; } if ((Object)(object)rightThighBone == (Object)null) { message = "IKMappingSpine is missing the right thigh bone."; return false; } if (solver.GetPoint(leftUpperArmBone) == null) { message = "Full Body IK is missing the left upper arm node."; return false; } if (solver.GetPoint(rightUpperArmBone) == null) { message = "Full Body IK is missing the right upper arm node."; return false; } if (solver.GetPoint(leftThighBone) == null) { message = "Full Body IK is missing the left thigh node."; return false; } if (solver.GetPoint(rightThighBone) == null) { message = "Full Body IK is missing the right thigh node."; return false; } return true; } public void SetBones(Transform[] spineBones, Transform leftUpperArmBone, Transform rightUpperArmBone, Transform leftThighBone, Transform rightThighBone) { this.spineBones = spineBones; this.leftUpperArmBone = leftUpperArmBone; this.rightUpperArmBone = rightUpperArmBone; this.leftThighBone = leftThighBone; this.rightThighBone = rightThighBone; } public void StoreDefaultLocalState() { for (int i = 0; i < spine.Length; i++) { spine[i].StoreDefaultLocalState(); } } public void FixTransforms() { for (int i = 0; i < spine.Length; i++) { spine[i].FixTransform(i == 0 || i == spine.Length - 1); } } public override void Initiate(IKSolverFullBody solver) { //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) if (iterations <= 0) { iterations = 3; } if (spine == null || spine.Length != spineBones.Length) { spine = new BoneMap[spineBones.Length]; } rootNodeIndex = -1; for (int i = 0; i < spineBones.Length; i++) { if (spine[i] == null) { spine[i] = new BoneMap(); } spine[i].Initiate(spineBones[i], solver); if (spine[i].isNodeBone) { rootNodeIndex = i; } } if (leftUpperArm == null) { leftUpperArm = new BoneMap(); } if (rightUpperArm == null) { rightUpperArm = new BoneMap(); } if (leftThigh == null) { leftThigh = new BoneMap(); } if (rightThigh == null) { rightThigh = new BoneMap(); } leftUpperArm.Initiate(leftUpperArmBone, solver); rightUpperArm.Initiate(rightUpperArmBone, solver); leftThigh.Initiate(leftThighBone, solver); rightThigh.Initiate(rightThighBone, solver); for (int j = 0; j < spine.Length; j++) { spine[j].SetIKPosition(); } spine[0].SetPlane(solver, spine[rootNodeIndex].transform, leftThigh.transform, rightThigh.transform); for (int k = 0; k < spine.Length - 1; k++) { spine[k].SetLength(spine[k + 1]); spine[k].SetLocalSwingAxis(spine[k + 1]); spine[k].SetLocalTwistAxis(leftUpperArm.transform.position - rightUpperArm.transform.position, spine[k + 1].transform.position - spine[k].transform.position); } spine[spine.Length - 1].SetPlane(solver, spine[rootNodeIndex].transform, leftUpperArm.transform, rightUpperArm.transform); spine[spine.Length - 1].SetLocalSwingAxis(leftUpperArm, rightUpperArm); useFABRIK = UseFABRIK(); } private bool UseFABRIK() { if (spine.Length > 3) { return true; } if (rootNodeIndex != 1) { return true; } return false; } public void ReadPose() { //IL_0059: 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_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_0099: Unknown result type (might be due to invalid IL or missing references) spine[0].UpdatePlane(rotation: true, position: true); for (int i = 0; i < spine.Length - 1; i++) { spine[i].SetLength(spine[i + 1]); spine[i].SetLocalSwingAxis(spine[i + 1]); spine[i].SetLocalTwistAxis(leftUpperArm.transform.position - rightUpperArm.transform.position, spine[i + 1].transform.position - spine[i].transform.position); } spine[spine.Length - 1].UpdatePlane(rotation: true, position: true); spine[spine.Length - 1].SetLocalSwingAxis(leftUpperArm, rightUpperArm); } public void WritePose(IKSolverFullBody solver) { //IL_000a: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) Vector3 planePosition = spine[0].GetPlanePosition(solver); Vector3 solverPosition = solver.GetNode(spine[rootNodeIndex].chainIndex, spine[rootNodeIndex].nodeIndex).solverPosition; Vector3 planePosition2 = spine[spine.Length - 1].GetPlanePosition(solver); if (useFABRIK) { Vector3 val = solver.GetNode(spine[rootNodeIndex].chainIndex, spine[rootNodeIndex].nodeIndex).solverPosition - spine[rootNodeIndex].transform.position; for (int i = 0; i < spine.Length; i++) { spine[i].ikPosition = spine[i].transform.position + val; } for (int j = 0; j < iterations; j++) { ForwardReach(planePosition2); BackwardReach(planePosition); spine[rootNodeIndex].ikPosition = solverPosition; } } else { spine[0].ikPosition = planePosition; spine[rootNodeIndex].ikPosition = solverPosition; } spine[spine.Length - 1].ikPosition = planePosition2; MapToSolverPositions(solver); } public void ForwardReach(Vector3 position) { //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_003a: 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_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) spine[spineBones.Length - 1].ikPosition = position; for (int num = spine.Length - 2; num > -1; num--) { spine[num].ikPosition = SolveFABRIKJoint(spine[num].ikPosition, spine[num + 1].ikPosition, spine[num].length); } } private void BackwardReach(Vector3 position) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0037: 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) spine[0].ikPosition = position; for (int i = 1; i < spine.Length; i++) { spine[i].ikPosition = SolveFABRIKJoint(spine[i].ikPosition, spine[i - 1].ikPosition, spine[i - 1].length); } } private void MapToSolverPositions(IKSolverFullBody solver) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ba: 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_00bc: 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_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) spine[0].SetToIKPosition(); spine[0].RotateToPlane(solver, 1f); for (int i = 1; i < spine.Length - 1; i++) { spine[i].Swing(spine[i + 1].ikPosition, 1f); if (twistWeight > 0f) { float num = (float)i / ((float)spine.Length - 2f); Vector3 solverPosition = solver.GetNode(leftUpperArm.chainIndex, leftUpperArm.nodeIndex).solverPosition; Vector3 solverPosition2 = solver.GetNode(rightUpperArm.chainIndex, rightUpperArm.nodeIndex).solverPosition; spine[i].Twist(solverPosition - solverPosition2, spine[i + 1].ikPosition - spine[i].transform.position, num * twistWeight); } } spine[spine.Length - 1].SetToIKPosition(); spine[spine.Length - 1].RotateToPlane(solver, 1f); } } [Serializable] public abstract class IKSolver { [Serializable] public class Point { public Transform transform; [Range(0f, 1f)] public float weight = 1f; public Vector3 solverPosition; public Quaternion solverRotation = Quaternion.identity; public Vector3 defaultLocalPosition; public Quaternion defaultLocalRotation; public void StoreDefaultLocalState() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) defaultLocalPosition = transform.localPosition; defaultLocalRotation = transform.localRotation; } public void FixTransform() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0023: 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) if (transform.localPosition != defaultLocalPosition) { transform.localPosition = defaultLocalPosition; } if (transform.localRotation != defaultLocalRotation) { transform.localRotation = defaultLocalRotation; } } public void UpdateSolverPosition() { //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) solverPosition = transform.position; } public void UpdateSolverLocalPosition() { //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) solverPosition = transform.localPosition; } public void UpdateSolverState() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) solverPosition = transform.position; solverRotation = transform.rotation; } public void UpdateSolverLocalState() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) solverPosition = transform.localPosition; solverRotation = transform.localRotation; } } [Serializable] public class Bone : Point { public float length; public float sqrMag; public Vector3 axis = -Vector3.right; private RotationLimit _rotationLimit; private bool isLimited = true; public RotationLimit rotationLimit { get { if (!isLimited) { return null; } if ((Object)(object)_rotationLimit == (Object)null) { _rotationLimit = ((Component)transform).GetComponent(); } isLimited = (Object)(object)_rotationLimit != (Object)null; return _rotationLimit; } set { _rotationLimit = value; isLimited = (Object)(object)value != (Object)null; } } public Bone() { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) public Bone(Transform transform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) base.transform = transform; } public Bone(Transform transform, float weight) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) base.transform = transform; base.weight = weight; } public void Swing(Vector3 swingTarget, float weight = 1f) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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) if (!(weight <= 0f)) { Quaternion val = Quaternion.FromToRotation(transform.rotation * axis, swingTarget - transform.position); if (weight >= 1f) { transform.rotation = val * transform.rotation; } else { transform.rotation = Quaternion.Lerp(Quaternion.identity, val, weight) * transform.rotation; } } } public static void SolverSwing(Bone[] bones, int index, Vector3 swingTarget, float weight = 1f) { //IL_0014: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0087: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return; } Quaternion val = Quaternion.FromToRotation(bones[index].solverRotation * bones[index].axis, swingTarget - bones[index].solverPosition); if (weight >= 1f) { for (int i = index; i < bones.Length; i++) { bones[i].solverRotation = val * bones[i].solverRotation; } } else { for (int j = index; j < bones.Length; j++) { bones[j].solverRotation = Quaternion.Lerp(Quaternion.identity, val, weight) * bones[j].solverRotation; } } } public void Swing2D(Vector3 swingTarget, float weight = 1f) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_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_0039: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (!(weight <= 0f)) { Vector3 val = transform.rotation * axis; Vector3 val2 = swingTarget - transform.position; float num = Mathf.Atan2(val.x, val.y) * 57.29578f; float num2 = Mathf.Atan2(val2.x, val2.y) * 57.29578f; transform.rotation = Quaternion.AngleAxis(Mathf.DeltaAngle(num, num2) * weight, Vector3.back) * transform.rotation; } } public void SetToSolverPosition() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) transform.position = solverPosition; } } [Serializable] public class Node : Point { public float length; public float effectorPositionWeight; public float effectorRotationWeight; public Vector3 offset; public Node() { } public Node(Transform transform) { base.transform = transform; } public Node(Transform transform, float weight) { base.transform = transform; base.weight = weight; } } public delegate void UpdateDelegate(); public delegate void IterationDelegate(int i); [HideInInspector] public bool executedInEditor; [HideInInspector] public Vector3 IKPosition; [Tooltip("The positional or the master weight of the solver.")] [Range(0f, 1f)] public float IKPositionWeight = 1f; public UpdateDelegate OnPreInitiate; public UpdateDelegate OnPostInitiate; public UpdateDelegate OnPreUpdate; public UpdateDelegate OnPostUpdate; protected bool firstInitiation = true; [SerializeField] [HideInInspector] protected Transform root; public bool initiated { get; private set; } public bool IsValid() { string message = string.Empty; return IsValid(ref message); } public abstract bool IsValid(ref string message); public void Initiate(Transform root) { if (executedInEditor) { return; } if (OnPreInitiate != null) { OnPreInitiate(); } if ((Object)(object)root == (Object)null) { Debug.LogError((object)"Initiating IKSolver with null root Transform."); } this.root = root; initiated = false; string message = string.Empty; if (!IsValid(ref message)) { Warning.Log(message, root); return; } OnInitiate(); StoreDefaultLocalState(); initiated = true; firstInitiation = false; if (OnPostInitiate != null) { OnPostInitiate(); } } public void Update() { if (OnPreUpdate != null) { OnPreUpdate(); } if (firstInitiation) { Initiate(root); } if (initiated) { OnUpdate(); if (OnPostUpdate != null) { OnPostUpdate(); } } } public virtual Vector3 GetIKPosition() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return IKPosition; } public void SetIKPosition(Vector3 position) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) IKPosition = position; } public float GetIKPositionWeight() { return IKPositionWeight; } public void SetIKPositionWeight(float weight) { IKPositionWeight = Mathf.Clamp(weight, 0f, 1f); } public Transform GetRoot() { return root; } public abstract Point[] GetPoints(); public abstract Point GetPoint(Transform transform); public abstract void FixTransforms(); public abstract void StoreDefaultLocalState(); protected abstract void OnInitiate(); protected abstract void OnUpdate(); protected void LogWarning(string message) { Warning.Log(message, root, logInEditMode: true); } public static Transform ContainsDuplicateBone(Bone[] bones) { for (int i = 0; i < bones.Length; i++) { for (int j = 0; j < bones.Length; j++) { if (i != j && (Object)(object)bones[i].transform == (Object)(object)bones[j].transform) { return bones[i].transform; } } } return null; } public static bool HierarchyIsValid(Bone[] bones) { for (int i = 1; i < bones.Length; i++) { if (!Hierarchy.IsAncestor(bones[i].transform, bones[i - 1].transform)) { return false; } } return true; } protected static float PreSolveBones(ref Bone[] bones) { //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) //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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) float num = 0f; for (int i = 0; i < bones.Length; i++) { bones[i].solverPosition = bones[i].transform.position; bones[i].solverRotation = bones[i].transform.rotation; } for (int j = 0; j < bones.Length; j++) { if (j < bones.Length - 1) { Bone obj = bones[j]; Vector3 val = bones[j + 1].solverPosition - bones[j].solverPosition; obj.sqrMag = ((Vector3)(ref val)).sqrMagnitude; bones[j].length = Mathf.Sqrt(bones[j].sqrMag); num += bones[j].length; bones[j].axis = Quaternion.Inverse(bones[j].solverRotation) * (bones[j + 1].solverPosition - bones[j].solverPosition); } else { bones[j].sqrMag = 0f; bones[j].length = 0f; } } return num; } } [Serializable] public class IKSolverAim : IKSolverHeuristic { public Transform transform; public Vector3 axis = Vector3.forward; public Vector3 poleAxis = Vector3.up; public Vector3 polePosition; [Range(0f, 1f)] public float poleWeight; public Transform poleTarget; [Range(0f, 1f)] public float clampWeight = 0.1f; [Range(0f, 2f)] public int clampSmoothing = 2; public IterationDelegate OnPreIteration; private float step; private Vector3 clampedIKPosition; private RotationLimit transformLimit; private Transform lastTransform; public Vector3 transformAxis => transform.rotation * axis; public Vector3 transformPoleAxis => transform.rotation * poleAxis; protected override int minBones => 1; protected override Vector3 localDirection => bones[0].transform.InverseTransformDirection(bones[bones.Length - 1].transform.forward); public float GetAngle() { //IL_0002: 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_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) return Vector3.Angle(transformAxis, IKPosition - transform.position); } protected override void OnInitiate() { //IL_002f: 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_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_005b: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if ((firstInitiation || !Application.isPlaying) && (Object)(object)transform != (Object)null) { IKPosition = transform.position + transformAxis * 3f; polePosition = transform.position + transformPoleAxis * 3f; } for (int i = 0; i < bones.Length; i++) { if ((Object)(object)bones[i].rotationLimit != (Object)null) { bones[i].rotationLimit.Disable(); } } step = 1f / (float)bones.Length; if (Application.isPlaying) { axis = ((Vector3)(ref axis)).normalized; } } protected override void OnUpdate() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) if (axis == Vector3.zero) { if (!Warning.logged) { LogWarning("IKSolverAim axis is Vector3.zero."); } return; } if (poleAxis == Vector3.zero && poleWeight > 0f) { if (!Warning.logged) { LogWarning("IKSolverAim poleAxis is Vector3.zero."); } return; } if ((Object)(object)target != (Object)null) { IKPosition = target.position; } if ((Object)(object)poleTarget != (Object)null) { polePosition = poleTarget.position; } if (XY) { IKPosition.z = bones[0].transform.position.z; } if (IKPositionWeight <= 0f) { return; } IKPositionWeight = Mathf.Clamp(IKPositionWeight, 0f, 1f); if ((Object)(object)transform != (Object)(object)lastTransform) { transformLimit = ((Component)transform).GetComponent(); if ((Object)(object)transformLimit != (Object)null) { ((Behaviour)transformLimit).enabled = false; } lastTransform = transform; } if ((Object)(object)transformLimit != (Object)null) { transformLimit.Apply(); } if ((Object)(object)transform == (Object)null) { if (!Warning.logged) { LogWarning("Aim Transform unassigned in Aim IK solver. Please Assign a Transform (lineal descendant to the last bone in the spine) that you want to be aimed at IKPosition"); } return; } clampWeight = Mathf.Clamp(clampWeight, 0f, 1f); clampedIKPosition = GetClampedIKPosition(); Vector3 val = clampedIKPosition - transform.position; val = Vector3.Slerp(transformAxis * ((Vector3)(ref val)).magnitude, val, IKPositionWeight); clampedIKPosition = transform.position + val; for (int i = 0; i < maxIterations && (i < 1 || !(tolerance > 0f) || !(GetAngle() < tolerance)); i++) { lastLocalDirection = localDirection; if (OnPreIteration != null) { OnPreIteration(i); } Solve(); } lastLocalDirection = localDirection; } private void Solve() { //IL_000a: 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) for (int i = 0; i < bones.Length - 1; i++) { RotateToTarget(clampedIKPosition, bones[i], step * (float)(i + 1) * IKPositionWeight * bones[i].weight); } RotateToTarget(clampedIKPosition, bones[bones.Length - 1], IKPositionWeight * bones[bones.Length - 1].weight); } private Vector3 GetClampedIKPosition() { //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_006d: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_0186: Unknown result type (might be due to invalid IL or missing references) if (clampWeight <= 0f) { return IKPosition; } if (clampWeight >= 1f) { Vector3 position = transform.position; Vector3 val = transformAxis; Vector3 val2 = IKPosition - transform.position; return position + val * ((Vector3)(ref val2)).magnitude; } float num = Vector3.Angle(transformAxis, IKPosition - transform.position); float num2 = 1f - num / 180f; float num3 = ((!(clampWeight > 0f)) ? 1f : Mathf.Clamp(1f - (clampWeight - num2) / (1f - num2), 0f, 1f)); float num4 = ((!(clampWeight > 0f)) ? 1f : Mathf.Clamp(num2 / clampWeight, 0f, 1f)); for (int i = 0; i < clampSmoothing; i++) { float num5 = num4 * (float)Math.PI * 0.5f; num4 = Mathf.Sin(num5); } return transform.position + Vector3.Slerp(transformAxis * 10f, IKPosition - transform.position, num4 * num3); } private void RotateToTarget(Vector3 targetPosition, Bone bone, float weight) { //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0020: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if (XY) { if (weight >= 0f) { Vector3 val = transformAxis; Vector3 val2 = targetPosition - transform.position; float num = Mathf.Atan2(val.x, val.y) * 57.29578f; float num2 = Mathf.Atan2(val2.x, val2.y) * 57.29578f; bone.transform.rotation = Quaternion.AngleAxis(Mathf.DeltaAngle(num, num2), Vector3.back) * bone.transform.rotation; } } else { if (weight >= 0f) { Quaternion val3 = Quaternion.FromToRotation(transformAxis, targetPosition - transform.position); if (weight >= 1f) { bone.transform.rotation = val3 * bone.transform.rotation; } else { bone.transform.rotation = Quaternion.Lerp(Quaternion.identity, val3, weight) * bone.transform.rotation; } } if (poleWeight > 0f) { Vector3 val4 = polePosition - transform.position; Vector3 val5 = val4; Vector3 val6 = transformAxis; Vector3.OrthoNormalize(ref val6, ref val5); Quaternion val7 = Quaternion.FromToRotation(transformPoleAxis, val5); bone.transform.rotation = Quaternion.Lerp(Quaternion.identity, val7, weight * poleWeight) * bone.transform.rotation; } } if (useRotationLimits && (Object)(object)bone.rotationLimit != (Object)null) { bone.rotationLimit.Apply(); } } } [Serializable] public class IKSolverArm : IKSolver { [Range(0f, 1f)] public float IKRotationWeight = 1f; public Quaternion IKRotation = Quaternion.identity; public Point chest = new Point(); public Point shoulder = new Point(); public Point upperArm = new Point(); public Point forearm = new Point(); public Point hand = new Point(); public bool isLeft; public IKSolverVR.Arm arm = new IKSolverVR.Arm(); private Vector3[] positions = (Vector3[])(object)new Vector3[6]; private Quaternion[] rotations = (Quaternion[])(object)new Quaternion[6]; public override bool IsValid(ref string message) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown if ((Object)(object)chest.transform == (Object)null || (Object)(object)shoulder.transform == (Object)null || (Object)(object)upperArm.transform == (Object)null || (Object)(object)forearm.transform == (Object)null || (Object)(object)hand.transform == (Object)null) { message = "Please assign all bone slots of the Arm IK solver."; return false; } Transform val = (Transform)Hierarchy.ContainsDuplicate((Object[])(object)new Transform[5] { chest.transform, shoulder.transform, upperArm.transform, forearm.transform, hand.transform }); if ((Object)(object)val != (Object)null) { message = ((Object)val).name + " is represented multiple times in the ArmIK."; return false; } return true; } public bool SetChain(Transform chest, Transform shoulder, Transform upperArm, Transform forearm, Transform hand, Transform root) { this.chest.transform = chest; this.shoulder.transform = shoulder; this.upperArm.transform = upperArm; this.forearm.transform = forearm; this.hand.transform = hand; Initiate(root); return base.initiated; } public override Point[] GetPoints() { return new Point[5] { chest, shoulder, upperArm, forearm, hand }; } public override Point GetPoint(Transform transform) { if ((Object)(object)chest.transform == (Object)(object)transform) { return chest; } if ((Object)(object)shoulder.transform == (Object)(object)transform) { return shoulder; } if ((Object)(object)upperArm.transform == (Object)(object)transform) { return upperArm; } if ((Object)(object)forearm.transform == (Object)(object)transform) { return forearm; } if ((Object)(object)hand.transform == (Object)(object)transform) { return hand; } return null; } public override void StoreDefaultLocalState() { shoulder.StoreDefaultLocalState(); upperArm.StoreDefaultLocalState(); forearm.StoreDefaultLocalState(); hand.StoreDefaultLocalState(); } public override void FixTransforms() { if (base.initiated) { shoulder.FixTransform(); upperArm.FixTransform(); forearm.FixTransform(); hand.FixTransform(); } } protected override void OnInitiate() { //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_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) IKPosition = hand.transform.position; IKRotation = hand.transform.rotation; Read(); } protected override void OnUpdate() { Read(); Solve(); Write(); } private void Solve() { arm.PreSolve(); arm.ApplyOffsets(1f); arm.Solve(isLeft); arm.ResetOffsets(); } private void Read() { //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_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_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_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_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_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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) arm.IKPosition = IKPosition; arm.positionWeight = IKPositionWeight; arm.IKRotation = IKRotation; arm.rotationWeight = IKRotationWeight; ref Vector3 reference = ref positions[0]; reference = root.position; ref Vector3 reference2 = ref positions[1]; reference2 = chest.transform.position; ref Vector3 reference3 = ref positions[2]; reference3 = shoulder.transform.position; ref Vector3 reference4 = ref positions[3]; reference4 = upperArm.transform.position; ref Vector3 reference5 = ref positions[4]; reference5 = forearm.transform.position; ref Vector3 reference6 = ref positions[5]; reference6 = hand.transform.position; ref Quaternion reference7 = ref rotations[0]; reference7 = root.rotation; ref Quaternion reference8 = ref rotations[1]; reference8 = chest.transform.rotation; ref Quaternion reference9 = ref rotations[2]; reference9 = shoulder.transform.rotation; ref Quaternion reference10 = ref rotations[3]; reference10 = upperArm.transform.rotation; ref Quaternion reference11 = ref rotations[4]; reference11 = forearm.transform.rotation; ref Quaternion reference12 = ref rotations[5]; reference12 = hand.transform.rotation; arm.Read(positions, rotations, hasChest: false, hasNeck: false, hasShoulders: true, hasToes: false, hasLegs: false, 1, 2); } private void Write() { //IL_002f: 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_0071: 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_00b3: 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) arm.Write(ref positions, ref rotations); shoulder.transform.rotation = rotations[2]; upperArm.transform.rotation = rotations[3]; forearm.transform.rotation = rotations[4]; hand.transform.rotation = rotations[5]; forearm.transform.position = positions[4]; hand.transform.position = positions[5]; } } [Serializable] public class IKSolverCCD : IKSolverHeuristic { public IterationDelegate OnPreIteration; public void FadeOutBoneWeights() { if (bones.Length >= 2) { bones[0].weight = 1f; float num = 1f / (float)(bones.Length - 1); for (int i = 1; i < bones.Length; i++) { bones[i].weight = num * (float)(bones.Length - 1 - i); } } } protected override void OnInitiate() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if (firstInitiation || !Application.isPlaying) { IKPosition = bones[bones.Length - 1].transform.position; } InitiateBones(); } protected override void OnUpdate() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_009f: 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_00a9: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) if (IKPositionWeight <= 0f) { return; } IKPositionWeight = Mathf.Clamp(IKPositionWeight, 0f, 1f); if ((Object)(object)target != (Object)null) { IKPosition = target.position; } if (XY) { IKPosition.z = bones[0].transform.position.z; } Vector3 val = ((maxIterations <= 1) ? Vector3.zero : GetSingularityOffset()); for (int i = 0; i < maxIterations && (!(val == Vector3.zero) || i < 1 || !(tolerance > 0f) || !(base.positionOffset < tolerance * tolerance)); i++) { lastLocalDirection = localDirection; if (OnPreIteration != null) { OnPreIteration(i); } Solve(IKPosition + ((i != 0) ? Vector3.zero : val)); } lastLocalDirection = localDirection; } protected void Solve(Vector3 targetPosition) { //IL_0195: 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) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) if (XY) { for (int num = bones.Length - 2; num > -1; num--) { float num2 = bones[num].weight * IKPositionWeight; if (num2 > 0f) { Vector3 val = bones[bones.Length - 1].transform.position - bones[num].transform.position; Vector3 val2 = targetPosition - bones[num].transform.position; float num3 = Mathf.Atan2(val.x, val.y) * 57.29578f; float num4 = Mathf.Atan2(val2.x, val2.y) * 57.29578f; bones[num].transform.rotation = Quaternion.AngleAxis(Mathf.DeltaAngle(num3, num4) * num2, Vector3.back) * bones[num].transform.rotation; } if (useRotationLimits && (Object)(object)bones[num].rotationLimit != (Object)null) { bones[num].rotationLimit.Apply(); } } return; } for (int num5 = bones.Length - 2; num5 > -1; num5--) { float num6 = bones[num5].weight * IKPositionWeight; if (num6 > 0f) { Vector3 val3 = bones[bones.Length - 1].transform.position - bones[num5].transform.position; Vector3 val4 = targetPosition - bones[num5].transform.position; Quaternion val5 = Quaternion.FromToRotation(val3, val4) * bones[num5].transform.rotation; if (num6 >= 1f) { bones[num5].transform.rotation = val5; } else { bones[num5].transform.rotation = Quaternion.Lerp(bones[num5].transform.rotation, val5, num6); } } if (useRotationLimits && (Object)(object)bones[num5].rotationLimit != (Object)null) { bones[num5].rotationLimit.Apply(); } } } } [Serializable] public class IKSolverFABRIK : IKSolverHeuristic { public IterationDelegate OnPreIteration; private bool[] limitedBones = new bool[0]; private Vector3[] solverLocalPositions = (Vector3[])(object)new Vector3[0]; protected override bool boneLengthCanBeZero => false; public void SolveForward(Vector3 position) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!base.initiated) { if (!Warning.logged) { LogWarning("Trying to solve uninitiated FABRIK chain."); } } else { OnPreSolve(); ForwardReach(position); } } public void SolveBackward(Vector3 position) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!base.initiated) { if (!Warning.logged) { LogWarning("Trying to solve uninitiated FABRIK chain."); } } else { BackwardReach(position); OnPostSolve(); } } public override Vector3 GetIKPosition() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_002f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target != (Object)null) { return target.position; } return IKPosition; } protected override void OnInitiate() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if (firstInitiation || !Application.isPlaying) { IKPosition = bones[bones.Length - 1].transform.position; } for (int i = 0; i < bones.Length; i++) { bones[i].solverPosition = bones[i].transform.position; bones[i].solverRotation = bones[i].transform.rotation; } limitedBones = new bool[bones.Length]; solverLocalPositions = (Vector3[])(object)new Vector3[bones.Length]; InitiateBones(); for (int j = 0; j < bones.Length; j++) { ref Vector3 reference = ref solverLocalPositions[j]; reference = Quaternion.Inverse(GetParentSolverRotation(j)) * (bones[j].transform.position - GetParentSolverPosition(j)); } } protected override void OnUpdate() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: 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_0117: 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_0122: 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) if (IKPositionWeight <= 0f) { return; } IKPositionWeight = Mathf.Clamp(IKPositionWeight, 0f, 1f); OnPreSolve(); if ((Object)(object)target != (Object)null) { IKPosition = target.position; } if (XY) { IKPosition.z = bones[0].transform.position.z; } Vector3 val = ((maxIterations <= 1) ? Vector3.zero : GetSingularityOffset()); for (int i = 0; i < maxIterations && (!(val == Vector3.zero) || i < 1 || !(tolerance > 0f) || !(base.positionOffset < tolerance * tolerance)); i++) { lastLocalDirection = localDirection; if (OnPreIteration != null) { OnPreIteration(i); } Solve(IKPosition + ((i != 0) ? Vector3.zero : val)); } OnPostSolve(); } private Vector3 SolveJoint(Vector3 pos1, Vector3 pos2, float length) { //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_001c: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) if (XY) { pos1.z = pos2.z; } Vector3 val = pos2; Vector3 val2 = pos1 - pos2; return val + ((Vector3)(ref val2)).normalized * length; } private void OnPreSolve() { //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_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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) chainLength = 0f; for (int i = 0; i < bones.Length; i++) { bones[i].solverPosition = bones[i].transform.position; bones[i].solverRotation = bones[i].transform.rotation; if (i < bones.Length - 1) { Bone obj = bones[i]; Vector3 val = bones[i].transform.position - bones[i + 1].transform.position; obj.length = ((Vector3)(ref val)).magnitude; bones[i].axis = Quaternion.Inverse(bones[i].transform.rotation) * (bones[i + 1].transform.position - bones[i].transform.position); chainLength += bones[i].length; } if (useRotationLimits) { ref Vector3 reference = ref solverLocalPositions[i]; reference = Quaternion.Inverse(GetParentSolverRotation(i)) * (bones[i].transform.position - GetParentSolverPosition(i)); } } } private void OnPostSolve() { //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) if (!useRotationLimits) { MapToSolverPositions(); } else { MapToSolverPositionsLimited(); } lastLocalDirection = localDirection; } private void Solve(Vector3 targetPosition) { //IL_0002: 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) ForwardReach(targetPosition); BackwardReach(bones[0].transform.position); } private void ForwardReach(Vector3 position) { //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_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_007d: 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_009e: 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) bones[bones.Length - 1].solverPosition = Vector3.Lerp(bones[bones.Length - 1].solverPosition, position, IKPositionWeight); for (int i = 0; i < limitedBones.Length; i++) { limitedBones[i] = false; } for (int num = bones.Length - 2; num > -1; num--) { bones[num].solverPosition = SolveJoint(bones[num].solverPosition, bones[num + 1].solverPosition, bones[num].length); LimitForward(num, num + 1); } LimitForward(0, 0); } private void SolverMove(int index, 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) for (int i = index; i < bones.Length; i++) { Bone obj = bones[i]; obj.solverPosition += offset; } } private void SolverRotate(int index, Quaternion rotation, bool recursive) { //IL_0011: 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) for (int i = index; i < bones.Length; i++) { bones[i].solverRotation = rotation * bones[i].solverRotation; if (!recursive) { break; } } } private void SolverRotateChildren(int index, Quaternion rotation) { //IL_0013: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) for (int i = index + 1; i < bones.Length; i++) { bones[i].solverRotation = rotation * bones[i].solverRotation; } } private void SolverMoveChildrenAroundPoint(int index, Quaternion rotation) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) for (int i = index + 1; i < bones.Length; i++) { Vector3 val = bones[i].solverPosition - bones[index].solverPosition; bones[i].solverPosition = bones[index].solverPosition + rotation * val; } } private Quaternion GetParentSolverRotation(int index) { //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_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (index > 0) { return bones[index - 1].solverRotation; } if ((Object)(object)bones[0].transform.parent == (Object)null) { return Quaternion.identity; } return bones[0].transform.parent.rotation; } private Vector3 GetParentSolverPosition(int index) { //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_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (index > 0) { return bones[index - 1].solverPosition; } if ((Object)(object)bones[0].transform.parent == (Object)null) { return Vector3.zero; } return bones[0].transform.parent.position; } private Quaternion GetLimitedRotation(int index, Quaternion q, out bool changed) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0018: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) changed = false; Quaternion parentSolverRotation = GetParentSolverRotation(index); Quaternion localRotation = Quaternion.Inverse(parentSolverRotation) * q; Quaternion limitedLocalRotation = bones[index].rotationLimit.GetLimitedLocalRotation(localRotation, out changed); if (!changed) { return q; } return parentSolverRotation * limitedLocalRotation; } private void LimitForward(int rotateBone, int limitBone) { //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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_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_0104: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) if (!useRotationLimits || (Object)(object)bones[limitBone].rotationLimit == (Object)null) { return; } Vector3 solverPosition = bones[bones.Length - 1].solverPosition; for (int i = rotateBone; i < bones.Length - 1 && !limitedBones[i]; i++) { Quaternion rotation = Quaternion.FromToRotation(bones[i].solverRotation * bones[i].axis, bones[i + 1].solverPosition - bones[i].solverPosition); SolverRotate(i, rotation, recursive: false); } bool changed = false; Quaternion limitedRotation = GetLimitedRotation(limitBone, bones[limitBone].solverRotation, out changed); if (changed) { if (limitBone < bones.Length - 1) { Quaternion rotation2 = QuaTools.FromToRotation(bones[limitBone].solverRotation, limitedRotation); bones[limitBone].solverRotation = limitedRotation; SolverRotateChildren(limitBone, rotation2); SolverMoveChildrenAroundPoint(limitBone, rotation2); Quaternion rotation3 = Quaternion.FromToRotation(bones[bones.Length - 1].solverPosition - bones[rotateBone].solverPosition, solverPosition - bones[rotateBone].solverPosition); SolverRotate(rotateBone, rotation3, recursive: true); SolverMoveChildrenAroundPoint(rotateBone, rotation3); SolverMove(rotateBone, solverPosition - bones[bones.Length - 1].solverPosition); } else { bones[limitBone].solverRotation = limitedRotation; } } limitedBones[limitBone] = true; } private void BackwardReach(Vector3 position) { //IL_0019: 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) if (useRotationLimits) { BackwardReachLimited(position); } else { BackwardReachUnlimited(position); } } private void BackwardReachUnlimited(Vector3 position) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0037: 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) bones[0].solverPosition = position; for (int i = 1; i < bones.Length; i++) { bones[i].solverPosition = SolveJoint(bones[i].solverPosition, bones[i - 1].solverPosition, bones[i - 1].length); } } private void BackwardReachLimited(Vector3 position) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0189: Unknown result type (might be due to invalid IL or missing references) bones[0].solverPosition = position; for (int i = 0; i < bones.Length - 1; i++) { Vector3 val = SolveJoint(bones[i + 1].solverPosition, bones[i].solverPosition, bones[i].length); Quaternion val2 = Quaternion.FromToRotation(bones[i].solverRotation * bones[i].axis, val - bones[i].solverPosition); Quaternion val3 = val2 * bones[i].solverRotation; if ((Object)(object)bones[i].rotationLimit != (Object)null) { bool changed = false; val3 = GetLimitedRotation(i, val3, out changed); } Quaternion rotation = QuaTools.FromToRotation(bones[i].solverRotation, val3); bones[i].solverRotation = val3; SolverRotateChildren(i, rotation); bones[i + 1].solverPosition = bones[i].solverPosition + bones[i].solverRotation * solverLocalPositions[i + 1]; } for (int j = 0; j < bones.Length; j++) { bones[j].solverRotation = Quaternion.LookRotation(bones[j].solverRotation * Vector3.forward, bones[j].solverRotation * Vector3.up); } } private void MapToSolverPositions() { //IL_0016: 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_0046: Unknown result type (might be due to invalid IL or missing references) bones[0].transform.position = bones[0].solverPosition; for (int i = 0; i < bones.Length - 1; i++) { if (XY) { bones[i].Swing2D(bones[i + 1].solverPosition); } else { bones[i].Swing(bones[i + 1].solverPosition); } } } private void MapToSolverPositionsLimited() { //IL_0016: 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) bones[0].transform.position = bones[0].solverPosition; for (int i = 0; i < bones.Length; i++) { if (i < bones.Length - 1) { bones[i].transform.rotation = bones[i].solverRotation; } } } } [Serializable] public class IKSolverFABRIKRoot : IKSolver { public int iterations = 4; [Range(0f, 1f)] public float rootPin = 0f; public FABRIKChain[] chains = new FABRIKChain[0]; private bool zeroWeightApplied; private bool[] isRoot; private Vector3 rootDefaultPosition; public override bool IsValid(ref string message) { if (chains.Length == 0) { message = "IKSolverFABRIKRoot contains no chains."; return false; } FABRIKChain[] array = chains; foreach (FABRIKChain fABRIKChain in array) { if (!fABRIKChain.IsValid(ref message)) { return false; } } for (int j = 0; j < chains.Length; j++) { for (int k = 0; k < chains.Length; k++) { if (j != k && (Object)(object)chains[j].ik == (Object)(object)chains[k].ik) { message = ((Object)chains[j].ik).name + " is represented more than once in IKSolverFABRIKRoot chain."; return false; } } } for (int l = 0; l < chains.Length; l++) { for (int m = 0; m < chains[l].children.Length; m++) { int num = chains[l].children[m]; if (num < 0) { message = ((Object)chains[l].ik).name + "IKSolverFABRIKRoot chain at index " + l + " has invalid children array. Child index is < 0."; return false; } if (num == l) { message = ((Object)chains[l].ik).name + "IKSolverFABRIKRoot chain at index " + l + " has invalid children array. Child index is referencing to itself."; return false; } if (num >= chains.Length) { message = ((Object)chains[l].ik).name + "IKSolverFABRIKRoot chain at index " + l + " has invalid children array. Child index > number of chains"; return false; } for (int n = 0; n < chains.Length; n++) { if (num != n) { continue; } for (int num2 = 0; num2 < chains[n].children.Length; num2++) { if (chains[n].children[num2] == l) { message = "Circular parenting. " + ((Object)chains[n].ik).name + " already has " + ((Object)chains[l].ik).name + " listed as it's child."; return false; } } } for (int num3 = 0; num3 < chains[l].children.Length; num3++) { if (m != num3 && chains[l].children[num3] == num) { message = "Chain number " + num + " is represented more than once in the children of " + ((Object)chains[l].ik).name; return false; } } } } return true; } public override void StoreDefaultLocalState() { //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) rootDefaultPosition = root.localPosition; for (int i = 0; i < chains.Length; i++) { chains[i].ik.solver.StoreDefaultLocalState(); } } public override void FixTransforms() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (base.initiated) { root.localPosition = rootDefaultPosition; for (int i = 0; i < chains.Length; i++) { chains[i].ik.solver.FixTransforms(); } } } protected override void OnInitiate() { for (int i = 0; i < chains.Length; i++) { chains[i].Initiate(); } isRoot = new bool[chains.Length]; for (int j = 0; j < chains.Length; j++) { isRoot[j] = IsRoot(j); } } private bool IsRoot(int index) { for (int i = 0; i < chains.Length; i++) { for (int j = 0; j < chains[i].children.Length; j++) { if (chains[i].children[j] == index) { return false; } } } return true; } protected override void OnUpdate() { //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_00e6: 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) if (IKPositionWeight <= 0f && zeroWeightApplied) { return; } IKPositionWeight = Mathf.Clamp(IKPositionWeight, 0f, 1f); for (int i = 0; i < chains.Length; i++) { chains[i].ik.solver.IKPositionWeight = IKPositionWeight; } if (IKPositionWeight <= 0f) { zeroWeightApplied = true; return; } zeroWeightApplied = false; for (int j = 0; j < iterations; j++) { for (int k = 0; k < chains.Length; k++) { if (isRoot[k]) { chains[k].Stage1(chains); } } Vector3 centroid = GetCentroid(); root.position = centroid; for (int l = 0; l < chains.Length; l++) { if (isRoot[l]) { chains[l].Stage2(centroid, chains); } } } } public override Point[] GetPoints() { Point[] array = new Point[0]; for (int i = 0; i < chains.Length; i++) { AddPointsToArray(ref array, chains[i]); } return array; } public override Point GetPoint(Transform transform) { Point point = null; for (int i = 0; i < chains.Length; i++) { point = chains[i].ik.solver.GetPoint(transform); if (point != null) { return point; } } return null; } private void AddPointsToArray(ref Point[] array, FABRIKChain chain) { Point[] points = chain.ik.solver.GetPoints(); Array.Resize(ref array, array.Length + points.Length); int num = 0; for (int i = array.Length - points.Length; i < array.Length; i++) { array[i] = points[num]; num++; } } private Vector3 GetCentroid() { //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_001d: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_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_0084: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00d9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = root.position; if (rootPin >= 1f) { return val; } float num = 0f; for (int i = 0; i < chains.Length; i++) { if (isRoot[i]) { num += chains[i].pull; } } for (int j = 0; j < chains.Length; j++) { if (isRoot[j] && num > 0f) { val += (chains[j].ik.solver.bones[0].solverPosition - root.position) * (chains[j].pull / Mathf.Clamp(num, 1f, num)); } } return Vector3.Lerp(val, root.position, rootPin); } } [Serializable] public class IKSolverFullBody : IKSolver { [Range(0f, 10f)] public int iterations = 4; public FBIKChain[] chain = new FBIKChain[0]; public IKEffector[] effectors = new IKEffector[0]; public IKMappingSpine spineMapping = new IKMappingSpine(); public IKMappingBone[] boneMappings = new IKMappingBone[0]; public IKMappingLimb[] limbMappings = new IKMappingLimb[0]; public bool FABRIKPass = true; public UpdateDelegate OnPreRead; public UpdateDelegate OnPreSolve; public IterationDelegate OnPreIteration; public IterationDelegate OnPostIteration; public UpdateDelegate OnPreBend; public UpdateDelegate OnPostSolve; public UpdateDelegate OnStoreDefaultLocalState; public UpdateDelegate OnFixTransforms; public IKEffector GetEffector(Transform t) { for (int i = 0; i < effectors.Length; i++) { if ((Object)(object)effectors[i].bone == (Object)(object)t) { return effectors[i]; } } return null; } public FBIKChain GetChain(Transform transform) { int chainIndex = GetChainIndex(transform); if (chainIndex == -1) { return null; } return chain[chainIndex]; } public int GetChainIndex(Transform transform) { for (int i = 0; i < chain.Length; i++) { for (int j = 0; j < chain[i].nodes.Length; j++) { if ((Object)(object)chain[i].nodes[j].transform == (Object)(object)transform) { return i; } } } return -1; } public Node GetNode(int chainIndex, int nodeIndex) { return chain[chainIndex].nodes[nodeIndex]; } public void GetChainAndNodeIndexes(Transform transform, out int chainIndex, out int nodeIndex) { chainIndex = GetChainIndex(transform); if (chainIndex == -1) { nodeIndex = -1; } else { nodeIndex = chain[chainIndex].GetNodeIndex(transform); } } public override Point[] GetPoints() { int num = 0; for (int i = 0; i < chain.Length; i++) { num += chain[i].nodes.Length; } Point[] array = new Point[num]; int num2 = 0; for (int j = 0; j < chain.Length; j++) { for (int k = 0; k < chain[j].nodes.Length; k++) { array[num2] = chain[j].nodes[k]; num2++; } } return array; } public override Point GetPoint(Transform transform) { for (int i = 0; i < chain.Length; i++) { for (int j = 0; j < chain[i].nodes.Length; j++) { if ((Object)(object)chain[i].nodes[j].transform == (Object)(object)transform) { return chain[i].nodes[j]; } } } return null; } public override bool IsValid(ref string message) { if (chain == null) { message = "FBIK chain is null, can't initiate solver."; return false; } if (chain.Length == 0) { message = "FBIK chain length is 0, can't initiate solver."; return false; } for (int i = 0; i < chain.Length; i++) { if (!chain[i].IsValid(ref message)) { return false; } } IKEffector[] array = effectors; foreach (IKEffector iKEffector in array) { if (!iKEffector.IsValid(this, ref message)) { return false; } } if (!spineMapping.IsValid(this, ref message)) { return false; } IKMappingLimb[] array2 = limbMappings; foreach (IKMappingLimb iKMappingLimb in array2) { if (!iKMappingLimb.IsValid(this, ref message)) { return false; } } IKMappingBone[] array3 = boneMappings; foreach (IKMappingBone iKMappingBone in array3) { if (!iKMappingBone.IsValid(this, ref message)) { return false; } } return true; } public override void StoreDefaultLocalState() { spineMapping.StoreDefaultLocalState(); for (int i = 0; i < limbMappings.Length; i++) { limbMappings[i].StoreDefaultLocalState(); } for (int j = 0; j < boneMappings.Length; j++) { boneMappings[j].StoreDefaultLocalState(); } if (OnStoreDefaultLocalState != null) { OnStoreDefaultLocalState(); } } public override void FixTransforms() { if (base.initiated && !(IKPositionWeight <= 0f)) { spineMapping.FixTransforms(); for (int i = 0; i < limbMappings.Length; i++) { limbMappings[i].FixTransforms(); } for (int j = 0; j < boneMappings.Length; j++) { boneMappings[j].FixTransforms(); } if (OnFixTransforms != null) { OnFixTransforms(); } } } protected override void OnInitiate() { for (int i = 0; i < chain.Length; i++) { chain[i].Initiate(this); } IKEffector[] array = effectors; foreach (IKEffector iKEffector in array) { iKEffector.Initiate(this); } spineMapping.Initiate(this); IKMappingBone[] array2 = boneMappings; foreach (IKMappingBone iKMappingBone in array2) { iKMappingBone.Initiate(this); } IKMappingLimb[] array3 = limbMappings; foreach (IKMappingLimb iKMappingLimb in array3) { iKMappingLimb.Initiate(this); } } protected override void OnUpdate() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (IKPositionWeight <= 0f) { for (int i = 0; i < effectors.Length; i++) { effectors[i].positionOffset = Vector3.zero; } } else if (chain.Length != 0) { IKPositionWeight = Mathf.Clamp(IKPositionWeight, 0f, 1f); if (OnPreRead != null) { OnPreRead(); } ReadPose(); if (OnPreSolve != null) { OnPreSolve(); } Solve(); if (OnPostSolve != null) { OnPostSolve(); } WritePose(); for (int j = 0; j < effectors.Length; j++) { effectors[j].OnPostWrite(); } } } protected virtual void ReadPose() { for (int i = 0; i < chain.Length; i++) { if (chain[i].bendConstraint.initiated) { chain[i].bendConstraint.LimitBend(IKPositionWeight, GetEffector(chain[i].nodes[2].transform).positionWeight); } } for (int j = 0; j < effectors.Length; j++) { effectors[j].ResetOffset(this); } for (int k = 0; k < effectors.Length; k++) { effectors[k].OnPreSolve(this); } for (int l = 0; l < chain.Length; l++) { chain[l].ReadPose(this, iterations > 0); } if (iterations > 0) { spineMapping.ReadPose(); for (int m = 0; m < boneMappings.Length; m++) { boneMappings[m].ReadPose(); } } for (int n = 0; n < limbMappings.Length; n++) { limbMappings[n].ReadPose(); } } protected virtual void Solve() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) if (iterations > 0) { for (int i = 0; i < ((!FABRIKPass) ? 1 : iterations); i++) { if (OnPreIteration != null) { OnPreIteration(i); } for (int j = 0; j < effectors.Length; j++) { if (effectors[j].isEndEffector) { effectors[j].Update(this); } } if (FABRIKPass) { chain[0].Push(this); if (FABRIKPass) { chain[0].Reach(this); } for (int k = 0; k < effectors.Length; k++) { if (!effectors[k].isEndEffector) { effectors[k].Update(this); } } } chain[0].SolveTrigonometric(this); if (FABRIKPass) { chain[0].Stage1(this); for (int l = 0; l < effectors.Length; l++) { if (!effectors[l].isEndEffector) { effectors[l].Update(this); } } chain[0].Stage2(this, chain[0].nodes[0].solverPosition); } if (OnPostIteration != null) { OnPostIteration(i); } } } if (OnPreBend != null) { OnPreBend(); } for (int m = 0; m < effectors.Length; m++) { if (effectors[m].isEndEffector) { effectors[m].Update(this); } } ApplyBendConstraints(); } protected virtual void ApplyBendConstraints() { chain[0].SolveTrigonometric(this, calculateBendDirection: true); } protected virtual void WritePose() { if (IKPositionWeight <= 0f) { return; } if (iterations > 0) { spineMapping.WritePose(this); for (int i = 0; i < boneMappings.Length; i++) { boneMappings[i].WritePose(IKPositionWeight); } } for (int j = 0; j < limbMappings.Length; j++) { limbMappings[j].WritePose(this, iterations > 0); } } } [Serializable] public enum FullBodyBipedEffector { Body, LeftShoulder, RightShoulder, LeftThigh, RightThigh, LeftHand, RightHand, LeftFoot, RightFoot } [Serializable] public enum FullBodyBipedChain { LeftArm, RightArm, LeftLeg, RightLeg } [Serializable] public class IKSolverFullBodyBiped : IKSolverFullBody { public Transform rootNode; [Range(0f, 1f)] public float spineStiffness = 0.5f; [Range(-1f, 1f)] public float pullBodyVertical = 0.5f; [Range(-1f, 1f)] public float pullBodyHorizontal = 0f; private Vector3 offset; public IKEffector bodyEffector => GetEffector(FullBodyBipedEffector.Body); public IKEffector leftShoulderEffector => GetEffector(FullBodyBipedEffector.LeftShoulder); public IKEffector rightShoulderEffector => GetEffector(FullBodyBipedEffector.RightShoulder); public IKEffector leftThighEffector => GetEffector(FullBodyBipedEffector.LeftThigh); public IKEffector rightThighEffector => GetEffector(FullBodyBipedEffector.RightThigh); public IKEffector leftHandEffector => GetEffector(FullBodyBipedEffector.LeftHand); public IKEffector rightHandEffector => GetEffector(FullBodyBipedEffector.RightHand); public IKEffector leftFootEffector => GetEffector(FullBodyBipedEffector.LeftFoot); public IKEffector rightFootEffector => GetEffector(FullBodyBipedEffector.RightFoot); public FBIKChain leftArmChain => chain[1]; public FBIKChain rightArmChain => chain[2]; public FBIKChain leftLegChain => chain[3]; public FBIKChain rightLegChain => chain[4]; public IKMappingLimb leftArmMapping => limbMappings[0]; public IKMappingLimb rightArmMapping => limbMappings[1]; public IKMappingLimb leftLegMapping => limbMappings[2]; public IKMappingLimb rightLegMapping => limbMappings[3]; public IKMappingBone headMapping => boneMappings[0]; public Vector3 pullBodyOffset { get; private set; } public void SetChainWeights(FullBodyBipedChain c, float pull, float reach = 0f) { GetChain(c).pull = pull; GetChain(c).reach = reach; } public void SetEffectorWeights(FullBodyBipedEffector effector, float positionWeight, float rotationWeight) { GetEffector(effector).positionWeight = Mathf.Clamp(positionWeight, 0f, 1f); GetEffector(effector).rotationWeight = Mathf.Clamp(rotationWeight, 0f, 1f); } public FBIKChain GetChain(FullBodyBipedChain c) { return c switch { FullBodyBipedChain.LeftArm => chain[1], FullBodyBipedChain.RightArm => chain[2], FullBodyBipedChain.LeftLeg => chain[3], FullBodyBipedChain.RightLeg => chain[4], _ => null, }; } public FBIKChain GetChain(FullBodyBipedEffector effector) { return effector switch { FullBodyBipedEffector.Body => chain[0], FullBodyBipedEffector.LeftShoulder => chain[1], FullBodyBipedEffector.RightShoulder => chain[2], FullBodyBipedEffector.LeftThigh => chain[3], FullBodyBipedEffector.RightThigh => chain[4], FullBodyBipedEffector.LeftHand => chain[1], FullBodyBipedEffector.RightHand => chain[2], FullBodyBipedEffector.LeftFoot => chain[3], FullBodyBipedEffector.RightFoot => chain[4], _ => null, }; } public IKEffector GetEffector(FullBodyBipedEffector effector) { return effector switch { FullBodyBipedEffector.Body => effectors[0], FullBodyBipedEffector.LeftShoulder => effectors[1], FullBodyBipedEffector.RightShoulder => effectors[2], FullBodyBipedEffector.LeftThigh => effectors[3], FullBodyBipedEffector.RightThigh => effectors[4], FullBodyBipedEffector.LeftHand => effectors[5], FullBodyBipedEffector.RightHand => effectors[6], FullBodyBipedEffector.LeftFoot => effectors[7], FullBodyBipedEffector.RightFoot => effectors[8], _ => null, }; } public IKEffector GetEndEffector(FullBodyBipedChain c) { return c switch { FullBodyBipedChain.LeftArm => effectors[5], FullBodyBipedChain.RightArm => effectors[6], FullBodyBipedChain.LeftLeg => effectors[7], FullBodyBipedChain.RightLeg => effectors[8], _ => null, }; } public IKMappingLimb GetLimbMapping(FullBodyBipedChain chain) { return chain switch { FullBodyBipedChain.LeftArm => limbMappings[0], FullBodyBipedChain.RightArm => limbMappings[1], FullBodyBipedChain.LeftLeg => limbMappings[2], FullBodyBipedChain.RightLeg => limbMappings[3], _ => null, }; } public IKMappingLimb GetLimbMapping(FullBodyBipedEffector effector) { return effector switch { FullBodyBipedEffector.LeftShoulder => limbMappings[0], FullBodyBipedEffector.RightShoulder => limbMappings[1], FullBodyBipedEffector.LeftThigh => limbMappings[2], FullBodyBipedEffector.RightThigh => limbMappings[3], FullBodyBipedEffector.LeftHand => limbMappings[0], FullBodyBipedEffector.RightHand => limbMappings[1], FullBodyBipedEffector.LeftFoot => limbMappings[2], FullBodyBipedEffector.RightFoot => limbMappings[3], _ => null, }; } public IKMappingSpine GetSpineMapping() { return spineMapping; } public IKMappingBone GetHeadMapping() { return boneMappings[0]; } public IKConstraintBend GetBendConstraint(FullBodyBipedChain limb) { return limb switch { FullBodyBipedChain.LeftArm => chain[1].bendConstraint, FullBodyBipedChain.RightArm => chain[2].bendConstraint, FullBodyBipedChain.LeftLeg => chain[3].bendConstraint, FullBodyBipedChain.RightLeg => chain[4].bendConstraint, _ => null, }; } public override bool IsValid(ref string message) { if (!base.IsValid(ref message)) { return false; } if ((Object)(object)rootNode == (Object)null) { message = "Root Node bone is null. FBBIK will not initiate."; return false; } if (chain.Length != 5 || chain[0].nodes.Length != 1 || chain[1].nodes.Length != 3 || chain[2].nodes.Length != 3 || chain[3].nodes.Length != 3 || chain[4].nodes.Length != 3 || effectors.Length != 9 || limbMappings.Length != 4) { message = "Invalid FBBIK setup. Please right-click on the component header and select 'Reinitiate'."; return false; } return true; } public void SetToReferences(BipedReferences references, Transform rootNode = null) { root = references.root; if ((Object)(object)rootNode == (Object)null) { rootNode = DetectRootNodeBone(references); } this.rootNode = rootNode; if (chain == null || chain.Length != 5) { chain = new FBIKChain[5]; } for (int i = 0; i < chain.Length; i++) { if (chain[i] == null) { chain[i] = new FBIKChain(); } } chain[0].pin = 0f; chain[0].SetNodes(rootNode); chain[0].children = new int[4] { 1, 2, 3, 4 }; chain[1].SetNodes(references.leftUpperArm, references.leftForearm, references.leftHand); chain[2].SetNodes(references.rightUpperArm, references.rightForearm, references.rightHand); chain[3].SetNodes(references.leftThigh, references.leftCalf, references.leftFoot); chain[4].SetNodes(references.rightThigh, references.rightCalf, references.rightFoot); if (effectors.Length != 9) { effectors = new IKEffector[9] { new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector(), new IKEffector() }; } effectors[0].bone = rootNode; effectors[0].childBones = (Transform[])(object)new Transform[2] { references.leftThigh, references.rightThigh }; effectors[1].bone = references.leftUpperArm; effectors[2].bone = references.rightUpperArm; effectors[3].bone = references.leftThigh; effectors[4].bone = references.rightThigh; effectors[5].bone = references.leftHand; effectors[6].bone = references.rightHand; effectors[7].bone = references.leftFoot; effectors[8].bone = references.rightFoot; effectors[5].planeBone1 = references.leftUpperArm; effectors[5].planeBone2 = references.rightUpperArm; effectors[5].planeBone3 = rootNode; effectors[6].planeBone1 = references.rightUpperArm; effectors[6].planeBone2 = references.leftUpperArm; effectors[6].planeBone3 = rootNode; effectors[7].planeBone1 = references.leftThigh; effectors[7].planeBone2 = references.rightThigh; effectors[7].planeBone3 = rootNode; effectors[8].planeBone1 = references.rightThigh; effectors[8].planeBone2 = references.leftThigh; effectors[8].planeBone3 = rootNode; chain[0].childConstraints = new FBIKChain.ChildConstraint[4] { new FBIKChain.ChildConstraint(references.leftUpperArm, references.rightThigh, 0f, 1f), new FBIKChain.ChildConstraint(references.rightUpperArm, references.leftThigh, 0f, 1f), new FBIKChain.ChildConstraint(references.leftUpperArm, references.rightUpperArm), new FBIKChain.ChildConstraint(references.leftThigh, references.rightThigh) }; Transform[] array = (Transform[])(object)new Transform[references.spine.Length + 1]; array[0] = references.pelvis; for (int j = 0; j < references.spine.Length; j++) { array[j + 1] = references.spine[j]; } if (spineMapping == null) { spineMapping = new IKMappingSpine(); spineMapping.iterations = 3; } spineMapping.SetBones(array, references.leftUpperArm, references.rightUpperArm, references.leftThigh, references.rightThigh); int num = (((Object)(object)references.head != (Object)null) ? 1 : 0); if (boneMappings.Length != num) { boneMappings = new IKMappingBone[num]; for (int k = 0; k < boneMappings.Length; k++) { boneMappings[k] = new IKMappingBone(); } if (num == 1) { boneMappings[0].maintainRotationWeight = 0f; } } if (boneMappings.Length > 0) { boneMappings[0].bone = references.head; } if (limbMappings.Length != 4) { limbMappings = new IKMappingLimb[4] { new IKMappingLimb(), new IKMappingLimb(), new IKMappingLimb(), new IKMappingLimb() }; limbMappings[2].maintainRotationWeight = 1f; limbMappings[3].maintainRotationWeight = 1f; } limbMappings[0].SetBones(references.leftUpperArm, references.leftForearm, references.leftHand, GetLeftClavicle(references)); limbMappings[1].SetBones(references.rightUpperArm, references.rightForearm, references.rightHand, GetRightClavicle(references)); limbMappings[2].SetBones(references.leftThigh, references.leftCalf, references.leftFoot); limbMappings[3].SetBones(references.rightThigh, references.rightCalf, references.rightFoot); if (Application.isPlaying) { Initiate(references.root); } } public static Transform DetectRootNodeBone(BipedReferences references) { //IL_004c: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0082: 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_0088: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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) if (!references.isFilled) { return null; } if (references.spine.Length < 1) { return null; } int num = references.spine.Length; if (num == 1) { return references.spine[0]; } Vector3 val = Vector3.Lerp(references.leftThigh.position, references.rightThigh.position, 0.5f); Vector3 val2 = Vector3.Lerp(references.leftUpperArm.position, references.rightUpperArm.position, 0.5f); Vector3 val3 = val2 - val; float magnitude = ((Vector3)(ref val3)).magnitude; if (references.spine.Length < 2) { return references.spine[0]; } int num2 = 0; for (int i = 1; i < num; i++) { Vector3 val4 = references.spine[i].position - val; Vector3 val5 = Vector3.Project(val4, val3); float num3 = Vector3.Dot(((Vector3)(ref val5)).normalized, ((Vector3)(ref val3)).normalized); if (num3 > 0f) { float num4 = ((Vector3)(ref val5)).magnitude / magnitude; if (num4 < 0.5f) { num2 = i; } } } return references.spine[num2]; } public void SetLimbOrientations(BipedLimbOrientations o) { SetLimbOrientation(FullBodyBipedChain.LeftArm, o.leftArm); SetLimbOrientation(FullBodyBipedChain.RightArm, o.rightArm); SetLimbOrientation(FullBodyBipedChain.LeftLeg, o.leftLeg); SetLimbOrientation(FullBodyBipedChain.RightLeg, o.rightLeg); } private void SetLimbOrientation(FullBodyBipedChain chain, BipedLimbOrientations.LimbOrientation limbOrientation) { //IL_0074: 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_0080: 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_0098: 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_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_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_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_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) if (chain == FullBodyBipedChain.LeftArm || chain == FullBodyBipedChain.RightArm) { GetBendConstraint(chain).SetLimbOrientation(-limbOrientation.upperBoneForwardAxis, -limbOrientation.lowerBoneForwardAxis, -limbOrientation.lastBoneLeftAxis); GetLimbMapping(chain).SetLimbOrientation(-limbOrientation.upperBoneForwardAxis, -limbOrientation.lowerBoneForwardAxis); } else { GetBendConstraint(chain).SetLimbOrientation(limbOrientation.upperBoneForwardAxis, limbOrientation.lowerBoneForwardAxis, limbOrientation.lastBoneLeftAxis); GetLimbMapping(chain).SetLimbOrientation(limbOrientation.upperBoneForwardAxis, limbOrientation.lowerBoneForwardAxis); } } private static Transform GetLeftClavicle(BipedReferences references) { if ((Object)(object)references.leftUpperArm == (Object)null) { return null; } if (!Contains(references.spine, references.leftUpperArm.parent)) { return references.leftUpperArm.parent; } return null; } private static Transform GetRightClavicle(BipedReferences references) { if ((Object)(object)references.rightUpperArm == (Object)null) { return null; } if (!Contains(references.spine, references.rightUpperArm.parent)) { return references.rightUpperArm.parent; } return null; } private static bool Contains(Transform[] array, Transform transform) { foreach (Transform val in array) { if ((Object)(object)val == (Object)(object)transform) { return true; } } return false; } protected override void ReadPose() { for (int i = 0; i < effectors.Length; i++) { effectors[i].SetToTarget(); } PullBody(); float pushElasticity = Mathf.Clamp(1f - spineStiffness, 0f, 1f); chain[0].childConstraints[0].pushElasticity = pushElasticity; chain[0].childConstraints[1].pushElasticity = pushElasticity; base.ReadPose(); } private void PullBody() { //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_003b: 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_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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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) if (iterations >= 1 && (pullBodyVertical != 0f || pullBodyHorizontal != 0f)) { Vector3 bodyOffset = GetBodyOffset(); pullBodyOffset = V3Tools.ExtractVertical(bodyOffset, root.up, pullBodyVertical) + V3Tools.ExtractHorizontal(bodyOffset, root.up, pullBodyHorizontal); IKEffector iKEffector = bodyEffector; iKEffector.positionOffset += pullBodyOffset; } } private Vector3 GetBodyOffset() { //IL_0001: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0070: 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_0080: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero + GetHandBodyPull(leftHandEffector, leftArmChain, Vector3.zero) * Mathf.Clamp(leftHandEffector.positionWeight, 0f, 1f); return val + GetHandBodyPull(rightHandEffector, rightArmChain, val) * Mathf.Clamp(rightHandEffector.positionWeight, 0f, 1f); } private Vector3 GetHandBodyPull(IKEffector effector, FBIKChain arm, Vector3 offset) { //IL_0002: 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_0019: 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_0060: 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_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_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_0074: Unknown result type (might be due to invalid IL or missing references) Vector3 val = effector.position - (arm.nodes[0].transform.position + offset); float num = arm.nodes[0].length + arm.nodes[1].length; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < num) { return Vector3.zero; } float num2 = magnitude - num; return val / magnitude * num2; } protected override void ApplyBendConstraints() { //IL_0092: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //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_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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (iterations > 0) { chain[1].bendConstraint.rotationOffset = leftHandEffector.planeRotationOffset; chain[2].bendConstraint.rotationOffset = rightHandEffector.planeRotationOffset; chain[3].bendConstraint.rotationOffset = leftFootEffector.planeRotationOffset; chain[4].bendConstraint.rotationOffset = rightFootEffector.planeRotationOffset; } else { offset = Vector3.Lerp(effectors[0].positionOffset, effectors[0].position - (effectors[0].bone.position + effectors[0].positionOffset), effectors[0].positionWeight); for (int i = 0; i < 5; i++) { Node node = effectors[i].GetNode(this); node.solverPosition += offset; } } base.ApplyBendConstraints(); } protected override void WritePose() { //IL_001b: 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_0026: Unknown result type (might be due to invalid IL or missing references) if (iterations == 0) { Transform obj = spineMapping.spineBones[0]; obj.position += offset; } base.WritePose(); } } [Serializable] public class IKSolverHeuristic : IKSolver { public Transform target; public float tolerance = 0f; public int maxIterations = 4; public bool useRotationLimits = true; public bool XY; public Bone[] bones = new Bone[0]; protected Vector3 lastLocalDirection; protected float chainLength; protected virtual int minBones => 2; protected virtual bool boneLengthCanBeZero => true; protected virtual bool allowCommonParent => false; protected virtual Vector3 localDirection => bones[0].transform.InverseTransformDirection(bones[bones.Length - 1].transform.position - bones[0].transform.position); protected float positionOffset => Vector3.SqrMagnitude(localDirection - lastLocalDirection); public bool SetChain(Transform[] hierarchy, Transform root) { if (bones == null || bones.Length != hierarchy.Length) { bones = new Bone[hierarchy.Length]; } for (int i = 0; i < hierarchy.Length; i++) { if (bones[i] == null) { bones[i] = new Bone(); } bones[i].transform = hierarchy[i]; } Initiate(root); return base.initiated; } public void AddBone(Transform bone) { Transform[] array = (Transform[])(object)new Transform[bones.Length + 1]; for (int i = 0; i < bones.Length; i++) { array[i] = bones[i].transform; } array[^1] = bone; SetChain(array, root); } public override void StoreDefaultLocalState() { for (int i = 0; i < bones.Length; i++) { bones[i].StoreDefaultLocalState(); } } public override void FixTransforms() { if (base.initiated && !(IKPositionWeight <= 0f)) { for (int i = 0; i < bones.Length; i++) { bones[i].FixTransform(); } } } public override bool IsValid(ref string message) { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) if (bones.Length == 0) { message = "IK chain has no Bones."; return false; } if (bones.Length < minBones) { message = "IK chain has less than " + minBones + " Bones."; return false; } Bone[] array = bones; foreach (Bone bone in array) { if ((Object)(object)bone.transform == (Object)null) { message = "One of the Bones is null."; return false; } } Transform val = IKSolver.ContainsDuplicateBone(bones); if ((Object)(object)val != (Object)null) { message = ((Object)val).name + " is represented multiple times in the Bones."; return false; } if (!allowCommonParent && !IKSolver.HierarchyIsValid(bones)) { message = "Invalid bone hierarchy detected. IK requires for it's bones to be parented to each other in descending order."; return false; } if (!boneLengthCanBeZero) { for (int j = 0; j < bones.Length - 1; j++) { Vector3 val2 = bones[j].transform.position - bones[j + 1].transform.position; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude == 0f) { message = "Bone " + j + " length is zero."; return false; } } } return true; } public override Point[] GetPoints() { return bones; } public override Point GetPoint(Transform transform) { for (int i = 0; i < bones.Length; i++) { if ((Object)(object)bones[i].transform == (Object)(object)transform) { return bones[i]; } } return null; } protected override void OnInitiate() { } protected override void OnUpdate() { } protected void InitiateBones() { //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_0180: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_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_0058: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_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) chainLength = 0f; for (int i = 0; i < bones.Length; i++) { if (i < bones.Length - 1) { Bone obj = bones[i]; Vector3 val = bones[i].transform.position - bones[i + 1].transform.position; obj.length = ((Vector3)(ref val)).magnitude; chainLength += bones[i].length; Vector3 position = bones[i + 1].transform.position; bones[i].axis = Quaternion.Inverse(bones[i].transform.rotation) * (position - bones[i].transform.position); if ((Object)(object)bones[i].rotationLimit != (Object)null) { if (XY && !(bones[i].rotationLimit is RotationLimitHinge)) { Warning.Log("Only Hinge Rotation Limits should be used on 2D IK solvers.", bones[i].transform); } bones[i].rotationLimit.Disable(); } } else { bones[i].axis = Quaternion.Inverse(bones[i].transform.rotation) * (bones[bones.Length - 1].transform.position - bones[0].transform.position); } } } protected Vector3 GetSingularityOffset() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if (!SingularityDetected()) { return Vector3.zero; } Vector3 val = IKPosition - bones[0].transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(normalized.y, normalized.z, normalized.x); if (useRotationLimits && (Object)(object)bones[bones.Length - 2].rotationLimit != (Object)null && bones[bones.Length - 2].rotationLimit is RotationLimitHinge) { val2 = bones[bones.Length - 2].transform.rotation * bones[bones.Length - 2].rotationLimit.axis; } return Vector3.Cross(normalized, val2) * bones[bones.Length - 2].length * 0.5f; } private bool SingularityDetected() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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) if (!base.initiated) { return false; } Vector3 val = bones[bones.Length - 1].transform.position - bones[0].transform.position; Vector3 val2 = IKPosition - bones[0].transform.position; float magnitude = ((Vector3)(ref val)).magnitude; float magnitude2 = ((Vector3)(ref val2)).magnitude; if (magnitude < magnitude2) { return false; } if (magnitude < chainLength - bones[bones.Length - 2].length * 0.1f) { return false; } if (magnitude == 0f) { return false; } if (magnitude2 == 0f) { return false; } if (magnitude2 > magnitude) { return false; } float num = Vector3.Dot(val / magnitude, val2 / magnitude2); if (num < 0.999f) { return false; } return true; } } [Serializable] public class IKSolverLeg : IKSolver { [Range(0f, 1f)] public float IKRotationWeight = 1f; public Quaternion IKRotation = Quaternion.identity; public Point pelvis = new Point(); public Point thigh = new Point(); public Point calf = new Point(); public Point foot = new Point(); public Point toe = new Point(); public IKSolverVR.Leg leg = new IKSolverVR.Leg(); public Vector3 heelOffset; private Vector3[] positions = (Vector3[])(object)new Vector3[6]; private Quaternion[] rotations = (Quaternion[])(object)new Quaternion[6]; public override bool IsValid(ref string message) { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown if ((Object)(object)pelvis.transform == (Object)null || (Object)(object)thigh.transform == (Object)null || (Object)(object)calf.transform == (Object)null || (Object)(object)foot.transform == (Object)null || (Object)(object)toe.transform == (Object)null) { message = "Please assign all bone slots of the Leg IK solver."; return false; } Transform val = (Transform)Hierarchy.ContainsDuplicate((Object[])(object)new Transform[5] { pelvis.transform, thigh.transform, calf.transform, foot.transform, toe.transform }); if ((Object)(object)val != (Object)null) { message = ((Object)val).name + " is represented multiple times in the LegIK."; return false; } return true; } public bool SetChain(Transform pelvis, Transform thigh, Transform calf, Transform foot, Transform toe, Transform root) { this.pelvis.transform = pelvis; this.thigh.transform = thigh; this.calf.transform = calf; this.foot.transform = foot; this.toe.transform = toe; Initiate(root); return base.initiated; } public override Point[] GetPoints() { return new Point[5] { pelvis, thigh, calf, foot, toe }; } public override Point GetPoint(Transform transform) { if ((Object)(object)pelvis.transform == (Object)(object)transform) { return pelvis; } if ((Object)(object)thigh.transform == (Object)(object)transform) { return thigh; } if ((Object)(object)calf.transform == (Object)(object)transform) { return calf; } if ((Object)(object)foot.transform == (Object)(object)transform) { return foot; } if ((Object)(object)toe.transform == (Object)(object)transform) { return toe; } return null; } public override void StoreDefaultLocalState() { thigh.StoreDefaultLocalState(); calf.StoreDefaultLocalState(); foot.StoreDefaultLocalState(); toe.StoreDefaultLocalState(); } public override void FixTransforms() { if (base.initiated) { thigh.FixTransform(); calf.FixTransform(); foot.FixTransform(); toe.FixTransform(); } } protected override void OnInitiate() { //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_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) IKPosition = toe.transform.position; IKRotation = toe.transform.rotation; Read(); } protected override void OnUpdate() { Read(); Solve(); Write(); } private void Solve() { //IL_0008: 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) IKSolverVR.Leg obj = leg; obj.heelPositionOffset += heelOffset; leg.PreSolve(); leg.ApplyOffsets(1f); leg.Solve(stretch: true); leg.ResetOffsets(); } private void Read() { //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_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_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_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_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_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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) leg.IKPosition = IKPosition; leg.positionWeight = IKPositionWeight; leg.IKRotation = IKRotation; leg.rotationWeight = IKRotationWeight; ref Vector3 reference = ref positions[0]; reference = root.position; ref Vector3 reference2 = ref positions[1]; reference2 = pelvis.transform.position; ref Vector3 reference3 = ref positions[2]; reference3 = thigh.transform.position; ref Vector3 reference4 = ref positions[3]; reference4 = calf.transform.position; ref Vector3 reference5 = ref positions[4]; reference5 = foot.transform.position; ref Vector3 reference6 = ref positions[5]; reference6 = toe.transform.position; ref Quaternion reference7 = ref rotations[0]; reference7 = root.rotation; ref Quaternion reference8 = ref rotations[1]; reference8 = pelvis.transform.rotation; ref Quaternion reference9 = ref rotations[2]; reference9 = thigh.transform.rotation; ref Quaternion reference10 = ref rotations[3]; reference10 = calf.transform.rotation; ref Quaternion reference11 = ref rotations[4]; reference11 = foot.transform.rotation; ref Quaternion reference12 = ref rotations[5]; reference12 = toe.transform.rotation; leg.Read(positions, rotations, hasChest: false, hasNeck: false, hasShoulders: false, hasToes: true, hasLegs: true, 1, 2); } private void Write() { //IL_002f: 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_0071: 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_00b3: 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) leg.Write(ref positions, ref rotations); thigh.transform.rotation = rotations[2]; calf.transform.rotation = rotations[3]; foot.transform.rotation = rotations[4]; toe.transform.rotation = rotations[5]; calf.transform.position = positions[3]; foot.transform.position = positions[4]; } } [Serializable] public class IKSolverLimb : IKSolverTrigonometric { [Serializable] public enum BendModifier { Animation, Target, Parent, Arm, Goal } [Serializable] public struct AxisDirection { public Vector3 direction; public Vector3 axis; public float dot; public AxisDirection(Vector3 direction, Vector3 axis) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) this.direction = ((Vector3)(ref direction)).normalized; this.axis = ((Vector3)(ref axis)).normalized; dot = 0f; } } public AvatarIKGoal goal; public BendModifier bendModifier; [Range(0f, 1f)] public float maintainRotationWeight; [Range(0f, 1f)] public float bendModifierWeight = 1f; public Transform bendGoal; private bool maintainBendFor1Frame; private bool maintainRotationFor1Frame; private Quaternion defaultRootRotation; private Quaternion parentDefaultRotation; private Quaternion bone3RotationBeforeSolve; private Quaternion maintainRotation; private Quaternion bone3DefaultRotation; private Vector3 _bendNormal; private Vector3 animationNormal; private AxisDirection[] axisDirectionsLeft = new AxisDirection[4]; private AxisDirection[] axisDirectionsRight = new AxisDirection[4]; private AxisDirection[] axisDirections { get { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)goal == 2) { return axisDirectionsLeft; } return axisDirectionsRight; } } public IKSolverLimb() { } public IKSolverLimb(AvatarIKGoal goal) { //IL_002b: 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) this.goal = goal; } public void MaintainRotation() { //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) if (base.initiated) { maintainRotation = bone3.transform.rotation; maintainRotationFor1Frame = true; } } public void MaintainBend() { //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) if (base.initiated) { animationNormal = bone1.GetBendNormalFromCurrentRotation(); maintainBendFor1Frame = true; } } protected override void OnInitiateVirtual() { //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_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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) defaultRootRotation = root.rotation; if ((Object)(object)bone1.transform.parent != (Object)null) { parentDefaultRotation = Quaternion.Inverse(defaultRootRotation) * bone1.transform.parent.rotation; } if ((Object)(object)bone3.rotationLimit != (Object)null) { bone3.rotationLimit.Disable(); } bone3DefaultRotation = bone3.transform.rotation; Vector3 val = Vector3.Cross(bone2.transform.position - bone1.transform.position, bone3.transform.position - bone2.transform.position); if (val != Vector3.zero) { bendNormal = val; } animationNormal = bendNormal; StoreAxisDirections(ref axisDirectionsLeft); StoreAxisDirections(ref axisDirectionsRight); } protected override void OnUpdateVirtual() { //IL_004a: 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_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_009b: 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_00a0: Unknown result type (might be due to invalid IL or missing references) if (IKPositionWeight > 0f) { bendModifierWeight = Mathf.Clamp(bendModifierWeight, 0f, 1f); maintainRotationWeight = Mathf.Clamp(maintainRotationWeight, 0f, 1f); _bendNormal = bendNormal; bendNormal = GetModifiedBendNormal(); } if (maintainRotationWeight * IKPositionWeight > 0f) { bone3RotationBeforeSolve = ((!maintainRotationFor1Frame) ? bone3.transform.rotation : maintainRotation); maintainRotationFor1Frame = false; } } protected override void OnPostSolveVirtual() { //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_004b: 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_0063: Unknown result type (might be due to invalid IL or missing references) if (IKPositionWeight > 0f) { bendNormal = _bendNormal; } if (maintainRotationWeight * IKPositionWeight > 0f) { bone3.transform.rotation = Quaternion.Slerp(bone3.transform.rotation, bone3RotationBeforeSolve, maintainRotationWeight * IKPositionWeight); } } private void StoreAxisDirections(ref AxisDirection[] axisDirections) { //IL_0009: 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_0043: 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_007d: 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_00b7: 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) ref AxisDirection reference = ref axisDirections[0]; reference = new AxisDirection(Vector3.zero, new Vector3(-1f, 0f, 0f)); ref AxisDirection reference2 = ref axisDirections[1]; reference2 = new AxisDirection(new Vector3(0.5f, 0f, -0.2f), new Vector3(-0.5f, -1f, 1f)); ref AxisDirection reference3 = ref axisDirections[2]; reference3 = new AxisDirection(new Vector3(-0.5f, -1f, -0.2f), new Vector3(0f, 0.5f, -1f)); ref AxisDirection reference4 = ref axisDirections[3]; reference4 = new AxisDirection(new Vector3(-0.5f, -0.5f, 1f), new Vector3(-1f, -1f, -1f)); } private Vector3 GetModifiedBendNormal() { //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_00f0: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0419: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: 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_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Invalid comparison between Unknown and I4 //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017f: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_01c6: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Invalid comparison between Unknown and I4 //IL_03fa: 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_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Invalid comparison between Unknown and I4 //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: 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_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) float num = bendModifierWeight; if (num <= 0f) { return bendNormal; } switch (bendModifier) { case BendModifier.Animation: if (!maintainBendFor1Frame) { MaintainBend(); } maintainBendFor1Frame = false; return Vector3.Lerp(bendNormal, animationNormal, num); case BendModifier.Parent: { if ((Object)(object)bone1.transform.parent == (Object)null) { return bendNormal; } Quaternion val6 = bone1.transform.parent.rotation * Quaternion.Inverse(parentDefaultRotation); return Quaternion.Slerp(Quaternion.identity, val6 * Quaternion.Inverse(defaultRootRotation), num) * bendNormal; } case BendModifier.Target: { Quaternion val5 = IKRotation * Quaternion.Inverse(bone3DefaultRotation); return Quaternion.Slerp(Quaternion.identity, val5, num) * bendNormal; } case BendModifier.Arm: { if ((Object)(object)bone1.transform.parent == (Object)null) { return bendNormal; } if ((int)goal == 0 || (int)goal == 1) { if (!Warning.logged) { LogWarning("Trying to use the 'Arm' bend modifier on a leg."); } return bendNormal; } Vector3 val2 = IKPosition - bone1.transform.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; normalized = Quaternion.Inverse(bone1.transform.parent.rotation * Quaternion.Inverse(parentDefaultRotation)) * normalized; if ((int)goal == 2) { normalized.x = 0f - normalized.x; } for (int i = 1; i < axisDirections.Length; i++) { axisDirections[i].dot = Mathf.Clamp(Vector3.Dot(axisDirections[i].direction, normalized), 0f, 1f); axisDirections[i].dot = Interp.Float(axisDirections[i].dot, InterpolationMode.InOutQuintic); } Vector3 val3 = axisDirections[0].axis; for (int j = 1; j < axisDirections.Length; j++) { val3 = Vector3.Slerp(val3, axisDirections[j].axis, axisDirections[j].dot); } if ((int)goal == 2) { val3.x = 0f - val3.x; val3 = -val3; } Vector3 val4 = bone1.transform.parent.rotation * Quaternion.Inverse(parentDefaultRotation) * val3; if (num >= 1f) { return val4; } return Vector3.Lerp(bendNormal, val4, num); } case BendModifier.Goal: { if ((Object)(object)bendGoal == (Object)null) { if (!Warning.logged) { LogWarning("Trying to use the 'Goal' Bend Modifier, but the Bend Goal is unassigned."); } return bendNormal; } Vector3 val = Vector3.Cross(bendGoal.position - bone1.transform.position, IKPosition - bone1.transform.position); if (val == Vector3.zero) { return bendNormal; } if (num >= 1f) { return val; } return Vector3.Lerp(bendNormal, val, num); } default: return bendNormal; } } } [Serializable] public class IKSolverLookAt : IKSolver { [Serializable] public class LookAtBone : Bone { public Vector3 baseForwardOffsetEuler; public Vector3 forward => transform.rotation * axis; public LookAtBone() { } public LookAtBone(Transform transform) { base.transform = transform; } public void Initiate(Transform root) { //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_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_0033: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)transform == (Object)null)) { axis = Quaternion.Inverse(transform.rotation) * root.forward; } } public void LookAt(Vector3 direction, float weight) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_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_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_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) Quaternion val = Quaternion.FromToRotation(forward, direction); Quaternion rotation = transform.rotation; transform.rotation = Quaternion.Lerp(rotation, val * rotation, weight); } } public Transform target; public LookAtBone[] spine = new LookAtBone[0]; public LookAtBone head = new LookAtBone(); public LookAtBone[] eyes = new LookAtBone[0]; [Range(0f, 1f)] public float bodyWeight = 0.5f; [Range(0f, 1f)] public float headWeight = 0.5f; [Range(0f, 1f)] public float eyesWeight = 1f; [Range(0f, 1f)] public float clampWeight = 0.5f; [Range(0f, 1f)] public float clampWeightHead = 0.5f; [Range(0f, 1f)] public float clampWeightEyes = 0.5f; [Range(0f, 2f)] public int clampSmoothing = 2; public AnimationCurve spineWeightCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 0.3f), new Keyframe(1f, 1f) }); public Vector3 spineTargetOffset; protected Vector3[] spineForwards = (Vector3[])(object)new Vector3[0]; protected Vector3[] headForwards = (Vector3[])(object)new Vector3[1]; protected Vector3[] eyeForward = (Vector3[])(object)new Vector3[1]; private bool isDirty; protected bool spineIsValid { get { if (spine == null) { return false; } if (spine.Length == 0) { return true; } for (int i = 0; i < spine.Length; i++) { if (spine[i] == null || (Object)(object)spine[i].transform == (Object)null) { return false; } } return true; } } protected bool spineIsEmpty => spine.Length == 0; protected bool headIsValid { get { if (head == null) { return false; } return true; } } protected bool headIsEmpty => (Object)(object)head.transform == (Object)null; protected bool eyesIsValid { get { if (eyes == null) { return false; } if (eyes.Length == 0) { return true; } for (int i = 0; i < eyes.Length; i++) { if (eyes[i] == null || (Object)(object)eyes[i].transform == (Object)null) { return false; } } return true; } } protected bool eyesIsEmpty => eyes.Length == 0; public void SetLookAtWeight(float weight) { IKPositionWeight = Mathf.Clamp(weight, 0f, 1f); } public void SetLookAtWeight(float weight, float bodyWeight) { IKPositionWeight = Mathf.Clamp(weight, 0f, 1f); this.bodyWeight = Mathf.Clamp(bodyWeight, 0f, 1f); } public void SetLookAtWeight(float weight, float bodyWeight, float headWeight) { IKPositionWeight = Mathf.Clamp(weight, 0f, 1f); this.bodyWeight = Mathf.Clamp(bodyWeight, 0f, 1f); this.headWeight = Mathf.Clamp(headWeight, 0f, 1f); } public void SetLookAtWeight(float weight, float bodyWeight, float headWeight, float eyesWeight) { IKPositionWeight = Mathf.Clamp(weight, 0f, 1f); this.bodyWeight = Mathf.Clamp(bodyWeight, 0f, 1f); this.headWeight = Mathf.Clamp(headWeight, 0f, 1f); this.eyesWeight = Mathf.Clamp(eyesWeight, 0f, 1f); } public void SetLookAtWeight(float weight, float bodyWeight, float headWeight, float eyesWeight, float clampWeight) { IKPositionWeight = Mathf.Clamp(weight, 0f, 1f); this.bodyWeight = Mathf.Clamp(bodyWeight, 0f, 1f); this.headWeight = Mathf.Clamp(headWeight, 0f, 1f); this.eyesWeight = Mathf.Clamp(eyesWeight, 0f, 1f); this.clampWeight = Mathf.Clamp(clampWeight, 0f, 1f); clampWeightHead = this.clampWeight; clampWeightEyes = this.clampWeight; } public void SetLookAtWeight(float weight, float bodyWeight = 0f, float headWeight = 1f, float eyesWeight = 0.5f, float clampWeight = 0.5f, float clampWeightHead = 0.5f, float clampWeightEyes = 0.3f) { IKPositionWeight = Mathf.Clamp(weight, 0f, 1f); this.bodyWeight = Mathf.Clamp(bodyWeight, 0f, 1f); this.headWeight = Mathf.Clamp(headWeight, 0f, 1f); this.eyesWeight = Mathf.Clamp(eyesWeight, 0f, 1f); this.clampWeight = Mathf.Clamp(clampWeight, 0f, 1f); this.clampWeightHead = Mathf.Clamp(clampWeightHead, 0f, 1f); this.clampWeightEyes = Mathf.Clamp(clampWeightEyes, 0f, 1f); } public override void StoreDefaultLocalState() { for (int i = 0; i < spine.Length; i++) { spine[i].StoreDefaultLocalState(); } for (int j = 0; j < eyes.Length; j++) { eyes[j].StoreDefaultLocalState(); } if (head != null && (Object)(object)head.transform != (Object)null) { head.StoreDefaultLocalState(); } } public void SetDirty() { isDirty = true; } public override void FixTransforms() { if (base.initiated && (!(IKPositionWeight <= 0f) || isDirty)) { for (int i = 0; i < spine.Length; i++) { spine[i].FixTransform(); } for (int j = 0; j < eyes.Length; j++) { eyes[j].FixTransform(); } if (head != null && (Object)(object)head.transform != (Object)null) { head.FixTransform(); } isDirty = false; } } public override bool IsValid(ref string message) { if (!spineIsValid) { message = "IKSolverLookAt spine setup is invalid. Can't initiate solver."; return false; } if (!headIsValid) { message = "IKSolverLookAt head transform is null. Can't initiate solver."; return false; } if (!eyesIsValid) { message = "IKSolverLookAt eyes setup is invalid. Can't initiate solver."; return false; } if (spineIsEmpty && headIsEmpty && eyesIsEmpty) { message = "IKSolverLookAt eyes setup is invalid. Can't initiate solver."; return false; } Transform val = IKSolver.ContainsDuplicateBone(spine); if ((Object)(object)val != (Object)null) { message = ((Object)val).name + " is represented multiple times in a single IK chain. Can't initiate solver."; return false; } Transform val2 = IKSolver.ContainsDuplicateBone(eyes); if ((Object)(object)val2 != (Object)null) { message = ((Object)val2).name + " is represented multiple times in a single IK chain. Can't initiate solver."; return false; } return true; } public override Point[] GetPoints() { Point[] array = new Point[spine.Length + eyes.Length + (((Object)(object)head.transform != (Object)null) ? 1 : 0)]; for (int i = 0; i < spine.Length; i++) { array[i] = spine[i]; } int num = 0; for (int j = spine.Length; j < spine.Length + eyes.Length; j++) { array[j] = eyes[num]; num++; } if ((Object)(object)head.transform != (Object)null) { array[^1] = head; } return array; } public override Point GetPoint(Transform transform) { LookAtBone[] array = spine; foreach (LookAtBone lookAtBone in array) { if ((Object)(object)lookAtBone.transform == (Object)(object)transform) { return lookAtBone; } } LookAtBone[] array2 = eyes; foreach (LookAtBone lookAtBone2 in array2) { if ((Object)(object)lookAtBone2.transform == (Object)(object)transform) { return lookAtBone2; } } if ((Object)(object)head.transform == (Object)(object)transform) { return head; } return null; } public bool SetChain(Transform[] spine, Transform head, Transform[] eyes, Transform root) { SetBones(spine, ref this.spine); this.head = new LookAtBone(head); SetBones(eyes, ref this.eyes); Initiate(root); return base.initiated; } protected override void OnInitiate() { //IL_003c: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_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_0103: Unknown result type (might be due to invalid IL or missing references) if (firstInitiation || !Application.isPlaying) { if (spine.Length > 0) { IKPosition = spine[spine.Length - 1].transform.position + root.forward * 3f; } else if ((Object)(object)head.transform != (Object)null) { IKPosition = head.transform.position + root.forward * 3f; } else if (eyes.Length > 0 && (Object)(object)eyes[0].transform != (Object)null) { IKPosition = eyes[0].transform.position + root.forward * 3f; } } LookAtBone[] array = spine; foreach (LookAtBone lookAtBone in array) { lookAtBone.Initiate(root); } if (head != null) { head.Initiate(root); } LookAtBone[] array2 = eyes; foreach (LookAtBone lookAtBone2 in array2) { lookAtBone2.Initiate(root); } if (spineForwards == null || spineForwards.Length != spine.Length) { spineForwards = (Vector3[])(object)new Vector3[spine.Length]; } if (headForwards == null) { headForwards = (Vector3[])(object)new Vector3[1]; } if (eyeForward == null) { eyeForward = (Vector3[])(object)new Vector3[1]; } } protected override void OnUpdate() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) if (!(IKPositionWeight <= 0f)) { IKPositionWeight = Mathf.Clamp(IKPositionWeight, 0f, 1f); if ((Object)(object)target != (Object)null) { IKPosition = target.position; } SolveSpine(); SolveHead(); SolveEyes(); } } protected void SolveSpine() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) if (!(bodyWeight <= 0f) && !spineIsEmpty) { Vector3 val = IKPosition + spineTargetOffset - spine[spine.Length - 1].transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; GetForwards(ref spineForwards, spine[0].forward, normalized, spine.Length, clampWeight); for (int i = 0; i < spine.Length; i++) { spine[i].LookAt(spineForwards[i], bodyWeight * IKPositionWeight); } } } protected void SolveHead() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_009b: 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_00b2: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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) if (!(headWeight <= 0f) && !headIsEmpty) { Vector3 val = ((spine.Length <= 0 || !((Object)(object)spine[spine.Length - 1].transform != (Object)null)) ? head.forward : spine[spine.Length - 1].forward); Vector3 val2 = IKPosition - head.transform.position; Vector3 val3 = Vector3.Lerp(val, ((Vector3)(ref val2)).normalized, headWeight * IKPositionWeight); Vector3 normalized = ((Vector3)(ref val3)).normalized; GetForwards(ref headForwards, val, normalized, 1, clampWeightHead); head.LookAt(headForwards[0], headWeight * IKPositionWeight); } } protected void SolveEyes() { //IL_004f: 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_007d: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_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_0123: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) if (eyesWeight <= 0f || eyesIsEmpty) { return; } for (int i = 0; i < eyes.Length; i++) { Quaternion val = (((Object)(object)head.transform != (Object)null) ? head.transform.rotation : ((spine.Length <= 0) ? root.rotation : spine[spine.Length - 1].transform.rotation)); Vector3 val2 = (((Object)(object)head.transform != (Object)null) ? head.axis : ((spine.Length <= 0) ? root.forward : spine[spine.Length - 1].axis)); if (eyes[i].baseForwardOffsetEuler != Vector3.zero) { val *= Quaternion.Euler(eyes[i].baseForwardOffsetEuler); } Vector3 baseForward = val * val2; ref Vector3[] forwards = ref eyeForward; Vector3 val3 = IKPosition - eyes[i].transform.position; GetForwards(ref forwards, baseForward, ((Vector3)(ref val3)).normalized, 1, clampWeightEyes); eyes[i].LookAt(eyeForward[0], eyesWeight * IKPositionWeight); } } protected Vector3[] GetForwards(ref Vector3[] forwards, Vector3 baseForward, Vector3 targetForward, int bones, float clamp) { //IL_0049: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) if (clamp >= 1f || IKPositionWeight <= 0f) { for (int i = 0; i < forwards.Length; i++) { forwards[i] = baseForward; } return forwards; } float num = Vector3.Angle(baseForward, targetForward); float num2 = 1f - num / 180f; float num3 = ((!(clamp > 0f)) ? 1f : Mathf.Clamp(1f - (clamp - num2) / (1f - num2), 0f, 1f)); float num4 = ((!(clamp > 0f)) ? 1f : Mathf.Clamp(num2 / clamp, 0f, 1f)); for (int j = 0; j < clampSmoothing; j++) { float num5 = num4 * (float)Math.PI * 0.5f; num4 = Mathf.Sin(num5); } if (forwards.Length == 1) { ref Vector3 reference = ref forwards[0]; reference = Vector3.Slerp(baseForward, targetForward, num4 * num3); } else { float num6 = 1f / (float)(forwards.Length - 1); for (int k = 0; k < forwards.Length; k++) { ref Vector3 reference2 = ref forwards[k]; reference2 = Vector3.Slerp(baseForward, targetForward, spineWeightCurve.Evaluate(num6 * (float)k) * num4 * num3); } } return forwards; } protected void SetBones(Transform[] array, ref LookAtBone[] bones) { if (array == null) { bones = new LookAtBone[0]; return; } if (bones.Length != array.Length) { bones = new LookAtBone[array.Length]; } for (int i = 0; i < array.Length; i++) { if (bones[i] == null) { bones[i] = new LookAtBone(array[i]); } else { bones[i].transform = array[i]; } } } } [Serializable] public class IKSolverTrigonometric : IKSolver { [Serializable] public class TrigonometricBone : Bone { private Quaternion targetToLocalSpace; private Vector3 defaultLocalBendNormal; public void Initiate(Vector3 childPosition, Vector3 bendNormal) { //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_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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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) Quaternion rotation = Quaternion.LookRotation(childPosition - transform.position, bendNormal); targetToLocalSpace = QuaTools.RotationToLocalSpace(transform.rotation, rotation); defaultLocalBendNormal = Quaternion.Inverse(transform.rotation) * bendNormal; } public Quaternion GetRotation(Vector3 direction, Vector3 bendNormal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) return Quaternion.LookRotation(direction, bendNormal) * targetToLocalSpace; } public Vector3 GetBendNormalFromCurrentRotation() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) return transform.rotation * defaultLocalBendNormal; } } public Transform target; [Range(0f, 1f)] public float IKRotationWeight = 1f; public Quaternion IKRotation = Quaternion.identity; public Vector3 bendNormal = Vector3.right; public TrigonometricBone bone1 = new TrigonometricBone(); public TrigonometricBone bone2 = new TrigonometricBone(); public TrigonometricBone bone3 = new TrigonometricBone(); protected Vector3 weightIKPosition; protected bool directHierarchy = true; public void SetBendGoalPosition(Vector3 goalPosition, float weight) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) if (!base.initiated || weight <= 0f) { return; } Vector3 val = Vector3.Cross(goalPosition - bone1.transform.position, IKPosition - bone1.transform.position); if (val != Vector3.zero) { if (weight >= 1f) { bendNormal = val; } else { bendNormal = Vector3.Lerp(bendNormal, val, weight); } } } public void SetBendPlaneToCurrent() { //IL_001c: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0062: 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) if (base.initiated) { Vector3 val = Vector3.Cross(bone2.transform.position - bone1.transform.position, bone3.transform.position - bone2.transform.position); if (val != Vector3.zero) { bendNormal = val; } } } public void SetIKRotation(Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) IKRotation = rotation; } public void SetIKRotationWeight(float weight) { IKRotationWeight = Mathf.Clamp(weight, 0f, 1f); } public Quaternion GetIKRotation() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return IKRotation; } public float GetIKRotationWeight() { return IKRotationWeight; } public override Point[] GetPoints() { return new Point[3] { bone1, bone2, bone3 }; } public override Point GetPoint(Transform transform) { if ((Object)(object)bone1.transform == (Object)(object)transform) { return bone1; } if ((Object)(object)bone2.transform == (Object)(object)transform) { return bone2; } if ((Object)(object)bone3.transform == (Object)(object)transform) { return bone3; } return null; } public override void StoreDefaultLocalState() { bone1.StoreDefaultLocalState(); bone2.StoreDefaultLocalState(); bone3.StoreDefaultLocalState(); } public override void FixTransforms() { if (base.initiated) { bone1.FixTransform(); bone2.FixTransform(); bone3.FixTransform(); } } public override bool IsValid(ref string message) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_00be: 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_00f7: 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) if ((Object)(object)bone1.transform == (Object)null || (Object)(object)bone2.transform == (Object)null || (Object)(object)bone3.transform == (Object)null) { message = "Please assign all Bones to the IK solver."; return false; } Transform val = (Transform)Hierarchy.ContainsDuplicate((Object[])(object)new Transform[3] { bone1.transform, bone2.transform, bone3.transform }); if ((Object)(object)val != (Object)null) { message = ((Object)val).name + " is represented multiple times in the Bones."; return false; } if (bone1.transform.position == bone2.transform.position) { message = "first bone position is the same as second bone position."; return false; } if (bone2.transform.position == bone3.transform.position) { message = "second bone position is the same as third bone position."; return false; } return true; } public bool SetChain(Transform bone1, Transform bone2, Transform bone3, Transform root) { this.bone1.transform = bone1; this.bone2.transform = bone2; this.bone3.transform = bone3; Initiate(root); return base.initiated; } public static void Solve(Transform bone1, Transform bone2, Transform bone3, Vector3 targetPosition, Vector3 bendNormal, float weight) { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_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_0048: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_007e: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0100: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return; } targetPosition = Vector3.Lerp(bone3.position, targetPosition, weight); Vector3 val = targetPosition - bone1.position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude != 0f) { Vector3 val2 = bone2.position - bone1.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; Vector3 val3 = bone3.position - bone2.position; float sqrMagnitude2 = ((Vector3)(ref val3)).sqrMagnitude; Vector3 bendDirection = Vector3.Cross(val, bendNormal); Vector3 directionToBendPoint = GetDirectionToBendPoint(val, magnitude, bendDirection, sqrMagnitude, sqrMagnitude2); Quaternion val4 = Quaternion.FromToRotation(bone2.position - bone1.position, directionToBendPoint); if (weight < 1f) { val4 = Quaternion.Lerp(Quaternion.identity, val4, weight); } bone1.rotation = val4 * bone1.rotation; Quaternion val5 = Quaternion.FromToRotation(bone3.position - bone2.position, targetPosition - bone2.position); if (weight < 1f) { val5 = Quaternion.Lerp(Quaternion.identity, val5, weight); } bone2.rotation = val5 * bone2.rotation; } } private static Vector3 GetDirectionToBendPoint(Vector3 direction, float directionMag, Vector3 bendDirection, float sqrMag1, float sqrMag2) { //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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) float num = (directionMag * directionMag + (sqrMag1 - sqrMag2)) / 2f / directionMag; float num2 = (float)Math.Sqrt(Mathf.Clamp(sqrMag1 - num * num, 0f, float.PositiveInfinity)); if (direction == Vector3.zero) { return Vector3.zero; } return Quaternion.LookRotation(direction, bendDirection) * new Vector3(0f, num2, num); } protected override void OnInitiate() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) if (bendNormal == Vector3.zero) { bendNormal = Vector3.right; } OnInitiateVirtual(); IKPosition = bone3.transform.position; IKRotation = bone3.transform.rotation; InitiateBones(); directHierarchy = IsDirectHierarchy(); } private bool IsDirectHierarchy() { if ((Object)(object)bone3.transform.parent != (Object)(object)bone2.transform) { return false; } if ((Object)(object)bone2.transform.parent != (Object)(object)bone1.transform) { return false; } return true; } private void InitiateBones() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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) bone1.Initiate(bone2.transform.position, bendNormal); bone2.Initiate(bone3.transform.position, bendNormal); SetBendPlaneToCurrent(); } protected override void OnUpdate() { //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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_00a6: 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_00c7: 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_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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_0223: Unknown result type (might be due to invalid IL or missing references) IKPositionWeight = Mathf.Clamp(IKPositionWeight, 0f, 1f); IKRotationWeight = Mathf.Clamp(IKRotationWeight, 0f, 1f); if ((Object)(object)target != (Object)null) { IKPosition = target.position; IKRotation = target.rotation; } OnUpdateVirtual(); if (IKPositionWeight > 0f) { if (!directHierarchy) { bone1.Initiate(bone2.transform.position, bendNormal); bone2.Initiate(bone3.transform.position, bendNormal); } TrigonometricBone trigonometricBone = bone1; Vector3 val = bone2.transform.position - bone1.transform.position; trigonometricBone.sqrMag = ((Vector3)(ref val)).sqrMagnitude; TrigonometricBone trigonometricBone2 = bone2; Vector3 val2 = bone3.transform.position - bone2.transform.position; trigonometricBone2.sqrMag = ((Vector3)(ref val2)).sqrMagnitude; if (bendNormal == Vector3.zero && !Warning.logged) { LogWarning("IKSolverTrigonometric Bend Normal is Vector3.zero."); } weightIKPosition = Vector3.Lerp(bone3.transform.position, IKPosition, IKPositionWeight); Vector3 val3 = Vector3.Lerp(bone1.GetBendNormalFromCurrentRotation(), bendNormal, IKPositionWeight); Vector3 val4 = Vector3.Lerp(bone2.transform.position - bone1.transform.position, GetBendDirection(weightIKPosition, val3), IKPositionWeight); if (val4 == Vector3.zero) { val4 = bone2.transform.position - bone1.transform.position; } bone1.transform.rotation = bone1.GetRotation(val4, val3); bone2.transform.rotation = bone2.GetRotation(weightIKPosition - bone2.transform.position, bone2.GetBendNormalFromCurrentRotation()); } if (IKRotationWeight > 0f) { bone3.transform.rotation = Quaternion.Slerp(bone3.transform.rotation, IKRotation, IKRotationWeight); } OnPostSolveVirtual(); } protected virtual void OnInitiateVirtual() { } protected virtual void OnUpdateVirtual() { } protected virtual void OnPostSolveVirtual() { } protected Vector3 GetBendDirection(Vector3 IKPosition, Vector3 bendNormal) { //IL_0001: 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_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) Vector3 val = IKPosition - bone1.transform.position; if (val == Vector3.zero) { return Vector3.zero; } float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; float num = (float)Math.Sqrt(sqrMagnitude); float num2 = (sqrMagnitude + bone1.sqrMag - bone2.sqrMag) / 2f / num; float num3 = (float)Math.Sqrt(Mathf.Clamp(bone1.sqrMag - num2 * num2, 0f, float.PositiveInfinity)); Vector3 val2 = Vector3.Cross(val / num, bendNormal); return Quaternion.LookRotation(val, val2) * new Vector3(0f, num3, num2); } } [Serializable] public class IKSolverVR : IKSolver { [Serializable] public class Arm : BodyPart { [Serializable] public enum ShoulderRotationMode { YawPitch, FromTo } [Tooltip("The hand target. This should not be the hand controller itself, but a child GameObject parented to it so you could adjust it's position/rotation to match the orientation of the hand bone. The best practice for setup would be to move the hand controller to the avatar's hand as it it was held by the avatar, duplicate the avatar's hand bone and parent it to the hand controller. Then assign the duplicate to this slot.")] public Transform target; [Tooltip("The elbow will be bent towards this Transform if 'Bend Goal Weight' > 0.")] public Transform bendGoal; [Tooltip("Positional weight of the hand target. Note that if you have nulled the target, the hand will still be pulled to the last position of the target until you set this value to 0.")] [Range(0f, 1f)] public float positionWeight = 1f; [Tooltip("Rotational weight of the hand target. Note that if you have nulled the target, the hand will still be rotated to the last rotation of the target until you set this value to 0.")] [Range(0f, 1f)] public float rotationWeight = 1f; [Tooltip("Different techniques for shoulder bone rotation.")] public ShoulderRotationMode shoulderRotationMode = ShoulderRotationMode.YawPitch; [Tooltip("The weight of shoulder rotation")] [Range(0f, 1f)] public float shoulderRotationWeight = 1f; [Tooltip("The weight of twisting the shoulders backwards when arms are lifted up.")] [Range(0f, 1f)] public float shoulderTwistWeight = 1f; [Tooltip("If greater than 0, will bend the elbow towards the 'Bend Goal' Transform.")] [Range(0f, 1f)] public float bendGoalWeight; [Tooltip("Angular offset of the elbow bending direction.")] [Range(-180f, 180f)] public float swivelOffset; [Tooltip("Local axis of the hand bone that points from the wrist towards the palm. Used for defining hand bone orientation. If you have copied VRIK component from another avatar that has different bone orientations, right-click on VRIK header and select 'Guess Hand Orientations' from the context menu.")] public Vector3 wristToPalmAxis = Vector3.zero; [Tooltip("Local axis of the hand bone that points from the palm towards the thumb. Used for defining hand bone orientation. If you have copied VRIK component from another avatar that has different bone orientations, right-click on VRIK header and select 'Guess Hand Orientations' from the context menu.")] public Vector3 palmToThumbAxis = Vector3.zero; [Tooltip("Use this to make the arm shorter/longer. Works by displacement of hand and forearm localPosition.")] [Range(0.01f, 2f)] public float armLengthMlp = 1f; [Tooltip("Evaluates stretching of the arm by target distance relative to arm length. Value at time 1 represents stretching amount at the point where distance to the target is equal to arm length. Value at time 2 represents stretching amount at the point where distance to the target is double the arm length. Value represents the amount of stretching. Linear stretching would be achieved with a linear curve going up by 45 degrees. Increase the range of stretching by moving the last key up and right at the same amount. Smoothing in the curve can help reduce elbow snapping (start stretching the arm slightly before target distance reaches arm length). To get a good optimal value for this curve, please go to the 'VRIK (Basic)' demo scene and copy the stretch curve over from the Pilot character.")] public AnimationCurve stretchCurve = new AnimationCurve(); [NonSerialized] [HideInInspector] public Vector3 IKPosition; [NonSerialized] [HideInInspector] public Quaternion IKRotation = Quaternion.identity; [NonSerialized] [HideInInspector] public Vector3 bendDirection = Vector3.back; [NonSerialized] [HideInInspector] public Vector3 handPositionOffset; private bool hasShoulder; private Vector3 chestForwardAxis; private Vector3 chestUpAxis; private Quaternion chestRotation = Quaternion.identity; private Vector3 chestForward; private Vector3 chestUp; private Quaternion forearmRelToUpperArm = Quaternion.identity; private Vector3 upperArmBendAxis; private const float yawOffsetAngle = 45f; private const float pitchOffsetAngle = -30f; public Vector3 position { get; private set; } public Quaternion rotation { get; private set; } private VirtualBone shoulder => bones[0]; private VirtualBone upperArm => bones[hasShoulder ? 1 : 0]; private VirtualBone forearm => bones[(!hasShoulder) ? 1 : 2]; private VirtualBone hand => bones[(!hasShoulder) ? 2 : 3]; protected override void OnRead(Vector3[] positions, Quaternion[] rotations, bool hasChest, bool hasNeck, bool hasShoulders, bool hasToes, bool hasLegs, int rootIndex, int index) { //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_0017: 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_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_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_008e: 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_0096: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0279: 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_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_00e1: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_0112: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01dc: 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_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: 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_01d9: Unknown result type (might be due to invalid IL or missing references) Vector3 val = positions[index]; Quaternion val2 = rotations[index]; Vector3 val3 = positions[index + 1]; Quaternion val4 = rotations[index + 1]; Vector3 val5 = positions[index + 2]; Quaternion val6 = rotations[index + 2]; Vector3 iKPosition = positions[index + 3]; Quaternion iKRotation = rotations[index + 3]; if (!initiated) { IKPosition = iKPosition; IKRotation = iKRotation; rotation = IKRotation; hasShoulder = hasShoulders; bones = new VirtualBone[(!hasShoulder) ? 3 : 4]; if (hasShoulder) { bones[0] = new VirtualBone(val, val2); bones[1] = new VirtualBone(val3, val4); bones[2] = new VirtualBone(val5, val6); bones[3] = new VirtualBone(iKPosition, iKRotation); } else { bones[0] = new VirtualBone(val3, val4); bones[1] = new VirtualBone(val5, val6); bones[2] = new VirtualBone(iKPosition, iKRotation); } Vector3 val7 = rotations[0] * Vector3.forward; chestForwardAxis = Quaternion.Inverse(rootRotation) * val7; chestUpAxis = Quaternion.Inverse(rootRotation) * (rotations[0] * Vector3.up); Vector3 val8 = AxisTools.GetAxisVectorToDirection(val4, val7); if (Vector3.Dot(val4 * val8, val7) < 0f) { val8 = -val8; } upperArmBendAxis = Vector3.Cross(Quaternion.Inverse(val4) * (val5 - val3), val8); if (upperArmBendAxis == Vector3.zero) { Debug.LogWarning((object)"VRIK can not calculate which way to bend the arms because the arms are perfectly straight. Please rotate the elbow bones slightly in their natural bending direction in the Editor."); } } if (hasShoulder) { bones[0].Read(val, val2); bones[1].Read(val3, val4); bones[2].Read(val5, val6); bones[3].Read(iKPosition, iKRotation); } else { bones[0].Read(val3, val4); bones[1].Read(val5, val6); bones[2].Read(iKPosition, iKRotation); } } public override void PreSolve() { //IL_003d: 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_005f: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) if ((Object)(object)target != (Object)null) { IKPosition = target.position; IKRotation = target.rotation; } position = V3Tools.Lerp(hand.solverPosition, IKPosition, positionWeight); rotation = QuaTools.Lerp(hand.solverRotation, IKRotation, rotationWeight); shoulder.axis = ((Vector3)(ref shoulder.axis)).normalized; forearmRelToUpperArm = Quaternion.Inverse(upperArm.solverRotation) * forearm.solverRotation; } public override void ApplyOffsets(float scale) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) position += handPositionOffset; } private void Stretching() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d4: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: 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_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_0066: 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_0072: 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_0082: 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_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) float num = upperArm.length + forearm.length; Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; if (armLengthMlp != 1f) { num *= armLengthMlp; zero = (forearm.solverPosition - upperArm.solverPosition) * (armLengthMlp - 1f); zero2 = (hand.solverPosition - forearm.solverPosition) * (armLengthMlp - 1f); VirtualBone virtualBone = forearm; virtualBone.solverPosition += zero; VirtualBone virtualBone2 = hand; virtualBone2.solverPosition += zero + zero2; } float num2 = Vector3.Distance(upperArm.solverPosition, position); float num3 = num2 / num; float num4 = stretchCurve.Evaluate(num3); num4 *= positionWeight; zero = (forearm.solverPosition - upperArm.solverPosition) * num4; zero2 = (hand.solverPosition - forearm.solverPosition) * num4; VirtualBone virtualBone3 = forearm; virtualBone3.solverPosition += zero; VirtualBone virtualBone4 = hand; virtualBone4.solverPosition += zero + zero2; } public void Solve(bool isLeft) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_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_0029: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //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_005a: 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) //IL_0720: Unknown result type (might be due to invalid IL or missing references) //IL_072b: Unknown result type (might be due to invalid IL or missing references) //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_0735: 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_0773: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Unknown result type (might be due to invalid IL or missing references) //IL_0751: Unknown result type (might be due to invalid IL or missing references) //IL_0756: 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_00ad: 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_00b7: 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_045e: 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_046b: 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_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: 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_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04af: 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_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: 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_050a: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0586: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_0599: Unknown result type (might be due to invalid IL or missing references) //IL_05a1: 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_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05b0: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05cf: Unknown result type (might be due to invalid IL or missing references) //IL_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_08c9: Unknown result type (might be due to invalid IL or missing references) //IL_08ce: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Unknown result type (might be due to invalid IL or missing references) //IL_07af: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07bf: Unknown result type (might be due to invalid IL or missing references) //IL_07ca: Unknown result type (might be due to invalid IL or missing references) //IL_07cf: Unknown result type (might be due to invalid IL or missing references) //IL_07d4: Unknown result type (might be due to invalid IL or missing references) //IL_07d9: Unknown result type (might be due to invalid IL or missing references) //IL_07db: Unknown result type (might be due to invalid IL or missing references) //IL_07dd: Unknown result type (might be due to invalid IL or missing references) //IL_07e2: Unknown result type (might be due to invalid IL or missing references) //IL_07e3: Unknown result type (might be due to invalid IL or missing references) //IL_07e8: Unknown result type (might be due to invalid IL or missing references) //IL_081a: Unknown result type (might be due to invalid IL or missing references) //IL_0825: Unknown result type (might be due to invalid IL or missing references) //IL_082a: Unknown result type (might be due to invalid IL or missing references) //IL_082f: Unknown result type (might be due to invalid IL or missing references) //IL_083a: Unknown result type (might be due to invalid IL or missing references) //IL_083f: Unknown result type (might be due to invalid IL or missing references) //IL_0844: Unknown result type (might be due to invalid IL or missing references) //IL_084f: Unknown result type (might be due to invalid IL or missing references) //IL_0855: Unknown result type (might be due to invalid IL or missing references) //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_085f: Unknown result type (might be due to invalid IL or missing references) //IL_0861: Unknown result type (might be due to invalid IL or missing references) //IL_0869: Unknown result type (might be due to invalid IL or missing references) //IL_086e: Unknown result type (might be due to invalid IL or missing references) //IL_0879: Unknown result type (might be due to invalid IL or missing references) //IL_0884: Unknown result type (might be due to invalid IL or missing references) //IL_0889: Unknown result type (might be due to invalid IL or missing references) //IL_088e: Unknown result type (might be due to invalid IL or missing references) //IL_0893: Unknown result type (might be due to invalid IL or missing references) //IL_089c: Unknown result type (might be due to invalid IL or missing references) //IL_089e: Unknown result type (might be due to invalid IL or missing references) //IL_08a0: Unknown result type (might be due to invalid IL or missing references) //IL_067f: Unknown result type (might be due to invalid IL or missing references) //IL_0684: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_08f6: Unknown result type (might be due to invalid IL or missing references) //IL_08fc: Unknown result type (might be due to invalid IL or missing references) //IL_0907: Unknown result type (might be due to invalid IL or missing references) //IL_090c: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0133: 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_0689: Unknown result type (might be due to invalid IL or missing references) //IL_068e: Unknown result type (might be due to invalid IL or missing references) //IL_0699: Unknown result type (might be due to invalid IL or missing references) //IL_069e: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_06d7: Unknown result type (might be due to invalid IL or missing references) //IL_06dc: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: Unknown result type (might be due to invalid IL or missing references) //IL_06e1: Unknown result type (might be due to invalid IL or missing references) //IL_06e6: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_06f6: Unknown result type (might be due to invalid IL or missing references) //IL_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: 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_01ff: 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_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024f: 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_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: 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_0328: 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_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_042f: 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_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) chestRotation = Quaternion.LookRotation(rootRotation * chestForwardAxis, rootRotation * chestUpAxis); chestForward = chestRotation * Vector3.forward; chestUp = chestRotation * Vector3.up; Vector3 val = Vector3.zero; if (hasShoulder && shoulderRotationWeight > 0f && LOD < 1) { switch (shoulderRotationMode) { case ShoulderRotationMode.YawPitch: { Vector3 val7 = position - shoulder.solverPosition; val7 = ((Vector3)(ref val7)).normalized; float num4 = ((!isLeft) ? (-45f) : 45f); Quaternion val8 = Quaternion.AngleAxis(((!isLeft) ? 90f : (-90f)) + num4, chestUp); Quaternion val9 = val8 * chestRotation; Vector3 val10 = Quaternion.Inverse(val9) * val7; float num5 = Mathf.Atan2(val10.x, val10.z) * 57.29578f; float num6 = Vector3.Dot(val10, Vector3.up); num6 = 1f - Mathf.Abs(num6); num5 *= num6; num5 -= num4; float num7 = ((!isLeft) ? (-50f) : (-20f)); float num8 = ((!isLeft) ? 20f : 50f); num5 = DamperValue(num5, num7 - num4, num8 - num4, 0.7f); Vector3 val11 = shoulder.solverRotation * shoulder.axis; Vector3 val12 = val9 * (Quaternion.AngleAxis(num5, Vector3.up) * Vector3.forward); Quaternion val13 = Quaternion.FromToRotation(val11, val12); Quaternion val14 = Quaternion.AngleAxis((!isLeft) ? 90f : (-90f), chestUp); val9 = val14 * chestRotation; val9 = Quaternion.AngleAxis((!isLeft) ? 30f : (-30f), chestForward) * val9; val7 = position - (shoulder.solverPosition + chestRotation * ((!isLeft) ? Vector3.left : Vector3.right) * base.mag); val10 = Quaternion.Inverse(val9) * val7; float num9 = Mathf.Atan2(val10.y, val10.z) * 57.29578f; num9 -= -30f; num9 = DamperValue(num9, -15f, 75f); Quaternion val15 = Quaternion.AngleAxis(0f - num9, val9 * Vector3.right); Quaternion val16 = val15 * val13; if (shoulderRotationWeight * positionWeight < 1f) { val16 = Quaternion.Lerp(Quaternion.identity, val16, shoulderRotationWeight * positionWeight); } VirtualBone.RotateBy(bones, val16); Stretching(); val = GetBendNormal(position - upperArm.solverPosition); VirtualBone.SolveTrigonometric(bones, 1, 2, 3, position, val, positionWeight); float num10 = Mathf.Clamp(num9 * positionWeight * shoulderRotationWeight * shoulderTwistWeight * 2f, 0f, 180f); shoulder.solverRotation = Quaternion.AngleAxis(num10, shoulder.solverRotation * ((!isLeft) ? (-shoulder.axis) : shoulder.axis)) * shoulder.solverRotation; upperArm.solverRotation = Quaternion.AngleAxis(num10, upperArm.solverRotation * ((!isLeft) ? (-upperArm.axis) : upperArm.axis)) * upperArm.solverRotation; break; } case ShoulderRotationMode.FromTo: { Quaternion solverRotation = shoulder.solverRotation; Vector3 val2 = upperArm.solverPosition - shoulder.solverPosition; Quaternion val3 = Quaternion.FromToRotation(((Vector3)(ref val2)).normalized + chestForward, position - shoulder.solverPosition); val3 = Quaternion.Slerp(Quaternion.identity, val3, 0.5f * shoulderRotationWeight * positionWeight); VirtualBone.RotateBy(bones, val3); Stretching(); VirtualBone.SolveTrigonometric(bones, 0, 2, 3, position, Vector3.Cross(forearm.solverPosition - shoulder.solverPosition, hand.solverPosition - shoulder.solverPosition), 0.5f * shoulderRotationWeight * positionWeight); val = GetBendNormal(position - upperArm.solverPosition); VirtualBone.SolveTrigonometric(bones, 1, 2, 3, position, val, positionWeight); Quaternion val4 = Quaternion.Inverse(Quaternion.LookRotation(chestUp, chestForward)); Vector3 val5 = val4 * (solverRotation * shoulder.axis); Vector3 val6 = val4 * (shoulder.solverRotation * shoulder.axis); float num = Mathf.Atan2(val5.x, val5.z) * 57.29578f; float num2 = Mathf.Atan2(val6.x, val6.z) * 57.29578f; float num3 = Mathf.DeltaAngle(num, num2); if (isLeft) { num3 = 0f - num3; } num3 = Mathf.Clamp(num3 * shoulderRotationWeight * shoulderTwistWeight * 2f * positionWeight, 0f, 180f); shoulder.solverRotation = Quaternion.AngleAxis(num3, shoulder.solverRotation * ((!isLeft) ? (-shoulder.axis) : shoulder.axis)) * shoulder.solverRotation; upperArm.solverRotation = Quaternion.AngleAxis(num3, upperArm.solverRotation * ((!isLeft) ? (-upperArm.axis) : upperArm.axis)) * upperArm.solverRotation; break; } } } else { if (LOD < 1) { Stretching(); } val = GetBendNormal(position - upperArm.solverPosition); if (hasShoulder) { VirtualBone.SolveTrigonometric(bones, 1, 2, 3, position, val, positionWeight); } else { VirtualBone.SolveTrigonometric(bones, 0, 1, 2, position, val, positionWeight); } } if (LOD < 1 && positionWeight > 0f) { Quaternion val17 = Quaternion.LookRotation(upperArm.solverRotation * upperArmBendAxis, forearm.solverPosition - upperArm.solverPosition); Vector3 val18 = Quaternion.Inverse(val17) * val; float num11 = Mathf.Atan2(val18.x, val18.z) * 57.29578f; upperArm.solverRotation = Quaternion.AngleAxis(num11 * positionWeight, forearm.solverPosition - upperArm.solverPosition) * upperArm.solverRotation; Quaternion val19 = upperArm.solverRotation * forearmRelToUpperArm; Quaternion val20 = Quaternion.FromToRotation(val19 * forearm.axis, hand.solverPosition - forearm.solverPosition); RotateTo(forearm, val20 * val19, positionWeight); } if (rotationWeight >= 1f) { hand.solverRotation = rotation; } else if (rotationWeight > 0f) { hand.solverRotation = Quaternion.Lerp(hand.solverRotation, rotation, rotationWeight); } } public override void ResetOffsets() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) handPositionOffset = Vector3.zero; } public override void Write(ref Vector3[] solvedPositions, ref Quaternion[] solvedRotations) { //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) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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) if (hasShoulder) { ref Vector3 reference = ref solvedPositions[index]; reference = shoulder.solverPosition; ref Quaternion reference2 = ref solvedRotations[index]; reference2 = shoulder.solverRotation; } ref Vector3 reference3 = ref solvedPositions[index + 1]; reference3 = upperArm.solverPosition; ref Vector3 reference4 = ref solvedPositions[index + 2]; reference4 = forearm.solverPosition; ref Vector3 reference5 = ref solvedPositions[index + 3]; reference5 = hand.solverPosition; ref Quaternion reference6 = ref solvedRotations[index + 1]; reference6 = upperArm.solverRotation; ref Quaternion reference7 = ref solvedRotations[index + 2]; reference7 = forearm.solverRotation; ref Quaternion reference8 = ref solvedRotations[index + 3]; reference8 = hand.solverRotation; } private float DamperValue(float value, float min, float max, float weight = 1f) { float num = max - min; if (weight < 1f) { float num2 = max - num * 0.5f; float num3 = value - num2; num3 *= 0.5f; value = num2 + num3; } value -= min; float t = Mathf.Clamp(value / num, 0f, 1f); float num4 = Interp.Float(t, InterpolationMode.InOutQuintic); return Mathf.Lerp(min, max, num4); } private Vector3 GetBendNormal(Vector3 dir) { //IL_003d: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_007c: 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_007e: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_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_009d: 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_00a3: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00d9: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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) if ((Object)(object)bendGoal != (Object)null) { bendDirection = bendGoal.position - bones[1].solverPosition; } Vector3 val = bones[0].solverRotation * bones[0].axis; Vector3 down = Vector3.down; Vector3 val2 = Quaternion.Inverse(chestRotation) * ((Vector3)(ref dir)).normalized + Vector3.forward; Quaternion val3 = Quaternion.FromToRotation(down, val2); Vector3 val4 = val3 * Vector3.back; down = Quaternion.Inverse(chestRotation) * val; val2 = Quaternion.Inverse(chestRotation) * dir; val3 = Quaternion.FromToRotation(down, val2); val4 = val3 * val4; val4 = chestRotation * val4; val4 += val; val4 -= rotation * wristToPalmAxis; val4 -= rotation * palmToThumbAxis * 0.5f; if (bendGoalWeight > 0f) { val4 = Vector3.Slerp(val4, bendDirection, bendGoalWeight); } if (swivelOffset != 0f) { val4 = Quaternion.AngleAxis(swivelOffset, -dir) * val4; } return Vector3.Cross(val4, dir); } private void Visualize(VirtualBone bone1, VirtualBone bone2, VirtualBone bone3, Color color) { //IL_0002: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Debug.DrawLine(bone1.solverPosition, bone2.solverPosition, color); Debug.DrawLine(bone2.solverPosition, bone3.solverPosition, color); } } [Serializable] public abstract class BodyPart { [HideInInspector] public VirtualBone[] bones = new VirtualBone[0]; protected bool initiated; protected Vector3 rootPosition; protected Quaternion rootRotation = Quaternion.identity; protected int index = -1; protected int LOD; public float sqrMag { get; private set; } public float mag { get; private set; } protected abstract void OnRead(Vector3[] positions, Quaternion[] rotations, bool hasChest, bool hasNeck, bool hasShoulders, bool hasToes, bool hasLegs, int rootIndex, int index); public abstract void PreSolve(); public abstract void Write(ref Vector3[] solvedPositions, ref Quaternion[] solvedRotations); public abstract void ApplyOffsets(float scale); public abstract void ResetOffsets(); public void SetLOD(int LOD) { this.LOD = LOD; } public void Read(Vector3[] positions, Quaternion[] rotations, bool hasChest, bool hasNeck, bool hasShoulders, bool hasToes, bool hasLegs, int rootIndex, int index) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) this.index = index; rootPosition = positions[rootIndex]; rootRotation = rotations[rootIndex]; OnRead(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, rootIndex, index); mag = VirtualBone.PreSolve(ref bones); sqrMag = mag * mag; initiated = true; } public void MovePosition(Vector3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0014: 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_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) Vector3 val = position - bones[0].solverPosition; VirtualBone[] array = bones; foreach (VirtualBone virtualBone in array) { virtualBone.solverPosition += val; } } public void MoveRotation(Quaternion rotation) { //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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation2 = QuaTools.FromToRotation(bones[0].solverRotation, rotation); VirtualBone.RotateAroundPoint(bones, 0, bones[0].solverPosition, rotation2); } public void Translate(Vector3 position, Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) MovePosition(position); MoveRotation(rotation); } public void TranslateRoot(Vector3 newRootPos, Quaternion newRootRot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_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_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_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_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_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_0056: 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_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) Vector3 val = newRootPos - rootPosition; rootPosition = newRootPos; VirtualBone[] array = bones; foreach (VirtualBone virtualBone in array) { virtualBone.solverPosition += val; } Quaternion rotation = QuaTools.FromToRotation(rootRotation, newRootRot); rootRotation = newRootRot; VirtualBone.RotateAroundPoint(bones, 0, newRootPos, rotation); } public void RotateTo(VirtualBone bone, Quaternion rotation, float weight = 1f) { //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_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_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_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) if (weight <= 0f) { return; } Quaternion val = QuaTools.FromToRotation(bone.solverRotation, rotation); if (weight < 1f) { val = Quaternion.Slerp(Quaternion.identity, val, weight); } for (int i = 0; i < bones.Length; i++) { if (bones[i] == bone) { VirtualBone.RotateAroundPoint(bones, i, bones[i].solverPosition, val); break; } } } public void Visualize(Color color) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < bones.Length - 1; i++) { Debug.DrawLine(bones[i].solverPosition, bones[i + 1].solverPosition, color); } } public void Visualize() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Visualize(Color.white); } } [Serializable] public class Footstep { public float stepSpeed = 3f; public Vector3 characterSpaceOffset; public Vector3 position; public Quaternion rotation = Quaternion.identity; public Quaternion stepToRootRot = Quaternion.identity; public bool isSupportLeg; public bool relaxFlag; public Vector3 stepFrom; public Vector3 stepTo; public Quaternion stepFromRot = Quaternion.identity; public Quaternion stepToRot = Quaternion.identity; private Quaternion footRelativeToRoot = Quaternion.identity; private float supportLegW; private float supportLegWV; public bool isStepping => stepProgress < 1f; public float stepProgress { get; private set; } public Footstep(Quaternion rootRotation, Vector3 footPosition, Quaternion footRotation, Vector3 characterSpaceOffset) { //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_0017: 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_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0054: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) this.characterSpaceOffset = characterSpaceOffset; Reset(rootRotation, footPosition, footRotation); footRelativeToRoot = Quaternion.Inverse(rootRotation) * rotation; } public void Reset(Quaternion rootRotation, Vector3 footPosition, Quaternion footRotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0040: 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) position = footPosition; rotation = footRotation; stepFrom = position; stepTo = position; stepFromRot = rotation; stepToRot = rotation; stepToRootRot = rootRotation; stepProgress = 1f; } public void StepTo(Vector3 p, Quaternion rootRotation, float stepThreshold) { //IL_001c: 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_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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (relaxFlag) { stepThreshold = 0f; relaxFlag = false; } if (!(Vector3.Magnitude(p - stepTo) < stepThreshold) || !(Quaternion.Angle(rootRotation, stepToRootRot) < 25f)) { stepFrom = position; stepTo = p; stepFromRot = rotation; stepToRootRot = rootRotation; stepToRot = rootRotation * footRelativeToRoot; stepProgress = 0f; } } public void UpdateStepping(Vector3 p, Quaternion rootRotation, float speed) { //IL_0003: 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_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_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) //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) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_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) stepTo = Vector3.Lerp(stepTo, p, Time.deltaTime * speed); stepToRot = Quaternion.Lerp(stepToRot, rootRotation * footRelativeToRoot, Time.deltaTime * speed); stepToRootRot = stepToRot * Quaternion.Inverse(footRelativeToRoot); } public void UpdateStanding(Quaternion rootRotation, float minAngle, float speed) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) if (!(speed <= 0f) && !(minAngle >= 180f)) { Quaternion val = rootRotation * footRelativeToRoot; float num = Quaternion.Angle(rotation, val); if (num > minAngle) { rotation = Quaternion.RotateTowards(rotation, val, Mathf.Min(Time.deltaTime * speed * (1f - supportLegW), num - minAngle)); } } } public void Update(InterpolationMode interpolation, UnityEvent onStep) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) float num = ((!isSupportLeg) ? 0f : 1f); supportLegW = Mathf.SmoothDamp(supportLegW, num, ref supportLegWV, 0.2f); if (isStepping) { stepProgress = Mathf.MoveTowards(stepProgress, 1f, Time.deltaTime * stepSpeed); if (stepProgress >= 1f) { onStep.Invoke(); } float num2 = Interp.Float(stepProgress, interpolation); position = Vector3.Lerp(stepFrom, stepTo, num2); rotation = Quaternion.Lerp(stepFromRot, stepToRot, num2); } } } [Serializable] public class Leg : BodyPart { [Tooltip("The foot/toe target. This should not be the foot tracker itself, but a child GameObject parented to it so you could adjust it's position/rotation to match the orientation of the foot/toe bone. If a toe bone is assigned in the References, the solver will match the toe bone to this target. If no toe bone assigned, foot bone will be used instead.")] public Transform target; [Tooltip("The knee will be bent towards this Transform if 'Bend Goal Weight' > 0.")] public Transform bendGoal; [Tooltip("Positional weight of the toe/foot target. Note that if you have nulled the target, the foot will still be pulled to the last position of the target until you set this value to 0.")] [Range(0f, 1f)] public float positionWeight; [Tooltip("Rotational weight of the toe/foot target. Note that if you have nulled the target, the foot will still be rotated to the last rotation of the target until you set this value to 0.")] [Range(0f, 1f)] public float rotationWeight; [Tooltip("If greater than 0, will bend the knee towards the 'Bend Goal' Transform.")] [Range(0f, 1f)] public float bendGoalWeight; [Tooltip("Angular offset of knee bending direction.")] [Range(-180f, 180f)] public float swivelOffset; [Tooltip("If 0, the bend plane will be locked to the rotation of the pelvis and rotating the foot will have no effect on the knee direction. If 1, to the target rotation of the leg so that the knee will bend towards the forward axis of the foot. Values in between will be slerped between the two.")] [Range(0f, 1f)] public float bendToTargetWeight = 0.5f; [Tooltip("Use this to make the leg shorter/longer. Works by displacement of foot and calf localPosition.")] [Range(0.01f, 2f)] public float legLengthMlp = 1f; [Tooltip("Evaluates stretching of the leg by target distance relative to leg length. Value at time 1 represents stretching amount at the point where distance to the target is equal to leg length. Value at time 1 represents stretching amount at the point where distance to the target is double the leg length. Value represents the amount of stretching. Linear stretching would be achieved with a linear curve going up by 45 degrees. Increase the range of stretching by moving the last key up and right at the same amount. Smoothing in the curve can help reduce knee snapping (start stretching the arm slightly before target distance reaches leg length). To get a good optimal value for this curve, please go to the 'VRIK (Basic)' demo scene and copy the stretch curve over from the Pilot character.")] public AnimationCurve stretchCurve = new AnimationCurve(); [NonSerialized] [HideInInspector] public Vector3 IKPosition; [NonSerialized] [HideInInspector] public Quaternion IKRotation = Quaternion.identity; [NonSerialized] [HideInInspector] public Vector3 footPositionOffset; [NonSerialized] [HideInInspector] public Vector3 heelPositionOffset; [NonSerialized] [HideInInspector] public Quaternion footRotationOffset = Quaternion.identity; [NonSerialized] [HideInInspector] public float currentMag; [HideInInspector] public bool useAnimatedBendNormal; private Vector3 footPosition; private Quaternion footRotation = Quaternion.identity; private Vector3 bendNormal; private Quaternion calfRelToThigh = Quaternion.identity; private Quaternion thighRelToFoot = Quaternion.identity; private Vector3 bendNormalRelToPelvis; private Vector3 bendNormalRelToTarget; public Vector3 position { get; private set; } public Quaternion rotation { get; private set; } public bool hasToes { get; private set; } public VirtualBone thigh => bones[0]; private VirtualBone calf => bones[1]; private VirtualBone foot => bones[2]; private VirtualBone toes => bones[3]; public VirtualBone lastBone => bones[bones.Length - 1]; public Vector3 thighRelativeToPelvis { get; private set; } protected override void OnRead(Vector3[] positions, Quaternion[] rotations, bool hasChest, bool hasNeck, bool hasShoulders, bool hasToes, bool hasLegs, int rootIndex, int index) { //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_0017: 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_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_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0203: 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_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: 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_0115: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00db: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_0195: 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_01a1: Unknown result type (might be due to invalid IL or missing references) Vector3 val = positions[index]; Quaternion val2 = rotations[index]; Vector3 val3 = positions[index + 1]; Quaternion val4 = rotations[index + 1]; Vector3 val5 = positions[index + 2]; Quaternion iKRotation = rotations[index + 2]; Vector3 iKPosition = positions[index + 3]; Quaternion iKRotation2 = rotations[index + 3]; if (!initiated) { this.hasToes = hasToes; bones = new VirtualBone[(!hasToes) ? 3 : 4]; if (hasToes) { bones[0] = new VirtualBone(val, val2); bones[1] = new VirtualBone(val3, val4); bones[2] = new VirtualBone(val5, iKRotation); bones[3] = new VirtualBone(iKPosition, iKRotation2); IKPosition = iKPosition; IKRotation = iKRotation2; } else { bones[0] = new VirtualBone(val, val2); bones[1] = new VirtualBone(val3, val4); bones[2] = new VirtualBone(val5, iKRotation); IKPosition = val5; IKRotation = iKRotation; } bendNormal = Vector3.Cross(val3 - val, val5 - val3); bendNormalRelToPelvis = Quaternion.Inverse(rootRotation) * bendNormal; bendNormalRelToTarget = Quaternion.Inverse(IKRotation) * bendNormal; rotation = IKRotation; } if (hasToes) { bones[0].Read(val, val2); bones[1].Read(val3, val4); bones[2].Read(val5, iKRotation); bones[3].Read(iKPosition, iKRotation2); } else { bones[0].Read(val, val2); bones[1].Read(val3, val4); bones[2].Read(val5, iKRotation); } } public override void PreSolve() { //IL_003d: 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_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_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_008d: 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_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_00ea: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_018e: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: 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_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target != (Object)null) { IKPosition = target.position; IKRotation = target.rotation; } footPosition = foot.solverPosition; footRotation = foot.solverRotation; position = lastBone.solverPosition; rotation = lastBone.solverRotation; if (rotationWeight > 0f) { ApplyRotationOffset(QuaTools.FromToRotation(rotation, IKRotation), rotationWeight); } if (positionWeight > 0f) { ApplyPositionOffset(IKPosition - position, positionWeight); } thighRelativeToPelvis = Quaternion.Inverse(rootRotation) * (thigh.solverPosition - rootPosition); calfRelToThigh = Quaternion.Inverse(thigh.solverRotation) * calf.solverRotation; thighRelToFoot = Quaternion.Inverse(lastBone.solverRotation) * thigh.solverRotation; if (useAnimatedBendNormal) { bendNormal = Vector3.Cross(calf.solverPosition - thigh.solverPosition, foot.solverPosition - calf.solverPosition); } else if (bendToTargetWeight <= 0f) { bendNormal = rootRotation * bendNormalRelToPelvis; } else if (bendToTargetWeight >= 1f) { bendNormal = rotation * bendNormalRelToTarget; } else { bendNormal = Vector3.Slerp(rootRotation * bendNormalRelToPelvis, rotation * bendNormalRelToTarget, bendToTargetWeight); } bendNormal = ((Vector3)(ref bendNormal)).normalized; } public override void ApplyOffsets(float scale) { //IL_0003: 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_0024: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_00fb: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) ApplyPositionOffset(footPositionOffset, 1f); ApplyRotationOffset(footRotationOffset, 1f); Quaternion val = Quaternion.FromToRotation(footPosition - position, footPosition + heelPositionOffset - position); footPosition = position + val * (footPosition - position); footRotation = val * footRotation; float num = 0f; if ((Object)(object)bendGoal != (Object)null && bendGoalWeight > 0f) { Vector3 val2 = Vector3.Cross(bendGoal.position - thigh.solverPosition, position - thigh.solverPosition); Quaternion val3 = Quaternion.LookRotation(bendNormal, thigh.solverPosition - foot.solverPosition); Vector3 val4 = Quaternion.Inverse(val3) * val2; num = Mathf.Atan2(val4.x, val4.z) * 57.29578f * bendGoalWeight; } float num2 = swivelOffset + num; if (num2 != 0f) { bendNormal = Quaternion.AngleAxis(num2, thigh.solverPosition - lastBone.solverPosition) * bendNormal; thigh.solverRotation = Quaternion.AngleAxis(0f - num2, thigh.solverRotation * thigh.axis) * thigh.solverRotation; } } private void ApplyPositionOffset(Vector3 offset, float weight) { //IL_0011: 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_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) //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_0034: Unknown result type (might be due to invalid IL or missing references) if (!(weight <= 0f)) { offset *= weight; footPosition += offset; position += offset; } } private void ApplyRotationOffset(Quaternion offset, float weight) { //IL_002d: 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_0039: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!(weight <= 0f)) { if (weight < 1f) { offset = Quaternion.Lerp(Quaternion.identity, offset, weight); } footRotation = offset * footRotation; rotation = offset * rotation; bendNormal = offset * bendNormal; footPosition = position + offset * (footPosition - position); } } public void Solve(bool stretch) { //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_0040: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0097: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) if (stretch && LOD < 1) { Stretching(); } VirtualBone.SolveTrigonometric(bones, 0, 1, 2, footPosition, bendNormal, 1f); RotateTo(foot, footRotation); if (!hasToes) { FixTwistRotations(); return; } Vector3 val = Vector3.Cross(foot.solverPosition - thigh.solverPosition, toes.solverPosition - foot.solverPosition); Vector3 normalized = ((Vector3)(ref val)).normalized; VirtualBone.SolveTrigonometric(bones, 0, 2, 3, position, normalized, 1f); FixTwistRotations(); toes.solverRotation = rotation; } private void FixTwistRotations() { //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_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_00e5: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_010d: 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_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_0031: 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_003d: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00a9: 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_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_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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (LOD >= 1) { return; } if (bendToTargetWeight > 0f) { Quaternion val = rotation * thighRelToFoot; Quaternion val2 = Quaternion.FromToRotation(val * thigh.axis, calf.solverPosition - thigh.solverPosition); if (bendToTargetWeight < 1f) { thigh.solverRotation = Quaternion.Slerp(thigh.solverRotation, val2 * val, bendToTargetWeight); } else { thigh.solverRotation = val2 * val; } } Quaternion val3 = thigh.solverRotation * calfRelToThigh; Quaternion val4 = Quaternion.FromToRotation(val3 * calf.axis, foot.solverPosition - calf.solverPosition); calf.solverRotation = val4 * val3; } private void Stretching() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_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_0066: 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_0076: 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_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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) float num = thigh.length + calf.length; Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; if (legLengthMlp != 1f) { num *= legLengthMlp; zero = (calf.solverPosition - thigh.solverPosition) * (legLengthMlp - 1f) * positionWeight; zero2 = (foot.solverPosition - calf.solverPosition) * (legLengthMlp - 1f) * positionWeight; VirtualBone virtualBone = calf; virtualBone.solverPosition += zero; VirtualBone virtualBone2 = foot; virtualBone2.solverPosition += zero + zero2; if (hasToes) { VirtualBone virtualBone3 = toes; virtualBone3.solverPosition += zero + zero2; } } float num2 = Vector3.Distance(thigh.solverPosition, footPosition); float num3 = num2 / num; float num4 = stretchCurve.Evaluate(num3) * positionWeight; zero = (calf.solverPosition - thigh.solverPosition) * num4; zero2 = (foot.solverPosition - calf.solverPosition) * num4; VirtualBone virtualBone4 = calf; virtualBone4.solverPosition += zero; VirtualBone virtualBone5 = foot; virtualBone5.solverPosition += zero + zero2; if (hasToes) { VirtualBone virtualBone6 = toes; virtualBone6.solverPosition += zero + zero2; } } public override void Write(ref Vector3[] solvedPositions, ref Quaternion[] solvedRotations) { //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_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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0093: 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_00b2: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) ref Quaternion reference = ref solvedRotations[index]; reference = thigh.solverRotation; ref Quaternion reference2 = ref solvedRotations[index + 1]; reference2 = calf.solverRotation; ref Quaternion reference3 = ref solvedRotations[index + 2]; reference3 = foot.solverRotation; ref Vector3 reference4 = ref solvedPositions[index]; reference4 = thigh.solverPosition; ref Vector3 reference5 = ref solvedPositions[index + 1]; reference5 = calf.solverPosition; ref Vector3 reference6 = ref solvedPositions[index + 2]; reference6 = foot.solverPosition; if (hasToes) { ref Quaternion reference7 = ref solvedRotations[index + 3]; reference7 = toes.solverRotation; ref Vector3 reference8 = ref solvedPositions[index + 3]; reference8 = toes.solverPosition; } } public override void ResetOffsets() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) footPositionOffset = Vector3.zero; footRotationOffset = Quaternion.identity; heelPositionOffset = Vector3.zero; } } [Serializable] public class Locomotion { [Tooltip("Used for blending in/out of procedural locomotion.")] [Range(0f, 1f)] public float weight = 1f; [Tooltip("Tries to maintain this distance between the legs.")] public float footDistance = 0.3f; [Tooltip("Makes a step only if step target position is at least this far from the current footstep or the foot does not reach the current footstep anymore or footstep angle is past the 'Angle Threshold'.")] public float stepThreshold = 0.4f; [Tooltip("Makes a step only if step target position is at least 'Step Threshold' far from the current footstep or the foot does not reach the current footstep anymore or footstep angle is past this value.")] public float angleThreshold = 60f; [Tooltip("Multiplies angle of the center of mass - center of pressure vector. Larger value makes the character step sooner if losing balance.")] public float comAngleMlp = 1f; [Tooltip("Maximum magnitude of head/hand target velocity used in prediction.")] public float maxVelocity = 0.4f; [Tooltip("The amount of head/hand target velocity prediction.")] public float velocityFactor = 0.4f; [Tooltip("How much can a leg be extended before it is forced to step to another position? 1 means fully stretched.")] [Range(0.9f, 1f)] public float maxLegStretch = 1f; [Tooltip("The speed of lerping the root of the character towards the horizontal mid-point of the footsteps.")] public float rootSpeed = 20f; [Tooltip("The speed of moving a foot to the next position.")] public float stepSpeed = 3f; [Tooltip("The height of the foot by normalized step progress (0 - 1).")] public AnimationCurve stepHeight; [Tooltip("Reduce this value if locomotion makes the head bob too much.")] public float maxBodyYOffset = 0.05f; [Tooltip("The height offset of the heel by normalized step progress (0 - 1).")] public AnimationCurve heelHeight; [Tooltip("Rotates the foot while the leg is not stepping to relax the twist rotation of the leg if ideal rotation is past this angle.")] [Range(0f, 180f)] public float relaxLegTwistMinAngle = 20f; [Tooltip("The speed of rotating the foot while the leg is not stepping to relax the twist rotation of the leg.")] public float relaxLegTwistSpeed = 400f; [Tooltip("Interpolation mode of the step.")] public InterpolationMode stepInterpolation = InterpolationMode.InOutSine; [Tooltip("Offset for the approximated center of mass.")] public Vector3 offset; [HideInInspector] public bool blockingEnabled; [HideInInspector] public LayerMask blockingLayers; [HideInInspector] public float raycastRadius = 0.2f; [HideInInspector] public float raycastHeight = 0.2f; [Tooltip("Called when the left foot has finished a step.")] public UnityEvent onLeftFootstep = new UnityEvent(); [Tooltip("Called when the right foot has finished a step")] public UnityEvent onRightFootstep = new UnityEvent(); private Footstep[] footsteps = new Footstep[0]; private Vector3 lastComPosition; private Vector3 comVelocity; private int leftFootIndex; private int rightFootIndex; public Vector3 centerOfMass { get; private set; } public Vector3 leftFootstepPosition => footsteps[0].position; public Vector3 rightFootstepPosition => footsteps[1].position; public Quaternion leftFootstepRotation => footsteps[0].rotation; public Quaternion rightFootstepRotation => footsteps[1].rotation; public void Initiate(Vector3[] positions, Quaternion[] rotations, bool hasToes, float scale) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0070: 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) leftFootIndex = ((!hasToes) ? 16 : 17); rightFootIndex = ((!hasToes) ? 20 : 21); footsteps = new Footstep[2] { new Footstep(rotations[0], positions[leftFootIndex], rotations[leftFootIndex], footDistance * scale * Vector3.left), new Footstep(rotations[0], positions[rightFootIndex], rotations[rightFootIndex], footDistance * scale * Vector3.right) }; } public void Reset(Vector3[] positions, Quaternion[] rotations) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00bc: Unknown result type (might be due to invalid IL or missing references) lastComPosition = Vector3.Lerp(positions[1], positions[5], 0.25f) + rotations[0] * offset; comVelocity = Vector3.zero; footsteps[0].Reset(rotations[0], positions[leftFootIndex], rotations[leftFootIndex]); footsteps[1].Reset(rotations[0], positions[rightFootIndex], rotations[rightFootIndex]); } public void Relax() { footsteps[0].relaxFlag = true; footsteps[1].relaxFlag = true; } public void AddDeltaRotation(Quaternion delta, Vector3 pivot) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0048: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0066: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00d2: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) Vector3 val = lastComPosition - pivot; lastComPosition = pivot + delta * val; Footstep[] array = footsteps; foreach (Footstep footstep in array) { footstep.rotation = delta * footstep.rotation; footstep.stepFromRot = delta * footstep.stepFromRot; footstep.stepToRot = delta * footstep.stepToRot; footstep.stepToRootRot = delta * footstep.stepToRootRot; Vector3 val2 = footstep.position - pivot; footstep.position = pivot + delta * val2; Vector3 val3 = footstep.stepFrom - pivot; footstep.stepFrom = pivot + delta * val3; Vector3 val4 = footstep.stepTo - pivot; footstep.stepTo = pivot + delta * val4; } } public void AddDeltaPosition(Vector3 delta) { //IL_0003: 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_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_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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) lastComPosition += delta; Footstep[] array = footsteps; foreach (Footstep footstep in array) { footstep.position += delta; footstep.stepFrom += delta; footstep.stepTo += delta; } } public void Solve(VirtualBone rootBone, Spine spine, Leg leftLeg, Leg rightLeg, Arm leftArm, Arm rightArm, int supportLegIndex, out Vector3 leftFootPosition, out Vector3 rightFootPosition, out Quaternion leftFootRotation, out Quaternion rightFootRotation, out float leftFootOffset, out float rightFootOffset, out float leftHeelOffset, out float rightHeelOffset, float scale) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_007e: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0122: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: 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_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0297: 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_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: 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_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0320: 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_0328: 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_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_079a: Unknown result type (might be due to invalid IL or missing references) //IL_079f: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07b3: Unknown result type (might be due to invalid IL or missing references) //IL_07bc: Unknown result type (might be due to invalid IL or missing references) //IL_07c7: 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_07cd: Unknown result type (might be due to invalid IL or missing references) //IL_07d2: Unknown result type (might be due to invalid IL or missing references) //IL_07db: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Unknown result type (might be due to invalid IL or missing references) //IL_07ed: Unknown result type (might be due to invalid IL or missing references) //IL_07f2: Unknown result type (might be due to invalid IL or missing references) //IL_0879: Unknown result type (might be due to invalid IL or missing references) //IL_087e: Unknown result type (might be due to invalid IL or missing references) //IL_088d: Unknown result type (might be due to invalid IL or missing references) //IL_0892: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_06fa: 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_070b: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Unknown result type (might be due to invalid IL or missing references) //IL_074a: Unknown result type (might be due to invalid IL or missing references) //IL_074c: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04af: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_05da: 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_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0593: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) //IL_05a3: 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) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_0575: Unknown result type (might be due to invalid IL or missing references) //IL_0687: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { leftFootPosition = Vector3.zero; rightFootPosition = Vector3.zero; leftFootRotation = Quaternion.identity; rightFootRotation = Quaternion.identity; leftFootOffset = 0f; rightFootOffset = 0f; leftHeelOffset = 0f; rightHeelOffset = 0f; return; } Vector3 val = rootBone.solverRotation * Vector3.up; Vector3 val2 = spine.pelvis.solverPosition + spine.pelvis.solverRotation * leftLeg.thighRelativeToPelvis; Vector3 val3 = spine.pelvis.solverPosition + spine.pelvis.solverRotation * rightLeg.thighRelativeToPelvis; footsteps[0].characterSpaceOffset = footDistance * Vector3.left * scale; footsteps[1].characterSpaceOffset = footDistance * Vector3.right * scale; Vector3 faceDirection = spine.faceDirection; Vector3 val4 = V3Tools.ExtractVertical(faceDirection, val, 1f); faceDirection -= val4; Quaternion val5 = Quaternion.LookRotation(faceDirection, val); if (spine.rootHeadingOffset != 0f) { val5 = Quaternion.AngleAxis(spine.rootHeadingOffset, val) * val5; } float num = 1f; float num2 = 1f; float num3 = 0.2f; float num4 = num + num2 + 2f * num3; centerOfMass = Vector3.zero; centerOfMass += spine.pelvis.solverPosition * num; centerOfMass += spine.head.solverPosition * num2; centerOfMass += leftArm.position * num3; centerOfMass += rightArm.position * num3; centerOfMass /= num4; centerOfMass += rootBone.solverRotation * offset; comVelocity = ((!(Time.deltaTime > 0f)) ? Vector3.zero : ((centerOfMass - lastComPosition) / Time.deltaTime)); lastComPosition = centerOfMass; comVelocity = Vector3.ClampMagnitude(comVelocity, maxVelocity) * velocityFactor * scale; Vector3 val6 = centerOfMass + comVelocity; Vector3 val7 = V3Tools.PointToPlane(spine.pelvis.solverPosition, rootBone.solverPosition, val); Vector3 val8 = V3Tools.PointToPlane(val6, rootBone.solverPosition, val); Vector3 val9 = Vector3.Lerp(footsteps[0].position, footsteps[1].position, 0.5f); Vector3 val10 = val6 - val9; float num5 = Vector3.Angle(val10, rootBone.solverRotation * Vector3.up) * comAngleMlp; for (int i = 0; i < footsteps.Length; i++) { footsteps[i].isSupportLeg = supportLegIndex == i; } for (int j = 0; j < footsteps.Length; j++) { if (footsteps[j].isStepping) { Vector3 val11 = val8 + rootBone.solverRotation * footsteps[j].characterSpaceOffset; if (!StepBlocked(footsteps[j].stepFrom, val11, rootBone.solverPosition)) { footsteps[j].UpdateStepping(val11, val5, 10f); } } else { footsteps[j].UpdateStanding(val5, relaxLegTwistMinAngle, relaxLegTwistSpeed); } } if (CanStep()) { int num6 = -1; float num7 = float.NegativeInfinity; for (int k = 0; k < footsteps.Length; k++) { if (footsteps[k].isStepping) { continue; } Vector3 val12 = val8 + rootBone.solverRotation * footsteps[k].characterSpaceOffset; float num8 = ((k != 0) ? rightLeg.mag : leftLeg.mag); Vector3 val13 = ((k != 0) ? val3 : val2); float num9 = Vector3.Distance(footsteps[k].position, val13); bool flag = false; if (num9 >= num8 * maxLegStretch) { val12 = val7 + rootBone.solverRotation * footsteps[k].characterSpaceOffset; flag = true; } bool flag2 = false; for (int l = 0; l < footsteps.Length; l++) { if (l == k || flag) { continue; } if (Vector3.Distance(footsteps[k].position, footsteps[l].position) < 0.25f * scale) { Vector3 val14 = footsteps[k].position - val12; float sqrMagnitude = ((Vector3)(ref val14)).sqrMagnitude; Vector3 val15 = footsteps[l].position - val12; if (sqrMagnitude < ((Vector3)(ref val15)).sqrMagnitude) { goto IL_05b7; } } flag2 = GetLineSphereCollision(footsteps[k].position, val12, footsteps[l].position, 0.25f * scale); goto IL_05b7; IL_05b7: if (flag2) { break; } } float num10 = Quaternion.Angle(val5, footsteps[k].stepToRootRot); if (flag2 && !(num10 > angleThreshold)) { continue; } float num11 = Vector3.Distance(footsteps[k].position, val12); float num12 = stepThreshold * scale; if (footsteps[k].relaxFlag) { num12 = 0f; } float num13 = Mathf.Lerp(num12, num12 * 0.1f, num5 * 0.015f); if (flag) { num13 *= 0.5f; } if (k == 0) { num13 *= 0.9f; } if (!StepBlocked(footsteps[k].position, val12, rootBone.solverPosition) && (num11 > num13 || num10 > angleThreshold)) { float num14 = 0f; num14 -= num11; if (num14 > num7) { num6 = k; num7 = num14; } } } if (num6 != -1) { Vector3 p = val8 + rootBone.solverRotation * footsteps[num6].characterSpaceOffset; footsteps[num6].stepSpeed = Random.Range(stepSpeed, stepSpeed * 1.5f); footsteps[num6].StepTo(p, val5, stepThreshold * scale); } } footsteps[0].Update(stepInterpolation, onLeftFootstep); footsteps[1].Update(stepInterpolation, onRightFootstep); leftFootPosition = footsteps[0].position; rightFootPosition = footsteps[1].position; leftFootPosition = V3Tools.PointToPlane(leftFootPosition, leftLeg.lastBone.readPosition, val); rightFootPosition = V3Tools.PointToPlane(rightFootPosition, rightLeg.lastBone.readPosition, val); leftFootOffset = stepHeight.Evaluate(footsteps[0].stepProgress) * scale; rightFootOffset = stepHeight.Evaluate(footsteps[1].stepProgress) * scale; leftHeelOffset = heelHeight.Evaluate(footsteps[0].stepProgress) * scale; rightHeelOffset = heelHeight.Evaluate(footsteps[1].stepProgress) * scale; leftFootRotation = footsteps[0].rotation; rightFootRotation = footsteps[1].rotation; } private bool StepBlocked(Vector3 fromPosition, Vector3 toPosition, Vector3 rootPosition) { //IL_0002: 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_0025: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0073: Unknown result type (might be due to invalid IL or missing references) if (LayerMask.op_Implicit(blockingLayers) == -1 || !blockingEnabled) { return false; } Vector3 val = fromPosition; val.y = rootPosition.y + raycastHeight + raycastRadius; Vector3 val2 = toPosition - val; val2.y = 0f; RaycastHit val3 = default(RaycastHit); if (raycastRadius <= 0f) { return Physics.Raycast(val, val2, ref val3, ((Vector3)(ref val2)).magnitude, LayerMask.op_Implicit(blockingLayers)); } return Physics.SphereCast(val, raycastRadius, val2, ref val3, ((Vector3)(ref val2)).magnitude, LayerMask.op_Implicit(blockingLayers)); } private bool CanStep() { Footstep[] array = footsteps; foreach (Footstep footstep in array) { if (footstep.isStepping && footstep.stepProgress < 0.8f) { return false; } } return true; } private static bool GetLineSphereCollision(Vector3 lineStart, Vector3 lineEnd, Vector3 sphereCenter, float sphereRadius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0033: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) Vector3 val = lineEnd - lineStart; Vector3 val2 = sphereCenter - lineStart; float magnitude = ((Vector3)(ref val2)).magnitude; float num = magnitude - sphereRadius; if (num > ((Vector3)(ref val)).magnitude) { return false; } Quaternion val3 = Quaternion.LookRotation(val, val2); Vector3 val4 = Quaternion.Inverse(val3) * val2; if (val4.z < 0f) { return num < 0f; } return val4.y - sphereRadius < 0f; } } [Serializable] public class Spine : BodyPart { [Tooltip("The head target. This should not be the camera Transform itself, but a child GameObject parented to it so you could adjust it's position/rotation to match the orientation of the head bone. The best practice for setup would be to move the camera to the avatar's eyes, duplicate the avatar's head bone and parent it to the camera. Then assign the duplicate to this slot.")] public Transform headTarget; [Tooltip("The pelvis target (optional), useful for seated rigs or if you had an additional tracker on the backpack or belt are. The best practice for setup would be to duplicate the avatar's pelvis bone and parenting it to the pelvis tracker. Then assign the duplicate to this slot.")] public Transform pelvisTarget; [Tooltip("Positional weight of the head target. Note that if you have nulled the headTarget, the head will still be pulled to the last position of the headTarget until you set this value to 0.")] [Range(0f, 1f)] public float positionWeight = 1f; [Tooltip("Rotational weight of the head target. Note that if you have nulled the headTarget, the head will still be rotated to the last rotation of the headTarget until you set this value to 0.")] [Range(0f, 1f)] public float rotationWeight = 1f; [Tooltip("Positional weight of the pelvis target. Note that if you have nulled the pelvisTarget, the pelvis will still be pulled to the last position of the pelvisTarget until you set this value to 0.")] [Range(0f, 1f)] public float pelvisPositionWeight; [Tooltip("Rotational weight of the pelvis target. Note that if you have nulled the pelvisTarget, the pelvis will still be rotated to the last rotation of the pelvisTarget until you set this value to 0.")] [Range(0f, 1f)] public float pelvisRotationWeight; [Tooltip("If 'Chest Goal Weight' is greater than 0, the chest will be turned towards this Transform.")] public Transform chestGoal; [Tooltip("Weight of turning the chest towards the 'Chest Goal'.")] [Range(0f, 1f)] public float chestGoalWeight; [Tooltip("Minimum height of the head from the root of the character.")] public float minHeadHeight = 0.8f; [Tooltip("Determines how much the body will follow the position of the head.")] [Range(0f, 1f)] public float bodyPosStiffness = 0.55f; [Tooltip("Determines how much the body will follow the rotation of the head.")] [Range(0f, 1f)] public float bodyRotStiffness = 0.1f; [Tooltip("Determines how much the chest will rotate to the rotation of the head.")] [FormerlySerializedAs("chestRotationWeight")] [Range(0f, 1f)] public float neckStiffness = 0.2f; [Tooltip("The amount of rotation applied to the chest based on hand positions.")] [Range(0f, 1f)] public float rotateChestByHands = 1f; [Tooltip("Clamps chest rotation. Value of 0.5 allows 90 degrees of rotation for the chest relative to the head. Value of 0 allows 180 degrees and value of 1 means the chest will be locked relative to the head.")] [Range(0f, 1f)] public float chestClampWeight = 0.5f; [Tooltip("Clamps head rotation. Value of 0.5 allows 90 degrees of rotation for the head relative to the headTarget. Value of 0 allows 180 degrees and value of 1 means head rotation will be locked to the target.")] [Range(0f, 1f)] public float headClampWeight = 0.6f; [Tooltip("Moves the body horizontally along -character.forward axis by that value when the player is crouching.")] public float moveBodyBackWhenCrouching = 0.5f; [Tooltip("How much will the pelvis maintain it's animated position?")] [Range(0f, 1f)] public float maintainPelvisPosition = 0.2f; [Tooltip("Will automatically rotate the root of the character if the head target has turned past this angle.")] [Range(0f, 180f)] public float maxRootAngle = 25f; [Tooltip("Angular offset for root heading. Adjust this value to turn the root relative to the HMD around the vertical axis. Usefulf for fighting or shooting games where you would sometimes want the avatar to stand at an angled stance.")] [Range(-180f, 180f)] public float rootHeadingOffset; [NonSerialized] [HideInInspector] public Vector3 IKPositionHead; [NonSerialized] [HideInInspector] public Quaternion IKRotationHead = Quaternion.identity; [NonSerialized] [HideInInspector] public Vector3 IKPositionPelvis; [NonSerialized] [HideInInspector] public Quaternion IKRotationPelvis = Quaternion.identity; [NonSerialized] [HideInInspector] public Vector3 goalPositionChest; [NonSerialized] [HideInInspector] public Vector3 pelvisPositionOffset; [NonSerialized] [HideInInspector] public Vector3 chestPositionOffset; [NonSerialized] [HideInInspector] public Vector3 headPositionOffset; [NonSerialized] [HideInInspector] public Quaternion pelvisRotationOffset = Quaternion.identity; [NonSerialized] [HideInInspector] public Quaternion chestRotationOffset = Quaternion.identity; [NonSerialized] [HideInInspector] public Quaternion headRotationOffset = Quaternion.identity; [NonSerialized] [HideInInspector] public Vector3 faceDirection; [NonSerialized] [HideInInspector] public Vector3 locomotionHeadPositionOffset; [NonSerialized] [HideInInspector] public Vector3 headPosition; private Quaternion headRotation = Quaternion.identity; private Quaternion pelvisRotation = Quaternion.identity; private Quaternion anchorRelativeToPelvis = Quaternion.identity; private Quaternion pelvisRelativeRotation = Quaternion.identity; private Quaternion chestRelativeRotation = Quaternion.identity; private Vector3 headDeltaPosition; private Quaternion pelvisDeltaRotation = Quaternion.identity; private Quaternion chestTargetRotation = Quaternion.identity; private int pelvisIndex = 0; private int spineIndex = 1; private int chestIndex = -1; private int neckIndex = -1; private int headIndex = -1; private float length; private bool hasChest; private bool hasNeck; private bool hasLegs; private float headHeight; private float sizeMlp; private Vector3 chestForward; public VirtualBone pelvis => bones[pelvisIndex]; public VirtualBone firstSpineBone => bones[spineIndex]; public VirtualBone chest { get { if (hasChest) { return bones[chestIndex]; } return bones[spineIndex]; } } private VirtualBone neck => bones[neckIndex]; public VirtualBone head => bones[headIndex]; public Quaternion anchorRotation { get; private set; } public Quaternion anchorRelativeToHead { get; private set; } protected override void OnRead(Vector3[] positions, Quaternion[] rotations, bool hasChest, bool hasNeck, bool hasShoulders, bool hasToes, bool hasLegs, int rootIndex, int index) { //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_0017: 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_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_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: 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_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: 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_0303: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: 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_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0395: 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_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: 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_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0241: 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_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: 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_02a9: 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_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) Vector3 val = positions[index]; Quaternion val2 = rotations[index]; Vector3 val3 = positions[index + 1]; Quaternion val4 = rotations[index + 1]; Vector3 val5 = positions[index + 2]; Quaternion val6 = rotations[index + 2]; Vector3 position = positions[index + 3]; Quaternion rotation = rotations[index + 3]; Vector3 val7 = positions[index + 4]; Quaternion val8 = rotations[index + 4]; this.hasLegs = hasLegs; if (!hasChest) { val5 = val3; val6 = val4; } if (!initiated) { this.hasChest = hasChest; this.hasNeck = hasNeck; Vector3 val9 = V3Tools.ExtractVertical(val7 - positions[0], rotations[0] * Vector3.up, 1f); headHeight = ((Vector3)(ref val9)).magnitude; int num = 3; if (hasChest) { num++; } if (hasNeck) { num++; } bones = new VirtualBone[num]; chestIndex = ((!hasChest) ? 1 : 2); neckIndex = 1; if (hasChest) { neckIndex++; } if (hasNeck) { neckIndex++; } headIndex = 2; if (hasChest) { headIndex++; } if (hasNeck) { headIndex++; } bones[0] = new VirtualBone(val, val2); bones[1] = new VirtualBone(val3, val4); if (hasChest) { bones[chestIndex] = new VirtualBone(val5, val6); } if (hasNeck) { bones[neckIndex] = new VirtualBone(position, rotation); } bones[headIndex] = new VirtualBone(val7, val8); pelvisRotationOffset = Quaternion.identity; chestRotationOffset = Quaternion.identity; headRotationOffset = Quaternion.identity; anchorRelativeToHead = Quaternion.Inverse(val8) * rotations[0]; anchorRelativeToPelvis = Quaternion.Inverse(val2) * rotations[0]; faceDirection = rotations[0] * Vector3.forward; IKPositionHead = val7; IKRotationHead = val8; IKPositionPelvis = val; IKRotationPelvis = val2; goalPositionChest = val5 + rotations[0] * Vector3.forward; } pelvisRelativeRotation = Quaternion.Inverse(val8) * val2; chestRelativeRotation = Quaternion.Inverse(val8) * val6; chestForward = Quaternion.Inverse(val6) * (rotations[0] * Vector3.forward); bones[0].Read(val, val2); bones[1].Read(val3, val4); if (hasChest) { bones[chestIndex].Read(val5, val6); } if (hasNeck) { bones[neckIndex].Read(position, rotation); } bones[headIndex].Read(val7, val8); float num2 = Vector3.Distance(val, val7); sizeMlp = num2 / 0.7f; } public override void PreSolve() { //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_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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)headTarget != (Object)null) { IKPositionHead = headTarget.position; IKRotationHead = headTarget.rotation; } if ((Object)(object)chestGoal != (Object)null) { goalPositionChest = chestGoal.position; } if ((Object)(object)pelvisTarget != (Object)null) { IKPositionPelvis = pelvisTarget.position; IKRotationPelvis = pelvisTarget.rotation; } headPosition = V3Tools.Lerp(head.solverPosition, IKPositionHead, positionWeight); headRotation = QuaTools.Lerp(head.solverRotation, IKRotationHead, rotationWeight); pelvisRotation = QuaTools.Lerp(pelvis.solverRotation, IKRotationPelvis, rotationWeight); } public override void ApplyOffsets(float scale) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0032: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f1: 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_00f8: 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_00c0: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) headPosition += headPositionOffset; float num = minHeadHeight * scale; Vector3 val = rootRotation * Vector3.up; if (val == Vector3.up) { headPosition.y = Math.Max(rootPosition.y + num, headPosition.y); } else { Vector3 val2 = headPosition - rootPosition; Vector3 val3 = V3Tools.ExtractHorizontal(val2, val, 1f); Vector3 val4 = val2 - val3; float num2 = Vector3.Dot(val4, val); if (num2 > 0f) { if (((Vector3)(ref val4)).magnitude < num) { val4 = ((Vector3)(ref val4)).normalized * num; } } else { val4 = -((Vector3)(ref val4)).normalized * num; } headPosition = rootPosition + val3 + val4; } headRotation = headRotationOffset * headRotation; headDeltaPosition = headPosition - head.solverPosition; pelvisDeltaRotation = QuaTools.FromToRotation(pelvis.solverRotation, headRotation * pelvisRelativeRotation); if (pelvisRotationWeight <= 0f) { anchorRotation = headRotation * anchorRelativeToHead; } else if (pelvisRotationWeight > 0f && pelvisRotationWeight < 1f) { anchorRotation = Quaternion.Lerp(headRotation * anchorRelativeToHead, pelvisRotation * anchorRelativeToPelvis, pelvisRotationWeight); } else if (pelvisRotationWeight >= 1f) { anchorRotation = pelvisRotation * anchorRelativeToPelvis; } } private void CalculateChestTargetRotation(VirtualBone rootBone, Arm[] arms) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) chestTargetRotation = headRotation * chestRelativeRotation; AdjustChestByHands(ref chestTargetRotation, arms); faceDirection = Vector3.Cross(anchorRotation * Vector3.right, rootBone.readRotation * Vector3.up) + anchorRotation * Vector3.forward; } public void Solve(VirtualBone rootBone, Leg[] legs, Arm[] arms, float scale) { //IL_00cf: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0100: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0212: 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_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) CalculateChestTargetRotation(rootBone, arms); if (maxRootAngle < 180f) { Vector3 val = faceDirection; if (rootHeadingOffset != 0f) { val = Quaternion.AngleAxis(rootHeadingOffset, Vector3.up) * val; } Vector3 val2 = Quaternion.Inverse(rootBone.solverRotation) * val; float num = Mathf.Atan2(val2.x, val2.z) * 57.29578f; float num2 = 0f; float num3 = maxRootAngle; if (num > num3) { num2 = num - num3; } if (num < 0f - num3) { num2 = num + num3; } rootBone.solverRotation = Quaternion.AngleAxis(num2, rootBone.readRotation * Vector3.up) * rootBone.solverRotation; } Vector3 solverPosition = pelvis.solverPosition; Vector3 rootUp = rootBone.solverRotation * Vector3.up; TranslatePelvis(legs, headDeltaPosition, pelvisDeltaRotation, scale); FABRIKPass(solverPosition, rootUp, positionWeight); Bend(bones, pelvisIndex, chestIndex, chestTargetRotation, chestRotationOffset, chestClampWeight, uniformWeight: false, neckStiffness * rotationWeight); if (LOD < 1 && chestGoalWeight > 0f) { Quaternion targetRotation = Quaternion.FromToRotation(bones[chestIndex].solverRotation * chestForward, goalPositionChest - bones[chestIndex].solverPosition) * bones[chestIndex].solverRotation; Bend(bones, pelvisIndex, chestIndex, targetRotation, chestRotationOffset, chestClampWeight, uniformWeight: false, chestGoalWeight * rotationWeight); } InverseTranslateToHead(legs, limited: false, useCurrentLegMag: false, Vector3.zero, positionWeight); if (LOD < 1) { FABRIKPass(solverPosition, rootUp, positionWeight); } Bend(bones, neckIndex, headIndex, headRotation, headClampWeight, uniformWeight: true, rotationWeight); SolvePelvis(); } private void FABRIKPass(Vector3 animatedPelvisPos, Vector3 rootUp, float weight) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0075: Unknown result type (might be due to invalid IL or missing references) Vector3 startPosition = Vector3.Lerp(pelvis.solverPosition, animatedPelvisPos, maintainPelvisPosition) + pelvisPositionOffset; Vector3 targetPosition = headPosition - chestPositionOffset; Vector3 zero = Vector3.zero; float num = Vector3.Distance(bones[0].solverPosition, bones[bones.Length - 1].solverPosition); VirtualBone.SolveFABRIK(bones, startPosition, targetPosition, weight, 1f, 1, num, zero); } private void SolvePelvis() { //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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) if (pelvisPositionWeight > 0f) { Quaternion solverRotation = head.solverRotation; Vector3 val = (IKPositionPelvis + pelvisPositionOffset - pelvis.solverPosition) * pelvisPositionWeight; VirtualBone[] array = bones; foreach (VirtualBone virtualBone in array) { virtualBone.solverPosition += val; } Vector3 bendNormal = anchorRotation * Vector3.right; if (hasChest && hasNeck) { VirtualBone.SolveTrigonometric(bones, spineIndex, chestIndex, headIndex, headPosition, bendNormal, pelvisPositionWeight * 0.9f); VirtualBone.SolveTrigonometric(bones, chestIndex, neckIndex, headIndex, headPosition, bendNormal, pelvisPositionWeight); } else if (hasChest && !hasNeck) { VirtualBone.SolveTrigonometric(bones, spineIndex, chestIndex, headIndex, headPosition, bendNormal, pelvisPositionWeight); } else if (!hasChest && hasNeck) { VirtualBone.SolveTrigonometric(bones, spineIndex, neckIndex, headIndex, headPosition, bendNormal, pelvisPositionWeight); } else if (!hasNeck && !hasChest) { VirtualBone.SolveTrigonometric(bones, pelvisIndex, spineIndex, headIndex, headPosition, bendNormal, pelvisPositionWeight); } head.solverRotation = solverRotation; } } public override void Write(ref Vector3[] solvedPositions, ref Quaternion[] solvedRotations) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) ref Vector3 reference = ref solvedPositions[index]; reference = bones[0].solverPosition; ref Quaternion reference2 = ref solvedRotations[index]; reference2 = bones[0].solverRotation; ref Quaternion reference3 = ref solvedRotations[index + 1]; reference3 = bones[1].solverRotation; if (hasChest) { ref Quaternion reference4 = ref solvedRotations[index + 2]; reference4 = bones[chestIndex].solverRotation; } if (hasNeck) { ref Quaternion reference5 = ref solvedRotations[index + 3]; reference5 = bones[neckIndex].solverRotation; } ref Quaternion reference6 = ref solvedRotations[index + 4]; reference6 = bones[headIndex].solverRotation; } public override void ResetOffsets() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) pelvisPositionOffset = Vector3.zero; chestPositionOffset = Vector3.zero; headPositionOffset = locomotionHeadPositionOffset; pelvisRotationOffset = Quaternion.identity; chestRotationOffset = Quaternion.identity; headRotationOffset = Quaternion.identity; } private void AdjustChestByHands(ref Quaternion chestTargetRotation, Arm[] arms) { //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_001d: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0043: 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_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_0057: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_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_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) if (LOD <= 0) { Quaternion val = Quaternion.Inverse(anchorRotation); Vector3 val2 = val * (arms[0].position - headPosition) / sizeMlp; Vector3 val3 = val * (arms[1].position - headPosition) / sizeMlp; Vector3 forward = Vector3.forward; forward.x += val2.x * Mathf.Abs(val2.x); forward.x += val2.z * Mathf.Abs(val2.z); forward.x += val3.x * Mathf.Abs(val3.x); forward.x -= val3.z * Mathf.Abs(val3.z); forward.x *= 5f * rotateChestByHands; float num = Mathf.Atan2(forward.x, forward.z) * 57.29578f; Quaternion val4 = Quaternion.AngleAxis(num, rootRotation * Vector3.up); chestTargetRotation = val4 * chestTargetRotation; Vector3 up = Vector3.up; up.x += val2.y; up.x -= val3.y; up.x *= 0.5f * rotateChestByHands; num = Mathf.Atan2(up.x, up.y) * 57.29578f; val4 = Quaternion.AngleAxis(num, rootRotation * Vector3.back); chestTargetRotation = val4 * chestTargetRotation; } } public void InverseTranslateToHead(Leg[] legs, bool limited, bool useCurrentLegMag, Vector3 offset, float w) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0044: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (headPosition + offset - head.solverPosition) * w; Vector3 val2 = pelvis.solverPosition + val; MovePosition((!limited) ? val2 : LimitPelvisPosition(legs, val2, useCurrentLegMag)); } private void TranslatePelvis(Leg[] legs, Vector3 deltaPosition, Quaternion deltaRotation, float scale) { //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_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_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) //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_0035: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_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_0070: 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_007b: 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_0087: 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_0092: 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_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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_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_0112: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) Vector3 solverPosition = head.solverPosition; deltaRotation = QuaTools.ClampRotation(deltaRotation, chestClampWeight, 2); Quaternion val = Quaternion.Slerp(Quaternion.identity, deltaRotation, bodyRotStiffness * rotationWeight); val = Quaternion.Slerp(val, QuaTools.FromToRotation(pelvis.solverRotation, IKRotationPelvis), pelvisRotationWeight); VirtualBone.RotateAroundPoint(bones, 0, pelvis.solverPosition, pelvisRotationOffset * val); deltaPosition -= head.solverPosition - solverPosition; Vector3 val2 = rootRotation * Vector3.forward; Vector3 val3 = V3Tools.ExtractVertical(deltaPosition, rootRotation * Vector3.up, 1f); float num = ((Vector3)(ref val3)).magnitude; if (scale > 0f) { num /= scale; } float num2 = num * (0f - moveBodyBackWhenCrouching) * headHeight; deltaPosition += val2 * num2; MovePosition(LimitPelvisPosition(legs, pelvis.solverPosition + deltaPosition * bodyPosStiffness * positionWeight, useCurrentLegMag: false)); } private Vector3 LimitPelvisPosition(Leg[] legs, Vector3 pelvisPosition, bool useCurrentLegMag, int it = 2) { //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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) if (!hasLegs) { return pelvisPosition; } if (useCurrentLegMag) { foreach (Leg leg in legs) { leg.currentMag = Vector3.Distance(leg.thigh.solverPosition, leg.lastBone.solverPosition); } } for (int j = 0; j < it; j++) { foreach (Leg leg2 in legs) { Vector3 val = pelvisPosition - pelvis.solverPosition; Vector3 val2 = leg2.thigh.solverPosition + val; Vector3 val3 = val2 - leg2.position; float num = ((!useCurrentLegMag) ? leg2.mag : leg2.currentMag); Vector3 val4 = leg2.position + Vector3.ClampMagnitude(val3, num); pelvisPosition += val4 - val2; } } return pelvisPosition; } private void Bend(VirtualBone[] bones, int firstIndex, int lastIndex, Quaternion targetRotation, float clampWeight, bool uniformWeight, float w) { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (w <= 0f || bones.Length == 0) { return; } int num = lastIndex + 1 - firstIndex; if (num < 1) { return; } Quaternion rotation = QuaTools.FromToRotation(bones[lastIndex].solverRotation, targetRotation); rotation = QuaTools.ClampRotation(rotation, clampWeight, 2); float num2 = ((!uniformWeight) ? 0f : (1f / (float)num)); for (int i = firstIndex; i < lastIndex + 1; i++) { if (!uniformWeight) { num2 = Mathf.Clamp((float)((i - firstIndex + 1) / num), 0f, 1f); } VirtualBone.RotateAroundPoint(bones, i, bones[i].solverPosition, Quaternion.Slerp(Quaternion.identity, rotation, num2 * w)); } } private void Bend(VirtualBone[] bones, int firstIndex, int lastIndex, Quaternion targetRotation, Quaternion rotationOffset, float clampWeight, bool uniformWeight, float w) { //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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) if (w <= 0f || bones.Length == 0) { return; } int num = lastIndex + 1 - firstIndex; if (num < 1) { return; } Quaternion rotation = QuaTools.FromToRotation(bones[lastIndex].solverRotation, targetRotation); rotation = QuaTools.ClampRotation(rotation, clampWeight, 2); float num2 = ((!uniformWeight) ? 0f : (1f / (float)num)); for (int i = firstIndex; i < lastIndex + 1; i++) { if (!uniformWeight) { if (num == 1) { num2 = 1f; } else if (num == 2) { num2 = ((i != 0) ? 0.8f : 0.2f); } else if (num == 3) { num2 = i switch { 0 => 0.15f, 1 => 0.4f, _ => 0.45f, }; } else if (num > 3) { num2 = 1f / (float)num; } } VirtualBone.RotateAroundPoint(bones, i, bones[i].solverPosition, Quaternion.Slerp(Quaternion.Slerp(Quaternion.identity, rotationOffset, num2), rotation, num2 * w)); } } } [Serializable] public enum PositionOffset { Pelvis, Chest, Head, LeftHand, RightHand, LeftFoot, RightFoot, LeftHeel, RightHeel } [Serializable] public enum RotationOffset { Pelvis, Chest, Head } [Serializable] public class VirtualBone { public Vector3 readPosition; public Quaternion readRotation; public Vector3 solverPosition; public Quaternion solverRotation; public float length; public float sqrMag; public Vector3 axis; public VirtualBone(Vector3 position, Quaternion rotation) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Read(position, rotation); } public void Read(Vector3 position, Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0011: 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) readPosition = position; readRotation = rotation; solverPosition = position; solverRotation = rotation; } public static void SwingRotation(VirtualBone[] bones, int index, Vector3 swingTarget, float weight = 1f) { //IL_0014: 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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_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_004c: 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_005d: 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_0066: 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) if (!(weight <= 0f)) { Quaternion val = Quaternion.FromToRotation(bones[index].solverRotation * bones[index].axis, swingTarget - bones[index].solverPosition); if (weight < 1f) { val = Quaternion.Lerp(Quaternion.identity, val, weight); } for (int i = index; i < bones.Length; i++) { bones[i].solverRotation = val * bones[i].solverRotation; } } } public static float PreSolve(ref VirtualBone[] bones) { //IL_0026: 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_0039: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) float num = 0f; for (int i = 0; i < bones.Length; i++) { if (i < bones.Length - 1) { VirtualBone obj = bones[i]; Vector3 val = bones[i + 1].solverPosition - bones[i].solverPosition; obj.sqrMag = ((Vector3)(ref val)).sqrMagnitude; bones[i].length = Mathf.Sqrt(bones[i].sqrMag); num += bones[i].length; bones[i].axis = Quaternion.Inverse(bones[i].solverRotation) * (bones[i + 1].solverPosition - bones[i].solverPosition); } else { bones[i].sqrMag = 0f; bones[i].length = 0f; } } return num; } public static void RotateAroundPoint(VirtualBone[] bones, int index, Vector3 point, Quaternion rotation) { //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_0020: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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) for (int i = index; i < bones.Length; i++) { if (bones[i] != null) { Vector3 val = bones[i].solverPosition - point; bones[i].solverPosition = point + rotation * val; bones[i].solverRotation = rotation * bones[i].solverRotation; } } } public static void RotateBy(VirtualBone[] bones, int index, Quaternion rotation) { //IL_0015: 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_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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0055: Unknown result type (might be due to invalid IL or missing references) for (int i = index; i < bones.Length; i++) { if (bones[i] != null) { Vector3 val = bones[i].solverPosition - bones[index].solverPosition; bones[i].solverPosition = bones[index].solverPosition + rotation * val; bones[i].solverRotation = rotation * bones[i].solverRotation; } } } public static void RotateBy(VirtualBone[] bones, Quaternion rotation) { //IL_0050: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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) for (int i = 0; i < bones.Length; i++) { if (bones[i] != null) { if (i > 0) { Vector3 val = bones[i].solverPosition - bones[0].solverPosition; bones[i].solverPosition = bones[0].solverPosition + rotation * val; } bones[i].solverRotation = rotation * bones[i].solverRotation; } } } public static void RotateTo(VirtualBone[] bones, int index, Quaternion rotation) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_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) Quaternion rotation2 = QuaTools.FromToRotation(bones[index].solverRotation, rotation); RotateAroundPoint(bones, index, bones[index].solverPosition, rotation2); } public static void SolveTrigonometric(VirtualBone[] bones, int first, int second, int third, Vector3 targetPosition, Vector3 bendNormal, float weight) { //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_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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return; } targetPosition = Vector3.Lerp(bones[third].solverPosition, targetPosition, weight); Vector3 val = targetPosition - bones[first].solverPosition; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude != 0f) { float directionMag = Mathf.Sqrt(sqrMagnitude); Vector3 val2 = bones[second].solverPosition - bones[first].solverPosition; float sqrMagnitude2 = ((Vector3)(ref val2)).sqrMagnitude; Vector3 val3 = bones[third].solverPosition - bones[second].solverPosition; float sqrMagnitude3 = ((Vector3)(ref val3)).sqrMagnitude; Vector3 bendDirection = Vector3.Cross(val, bendNormal); Vector3 directionToBendPoint = GetDirectionToBendPoint(val, directionMag, bendDirection, sqrMagnitude2, sqrMagnitude3); Quaternion val4 = Quaternion.FromToRotation(bones[second].solverPosition - bones[first].solverPosition, directionToBendPoint); if (weight < 1f) { val4 = Quaternion.Lerp(Quaternion.identity, val4, weight); } RotateAroundPoint(bones, first, bones[first].solverPosition, val4); Quaternion val5 = Quaternion.FromToRotation(bones[third].solverPosition - bones[second].solverPosition, targetPosition - bones[second].solverPosition); if (weight < 1f) { val5 = Quaternion.Lerp(Quaternion.identity, val5, weight); } RotateAroundPoint(bones, second, bones[second].solverPosition, val5); } } private static Vector3 GetDirectionToBendPoint(Vector3 direction, float directionMag, Vector3 bendDirection, float sqrMag1, float sqrMag2) { //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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) float num = (directionMag * directionMag + (sqrMag1 - sqrMag2)) / 2f / directionMag; float num2 = (float)Math.Sqrt(Mathf.Clamp(sqrMag1 - num * num, 0f, float.PositiveInfinity)); if (direction == Vector3.zero) { return Vector3.zero; } return Quaternion.LookRotation(direction, bendDirection) * new Vector3(0f, num2, num); } public static void SolveFABRIK(VirtualBone[] bones, Vector3 startPosition, Vector3 targetPosition, float weight, float minNormalizedTargetDistance, int iterations, float length, Vector3 startOffset) { //IL_001e: 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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_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_0174: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return; } if (minNormalizedTargetDistance > 0f) { Vector3 val = targetPosition - startPosition; float magnitude = ((Vector3)(ref val)).magnitude; Vector3 val2 = startPosition + val / magnitude * Mathf.Max(length * minNormalizedTargetDistance, magnitude); targetPosition = Vector3.Lerp(targetPosition, val2, weight); } for (int i = 0; i < iterations; i++) { bones[^1].solverPosition = Vector3.Lerp(bones[^1].solverPosition, targetPosition, weight); for (int num = bones.Length - 2; num > -1; num--) { bones[num].solverPosition = SolveFABRIKJoint(bones[num].solverPosition, bones[num + 1].solverPosition, bones[num].length); } if (i == 0) { foreach (VirtualBone virtualBone in bones) { virtualBone.solverPosition += startOffset; } } bones[0].solverPosition = startPosition; for (int k = 1; k < bones.Length; k++) { bones[k].solverPosition = SolveFABRIKJoint(bones[k].solverPosition, bones[k - 1].solverPosition, bones[k - 1].length); } } for (int l = 0; l < bones.Length - 1; l++) { SwingRotation(bones, l, bones[l + 1].solverPosition); } } private static Vector3 SolveFABRIKJoint(Vector3 pos1, Vector3 pos2, float length) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) Vector3 val = pos1 - pos2; return pos2 + ((Vector3)(ref val)).normalized * length; } public static void SolveCCD(VirtualBone[] bones, Vector3 targetPosition, float weight, int iterations) { //IL_002c: 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_003f: 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_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) //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_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_007d: 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) if (weight <= 0f) { return; } for (int i = 0; i < iterations; i++) { for (int num = bones.Length - 2; num > -1; num--) { Vector3 val = bones[^1].solverPosition - bones[num].solverPosition; Vector3 val2 = targetPosition - bones[num].solverPosition; Quaternion val3 = Quaternion.FromToRotation(val, val2); if (weight >= 1f) { RotateBy(bones, num, val3); } else { RotateBy(bones, num, Quaternion.Lerp(Quaternion.identity, val3, weight)); } } } } } private Transform[] solverTransforms = (Transform[])(object)new Transform[0]; private bool hasChest; private bool hasNeck; private bool hasShoulders; private bool hasToes; private bool hasLegs; private Vector3[] readPositions = (Vector3[])(object)new Vector3[0]; private Quaternion[] readRotations = (Quaternion[])(object)new Quaternion[0]; private Vector3[] solvedPositions = (Vector3[])(object)new Vector3[22]; private Quaternion[] solvedRotations = (Quaternion[])(object)new Quaternion[22]; private Quaternion[] defaultLocalRotations = (Quaternion[])(object)new Quaternion[21]; private Vector3[] defaultLocalPositions = (Vector3[])(object)new Vector3[21]; private Vector3 rootV; private Vector3 rootVelocity; private Vector3 bodyOffset; private int supportLegIndex; private int lastLOD; [Tooltip("LOD 0: Full quality solving. LOD 1: Shoulder solving, stretching plant feet disabled, spine solving quality reduced. This provides about 30% of performance gain. LOD 2: Culled, but updating root position and rotation if locomotion is enabled.")] [Range(0f, 2f)] public int LOD = 0; [Tooltip("Scale of the character. Value of 1 means normal adult human size.")] public float scale = 1f; [Tooltip("If true, will keep the toes planted even if head target is out of reach, so this can cause the camera to exit the head if it is too high for the model to reach. Enabling this increases the cost of the solver as the legs will have to be solved multiple times.")] public bool plantFeet = true; [Tooltip("The spine solver.")] public Spine spine = new Spine(); [Tooltip("The left arm solver.")] public Arm leftArm = new Arm(); [Tooltip("The right arm solver.")] public Arm rightArm = new Arm(); [Tooltip("The left leg solver.")] public Leg leftLeg = new Leg(); [Tooltip("The right leg solver.")] public Leg rightLeg = new Leg(); [Tooltip("Procedural leg shuffling for stationary VR games. Not designed for roomscale and thumbstick locomotion. For those it would be better to use a strafing locomotion blend tree to make the character follow the horizontal direction towards the HMD by root motion or script.")] public Locomotion locomotion = new Locomotion(); private Leg[] legs = new Leg[2]; private Arm[] arms = new Arm[2]; private Vector3 headPosition; private Vector3 headDeltaPosition; private Vector3 raycastOriginPelvis; private Vector3 lastOffset; private Vector3 debugPos1; private Vector3 debugPos2; private Vector3 debugPos3; private Vector3 debugPos4; [HideInInspector] public VirtualBone rootBone { get; private set; } public void SetToReferences(VRIK.References references) { if (!references.isFilled) { Debug.LogError((object)"Invalid references, one or more Transforms are missing."); return; } solverTransforms = references.GetTransforms(); hasChest = (Object)(object)solverTransforms[3] != (Object)null; hasNeck = (Object)(object)solverTransforms[4] != (Object)null; hasShoulders = (Object)(object)solverTransforms[6] != (Object)null && (Object)(object)solverTransforms[10] != (Object)null; hasToes = (Object)(object)solverTransforms[17] != (Object)null && (Object)(object)solverTransforms[21] != (Object)null; hasLegs = (Object)(object)solverTransforms[14] != (Object)null; readPositions = (Vector3[])(object)new Vector3[solverTransforms.Length]; readRotations = (Quaternion[])(object)new Quaternion[solverTransforms.Length]; DefaultAnimationCurves(); GuessHandOrientations(references, onlyIfZero: true); } public void GuessHandOrientations(VRIK.References references, bool onlyIfZero) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) if (!references.isFilled) { Debug.LogWarning((object)"VRIK References are not filled in, can not guess hand orientations. Right-click on VRIK header and slect 'Guess Hand Orientations' when you have filled in the References.", (Object)(object)references.root); return; } if (leftArm.wristToPalmAxis == Vector3.zero || !onlyIfZero) { leftArm.wristToPalmAxis = VRIKCalibrator.GuessWristToPalmAxis(references.leftHand, references.leftForearm); } if (leftArm.palmToThumbAxis == Vector3.zero || !onlyIfZero) { leftArm.palmToThumbAxis = VRIKCalibrator.GuessPalmToThumbAxis(references.leftHand, references.leftForearm); } if (rightArm.wristToPalmAxis == Vector3.zero || !onlyIfZero) { rightArm.wristToPalmAxis = VRIKCalibrator.GuessWristToPalmAxis(references.rightHand, references.rightForearm); } if (rightArm.palmToThumbAxis == Vector3.zero || !onlyIfZero) { rightArm.palmToThumbAxis = VRIKCalibrator.GuessPalmToThumbAxis(references.rightHand, references.rightForearm); } } public void DefaultAnimationCurves() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown if (locomotion.stepHeight == null) { locomotion.stepHeight = new AnimationCurve(); } if (locomotion.heelHeight == null) { locomotion.heelHeight = new AnimationCurve(); } if (locomotion.stepHeight.keys.Length == 0) { locomotion.stepHeight.keys = GetSineKeyframes(0.03f); } if (locomotion.heelHeight.keys.Length == 0) { locomotion.heelHeight.keys = GetSineKeyframes(0.03f); } } public void AddPositionOffset(PositionOffset positionOffset, Vector3 value) { //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_003d: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) switch (positionOffset) { case PositionOffset.Pelvis: { Spine obj3 = spine; obj3.pelvisPositionOffset += value; break; } case PositionOffset.Chest: { Spine obj2 = spine; obj2.chestPositionOffset += value; break; } case PositionOffset.Head: { Spine obj = spine; obj.headPositionOffset += value; break; } case PositionOffset.LeftHand: { Arm arm2 = leftArm; arm2.handPositionOffset += value; break; } case PositionOffset.RightHand: { Arm arm = rightArm; arm.handPositionOffset += value; break; } case PositionOffset.LeftFoot: { Leg leg4 = leftLeg; leg4.footPositionOffset += value; break; } case PositionOffset.RightFoot: { Leg leg3 = rightLeg; leg3.footPositionOffset += value; break; } case PositionOffset.LeftHeel: { Leg leg2 = leftLeg; leg2.heelPositionOffset += value; break; } case PositionOffset.RightHeel: { Leg leg = rightLeg; leg.heelPositionOffset += value; break; } } } public void AddRotationOffset(RotationOffset rotationOffset, Vector3 value) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) AddRotationOffset(rotationOffset, Quaternion.Euler(value)); } public void AddRotationOffset(RotationOffset rotationOffset, Quaternion value) { //IL_0020: 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_0031: 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_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_0052: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) switch (rotationOffset) { case RotationOffset.Pelvis: spine.pelvisRotationOffset = value * spine.pelvisRotationOffset; break; case RotationOffset.Chest: spine.chestRotationOffset = value * spine.chestRotationOffset; break; case RotationOffset.Head: spine.headRotationOffset = value * spine.headRotationOffset; break; } } public void AddPlatformMotion(Vector3 deltaPosition, Quaternion deltaRotation, Vector3 platformPivot) { //IL_0007: 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_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) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0043: Unknown result type (might be due to invalid IL or missing references) locomotion.AddDeltaPosition(deltaPosition); raycastOriginPelvis += deltaPosition; locomotion.AddDeltaRotation(deltaRotation, platformPivot); spine.faceDirection = deltaRotation * spine.faceDirection; } public void Reset() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if (base.initiated) { UpdateSolverTransforms(); Read(readPositions, readRotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs); spine.faceDirection = rootBone.readRotation * Vector3.forward; if (hasLegs) { locomotion.Reset(readPositions, readRotations); raycastOriginPelvis = spine.pelvis.readPosition; } } } public override void StoreDefaultLocalState() { //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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) for (int i = 1; i < solverTransforms.Length; i++) { if ((Object)(object)solverTransforms[i] != (Object)null) { ref Vector3 reference = ref defaultLocalPositions[i - 1]; reference = solverTransforms[i].localPosition; ref Quaternion reference2 = ref defaultLocalRotations[i - 1]; reference2 = solverTransforms[i].localRotation; } } } public override void FixTransforms() { //IL_00b3: 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) if (!base.initiated || LOD >= 2) { return; } for (int i = 1; i < solverTransforms.Length; i++) { if ((Object)(object)solverTransforms[i] != (Object)null) { bool flag = i == 1; bool flag2 = i == 8 || i == 9 || i == 12 || i == 13; bool flag3 = (i >= 15 && i <= 17) || (i >= 19 && i <= 21); if (flag || flag2 || flag3) { solverTransforms[i].localPosition = defaultLocalPositions[i - 1]; } solverTransforms[i].localRotation = defaultLocalRotations[i - 1]; } } } public override Point[] GetPoints() { Debug.LogError((object)"GetPoints() is not applicable to IKSolverVR."); return null; } public override Point GetPoint(Transform transform) { Debug.LogError((object)"GetPoint is not applicable to IKSolverVR."); return null; } public override bool IsValid(ref string message) { //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_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_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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (solverTransforms == null || solverTransforms.Length == 0) { message = "Trying to initiate IKSolverVR with invalid bone references."; return false; } if (leftArm.wristToPalmAxis == Vector3.zero) { message = "Left arm 'Wrist To Palm Axis' needs to be set in VRIK. Please select the hand bone, set it to the axis that points from the wrist towards the palm. If the arrow points away from the palm, axis must be negative."; return false; } if (rightArm.wristToPalmAxis == Vector3.zero) { message = "Right arm 'Wrist To Palm Axis' needs to be set in VRIK. Please select the hand bone, set it to the axis that points from the wrist towards the palm. If the arrow points away from the palm, axis must be negative."; return false; } if (leftArm.palmToThumbAxis == Vector3.zero) { message = "Left arm 'Palm To Thumb Axis' needs to be set in VRIK. Please select the hand bone, set it to the axis that points from the palm towards the thumb. If the arrow points away from the thumb, axis must be negative."; return false; } if (rightArm.palmToThumbAxis == Vector3.zero) { message = "Right arm 'Palm To Thumb Axis' needs to be set in VRIK. Please select the hand bone, set it to the axis that points from the palm towards the thumb. If the arrow points away from the thumb, axis must be negative."; return false; } return true; } private Vector3 GetNormal(Transform[] transforms) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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_0077: 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_0089: 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) Vector3 val = Vector3.zero; Vector3 val2 = Vector3.zero; for (int i = 0; i < transforms.Length; i++) { val2 += transforms[i].position; } val2 /= (float)transforms.Length; for (int j = 0; j < transforms.Length - 1; j++) { Vector3 val3 = val; Vector3 val4 = Vector3.Cross(transforms[j].position - val2, transforms[j + 1].position - val2); val = val3 + ((Vector3)(ref val4)).normalized; } return val; } private static Keyframe[] GetSineKeyframes(float mag) { Keyframe[] array = (Keyframe[])(object)new Keyframe[3]; ((Keyframe)(ref array[0])).time = 0f; ((Keyframe)(ref array[0])).value = 0f; ((Keyframe)(ref array[1])).time = 0.5f; ((Keyframe)(ref array[1])).value = mag; ((Keyframe)(ref array[2])).time = 1f; ((Keyframe)(ref array[2])).value = 0f; return array; } private void UpdateSolverTransforms() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < solverTransforms.Length; i++) { if ((Object)(object)solverTransforms[i] != (Object)null) { ref Vector3 reference = ref readPositions[i]; reference = solverTransforms[i].position; ref Quaternion reference2 = ref readRotations[i]; reference2 = solverTransforms[i].rotation; } } } protected override void OnInitiate() { UpdateSolverTransforms(); Read(readPositions, readRotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs); } protected override void OnUpdate() { //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) if (IKPositionWeight > 0f) { if (LOD < 2) { bool flag = false; if (lastLOD != LOD && lastLOD == 2) { spine.faceDirection = rootBone.readRotation * Vector3.forward; if (hasLegs) { if (locomotion.weight > 0f) { root.position = new Vector3(spine.headTarget.position.x, root.position.y, spine.headTarget.position.z); Vector3 faceDirection = spine.faceDirection; faceDirection.y = 0f; root.rotation = Quaternion.LookRotation(faceDirection, root.up); UpdateSolverTransforms(); Read(readPositions, readRotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs); flag = true; locomotion.Reset(readPositions, readRotations); } raycastOriginPelvis = spine.pelvis.readPosition; } } if (!flag) { UpdateSolverTransforms(); Read(readPositions, readRotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs); } Solve(); Write(); WriteTransforms(); } else if (locomotion.weight > 0f) { root.position = new Vector3(spine.headTarget.position.x, root.position.y, spine.headTarget.position.z); Vector3 val = spine.headTarget.rotation * spine.anchorRelativeToHead * Vector3.forward; val.y = 0f; root.rotation = Quaternion.LookRotation(val, root.up); } } lastLOD = LOD; } private void WriteTransforms() { //IL_0092: 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_00a4: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < solverTransforms.Length; i++) { if (!((Object)(object)solverTransforms[i] != (Object)null)) { continue; } bool flag = i < 2; bool flag2 = i == 8 || i == 9 || i == 12 || i == 13; bool flag3 = (i >= 15 && i <= 17) || (i >= 19 && i <= 21); if (LOD > 0) { flag2 = false; flag3 = false; } if (flag) { solverTransforms[i].position = V3Tools.Lerp(solverTransforms[i].position, GetPosition(i), IKPositionWeight); } if (flag2 || flag3) { if (IKPositionWeight < 1f) { Vector3 localPosition = solverTransforms[i].localPosition; solverTransforms[i].position = V3Tools.Lerp(solverTransforms[i].position, GetPosition(i), IKPositionWeight); solverTransforms[i].localPosition = Vector3.Project(solverTransforms[i].localPosition, localPosition); } else { solverTransforms[i].position = V3Tools.Lerp(solverTransforms[i].position, GetPosition(i), IKPositionWeight); } } solverTransforms[i].rotation = QuaTools.Lerp(solverTransforms[i].rotation, GetRotation(i), IKPositionWeight); } } private void Read(Vector3[] positions, Quaternion[] rotations, bool hasChest, bool hasNeck, bool hasShoulders, bool hasToes, bool hasLegs) { //IL_0044: 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_0015: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) if (rootBone == null) { rootBone = new VirtualBone(positions[0], rotations[0]); } else { rootBone.Read(positions[0], rotations[0]); } spine.Read(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, 0, 1); leftArm.Read(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, (!hasChest) ? 2 : 3, 6); rightArm.Read(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, (!hasChest) ? 2 : 3, 10); if (hasLegs) { leftLeg.Read(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, 1, 14); rightLeg.Read(positions, rotations, hasChest, hasNeck, hasShoulders, hasToes, hasLegs, 1, 18); } for (int i = 0; i < rotations.Length; i++) { ref Vector3 reference = ref solvedPositions[i]; reference = positions[i]; ref Quaternion reference2 = ref solvedRotations[i]; reference2 = rotations[i]; } if (!base.initiated) { if (hasLegs) { legs = new Leg[2] { leftLeg, rightLeg }; } arms = new Arm[2] { leftArm, rightArm }; if (hasLegs) { locomotion.Initiate(positions, rotations, hasToes, scale); } raycastOriginPelvis = spine.pelvis.readPosition; spine.faceDirection = readRotations[0] * Vector3.forward; } } private void Solve() { //IL_0810: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0289: 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_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: 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_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_031c: 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_0342: 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_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_037a: 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_0384: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_0450: 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_045d: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: 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_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: 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_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d3: 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_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04eb: Unknown result type (might be due to invalid IL or missing references) //IL_04f0: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_052e: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_059b: 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: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05b9: Unknown result type (might be due to invalid IL or missing references) //IL_05be: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: 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_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0617: 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_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0632: Unknown result type (might be due to invalid IL or missing references) //IL_083d: Unknown result type (might be due to invalid IL or missing references) //IL_084d: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06d7: Unknown result type (might be due to invalid IL or missing references) //IL_06e7: Unknown result type (might be due to invalid IL or missing references) //IL_0754: Unknown result type (might be due to invalid IL or missing references) //IL_0788: Unknown result type (might be due to invalid IL or missing references) //IL_0798: Unknown result type (might be due to invalid IL or missing references) //IL_0928: Unknown result type (might be due to invalid IL or missing references) //IL_092e: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Unknown result type (might be due to invalid IL or missing references) //IL_0938: Unknown result type (might be due to invalid IL or missing references) //IL_0944: Unknown result type (might be due to invalid IL or missing references) //IL_094f: Unknown result type (might be due to invalid IL or missing references) //IL_0954: Unknown result type (might be due to invalid IL or missing references) //IL_0959: Unknown result type (might be due to invalid IL or missing references) //IL_0996: Unknown result type (might be due to invalid IL or missing references) //IL_09ab: Unknown result type (might be due to invalid IL or missing references) //IL_09b0: Unknown result type (might be due to invalid IL or missing references) if (scale <= 0f) { Debug.LogError((object)"VRIK solver scale <= 0, can not solve!"); return; } spine.SetLOD(LOD); Arm[] array = arms; foreach (Arm arm in array) { arm.SetLOD(LOD); } if (hasLegs) { Leg[] array2 = legs; foreach (Leg leg in array2) { leg.SetLOD(LOD); } } spine.PreSolve(); Arm[] array3 = arms; foreach (Arm arm2 in array3) { arm2.PreSolve(); } if (hasLegs) { Leg[] array4 = legs; foreach (Leg leg2 in array4) { leg2.PreSolve(); } } Arm[] array5 = arms; foreach (Arm arm3 in array5) { arm3.ApplyOffsets(scale); } spine.ApplyOffsets(scale); spine.Solve(rootBone, legs, arms, scale); if (hasLegs && spine.pelvisPositionWeight > 0f && plantFeet) { Warning.Log("If VRIK 'Pelvis Position Weight' is > 0, 'Plant Feet' should be disabled to improve performance and stability.", root); } if (hasLegs && locomotion.weight > 0f) { Vector3 leftFootPosition = Vector3.zero; Vector3 rightFootPosition = Vector3.zero; Quaternion leftFootRotation = Quaternion.identity; Quaternion rightFootRotation = Quaternion.identity; float leftFootOffset = 0f; float rightFootOffset = 0f; float leftHeelOffset = 0f; float rightHeelOffset = 0f; locomotion.Solve(rootBone, spine, leftLeg, rightLeg, leftArm, rightArm, supportLegIndex, out leftFootPosition, out rightFootPosition, out leftFootRotation, out rightFootRotation, out leftFootOffset, out rightFootOffset, out leftHeelOffset, out rightHeelOffset, scale); leftFootPosition += root.up * leftFootOffset; rightFootPosition += root.up * rightFootOffset; Leg leg3 = leftLeg; leg3.footPositionOffset += (leftFootPosition - leftLeg.lastBone.solverPosition) * IKPositionWeight * (1f - leftLeg.positionWeight) * locomotion.weight; Leg leg4 = rightLeg; leg4.footPositionOffset += (rightFootPosition - rightLeg.lastBone.solverPosition) * IKPositionWeight * (1f - rightLeg.positionWeight) * locomotion.weight; Leg leg5 = leftLeg; leg5.heelPositionOffset += root.up * leftHeelOffset * locomotion.weight; Leg leg6 = rightLeg; leg6.heelPositionOffset += root.up * rightHeelOffset * locomotion.weight; Quaternion val = QuaTools.FromToRotation(leftLeg.lastBone.solverRotation, leftFootRotation); Quaternion val2 = QuaTools.FromToRotation(rightLeg.lastBone.solverRotation, rightFootRotation); val = Quaternion.Lerp(Quaternion.identity, val, IKPositionWeight * (1f - leftLeg.rotationWeight) * locomotion.weight); val2 = Quaternion.Lerp(Quaternion.identity, val2, IKPositionWeight * (1f - rightLeg.rotationWeight) * locomotion.weight); leftLeg.footRotationOffset = val * leftLeg.footRotationOffset; rightLeg.footRotationOffset = val2 * rightLeg.footRotationOffset; Vector3 point = Vector3.Lerp(leftLeg.position + leftLeg.footPositionOffset, rightLeg.position + rightLeg.footPositionOffset, 0.5f); point = V3Tools.PointToPlane(point, rootBone.solverPosition, root.up); Vector3 val3 = rootBone.solverPosition + rootVelocity * Time.deltaTime * 2f * locomotion.weight; val3 = Vector3.Lerp(val3, point, Time.deltaTime * locomotion.rootSpeed * locomotion.weight); rootBone.solverPosition = val3; rootVelocity += (point - rootBone.solverPosition) * Time.deltaTime * 10f; Vector3 val4 = V3Tools.ExtractVertical(rootVelocity, root.up, 1f); rootVelocity -= val4; float num = Mathf.Min(leftFootOffset + rightFootOffset, locomotion.maxBodyYOffset * scale); bodyOffset = Vector3.Lerp(bodyOffset, root.up * num, Time.deltaTime * 3f); bodyOffset = Vector3.Lerp(Vector3.zero, bodyOffset, locomotion.weight); } if (hasLegs) { Leg[] array6 = legs; foreach (Leg leg7 in array6) { leg7.ApplyOffsets(scale); } if (!plantFeet || LOD > 0) { spine.InverseTranslateToHead(legs, limited: false, useCurrentLegMag: false, bodyOffset, 1f); Leg[] array7 = legs; foreach (Leg leg8 in array7) { leg8.TranslateRoot(spine.pelvis.solverPosition, spine.pelvis.solverRotation); } Leg[] array8 = legs; foreach (Leg leg9 in array8) { leg9.Solve(stretch: true); } } else { for (int num4 = 0; num4 < 2; num4++) { spine.InverseTranslateToHead(legs, limited: true, useCurrentLegMag: true, bodyOffset, 1f); Leg[] array9 = legs; foreach (Leg leg10 in array9) { leg10.TranslateRoot(spine.pelvis.solverPosition, spine.pelvis.solverRotation); } Leg[] array10 = legs; foreach (Leg leg11 in array10) { leg11.Solve(num4 == 0); } } } } else { spine.InverseTranslateToHead(legs, limited: false, useCurrentLegMag: false, bodyOffset, 1f); } for (int num7 = 0; num7 < arms.Length; num7++) { arms[num7].TranslateRoot(spine.chest.solverPosition, spine.chest.solverRotation); } for (int num8 = 0; num8 < arms.Length; num8++) { arms[num8].Solve(num8 == 0); } spine.ResetOffsets(); if (hasLegs) { Leg[] array11 = legs; foreach (Leg leg12 in array11) { leg12.ResetOffsets(); } } Arm[] array12 = arms; foreach (Arm arm4 in array12) { arm4.ResetOffsets(); } if (hasLegs) { Spine obj = spine; obj.pelvisPositionOffset += GetPelvisOffset(); Spine obj2 = spine; obj2.chestPositionOffset += spine.pelvisPositionOffset; } Write(); if (!hasLegs) { return; } supportLegIndex = -1; float num11 = float.PositiveInfinity; for (int num12 = 0; num12 < legs.Length; num12++) { float num13 = Vector3.SqrMagnitude(legs[num12].lastBone.solverPosition - legs[num12].bones[0].solverPosition); if (num13 < num11) { supportLegIndex = num12; num11 = num13; } } } private Vector3 GetPosition(int index) { //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_0018: Unknown result type (might be due to invalid IL or missing references) return solvedPositions[index]; } private Quaternion GetRotation(int index) { //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_0018: Unknown result type (might be due to invalid IL or missing references) return solvedRotations[index]; } private void Write() { //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_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) ref Vector3 reference = ref solvedPositions[0]; reference = rootBone.solverPosition; ref Quaternion reference2 = ref solvedRotations[0]; reference2 = rootBone.solverRotation; spine.Write(ref solvedPositions, ref solvedRotations); if (hasLegs) { Leg[] array = legs; foreach (Leg leg in array) { leg.Write(ref solvedPositions, ref solvedRotations); } } Arm[] array2 = arms; foreach (Arm arm in array2) { arm.Write(ref solvedPositions, ref solvedRotations); } } private Vector3 GetPelvisOffset() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0070: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_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_0294: 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_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c7: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0289: 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) if (locomotion.weight <= 0f) { return Vector3.zero; } if (LayerMask.op_Implicit(locomotion.blockingLayers) == -1) { return Vector3.zero; } Vector3 val = raycastOriginPelvis; val.y = spine.pelvis.solverPosition.y; Vector3 val2 = spine.pelvis.readPosition; val2.y = spine.pelvis.solverPosition.y; Vector3 val3 = val2 - val; RaycastHit val4 = default(RaycastHit); if (locomotion.raycastRadius <= 0f) { if (Physics.Raycast(val, val3, ref val4, ((Vector3)(ref val3)).magnitude * 1.1f, LayerMask.op_Implicit(locomotion.blockingLayers))) { val2 = ((RaycastHit)(ref val4)).point; } } else if (Physics.SphereCast(val, locomotion.raycastRadius * 1.1f, val3, ref val4, ((Vector3)(ref val3)).magnitude, LayerMask.op_Implicit(locomotion.blockingLayers))) { val2 = val + ((Vector3)(ref val3)).normalized * ((RaycastHit)(ref val4)).distance / 1.1f; } Vector3 val5 = spine.pelvis.solverPosition; val3 = val5 - val2; if (locomotion.raycastRadius <= 0f) { if (Physics.Raycast(val2, val3, ref val4, ((Vector3)(ref val3)).magnitude, LayerMask.op_Implicit(locomotion.blockingLayers))) { val5 = ((RaycastHit)(ref val4)).point; } } else if (Physics.SphereCast(val2, locomotion.raycastRadius, val3, ref val4, ((Vector3)(ref val3)).magnitude, LayerMask.op_Implicit(locomotion.blockingLayers))) { val5 = val2 + ((Vector3)(ref val3)).normalized * ((RaycastHit)(ref val4)).distance; } lastOffset = Vector3.Lerp(lastOffset, Vector3.zero, Time.deltaTime * 3f); val5 += Vector3.ClampMagnitude(lastOffset, 0.75f); val5.y = spine.pelvis.solverPosition.y; lastOffset = Vector3.Lerp(lastOffset, val5 - spine.pelvis.solverPosition, Time.deltaTime * 15f); return lastOffset; } } public class TwistRelaxer : MonoBehaviour { public IK ik; [Tooltip("If using multiple solvers, add them in inverse hierarchical order - first forearm roll bone, then forearm bone and upper arm bone.")] public TwistSolver[] twistSolvers = new TwistSolver[0]; public void Start() { if (twistSolvers.Length == 0) { Debug.LogError((object)"TwistRelaxer has no TwistSolvers. TwistRelaxer.cs was restructured for FIK v2.0 to support multiple relaxers on the same body part and TwistRelaxer components need to be set up again, sorry for the inconvenience!", (Object)(object)((Component)this).transform); return; } TwistSolver[] array = twistSolvers; foreach (TwistSolver twistSolver in array) { twistSolver.Initiate(); } if ((Object)(object)ik != (Object)null) { IKSolver iKSolver = ik.GetIKSolver(); iKSolver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(iKSolver.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostUpdate)); } } private void OnPostUpdate() { if ((Object)(object)ik != (Object)null) { TwistSolver[] array = twistSolvers; foreach (TwistSolver twistSolver in array) { twistSolver.Relax(); } } } private void LateUpdate() { if ((Object)(object)ik == (Object)null) { TwistSolver[] array = twistSolvers; foreach (TwistSolver twistSolver in array) { twistSolver.Relax(); } } } private void OnDestroy() { if ((Object)(object)ik != (Object)null) { IKSolver iKSolver = ik.GetIKSolver(); iKSolver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(iKSolver.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostUpdate)); } } } [Serializable] public class TwistSolver { [Tooltip("The transform that this solver operates on.")] public Transform transform; [Tooltip("If this is the forearm roll bone, the parent should be the forearm bone. If null, will be found automatically.")] public Transform parent; [Tooltip("If this is the forearm roll bone, the child should be the hand bone. If null, will attempt to find automatically. Assign the hand manually if the hand bone is not a child of the roll bone.")] public Transform[] children = (Transform[])(object)new Transform[0]; [Tooltip("The weight of relaxing the twist of this Transform")] [Range(0f, 1f)] public float weight = 1f; [Tooltip("If 0.5, this Transform will be twisted half way from parent to child. If 1, the twist angle will be locked to the child and will rotate with along with it.")] [Range(0f, 1f)] public float parentChildCrossfade = 0.5f; [Tooltip("Rotation offset around the twist axis.")] [Range(-180f, 180f)] public float twistAngleOffset; private Vector3 twistAxis = Vector3.right; private Vector3 axis = Vector3.forward; private Vector3 axisRelativeToParentDefault; private Vector3 axisRelativeToChildDefault; private Quaternion[] childRotations; private bool inititated; public TwistSolver() { //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_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) weight = 1f; parentChildCrossfade = 0.5f; } public void Initiate() { //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)transform == (Object)null) { Debug.LogError((object)"TwistRelaxer solver has unassigned Transform. TwistRelaxer.cs was restructured for FIK v2.0 to support multiple relaxers on the same body part and TwistRelaxer components need to be set up again, sorry for the inconvenience!", (Object)(object)transform); return; } if ((Object)(object)parent == (Object)null) { parent = transform.parent; } if (children.Length == 0) { if (transform.childCount == 0) { Transform[] componentsInChildren = ((Component)parent).GetComponentsInChildren(); for (int i = 1; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)(object)transform) { componentsInChildren = (Transform[])(object)new Transform[1] { componentsInChildren[i] }; break; } } } else { children = (Transform[])(object)new Transform[1] { transform.GetChild(0) }; } } if (children.Length == 0 || (Object)(object)children[0] == (Object)null) { Debug.LogError((object)"TwistRelaxer has no children assigned.", (Object)(object)transform); return; } twistAxis = transform.InverseTransformDirection(children[0].position - transform.position); axis = new Vector3(twistAxis.y, twistAxis.z, twistAxis.x); Vector3 val = transform.rotation * axis; axisRelativeToParentDefault = Quaternion.Inverse(parent.rotation) * val; axisRelativeToChildDefault = Quaternion.Inverse(children[0].rotation) * val; childRotations = (Quaternion[])(object)new Quaternion[children.Length]; inititated = true; } public void Relax() { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0052: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00a9: 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_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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) if (inititated && !(weight <= 0f)) { Quaternion rotation = transform.rotation; Quaternion val = Quaternion.AngleAxis(twistAngleOffset, rotation * twistAxis); rotation = val * rotation; Vector3 val2 = val * parent.rotation * axisRelativeToParentDefault; Vector3 val3 = val * children[0].rotation * axisRelativeToChildDefault; Vector3 val4 = Vector3.Slerp(val2, val3, parentChildCrossfade); Quaternion val5 = Quaternion.LookRotation(rotation * axis, rotation * twistAxis); val4 = Quaternion.Inverse(val5) * val4; float num = Mathf.Atan2(val4.x, val4.z) * 57.29578f; for (int i = 0; i < children.Length; i++) { ref Quaternion reference = ref childRotations[i]; reference = children[i].rotation; } transform.rotation = Quaternion.AngleAxis(num * weight, rotation * twistAxis) * rotation; for (int j = 0; j < children.Length; j++) { children[j].rotation = childRotations[j]; } } } } [Serializable] public class InteractionEffector { private Poser poser; private IKEffector effector; private float timer; private float length; private float weight; private float fadeInSpeed; private float defaultPositionWeight; private float defaultRotationWeight; private float defaultPull; private float defaultReach; private float defaultPush; private float defaultPushParent; private float defaultBendGoalWeight; private float resetTimer; private bool positionWeightUsed; private bool rotationWeightUsed; private bool pullUsed; private bool reachUsed; private bool pushUsed; private bool pushParentUsed; private bool bendGoalWeightUsed; private bool pickedUp; private bool defaults; private bool pickUpOnPostFBBIK; private Vector3 pickUpPosition; private Vector3 pausePositionRelative; private Quaternion pickUpRotation; private Quaternion pauseRotationRelative; private InteractionTarget interactionTarget; private Transform target; private List triggered = new List(); private InteractionSystem interactionSystem; private bool started; public FullBodyBipedEffector effectorType { get; private set; } public bool isPaused { get; private set; } public InteractionObject interactionObject { get; private set; } public bool inInteraction => (Object)(object)interactionObject != (Object)null; public float progress { get { if (!inInteraction) { return 0f; } if (length == 0f) { return 0f; } return timer / length; } } public InteractionEffector(FullBodyBipedEffector effectorType) { this.effectorType = effectorType; } public void Initiate(InteractionSystem interactionSystem) { this.interactionSystem = interactionSystem; effector = interactionSystem.ik.solver.GetEffector(effectorType); poser = ((Component)effector.bone).GetComponent(); StoreDefaults(); } private void StoreDefaults() { defaultPositionWeight = interactionSystem.ik.solver.GetEffector(effectorType).positionWeight; defaultRotationWeight = interactionSystem.ik.solver.GetEffector(effectorType).rotationWeight; defaultPull = interactionSystem.ik.solver.GetChain(effectorType).pull; defaultReach = interactionSystem.ik.solver.GetChain(effectorType).reach; defaultPush = interactionSystem.ik.solver.GetChain(effectorType).push; defaultPushParent = interactionSystem.ik.solver.GetChain(effectorType).pushParent; defaultBendGoalWeight = interactionSystem.ik.solver.GetChain(effectorType).bendConstraint.weight; } public bool ResetToDefaults(float speed) { if (inInteraction) { return false; } if (isPaused) { return false; } if (defaults) { return false; } resetTimer = Mathf.MoveTowards(resetTimer, 0f, Time.deltaTime * speed); if (effector.isEndEffector) { if (pullUsed) { interactionSystem.ik.solver.GetChain(effectorType).pull = Mathf.Lerp(defaultPull, interactionSystem.ik.solver.GetChain(effectorType).pull, resetTimer); } if (reachUsed) { interactionSystem.ik.solver.GetChain(effectorType).reach = Mathf.Lerp(defaultReach, interactionSystem.ik.solver.GetChain(effectorType).reach, resetTimer); } if (pushUsed) { interactionSystem.ik.solver.GetChain(effectorType).push = Mathf.Lerp(defaultPush, interactionSystem.ik.solver.GetChain(effectorType).push, resetTimer); } if (pushParentUsed) { interactionSystem.ik.solver.GetChain(effectorType).pushParent = Mathf.Lerp(defaultPushParent, interactionSystem.ik.solver.GetChain(effectorType).pushParent, resetTimer); } if (bendGoalWeightUsed) { interactionSystem.ik.solver.GetChain(effectorType).bendConstraint.weight = Mathf.Lerp(defaultBendGoalWeight, interactionSystem.ik.solver.GetChain(effectorType).bendConstraint.weight, resetTimer); } } if (positionWeightUsed) { effector.positionWeight = Mathf.Lerp(defaultPositionWeight, effector.positionWeight, resetTimer); } if (rotationWeightUsed) { effector.rotationWeight = Mathf.Lerp(defaultRotationWeight, effector.rotationWeight, resetTimer); } if (resetTimer <= 0f) { pullUsed = false; reachUsed = false; pushUsed = false; pushParentUsed = false; positionWeightUsed = false; rotationWeightUsed = false; bendGoalWeightUsed = false; defaults = true; } return true; } public bool Pause() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_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_0057: Unknown result type (might be due to invalid IL or missing references) if (!inInteraction) { return false; } isPaused = true; pausePositionRelative = target.InverseTransformPoint(effector.position); pauseRotationRelative = Quaternion.Inverse(target.rotation) * effector.rotation; if (interactionSystem.OnInteractionPause != null) { interactionSystem.OnInteractionPause(effectorType, interactionObject); } return true; } public bool Resume() { if (!inInteraction) { return false; } isPaused = false; if (interactionSystem.OnInteractionResume != null) { interactionSystem.OnInteractionResume(effectorType, interactionObject); } return true; } public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt) { //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_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_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) if (!inInteraction) { effector.position = effector.bone.position; effector.rotation = effector.bone.rotation; } else { if (!interrupt) { return false; } defaults = false; } target = interactionObject.GetTarget(effectorType, tag); if ((Object)(object)target == (Object)null) { return false; } interactionTarget = ((Component)target).GetComponent(); this.interactionObject = interactionObject; if (interactionSystem.OnInteractionStart != null) { interactionSystem.OnInteractionStart(effectorType, interactionObject); } interactionObject.OnStartInteraction(interactionSystem); triggered.Clear(); for (int i = 0; i < interactionObject.events.Length; i++) { triggered.Add(item: false); } if ((Object)(object)poser != (Object)null) { if ((Object)(object)poser.poseRoot == (Object)null) { poser.weight = 0f; } if ((Object)(object)interactionTarget != (Object)null) { poser.poseRoot = ((Component)target).transform; } else { poser.poseRoot = null; } poser.AutoMapping(); } positionWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PositionWeight); rotationWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.RotationWeight); pullUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Pull); reachUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Reach); pushUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Push); pushParentUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PushParent); bendGoalWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.BendGoalWeight); if (defaults) { StoreDefaults(); } timer = 0f; weight = 0f; fadeInSpeed = ((!(fadeInTime > 0f)) ? 1000f : (1f / fadeInTime)); length = interactionObject.length; isPaused = false; pickedUp = false; pickUpPosition = Vector3.zero; pickUpRotation = Quaternion.identity; if ((Object)(object)interactionTarget != (Object)null) { interactionTarget.RotateTo(effector.bone); } started = true; return true; } public void Update(Transform root, float speed) { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: 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_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: 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_0224: Unknown result type (might be due to invalid IL or missing references) if (!inInteraction) { if (started) { isPaused = false; pickedUp = false; defaults = false; resetTimer = 1f; started = false; } return; } if ((Object)(object)interactionTarget != (Object)null && !interactionTarget.rotateOnce) { interactionTarget.RotateTo(effector.bone); } if (isPaused) { effector.position = target.TransformPoint(pausePositionRelative); effector.rotation = target.rotation * pauseRotationRelative; interactionObject.Apply(interactionSystem.ik.solver, effectorType, interactionTarget, timer, weight); return; } timer += Time.deltaTime * speed * ((!((Object)(object)interactionTarget != (Object)null)) ? 1f : interactionTarget.interactionSpeedMlp); weight = Mathf.Clamp(weight + Time.deltaTime * fadeInSpeed * speed, 0f, 1f); bool pickUp = false; bool pause = false; TriggerUntriggeredEvents(checkTime: true, out pickUp, out pause); Vector3 val = ((!pickedUp) ? target.position : ((Component)interactionSystem).transform.TransformPoint(pickUpPosition)); Quaternion val2 = ((!pickedUp) ? target.rotation : (((Component)interactionSystem).transform.rotation * pickUpRotation)); effector.position = Vector3.Lerp(effector.bone.position, val, weight); effector.rotation = Quaternion.Lerp(effector.bone.rotation, val2, weight); interactionObject.Apply(interactionSystem.ik.solver, effectorType, interactionTarget, timer, weight); if (pickUp) { PickUp(root); } if (pause) { Pause(); } float value = interactionObject.GetValue(InteractionObject.WeightCurve.Type.PoserWeight, interactionTarget, timer); if ((Object)(object)poser != (Object)null) { poser.weight = Mathf.Lerp(poser.weight, value, weight); } else if (value > 0f) { Warning.Log("InteractionObject " + ((Object)interactionObject).name + " has a curve/multipler for Poser Weight, but the bone of effector " + effectorType.ToString() + " has no HandPoser/GenericPoser attached.", effector.bone); } if (timer >= length) { Stop(); } } private void TriggerUntriggeredEvents(bool checkTime, out bool pickUp, out bool pause) { pickUp = false; pause = false; for (int i = 0; i < triggered.Count; i++) { if (triggered[i] || (checkTime && !(interactionObject.events[i].time < timer))) { continue; } interactionObject.events[i].Activate(effector.bone); if (interactionObject.events[i].pickUp) { if (timer >= interactionObject.events[i].time) { timer = interactionObject.events[i].time; } pickUp = true; } if (interactionObject.events[i].pause) { if (timer >= interactionObject.events[i].time) { timer = interactionObject.events[i].time; } pause = true; } if (interactionSystem.OnInteractionEvent != null) { interactionSystem.OnInteractionEvent(effectorType, interactionObject, interactionObject.events[i]); } triggered[i] = true; } } private void PickUp(Transform root) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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) pickUpPosition = root.InverseTransformPoint(effector.position); pickUpRotation = Quaternion.Inverse(((Component)interactionSystem).transform.rotation) * effector.rotation; pickUpOnPostFBBIK = true; pickedUp = true; Rigidbody component = ((Component)interactionObject.targetsRoot).GetComponent(); if ((Object)(object)component != (Object)null) { if (!component.isKinematic) { component.isKinematic = true; } Collider component2 = ((Component)root).GetComponent(); if ((Object)(object)component2 != (Object)null) { Collider[] componentsInChildren = ((Component)interactionObject.targetsRoot).GetComponentsInChildren(); Collider[] array = componentsInChildren; foreach (Collider val in array) { if (!val.isTrigger && val.enabled) { Physics.IgnoreCollision(component2, val); } } } } if (interactionSystem.OnInteractionPickUp != null) { interactionSystem.OnInteractionPickUp(effectorType, interactionObject); } } public bool Stop() { if (!inInteraction) { return false; } bool pickUp = false; bool pause = false; TriggerUntriggeredEvents(checkTime: false, out pickUp, out pause); if (interactionSystem.OnInteractionStop != null) { interactionSystem.OnInteractionStop(effectorType, interactionObject); } if ((Object)(object)interactionTarget != (Object)null) { interactionTarget.ResetRotation(); } interactionObject = null; weight = 0f; timer = 0f; isPaused = false; target = null; defaults = false; resetTimer = 1f; if ((Object)(object)poser != (Object)null && !pickedUp) { poser.weight = 0f; } pickedUp = false; started = false; return true; } public void OnPostFBBIK() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_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_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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) if (inInteraction) { float num = interactionObject.GetValue(InteractionObject.WeightCurve.Type.RotateBoneWeight, interactionTarget, timer) * weight; if (num > 0f) { Quaternion val = ((!pickedUp) ? effector.rotation : (((Component)interactionSystem).transform.rotation * pickUpRotation)); Quaternion val2 = Quaternion.Slerp(effector.bone.rotation, val, num * num); effector.bone.localRotation = Quaternion.Inverse(effector.bone.parent.rotation) * val2; } if (pickUpOnPostFBBIK) { Vector3 position = effector.bone.position; effector.bone.position = ((Component)interactionSystem).transform.TransformPoint(pickUpPosition); interactionObject.targetsRoot.parent = effector.bone; effector.bone.position = position; pickUpOnPostFBBIK = false; } } } } [Serializable] public class InteractionLookAt { [Tooltip("(Optional) reference to the LookAtIK component that will be used to make the character look at the objects that it is interacting with.")] public LookAtIK ik; [Tooltip("Interpolation speed of the LookAtIK target.")] public float lerpSpeed = 5f; [Tooltip("Interpolation speed of the LookAtIK weight.")] public float weightSpeed = 1f; [HideInInspector] public bool isPaused; private Transform lookAtTarget; private float stopLookTime; private float weight; private bool firstFBBIKSolve; public void Look(Transform target, float time) { //IL_004c: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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) if (!((Object)(object)ik == (Object)null)) { if (ik.solver.IKPositionWeight <= 0f) { ik.solver.IKPosition = ik.solver.GetRoot().position + ik.solver.GetRoot().forward * 3f; } lookAtTarget = target; stopLookTime = time; } } public void OnFixTransforms() { if (!((Object)(object)ik == (Object)null) && ik.fixTransforms) { ik.solver.FixTransforms(); } } public void Update() { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ik == (Object)null) { return; } if (((Behaviour)ik).enabled) { ((Behaviour)ik).enabled = false; } if (!((Object)(object)lookAtTarget == (Object)null)) { if (isPaused) { stopLookTime += Time.deltaTime; } float num = ((!(Time.time < stopLookTime)) ? (0f - weightSpeed) : weightSpeed); weight = Mathf.Clamp(weight + num * Time.deltaTime, 0f, 1f); ik.solver.IKPositionWeight = Interp.Float(weight, InterpolationMode.InOutQuintic); ik.solver.IKPosition = Vector3.Lerp(ik.solver.IKPosition, lookAtTarget.position, lerpSpeed * Time.deltaTime); if (weight <= 0f) { lookAtTarget = null; } firstFBBIKSolve = true; } } public void SolveSpine() { if (!((Object)(object)ik == (Object)null) && firstFBBIKSolve) { float headWeight = ik.solver.headWeight; float eyesWeight = ik.solver.eyesWeight; ik.solver.headWeight = 0f; ik.solver.eyesWeight = 0f; ik.solver.Update(); ik.solver.headWeight = headWeight; ik.solver.eyesWeight = eyesWeight; } } public void SolveHead() { if (!((Object)(object)ik == (Object)null) && firstFBBIKSolve) { float bodyWeight = ik.solver.bodyWeight; ik.solver.bodyWeight = 0f; ik.solver.Update(); ik.solver.bodyWeight = bodyWeight; firstFBBIKSolve = false; } } } [HelpURL("https://www.youtube.com/watch?v=r5jiZnsDH3M")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Interaction System/Interaction Object")] public class InteractionObject : MonoBehaviour { [Serializable] public class InteractionEvent { [Tooltip("The time of the event since interaction start.")] public float time; [Tooltip("If true, the interaction will be paused on this event. The interaction can be resumed by InteractionSystem.ResumeInteraction() or InteractionSystem.ResumeAll;")] public bool pause; [Tooltip("If true, the object will be parented to the effector bone on this event. Note that picking up like this can be done by only a single effector at a time. If you wish to pick up an object with both hands, see the Interaction PickUp2Handed demo scene.")] public bool pickUp; [Tooltip("The animations called on this event.")] public AnimatorEvent[] animations; [Tooltip("The messages sent on this event using GameObject.SendMessage().")] public Message[] messages; [Tooltip("The UnityEvent to invoke on this event.")] public UnityEvent unityEvent; public void Activate(Transform t) { unityEvent.Invoke(); AnimatorEvent[] array = animations; foreach (AnimatorEvent animatorEvent in array) { animatorEvent.Activate(pickUp); } Message[] array2 = messages; foreach (Message message in array2) { message.Send(t); } } } [Serializable] public class Message { [Tooltip("The name of the function called.")] public string function; [Tooltip("The recipient game object.")] public GameObject recipient; private const string empty = ""; public void Send(Transform t) { if (!((Object)(object)recipient == (Object)null) && !(function == string.Empty) && !(function == "")) { recipient.SendMessage(function, (object)t, (SendMessageOptions)0); } } } [Serializable] public class AnimatorEvent { [Tooltip("The Animator component that will receive the AnimatorEvents.")] public Animator animator; [Tooltip("The Animation component that will receive the AnimatorEvents (Legacy).")] public Animation animation; [Tooltip("The name of the animation state.")] public string animationState; [Tooltip("The crossfading time.")] public float crossfadeTime = 0.3f; [Tooltip("The layer of the animation state (if using Legacy, the animation state will be forced to this layer).")] public int layer; [Tooltip("Should the animation always start from 0 normalized time?")] public bool resetNormalizedTime; private const string empty = ""; public void Activate(bool pickUp) { if ((Object)(object)animator != (Object)null) { if (pickUp) { animator.applyRootMotion = false; } Activate(animator); } if ((Object)(object)animation != (Object)null) { Activate(animation); } } private void Activate(Animator animator) { if (!(animationState == "")) { if (resetNormalizedTime) { animator.CrossFade(animationState, crossfadeTime, layer, 0f); } else { animator.CrossFade(animationState, crossfadeTime, layer); } } } private void Activate(Animation animation) { if (!(animationState == "")) { if (resetNormalizedTime) { animation[animationState].normalizedTime = 0f; } animation[animationState].layer = layer; animation.CrossFade(animationState, crossfadeTime); } } } [Serializable] public class WeightCurve { [Serializable] public enum Type { PositionWeight, RotationWeight, PositionOffsetX, PositionOffsetY, PositionOffsetZ, Pull, Reach, RotateBoneWeight, Push, PushParent, PoserWeight, BendGoalWeight } [Tooltip("The type of the curve (InteractionObject.WeightCurve.Type).")] public Type type; [Tooltip("The weight curve.")] public AnimationCurve curve; public float GetValue(float timer) { return curve.Evaluate(timer); } } [Serializable] public class Multiplier { [Tooltip("The curve type to multiply.")] public WeightCurve.Type curve; [Tooltip("The multiplier of the curve's value.")] public float multiplier = 1f; [Tooltip("The resulting value will be applied to this channel.")] public WeightCurve.Type result; public float GetValue(WeightCurve weightCurve, float timer) { return weightCurve.GetValue(timer) * multiplier; } } [Tooltip("If the Interaction System has a 'Look At' LookAtIK component assigned, will use it to make the character look at the specified Transform. If unassigned, will look at this GameObject.")] public Transform otherLookAtTarget; [Tooltip("The root Transform of the InteractionTargets. If null, will use this GameObject. GetComponentsInChildren() will be used at initiation to find all InteractionTargets associated with this InteractionObject.")] public Transform otherTargetsRoot; [Tooltip("If assigned, all PositionOffset channels will be applied in the rotation space of this Transform. If not, they will be in the rotation space of the character.")] public Transform positionOffsetSpace; public WeightCurve[] weightCurves; public Multiplier[] multipliers; public InteractionEvent[] events; private InteractionTarget[] targets = new InteractionTarget[0]; public float length { get; private set; } public InteractionSystem lastUsedInteractionSystem { get; private set; } public Transform lookAtTarget { get { if ((Object)(object)otherLookAtTarget != (Object)null) { return otherLookAtTarget; } return ((Component)this).transform; } } public Transform targetsRoot { get { if ((Object)(object)otherTargetsRoot != (Object)null) { return otherTargetsRoot; } return ((Component)this).transform; } } [ContextMenu("User Manual")] private void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page10.html"); } [ContextMenu("Scrpt Reference")] private void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_interaction_object.html"); } [ContextMenu("TUTORIAL VIDEO (PART 1: BASICS)")] private void OpenTutorial1() { Application.OpenURL("https://www.youtube.com/watch?v=r5jiZnsDH3M"); } [ContextMenu("TUTORIAL VIDEO (PART 2: PICKING UP...)")] private void OpenTutorial2() { Application.OpenURL("https://www.youtube.com/watch?v=eP9-zycoHLk"); } [ContextMenu("TUTORIAL VIDEO (PART 3: ANIMATION)")] private void OpenTutorial3() { Application.OpenURL("https://www.youtube.com/watch?v=sQfB2RcT1T4&index=14&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6"); } [ContextMenu("TUTORIAL VIDEO (PART 4: TRIGGERS)")] private void OpenTutorial4() { Application.OpenURL("https://www.youtube.com/watch?v=-TDZpNjt2mk&index=15&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public void Initiate() { for (int i = 0; i < weightCurves.Length; i++) { if (weightCurves[i].curve.length > 0) { float time = ((Keyframe)(ref weightCurves[i].curve.keys[weightCurves[i].curve.length - 1])).time; length = Mathf.Clamp(length, time, length); } } for (int j = 0; j < events.Length; j++) { length = Mathf.Clamp(length, events[j].time, length); } targets = ((Component)targetsRoot).GetComponentsInChildren(); } public InteractionTarget GetTarget(FullBodyBipedEffector effectorType, InteractionSystem interactionSystem) { if (((Component)interactionSystem).CompareTag(string.Empty) || ((Component)interactionSystem).CompareTag("")) { InteractionTarget[] array = targets; foreach (InteractionTarget interactionTarget in array) { if (interactionTarget.effectorType == effectorType) { return interactionTarget; } } return null; } InteractionTarget[] array2 = targets; foreach (InteractionTarget interactionTarget2 in array2) { if (interactionTarget2.effectorType == effectorType && ((Component)interactionTarget2).CompareTag(((Component)interactionSystem).tag)) { return interactionTarget2; } } return null; } public bool CurveUsed(WeightCurve.Type type) { WeightCurve[] array = weightCurves; foreach (WeightCurve weightCurve in array) { if (weightCurve.type == type) { return true; } } Multiplier[] array2 = multipliers; foreach (Multiplier multiplier in array2) { if (multiplier.result == type) { return true; } } return false; } public InteractionTarget[] GetTargets() { return targets; } public Transform GetTarget(FullBodyBipedEffector effectorType, string tag) { if (tag == string.Empty || tag == "") { return GetTarget(effectorType); } for (int i = 0; i < targets.Length; i++) { if (targets[i].effectorType == effectorType && ((Component)targets[i]).CompareTag(tag)) { return ((Component)targets[i]).transform; } } return ((Component)this).transform; } public void OnStartInteraction(InteractionSystem interactionSystem) { lastUsedInteractionSystem = interactionSystem; } public void Apply(IKSolverFullBodyBiped solver, FullBodyBipedEffector effector, InteractionTarget target, float timer, float weight) { for (int i = 0; i < weightCurves.Length; i++) { float num = ((!((Object)(object)target == (Object)null)) ? target.GetValue(weightCurves[i].type) : 1f); Apply(solver, effector, weightCurves[i].type, weightCurves[i].GetValue(timer), weight * num); } for (int j = 0; j < multipliers.Length; j++) { if (multipliers[j].curve == multipliers[j].result && !Warning.logged) { Warning.Log("InteractionObject Multiplier 'Curve' " + multipliers[j].curve.ToString() + "and 'Result' are the same.", ((Component)this).transform); } int weightCurveIndex = GetWeightCurveIndex(multipliers[j].curve); if (weightCurveIndex != -1) { float num2 = ((!((Object)(object)target == (Object)null)) ? target.GetValue(multipliers[j].result) : 1f); Apply(solver, effector, multipliers[j].result, multipliers[j].GetValue(weightCurves[weightCurveIndex], timer), weight * num2); } else if (!Warning.logged) { Warning.Log("InteractionObject Multiplier curve " + multipliers[j].curve.ToString() + "does not exist.", ((Component)this).transform); } } } public float GetValue(WeightCurve.Type weightCurveType, InteractionTarget target, float timer) { int weightCurveIndex = GetWeightCurveIndex(weightCurveType); if (weightCurveIndex != -1) { float num = ((!((Object)(object)target == (Object)null)) ? target.GetValue(weightCurveType) : 1f); return weightCurves[weightCurveIndex].GetValue(timer) * num; } for (int i = 0; i < multipliers.Length; i++) { if (multipliers[i].result == weightCurveType) { int weightCurveIndex2 = GetWeightCurveIndex(multipliers[i].curve); if (weightCurveIndex2 != -1) { float num2 = ((!((Object)(object)target == (Object)null)) ? target.GetValue(multipliers[i].result) : 1f); return multipliers[i].GetValue(weightCurves[weightCurveIndex2], timer) * num2; } } } return 0f; } private void Start() { Initiate(); } private void Apply(IKSolverFullBodyBiped solver, FullBodyBipedEffector effector, WeightCurve.Type type, float value, float weight) { //IL_0090: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_016c: 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_00cd: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) switch (type) { case WeightCurve.Type.PositionWeight: solver.GetEffector(effector).positionWeight = Mathf.Lerp(solver.GetEffector(effector).positionWeight, value, weight); break; case WeightCurve.Type.RotationWeight: solver.GetEffector(effector).rotationWeight = Mathf.Lerp(solver.GetEffector(effector).rotationWeight, value, weight); break; case WeightCurve.Type.PositionOffsetX: { IKEffector effector3 = solver.GetEffector(effector); effector3.position += ((!((Object)(object)positionOffsetSpace != (Object)null)) ? solver.GetRoot().rotation : positionOffsetSpace.rotation) * Vector3.right * value * weight; break; } case WeightCurve.Type.PositionOffsetY: { IKEffector effector4 = solver.GetEffector(effector); effector4.position += ((!((Object)(object)positionOffsetSpace != (Object)null)) ? solver.GetRoot().rotation : positionOffsetSpace.rotation) * Vector3.up * value * weight; break; } case WeightCurve.Type.PositionOffsetZ: { IKEffector effector2 = solver.GetEffector(effector); effector2.position += ((!((Object)(object)positionOffsetSpace != (Object)null)) ? solver.GetRoot().rotation : positionOffsetSpace.rotation) * Vector3.forward * value * weight; break; } case WeightCurve.Type.Pull: solver.GetChain(effector).pull = Mathf.Lerp(solver.GetChain(effector).pull, value, weight); break; case WeightCurve.Type.Reach: solver.GetChain(effector).reach = Mathf.Lerp(solver.GetChain(effector).reach, value, weight); break; case WeightCurve.Type.Push: solver.GetChain(effector).push = Mathf.Lerp(solver.GetChain(effector).push, value, weight); break; case WeightCurve.Type.PushParent: solver.GetChain(effector).pushParent = Mathf.Lerp(solver.GetChain(effector).pushParent, value, weight); break; case WeightCurve.Type.BendGoalWeight: solver.GetChain(effector).bendConstraint.weight = Mathf.Lerp(solver.GetChain(effector).bendConstraint.weight, value, weight); break; case WeightCurve.Type.RotateBoneWeight: case WeightCurve.Type.PoserWeight: break; } } private Transform GetTarget(FullBodyBipedEffector effectorType) { for (int i = 0; i < targets.Length; i++) { if (targets[i].effectorType == effectorType) { return ((Component)targets[i]).transform; } } return ((Component)this).transform; } private int GetWeightCurveIndex(WeightCurve.Type weightCurveType) { for (int i = 0; i < weightCurves.Length; i++) { if (weightCurves[i].type == weightCurveType) { return i; } } return -1; } private int GetMultiplierIndex(WeightCurve.Type weightCurveType) { for (int i = 0; i < multipliers.Length; i++) { if (multipliers[i].result == weightCurveType) { return i; } } return -1; } } [HelpURL("https://www.youtube.com/watch?v=r5jiZnsDH3M")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Interaction System/Interaction System")] public class InteractionSystem : MonoBehaviour { public delegate void InteractionDelegate(FullBodyBipedEffector effectorType, InteractionObject interactionObject); public delegate void InteractionEventDelegate(FullBodyBipedEffector effectorType, InteractionObject interactionObject, InteractionObject.InteractionEvent interactionEvent); [Tooltip("If not empty, only the targets with the specified tag will be used by this Interaction System.")] public string targetTag = ""; [Tooltip("The fade in time of the interaction.")] public float fadeInTime = 0.3f; [Tooltip("The master speed for all interactions.")] public float speed = 1f; [Tooltip("If > 0, lerps all the FBBIK channels used by the Interaction System back to their default or initial values when not in interaction.")] public float resetToDefaultsSpeed = 1f; [Header("Triggering")] [Tooltip("The collider that registers OnTriggerEnter and OnTriggerExit events with InteractionTriggers.")] [FormerlySerializedAs("collider")] public Collider characterCollider; [Tooltip("Will be used by Interaction Triggers that need the camera's position. Assign the first person view character camera.")] [FormerlySerializedAs("camera")] public Transform FPSCamera; [Tooltip("The layers that will be raycasted from the camera (along camera.forward). All InteractionTrigger look at target colliders should be included.")] public LayerMask camRaycastLayers; [Tooltip("Max distance of raycasting from the camera.")] public float camRaycastDistance = 1f; private List inContact = new List(); private List bestRangeIndexes = new List(); public InteractionDelegate OnInteractionStart; public InteractionDelegate OnInteractionPause; public InteractionDelegate OnInteractionPickUp; public InteractionDelegate OnInteractionResume; public InteractionDelegate OnInteractionStop; public InteractionEventDelegate OnInteractionEvent; public RaycastHit raycastHit; [Space(10f)] [Tooltip("Reference to the FBBIK component.")] [SerializeField] private FullBodyBipedIK fullBody; [Tooltip("Handles looking at the interactions.")] public InteractionLookAt lookAt = new InteractionLookAt(); private InteractionEffector[] interactionEffectors = new InteractionEffector[9] { new InteractionEffector(FullBodyBipedEffector.Body), new InteractionEffector(FullBodyBipedEffector.LeftFoot), new InteractionEffector(FullBodyBipedEffector.LeftHand), new InteractionEffector(FullBodyBipedEffector.LeftShoulder), new InteractionEffector(FullBodyBipedEffector.LeftThigh), new InteractionEffector(FullBodyBipedEffector.RightFoot), new InteractionEffector(FullBodyBipedEffector.RightHand), new InteractionEffector(FullBodyBipedEffector.RightShoulder), new InteractionEffector(FullBodyBipedEffector.RightThigh) }; private Collider lastCollider; private Collider c; public bool inInteraction { get { if (!IsValid(log: true)) { return false; } for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].inInteraction && !interactionEffectors[i].isPaused) { return true; } } return false; } } public FullBodyBipedIK ik { get { return fullBody; } set { fullBody = value; } } public List triggersInRange { get; private set; } public bool initiated { get; private set; } [ContextMenu("User Manual")] private void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page10.html"); } [ContextMenu("Scrpt Reference")] private void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_interaction_system.html"); } [ContextMenu("TUTORIAL VIDEO (PART 1: BASICS)")] private void OpenTutorial1() { Application.OpenURL("https://www.youtube.com/watch?v=r5jiZnsDH3M"); } [ContextMenu("TUTORIAL VIDEO (PART 2: PICKING UP...)")] private void OpenTutorial2() { Application.OpenURL("https://www.youtube.com/watch?v=eP9-zycoHLk"); } [ContextMenu("TUTORIAL VIDEO (PART 3: ANIMATION)")] private void OpenTutorial3() { Application.OpenURL("https://www.youtube.com/watch?v=sQfB2RcT1T4&index=14&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6"); } [ContextMenu("TUTORIAL VIDEO (PART 4: TRIGGERS)")] private void OpenTutorial4() { Application.OpenURL("https://www.youtube.com/watch?v=-TDZpNjt2mk&index=15&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6"); } [ContextMenu("Support")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public bool IsInInteraction(FullBodyBipedEffector effectorType) { if (!IsValid(log: true)) { return false; } for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].effectorType == effectorType) { return interactionEffectors[i].inInteraction && !interactionEffectors[i].isPaused; } } return false; } public bool IsPaused(FullBodyBipedEffector effectorType) { if (!IsValid(log: true)) { return false; } for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].effectorType == effectorType) { return interactionEffectors[i].inInteraction && interactionEffectors[i].isPaused; } } return false; } public bool IsPaused() { if (!IsValid(log: true)) { return false; } for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].inInteraction && interactionEffectors[i].isPaused) { return true; } } return false; } public bool IsInSync() { if (!IsValid(log: true)) { return false; } for (int i = 0; i < interactionEffectors.Length; i++) { if (!interactionEffectors[i].isPaused) { continue; } for (int j = 0; j < interactionEffectors.Length; j++) { if (j != i && interactionEffectors[j].inInteraction && !interactionEffectors[j].isPaused) { return false; } } } return true; } public bool StartInteraction(FullBodyBipedEffector effectorType, InteractionObject interactionObject, bool interrupt) { if (!IsValid(log: true)) { return false; } if ((Object)(object)interactionObject == (Object)null) { return false; } for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].effectorType == effectorType) { return interactionEffectors[i].Start(interactionObject, targetTag, fadeInTime, interrupt); } } return false; } public bool PauseInteraction(FullBodyBipedEffector effectorType) { if (!IsValid(log: true)) { return false; } for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].effectorType == effectorType) { return interactionEffectors[i].Pause(); } } return false; } public bool ResumeInteraction(FullBodyBipedEffector effectorType) { if (!IsValid(log: true)) { return false; } for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].effectorType == effectorType) { return interactionEffectors[i].Resume(); } } return false; } public bool StopInteraction(FullBodyBipedEffector effectorType) { if (!IsValid(log: true)) { return false; } for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].effectorType == effectorType) { return interactionEffectors[i].Stop(); } } return false; } public void PauseAll() { if (IsValid(log: true)) { for (int i = 0; i < interactionEffectors.Length; i++) { interactionEffectors[i].Pause(); } } } public void ResumeAll() { if (IsValid(log: true)) { for (int i = 0; i < interactionEffectors.Length; i++) { interactionEffectors[i].Resume(); } } } public void StopAll() { for (int i = 0; i < interactionEffectors.Length; i++) { interactionEffectors[i].Stop(); } } public InteractionObject GetInteractionObject(FullBodyBipedEffector effectorType) { if (!IsValid(log: true)) { return null; } for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].effectorType == effectorType) { return interactionEffectors[i].interactionObject; } } return null; } public float GetProgress(FullBodyBipedEffector effectorType) { if (!IsValid(log: true)) { return 0f; } for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].effectorType == effectorType) { return interactionEffectors[i].progress; } } return 0f; } public float GetMinActiveProgress() { if (!IsValid(log: true)) { return 0f; } float num = 1f; for (int i = 0; i < interactionEffectors.Length; i++) { if (interactionEffectors[i].inInteraction) { float progress = interactionEffectors[i].progress; if (progress > 0f && progress < num) { num = progress; } } } return num; } public bool TriggerInteraction(int index, bool interrupt) { if (!IsValid(log: true)) { return false; } if (!TriggerIndexIsValid(index)) { return false; } bool result = true; InteractionTrigger.Range range = triggersInRange[index].ranges[bestRangeIndexes[index]]; for (int i = 0; i < range.interactions.Length; i++) { for (int j = 0; j < range.interactions[i].effectors.Length; j++) { if (!StartInteraction(range.interactions[i].effectors[j], range.interactions[i].interactionObject, interrupt)) { result = false; } } } return result; } public bool TriggerInteraction(int index, bool interrupt, out InteractionObject interactionObject) { interactionObject = null; if (!IsValid(log: true)) { return false; } if (!TriggerIndexIsValid(index)) { return false; } bool result = true; InteractionTrigger.Range range = triggersInRange[index].ranges[bestRangeIndexes[index]]; for (int i = 0; i < range.interactions.Length; i++) { for (int j = 0; j < range.interactions[i].effectors.Length; j++) { interactionObject = range.interactions[i].interactionObject; if (!StartInteraction(range.interactions[i].effectors[j], interactionObject, interrupt)) { result = false; } } } return result; } public bool TriggerInteraction(int index, bool interrupt, out InteractionTarget interactionTarget) { interactionTarget = null; if (!IsValid(log: true)) { return false; } if (!TriggerIndexIsValid(index)) { return false; } bool result = true; InteractionTrigger.Range range = triggersInRange[index].ranges[bestRangeIndexes[index]]; for (int i = 0; i < range.interactions.Length; i++) { for (int j = 0; j < range.interactions[i].effectors.Length; j++) { InteractionObject interactionObject = range.interactions[i].interactionObject; Transform target = interactionObject.GetTarget(range.interactions[i].effectors[j], ((Component)this).tag); if ((Object)(object)target != (Object)null) { interactionTarget = ((Component)target).GetComponent(); } if (!StartInteraction(range.interactions[i].effectors[j], interactionObject, interrupt)) { result = false; } } } return result; } public InteractionTrigger.Range GetClosestInteractionRange() { if (!IsValid(log: true)) { return null; } int closestTriggerIndex = GetClosestTriggerIndex(); if (closestTriggerIndex < 0 || closestTriggerIndex >= triggersInRange.Count) { return null; } return triggersInRange[closestTriggerIndex].ranges[bestRangeIndexes[closestTriggerIndex]]; } public InteractionObject GetClosestInteractionObjectInRange() { InteractionTrigger.Range closestInteractionRange = GetClosestInteractionRange(); if (closestInteractionRange == null) { return null; } return closestInteractionRange.interactions[0].interactionObject; } public InteractionTarget GetClosestInteractionTargetInRange() { InteractionTrigger.Range closestInteractionRange = GetClosestInteractionRange(); if (closestInteractionRange == null) { return null; } return closestInteractionRange.interactions[0].interactionObject.GetTarget(closestInteractionRange.interactions[0].effectors[0], this); } public InteractionObject[] GetClosestInteractionObjectsInRange() { InteractionTrigger.Range closestInteractionRange = GetClosestInteractionRange(); if (closestInteractionRange == null) { return new InteractionObject[0]; } InteractionObject[] array = new InteractionObject[closestInteractionRange.interactions.Length]; for (int i = 0; i < closestInteractionRange.interactions.Length; i++) { array[i] = closestInteractionRange.interactions[i].interactionObject; } return array; } public InteractionTarget[] GetClosestInteractionTargetsInRange() { InteractionTrigger.Range closestInteractionRange = GetClosestInteractionRange(); if (closestInteractionRange == null) { return new InteractionTarget[0]; } List list = new List(); InteractionTrigger.Range.Interaction[] interactions = closestInteractionRange.interactions; foreach (InteractionTrigger.Range.Interaction interaction in interactions) { FullBodyBipedEffector[] effectors = interaction.effectors; foreach (FullBodyBipedEffector effectorType in effectors) { list.Add(interaction.interactionObject.GetTarget(effectorType, this)); } } return list.ToArray(); } public bool TriggerEffectorsReady(int index) { if (!IsValid(log: true)) { return false; } if (!TriggerIndexIsValid(index)) { return false; } for (int i = 0; i < triggersInRange[index].ranges.Length; i++) { InteractionTrigger.Range range = triggersInRange[index].ranges[i]; for (int j = 0; j < range.interactions.Length; j++) { for (int k = 0; k < range.interactions[j].effectors.Length; k++) { if (IsInInteraction(range.interactions[j].effectors[k])) { return false; } } } for (int l = 0; l < range.interactions.Length; l++) { for (int m = 0; m < range.interactions[l].effectors.Length; m++) { if (!IsPaused(range.interactions[l].effectors[m])) { continue; } for (int n = 0; n < range.interactions[l].effectors.Length; n++) { if (n != m && !IsPaused(range.interactions[l].effectors[n])) { return false; } } } } } return true; } public InteractionTrigger.Range GetTriggerRange(int index) { if (!IsValid(log: true)) { return null; } if (index < 0 || index >= bestRangeIndexes.Count) { Warning.Log("Index out of range.", ((Component)this).transform); return null; } return triggersInRange[index].ranges[bestRangeIndexes[index]]; } public int GetClosestTriggerIndex() { //IL_007c: 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) if (!IsValid(log: true)) { return -1; } if (triggersInRange.Count == 0) { return -1; } if (triggersInRange.Count == 1) { return 0; } int result = -1; float num = float.PositiveInfinity; for (int i = 0; i < triggersInRange.Count; i++) { if ((Object)(object)triggersInRange[i] != (Object)null) { float num2 = Vector3.SqrMagnitude(((Component)triggersInRange[i]).transform.position - ((Component)this).transform.position); if (num2 < num) { result = i; num = num2; } } } return result; } public void Start() { if ((Object)(object)fullBody == (Object)null) { fullBody = ((Component)this).GetComponent(); } if ((Object)(object)fullBody == (Object)null) { Warning.Log("InteractionSystem can not find a FullBodyBipedIK component", ((Component)this).transform); return; } IKSolverFullBodyBiped solver = fullBody.solver; solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPreUpdate, new IKSolver.UpdateDelegate(OnPreFBBIK)); IKSolverFullBodyBiped solver2 = fullBody.solver; solver2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver2.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostFBBIK)); IKSolverFullBodyBiped solver3 = fullBody.solver; solver3.OnFixTransforms = (IKSolver.UpdateDelegate)Delegate.Combine(solver3.OnFixTransforms, new IKSolver.UpdateDelegate(OnFixTransforms)); OnInteractionStart = (InteractionDelegate)Delegate.Combine(OnInteractionStart, new InteractionDelegate(LookAtInteraction)); OnInteractionPause = (InteractionDelegate)Delegate.Combine(OnInteractionPause, new InteractionDelegate(InteractionPause)); OnInteractionResume = (InteractionDelegate)Delegate.Combine(OnInteractionResume, new InteractionDelegate(InteractionResume)); OnInteractionStop = (InteractionDelegate)Delegate.Combine(OnInteractionStop, new InteractionDelegate(InteractionStop)); InteractionEffector[] array = interactionEffectors; foreach (InteractionEffector interactionEffector in array) { interactionEffector.Initiate(this); } triggersInRange = new List(); c = ((Component)this).GetComponent(); UpdateTriggerEventBroadcasting(); initiated = true; } private void InteractionPause(FullBodyBipedEffector effector, InteractionObject interactionObject) { lookAt.isPaused = true; } private void InteractionResume(FullBodyBipedEffector effector, InteractionObject interactionObject) { lookAt.isPaused = false; } private void InteractionStop(FullBodyBipedEffector effector, InteractionObject interactionObject) { lookAt.isPaused = false; } private void LookAtInteraction(FullBodyBipedEffector effector, InteractionObject interactionObject) { lookAt.Look(interactionObject.lookAtTarget, Time.time + interactionObject.length * 0.5f); } public void OnTriggerEnter(Collider c) { if (!((Object)(object)fullBody == (Object)null)) { InteractionTrigger component = ((Component)c).GetComponent(); if (!((Object)(object)component == (Object)null) && !inContact.Contains(component)) { inContact.Add(component); } } } public void OnTriggerExit(Collider c) { if (!((Object)(object)fullBody == (Object)null)) { InteractionTrigger component = ((Component)c).GetComponent(); if (!((Object)(object)component == (Object)null)) { inContact.Remove(component); } } } private bool ContactIsInRange(int index, out int bestRangeIndex) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) bestRangeIndex = -1; if (!IsValid(log: true)) { return false; } if (index < 0 || index >= inContact.Count) { Warning.Log("Index out of range.", ((Component)this).transform); return false; } if ((Object)(object)inContact[index] == (Object)null) { Warning.Log("The InteractionTrigger in the list 'inContact' has been destroyed", ((Component)this).transform); return false; } bestRangeIndex = inContact[index].GetBestRangeIndex(((Component)this).transform, FPSCamera, raycastHit); if (bestRangeIndex == -1) { return false; } return true; } private void OnDrawGizmosSelected() { if (!Application.isPlaying) { if ((Object)(object)fullBody == (Object)null) { fullBody = ((Component)this).GetComponent(); } if ((Object)(object)characterCollider == (Object)null) { characterCollider = ((Component)this).GetComponent(); } } } public void Update() { if ((Object)(object)fullBody == (Object)null) { return; } UpdateTriggerEventBroadcasting(); Raycasting(); triggersInRange.Clear(); bestRangeIndexes.Clear(); for (int i = 0; i < inContact.Count; i++) { int bestRangeIndex = -1; if ((Object)(object)inContact[i] != (Object)null && ((Component)inContact[i]).gameObject.activeInHierarchy && ContactIsInRange(i, out bestRangeIndex)) { triggersInRange.Add(inContact[i]); bestRangeIndexes.Add(bestRangeIndex); } } lookAt.Update(); } private void Raycasting() { //IL_0002: 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_003e: 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 (LayerMask.op_Implicit(camRaycastLayers) != -1 && !((Object)(object)FPSCamera == (Object)null)) { Physics.Raycast(FPSCamera.position, FPSCamera.forward, ref raycastHit, camRaycastDistance, LayerMask.op_Implicit(camRaycastLayers)); } } private void UpdateTriggerEventBroadcasting() { if ((Object)(object)characterCollider == (Object)null) { characterCollider = c; } if ((Object)(object)characterCollider != (Object)null && (Object)(object)characterCollider != (Object)(object)c) { if ((Object)(object)((Component)characterCollider).GetComponent() == (Object)null) { TriggerEventBroadcaster triggerEventBroadcaster = ((Component)characterCollider).gameObject.AddComponent(); triggerEventBroadcaster.target = ((Component)this).gameObject; } if ((Object)(object)lastCollider != (Object)null && (Object)(object)lastCollider != (Object)(object)c && (Object)(object)lastCollider != (Object)(object)characterCollider) { TriggerEventBroadcaster component = ((Component)lastCollider).GetComponent(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } } } lastCollider = characterCollider; } private void UpdateEffectors() { if (!((Object)(object)fullBody == (Object)null)) { for (int i = 0; i < interactionEffectors.Length; i++) { interactionEffectors[i].Update(((Component)this).transform, speed); } for (int j = 0; j < interactionEffectors.Length; j++) { interactionEffectors[j].ResetToDefaults(resetToDefaultsSpeed * speed); } } } private void OnPreFBBIK() { if (!((Object)(object)fullBody == (Object)null)) { lookAt.SolveSpine(); UpdateEffectors(); } } private void OnPostFBBIK() { if (!((Object)(object)fullBody == (Object)null)) { for (int i = 0; i < interactionEffectors.Length; i++) { interactionEffectors[i].OnPostFBBIK(); } lookAt.SolveHead(); } } private void OnFixTransforms() { lookAt.OnFixTransforms(); } private void OnDestroy() { if (!((Object)(object)fullBody == (Object)null)) { IKSolverFullBodyBiped solver = fullBody.solver; solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPreUpdate, new IKSolver.UpdateDelegate(OnPreFBBIK)); IKSolverFullBodyBiped solver2 = fullBody.solver; solver2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver2.OnPostUpdate, new IKSolver.UpdateDelegate(OnPostFBBIK)); IKSolverFullBodyBiped solver3 = fullBody.solver; solver3.OnFixTransforms = (IKSolver.UpdateDelegate)Delegate.Remove(solver3.OnFixTransforms, new IKSolver.UpdateDelegate(OnFixTransforms)); OnInteractionStart = (InteractionDelegate)Delegate.Remove(OnInteractionStart, new InteractionDelegate(LookAtInteraction)); OnInteractionPause = (InteractionDelegate)Delegate.Remove(OnInteractionPause, new InteractionDelegate(InteractionPause)); OnInteractionResume = (InteractionDelegate)Delegate.Remove(OnInteractionResume, new InteractionDelegate(InteractionResume)); OnInteractionStop = (InteractionDelegate)Delegate.Remove(OnInteractionStop, new InteractionDelegate(InteractionStop)); } } private bool IsValid(bool log) { if ((Object)(object)fullBody == (Object)null) { if (log) { Warning.Log("FBBIK is null. Will not update the InteractionSystem", ((Component)this).transform); } return false; } if (!initiated) { if (log) { Warning.Log("The InteractionSystem has not been initiated yet.", ((Component)this).transform); } return false; } return true; } private bool TriggerIndexIsValid(int index) { if (index < 0 || index >= triggersInRange.Count) { Warning.Log("Index out of range.", ((Component)this).transform); return false; } if ((Object)(object)triggersInRange[index] == (Object)null) { Warning.Log("The InteractionTrigger in the list 'inContact' has been destroyed", ((Component)this).transform); return false; } return true; } } [HelpURL("https://www.youtube.com/watch?v=r5jiZnsDH3M")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Interaction System/Interaction Target")] public class InteractionTarget : MonoBehaviour { [Serializable] public enum RotationMode { TwoDOF, ThreeDOF } [Serializable] public class Multiplier { [Tooltip("The curve type (InteractionObject.WeightCurve.Type).")] public InteractionObject.WeightCurve.Type curve; [Tooltip("Multiplier of the curve's value.")] public float multiplier; } [Tooltip("The type of the FBBIK effector.")] public FullBodyBipedEffector effectorType; [Tooltip("InteractionObject weight curve multipliers for this effector target.")] public Multiplier[] multipliers; [Tooltip("The interaction speed multiplier for this effector. This can be used to make interactions faster/slower for specific effectors.")] public float interactionSpeedMlp = 1f; [Tooltip("The pivot to twist/swing this interaction target about. For symmetric objects that can be interacted with from a certain angular range.")] public Transform pivot; [Tooltip("2 or 3 degrees of freedom to match this InteractionTarget's rotation to the effector bone rotation.")] public RotationMode rotationMode; [Tooltip("The axis of twisting the interaction target (blue line).")] public Vector3 twistAxis = Vector3.up; [Tooltip("The weight of twisting the interaction target towards the effector bone in the start of the interaction.")] public float twistWeight = 1f; [Tooltip("The weight of swinging the interaction target towards the effector bone in the start of the interaction. Swing is defined as a 3-DOF rotation around any axis, while twist is only around the twist axis.")] public float swingWeight; [Tooltip("The weight of rotating this InteractionTarget to the effector bone in the start of the interaction (and during if 'Rotate Once' is disabled")] [Range(0f, 1f)] public float threeDOFWeight = 1f; [Tooltip("If true, will twist/swing around the pivot only once at the start of the interaction. If false, will continue rotating throuout the whole interaction.")] public bool rotateOnce = true; private Quaternion defaultLocalRotation; private Transform lastPivot; [ContextMenu("User Manual")] private void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page10.html"); } [ContextMenu("Scrpt Reference")] private void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_interaction_target.html"); } [ContextMenu("TUTORIAL VIDEO (PART 1: BASICS)")] private void OpenTutorial1() { Application.OpenURL("https://www.youtube.com/watch?v=r5jiZnsDH3M"); } [ContextMenu("TUTORIAL VIDEO (PART 2: PICKING UP...)")] private void OpenTutorial2() { Application.OpenURL("https://www.youtube.com/watch?v=eP9-zycoHLk"); } [ContextMenu("TUTORIAL VIDEO (PART 3: ANIMATION)")] private void OpenTutorial3() { Application.OpenURL("https://www.youtube.com/watch?v=sQfB2RcT1T4&index=14&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6"); } [ContextMenu("TUTORIAL VIDEO (PART 4: TRIGGERS)")] private void OpenTutorial4() { Application.OpenURL("https://www.youtube.com/watch?v=-TDZpNjt2mk&index=15&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public float GetValue(InteractionObject.WeightCurve.Type curveType) { for (int i = 0; i < multipliers.Length; i++) { if (multipliers[i].curve == curveType) { return multipliers[i].multiplier; } } return 1f; } public void ResetRotation() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)pivot != (Object)null) { pivot.localRotation = defaultLocalRotation; } } public void RotateTo(Transform bone) { //IL_0053: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)pivot == (Object)null) { return; } if ((Object)(object)pivot != (Object)(object)lastPivot) { defaultLocalRotation = pivot.localRotation; lastPivot = pivot; } pivot.localRotation = defaultLocalRotation; switch (rotationMode) { case RotationMode.TwoDOF: if (twistWeight > 0f) { Vector3 fromDirection = ((Component)this).transform.position - pivot.position; Vector3 val2 = pivot.rotation * twistAxis; Vector3 val3 = val2; Vector3.OrthoNormalize(ref val3, ref fromDirection); val3 = val2; Vector3 toDirection = bone.position - pivot.position; Vector3.OrthoNormalize(ref val3, ref toDirection); Quaternion val4 = QuaTools.FromToAroundAxis(fromDirection, toDirection, val2); pivot.rotation = Quaternion.Lerp(Quaternion.identity, val4, twistWeight) * pivot.rotation; } if (swingWeight > 0f) { Quaternion val5 = Quaternion.FromToRotation(((Component)this).transform.position - pivot.position, bone.position - pivot.position); pivot.rotation = Quaternion.Lerp(Quaternion.identity, val5, swingWeight) * pivot.rotation; } break; case RotationMode.ThreeDOF: if (!(threeDOFWeight <= 0f)) { Quaternion val = QuaTools.FromToRotation(((Component)this).transform.rotation, bone.rotation); if (threeDOFWeight >= 1f) { pivot.rotation = val * pivot.rotation; } else { pivot.rotation = Quaternion.Slerp(Quaternion.identity, val, threeDOFWeight) * pivot.rotation; } } break; } } } [HelpURL("https://www.youtube.com/watch?v=-TDZpNjt2mk&index=15&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Interaction System/Interaction Trigger")] public class InteractionTrigger : MonoBehaviour { [Serializable] public class CharacterPosition { [Tooltip("If false, will not care where the character stands, as long as it is in contact with the trigger collider.")] public bool use; [Tooltip("The offset of the character's position relative to the trigger in XZ plane. Y position of the character is unlimited as long as it is contact with the collider.")] public Vector2 offset; [Tooltip("Angle offset from the default forward direction.")] [Range(-180f, 180f)] public float angleOffset; [Tooltip("Max angular offset of the character's forward from the direction of this trigger.")] [Range(0f, 180f)] public float maxAngle = 45f; [Tooltip("Max offset of the character's position from this range's center.")] public float radius = 0.5f; [Tooltip("If true, will rotate the trigger around it's Y axis relative to the position of the character, so the object can be interacted with from all sides.")] public bool orbit; [Tooltip("Fixes the Y axis of the trigger to Vector3.up. This makes the trigger symmetrical relative to the object. For example a gun will be able to be picked up from the same direction relative to the barrel no matter which side the gun is resting on.")] public bool fixYAxis; public Vector3 offset3D => new Vector3(offset.x, 0f, offset.y); public Vector3 direction3D => Quaternion.AngleAxis(angleOffset, Vector3.up) * Vector3.forward; public bool IsInRange(Transform character, Transform trigger, out float error) { //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_006d: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d7: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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) //IL_0217: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: 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) error = 0f; if (!use) { return true; } error = 180f; if (radius <= 0f) { return false; } if (maxAngle <= 0f) { return false; } Vector3 forward = trigger.forward; if (fixYAxis) { forward.y = 0f; } if (forward == Vector3.zero) { return false; } Vector3 val = ((!fixYAxis) ? trigger.up : Vector3.up); Quaternion val2 = Quaternion.LookRotation(forward, val); Vector3 val3 = trigger.position + val2 * offset3D; Vector3 val4 = ((!orbit) ? val3 : trigger.position); Vector3 val5 = character.position - val4; Vector3.OrthoNormalize(ref val, ref val5); Vector3 val6 = val5; Vector3 val7 = Vector3.Project(character.position - val4, val5); val5 = val6 * ((Vector3)(ref val7)).magnitude; if (orbit) { float magnitude = ((Vector2)(ref offset)).magnitude; float magnitude2 = ((Vector3)(ref val5)).magnitude; if (magnitude2 < magnitude - radius || magnitude2 > magnitude + radius) { return false; } } else if (((Vector3)(ref val5)).magnitude > radius) { return false; } Vector3 val8 = val2 * direction3D; Vector3.OrthoNormalize(ref val, ref val8); if (orbit) { Vector3 val9 = val3 - trigger.position; if (val9 == Vector3.zero) { val9 = Vector3.forward; } Quaternion val10 = Quaternion.LookRotation(val9, val); val5 = Quaternion.Inverse(val10) * val5; float num = Mathf.Atan2(val5.x, val5.z) * 57.29578f; val8 = Quaternion.AngleAxis(num, val) * val8; } float num2 = Vector3.Angle(val8, character.forward); if (num2 > maxAngle) { return false; } error = num2 / maxAngle * 180f; return true; } } [Serializable] public class CameraPosition { [Tooltip("What the camera should be looking at to trigger the interaction? If null, this camera position will not be used.")] public Collider lookAtTarget; [Tooltip("The direction from the lookAtTarget towards the camera (in lookAtTarget's space).")] public Vector3 direction = -Vector3.forward; [Tooltip("Max distance from the lookAtTarget to the camera.")] public float maxDistance = 0.5f; [Tooltip("Max angle between the direction and the direction towards the camera.")] [Range(0f, 180f)] public float maxAngle = 45f; [Tooltip("Fixes the Y axis of the trigger to Vector3.up. This makes the trigger symmetrical relative to the object.")] public bool fixYAxis; public Quaternion GetRotation() { //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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0064: 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_0077: 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_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_0071: Unknown result type (might be due to invalid IL or missing references) Vector3 forward = ((Component)lookAtTarget).transform.forward; if (fixYAxis) { forward.y = 0f; } if (forward == Vector3.zero) { return Quaternion.identity; } Vector3 val = ((!fixYAxis) ? ((Component)lookAtTarget).transform.up : Vector3.up); return Quaternion.LookRotation(forward, val); } public bool IsInRange(Transform raycastFrom, RaycastHit hit, Transform trigger, out float error) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) error = 0f; if ((Object)(object)lookAtTarget == (Object)null) { return true; } error = 180f; if ((Object)(object)raycastFrom == (Object)null) { return false; } if ((Object)(object)((RaycastHit)(ref hit)).collider != (Object)(object)lookAtTarget) { return false; } if (((RaycastHit)(ref hit)).distance > maxDistance) { return false; } if (direction == Vector3.zero) { return false; } if (maxDistance <= 0f) { return false; } if (maxAngle <= 0f) { return false; } Vector3 val = GetRotation() * direction; float num = Vector3.Angle(raycastFrom.position - ((RaycastHit)(ref hit)).point, val); if (num > maxAngle) { return false; } error = num / maxAngle * 180f; return true; } } [Serializable] public class Range { [Serializable] public class Interaction { [Tooltip("The InteractionObject to interact with.")] public InteractionObject interactionObject; [Tooltip("The effectors to interact with.")] public FullBodyBipedEffector[] effectors; } [HideInInspector] public string name; [HideInInspector] public bool show = true; [Tooltip("The range for the character's position and rotation.")] public CharacterPosition characterPosition; [Tooltip("The range for the character camera's position and rotation.")] public CameraPosition cameraPosition; [Tooltip("Definitions of the interactions associated with this range.")] public Interaction[] interactions; public bool IsInRange(Transform character, Transform raycastFrom, RaycastHit raycastHit, Transform trigger, out float maxError) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) maxError = 0f; float error = 0f; float error2 = 0f; if (!characterPosition.IsInRange(character, trigger, out error)) { return false; } if (!cameraPosition.IsInRange(raycastFrom, raycastHit, trigger, out error2)) { return false; } maxError = Mathf.Max(error, error2); return true; } } [Tooltip("The valid ranges of the character's and/or it's camera's position for triggering interaction when the character is in contact with the collider of this trigger.")] public Range[] ranges = new Range[0]; [ContextMenu("User Manual")] private void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page10.html"); } [ContextMenu("Scrpt Reference")] private void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_interaction_trigger.html"); } [ContextMenu("TUTORIAL VIDEO")] private void OpenTutorial4() { Application.OpenURL("https://www.youtube.com/watch?v=-TDZpNjt2mk&index=15&list=PLVxSIA1OaTOu8Nos3CalXbJ2DrKnntMv6"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public int GetBestRangeIndex(Transform character, Transform raycastFrom, RaycastHit raycastHit) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)this).GetComponent() == (Object)null) { Warning.Log("Using the InteractionTrigger requires a Collider component.", ((Component)this).transform); return -1; } int result = -1; float num = 180f; float maxError = 0f; for (int i = 0; i < ranges.Length; i++) { if (ranges[i].IsInRange(character, raycastFrom, raycastHit, ((Component)this).transform, out maxError) && maxError <= num) { num = maxError; result = i; } } return result; } } public class GenericPoser : Poser { [Serializable] public class Map { public Transform bone; public Transform target; private Vector3 defaultLocalPosition; private Quaternion defaultLocalRotation; public Map(Transform bone, Transform target) { this.bone = bone; this.target = target; StoreDefaultState(); } public void StoreDefaultState() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) defaultLocalPosition = bone.localPosition; defaultLocalRotation = bone.localRotation; } public void FixTransform() { //IL_0008: 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) bone.localPosition = defaultLocalPosition; bone.localRotation = defaultLocalRotation; } public void Update(float localRotationWeight, float localPositionWeight) { //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_001e: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) bone.localRotation = Quaternion.Lerp(bone.localRotation, target.localRotation, localRotationWeight); bone.localPosition = Vector3.Lerp(bone.localPosition, target.localPosition, localPositionWeight); } } public Map[] maps; [ContextMenu("Auto-Mapping")] public override void AutoMapping() { if ((Object)(object)poseRoot == (Object)null) { maps = new Map[0]; return; } maps = new Map[0]; Transform[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren(); Transform[] componentsInChildren2 = ((Component)poseRoot).GetComponentsInChildren(); for (int i = 1; i < componentsInChildren.Length; i++) { Transform targetNamed = GetTargetNamed(((Object)componentsInChildren[i]).name, componentsInChildren2); if ((Object)(object)targetNamed != (Object)null) { Array.Resize(ref maps, maps.Length + 1); maps[maps.Length - 1] = new Map(componentsInChildren[i], targetNamed); } } StoreDefaultState(); } protected override void InitiatePoser() { StoreDefaultState(); } protected override void UpdatePoser() { if (!(weight <= 0f) && (!(localPositionWeight <= 0f) || !(localRotationWeight <= 0f)) && !((Object)(object)poseRoot == (Object)null)) { float num = localRotationWeight * weight; float num2 = localPositionWeight * weight; for (int i = 0; i < maps.Length; i++) { maps[i].Update(num, num2); } } } protected override void FixPoserTransforms() { for (int i = 0; i < maps.Length; i++) { maps[i].FixTransform(); } } private void StoreDefaultState() { for (int i = 0; i < maps.Length; i++) { maps[i].StoreDefaultState(); } } private Transform GetTargetNamed(string tName, Transform[] array) { for (int i = 0; i < array.Length; i++) { if (((Object)array[i]).name == tName) { return array[i]; } } return null; } } public class HandPoser : Poser { protected Transform[] children; private Transform _poseRoot; private Transform[] poseChildren; private Vector3[] defaultLocalPositions; private Quaternion[] defaultLocalRotations; public override void AutoMapping() { if ((Object)(object)poseRoot == (Object)null) { poseChildren = (Transform[])(object)new Transform[0]; } else { poseChildren = ((Component)poseRoot).GetComponentsInChildren(); } _poseRoot = poseRoot; } protected override void InitiatePoser() { children = ((Component)this).GetComponentsInChildren(); StoreDefaultState(); } protected override void FixPoserTransforms() { //IL_001d: 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) for (int i = 0; i < children.Length; i++) { children[i].localPosition = defaultLocalPositions[i]; children[i].localRotation = defaultLocalRotations[i]; } } protected override void UpdatePoser() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f || (localPositionWeight <= 0f && localRotationWeight <= 0f)) { return; } if ((Object)(object)_poseRoot != (Object)(object)poseRoot) { AutoMapping(); } if ((Object)(object)poseRoot == (Object)null) { return; } if (children.Length != poseChildren.Length) { Warning.Log("Number of children does not match with the pose", ((Component)this).transform); return; } float num = localRotationWeight * weight; float num2 = localPositionWeight * weight; for (int i = 0; i < children.Length; i++) { if ((Object)(object)children[i] != (Object)(object)((Component)this).transform) { children[i].localRotation = Quaternion.Lerp(children[i].localRotation, poseChildren[i].localRotation, num); children[i].localPosition = Vector3.Lerp(children[i].localPosition, poseChildren[i].localPosition, num2); } } } protected void StoreDefaultState() { //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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) defaultLocalPositions = (Vector3[])(object)new Vector3[children.Length]; defaultLocalRotations = (Quaternion[])(object)new Quaternion[children.Length]; for (int i = 0; i < children.Length; i++) { ref Vector3 reference = ref defaultLocalPositions[i]; reference = children[i].localPosition; ref Quaternion reference2 = ref defaultLocalRotations[i]; reference2 = children[i].localRotation; } } } public abstract class Poser : SolverManager { public Transform poseRoot; [Range(0f, 1f)] public float weight = 1f; [Range(0f, 1f)] public float localRotationWeight = 1f; [Range(0f, 1f)] public float localPositionWeight; private bool initiated; public abstract void AutoMapping(); public void UpdateManual() { UpdatePoser(); } protected abstract void InitiatePoser(); protected abstract void UpdatePoser(); protected abstract void FixPoserTransforms(); protected override void UpdateSolver() { if (!initiated) { InitiateSolver(); } if (initiated) { UpdatePoser(); } } protected override void InitiateSolver() { if (!initiated) { InitiatePoser(); initiated = true; } } protected override void FixTransforms() { if (initiated) { FixPoserTransforms(); } } } public class RagdollUtility : MonoBehaviour { public class Rigidbone { public Rigidbody r; public Transform t; public Collider collider; public Joint joint; public Rigidbody c; public bool updateAnchor; public Vector3 deltaPosition; public Quaternion deltaRotation; public float deltaTime; public Vector3 lastPosition; public Quaternion lastRotation; public Rigidbone(Rigidbody r) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) this.r = r; t = ((Component)r).transform; joint = ((Component)t).GetComponent(); collider = ((Component)t).GetComponent(); if ((Object)(object)joint != (Object)null) { c = joint.connectedBody; updateAnchor = (Object)(object)c != (Object)null; } lastPosition = t.position; lastRotation = t.rotation; } public void RecordVelocity() { //IL_0008: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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) deltaPosition = t.position - lastPosition; lastPosition = t.position; deltaRotation = QuaTools.FromToRotation(lastRotation, t.rotation); lastRotation = t.rotation; deltaTime = Time.deltaTime; } public void WakeUp(float velocityWeight, float angularVelocityWeight) { //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_004e: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (updateAnchor) { joint.connectedAnchor = t.InverseTransformPoint(c.position); } r.isKinematic = false; if (velocityWeight != 0f) { r.velocity = deltaPosition / deltaTime * velocityWeight; } if (angularVelocityWeight != 0f) { float num = 0f; Vector3 zero = Vector3.zero; ((Quaternion)(ref deltaRotation)).ToAngleAxis(ref num, ref zero); num *= (float)Math.PI / 180f; num /= deltaTime; zero *= num * angularVelocityWeight; r.angularVelocity = Vector3.ClampMagnitude(zero, r.maxAngularVelocity); } r.WakeUp(); } } public class Child { public Transform t; public Vector3 localPosition; public Quaternion localRotation; public Child(Transform transform) { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) t = transform; localPosition = t.localPosition; localRotation = t.localRotation; } public void FixTransform(float weight) { //IL_0050: 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_005c: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!(weight <= 0f)) { if (weight >= 1f) { t.localPosition = localPosition; t.localRotation = localRotation; } else { t.localPosition = Vector3.Lerp(t.localPosition, localPosition, weight); t.localRotation = Quaternion.Lerp(t.localRotation, localRotation, weight); } } } public void StoreLocalState() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) localPosition = t.localPosition; localRotation = t.localRotation; } } [Tooltip("If you have multiple IK components, then this should be the one that solves last each frame.")] public IK ik; [Tooltip("How long does it take to blend from ragdoll to animation?")] public float ragdollToAnimationTime = 0.2f; [Tooltip("If true, IK can be used on top of physical ragdoll simulation.")] public bool applyIkOnRagdoll; [Tooltip("How much velocity transfer from animation to ragdoll?")] public float applyVelocity = 1f; [Tooltip("How much angular velocity to transfer from animation to ragdoll?")] public float applyAngularVelocity = 1f; private Animator animator; private Rigidbone[] rigidbones = new Rigidbone[0]; private Child[] children = new Child[0]; private bool enableRagdollFlag; private AnimatorUpdateMode animatorUpdateMode; private IK[] allIKComponents = new IK[0]; private bool[] fixTransforms = new bool[0]; private float ragdollWeight; private float ragdollWeightV; private bool fixedFrame; private bool[] disabledIKComponents = new bool[0]; private bool isRagdoll => !rigidbones[0].r.isKinematic && !((Behaviour)animator).enabled; private bool ikUsed { get { if ((Object)(object)ik == (Object)null) { return false; } if (((Behaviour)ik).enabled && ik.GetIKSolver().IKPositionWeight > 0f) { return true; } IK[] array = allIKComponents; foreach (IK iK in array) { if (((Behaviour)iK).enabled && iK.GetIKSolver().IKPositionWeight > 0f) { return true; } } return false; } } public void EnableRagdoll() { if (!isRagdoll) { ((MonoBehaviour)this).StopAllCoroutines(); enableRagdollFlag = true; } } public void DisableRagdoll() { if (isRagdoll) { StoreLocalState(); ((MonoBehaviour)this).StopAllCoroutines(); ((MonoBehaviour)this).StartCoroutine(DisableRagdollSmooth()); } } public void Start() { animator = ((Component)this).GetComponent(); allIKComponents = ((Component)this).GetComponentsInChildren(); disabledIKComponents = new bool[allIKComponents.Length]; fixTransforms = new bool[allIKComponents.Length]; if ((Object)(object)ik != (Object)null) { IKSolver iKSolver = ik.GetIKSolver(); iKSolver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(iKSolver.OnPostUpdate, new IKSolver.UpdateDelegate(AfterLastIK)); } Rigidbody[] componentsInChildren = ((Component)this).GetComponentsInChildren(); int num = (((Object)(object)((Component)componentsInChildren[0]).gameObject == (Object)(object)((Component)this).gameObject) ? 1 : 0); rigidbones = new Rigidbone[(num != 0) ? (componentsInChildren.Length - 1) : componentsInChildren.Length]; for (int i = 0; i < rigidbones.Length; i++) { rigidbones[i] = new Rigidbone(componentsInChildren[i + num]); } Transform[] componentsInChildren2 = ((Component)this).GetComponentsInChildren(); children = new Child[componentsInChildren2.Length - 1]; for (int j = 0; j < children.Length; j++) { children[j] = new Child(componentsInChildren2[j + 1]); } } private IEnumerator DisableRagdollSmooth() { for (int i = 0; i < rigidbones.Length; i++) { rigidbones[i].r.isKinematic = true; } for (int j = 0; j < allIKComponents.Length; j++) { allIKComponents[j].fixTransforms = fixTransforms[j]; if (disabledIKComponents[j]) { ((Behaviour)allIKComponents[j]).enabled = true; } } animator.updateMode = animatorUpdateMode; ((Behaviour)animator).enabled = true; while (ragdollWeight > 0f) { ragdollWeight = Mathf.SmoothDamp(ragdollWeight, 0f, ref ragdollWeightV, ragdollToAnimationTime); if (ragdollWeight < 0.001f) { ragdollWeight = 0f; } yield return null; } yield return null; } private void Update() { if (!isRagdoll) { return; } if (!applyIkOnRagdoll) { bool flag = false; for (int i = 0; i < allIKComponents.Length; i++) { if (((Behaviour)allIKComponents[i]).enabled) { flag = true; break; } } if (flag) { for (int j = 0; j < allIKComponents.Length; j++) { disabledIKComponents[j] = false; } } for (int k = 0; k < allIKComponents.Length; k++) { if (((Behaviour)allIKComponents[k]).enabled) { ((Behaviour)allIKComponents[k]).enabled = false; disabledIKComponents[k] = true; } } return; } bool flag2 = false; for (int l = 0; l < allIKComponents.Length; l++) { if (disabledIKComponents[l]) { flag2 = true; break; } } if (!flag2) { return; } for (int m = 0; m < allIKComponents.Length; m++) { if (disabledIKComponents[m]) { ((Behaviour)allIKComponents[m]).enabled = true; } } for (int n = 0; n < allIKComponents.Length; n++) { disabledIKComponents[n] = false; } } private void FixedUpdate() { if (isRagdoll && applyIkOnRagdoll) { FixTransforms(1f); } fixedFrame = true; } private void LateUpdate() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 if ((int)animator.updateMode != 1 || ((int)animator.updateMode == 1 && fixedFrame)) { AfterAnimation(); } fixedFrame = false; if (!ikUsed) { OnFinalPose(); } } private void AfterLastIK() { if (ikUsed) { OnFinalPose(); } } private void AfterAnimation() { if (isRagdoll) { StoreLocalState(); } else { FixTransforms(ragdollWeight); } } private void OnFinalPose() { if (!isRagdoll) { RecordVelocities(); } if (enableRagdollFlag) { RagdollEnabler(); } } private void RagdollEnabler() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) StoreLocalState(); for (int i = 0; i < allIKComponents.Length; i++) { disabledIKComponents[i] = false; } if (!applyIkOnRagdoll) { for (int j = 0; j < allIKComponents.Length; j++) { if (((Behaviour)allIKComponents[j]).enabled) { ((Behaviour)allIKComponents[j]).enabled = false; disabledIKComponents[j] = true; } } } animatorUpdateMode = animator.updateMode; animator.updateMode = (AnimatorUpdateMode)1; ((Behaviour)animator).enabled = false; for (int k = 0; k < rigidbones.Length; k++) { rigidbones[k].WakeUp(applyVelocity, applyAngularVelocity); } for (int l = 0; l < fixTransforms.Length; l++) { fixTransforms[l] = allIKComponents[l].fixTransforms; allIKComponents[l].fixTransforms = false; } ragdollWeight = 1f; ragdollWeightV = 0f; enableRagdollFlag = false; } private void RecordVelocities() { Rigidbone[] array = rigidbones; foreach (Rigidbone rigidbone in array) { rigidbone.RecordVelocity(); } } private void StoreLocalState() { Child[] array = children; foreach (Child child in array) { child.StoreLocalState(); } } private void FixTransforms(float weight) { Child[] array = children; foreach (Child child in array) { child.FixTransform(weight); } } private void OnDestroy() { if ((Object)(object)ik != (Object)null) { IKSolver iKSolver = ik.GetIKSolver(); iKSolver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(iKSolver.OnPostUpdate, new IKSolver.UpdateDelegate(AfterLastIK)); } } } public abstract class RotationLimit : MonoBehaviour { public Vector3 axis = Vector3.forward; [HideInInspector] public Quaternion defaultLocalRotation; private bool initiated; private bool applicationQuit; private bool defaultLocalRotationSet; public Vector3 secondaryAxis => new Vector3(axis.y, axis.z, axis.x); public Vector3 crossAxis => Vector3.Cross(axis, secondaryAxis); public bool defaultLocalRotationOverride { get; private set; } public void SetDefaultLocalRotation() { //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) defaultLocalRotation = ((Component)this).transform.localRotation; defaultLocalRotationSet = true; defaultLocalRotationOverride = false; } public void SetDefaultLocalRotation(Quaternion localRotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) defaultLocalRotation = localRotation; defaultLocalRotationSet = true; defaultLocalRotationOverride = true; } public Quaternion GetLimitedLocalRotation(Quaternion localRotation, out bool changed) { //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_001d: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) if (!initiated) { Awake(); } Quaternion val = Quaternion.Inverse(defaultLocalRotation) * localRotation; Quaternion val2 = LimitRotation(val); changed = val2 != val; if (!changed) { return localRotation; } return defaultLocalRotation * val2; } public bool Apply() { //IL_0010: 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) bool changed = false; ((Component)this).transform.localRotation = GetLimitedLocalRotation(((Component)this).transform.localRotation, out changed); return changed; } public void Disable() { if (initiated) { ((Behaviour)this).enabled = false; return; } Awake(); ((Behaviour)this).enabled = false; } protected abstract Quaternion LimitRotation(Quaternion rotation); private void Awake() { //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) if (!defaultLocalRotationSet) { SetDefaultLocalRotation(); } if (axis == Vector3.zero) { Debug.LogError((object)"Axis is Vector3.zero."); } initiated = true; } private void LateUpdate() { Apply(); } public void LogWarning(string message) { Warning.Log(message, ((Component)this).transform); } protected static Quaternion Limit1DOF(Quaternion rotation, Vector3 axis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return Quaternion.FromToRotation(rotation * axis, axis) * rotation; } protected static Quaternion LimitTwist(Quaternion rotation, Vector3 axis, Vector3 orthoAxis, float twistLimit) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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_002e: 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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //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) //IL_001e: 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_006b: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0065: 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) twistLimit = Mathf.Clamp(twistLimit, 0f, 180f); if (twistLimit >= 180f) { return rotation; } Vector3 val = rotation * axis; Vector3 val2 = orthoAxis; Vector3.OrthoNormalize(ref val, ref val2); Vector3 val3 = rotation * orthoAxis; Vector3.OrthoNormalize(ref val, ref val3); Quaternion val4 = Quaternion.FromToRotation(val3, val2) * rotation; if (twistLimit <= 0f) { return val4; } return Quaternion.RotateTowards(val4, rotation, twistLimit); } protected static float GetOrthogonalAngle(Vector3 v1, Vector3 v2, Vector3 normal) { //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) Vector3.OrthoNormalize(ref normal, ref v1); Vector3.OrthoNormalize(ref normal, ref v2); return Vector3.Angle(v1, v2); } } [HelpURL("http://www.root-motion.com/finalikdox/html/page14.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Rotation Limits/Rotation Limit Angle")] public class RotationLimitAngle : RotationLimit { [Range(0f, 180f)] public float limit = 45f; [Range(0f, 180f)] public float twistLimit = 180f; [ContextMenu("User Manual")] private void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page14.html"); } [ContextMenu("Scrpt Reference")] private void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_rotation_limit_angle.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } protected override Quaternion LimitRotation(Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation2 = LimitSwing(rotation); return RotationLimit.LimitTwist(rotation2, axis, base.secondaryAxis, twistLimit); } private Quaternion LimitSwing(Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_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_0057: 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_005f: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0078: 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_0089: 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_008d: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (axis == Vector3.zero) { return rotation; } if (rotation == Quaternion.identity) { return rotation; } if (limit >= 180f) { return rotation; } Vector3 val = rotation * axis; Quaternion val2 = Quaternion.FromToRotation(axis, val); Quaternion val3 = Quaternion.RotateTowards(Quaternion.identity, val2, limit); Quaternion val4 = Quaternion.FromToRotation(val, val3 * axis); return val4 * rotation; } } [HelpURL("http://www.root-motion.com/finalikdox/html/page14.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Rotation Limits/Rotation Limit Hinge")] public class RotationLimitHinge : RotationLimit { public bool useLimits = true; public float min = -45f; public float max = 90f; [HideInInspector] public float zeroAxisDisplayOffset; private float lastAngle; [ContextMenu("User Manual")] private void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page14.html"); } [ContextMenu("Scrpt Reference")] private void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_rotation_limit_hinge.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } protected override Quaternion LimitRotation(Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_000e: Unknown result type (might be due to invalid IL or missing references) return LimitHinge(rotation); } private Quaternion LimitHinge(Quaternion rotation) { //IL_0042: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (min == 0f && max == 0f && useLimits) { return Quaternion.AngleAxis(0f, axis); } Quaternion val = RotationLimit.Limit1DOF(rotation, axis); if (!useLimits) { return val; } Quaternion val2 = Quaternion.Inverse(Quaternion.AngleAxis(lastAngle, axis) * Quaternion.LookRotation(base.secondaryAxis, axis)); Vector3 val3 = val2 * val * base.secondaryAxis; float num = Mathf.Atan2(val3.x, val3.z) * 57.29578f; lastAngle = Mathf.Clamp(lastAngle + num, min, max); return Quaternion.AngleAxis(lastAngle, axis); } } [HelpURL("http://www.root-motion.com/finalikdox/html/page14.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Rotation Limits/Rotation Limit Polygonal")] public class RotationLimitPolygonal : RotationLimit { [Serializable] public class ReachCone { public Vector3[] tetrahedron; public float volume; public Vector3 S; public Vector3 B; public Vector3 o => tetrahedron[0]; public Vector3 a => tetrahedron[1]; public Vector3 b => tetrahedron[2]; public Vector3 c => tetrahedron[3]; public bool isValid => volume > 0f; public ReachCone(Vector3 _o, Vector3 _a, Vector3 _b, Vector3 _c) { //IL_001f: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) tetrahedron = (Vector3[])(object)new Vector3[4]; tetrahedron[0] = _o; tetrahedron[1] = _a; tetrahedron[2] = _b; tetrahedron[3] = _c; volume = 0f; S = Vector3.zero; B = Vector3.zero; } public void Calculate() { //IL_0002: 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_0014: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_0064: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(a, b); volume = Vector3.Dot(val, c) / 6f; Vector3 val2 = Vector3.Cross(a, b); S = ((Vector3)(ref val2)).normalized; Vector3 val3 = Vector3.Cross(b, c); B = ((Vector3)(ref val3)).normalized; } } [Serializable] public class LimitPoint { public Vector3 point; public float tangentWeight; public LimitPoint() { //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) point = Vector3.forward; tangentWeight = 1f; } } [Range(0f, 180f)] public float twistLimit = 180f; [Range(0f, 3f)] public int smoothIterations = 0; [HideInInspector] public LimitPoint[] points; [HideInInspector] public Vector3[] P; [HideInInspector] public ReachCone[] reachCones = new ReachCone[0]; [ContextMenu("User Manual")] private void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page14.html"); } [ContextMenu("Scrpt Reference")] private void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_rotation_limit_polygonal.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public void SetLimitPoints(LimitPoint[] points) { if (points.Length < 3) { LogWarning("The polygon must have at least 3 Limit Points."); return; } this.points = points; BuildReachCones(); } protected override Quaternion LimitRotation(Quaternion rotation) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) if (reachCones.Length == 0) { Start(); } Quaternion rotation2 = LimitSwing(rotation); return RotationLimit.LimitTwist(rotation2, axis, base.secondaryAxis, twistLimit); } private void Start() { //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) if (points.Length < 3) { ResetToDefault(); } for (int i = 0; i < reachCones.Length; i++) { if (!reachCones[i].isValid) { if (smoothIterations <= 0) { int num = 0; num = ((i < reachCones.Length - 1) ? (i + 1) : 0); LogWarning("Reach Cone {point " + i + ", point " + num + ", Origin} has negative volume. Make sure Axis vector is in the reachable area and the polygon is convex."); } else { LogWarning("One of the Reach Cones in the polygon has negative volume. Make sure Axis vector is in the reachable area and the polygon is convex."); } } } axis = ((Vector3)(ref axis)).normalized; } public void ResetToDefault() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_0052: 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_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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) points = new LimitPoint[4]; for (int i = 0; i < points.Length; i++) { points[i] = new LimitPoint(); } Quaternion val = Quaternion.AngleAxis(45f, Vector3.right); Quaternion val2 = Quaternion.AngleAxis(45f, Vector3.up); points[0].point = val * val2 * axis; points[1].point = Quaternion.Inverse(val) * val2 * axis; points[2].point = Quaternion.Inverse(val) * Quaternion.Inverse(val2) * axis; points[3].point = val * Quaternion.Inverse(val2) * axis; BuildReachCones(); } public void BuildReachCones() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00c4: 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_0112: 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_013d: Unknown result type (might be due to invalid IL or missing references) smoothIterations = Mathf.Clamp(smoothIterations, 0, 3); P = (Vector3[])(object)new Vector3[points.Length]; for (int i = 0; i < points.Length; i++) { ref Vector3 reference = ref P[i]; reference = ((Vector3)(ref points[i].point)).normalized; } for (int j = 0; j < smoothIterations; j++) { P = SmoothPoints(); } reachCones = new ReachCone[P.Length]; for (int k = 0; k < reachCones.Length - 1; k++) { reachCones[k] = new ReachCone(Vector3.zero, ((Vector3)(ref axis)).normalized, P[k], P[k + 1]); } reachCones[P.Length - 1] = new ReachCone(Vector3.zero, ((Vector3)(ref axis)).normalized, P[P.Length - 1], P[0]); for (int l = 0; l < reachCones.Length; l++) { reachCones[l].Calculate(); } } private Vector3[] SmoothPoints() { //IL_003d: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) Vector3[] array = (Vector3[])(object)new Vector3[P.Length * 2]; float scalar = GetScalar(P.Length); for (int i = 0; i < array.Length; i += 2) { ref Vector3 reference = ref array[i]; reference = PointToTangentPlane(P[i / 2], 1f); } for (int j = 1; j < array.Length; j += 2) { Vector3 val = Vector3.zero; Vector3 zero = Vector3.zero; Vector3 val2 = Vector3.zero; if (j > 1 && j < array.Length - 2) { val = array[j - 2]; val2 = array[j + 1]; } else if (j == 1) { val = array[^2]; val2 = array[j + 1]; } else if (j == array.Length - 1) { val = array[j - 2]; val2 = array[0]; } zero = ((j >= array.Length - 1) ? array[0] : array[j + 1]); int num = array.Length / points.Length; ref Vector3 reference2 = ref array[j]; reference2 = 0.5f * (array[j - 1] + zero) + scalar * points[j / num].tangentWeight * (zero - val) + scalar * points[j / num].tangentWeight * (array[j - 1] - val2); } for (int k = 0; k < array.Length; k++) { ref Vector3 reference3 = ref array[k]; reference3 = TangentPointToSphere(array[k], 1f); } return array; } private float GetScalar(int k) { if (k <= 3) { return 0.1667f; } return k switch { 4 => 0.1036f, 5 => 0.085f, 6 => 0.0773f, 7 => 0.07f, _ => 0.0625f, }; } private Vector3 PointToTangentPlane(Vector3 p, float r) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Dot(axis, p); float num2 = 2f * r * r / (r * r + num); return num2 * p + (1f - num2) * -axis; } private Vector3 TangentPointToSphere(Vector3 q, float r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_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_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_0058: 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) float num = Vector3.Dot(q - axis, q - axis); float num2 = 4f * r * r / (4f * r * r + num); return num2 * q + (1f - num2) * -axis; } private Quaternion LimitSwing(Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c1: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b3: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (rotation == Quaternion.identity) { return rotation; } Vector3 val = rotation * axis; int reachCone = GetReachCone(val); if (reachCone == -1) { if (!Warning.logged) { LogWarning("RotationLimitPolygonal reach cones are invalid."); } return rotation; } float num = Vector3.Dot(reachCones[reachCone].B, val); if (num > 0f) { return rotation; } Vector3 val2 = Vector3.Cross(axis, val); val = Vector3.Cross(-reachCones[reachCone].B, val2); Quaternion val3 = Quaternion.FromToRotation(rotation * axis, val); return val3 * rotation; } private int GetReachCone(Vector3 L) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_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) float num = 0f; float num2 = Vector3.Dot(reachCones[0].S, L); for (int i = 0; i < reachCones.Length; i++) { num = num2; num2 = ((i >= reachCones.Length - 1) ? Vector3.Dot(reachCones[0].S, L) : Vector3.Dot(reachCones[i + 1].S, L)); if (num >= 0f && num2 < 0f) { return i; } } return -1; } } [HelpURL("http://www.root-motion.com/finalikdox/html/page14.html")] [AddComponentMenu("Scripts/RootMotion.FinalIK/Rotation Limits/Rotation Limit Spline")] public class RotationLimitSpline : RotationLimit { [Range(0f, 180f)] public float twistLimit = 180f; [HideInInspector] public AnimationCurve spline; [ContextMenu("User Manual")] private void OpenUserManual() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/page14.html"); } [ContextMenu("Scrpt Reference")] private void OpenScriptReference() { Application.OpenURL("http://www.root-motion.com/finalikdox/html/class_root_motion_1_1_final_i_k_1_1_rotation_limit_spline.html"); } [ContextMenu("Support Group")] private void SupportGroup() { Application.OpenURL("https://groups.google.com/forum/#!forum/final-ik"); } [ContextMenu("Asset Store Thread")] private void ASThread() { Application.OpenURL("http://forum.unity3d.com/threads/final-ik-full-body-ik-aim-look-at-fabrik-ccd-ik-1-0-released.222685/"); } public void SetSpline(Keyframe[] keyframes) { spline.keys = keyframes; } protected override Quaternion LimitRotation(Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Quaternion rotation2 = LimitSwing(rotation); return RotationLimit.LimitTwist(rotation2, axis, base.secondaryAxis, twistLimit); } public Quaternion LimitSwing(Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0049: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) if (axis == Vector3.zero) { return rotation; } if (rotation == Quaternion.identity) { return rotation; } Vector3 val = rotation * axis; float num = RotationLimit.GetOrthogonalAngle(val, base.secondaryAxis, axis); float num2 = Vector3.Dot(val, base.crossAxis); if (num2 < 0f) { num = 180f + (180f - num); } float num3 = spline.Evaluate(num); Quaternion val2 = Quaternion.FromToRotation(axis, val); Quaternion val3 = Quaternion.RotateTowards(Quaternion.identity, val2, num3); Quaternion val4 = Quaternion.FromToRotation(val, val3 * axis); return val4 * rotation; } } public class AimController : MonoBehaviour { [Tooltip("Reference to the AimIK component.")] public AimIK ik; [Tooltip("Master weight of the IK solver.")] [Range(0f, 1f)] public float weight = 1f; [Header("Target Smoothing")] [Tooltip("The target to aim at. Do not use the Target transform that is assigned to AimIK. Set to null if you wish to stop aiming.")] public Transform target; [Tooltip("The time it takes to switch targets.")] public float targetSwitchSmoothTime = 0.3f; [Tooltip("The time it takes to blend in/out of AimIK weight.")] public float weightSmoothTime = 0.3f; [Header("Turning Towards The Target")] [Tooltip("Enables smooth turning towards the target according to the parameters under this header.")] public bool smoothTurnTowardsTarget = true; [Tooltip("Speed of turning towards the target using Vector3.RotateTowards.")] public float maxRadiansDelta = 3f; [Tooltip("Speed of moving towards the target using Vector3.RotateTowards.")] public float maxMagnitudeDelta = 3f; [Tooltip("Speed of slerping towards the target.")] public float slerpSpeed = 3f; [Tooltip("Smoothing time for turning towards the yaw and pitch of the target using Mathf.SmoothDampAngle. Value of 0 means smooth damping is disabled.")] public float smoothDampTime = 0f; [Tooltip("The position of the pivot that the aim target is rotated around relative to the root of the character.")] public Vector3 pivotOffsetFromRoot = Vector3.up; [Tooltip("Minimum distance of aiming from the first bone. Keeps the solver from failing if the target is too close.")] public float minDistance = 1f; [Tooltip("Offset applied to the target in world space. Convenient for scripting aiming inaccuracy.")] public Vector3 offset; [Header("RootRotation")] [Tooltip("Character root will be rotate around the Y axis to keep root forward within this angle from the aiming direction.")] [Range(0f, 180f)] public float maxRootAngle = 45f; [Tooltip("If enabled, aligns the root forward to target direction after 'Max Root Angle' has been exceeded.")] public bool turnToTarget; [Tooltip("The time of turning towards the target direction if 'Max Root Angle has been exceeded and 'Turn To Target' is enabled.")] public float turnToTargetTime = 0.2f; [Header("Mode")] [Tooltip("If true, AimIK will consider whatever the current direction of the weapon to be the forward aiming direction and work additively on top of that. This enables you to use recoil and reloading animations seamlessly with AimIK. Adjust the Vector3 value below if the weapon is not aiming perfectly forward in the aiming animation clip.")] public bool useAnimatedAimDirection; [Tooltip("The direction of the animated weapon aiming in character space. Tweak this value to adjust the aiming. 'Use Animated Aim Direction' must be enabled for this property to work.")] public Vector3 animatedAimDirection = Vector3.forward; private Transform lastTarget; private float switchWeight; private float switchWeightV; private float weightV; private Vector3 lastPosition; private Vector3 dir; private bool lastSmoothTowardsTarget; private bool turningToTarget; private float turnToTargetMlp = 1f; private float turnToTargetMlpV; private float yawV; private float pitchV; private float dirMagV; private Vector3 pivot => ((Component)ik).transform.position + ((Component)ik).transform.rotation * pivotOffsetFromRoot; private void Start() { //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_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_0033: Unknown result type (might be due to invalid IL or missing references) lastPosition = ik.solver.IKPosition; dir = ik.solver.IKPosition - pivot; ik.solver.target = null; } private void LateUpdate() { //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_00d1: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02da: 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_02ea: 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_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0419: 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_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target != (Object)(object)lastTarget) { if ((Object)(object)lastTarget == (Object)null && (Object)(object)target != (Object)null && ik.solver.IKPositionWeight <= 0f) { lastPosition = target.position; dir = target.position - pivot; ik.solver.IKPosition = target.position + offset; } else { lastPosition = ik.solver.IKPosition; dir = ik.solver.IKPosition - pivot; } switchWeight = 0f; lastTarget = target; } float num = ((!((Object)(object)target != (Object)null)) ? 0f : weight); ik.solver.IKPositionWeight = Mathf.SmoothDamp(ik.solver.IKPositionWeight, num, ref weightV, weightSmoothTime); if (ik.solver.IKPositionWeight >= 0.999f && num > ik.solver.IKPositionWeight) { ik.solver.IKPositionWeight = 1f; } if (ik.solver.IKPositionWeight <= 0.001f && num < ik.solver.IKPositionWeight) { ik.solver.IKPositionWeight = 0f; } if (ik.solver.IKPositionWeight <= 0f) { return; } switchWeight = Mathf.SmoothDamp(switchWeight, 1f, ref switchWeightV, targetSwitchSmoothTime); if (switchWeight >= 0.999f) { switchWeight = 1f; } if ((Object)(object)target != (Object)null) { ik.solver.IKPosition = Vector3.Lerp(lastPosition, target.position + offset, switchWeight); } if (smoothTurnTowardsTarget != lastSmoothTowardsTarget) { dir = ik.solver.IKPosition - pivot; lastSmoothTowardsTarget = smoothTurnTowardsTarget; } if (smoothTurnTowardsTarget) { Vector3 val = ik.solver.IKPosition - pivot; if (slerpSpeed > 0f) { dir = Vector3.Slerp(dir, val, Time.deltaTime * slerpSpeed); } if (maxRadiansDelta > 0f || maxMagnitudeDelta > 0f) { dir = Vector3.RotateTowards(dir, val, Time.deltaTime * maxRadiansDelta, maxMagnitudeDelta); } if (smoothDampTime > 0f) { float yaw = V3Tools.GetYaw(dir); float yaw2 = V3Tools.GetYaw(val); float num2 = Mathf.SmoothDampAngle(yaw, yaw2, ref yawV, smoothDampTime); float pitch = V3Tools.GetPitch(dir); float pitch2 = V3Tools.GetPitch(val); float num3 = Mathf.SmoothDampAngle(pitch, pitch2, ref pitchV, smoothDampTime); float num4 = Mathf.SmoothDamp(((Vector3)(ref dir)).magnitude, ((Vector3)(ref val)).magnitude, ref dirMagV, smoothDampTime); dir = Quaternion.Euler(num3, num2, 0f) * Vector3.forward * num4; } ik.solver.IKPosition = pivot + dir; } ApplyMinDistance(); RootRotation(); if (useAnimatedAimDirection) { ik.solver.axis = ik.solver.transform.InverseTransformVector(((Component)ik).transform.rotation * animatedAimDirection); } } private void ApplyMinDistance() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_003d: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pivot; Vector3 val2 = ik.solver.IKPosition - val; val2 = ((Vector3)(ref val2)).normalized * Mathf.Max(((Vector3)(ref val2)).magnitude, minDistance); ik.solver.IKPosition = val + val2; } private void RootRotation() { //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_0055: 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_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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Lerp(180f, maxRootAngle * turnToTargetMlp, ik.solver.IKPositionWeight); if (!(num < 180f)) { return; } Vector3 val = Quaternion.Inverse(((Component)ik).transform.rotation) * (ik.solver.IKPosition - pivot); float num2 = Mathf.Atan2(val.x, val.z) * 57.29578f; float num3 = 0f; if (num2 > num) { num3 = num2 - num; if (!turningToTarget && turnToTarget) { ((MonoBehaviour)this).StartCoroutine(TurnToTarget()); } } if (num2 < 0f - num) { num3 = num2 + num; if (!turningToTarget && turnToTarget) { ((MonoBehaviour)this).StartCoroutine(TurnToTarget()); } } ((Component)ik).transform.rotation = Quaternion.AngleAxis(num3, ((Component)ik).transform.up) * ((Component)ik).transform.rotation; } private IEnumerator TurnToTarget() { turningToTarget = true; while (turnToTargetMlp > 0f) { turnToTargetMlp = Mathf.SmoothDamp(turnToTargetMlp, 0f, ref turnToTargetMlpV, turnToTargetTime); if (turnToTargetMlp < 0.01f) { turnToTargetMlp = 0f; } yield return null; } turnToTargetMlp = 1f; turningToTarget = false; } } public class AimPoser : MonoBehaviour { [Serializable] public class Pose { public bool visualize = true; public string name; public Vector3 direction; public float yaw = 75f; public float pitch = 45f; private float angleBuffer; public bool IsInDirection(Vector3 d) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_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) if (direction == Vector3.zero) { return false; } if (yaw <= 0f || pitch <= 0f) { return false; } if (yaw < 180f) { Vector3 forward = default(Vector3); ((Vector3)(ref forward))..ctor(direction.x, 0f, direction.z); if (forward == Vector3.zero) { forward = Vector3.forward; } Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(d.x, 0f, d.z); float num = Vector3.Angle(val, forward); if (num > yaw + angleBuffer) { return false; } } if (pitch >= 180f) { return true; } float num2 = Vector3.Angle(Vector3.up, direction); float num3 = Vector3.Angle(Vector3.up, d); return Mathf.Abs(num3 - num2) < pitch + angleBuffer; } public void SetAngleBuffer(float value) { angleBuffer = value; } } public float angleBuffer = 5f; public Pose[] poses = new Pose[0]; public Pose GetPose(Vector3 localDirection) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (poses.Length == 0) { return null; } for (int i = 0; i < poses.Length - 1; i++) { if (poses[i].IsInDirection(localDirection)) { return poses[i]; } } return poses[poses.Length - 1]; } public void SetPoseActive(Pose pose) { for (int i = 0; i < poses.Length; i++) { poses[i].SetAngleBuffer((poses[i] != pose) ? 0f : angleBuffer); } } } public class Amplifier : OffsetModifier { [Serializable] public class Body { [Serializable] public class EffectorLink { [Tooltip("Type of the FBBIK effector to use")] public FullBodyBipedEffector effector; [Tooltip("Weight of using this effector")] public float weight; } [Tooltip("The Transform that's motion we are reading.")] public Transform transform; [Tooltip("Amplify the 'transform's' position relative to this Transform.")] public Transform relativeTo; [Tooltip("Linking the body to effectors. One Body can be used to offset more than one effector.")] public EffectorLink[] effectorLinks; [Tooltip("Amplification magnitude along the up axis of the character.")] public float verticalWeight = 1f; [Tooltip("Amplification magnitude along the horizontal axes of the character.")] public float horizontalWeight = 1f; [Tooltip("Speed of the amplifier. 0 means instant.")] public float speed = 3f; private Vector3 lastRelativePos; private Vector3 smoothDelta; private bool firstUpdate; public void Update(IKSolverFullBodyBiped solver, float w, float deltaTime) { //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_004e: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00a3: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)transform == (Object)null) && !((Object)(object)relativeTo == (Object)null)) { Vector3 val = relativeTo.InverseTransformDirection(transform.position - relativeTo.position); if (firstUpdate) { lastRelativePos = val; firstUpdate = false; } Vector3 val2 = (val - lastRelativePos) / deltaTime; smoothDelta = ((!(speed <= 0f)) ? Vector3.Lerp(smoothDelta, val2, deltaTime * speed) : val2); Vector3 v = relativeTo.TransformDirection(smoothDelta); Vector3 val3 = V3Tools.ExtractVertical(v, solver.GetRoot().up, verticalWeight) + V3Tools.ExtractHorizontal(v, solver.GetRoot().up, horizontalWeight); for (int i = 0; i < effectorLinks.Length; i++) { IKEffector effector = solver.GetEffector(effectorLinks[i].effector); effector.positionOffset += val3 * w * effectorLinks[i].weight; } lastRelativePos = val; } } private static Vector3 Multiply(Vector3 v1, Vector3 v2) { //IL_0040: 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_0047: Unknown result type (might be due to invalid IL or missing references) v1.x *= v2.x; v1.y *= v2.y; v1.z *= v2.z; return v1; } } [Tooltip("The amplified bodies.")] public Body[] bodies; protected override void OnModifyOffset() { if (!ik.fixTransforms) { if (!Warning.logged) { Warning.Log("Amplifier needs the Fix Transforms option of the FBBIK to be set to true. Otherwise it might amplify to infinity, should the animator of the character stop because of culling.", ((Component)this).transform); } return; } Body[] array = bodies; foreach (Body body in array) { body.Update(ik.solver, weight, base.deltaTime); } } } public class BodyTilt : OffsetModifier { [Tooltip("Speed of tilting")] public float tiltSpeed = 6f; [Tooltip("Sensitivity of tilting")] public float tiltSensitivity = 0.07f; [Tooltip("The OffsetPose components")] public OffsetPose poseLeft; [Tooltip("The OffsetPose components")] public OffsetPose poseRight; private float tiltAngle; private Vector3 lastForward; protected override void Start() { //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) base.Start(); lastForward = ((Component)this).transform.forward; } protected override void OnModifyOffset() { //IL_0002: 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_0017: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.FromToRotation(lastForward, ((Component)this).transform.forward); float num = 0f; Vector3 zero = Vector3.zero; ((Quaternion)(ref val)).ToAngleAxis(ref num, ref zero); if (zero.y > 0f) { num = 0f - num; } num *= tiltSensitivity * 0.01f; num /= base.deltaTime; num = Mathf.Clamp(num, -1f, 1f); tiltAngle = Mathf.Lerp(tiltAngle, num, base.deltaTime * tiltSpeed); float num2 = Mathf.Abs(tiltAngle) / 1f; if (tiltAngle < 0f) { poseRight.Apply(ik.solver, num2); } else { poseLeft.Apply(ik.solver, num2); } lastForward = ((Component)this).transform.forward; } } public class CCDBendGoal : MonoBehaviour { public CCDIK ik; [Range(0f, 1f)] public float weight = 1f; private void Start() { IKSolverCCD solver = ik.solver; solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPreUpdate, new IKSolver.UpdateDelegate(BeforeIK)); } private void BeforeIK() { //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_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_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_0088: 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_00a3: 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_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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) if (!((Behaviour)this).enabled) { return; } float num = ik.solver.IKPositionWeight * weight; if (!(num <= 0f)) { Vector3 position = ik.solver.bones[0].transform.position; Vector3 position2 = ik.solver.bones[ik.solver.bones.Length - 1].transform.position; Quaternion val = Quaternion.FromToRotation(position2 - position, ((Component)this).transform.position - position); if (num < 1f) { val = Quaternion.Slerp(Quaternion.identity, val, num); } ik.solver.bones[0].transform.rotation = val * ik.solver.bones[0].transform.rotation; } } private void OnDestroy() { if ((Object)(object)ik != (Object)null) { IKSolverCCD solver = ik.solver; solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPreUpdate, new IKSolver.UpdateDelegate(BeforeIK)); } } } [ExecuteInEditMode] public class EditorIK : MonoBehaviour { [Tooltip("If slot assigned, will update Animator before IK.")] public Animator animator; [Tooltip("Create/Final IK/Editor IK Pose")] public EditorIKPose defaultPose; [HideInInspector] public Transform[] bones = (Transform[])(object)new Transform[0]; public IK ik { get; private set; } private void OnEnable() { if (!Application.isPlaying) { if ((Object)(object)ik == (Object)null) { ik = ((Component)this).GetComponent(); } if ((Object)(object)ik == (Object)null) { Debug.LogError((object)"EditorIK needs to have an IK component on the same GameObject.", (Object)(object)((Component)this).transform); } else if (bones.Length == 0) { bones = ((Component)((Component)ik).transform).GetComponentsInChildren(); } } } private void OnDisable() { if (!Application.isPlaying) { if ((Object)(object)defaultPose != (Object)null && defaultPose.poseStored) { defaultPose.Restore(bones); } if ((Object)(object)ik != (Object)null) { ik.GetIKSolver().executedInEditor = false; } } } private void OnDestroy() { if (!Application.isPlaying && !((Object)(object)ik == (Object)null)) { if (bones.Length == 0) { bones = ((Component)((Component)ik).transform).GetComponentsInChildren(); } if ((Object)(object)defaultPose != (Object)null && defaultPose.poseStored && bones.Length != 0) { defaultPose.Restore(bones); } ik.GetIKSolver().executedInEditor = false; } } public void StoreDefaultPose() { bones = ((Component)((Component)ik).transform).GetComponentsInChildren(); defaultPose.Store(bones); } public bool Initiate() { if ((Object)(object)defaultPose == (Object)null) { return false; } if (!defaultPose.poseStored) { return false; } if (bones.Length == 0) { return false; } if ((Object)(object)ik == (Object)null) { ik = ((Component)this).GetComponent(); } if ((Object)(object)ik == (Object)null) { Debug.LogError((object)"EditorIK can not find an IK component.", (Object)(object)((Component)this).transform); return false; } defaultPose.Restore(bones); ik.GetIKSolver().executedInEditor = false; ik.GetIKSolver().Initiate(((Component)ik).transform); ik.GetIKSolver().executedInEditor = true; return true; } public void Update() { if (Application.isPlaying || (Object)(object)ik == (Object)null || !((Behaviour)ik).enabled || !ik.GetIKSolver().executedInEditor) { return; } if (bones.Length == 0) { bones = ((Component)((Component)ik).transform).GetComponentsInChildren(); } if (bones.Length == 0 || !defaultPose.Restore(bones)) { return; } ik.GetIKSolver().executedInEditor = false; if (!ik.GetIKSolver().initiated) { ik.GetIKSolver().Initiate(((Component)ik).transform); } if (ik.GetIKSolver().initiated) { ik.GetIKSolver().executedInEditor = true; if ((Object)(object)animator != (Object)null && (Object)(object)animator.runtimeAnimatorController != (Object)null) { animator.Update(Time.deltaTime); } ik.GetIKSolver().Update(); } } } [CreateAssetMenu(fileName = "Editor IK Pose", menuName = "Final IK/Editor IK Pose", order = 1)] public class EditorIKPose : ScriptableObject { public Vector3[] localPositions = (Vector3[])(object)new Vector3[0]; public Quaternion[] localRotations = (Quaternion[])(object)new Quaternion[0]; public bool poseStored => localPositions.Length > 0; public void Store(Transform[] T) { //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_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) localPositions = (Vector3[])(object)new Vector3[T.Length]; localRotations = (Quaternion[])(object)new Quaternion[T.Length]; for (int i = 1; i < T.Length; i++) { ref Vector3 reference = ref localPositions[i]; reference = T[i].localPosition; ref Quaternion reference2 = ref localRotations[i]; reference2 = T[i].localRotation; } } public bool Restore(Transform[] T) { //IL_003a: 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) if (localPositions.Length != T.Length) { Debug.LogError((object)"Can not restore pose (unmatched bone count). Please stop the solver and click on 'Store Default Pose' if you have made changes to character hierarchy."); return false; } for (int i = 1; i < T.Length; i++) { T[i].localPosition = localPositions[i]; T[i].localRotation = localRotations[i]; } return true; } } public class HitReaction : OffsetModifier { [Serializable] public abstract class HitPoint { [Tooltip("Just for visual clarity, not used at all")] public string name; [Tooltip("Linking this hit point to a collider")] public Collider collider; [Tooltip("Only used if this hit point gets hit when already processing another hit")] [SerializeField] private float crossFadeTime = 0.1f; private float length; private float crossFadeSpeed; private float lastTime; public bool inProgress => timer < length; protected float crossFader { get; private set; } protected float timer { get; private set; } protected Vector3 force { get; private set; } protected Vector3 point { get; private set; } public void Hit(Vector3 force, Vector3 point) { //IL_0096: 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) if (length == 0f) { length = GetLength(); } if (length <= 0f) { Debug.LogError((object)"Hit Point WeightCurve length is zero."); return; } if (timer < 1f) { crossFader = 0f; } crossFadeSpeed = ((!(crossFadeTime > 0f)) ? 0f : (1f / crossFadeTime)); CrossFadeStart(); timer = 0f; this.force = force; this.point = point; } public void Apply(IKSolverFullBodyBiped solver, float weight) { float num = Time.time - lastTime; lastTime = Time.time; if (!(timer >= length)) { timer = Mathf.Clamp(timer + num, 0f, length); if (crossFadeSpeed > 0f) { crossFader = Mathf.Clamp(crossFader + num * crossFadeSpeed, 0f, 1f); } else { crossFader = 1f; } OnApply(solver, weight); } } protected abstract float GetLength(); protected abstract void CrossFadeStart(); protected abstract void OnApply(IKSolverFullBodyBiped solver, float weight); } [Serializable] public class HitPointEffector : HitPoint { [Serializable] public class EffectorLink { [Tooltip("The FBBIK effector type")] public FullBodyBipedEffector effector; [Tooltip("The weight of this effector (could also be negative)")] public float weight; private Vector3 lastValue; private Vector3 current; public void Apply(IKSolverFullBodyBiped solver, Vector3 offset, float crossFader) { //IL_0003: 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_000f: 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_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_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) current = Vector3.Lerp(lastValue, offset * weight, crossFader); IKEffector iKEffector = solver.GetEffector(effector); iKEffector.positionOffset += current; } public void CrossFadeStart() { //IL_0003: 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) lastValue = current; } } [Tooltip("Offset magnitude in the direction of the hit force")] public AnimationCurve offsetInForceDirection; [Tooltip("Offset magnitude in the direction of character.up")] public AnimationCurve offsetInUpDirection; [Tooltip("Linking this offset to the FBBIK effectors")] public EffectorLink[] effectorLinks; protected override float GetLength() { float num = ((offsetInForceDirection.keys.Length <= 0) ? 0f : ((Keyframe)(ref offsetInForceDirection.keys[offsetInForceDirection.length - 1])).time); float num2 = ((offsetInUpDirection.keys.Length <= 0) ? 0f : ((Keyframe)(ref offsetInUpDirection.keys[offsetInUpDirection.length - 1])).time); return Mathf.Clamp(num, num2, num); } protected override void CrossFadeStart() { EffectorLink[] array = effectorLinks; foreach (EffectorLink effectorLink in array) { effectorLink.CrossFadeStart(); } } protected override void OnApply(IKSolverFullBodyBiped solver, float weight) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0060: 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) Vector3 up = solver.GetRoot().up; Vector3 val = base.force; Vector3 val2 = up * ((Vector3)(ref val)).magnitude; Vector3 val3 = offsetInForceDirection.Evaluate(base.timer) * base.force + offsetInUpDirection.Evaluate(base.timer) * val2; val3 *= weight; EffectorLink[] array = effectorLinks; foreach (EffectorLink effectorLink in array) { effectorLink.Apply(solver, val3, base.crossFader); } } } [Serializable] public class HitPointBone : HitPoint { [Serializable] public class BoneLink { [Tooltip("Reference to the bone that this hit point rotates")] public Transform bone; [Tooltip("Weight of rotating the bone")] [Range(0f, 1f)] public float weight; private Quaternion lastValue = Quaternion.identity; private Quaternion current = Quaternion.identity; public void Apply(IKSolverFullBodyBiped solver, Quaternion offset, float crossFader) { //IL_0003: 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_0014: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) current = Quaternion.Lerp(lastValue, Quaternion.Lerp(Quaternion.identity, offset, weight), crossFader); bone.rotation = current * bone.rotation; } public void CrossFadeStart() { //IL_0003: 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) lastValue = current; } } [Tooltip("The angle to rotate the bone around it's rigidbody's world center of mass")] public AnimationCurve aroundCenterOfMass; [Tooltip("Linking this hit point to bone(s)")] public BoneLink[] boneLinks; private Rigidbody rigidbody; protected override float GetLength() { return (aroundCenterOfMass.keys.Length <= 0) ? 0f : ((Keyframe)(ref aroundCenterOfMass.keys[aroundCenterOfMass.length - 1])).time; } protected override void CrossFadeStart() { BoneLink[] array = boneLinks; foreach (BoneLink boneLink in array) { boneLink.CrossFadeStart(); } } protected override void OnApply(IKSolverFullBodyBiped solver, float weight) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_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_008c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rigidbody == (Object)null) { rigidbody = ((Component)collider).GetComponent(); } if ((Object)(object)rigidbody != (Object)null) { Vector3 val = Vector3.Cross(base.force, base.point - rigidbody.worldCenterOfMass); float num = aroundCenterOfMass.Evaluate(base.timer) * weight; Quaternion offset = Quaternion.AngleAxis(num, val); BoneLink[] array = boneLinks; foreach (BoneLink boneLink in array) { boneLink.Apply(solver, offset, base.crossFader); } } } } [Tooltip("Hit points for the FBBIK effectors")] public HitPointEffector[] effectorHitPoints; [Tooltip(" Hit points for bones without an effector, such as the head")] public HitPointBone[] boneHitPoints; public bool inProgress { get { HitPointEffector[] array = effectorHitPoints; foreach (HitPointEffector hitPointEffector in array) { if (hitPointEffector.inProgress) { return true; } } HitPointBone[] array2 = boneHitPoints; foreach (HitPointBone hitPointBone in array2) { if (hitPointBone.inProgress) { return true; } } return false; } } protected override void OnModifyOffset() { HitPointEffector[] array = effectorHitPoints; foreach (HitPointEffector hitPointEffector in array) { hitPointEffector.Apply(ik.solver, weight); } HitPointBone[] array2 = boneHitPoints; foreach (HitPointBone hitPointBone in array2) { hitPointBone.Apply(ik.solver, weight); } } public void Hit(Collider collider, Vector3 force, Vector3 point) { //IL_0048: 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_0087: 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) if ((Object)(object)ik == (Object)null) { Debug.LogError((object)"No IK assigned in HitReaction"); return; } HitPointEffector[] array = effectorHitPoints; foreach (HitPointEffector hitPointEffector in array) { if ((Object)(object)hitPointEffector.collider == (Object)(object)collider) { hitPointEffector.Hit(force, point); } } HitPointBone[] array2 = boneHitPoints; foreach (HitPointBone hitPointBone in array2) { if ((Object)(object)hitPointBone.collider == (Object)(object)collider) { hitPointBone.Hit(force, point); } } } } public class HitReactionVRIK : OffsetModifierVRIK { [Serializable] public abstract class Offset { [Tooltip("Just for visual clarity, not used at all")] public string name; [Tooltip("Linking this hit point to a collider")] public Collider collider; [Tooltip("Only used if this hit point gets hit when already processing another hit")] [SerializeField] private float crossFadeTime = 0.1f; private float length; private float crossFadeSpeed; private float lastTime; protected float crossFader { get; private set; } protected float timer { get; private set; } protected Vector3 force { get; private set; } protected Vector3 point { get; private set; } public void Hit(Vector3 force, AnimationCurve[] curves, Vector3 point) { //IL_0097: 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) if (length == 0f) { length = GetLength(curves); } if (length <= 0f) { Debug.LogError((object)"Hit Point WeightCurve length is zero."); return; } if (timer < 1f) { crossFader = 0f; } crossFadeSpeed = ((!(crossFadeTime > 0f)) ? 0f : (1f / crossFadeTime)); CrossFadeStart(); timer = 0f; this.force = force; this.point = point; } public void Apply(VRIK ik, AnimationCurve[] curves, float weight) { float num = Time.time - lastTime; lastTime = Time.time; if (!(timer >= length)) { timer = Mathf.Clamp(timer + num, 0f, length); if (crossFadeSpeed > 0f) { crossFader = Mathf.Clamp(crossFader + num * crossFadeSpeed, 0f, 1f); } else { crossFader = 1f; } OnApply(ik, curves, weight); } } protected abstract float GetLength(AnimationCurve[] curves); protected abstract void CrossFadeStart(); protected abstract void OnApply(VRIK ik, AnimationCurve[] curves, float weight); } [Serializable] public class PositionOffset : Offset { [Serializable] public class PositionOffsetLink { [Tooltip("The FBBIK effector type")] public IKSolverVR.PositionOffset positionOffset; [Tooltip("The weight of this effector (could also be negative)")] public float weight; private Vector3 lastValue; private Vector3 current; public void Apply(VRIK ik, Vector3 offset, float crossFader) { //IL_0003: 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_000f: 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_002c: Unknown result type (might be due to invalid IL or missing references) current = Vector3.Lerp(lastValue, offset * weight, crossFader); ik.solver.AddPositionOffset(positionOffset, current); } public void CrossFadeStart() { //IL_0003: 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) lastValue = current; } } [Tooltip("Offset magnitude in the direction of the hit force")] public int forceDirCurveIndex; [Tooltip("Offset magnitude in the direction of character.up")] public int upDirCurveIndex = 1; [Tooltip("Linking this offset to the VRIK position offsets")] public PositionOffsetLink[] offsetLinks; protected override float GetLength(AnimationCurve[] curves) { float num = ((curves[forceDirCurveIndex].keys.Length <= 0) ? 0f : ((Keyframe)(ref curves[forceDirCurveIndex].keys[curves[forceDirCurveIndex].length - 1])).time); float num2 = ((curves[upDirCurveIndex].keys.Length <= 0) ? 0f : ((Keyframe)(ref curves[upDirCurveIndex].keys[curves[upDirCurveIndex].length - 1])).time); return Mathf.Clamp(num, num2, num); } protected override void CrossFadeStart() { PositionOffsetLink[] array = offsetLinks; foreach (PositionOffsetLink positionOffsetLink in array) { positionOffsetLink.CrossFadeStart(); } } protected override void OnApply(VRIK ik, AnimationCurve[] curves, float weight) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: 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_007e: Unknown result type (might be due to invalid IL or missing references) Vector3 up = ((Component)ik).transform.up; Vector3 val = base.force; Vector3 val2 = up * ((Vector3)(ref val)).magnitude; Vector3 val3 = curves[forceDirCurveIndex].Evaluate(base.timer) * base.force + curves[upDirCurveIndex].Evaluate(base.timer) * val2; val3 *= weight; PositionOffsetLink[] array = offsetLinks; foreach (PositionOffsetLink positionOffsetLink in array) { positionOffsetLink.Apply(ik, val3, base.crossFader); } } } [Serializable] public class RotationOffset : Offset { [Serializable] public class RotationOffsetLink { [Tooltip("Reference to the bone that this hit point rotates")] public IKSolverVR.RotationOffset rotationOffset; [Tooltip("Weight of rotating the bone")] [Range(0f, 1f)] public float weight; private Quaternion lastValue = Quaternion.identity; private Quaternion current = Quaternion.identity; public void Apply(VRIK ik, Quaternion offset, float crossFader) { //IL_0003: 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_0014: 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_0031: Unknown result type (might be due to invalid IL or missing references) current = Quaternion.Lerp(lastValue, Quaternion.Lerp(Quaternion.identity, offset, weight), crossFader); ik.solver.AddRotationOffset(rotationOffset, current); } public void CrossFadeStart() { //IL_0003: 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) lastValue = current; } } [Tooltip("The angle to rotate the bone around it's rigidbody's world center of mass")] public int curveIndex; [Tooltip("Linking this hit point to bone(s)")] public RotationOffsetLink[] offsetLinks; private Rigidbody rigidbody; protected override float GetLength(AnimationCurve[] curves) { return (curves[curveIndex].keys.Length <= 0) ? 0f : ((Keyframe)(ref curves[curveIndex].keys[curves[curveIndex].length - 1])).time; } protected override void CrossFadeStart() { RotationOffsetLink[] array = offsetLinks; foreach (RotationOffsetLink rotationOffsetLink in array) { rotationOffsetLink.CrossFadeStart(); } } protected override void OnApply(VRIK ik, AnimationCurve[] curves, float weight) { //IL_0057: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)collider == (Object)null) { Debug.LogError((object)"No collider assigned for a HitPointBone in the HitReaction component."); return; } if ((Object)(object)rigidbody == (Object)null) { rigidbody = ((Component)collider).GetComponent(); } if ((Object)(object)rigidbody != (Object)null) { Vector3 val = Vector3.Cross(base.force, base.point - rigidbody.worldCenterOfMass); float num = curves[curveIndex].Evaluate(base.timer) * weight; Quaternion offset = Quaternion.AngleAxis(num, val); RotationOffsetLink[] array = offsetLinks; foreach (RotationOffsetLink rotationOffsetLink in array) { rotationOffsetLink.Apply(ik, offset, base.crossFader); } } } } public AnimationCurve[] offsetCurves; [Tooltip("Hit points for the FBBIK effectors")] public PositionOffset[] positionOffsets; [Tooltip(" Hit points for bones without an effector, such as the head")] public RotationOffset[] rotationOffsets; protected override void OnModifyOffset() { PositionOffset[] array = positionOffsets; foreach (PositionOffset positionOffset in array) { positionOffset.Apply(ik, offsetCurves, weight); } RotationOffset[] array2 = rotationOffsets; foreach (RotationOffset rotationOffset in array2) { rotationOffset.Apply(ik, offsetCurves, weight); } } public void Hit(Collider collider, Vector3 force, Vector3 point) { //IL_0048: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ik == (Object)null) { Debug.LogError((object)"No IK assigned in HitReaction"); return; } PositionOffset[] array = positionOffsets; foreach (PositionOffset positionOffset in array) { if ((Object)(object)positionOffset.collider == (Object)(object)collider) { positionOffset.Hit(force, offsetCurves, point); } } RotationOffset[] array2 = rotationOffsets; foreach (RotationOffset rotationOffset in array2) { if ((Object)(object)rotationOffset.collider == (Object)(object)collider) { rotationOffset.Hit(force, offsetCurves, point); } } } } public class Inertia : OffsetModifier { [Serializable] public class Body { [Serializable] public class EffectorLink { [Tooltip("Type of the FBBIK effector to use")] public FullBodyBipedEffector effector; [Tooltip("Weight of using this effector")] public float weight; } [Tooltip("The Transform to follow, can be any bone of the character")] public Transform transform; [Tooltip("Linking the body to effectors. One Body can be used to offset more than one effector")] public EffectorLink[] effectorLinks; [Tooltip("The speed to follow the Transform")] public float speed = 10f; [Tooltip("The acceleration, smaller values means lazyer following")] public float acceleration = 3f; [Tooltip("Matching target velocity")] [Range(0f, 1f)] public float matchVelocity; [Tooltip("gravity applied to the Body")] public float gravity; private Vector3 delta; private Vector3 lazyPoint; private Vector3 direction; private Vector3 lastPosition; private bool firstUpdate = true; public void Reset() { //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_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)transform == (Object)null)) { lazyPoint = transform.position; lastPosition = transform.position; direction = Vector3.zero; } } public void Update(IKSolverFullBodyBiped solver, float weight, float deltaTime) { //IL_0033: 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_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_004f: 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_0066: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)transform == (Object)null)) { if (firstUpdate) { Reset(); firstUpdate = false; } direction = Vector3.Lerp(direction, (transform.position - lazyPoint) / deltaTime * 0.01f, deltaTime * acceleration); lazyPoint += direction * deltaTime * speed; delta = transform.position - lastPosition; lazyPoint += delta * matchVelocity; ref Vector3 reference = ref lazyPoint; reference.y += gravity * deltaTime; EffectorLink[] array = effectorLinks; foreach (EffectorLink effectorLink in array) { IKEffector effector = solver.GetEffector(effectorLink.effector); effector.positionOffset += (lazyPoint - transform.position) * effectorLink.weight * weight; } lastPosition = transform.position; } } } [Tooltip("The array of Bodies")] public Body[] bodies; [Tooltip("The array of OffsetLimits")] public OffsetLimits[] limits; public void ResetBodies() { lastTime = Time.time; Body[] array = bodies; foreach (Body body in array) { body.Reset(); } } protected override void OnModifyOffset() { Body[] array = bodies; foreach (Body body in array) { body.Update(ik.solver, weight, base.deltaTime); } ApplyLimits(limits); } } public class LookAtController : MonoBehaviour { public LookAtIK ik; [Header("Target Smoothing")] [Tooltip("The target to look at. Do not use the Target transform that is assigned to LookAtIK. Set to null if you wish to stop looking.")] public Transform target; [Range(0f, 1f)] public float weight = 1f; public Vector3 offset; [Tooltip("The time it takes to switch targets.")] public float targetSwitchSmoothTime = 0.3f; [Tooltip("The time it takes to blend in/out of LookAtIK weight.")] public float weightSmoothTime = 0.3f; [Header("Turning Towards The Target")] [Tooltip("Enables smooth turning towards the target according to the parameters under this header.")] public bool smoothTurnTowardsTarget = true; [Tooltip("Speed of turning towards the target using Vector3.RotateTowards.")] public float maxRadiansDelta = 3f; [Tooltip("Speed of moving towards the target using Vector3.RotateTowards.")] public float maxMagnitudeDelta = 3f; [Tooltip("Speed of slerping towards the target.")] public float slerpSpeed = 3f; [Tooltip("The position of the pivot that the look at target is rotated around relative to the root of the character.")] public Vector3 pivotOffsetFromRoot = Vector3.up; [Tooltip("Minimum distance of looking from the first bone. Keeps the solver from failing if the target is too close.")] public float minDistance = 1f; [Header("RootRotation")] [Tooltip("Character root will be rotate around the Y axis to keep root forward within this angle from the look direction.")] [Range(0f, 180f)] public float maxRootAngle = 45f; private Transform lastTarget; private float switchWeight; private float switchWeightV; private float weightV; private Vector3 lastPosition; private Vector3 dir; private bool lastSmoothTowardsTarget; private Vector3 pivot => ((Component)ik).transform.position + ((Component)ik).transform.rotation * pivotOffsetFromRoot; private void Start() { //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_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_0033: Unknown result type (might be due to invalid IL or missing references) lastPosition = ik.solver.IKPosition; dir = ik.solver.IKPosition - pivot; } private void LateUpdate() { //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_00d1: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02da: 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_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_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_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: 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_0328: 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_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)target != (Object)(object)lastTarget) { if ((Object)(object)lastTarget == (Object)null && (Object)(object)target != (Object)null && ik.solver.IKPositionWeight <= 0f) { lastPosition = target.position; dir = target.position - pivot; ik.solver.IKPosition = target.position + offset; } else { lastPosition = ik.solver.IKPosition; dir = ik.solver.IKPosition - pivot; } switchWeight = 0f; lastTarget = target; } float num = ((!((Object)(object)target != (Object)null)) ? 0f : weight); ik.solver.IKPositionWeight = Mathf.SmoothDamp(ik.solver.IKPositionWeight, num, ref weightV, weightSmoothTime); if (ik.solver.IKPositionWeight >= 0.999f && num > ik.solver.IKPositionWeight) { ik.solver.IKPositionWeight = 1f; } if (ik.solver.IKPositionWeight <= 0.001f && num < ik.solver.IKPositionWeight) { ik.solver.IKPositionWeight = 0f; } if (!(ik.solver.IKPositionWeight <= 0f)) { switchWeight = Mathf.SmoothDamp(switchWeight, 1f, ref switchWeightV, targetSwitchSmoothTime); if (switchWeight >= 0.999f) { switchWeight = 1f; } if ((Object)(object)target != (Object)null) { ik.solver.IKPosition = Vector3.Lerp(lastPosition, target.position + offset, switchWeight); } if (smoothTurnTowardsTarget != lastSmoothTowardsTarget) { dir = ik.solver.IKPosition - pivot; lastSmoothTowardsTarget = smoothTurnTowardsTarget; } if (smoothTurnTowardsTarget) { Vector3 val = ik.solver.IKPosition - pivot; dir = Vector3.Slerp(dir, val, Time.deltaTime * slerpSpeed); dir = Vector3.RotateTowards(dir, val, Time.deltaTime * maxRadiansDelta, maxMagnitudeDelta); ik.solver.IKPosition = pivot + dir; } ApplyMinDistance(); RootRotation(); } } private void ApplyMinDistance() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_003d: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pivot; Vector3 val2 = ik.solver.IKPosition - val; val2 = ((Vector3)(ref val2)).normalized * Mathf.Max(((Vector3)(ref val2)).magnitude, minDistance); ik.solver.IKPosition = val + val2; } private void RootRotation() { //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_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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_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) float num = Mathf.Lerp(180f, maxRootAngle, ik.solver.IKPositionWeight); if (num < 180f) { Vector3 val = Quaternion.Inverse(((Component)ik).transform.rotation) * (ik.solver.IKPosition - pivot); float num2 = Mathf.Atan2(val.x, val.z) * 57.29578f; float num3 = 0f; if (num2 > num) { num3 = num2 - num; } if (num2 < 0f - num) { num3 = num2 + num; } ((Component)ik).transform.rotation = Quaternion.AngleAxis(num3, ((Component)ik).transform.up) * ((Component)ik).transform.rotation; } } } public abstract class OffsetModifier : MonoBehaviour { [Serializable] public class OffsetLimits { [Tooltip("The effector type (this is just an enum)")] public FullBodyBipedEffector effector; [Tooltip("Spring force, if zero then this is a hard limit, if not, offset can exceed the limit.")] public float spring = 0f; [Tooltip("Which axes to limit the offset on?")] public bool x; [Tooltip("Which axes to limit the offset on?")] public bool y; [Tooltip("Which axes to limit the offset on?")] public bool z; [Tooltip("The limits")] public float minX; [Tooltip("The limits")] public float maxX; [Tooltip("The limits")] public float minY; [Tooltip("The limits")] public float maxY; [Tooltip("The limits")] public float minZ; [Tooltip("The limits")] public float maxZ; public void Apply(IKEffector e, Quaternion rootRotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_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_012c: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Quaternion.Inverse(rootRotation) * e.positionOffset; if (spring <= 0f) { if (x) { val.x = Mathf.Clamp(val.x, minX, maxX); } if (y) { val.y = Mathf.Clamp(val.y, minY, maxY); } if (z) { val.z = Mathf.Clamp(val.z, minZ, maxZ); } } else { if (x) { val.x = SpringAxis(val.x, minX, maxX); } if (y) { val.y = SpringAxis(val.y, minY, maxY); } if (z) { val.z = SpringAxis(val.z, minZ, maxZ); } } e.positionOffset = rootRotation * val; } private float SpringAxis(float value, float min, float max) { if (value > min && value < max) { return value; } if (value < min) { return Spring(value, min, negative: true); } return Spring(value, max, negative: false); } private float Spring(float value, float limit, bool negative) { float num = value - limit; float num2 = num * spring; if (negative) { return value + Mathf.Clamp(0f - num2, 0f, 0f - num); } return value - Mathf.Clamp(num2, 0f, num); } } [Tooltip("The master weight")] public float weight = 1f; [Tooltip("Reference to the FBBIK component")] public FullBodyBipedIK ik; protected float lastTime; protected float deltaTime => Time.time - lastTime; protected abstract void OnModifyOffset(); protected virtual void Start() { ((MonoBehaviour)this).StartCoroutine(Initiate()); } private IEnumerator Initiate() { while ((Object)(object)ik == (Object)null) { yield return null; } IKSolverFullBodyBiped solver = ik.solver; solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPreUpdate, new IKSolver.UpdateDelegate(ModifyOffset)); lastTime = Time.time; } private void ModifyOffset() { if (((Behaviour)this).enabled && !(weight <= 0f) && !(deltaTime <= 0f) && !((Object)(object)ik == (Object)null)) { weight = Mathf.Clamp(weight, 0f, 1f); OnModifyOffset(); lastTime = Time.time; } } protected void ApplyLimits(OffsetLimits[] limits) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) foreach (OffsetLimits offsetLimits in limits) { offsetLimits.Apply(ik.solver.GetEffector(offsetLimits.effector), ((Component)this).transform.rotation); } } protected virtual void OnDestroy() { if ((Object)(object)ik != (Object)null) { IKSolverFullBodyBiped solver = ik.solver; solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPreUpdate, new IKSolver.UpdateDelegate(ModifyOffset)); } } } public abstract class OffsetModifierVRIK : MonoBehaviour { [Tooltip("The master weight")] public float weight = 1f; [Tooltip("Reference to the VRIK component")] public VRIK ik; private float lastTime; protected float deltaTime => Time.time - lastTime; protected abstract void OnModifyOffset(); protected virtual void Start() { ((MonoBehaviour)this).StartCoroutine(Initiate()); } private IEnumerator Initiate() { while ((Object)(object)ik == (Object)null) { yield return null; } IKSolverVR solver = ik.solver; solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPreUpdate, new IKSolver.UpdateDelegate(ModifyOffset)); lastTime = Time.time; } private void ModifyOffset() { if (((Behaviour)this).enabled && !(weight <= 0f) && !(deltaTime <= 0f) && !((Object)(object)ik == (Object)null)) { weight = Mathf.Clamp(weight, 0f, 1f); OnModifyOffset(); lastTime = Time.time; } } protected virtual void OnDestroy() { if ((Object)(object)ik != (Object)null) { IKSolverVR solver = ik.solver; solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPreUpdate, new IKSolver.UpdateDelegate(ModifyOffset)); } } } public class OffsetPose : MonoBehaviour { [Serializable] public class EffectorLink { public FullBodyBipedEffector effector; public Vector3 offset; public Vector3 pin; public Vector3 pinWeight; public void Apply(IKSolverFullBodyBiped solver, float weight, Quaternion rotation) { //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_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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0068: 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_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_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) IKEffector iKEffector = solver.GetEffector(effector); iKEffector.positionOffset += rotation * offset * weight; Vector3 val = solver.GetRoot().position + rotation * pin; Vector3 val2 = val - solver.GetEffector(effector).bone.position; Vector3 val3 = pinWeight * Mathf.Abs(weight); solver.GetEffector(effector).positionOffset = new Vector3(Mathf.Lerp(solver.GetEffector(effector).positionOffset.x, val2.x, val3.x), Mathf.Lerp(solver.GetEffector(effector).positionOffset.y, val2.y, val3.y), Mathf.Lerp(solver.GetEffector(effector).positionOffset.z, val2.z, val3.z)); } } public EffectorLink[] effectorLinks = new EffectorLink[0]; public void Apply(IKSolverFullBodyBiped solver, float weight) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < effectorLinks.Length; i++) { effectorLinks[i].Apply(solver, weight, solver.GetRoot().rotation); } } public void Apply(IKSolverFullBodyBiped solver, float weight, Quaternion rotation) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < effectorLinks.Length; i++) { effectorLinks[i].Apply(solver, weight, rotation); } } } public class PenetrationAvoidance : OffsetModifier { [Serializable] public class Avoider { [Serializable] public class EffectorLink { [Tooltip("Effector to apply the offset to.")] public FullBodyBipedEffector effector; [Tooltip("Multiplier of the offset value, can be negative.")] public float weight; } [Tooltip("Bones to start the raycast from. Multiple raycasts can be used by assigning more than 1 bone.")] public Transform[] raycastFrom; [Tooltip("The Transform to raycast towards. Usually the body part that you want to keep from penetrating.")] public Transform raycastTo; [Tooltip("If 0, will use simple raycasting, if > 0, will use sphere casting (better, but slower).")] [Range(0f, 1f)] public float raycastRadius; [Tooltip("Linking this to FBBIK effectors.")] public EffectorLink[] effectors; [Tooltip("The time of smooth interpolation of the offset value to avoid penetration.")] public float smoothTimeIn = 0.1f; [Tooltip("The time of smooth interpolation of the offset value blending out of penetration avoidance.")] public float smoothTimeOut = 0.3f; [Tooltip("Layers to keep penetrating from.")] public LayerMask layers; private Vector3 offset; private Vector3 offsetTarget; private Vector3 offsetV; public void Solve(IKSolverFullBodyBiped solver, float weight) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0086: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) offsetTarget = GetOffsetTarget(solver); float num = ((!(((Vector3)(ref offsetTarget)).sqrMagnitude > ((Vector3)(ref offset)).sqrMagnitude)) ? smoothTimeOut : smoothTimeIn); offset = Vector3.SmoothDamp(offset, offsetTarget, ref offsetV, num); EffectorLink[] array = effectors; foreach (EffectorLink effectorLink in array) { IKEffector effector = solver.GetEffector(effectorLink.effector); effector.positionOffset += offset * weight * effectorLink.weight; } } private Vector3 GetOffsetTarget(IKSolverFullBodyBiped solver) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_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_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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; Transform[] array = raycastFrom; foreach (Transform val2 in array) { val += Raycast(val2.position, raycastTo.position + val); } return val; } private Vector3 Raycast(Vector3 from, Vector3 to) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_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_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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Vector3 val = to - from; float magnitude = ((Vector3)(ref val)).magnitude; RaycastHit val2 = default(RaycastHit); if (raycastRadius <= 0f) { Physics.Raycast(from, val, ref val2, magnitude, LayerMask.op_Implicit(layers)); } else { Physics.SphereCast(from, raycastRadius, val, ref val2, magnitude, LayerMask.op_Implicit(layers)); } if ((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) { return Vector3.zero; } return Vector3.Project(-((Vector3)(ref val)).normalized * (magnitude - ((RaycastHit)(ref val2)).distance), ((RaycastHit)(ref val2)).normal); } } [Tooltip("Definitions of penetration avoidances.")] public Avoider[] avoiders; protected override void OnModifyOffset() { Avoider[] array = avoiders; foreach (Avoider avoider in array) { avoider.Solve(ik.solver, weight); } } } public class Recoil : OffsetModifier { [Serializable] public class RecoilOffset { [Serializable] public class EffectorLink { [Tooltip("Type of the FBBIK effector to use")] public FullBodyBipedEffector effector; [Tooltip("Weight of using this effector")] public float weight; } [Tooltip("Offset vector for the associated effector when doing recoil.")] public Vector3 offset; [Tooltip("When firing before the last recoil has faded, how much of the current recoil offset will be maintained?")] [Range(0f, 1f)] public float additivity = 1f; [Tooltip("Max additive recoil for automatic fire.")] public float maxAdditiveOffsetMag = 0.2f; [Tooltip("Linking this recoil offset to FBBIK effectors.")] public EffectorLink[] effectorLinks; private Vector3 additiveOffset; private Vector3 lastOffset; public void Start() { //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) //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) if (!(additivity <= 0f)) { additiveOffset = Vector3.ClampMagnitude(lastOffset * additivity, maxAdditiveOffsetMag); } } public void Apply(IKSolverFullBodyBiped solver, Quaternion rotation, float masterWeight, float length, float timeLeft) { //IL_0002: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) additiveOffset = Vector3.Lerp(Vector3.zero, additiveOffset, timeLeft / length); lastOffset = rotation * (offset * masterWeight) + rotation * additiveOffset; EffectorLink[] array = effectorLinks; foreach (EffectorLink effectorLink in array) { IKEffector effector = solver.GetEffector(effectorLink.effector); effector.positionOffset += lastOffset * effectorLink.weight; } } } [Serializable] public enum Handedness { Right, Left } [Tooltip("Reference to the AimIK component. Optional, only used to getting the aiming direction.")] public AimIK aimIK; [Tooltip("Set this true if you are using IKExecutionOrder.cs or a custom script to force AimIK solve after FBBIK.")] public bool aimIKSolvedLast; [Tooltip("Which hand is holding the weapon?")] public Handedness handedness; [Tooltip("Check for 2-handed weapons.")] public bool twoHanded = true; [Tooltip("Weight curve for the recoil offsets. Recoil procedure is as long as this curve.")] public AnimationCurve recoilWeight; [Tooltip("How much is the magnitude randomized each time Recoil is called?")] public float magnitudeRandom = 0.1f; [Tooltip("How much is the rotation randomized each time Recoil is called?")] public Vector3 rotationRandom; [Tooltip("Rotating the primary hand bone for the recoil (in local space).")] public Vector3 handRotationOffset; [Tooltip("Time of blending in another recoil when doing automatic fire.")] public float blendTime; [Space(10f)] [Tooltip("FBBIK effector position offsets for the recoil (in aiming direction space).")] public RecoilOffset[] offsets; [HideInInspector] public Quaternion rotationOffset = Quaternion.identity; private float magnitudeMlp = 1f; private float endTime = -1f; private Quaternion handRotation; private Quaternion secondaryHandRelativeRotation; private Quaternion randomRotation; private float length = 1f; private bool initiated; private float blendWeight; private float w; private Quaternion primaryHandRotation = Quaternion.identity; private bool handRotationsSet; private Vector3 aimIKAxis; public bool isFinished => Time.time > endTime; private IKEffector primaryHandEffector { get { if (handedness == Handedness.Right) { return ik.solver.rightHandEffector; } return ik.solver.leftHandEffector; } } private IKEffector secondaryHandEffector { get { if (handedness == Handedness.Right) { return ik.solver.leftHandEffector; } return ik.solver.rightHandEffector; } } private Transform primaryHand => primaryHandEffector.bone; private Transform secondaryHand => secondaryHandEffector.bone; public void SetHandRotations(Quaternion leftHandRotation, Quaternion rightHandRotation) { //IL_001d: 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_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) if (handedness == Handedness.Left) { primaryHandRotation = leftHandRotation; } else { primaryHandRotation = rightHandRotation; } handRotationsSet = true; } public void Fire(float magnitude) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) float num = magnitude * Random.value * magnitudeRandom; magnitudeMlp = magnitude + num; randomRotation = Quaternion.Euler(rotationRandom * Random.value); RecoilOffset[] array = offsets; foreach (RecoilOffset recoilOffset in array) { recoilOffset.Start(); } if (Time.time < endTime) { blendWeight = 0f; } else { blendWeight = 1f; } length = ((Keyframe)(ref recoilWeight.keys[^1])).time; endTime = Time.time + length; } protected override void OnModifyOffset() { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_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_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: 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_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0239: 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_0294: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_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_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0308: 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_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0335: 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_0345: 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_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0386: 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_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)aimIK != (Object)null) { aimIKAxis = aimIK.solver.axis; } if (Time.time >= endTime) { rotationOffset = Quaternion.identity; return; } if (!initiated && (Object)(object)ik != (Object)null) { initiated = true; IKSolverFullBodyBiped solver = ik.solver; solver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPostUpdate, new IKSolver.UpdateDelegate(AfterFBBIK)); if ((Object)(object)aimIK != (Object)null) { IKSolverAim solver2 = aimIK.solver; solver2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver2.OnPostUpdate, new IKSolver.UpdateDelegate(AfterAimIK)); } } blendTime = Mathf.Max(blendTime, 0f); if (blendTime > 0f) { blendWeight = Mathf.Min(blendWeight + Time.deltaTime * (1f / blendTime), 1f); } else { blendWeight = 1f; } float num = recoilWeight.Evaluate(length - (endTime - Time.time)) * magnitudeMlp; w = Mathf.Lerp(w, num, blendWeight); Quaternion val = ((!((Object)(object)aimIK != (Object)null) || !((Object)(object)aimIK.solver.transform != (Object)null) || aimIKSolvedLast) ? ik.references.root.rotation : Quaternion.LookRotation(aimIK.solver.IKPosition - aimIK.solver.transform.position, ik.references.root.up)); val = randomRotation * val; RecoilOffset[] array = offsets; foreach (RecoilOffset recoilOffset in array) { recoilOffset.Apply(ik.solver, val, w, length, endTime - Time.time); } if (!handRotationsSet) { primaryHandRotation = primaryHand.rotation; } handRotationsSet = false; rotationOffset = Quaternion.Lerp(Quaternion.identity, Quaternion.Euler(randomRotation * primaryHandRotation * handRotationOffset), w); handRotation = rotationOffset * primaryHandRotation; if (twoHanded) { Vector3 val2 = Quaternion.Inverse(primaryHand.rotation) * (secondaryHand.position - primaryHand.position); secondaryHandRelativeRotation = Quaternion.Inverse(primaryHand.rotation) * secondaryHand.rotation; Vector3 val3 = primaryHand.position + primaryHandEffector.positionOffset; Vector3 val4 = val3 + handRotation * val2; IKEffector iKEffector = secondaryHandEffector; iKEffector.positionOffset += val4 - (secondaryHand.position + secondaryHandEffector.positionOffset); } if ((Object)(object)aimIK != (Object)null && aimIKSolvedLast) { aimIK.solver.axis = Quaternion.Inverse(ik.references.root.rotation) * Quaternion.Inverse(rotationOffset) * aimIKAxis; } } private void AfterFBBIK() { //IL_001d: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!(Time.time >= endTime)) { primaryHand.rotation = handRotation; if (twoHanded) { secondaryHand.rotation = primaryHand.rotation * secondaryHandRelativeRotation; } } } private void AfterAimIK() { //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) if (aimIKSolvedLast) { aimIK.solver.axis = aimIKAxis; } } protected override void OnDestroy() { base.OnDestroy(); if ((Object)(object)ik != (Object)null && initiated) { IKSolverFullBodyBiped solver = ik.solver; solver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPostUpdate, new IKSolver.UpdateDelegate(AfterFBBIK)); if ((Object)(object)aimIK != (Object)null) { IKSolverAim solver2 = aimIK.solver; solver2.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver2.OnPostUpdate, new IKSolver.UpdateDelegate(AfterAimIK)); } } } } public class ShoulderRotator : MonoBehaviour { [Tooltip("Weight of shoulder rotation")] public float weight = 1.5f; [Tooltip("The greater the offset, the sooner the shoulder will start rotating")] public float offset = 0.2f; private FullBodyBipedIK ik; private bool skip; private void Start() { ik = ((Component)this).GetComponent(); IKSolverFullBodyBiped solver = ik.solver; solver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPostUpdate, new IKSolver.UpdateDelegate(RotateShoulders)); } private void RotateShoulders() { if (!((Object)(object)ik == (Object)null) && !(ik.solver.IKPositionWeight <= 0f)) { if (skip) { skip = false; return; } RotateShoulder(FullBodyBipedChain.LeftArm, weight, offset); RotateShoulder(FullBodyBipedChain.RightArm, weight, offset); skip = true; ik.solver.Update(); } } private void RotateShoulder(FullBodyBipedChain chain, float weight, float offset) { //IL_0008: 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_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_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_0050: 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_0070: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.FromToRotation(GetParentBoneMap(chain).swingDirection, ik.solver.GetEndEffector(chain).position - GetParentBoneMap(chain).transform.position); Vector3 val2 = ik.solver.GetEndEffector(chain).position - ik.solver.GetLimbMapping(chain).bone1.position; float num = ik.solver.GetChain(chain).nodes[0].length + ik.solver.GetChain(chain).nodes[1].length; float num2 = ((Vector3)(ref val2)).magnitude / num - 1f + offset; num2 = Mathf.Clamp(num2 * weight, 0f, 1f); Quaternion val3 = Quaternion.Lerp(Quaternion.identity, val, num2 * ik.solver.GetEndEffector(chain).positionWeight * ik.solver.IKPositionWeight); ik.solver.GetLimbMapping(chain).parentBone.rotation = val3 * ik.solver.GetLimbMapping(chain).parentBone.rotation; } private IKMapping.BoneMap GetParentBoneMap(FullBodyBipedChain chain) { return ik.solver.GetLimbMapping(chain).GetBoneMap(IKMappingLimb.BoneMapType.Parent); } private void OnDestroy() { if ((Object)(object)ik != (Object)null) { IKSolverFullBodyBiped solver = ik.solver; solver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPostUpdate, new IKSolver.UpdateDelegate(RotateShoulders)); } } } public static class VRIKCalibrator { [Serializable] public class Settings { [Tooltip("Multiplies character scale")] public float scaleMlp = 1f; [Tooltip("Local axis of the HMD facing forward.")] public Vector3 headTrackerForward = Vector3.forward; [Tooltip("Local axis of the HMD facing up.")] public Vector3 headTrackerUp = Vector3.up; [Tooltip("Local axis of the hand trackers pointing from the wrist towards the palm.")] public Vector3 handTrackerForward = Vector3.forward; [Tooltip("Local axis of the hand trackers pointing in the direction of the surface normal of the back of the hand.")] public Vector3 handTrackerUp = Vector3.up; [Tooltip("Local axis of the foot trackers towards the player's forward direction.")] public Vector3 footTrackerForward = Vector3.forward; [Tooltip("Local axis of the foot tracker towards the up direction.")] public Vector3 footTrackerUp = Vector3.up; [Space(10f)] [Tooltip("Offset of the head bone from the HMD in (headTrackerForward, headTrackerUp) space relative to the head tracker.")] public Vector3 headOffset; [Tooltip("Offset of the hand bones from the hand trackers in (handTrackerForward, handTrackerUp) space relative to the hand trackers.")] public Vector3 handOffset; [Tooltip("Forward offset of the foot bones from the foot trackers.")] public float footForwardOffset; [Tooltip("Inward offset of the foot bones from the foot trackers.")] public float footInwardOffset; [Tooltip("Used for adjusting foot heading relative to the foot trackers.")] [Range(-180f, 180f)] public float footHeadingOffset; [Range(0f, 1f)] public float pelvisPositionWeight = 1f; [Range(0f, 1f)] public float pelvisRotationWeight = 1f; } [Serializable] public class CalibrationData { [Serializable] public class Target { public bool used; public Vector3 localPosition; public Quaternion localRotation; public Target(Transform t) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) used = (Object)(object)t != (Object)null; if (used) { localPosition = t.localPosition; localRotation = t.localRotation; } } public void SetTo(Transform t) { //IL_0013: 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) if (used) { t.localPosition = localPosition; t.localRotation = localRotation; } } } public float scale; public Target head; public Target leftHand; public Target rightHand; public Target pelvis; public Target leftFoot; public Target rightFoot; public Target leftLegGoal; public Target rightLegGoal; public Vector3 pelvisTargetRight; public float pelvisPositionWeight; public float pelvisRotationWeight; } public static void RecalibrateScale(VRIK ik, CalibrationData data, Settings settings) { RecalibrateScale(ik, data, settings.scaleMlp); } public static void RecalibrateScale(VRIK ik, CalibrationData data, float scaleMlp) { //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) CalibrateScale(ik, scaleMlp); data.scale = ik.references.root.localScale.y; } private static void CalibrateScale(VRIK ik, Settings settings) { CalibrateScale(ik, settings.scaleMlp); } private static void CalibrateScale(VRIK ik, float scaleMlp = 1f) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_005a: 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) //IL_0077: 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) float num = (ik.solver.spine.headTarget.position.y - ik.references.root.position.y) / (ik.references.head.position.y - ik.references.root.position.y); Transform root = ik.references.root; root.localScale *= num * scaleMlp; } public static CalibrationData Calibrate(VRIK ik, Settings settings, Transform headTracker, Transform bodyTracker = null, Transform leftHandTracker = null, Transform rightHandTracker = null, Transform leftFootTracker = null, Transform rightFootTracker = null) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_006f: 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_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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_033c: 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_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037e: 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_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: 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_03b8: 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_03c3: 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_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f3: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0531: 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_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_054d: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) //IL_0648: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_07a5: Unknown result type (might be due to invalid IL or missing references) //IL_07aa: Unknown result type (might be due to invalid IL or missing references) //IL_08aa: Unknown result type (might be due to invalid IL or missing references) //IL_08a0: Unknown result type (might be due to invalid IL or missing references) //IL_08af: Unknown result type (might be due to invalid IL or missing references) if (!ik.solver.initiated) { Debug.LogError((object)"Can not calibrate before VRIK has initiated."); return null; } if ((Object)(object)headTracker == (Object)null) { Debug.LogError((object)"Can not calibrate VRIK without the head tracker."); return null; } CalibrationData calibrationData = new CalibrationData(); ik.solver.FixTransforms(); Vector3 position = headTracker.position + headTracker.rotation * Quaternion.LookRotation(settings.headTrackerForward, settings.headTrackerUp) * settings.headOffset; ik.references.root.position = new Vector3(position.x, ik.references.root.position.y, position.z); Vector3 val = headTracker.rotation * settings.headTrackerForward; val.y = 0f; ik.references.root.rotation = Quaternion.LookRotation(val); Transform val2 = ((!((Object)(object)ik.solver.spine.headTarget == (Object)null)) ? ik.solver.spine.headTarget : new GameObject("Head Target").transform); val2.position = position; val2.rotation = ik.references.head.rotation; val2.parent = headTracker; ik.solver.spine.headTarget = val2; float num = (val2.position.y - ik.references.root.position.y) / (ik.references.head.position.y - ik.references.root.position.y); Transform root = ik.references.root; root.localScale *= num * settings.scaleMlp; if ((Object)(object)bodyTracker != (Object)null) { Transform val3 = ((!((Object)(object)ik.solver.spine.pelvisTarget == (Object)null)) ? ik.solver.spine.pelvisTarget : new GameObject("Pelvis Target").transform); val3.position = ik.references.pelvis.position; val3.rotation = ik.references.pelvis.rotation; val3.parent = bodyTracker; ik.solver.spine.pelvisTarget = val3; ik.solver.spine.pelvisPositionWeight = settings.pelvisPositionWeight; ik.solver.spine.pelvisRotationWeight = settings.pelvisRotationWeight; ik.solver.plantFeet = false; ik.solver.spine.maxRootAngle = 180f; } else if ((Object)(object)leftFootTracker != (Object)null && (Object)(object)rightFootTracker != (Object)null) { ik.solver.spine.maxRootAngle = 0f; } if ((Object)(object)leftHandTracker != (Object)null) { Transform val4 = ((!((Object)(object)ik.solver.leftArm.target == (Object)null)) ? ik.solver.leftArm.target : new GameObject("Left Hand Target").transform); val4.position = leftHandTracker.position + leftHandTracker.rotation * Quaternion.LookRotation(settings.handTrackerForward, settings.handTrackerUp) * settings.handOffset; Vector3 upAxis = Vector3.Cross(ik.solver.leftArm.wristToPalmAxis, ik.solver.leftArm.palmToThumbAxis); val4.rotation = QuaTools.MatchRotation(leftHandTracker.rotation * Quaternion.LookRotation(settings.handTrackerForward, settings.handTrackerUp), settings.handTrackerForward, settings.handTrackerUp, ik.solver.leftArm.wristToPalmAxis, upAxis); val4.parent = leftHandTracker; ik.solver.leftArm.target = val4; ik.solver.leftArm.positionWeight = 1f; ik.solver.leftArm.rotationWeight = 1f; } else { ik.solver.leftArm.positionWeight = 0f; ik.solver.leftArm.rotationWeight = 0f; } if ((Object)(object)rightHandTracker != (Object)null) { Transform val5 = ((!((Object)(object)ik.solver.rightArm.target == (Object)null)) ? ik.solver.rightArm.target : new GameObject("Right Hand Target").transform); val5.position = rightHandTracker.position + rightHandTracker.rotation * Quaternion.LookRotation(settings.handTrackerForward, settings.handTrackerUp) * settings.handOffset; Vector3 upAxis2 = -Vector3.Cross(ik.solver.rightArm.wristToPalmAxis, ik.solver.rightArm.palmToThumbAxis); val5.rotation = QuaTools.MatchRotation(rightHandTracker.rotation * Quaternion.LookRotation(settings.handTrackerForward, settings.handTrackerUp), settings.handTrackerForward, settings.handTrackerUp, ik.solver.rightArm.wristToPalmAxis, upAxis2); val5.parent = rightHandTracker; ik.solver.rightArm.target = val5; ik.solver.rightArm.positionWeight = 1f; ik.solver.rightArm.rotationWeight = 1f; } else { ik.solver.rightArm.positionWeight = 0f; ik.solver.rightArm.rotationWeight = 0f; } if ((Object)(object)leftFootTracker != (Object)null) { CalibrateLeg(settings, leftFootTracker, ik.solver.leftLeg, (!((Object)(object)ik.references.leftToes != (Object)null)) ? ik.references.leftFoot : ik.references.leftToes, ik.references.root.forward, isLeft: true); } if ((Object)(object)rightFootTracker != (Object)null) { CalibrateLeg(settings, rightFootTracker, ik.solver.rightLeg, (!((Object)(object)ik.references.rightToes != (Object)null)) ? ik.references.rightFoot : ik.references.rightToes, ik.references.root.forward, isLeft: false); } bool flag = (Object)(object)bodyTracker != (Object)null || ((Object)(object)leftFootTracker != (Object)null && (Object)(object)rightFootTracker != (Object)null); VRIKRootController vRIKRootController = ((Component)ik.references.root).GetComponent(); if (flag) { if ((Object)(object)vRIKRootController == (Object)null) { vRIKRootController = ((Component)ik.references.root).gameObject.AddComponent(); } vRIKRootController.Calibrate(); } else if ((Object)(object)vRIKRootController != (Object)null) { Object.Destroy((Object)(object)vRIKRootController); } ik.solver.spine.minHeadHeight = 0f; ik.solver.locomotion.weight = ((!((Object)(object)bodyTracker == (Object)null) || !((Object)(object)leftFootTracker == (Object)null) || !((Object)(object)rightFootTracker == (Object)null)) ? 0f : 1f); calibrationData.scale = ik.references.root.localScale.y; calibrationData.head = new CalibrationData.Target(ik.solver.spine.headTarget); calibrationData.pelvis = new CalibrationData.Target(ik.solver.spine.pelvisTarget); calibrationData.leftHand = new CalibrationData.Target(ik.solver.leftArm.target); calibrationData.rightHand = new CalibrationData.Target(ik.solver.rightArm.target); calibrationData.leftFoot = new CalibrationData.Target(ik.solver.leftLeg.target); calibrationData.rightFoot = new CalibrationData.Target(ik.solver.rightLeg.target); calibrationData.leftLegGoal = new CalibrationData.Target(ik.solver.leftLeg.bendGoal); calibrationData.rightLegGoal = new CalibrationData.Target(ik.solver.rightLeg.bendGoal); calibrationData.pelvisTargetRight = ((!((Object)(object)vRIKRootController != (Object)null)) ? Vector3.zero : vRIKRootController.pelvisTargetRight); calibrationData.pelvisPositionWeight = ik.solver.spine.pelvisPositionWeight; calibrationData.pelvisRotationWeight = ik.solver.spine.pelvisRotationWeight; return calibrationData; } private static void CalibrateLeg(Settings settings, Transform tracker, IKSolverVR.Leg leg, Transform lastBone, Vector3 rootForward, bool isLeft) { //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_0051: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0085: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0224: 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_022e: Unknown result type (might be due to invalid IL or missing references) string text = ((!isLeft) ? "Right" : "Left"); Transform val = ((!((Object)(object)leg.target == (Object)null)) ? leg.target : new GameObject(text + " Foot Target").transform); Quaternion val2 = tracker.rotation * Quaternion.LookRotation(settings.footTrackerForward, settings.footTrackerUp); Vector3 val3 = val2 * Vector3.forward; val3.y = 0f; val2 = Quaternion.LookRotation(val3); float num = ((!isLeft) ? (0f - settings.footInwardOffset) : settings.footInwardOffset); val.position = tracker.position + val2 * new Vector3(num, 0f, settings.footForwardOffset); val.position = new Vector3(val.position.x, lastBone.position.y, val.position.z); val.rotation = lastBone.rotation; Vector3 val4 = AxisTools.GetAxisVectorToDirection(lastBone, rootForward); if (Vector3.Dot(lastBone.rotation * val4, rootForward) < 0f) { val4 = -val4; } Vector3 val5 = Quaternion.Inverse(Quaternion.LookRotation(val.rotation * val4)) * val3; float num2 = Mathf.Atan2(val5.x, val5.z) * 57.29578f; float num3 = ((!isLeft) ? (0f - settings.footHeadingOffset) : settings.footHeadingOffset); val.rotation = Quaternion.AngleAxis(num2 + num3, Vector3.up) * val.rotation; val.parent = tracker; leg.target = val; leg.positionWeight = 1f; leg.rotationWeight = 1f; Transform val6 = ((!((Object)(object)leg.bendGoal == (Object)null)) ? leg.bendGoal : new GameObject(text + " Leg Bend Goal").transform); val6.position = lastBone.position + val2 * Vector3.forward + val2 * Vector3.up; val6.parent = tracker; leg.bendGoal = val6; leg.bendGoalWeight = 1f; } public static void Calibrate(VRIK ik, CalibrationData data, Transform headTracker, Transform bodyTracker = null, Transform leftHandTracker = null, Transform rightHandTracker = null, Transform leftFootTracker = null, Transform rightFootTracker = null) { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) if (!ik.solver.initiated) { Debug.LogError((object)"Can not calibrate before VRIK has initiated."); return; } if ((Object)(object)headTracker == (Object)null) { Debug.LogError((object)"Can not calibrate VRIK without the head tracker."); return; } ik.solver.FixTransforms(); Transform val = ((!((Object)(object)ik.solver.spine.headTarget == (Object)null)) ? ik.solver.spine.headTarget : new GameObject("Head Target").transform); val.parent = headTracker; data.head.SetTo(val); ik.solver.spine.headTarget = val; ik.references.root.localScale = data.scale * Vector3.one; if ((Object)(object)bodyTracker != (Object)null && data.pelvis != null) { Transform val2 = ((!((Object)(object)ik.solver.spine.pelvisTarget == (Object)null)) ? ik.solver.spine.pelvisTarget : new GameObject("Pelvis Target").transform); val2.parent = bodyTracker; data.pelvis.SetTo(val2); ik.solver.spine.pelvisTarget = val2; ik.solver.spine.pelvisPositionWeight = data.pelvisPositionWeight; ik.solver.spine.pelvisRotationWeight = data.pelvisRotationWeight; ik.solver.plantFeet = false; ik.solver.spine.maxRootAngle = 180f; } else if ((Object)(object)leftFootTracker != (Object)null && (Object)(object)rightFootTracker != (Object)null) { ik.solver.spine.maxRootAngle = 0f; } if ((Object)(object)leftHandTracker != (Object)null) { Transform val3 = ((!((Object)(object)ik.solver.leftArm.target == (Object)null)) ? ik.solver.leftArm.target : new GameObject("Left Hand Target").transform); val3.parent = leftHandTracker; data.leftHand.SetTo(val3); ik.solver.leftArm.target = val3; ik.solver.leftArm.positionWeight = 1f; ik.solver.leftArm.rotationWeight = 1f; } else { ik.solver.leftArm.positionWeight = 0f; ik.solver.leftArm.rotationWeight = 0f; } if ((Object)(object)rightHandTracker != (Object)null) { Transform val4 = ((!((Object)(object)ik.solver.rightArm.target == (Object)null)) ? ik.solver.rightArm.target : new GameObject("Right Hand Target").transform); val4.parent = rightHandTracker; data.rightHand.SetTo(val4); ik.solver.rightArm.target = val4; ik.solver.rightArm.positionWeight = 1f; ik.solver.rightArm.rotationWeight = 1f; } else { ik.solver.rightArm.positionWeight = 0f; ik.solver.rightArm.rotationWeight = 0f; } if ((Object)(object)leftFootTracker != (Object)null) { CalibrateLeg(data, leftFootTracker, ik.solver.leftLeg, (!((Object)(object)ik.references.leftToes != (Object)null)) ? ik.references.leftFoot : ik.references.leftToes, ik.references.root.forward, isLeft: true); } if ((Object)(object)rightFootTracker != (Object)null) { CalibrateLeg(data, rightFootTracker, ik.solver.rightLeg, (!((Object)(object)ik.references.rightToes != (Object)null)) ? ik.references.rightFoot : ik.references.rightToes, ik.references.root.forward, isLeft: false); } bool flag = (Object)(object)bodyTracker != (Object)null || ((Object)(object)leftFootTracker != (Object)null && (Object)(object)rightFootTracker != (Object)null); VRIKRootController vRIKRootController = ((Component)ik.references.root).GetComponent(); if (flag) { if ((Object)(object)vRIKRootController == (Object)null) { vRIKRootController = ((Component)ik.references.root).gameObject.AddComponent(); } vRIKRootController.Calibrate(data); } else if ((Object)(object)vRIKRootController != (Object)null) { Object.Destroy((Object)(object)vRIKRootController); } ik.solver.spine.minHeadHeight = 0f; ik.solver.locomotion.weight = ((!((Object)(object)bodyTracker == (Object)null) || !((Object)(object)leftFootTracker == (Object)null) || !((Object)(object)rightFootTracker == (Object)null)) ? 0f : 1f); } private static void CalibrateLeg(CalibrationData data, Transform tracker, IKSolverVR.Leg leg, Transform lastBone, Vector3 rootForward, bool isLeft) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if ((!isLeft || data.leftFoot != null) && (isLeft || data.rightFoot != null)) { string text = ((!isLeft) ? "Right" : "Left"); Transform val = ((!((Object)(object)leg.target == (Object)null)) ? leg.target : new GameObject(text + " Foot Target").transform); val.parent = tracker; if (isLeft) { data.leftFoot.SetTo(val); } else { data.rightFoot.SetTo(val); } leg.target = val; leg.positionWeight = 1f; leg.rotationWeight = 1f; Transform val2 = ((!((Object)(object)leg.bendGoal == (Object)null)) ? leg.bendGoal : new GameObject(text + " Leg Bend Goal").transform); val2.parent = tracker; if (isLeft) { data.leftLegGoal.SetTo(val2); } else { data.rightLegGoal.SetTo(val2); } leg.bendGoal = val2; leg.bendGoalWeight = 1f; } } public static CalibrationData Calibrate(VRIK ik, Transform centerEyeAnchor, Transform leftHandAnchor, Transform rightHandAnchor, Vector3 centerEyePositionOffset, Vector3 centerEyeRotationOffset, Vector3 handPositionOffset, Vector3 handRotationOffset, float scaleMlp = 1f) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) CalibrateHead(ik, centerEyeAnchor, centerEyePositionOffset, centerEyeRotationOffset); CalibrateHands(ik, leftHandAnchor, rightHandAnchor, handPositionOffset, handRotationOffset); CalibrateScale(ik, scaleMlp); CalibrationData calibrationData = new CalibrationData(); calibrationData.scale = ik.references.root.localScale.y; calibrationData.head = new CalibrationData.Target(ik.solver.spine.headTarget); calibrationData.leftHand = new CalibrationData.Target(ik.solver.leftArm.target); calibrationData.rightHand = new CalibrationData.Target(ik.solver.rightArm.target); return calibrationData; } public static void CalibrateHead(VRIK ik, Transform centerEyeAnchor, Vector3 anchorPositionOffset, Vector3 anchorRotationOffset) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0065: 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_0076: 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_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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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) if ((Object)(object)ik.solver.spine.headTarget == (Object)null) { ik.solver.spine.headTarget = new GameObject("Head IK Target").transform; } Vector3 val = Quaternion.Inverse(ik.references.head.rotation) * ik.references.root.forward; Vector3 val2 = Quaternion.Inverse(ik.references.head.rotation) * ik.references.root.up; Quaternion val3 = Quaternion.LookRotation(val, val2); Vector3 val4 = ik.references.head.position + ik.references.head.rotation * val3 * anchorPositionOffset; Quaternion val5 = ik.references.head.rotation * val3 * Quaternion.Euler(anchorRotationOffset); Quaternion val6 = Quaternion.Inverse(val5); ik.solver.spine.headTarget.parent = centerEyeAnchor; ik.solver.spine.headTarget.localPosition = val6 * (ik.references.head.position - val4); ik.solver.spine.headTarget.localRotation = val6 * ik.references.head.rotation; } public static void CalibrateBody(VRIK ik, Transform pelvisTracker, Vector3 trackerPositionOffset, Vector3 trackerRotationOffset) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //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_002c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ik.solver.spine.pelvisTarget == (Object)null) { ik.solver.spine.pelvisTarget = new GameObject("Pelvis IK Target").transform; } ik.solver.spine.pelvisTarget.position = ik.references.pelvis.position + ik.references.root.rotation * trackerPositionOffset; ik.solver.spine.pelvisTarget.rotation = ik.references.root.rotation * Quaternion.Euler(trackerRotationOffset); ik.solver.spine.pelvisTarget.parent = pelvisTracker; } public static void CalibrateHands(VRIK ik, Transform leftHandAnchor, Transform rightHandAnchor, Vector3 anchorPositionOffset, Vector3 anchorRotationOffset) { //IL_002c: 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_009d: 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_00cd: 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) if ((Object)(object)ik.solver.leftArm.target == (Object)null) { ik.solver.leftArm.target = new GameObject("Left Hand IK Target").transform; } if ((Object)(object)ik.solver.rightArm.target == (Object)null) { ik.solver.rightArm.target = new GameObject("Right Hand IK Target").transform; } CalibrateHand(ik.references.leftHand, ik.references.leftForearm, ik.solver.leftArm.target, leftHandAnchor, anchorPositionOffset, anchorRotationOffset, isLeft: true); CalibrateHand(ik.references.rightHand, ik.references.rightForearm, ik.solver.rightArm.target, rightHandAnchor, anchorPositionOffset, anchorRotationOffset, isLeft: false); } private static void CalibrateHand(Transform hand, Transform forearm, Transform target, Transform anchor, Vector3 positionOffset, Vector3 rotationOffset, bool isLeft) { //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) //IL_0046: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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) if (isLeft) { positionOffset.x = 0f - positionOffset.x; rotationOffset.y = 0f - rotationOffset.y; rotationOffset.z = 0f - rotationOffset.z; } Vector3 val = GuessWristToPalmAxis(hand, forearm); Vector3 val2 = GuessPalmToThumbAxis(hand, forearm); Quaternion val3 = Quaternion.LookRotation(val, val2); Vector3 val4 = hand.position + hand.rotation * val3 * positionOffset; Quaternion val5 = hand.rotation * val3 * Quaternion.Euler(rotationOffset); Quaternion val6 = Quaternion.Inverse(val5); target.parent = anchor; target.localPosition = val6 * (hand.position - val4); target.localRotation = val6 * hand.rotation; } public static Vector3 GuessWristToPalmAxis(Transform hand, Transform forearm) { //IL_0002: 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_0014: 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_0020: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) Vector3 val = forearm.position - hand.position; Vector3 val2 = AxisTools.ToVector3(AxisTools.GetAxisToDirection(hand, val)); if (Vector3.Dot(val, hand.rotation * val2) > 0f) { val2 = -val2; } return val2; } public static Vector3 GuessPalmToThumbAxis(Transform hand, Transform forearm) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0108: 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_0082: 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_0099: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: 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) if (hand.childCount == 0) { Debug.LogWarning((object)("Hand " + ((Object)hand).name + " does not have any fingers, VRIK can not guess the hand bone's orientation. Please assign 'Wrist To Palm Axis' and 'Palm To Thumb Axis' manually for both arms in VRIK settings."), (Object)(object)hand); return Vector3.zero; } float num = float.PositiveInfinity; int num2 = 0; for (int i = 0; i < hand.childCount; i++) { float num3 = Vector3.SqrMagnitude(hand.GetChild(i).position - hand.position); if (num3 < num) { num = num3; num2 = i; } } Vector3 val = Vector3.Cross(hand.position - forearm.position, hand.GetChild(num2).position - hand.position); Vector3 val2 = Vector3.Cross(val, hand.position - forearm.position); Vector3 val3 = AxisTools.ToVector3(AxisTools.GetAxisToDirection(hand, val2)); if (Vector3.Dot(val2, hand.rotation * val3) < 0f) { val3 = -val3; } return val3; } } public class VRIKLODController : MonoBehaviour { public Renderer LODRenderer; public float LODDistance = 15f; public bool allowCulled = true; private VRIK ik; private void Start() { ik = ((Component)this).GetComponent(); } private void Update() { ik.solver.LOD = GetLODLevel(); } private int GetLODLevel() { //IL_0048: 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_0061: Unknown result type (might be due to invalid IL or missing references) if (allowCulled) { if ((Object)(object)LODRenderer == (Object)null) { return 0; } if (!LODRenderer.isVisible) { return 2; } } Vector3 val = ((Component)ik).transform.position - ((Component)Camera.main).transform.position; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude > LODDistance * LODDistance) { return 1; } return 0; } } public class VRIKRootController : MonoBehaviour { private Transform pelvisTarget; private Transform leftFootTarget; private Transform rightFootTarget; private VRIK ik; public Vector3 pelvisTargetRight { get; private set; } private void Awake() { ik = ((Component)this).GetComponent(); IKSolverVR solver = ik.solver; solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPreUpdate, new IKSolver.UpdateDelegate(OnPreUpdate)); Calibrate(); } public void Calibrate() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)ik == (Object)null) { Debug.LogError((object)"No VRIK found on VRIKRootController's GameObject.", (Object)(object)((Component)this).transform); return; } pelvisTarget = ik.solver.spine.pelvisTarget; leftFootTarget = ik.solver.leftLeg.target; rightFootTarget = ik.solver.rightLeg.target; if ((Object)(object)pelvisTarget != (Object)null) { pelvisTargetRight = Quaternion.Inverse(pelvisTarget.rotation) * ik.references.root.right; } } public void Calibrate(VRIKCalibrator.CalibrationData data) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)ik == (Object)null) { Debug.LogError((object)"No VRIK found on VRIKRootController's GameObject.", (Object)(object)((Component)this).transform); return; } pelvisTarget = ik.solver.spine.pelvisTarget; leftFootTarget = ik.solver.leftLeg.target; rightFootTarget = ik.solver.rightLeg.target; if ((Object)(object)pelvisTarget != (Object)null) { pelvisTargetRight = data.pelvisTargetRight; } } private void OnPreUpdate() { //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_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_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_0076: 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_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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) if (((Behaviour)this).enabled) { if ((Object)(object)pelvisTarget != (Object)null) { ik.references.root.position = new Vector3(pelvisTarget.position.x, ik.references.root.position.y, pelvisTarget.position.z); Vector3 val = Vector3.Cross(pelvisTarget.rotation * pelvisTargetRight, ik.references.root.up); val.y = 0f; ik.references.root.rotation = Quaternion.LookRotation(val); ik.references.pelvis.position = Vector3.Lerp(ik.references.pelvis.position, pelvisTarget.position, ik.solver.spine.pelvisPositionWeight); ik.references.pelvis.rotation = Quaternion.Slerp(ik.references.pelvis.rotation, pelvisTarget.rotation, ik.solver.spine.pelvisRotationWeight); } else if ((Object)(object)leftFootTarget != (Object)null && (Object)(object)rightFootTarget != (Object)null) { ik.references.root.position = Vector3.Lerp(leftFootTarget.position, rightFootTarget.position, 0.5f); } } } private void OnDestroy() { if ((Object)(object)ik != (Object)null) { IKSolverVR solver = ik.solver; solver.OnPreUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPreUpdate, new IKSolver.UpdateDelegate(OnPreUpdate)); } } } } namespace RootMotion.Demos { public class AimBoxing : MonoBehaviour { public AimIK aimIK; public Transform pin; private void LateUpdate() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) aimIK.solver.transform.LookAt(pin.position); ((IKSolver)aimIK.solver).IKPosition = ((Component)this).transform.position; } } public class AimSwing : MonoBehaviour { public AimIK ik; [Tooltip("The direction of the animated weapon swing in character space. Tweak this value to adjust the aiming.")] public Vector3 animatedSwingDirection = Vector3.forward; private void LateUpdate() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_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) ik.solver.axis = ik.solver.transform.InverseTransformVector(((Component)ik).transform.rotation * animatedSwingDirection); } } public class SecondHandOnGun : MonoBehaviour { public AimIK aim; public LimbIK leftArmIK; public Transform leftHand; public Transform rightHand; public Vector3 leftHandPositionOffset; public Vector3 leftHandRotationOffset; private Vector3 leftHandPosRelToRight; private Quaternion leftHandRotRelToRight; private void Start() { ((Behaviour)aim).enabled = false; ((Behaviour)leftArmIK).enabled = false; } private void LateUpdate() { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0070: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) leftHandPosRelToRight = rightHand.InverseTransformPoint(leftHand.position); leftHandRotRelToRight = Quaternion.Inverse(rightHand.rotation) * leftHand.rotation; ((IKSolver)aim.solver).Update(); ((IKSolver)leftArmIK.solver).IKPosition = rightHand.TransformPoint(leftHandPosRelToRight + leftHandPositionOffset); ((IKSolverTrigonometric)leftArmIK.solver).IKRotation = rightHand.rotation * Quaternion.Euler(leftHandRotationOffset) * leftHandRotRelToRight; ((IKSolver)leftArmIK.solver).Update(); } } public class SimpleAimingSystem : MonoBehaviour { [Tooltip("AimPoser is a tool that returns an animation name based on direction.")] public AimPoser aimPoser; [Tooltip("Reference to the AimIK component.")] public AimIK aim; [Tooltip("Reference to the LookAt component (only used for the head in this instance).")] public LookAtIK lookAt; [Tooltip("Reference to the Animator component.")] public Animator animator; [Tooltip("Time of cross-fading from pose to pose.")] public float crossfadeTime = 0.2f; [Tooltip("Will keep the aim target at a distance.")] public float minAimDistance = 0.5f; private Pose aimPose; private Pose lastPose; private void Start() { ((Behaviour)aim).enabled = false; ((Behaviour)lookAt).enabled = false; } private void LateUpdate() { if ((Object)(object)((IKSolverHeuristic)aim.solver).target == (Object)null) { Debug.LogWarning((object)"AimIK and LookAtIK need to have their 'Target' value assigned.", (Object)(object)((Component)this).transform); } Pose(); ((IKSolver)aim.solver).Update(); if ((Object)(object)lookAt != (Object)null) { ((IKSolver)lookAt.solver).Update(); } } private void Pose() { //IL_0017: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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) LimitAimTarget(); Vector3 val = ((IKSolverHeuristic)aim.solver).target.position - ((Point)((IKSolverHeuristic)aim.solver).bones[0]).transform.position; Vector3 val2 = ((Component)this).transform.InverseTransformDirection(val); aimPose = aimPoser.GetPose(val2); if (aimPose != lastPose) { aimPoser.SetPoseActive(aimPose); lastPose = aimPose; } Pose[] poses = aimPoser.poses; foreach (Pose val3 in poses) { if (val3 == aimPose) { DirectCrossFade(val3.name, 1f); } else { DirectCrossFade(val3.name, 0f); } } } private void LimitAimTarget() { //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_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_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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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) Vector3 position = ((Point)((IKSolverHeuristic)aim.solver).bones[0]).transform.position; Vector3 val = ((IKSolverHeuristic)aim.solver).target.position - position; val = ((Vector3)(ref val)).normalized * Mathf.Max(((Vector3)(ref val)).magnitude, minAimDistance); ((IKSolverHeuristic)aim.solver).target.position = position + val; } private void DirectCrossFade(string state, float target) { float num = Mathf.MoveTowards(animator.GetFloat(state), target, Time.deltaTime * (1f / crossfadeTime)); animator.SetFloat(state, num); } } public class TerrainOffset : MonoBehaviour { public AimIK aimIK; public Vector3 raycastOffset = new Vector3(0f, 2f, 1.5f); public LayerMask raycastLayers; public float min = -2f; public float max = 2f; public float lerpSpeed = 10f; private RaycastHit hit; private Vector3 offset; private void LateUpdate() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0098: 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_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) Vector3 val = ((Component)this).transform.rotation * raycastOffset; Vector3 groundHeightOffset = GetGroundHeightOffset(((Component)this).transform.position + val); offset = Vector3.Lerp(offset, groundHeightOffset, Time.deltaTime * lerpSpeed); Vector3 val2 = ((Component)this).transform.position + new Vector3(val.x, 0f, val.z); aimIK.solver.transform.LookAt(val2); ((IKSolver)aimIK.solver).IKPosition = val2 + offset; } private Vector3 GetGroundHeightOffset(Vector3 worldPosition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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) //IL_002b: 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_009b: 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_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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Debug.DrawRay(worldPosition, Vector3.down * raycastOffset.y * 2f, Color.green); if (Physics.Raycast(worldPosition, Vector3.down, ref hit, raycastOffset.y * 2f)) { return Mathf.Clamp(((RaycastHit)(ref hit)).point.y - ((Component)this).transform.position.y, min, max) * Vector3.up; } return Vector3.zero; } } public class BipedIKvsAnimatorIK : MonoBehaviour { [LargeHeader("References")] public Animator animator; public BipedIK bipedIK; [LargeHeader("Look At")] public Transform lookAtTargetBiped; public Transform lookAtTargetAnimator; [Range(0f, 1f)] public float lookAtWeight = 1f; [Range(0f, 1f)] public float lookAtBodyWeight = 1f; [Range(0f, 1f)] public float lookAtHeadWeight = 1f; [Range(0f, 1f)] public float lookAtEyesWeight = 1f; [Range(0f, 1f)] public float lookAtClampWeight = 0.5f; [Range(0f, 1f)] public float lookAtClampWeightHead = 0.5f; [Range(0f, 1f)] public float lookAtClampWeightEyes = 0.5f; [LargeHeader("Foot")] public Transform footTargetBiped; public Transform footTargetAnimator; [Range(0f, 1f)] public float footPositionWeight = 0f; [Range(0f, 1f)] public float footRotationWeight = 0f; [LargeHeader("Hand")] public Transform handTargetBiped; public Transform handTargetAnimator; [Range(0f, 1f)] public float handPositionWeight = 0f; [Range(0f, 1f)] public float handRotationWeight = 0f; private void OnAnimatorIK(int layer) { //IL_0017: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) ((Component)animator).transform.rotation = ((Component)bipedIK).transform.rotation; Vector3 val = ((Component)animator).transform.position - ((Component)bipedIK).transform.position; lookAtTargetAnimator.position = lookAtTargetBiped.position + val; bipedIK.SetLookAtPosition(lookAtTargetBiped.position); bipedIK.SetLookAtWeight(lookAtWeight, lookAtBodyWeight, lookAtHeadWeight, lookAtEyesWeight, lookAtClampWeight, lookAtClampWeightHead, lookAtClampWeightEyes); animator.SetLookAtPosition(lookAtTargetAnimator.position); animator.SetLookAtWeight(lookAtWeight, lookAtBodyWeight, lookAtHeadWeight, lookAtEyesWeight, lookAtClampWeight); footTargetAnimator.position = footTargetBiped.position + val; footTargetAnimator.rotation = footTargetBiped.rotation; bipedIK.SetIKPosition((AvatarIKGoal)0, footTargetBiped.position); bipedIK.SetIKRotation((AvatarIKGoal)0, footTargetBiped.rotation); bipedIK.SetIKPositionWeight((AvatarIKGoal)0, footPositionWeight); bipedIK.SetIKRotationWeight((AvatarIKGoal)0, footRotationWeight); animator.SetIKPosition((AvatarIKGoal)0, footTargetAnimator.position); animator.SetIKRotation((AvatarIKGoal)0, footTargetAnimator.rotation); animator.SetIKPositionWeight((AvatarIKGoal)0, footPositionWeight); animator.SetIKRotationWeight((AvatarIKGoal)0, footRotationWeight); handTargetAnimator.position = handTargetBiped.position + val; handTargetAnimator.rotation = handTargetBiped.rotation; bipedIK.SetIKPosition((AvatarIKGoal)2, handTargetBiped.position); bipedIK.SetIKRotation((AvatarIKGoal)2, handTargetBiped.rotation); bipedIK.SetIKPositionWeight((AvatarIKGoal)2, handPositionWeight); bipedIK.SetIKRotationWeight((AvatarIKGoal)2, handRotationWeight); animator.SetIKPosition((AvatarIKGoal)2, handTargetAnimator.position); animator.SetIKRotation((AvatarIKGoal)2, handTargetAnimator.rotation); animator.SetIKPositionWeight((AvatarIKGoal)2, handPositionWeight); animator.SetIKRotationWeight((AvatarIKGoal)2, handRotationWeight); } } public class MechSpider : MonoBehaviour { public LayerMask raycastLayers; public float scale = 1f; public Transform body; public MechSpiderLeg[] legs; public float legRotationWeight = 1f; public float rootPositionSpeed = 5f; public float rootRotationSpeed = 30f; public float breatheSpeed = 2f; public float breatheMagnitude = 0.2f; public float height = 3.5f; public float minHeight = 2f; public float raycastHeight = 10f; public float raycastDistance = 5f; private Vector3 lastPosition; private Vector3 defaultBodyLocalPosition; private float sine; private RaycastHit rootHit; public Vector3 velocity { get; private set; } private void Start() { //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) lastPosition = ((Component)this).transform.position; } private void Update() { //IL_0008: 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_001d: 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_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_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_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) //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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00ad: 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_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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: 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_0219: Unknown result type (might be due to invalid IL or missing references) velocity = (((Component)this).transform.position - lastPosition) / Time.deltaTime; lastPosition = ((Component)this).transform.position; Vector3 legsPlaneNormal = GetLegsPlaneNormal(); Quaternion val = Quaternion.FromToRotation(((Component)this).transform.up, legsPlaneNormal); ((Component)this).transform.rotation = Quaternion.Slerp(((Component)this).transform.rotation, val * ((Component)this).transform.rotation, Time.deltaTime * rootRotationSpeed); Vector3 legCentroid = GetLegCentroid(); Vector3 val2 = Vector3.Project(legCentroid + ((Component)this).transform.up * height * scale - ((Component)this).transform.position, ((Component)this).transform.up); Transform transform = ((Component)this).transform; transform.position += val2 * Time.deltaTime * (rootPositionSpeed * scale); if (Physics.Raycast(((Component)this).transform.position + ((Component)this).transform.up * raycastHeight * scale, -((Component)this).transform.up, ref rootHit, raycastHeight * scale + raycastDistance * scale, LayerMask.op_Implicit(raycastLayers))) { ref RaycastHit reference = ref rootHit; ((RaycastHit)(ref reference)).distance = ((RaycastHit)(ref reference)).distance - (raycastHeight * scale + minHeight * scale); if (((RaycastHit)(ref rootHit)).distance < 0f) { Vector3 val3 = ((Component)this).transform.position - ((Component)this).transform.up * ((RaycastHit)(ref rootHit)).distance; ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, val3, Time.deltaTime * rootPositionSpeed * scale); } } sine += Time.deltaTime * breatheSpeed; if (sine >= (float)Math.PI * 2f) { sine -= (float)Math.PI * 2f; } float num = Mathf.Sin(sine) * breatheMagnitude * scale; Vector3 val4 = ((Component)this).transform.up * num; ((Component)body).transform.position = ((Component)this).transform.position + val4; } private Vector3 GetLegCentroid() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0053: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; float num = 1f / (float)legs.Length; for (int i = 0; i < legs.Length; i++) { val += legs[i].position * num; } return val; } private Vector3 GetLegsPlaneNormal() { //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_001d: 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_00e8: 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_005f: 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_0075: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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) Vector3 val = ((Component)this).transform.up; if (legRotationWeight <= 0f) { return val; } float num = 1f / Mathf.Lerp((float)legs.Length, 1f, legRotationWeight); for (int i = 0; i < legs.Length; i++) { Vector3 val2 = legs[i].position - (((Component)this).transform.position - ((Component)this).transform.up * height * scale); Vector3 up = ((Component)this).transform.up; Vector3 val3 = val2; Vector3.OrthoNormalize(ref up, ref val3); Quaternion val4 = Quaternion.FromToRotation(val3, val2); val4 = Quaternion.Lerp(Quaternion.identity, val4, num); val = val4 * val; } return val; } } public class MechSpiderController : MonoBehaviour { public MechSpider mechSpider; public Transform cameraTransform; public float speed = 6f; public float turnSpeed = 30f; public Vector3 inputVector => new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical")); private void Update() { //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_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_0022: 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_0033: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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_0053: 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_006e: 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_0097: Unknown result type (might be due to invalid IL or missing references) Vector3 forward = cameraTransform.forward; Vector3 up = ((Component)this).transform.up; Vector3.OrthoNormalize(ref up, ref forward); Quaternion val = Quaternion.LookRotation(forward, ((Component)this).transform.up); Transform transform = ((Component)this).transform; Vector3 val2 = inputVector; transform.Translate(val * ((Vector3)(ref val2)).normalized * Time.deltaTime * speed * mechSpider.scale, (Space)0); ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val, Time.deltaTime * turnSpeed); } } public class MechSpiderLeg : MonoBehaviour { public MechSpider mechSpider; public MechSpiderLeg unSync; public Vector3 offset; public float minDelay = 0.2f; public float maxOffset = 1f; public float stepSpeed = 5f; public float footHeight = 0.15f; public float velocityPrediction = 0.2f; public float raycastFocus = 0.1f; public AnimationCurve yOffset; public Transform foot; public Vector3 footUpAxis; public float footRotationSpeed = 10f; public ParticleSystem sand; private IK ik; private float stepProgress = 1f; private float lastStepTime; private Vector3 defaultPosition; private RaycastHit hit = default(RaycastHit); private Quaternion lastFootLocalRotation; private Vector3 smoothHitNormal = Vector3.up; private Vector3 lastStepPosition; public bool isStepping => stepProgress < 1f; public Vector3 position { get { //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_0017: Unknown result type (might be due to invalid IL or missing references) return ik.GetIKSolver().GetIKPosition(); } set { //IL_000c: Unknown result type (might be due to invalid IL or missing references) ik.GetIKSolver().SetIKPosition(value); } } private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_004f: Unknown result type (might be due to invalid IL or missing references) ik = ((Component)this).GetComponent(); if ((Object)(object)foot != (Object)null) { if (footUpAxis == Vector3.zero) { footUpAxis = Quaternion.Inverse(foot.rotation) * Vector3.up; } lastFootLocalRotation = foot.localRotation; IKSolver iKSolver = ik.GetIKSolver(); iKSolver.OnPostUpdate = (UpdateDelegate)Delegate.Combine((Delegate?)(object)iKSolver.OnPostUpdate, (Delegate?)new UpdateDelegate(AfterIK)); } } private void AfterIK() { //IL_001e: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) if (!((Object)(object)foot == (Object)null)) { foot.localRotation = lastFootLocalRotation; smoothHitNormal = Vector3.Slerp(smoothHitNormal, ((RaycastHit)(ref hit)).normal, Time.deltaTime * footRotationSpeed); Quaternion val = Quaternion.FromToRotation(foot.rotation * footUpAxis, smoothHitNormal); foot.rotation = val * foot.rotation; } } private void Start() { //IL_000f: 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_0016: 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_0056: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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) stepProgress = 1f; hit = default(RaycastHit); position = ik.GetIKSolver().GetPoints()[^1].transform.position; lastStepPosition = position; ((RaycastHit)(ref hit)).point = position; defaultPosition = ((Component)mechSpider).transform.InverseTransformPoint(position + offset * mechSpider.scale); ((MonoBehaviour)this).StartCoroutine(Step(position, position)); } private Vector3 GetStepTarget(out bool stepFound, float focus, float distance) { //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_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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) stepFound = false; Vector3 val = ((Component)mechSpider).transform.TransformPoint(defaultPosition); val += mechSpider.velocity * velocityPrediction; Vector3 up = ((Component)mechSpider).transform.up; Vector3 val2 = mechSpider.body.position - position; Vector3 val3 = Vector3.Cross(up, val2); up = Quaternion.AngleAxis(focus, val3) * up; if (Physics.Raycast(val + up * mechSpider.raycastHeight * mechSpider.scale, -up, ref hit, mechSpider.raycastHeight * mechSpider.scale + distance, LayerMask.op_Implicit(mechSpider.raycastLayers))) { stepFound = true; } return ((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * footHeight * mechSpider.scale; } private void UpdatePosition(float distance) { //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_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_0024: 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_003f: 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_0085: 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_009b: 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) Vector3 up = ((Component)mechSpider).transform.up; if (Physics.Raycast(lastStepPosition + up * mechSpider.raycastHeight * mechSpider.scale, -up, ref hit, mechSpider.raycastHeight * mechSpider.scale + distance, LayerMask.op_Implicit(mechSpider.raycastLayers))) { position = ((RaycastHit)(ref hit)).point + ((RaycastHit)(ref hit)).normal * footHeight * mechSpider.scale; } } private void Update() { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) UpdatePosition(mechSpider.raycastDistance * mechSpider.scale); if (!isStepping && !(Time.time < lastStepTime + minDelay) && (!((Object)(object)unSync != (Object)null) || !unSync.isStepping)) { bool stepFound = false; Vector3 stepTarget = GetStepTarget(out stepFound, raycastFocus, mechSpider.raycastDistance * mechSpider.scale); if (!stepFound) { stepTarget = GetStepTarget(out stepFound, 0f - raycastFocus, mechSpider.raycastDistance * 3f * mechSpider.scale); } if (stepFound && !(Vector3.Distance(position, stepTarget) < maxOffset * mechSpider.scale * Random.Range(0.9f, 1.2f))) { ((MonoBehaviour)this).StopAllCoroutines(); ((MonoBehaviour)this).StartCoroutine(Step(position, stepTarget)); } } } private IEnumerator Step(Vector3 stepStartPosition, Vector3 targetPosition) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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) stepProgress = 0f; while (stepProgress < 1f) { stepProgress += Time.deltaTime * stepSpeed; position = Vector3.Lerp(stepStartPosition, targetPosition, stepProgress); MechSpiderLeg mechSpiderLeg = this; mechSpiderLeg.position += ((Component)mechSpider).transform.up * yOffset.Evaluate(stepProgress) * mechSpider.scale; lastStepPosition = position; yield return null; } position = targetPosition; lastStepPosition = position; if ((Object)(object)sand != (Object)null) { ((Component)sand).transform.position = position - ((Component)mechSpider).transform.up * footHeight * mechSpider.scale; sand.Emit(20); } lastStepTime = Time.time; } } public class MechSpiderParticles : MonoBehaviour { public MechSpiderController mechSpiderController; private ParticleSystem particles; private void Start() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown particles = (ParticleSystem)((Component)this).GetComponent(typeof(ParticleSystem)); } private void Update() { //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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_005a: 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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) Vector3 inputVector = mechSpiderController.inputVector; float magnitude = ((Vector3)(ref inputVector)).magnitude; float num = Mathf.Clamp(magnitude * 50f, 30f, 50f); EmissionModule emission = particles.emission; ((EmissionModule)(ref emission)).rateOverTime = new MinMaxCurve(num); MainModule main = particles.main; MainModule main2 = particles.main; MinMaxGradient startColor = ((MainModule)(ref main2)).startColor; float r = ((MinMaxGradient)(ref startColor)).color.r; MainModule main3 = particles.main; MinMaxGradient startColor2 = ((MainModule)(ref main3)).startColor; float g = ((MinMaxGradient)(ref startColor2)).color.g; MainModule main4 = particles.main; MinMaxGradient startColor3 = ((MainModule)(ref main4)).startColor; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(r, g, ((MinMaxGradient)(ref startColor3)).color.b, Mathf.Clamp(magnitude, 0.4f, 1f))); } } } namespace RootMotion1.Demos { public class AnimationWarping : OffsetModifier { [Serializable] public struct Warp { [Tooltip("Layer of the 'Animation State' in the Animator.")] public int animationLayer; [Tooltip("Name of the state in the Animator to warp.")] public string animationState; [Tooltip("Warping weight by normalized time of the animation state.")] public AnimationCurve weightCurve; [Tooltip("Animated point to warp from. This should be in character space so keep this Transform parented to the root of the character.")] public Transform warpFrom; [Tooltip("World space point to warp to.")] public Transform warpTo; [Tooltip("Which FBBIK effector to use?")] public FullBodyBipedEffector effector; } [Serializable] public enum EffectorMode { PositionOffset, Position } [Tooltip("Reference to the Animator component to use")] public Animator animator; [Tooltip("Using effector.positionOffset or effector.position with effector.positionWeight? The former will enable you to use effector.position for other things, the latter will weigh in the effectors, hence using Reach and Pull in the process.")] public EffectorMode effectorMode; [Space(10f)] [Tooltip("The array of warps, can have multiple simultaneous warps.")] public Warp[] warps; private EffectorMode lastMode; protected override void Start() { base.Start(); lastMode = effectorMode; } public float GetWarpWeight(int warpIndex) { //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) if (warpIndex < 0) { Debug.LogError((object)"Warp index out of range."); return 0f; } if (warpIndex >= warps.Length) { Debug.LogError((object)"Warp index out of range."); return 0f; } if ((Object)(object)animator == (Object)null) { Debug.LogError((object)"Animator unassigned in AnimationWarping"); return 0f; } AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(warps[warpIndex].animationLayer); if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName(warps[warpIndex].animationState)) { return 0f; } return warps[warpIndex].weightCurve.Evaluate(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime - (float)(int)((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime); } protected override void OnModifyOffset() { //IL_0022: 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_003d: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f1: 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) for (int i = 0; i < warps.Length; i++) { float warpWeight = GetWarpWeight(i); Vector3 val = warps[i].warpTo.position - warps[i].warpFrom.position; switch (effectorMode) { case EffectorMode.PositionOffset: { IKEffector effector = ik.solver.GetEffector(warps[i].effector); effector.positionOffset += val * warpWeight * weight; break; } case EffectorMode.Position: ik.solver.GetEffector(warps[i].effector).position = ik.solver.GetEffector(warps[i].effector).bone.position + val; ik.solver.GetEffector(warps[i].effector).positionWeight = weight * warpWeight; break; } } if (lastMode == EffectorMode.Position && effectorMode == EffectorMode.PositionOffset) { Warp[] array = warps; for (int j = 0; j < array.Length; j++) { Warp warp = array[j]; ik.solver.GetEffector(warp.effector).positionWeight = 0f; } } lastMode = effectorMode; } private void OnDisable() { if (effectorMode == EffectorMode.Position) { Warp[] array = warps; for (int i = 0; i < array.Length; i++) { Warp warp = array[i]; ik.solver.GetEffector(warp.effector).positionWeight = 0f; } } } } } namespace RootMotion.Demos { public class AnimatorController3rdPerson : MonoBehaviour { public float rotateSpeed = 7f; public float blendSpeed = 10f; public float maxAngle = 90f; public float moveSpeed = 1.5f; public float rootMotionWeight; protected Animator animator; protected Vector3 moveBlend; protected Vector3 moveInput; protected Vector3 velocity; protected virtual void Start() { animator = ((Component)this).GetComponent(); } private void OnAnimatorMove() { //IL_0003: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_0044: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) velocity = Vector3.Lerp(velocity, ((Component)this).transform.rotation * Vector3.ClampMagnitude(moveInput, 1f) * moveSpeed, Time.deltaTime * blendSpeed); Transform transform = ((Component)this).transform; transform.position += Vector3.Lerp(velocity * Time.deltaTime, animator.deltaPosition, rootMotionWeight); } public virtual void Move(Vector3 moveInput, bool isMoving, Vector3 faceDirection, Vector3 aimTarget) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_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) this.moveInput = moveInput; Vector3 val = ((Component)this).transform.InverseTransformDirection(faceDirection); float num = Mathf.Atan2(val.x, val.z) * 57.29578f; float num2 = num * Time.deltaTime * rotateSpeed; if (num > maxAngle) { num2 = Mathf.Clamp(num2, num - maxAngle, num2); } if (num < 0f - maxAngle) { num2 = Mathf.Clamp(num2, num2, num + maxAngle); } ((Component)this).transform.Rotate(Vector3.up, num2); moveBlend = Vector3.Lerp(moveBlend, moveInput, Time.deltaTime * blendSpeed); animator.SetFloat("X", moveBlend.x); animator.SetFloat("Z", moveBlend.z); animator.SetBool("IsMoving", isMoving); } } public class AnimatorController3rdPersonIK : AnimatorController3rdPerson { [Range(0f, 1f)] public float headLookWeight = 1f; public Vector3 gunHoldOffset; public Vector3 leftHandOffset; public Recoil recoil; private AimIK aim; private FullBodyBipedIK ik; private Vector3 headLookAxis; private Vector3 leftHandPosRelToRightHand; private Quaternion leftHandRotRelToRightHand; private Vector3 aimTarget; private Quaternion rightHandRotation; protected override void Start() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) base.Start(); aim = ((Component)this).GetComponent(); ik = ((Component)this).GetComponent(); IKSolverFullBodyBiped solver = ik.solver; ((IKSolverFullBody)solver).OnPreRead = (UpdateDelegate)Delegate.Combine((Delegate?)(object)((IKSolverFullBody)solver).OnPreRead, (Delegate?)new UpdateDelegate(OnPreRead)); ((Behaviour)aim).enabled = false; ((Behaviour)ik).enabled = false; headLookAxis = ik.references.head.InverseTransformVector(ik.references.root.forward); animator.SetLayerWeight(1, 1f); } public override void Move(Vector3 moveInput, bool isMoving, Vector3 faceDirection, Vector3 aimTarget) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_002d: Unknown result type (might be due to invalid IL or missing references) base.Move(moveInput, isMoving, faceDirection, aimTarget); this.aimTarget = aimTarget; Read(); AimIK(); FBBIK(); AimIK(); HeadLookAt(aimTarget); } private void Read() { //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_002c: 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_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_0066: Unknown result type (might be due to invalid IL or missing references) leftHandPosRelToRightHand = ik.references.rightHand.InverseTransformPoint(ik.references.leftHand.position); leftHandRotRelToRightHand = Quaternion.Inverse(ik.references.rightHand.rotation) * ik.references.leftHand.rotation; } private void AimIK() { //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) ((IKSolver)aim.solver).IKPosition = aimTarget; ((IKSolver)aim.solver).Update(); } private void FBBIK() { //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_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_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_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_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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) rightHandRotation = ik.references.rightHand.rotation; Vector3 val = ik.references.rightHand.rotation * gunHoldOffset; IKEffector rightHandEffector = ik.solver.rightHandEffector; rightHandEffector.positionOffset += val; if ((Object)(object)recoil != (Object)null) { recoil.SetHandRotations(rightHandRotation * leftHandRotRelToRightHand, rightHandRotation); } ((IKSolver)ik.solver).Update(); if ((Object)(object)recoil != (Object)null) { ik.references.rightHand.rotation = recoil.rotationOffset * rightHandRotation; ik.references.leftHand.rotation = recoil.rotationOffset * rightHandRotation * leftHandRotRelToRightHand; } else { ik.references.rightHand.rotation = rightHandRotation; ik.references.leftHand.rotation = rightHandRotation * leftHandRotRelToRightHand; } } private void OnPreRead() { //IL_002e: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //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_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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) Quaternion val = ((!((Object)(object)recoil != (Object)null)) ? rightHandRotation : (recoil.rotationOffset * rightHandRotation)); Vector3 val2 = ik.references.rightHand.position + ik.solver.rightHandEffector.positionOffset + val * leftHandPosRelToRightHand; IKEffector leftHandEffector = ik.solver.leftHandEffector; leftHandEffector.positionOffset += val2 - ik.references.leftHand.position - ik.solver.leftHandEffector.positionOffset + val * leftHandOffset; } private void HeadLookAt(Vector3 lookAtTarget) { //IL_0011: 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_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) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.FromToRotation(ik.references.head.rotation * headLookAxis, lookAtTarget - ik.references.head.position); ik.references.head.rotation = Quaternion.Lerp(Quaternion.identity, val, headLookWeight) * ik.references.head.rotation; } private void OnDestroy() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown if ((Object)(object)ik != (Object)null) { IKSolverFullBodyBiped solver = ik.solver; ((IKSolverFullBody)solver).OnPreRead = (UpdateDelegate)Delegate.Remove((Delegate?)(object)((IKSolverFullBody)solver).OnPreRead, (Delegate?)new UpdateDelegate(OnPreRead)); } } } public class CharacterAnimationThirdPersonIK : CharacterAnimationThirdPerson { private FullBodyBipedIK ik; protected override void Start() { base.Start(); ik = ((Component)this).GetComponent(); } protected override void LateUpdate() { //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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) base.LateUpdate(); if (!(Vector3.Angle(((Component)this).transform.up, Vector3.up) <= 0.01f)) { Quaternion rotation = Quaternion.FromToRotation(((Component)this).transform.up, Vector3.up); RotateEffector(ik.solver.bodyEffector, rotation, 0.1f); RotateEffector(ik.solver.leftShoulderEffector, rotation, 0.2f); RotateEffector(ik.solver.rightShoulderEffector, rotation, 0.2f); RotateEffector(ik.solver.leftHandEffector, rotation, 0.1f); RotateEffector(ik.solver.rightHandEffector, rotation, 0.1f); } } private void RotateEffector(IKEffector effector, Quaternion rotation, float mlp) { //IL_0007: 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_001c: 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_001e: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) Vector3 val = effector.bone.position - ((Component)this).transform.position; Vector3 val2 = rotation * val; Vector3 val3 = val2 - val; effector.positionOffset += val3 * mlp; } } public class CharacterController3rdPerson : MonoBehaviour { public CameraController cam; private AnimatorController3rdPerson animatorController; private static Vector3 inputVector => new Vector3(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical")); private static Vector3 inputVectorRaw => new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical")); private void Start() { animatorController = ((Component)this).GetComponent(); ((Behaviour)cam).enabled = false; } private void LateUpdate() { //IL_0017: 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_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) cam.UpdateInput(); cam.UpdateTransform(); Vector3 moveInput = inputVector; bool isMoving = inputVector != Vector3.zero || inputVectorRaw != Vector3.zero; Vector3 forward = ((Component)cam).transform.forward; Vector3 aimTarget = ((Component)cam).transform.position + forward * 10f; animatorController.Move(moveInput, isMoving, forward, aimTarget); } } } namespace RootMotion1.Demos { public class EffectorOffset : OffsetModifier { [Range(0f, 1f)] public float handsMaintainRelativePositionWeight; public Vector3 bodyOffset; public Vector3 leftShoulderOffset; public Vector3 rightShoulderOffset; public Vector3 leftThighOffset; public Vector3 rightThighOffset; public Vector3 leftHandOffset; public Vector3 rightHandOffset; public Vector3 leftFootOffset; public Vector3 rightFootOffset; protected override void OnModifyOffset() { //IL_0048: 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_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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_009a: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f5: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01ce: 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_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) ik.solver.leftHandEffector.maintainRelativePositionWeight = handsMaintainRelativePositionWeight; ik.solver.rightHandEffector.maintainRelativePositionWeight = handsMaintainRelativePositionWeight; IKEffector bodyEffector = ik.solver.bodyEffector; bodyEffector.positionOffset += ((Component)this).transform.rotation * bodyOffset * weight; IKEffector leftShoulderEffector = ik.solver.leftShoulderEffector; leftShoulderEffector.positionOffset += ((Component)this).transform.rotation * leftShoulderOffset * weight; IKEffector rightShoulderEffector = ik.solver.rightShoulderEffector; rightShoulderEffector.positionOffset += ((Component)this).transform.rotation * rightShoulderOffset * weight; IKEffector leftThighEffector = ik.solver.leftThighEffector; leftThighEffector.positionOffset += ((Component)this).transform.rotation * leftThighOffset * weight; IKEffector rightThighEffector = ik.solver.rightThighEffector; rightThighEffector.positionOffset += ((Component)this).transform.rotation * rightThighOffset * weight; IKEffector leftHandEffector = ik.solver.leftHandEffector; leftHandEffector.positionOffset += ((Component)this).transform.rotation * leftHandOffset * weight; IKEffector rightHandEffector = ik.solver.rightHandEffector; rightHandEffector.positionOffset += ((Component)this).transform.rotation * rightHandOffset * weight; IKEffector leftFootEffector = ik.solver.leftFootEffector; leftFootEffector.positionOffset += ((Component)this).transform.rotation * leftFootOffset * weight; IKEffector rightFootEffector = ik.solver.rightFootEffector; rightFootEffector.positionOffset += ((Component)this).transform.rotation * rightFootOffset * weight; } } } namespace RootMotion.Demos { public class ExplosionDemo : MonoBehaviour { public SimpleLocomotion character; public float forceMlp = 1f; public float upForce = 1f; public float weightFalloffSpeed = 1f; public AnimationCurve weightFalloff; public AnimationCurve explosionForceByDistance; public AnimationCurve scale; private float weight = 0f; private Vector3 defaultScale = Vector3.one; private Rigidbody r; private FullBodyBipedIK ik; private void Start() { //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) defaultScale = ((Component)this).transform.localScale; r = ((Component)character).GetComponent(); ik = ((Component)character).GetComponent(); } private void Update() { //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: 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) weight = Mathf.Clamp(weight - Time.deltaTime * weightFalloffSpeed, 0f, 1f); if (Input.GetKeyDown((KeyCode)101) && character.isGrounded) { ((IKSolver)ik.solver).IKPositionWeight = 1f; ik.solver.leftHandEffector.position = ik.solver.leftHandEffector.bone.position; ik.solver.rightHandEffector.position = ik.solver.rightHandEffector.bone.position; ik.solver.leftFootEffector.position = ik.solver.leftFootEffector.bone.position; ik.solver.rightFootEffector.position = ik.solver.rightFootEffector.bone.position; weight = 1f; Vector3 val = r.position - ((Component)this).transform.position; val.y = 0f; float num = explosionForceByDistance.Evaluate(((Vector3)(ref val)).magnitude); r.velocity = (((Vector3)(ref val)).normalized + Vector3.up * upForce) * num * forceMlp; } if (weight < 0.5f && character.isGrounded) { weight = Mathf.Clamp(weight - Time.deltaTime * 3f, 0f, 1f); } SetEffectorWeights(weightFalloff.Evaluate(weight)); ((Component)this).transform.localScale = scale.Evaluate(weight) * defaultScale; } private void SetEffectorWeights(float w) { ik.solver.leftHandEffector.positionWeight = w; ik.solver.rightHandEffector.positionWeight = w; ik.solver.leftFootEffector.positionWeight = w; ik.solver.rightFootEffector.positionWeight = w; } } public class FBBIKSettings : MonoBehaviour { [Serializable] public class Limb { public Smoothing reachSmoothing; public float maintainRelativePositionWeight; public float mappingWeight = 1f; public void Apply(FullBodyBipedChain chain, IKSolverFullBodyBiped solver) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: 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_0026: Unknown result type (might be due to invalid IL or missing references) solver.GetChain(chain).reachSmoothing = reachSmoothing; solver.GetEndEffector(chain).maintainRelativePositionWeight = maintainRelativePositionWeight; solver.GetLimbMapping(chain).weight = mappingWeight; } } public FullBodyBipedIK ik; public bool disableAfterStart; public Limb leftArm; public Limb rightArm; public Limb leftLeg; public Limb rightLeg; public float rootPin = 0f; public bool bodyEffectChildNodes = true; public void UpdateSettings() { if (!((Object)(object)ik == (Object)null)) { leftArm.Apply((FullBodyBipedChain)0, ik.solver); rightArm.Apply((FullBodyBipedChain)1, ik.solver); leftLeg.Apply((FullBodyBipedChain)2, ik.solver); rightLeg.Apply((FullBodyBipedChain)3, ik.solver); ((IKSolverFullBody)ik.solver).chain[0].pin = rootPin; ik.solver.bodyEffector.effectChildNodes = bodyEffectChildNodes; } } private void Start() { Debug.Log((object)"FBBIKSettings is deprecated, you can now edit all the settings from the custom inspector of the FullBodyBipedIK component."); UpdateSettings(); if (disableAfterStart) { ((Behaviour)this).enabled = false; } } private void Update() { UpdateSettings(); } } public class FBIKBendGoal : MonoBehaviour { public FullBodyBipedIK ik; public FullBodyBipedChain chain; public float weight; private void Start() { Debug.Log((object)"FBIKBendGoal is deprecated, you can now a bend goal from the custom inspector of the FullBodyBipedIK component."); } private void Update() { //IL_0023: 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) if (!((Object)(object)ik == (Object)null)) { ik.solver.GetBendConstraint(chain).bendGoal = ((Component)this).transform; ik.solver.GetBendConstraint(chain).weight = weight; } } } public class FBIKBoxing : MonoBehaviour { [Tooltip("The target we want to hit")] public Transform target; [Tooltip("The pin Transform is used to reference the exact hit point in the animation (used by AimIK to aim the upper body to follow the target).In Legacy and Generic modes you can just create and position a reference point in your animating software and include it in the FBX. Then in Unity if you added a GameObject with the exact same name under the character's root, it would be animated to the required position.In Humanoid mode however, Mecanim loses track of any Transform that does not belong to the avatar, so in this case the pin point has to be manually set inside the Unity Editor.")] public Transform pin; [Tooltip("The Full Body Biped IK component")] public FullBodyBipedIK ik; [Tooltip("The Aim IK component. Aim IK is ust used for following the target slightly with the body.")] public AimIK aim; [Tooltip("The master weight")] public float weight; [Tooltip("The effector type of the punching hand")] public FullBodyBipedEffector effector; [Tooltip("Weight of aiming the body to follow the target")] public AnimationCurve aimWeight; private Animator animator; private void Start() { animator = ((Component)this).GetComponent(); } private void LateUpdate() { //IL_001e: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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) float @float = animator.GetFloat("HitWeight"); ik.solver.GetEffector(effector).position = target.position; ik.solver.GetEffector(effector).positionWeight = @float * weight; if ((Object)(object)aim != (Object)null) { aim.solver.transform.LookAt(pin.position); ((IKSolver)aim.solver).IKPosition = target.position; ((IKSolver)aim.solver).IKPositionWeight = aimWeight.Evaluate(@float) * weight; } } } public class FBIKHandsOnProp : MonoBehaviour { public FullBodyBipedIK ik; public bool leftHanded; private void Awake() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown IKSolverFullBodyBiped solver = ik.solver; ((IKSolverFullBody)solver).OnPreRead = (UpdateDelegate)Delegate.Combine((Delegate?)(object)((IKSolverFullBody)solver).OnPreRead, (Delegate?)new UpdateDelegate(OnPreRead)); } private void OnPreRead() { if (leftHanded) { HandsOnProp(ik.solver.leftHandEffector, ik.solver.rightHandEffector); } else { HandsOnProp(ik.solver.rightHandEffector, ik.solver.leftHandEffector); } } private void HandsOnProp(IKEffector mainHand, IKEffector otherHand) { //IL_0007: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_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_0066: 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_0070: 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) //IL_0082: 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_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_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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_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_0166: Unknown result type (might be due to invalid IL or missing references) Vector3 val = otherHand.bone.position - mainHand.bone.position; Vector3 val2 = Quaternion.Inverse(mainHand.bone.rotation) * val; Vector3 val3 = mainHand.bone.position + val * 0.5f; Quaternion val4 = Quaternion.Inverse(mainHand.bone.rotation) * otherHand.bone.rotation; Vector3 val5 = otherHand.bone.position + otherHand.positionOffset - (mainHand.bone.position + mainHand.positionOffset); Vector3 val6 = mainHand.bone.position + mainHand.positionOffset + val * 0.5f; mainHand.position = mainHand.bone.position + mainHand.positionOffset + (val6 - val3); mainHand.positionWeight = 1f; Quaternion val7 = Quaternion.FromToRotation(val, val5); mainHand.bone.rotation = val7 * mainHand.bone.rotation; otherHand.position = mainHand.position + mainHand.bone.rotation * val2; otherHand.positionWeight = 1f; otherHand.bone.rotation = mainHand.bone.rotation * val4; ik.solver.leftArmMapping.maintainRotationWeight = 1f; ik.solver.rightArmMapping.maintainRotationWeight = 1f; } private void OnDestroy() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if ((Object)(object)ik != (Object)null) { IKSolverFullBodyBiped solver = ik.solver; ((IKSolverFullBody)solver).OnPreRead = (UpdateDelegate)Delegate.Remove((Delegate?)(object)((IKSolverFullBody)solver).OnPreRead, (Delegate?)new UpdateDelegate(OnPreRead)); } } } public class FPSAiming : MonoBehaviour { [Range(0f, 1f)] public float aimWeight = 1f; [Range(0f, 1f)] public float sightWeight = 1f; [Range(0f, 180f)] public float maxAngle = 80f; public Vector3 aimOffset; public bool animatePhysics; public Transform gun; public Transform gunTarget; public FullBodyBipedIK ik; public AimIK gunAim; public AimIK headAim; public CameraControllerFPS cam; public Recoil recoil; [Range(0f, 1f)] public float cameraRecoilWeight = 0.5f; private Vector3 gunTargetDefaultLocalPosition; private Vector3 gunTargetDefaultLocalRotation; private Vector3 camDefaultLocalPosition; private Vector3 camRelativeToGunTarget; private bool updateFrame; private void Start() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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) gunTargetDefaultLocalPosition = gunTarget.localPosition; gunTargetDefaultLocalRotation = gunTarget.localEulerAngles; camDefaultLocalPosition = ((Component)cam).transform.localPosition; ((Behaviour)cam).enabled = false; ((Behaviour)gunAim).enabled = false; if ((Object)(object)headAim != (Object)null) { ((Behaviour)headAim).enabled = false; } ((Behaviour)ik).enabled = false; if ((Object)(object)recoil != (Object)null && ((IKSolverFullBody)ik.solver).iterations == 0) { Debug.LogWarning((object)"FPSAiming with Recoil needs FBBIK solver iteration count to be at least 1 to maintain accuracy."); } } private void FixedUpdate() { updateFrame = true; } private void LateUpdate() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) if (!animatePhysics) { updateFrame = true; } if (updateFrame) { updateFrame = false; ((Component)cam).transform.localPosition = camDefaultLocalPosition; camRelativeToGunTarget = gunTarget.InverseTransformPoint(((Component)cam).transform.position); cam.LateUpdate(); RotateCharacter(); Aiming(); LookDownTheSight(); } } private void Aiming() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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) if (!((Object)(object)headAim == (Object)null) || !(aimWeight <= 0f)) { Quaternion rotation = ((Component)cam).transform.rotation; ((IKSolver)headAim.solver).IKPosition = ((Component)cam).transform.position + ((Component)cam).transform.forward * 10f; ((IKSolver)headAim.solver).IKPositionWeight = 1f - aimWeight; ((IKSolver)headAim.solver).Update(); ((IKSolver)gunAim.solver).IKPosition = ((Component)cam).transform.position + ((Component)cam).transform.forward * 10f + ((Component)cam).transform.rotation * aimOffset; ((IKSolver)gunAim.solver).IKPositionWeight = aimWeight; ((IKSolver)gunAim.solver).Update(); ((Component)cam).transform.rotation = rotation; } } private void LookDownTheSight() { //IL_001b: 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_0037: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: 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_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0258: 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_0314: 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_033b: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) float num = aimWeight * sightWeight; gunTarget.position = Vector3.Lerp(gun.position, gunTarget.parent.TransformPoint(gunTargetDefaultLocalPosition), num); gunTarget.rotation = Quaternion.Lerp(gun.rotation, gunTarget.parent.rotation * Quaternion.Euler(gunTargetDefaultLocalRotation), num); Vector3 val = gun.InverseTransformPoint(ik.solver.leftHandEffector.bone.position); Vector3 val2 = gun.InverseTransformPoint(ik.solver.rightHandEffector.bone.position); Quaternion val3 = Quaternion.Inverse(gun.rotation) * ik.solver.leftHandEffector.bone.rotation; Quaternion val4 = Quaternion.Inverse(gun.rotation) * ik.solver.rightHandEffector.bone.rotation; float num2 = 1f; IKEffector leftHandEffector = ik.solver.leftHandEffector; leftHandEffector.positionOffset += (gunTarget.TransformPoint(val) - (ik.solver.leftHandEffector.bone.position + ik.solver.leftHandEffector.positionOffset)) * num2; IKEffector rightHandEffector = ik.solver.rightHandEffector; rightHandEffector.positionOffset += (gunTarget.TransformPoint(val2) - (ik.solver.rightHandEffector.bone.position + ik.solver.rightHandEffector.positionOffset)) * num2; ik.solver.headMapping.maintainRotationWeight = 1f; if ((Object)(object)recoil != (Object)null) { recoil.SetHandRotations(gunTarget.rotation * val3, gunTarget.rotation * val4); } ((IKSolver)ik.solver).Update(); if ((Object)(object)recoil != (Object)null) { ik.references.leftHand.rotation = recoil.rotationOffset * (gunTarget.rotation * val3); ik.references.rightHand.rotation = recoil.rotationOffset * (gunTarget.rotation * val4); } else { ik.references.leftHand.rotation = gunTarget.rotation * val3; ik.references.rightHand.rotation = gunTarget.rotation * val4; } ((Component)cam).transform.position = Vector3.Lerp(((Component)cam).transform.position, Vector3.Lerp(gunTarget.TransformPoint(camRelativeToGunTarget), ((Component)gun).transform.TransformPoint(camRelativeToGunTarget), cameraRecoilWeight), num); } private void RotateCharacter() { //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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) if (maxAngle >= 180f) { return; } if (maxAngle <= 0f) { ((Component)this).transform.rotation = Quaternion.LookRotation(new Vector3(((Component)cam).transform.forward.x, 0f, ((Component)cam).transform.forward.z)); return; } Vector3 val = ((Component)this).transform.InverseTransformDirection(((Component)cam).transform.forward); float num = Mathf.Atan2(val.x, val.z) * 57.29578f; if (Mathf.Abs(num) > Mathf.Abs(maxAngle)) { float num2 = num - maxAngle; if (num < 0f) { num2 = num + maxAngle; } ((Component)this).transform.rotation = Quaternion.AngleAxis(num2, ((Component)this).transform.up) * ((Component)this).transform.rotation; } } } public class FPSCharacter : MonoBehaviour { [Range(0f, 1f)] public float walkSpeed = 0.5f; private float sVel; private Animator animator; private FPSAiming FPSAiming; private void Start() { animator = ((Component)this).GetComponent(); FPSAiming = ((Component)this).GetComponent(); } private void Update() { FPSAiming.sightWeight = Mathf.SmoothDamp(FPSAiming.sightWeight, (!Input.GetMouseButton(1)) ? 0f : 1f, ref sVel, 0.1f); if (FPSAiming.sightWeight < 0.001f) { FPSAiming.sightWeight = 0f; } if (FPSAiming.sightWeight > 0.999f) { FPSAiming.sightWeight = 1f; } animator.SetFloat("Speed", walkSpeed); } private void OnGUI() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect((float)(Screen.width - 210), 10f, 200f, 25f), "Hold RMB to aim down the sight"); } } public class HitReactionTrigger : MonoBehaviour { public HitReaction hitReaction; public float hitForce = 1f; private string colliderName; private void Update() { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0052: 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) if (Input.GetMouseButtonDown(0)) { Ray val = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, ref val2, 100f)) { hitReaction.Hit(((RaycastHit)(ref val2)).collider, ((Ray)(ref val)).direction * hitForce, ((RaycastHit)(ref val2)).point); colliderName = ((Object)((RaycastHit)(ref val2)).collider).name; } } } private void OnGUI() { GUILayout.Label("LMB to shoot the Dummy, RMB to rotate the camera.", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (colliderName != string.Empty) { GUILayout.Label("Last Bone Hit: " + colliderName, (GUILayoutOption[])(object)new GUILayoutOption[0]); } } } public class HoldingHands : MonoBehaviour { public FullBodyBipedIK rightHandChar; public FullBodyBipedIK leftHandChar; public Transform rightHandTarget; public Transform leftHandTarget; public float crossFade; public float speed = 10f; private Quaternion rightHandRotation; private Quaternion leftHandRotation; private void Start() { //IL_0017: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_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_0066: Unknown result type (might be due to invalid IL or missing references) rightHandRotation = Quaternion.Inverse(rightHandChar.solver.rightHandEffector.bone.rotation) * ((Component)this).transform.rotation; leftHandRotation = Quaternion.Inverse(leftHandChar.solver.leftHandEffector.bone.rotation) * ((Component)this).transform.rotation; } private void LateUpdate() { //IL_0016: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_005f: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_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_013f: 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) Vector3 val = Vector3.Lerp(rightHandChar.solver.rightHandEffector.bone.position, leftHandChar.solver.leftHandEffector.bone.position, crossFade); ((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, val, Time.deltaTime * speed); ((Component)this).transform.rotation = Quaternion.Slerp(rightHandChar.solver.rightHandEffector.bone.rotation * rightHandRotation, leftHandChar.solver.leftHandEffector.bone.rotation * leftHandRotation, crossFade); rightHandChar.solver.rightHandEffector.position = rightHandTarget.position; rightHandChar.solver.rightHandEffector.rotation = rightHandTarget.rotation; leftHandChar.solver.leftHandEffector.position = leftHandTarget.position; leftHandChar.solver.leftHandEffector.rotation = leftHandTarget.rotation; } } public class InteractionC2CDemo : MonoBehaviour { public InteractionSystem character1; public InteractionSystem character2; public InteractionObject handShake; private void OnGUI() { if (GUILayout.Button("Shake Hands", (GUILayoutOption[])(object)new GUILayoutOption[0])) { character1.StartInteraction((FullBodyBipedEffector)6, handShake, true); character2.StartInteraction((FullBodyBipedEffector)6, handShake, true); } } private void LateUpdate() { //IL_001b: 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_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) Vector3 position = Vector3.Lerp(character1.ik.solver.rightHandEffector.bone.position, character2.ik.solver.rightHandEffector.bone.position, 0.5f); ((Component)handShake).transform.position = position; } } public class InteractionDemo : MonoBehaviour { public InteractionSystem interactionSystem; public bool interrupt; public InteractionObject ball; public InteractionObject benchMain; public InteractionObject benchHands; public InteractionObject button; public InteractionObject cigarette; public InteractionObject door; private bool isSitting; private void OnGUI() { interrupt = GUILayout.Toggle(interrupt, "Interrupt", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (isSitting) { if (!interactionSystem.inInteraction && GUILayout.Button("Stand Up", (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.ResumeAll(); isSitting = false; } return; } if (GUILayout.Button("Pick Up Ball", (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.StartInteraction((FullBodyBipedEffector)6, ball, interrupt); } if (GUILayout.Button("Button Left Hand", (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.StartInteraction((FullBodyBipedEffector)5, button, interrupt); } if (GUILayout.Button("Button Right Hand", (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.StartInteraction((FullBodyBipedEffector)6, button, interrupt); } if (GUILayout.Button("Put Out Cigarette", (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.StartInteraction((FullBodyBipedEffector)8, cigarette, interrupt); } if (GUILayout.Button("Open Door", (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.StartInteraction((FullBodyBipedEffector)5, door, interrupt); } if (!interactionSystem.inInteraction && GUILayout.Button("Sit Down", (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.StartInteraction((FullBodyBipedEffector)0, benchMain, interrupt); interactionSystem.StartInteraction((FullBodyBipedEffector)3, benchMain, interrupt); interactionSystem.StartInteraction((FullBodyBipedEffector)4, benchMain, interrupt); interactionSystem.StartInteraction((FullBodyBipedEffector)7, benchMain, interrupt); interactionSystem.StartInteraction((FullBodyBipedEffector)5, benchHands, interrupt); interactionSystem.StartInteraction((FullBodyBipedEffector)6, benchHands, interrupt); isSitting = true; } } } public class InteractionSystemTestGUI : MonoBehaviour { [Tooltip("The object to interact to")] public InteractionObject interactionObject; [Tooltip("The effectors to interact with")] public FullBodyBipedEffector[] effectors; private InteractionSystem interactionSystem; private void Awake() { interactionSystem = ((Component)this).GetComponent(); } private void OnGUI() { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)interactionSystem == (Object)null) { return; } if (GUILayout.Button("Start Interaction With " + ((Object)interactionObject).name, (GUILayoutOption[])(object)new GUILayoutOption[0])) { if (effectors.Length == 0) { Debug.Log((object)"Please select the effectors to interact with."); } FullBodyBipedEffector[] array = effectors; foreach (FullBodyBipedEffector val in array) { interactionSystem.StartInteraction(val, interactionObject, true); } } if (effectors.Length != 0 && interactionSystem.IsPaused(effectors[0]) && GUILayout.Button("Resume Interaction With " + ((Object)interactionObject).name, (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.ResumeAll(); } } } public class KissingRig : MonoBehaviour { [Serializable] public class Partner { public FullBodyBipedIK ik; public Transform mouth; public Transform mouthTarget; public Transform touchTargetLeftHand; public Transform touchTargetRightHand; public float bodyWeightHorizontal = 0.4f; public float bodyWeightVertical = 1f; public float neckRotationWeight = 0.3f; public float headTiltAngle = 10f; public Vector3 headTiltAxis; private Quaternion neckRotation; private Transform neck => ((IKSolverFullBody)ik.solver).spineMapping.spineBones[((IKSolverFullBody)ik.solver).spineMapping.spineBones.Length - 1]; public void Initiate() { ((Behaviour)ik).enabled = false; } public void Update(float weight) { //IL_00a9: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: 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_0228: Unknown result type (might be due to invalid IL or missing references) //IL_022d: 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_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0299: 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_02bf: 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_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) ik.solver.leftShoulderEffector.positionWeight = weight; ik.solver.rightShoulderEffector.positionWeight = weight; ik.solver.leftHandEffector.positionWeight = weight; ik.solver.rightHandEffector.positionWeight = weight; ik.solver.leftHandEffector.rotationWeight = weight; ik.solver.rightHandEffector.rotationWeight = weight; ik.solver.bodyEffector.positionWeight = weight; InverseTransformEffector((FullBodyBipedEffector)1, mouth, mouthTarget.position, weight); InverseTransformEffector((FullBodyBipedEffector)2, mouth, mouthTarget.position, weight); InverseTransformEffector((FullBodyBipedEffector)0, mouth, mouthTarget.position, weight); ik.solver.bodyEffector.position = Vector3.Lerp(new Vector3(ik.solver.bodyEffector.position.x, ik.solver.bodyEffector.bone.position.y, ik.solver.bodyEffector.position.z), ik.solver.bodyEffector.position, bodyWeightVertical * weight); ik.solver.bodyEffector.position = Vector3.Lerp(new Vector3(ik.solver.bodyEffector.bone.position.x, ik.solver.bodyEffector.position.y, ik.solver.bodyEffector.bone.position.z), ik.solver.bodyEffector.position, bodyWeightHorizontal * weight); ik.solver.leftHandEffector.position = touchTargetLeftHand.position; ik.solver.rightHandEffector.position = touchTargetRightHand.position; ik.solver.leftHandEffector.rotation = touchTargetLeftHand.rotation; ik.solver.rightHandEffector.rotation = touchTargetRightHand.rotation; neckRotation = neck.rotation; ((IKSolver)ik.solver).Update(); neck.rotation = Quaternion.Slerp(neck.rotation, neckRotation, neckRotationWeight * weight); ik.references.head.localRotation = Quaternion.AngleAxis(headTiltAngle * weight, headTiltAxis) * ik.references.head.localRotation; } private void InverseTransformEffector(FullBodyBipedEffector effector, Transform target, Vector3 targetPosition, float weight) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ik.solver.GetEffector(effector).bone.position - target.position; ik.solver.GetEffector(effector).position = Vector3.Lerp(ik.solver.GetEffector(effector).bone.position, targetPosition + val, weight); } } public Partner partner1; public Partner partner2; public float weight; public int iterations = 3; private void Start() { partner1.Initiate(); partner2.Initiate(); } private void LateUpdate() { for (int i = 0; i < iterations; i++) { partner1.Update(weight); partner2.Update(weight); } } } } namespace RootMotion1.Demos { public class MotionAbsorb : OffsetModifier { [Serializable] public enum Mode { Position, PositionOffset } [Serializable] public class Absorber { [Tooltip("The type of effector (hand, foot, shoulder...) - this is just an enum")] public FullBodyBipedEffector effector; [Tooltip("How much should motion be absorbed on this effector")] public float weight = 1f; private Vector3 position; private Quaternion rotation = Quaternion.identity; private IKEffector e; public void SetToBone(IKSolverFullBodyBiped solver, Mode mode) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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) e = solver.GetEffector(effector); switch (mode) { case Mode.Position: e.position = e.bone.position; e.rotation = e.bone.rotation; break; case Mode.PositionOffset: position = e.bone.position; rotation = e.bone.rotation; break; } } public void UpdateEffectorWeights(float w) { e.positionWeight = w * weight; e.rotationWeight = w * weight; } public void SetPosition(float w) { //IL_0008: 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_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_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) IKEffector iKEffector = e; iKEffector.positionOffset += (position - e.bone.position) * w * weight; } public void SetRotation(float w) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) e.bone.rotation = Quaternion.Slerp(e.bone.rotation, rotation, w * weight); } } [Tooltip("Use either effector position, position weight, rotation, rotationWeight or positionOffset and rotating the bone directly.")] public Mode mode; [Tooltip("Array containing the absorbers")] public Absorber[] absorbers; [Tooltip("Weight falloff curve (how fast will the effect reduce after impact)")] public AnimationCurve falloff; [Tooltip("How fast will the impact fade away. (if 1, effect lasts for 1 second)")] public float falloffSpeed = 1f; private float timer; private float w; private Mode initialMode; protected override void Start() { base.Start(); IKSolverFullBodyBiped solver = ik.solver; solver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Combine(solver.OnPostUpdate, new IKSolver.UpdateDelegate(AfterIK)); initialMode = mode; } private void OnCollisionEnter(Collision c) { if (!(timer > 0f)) { timer = 1f; for (int i = 0; i < absorbers.Length; i++) { absorbers[i].SetToBone(ik.solver, mode); } } } protected override void OnModifyOffset() { if (timer <= 0f) { return; } mode = initialMode; timer -= Time.deltaTime * falloffSpeed; w = falloff.Evaluate(timer); if (mode == Mode.Position) { for (int i = 0; i < absorbers.Length; i++) { absorbers[i].UpdateEffectorWeights(w * weight); } } else { for (int j = 0; j < absorbers.Length; j++) { absorbers[j].SetPosition(w * weight); } } } private void AfterIK() { if (!(timer <= 0f) && mode != 0) { for (int i = 0; i < absorbers.Length; i++) { absorbers[i].SetRotation(w * weight); } } } protected override void OnDestroy() { base.OnDestroy(); if ((Object)(object)ik != (Object)null) { IKSolverFullBodyBiped solver = ik.solver; solver.OnPostUpdate = (IKSolver.UpdateDelegate)Delegate.Remove(solver.OnPostUpdate, new IKSolver.UpdateDelegate(AfterIK)); } } } } namespace RootMotion.Demos { public class MotionAbsorbCharacter : MonoBehaviour { public Animator animator; public MotionAbsorb motionAbsorb; public Transform cube; public float cubeRandomPosition = 0.1f; public AnimationCurve motionAbsorbWeight; private Vector3 cubeDefaultPosition; private AnimatorStateInfo info; private Rigidbody cubeRigidbody; private void Start() { //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) cubeDefaultPosition = cube.position; cubeRigidbody = ((Component)cube).GetComponent(); } private void Update() { //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) info = animator.GetCurrentAnimatorStateInfo(0); ((OffsetModifier)motionAbsorb).weight = motionAbsorbWeight.Evaluate(((AnimatorStateInfo)(ref info)).normalizedTime - (float)(int)((AnimatorStateInfo)(ref info)).normalizedTime); } private void SwingStart() { //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_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) cubeRigidbody.MovePosition(cubeDefaultPosition + Random.insideUnitSphere * cubeRandomPosition); cubeRigidbody.MoveRotation(Quaternion.identity); cubeRigidbody.velocity = Vector3.zero; cubeRigidbody.angularVelocity = Vector3.zero; } } } namespace RootMotion1.Demos { public class OffsetEffector : OffsetModifier { [Serializable] public class EffectorLink { public FullBodyBipedEffector effectorType; public float weightMultiplier = 1f; [HideInInspector] public Vector3 localPosition; } public EffectorLink[] effectorLinks; protected override void Start() { //IL_003d: 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) base.Start(); EffectorLink[] array = effectorLinks; foreach (EffectorLink effectorLink in array) { effectorLink.localPosition = ((Component)this).transform.InverseTransformPoint(ik.solver.GetEffector(effectorLink.effectorType).bone.position); if (effectorLink.effectorType == FullBodyBipedEffector.Body) { ik.solver.bodyEffector.effectChildNodes = false; } } } protected override void OnModifyOffset() { //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) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_008f: 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_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) EffectorLink[] array = effectorLinks; foreach (EffectorLink effectorLink in array) { Vector3 val = ((Component)this).transform.TransformPoint(effectorLink.localPosition); IKEffector effector = ik.solver.GetEffector(effectorLink.effectorType); effector.positionOffset += (val - (ik.solver.GetEffector(effectorLink.effectorType).bone.position + ik.solver.GetEffector(effectorLink.effectorType).positionOffset)) * weight * effectorLink.weightMultiplier; } } } } namespace RootMotion.Demos { public class PendulumExample : MonoBehaviour { [Tooltip("The master weight of this script.")] [Range(0f, 1f)] public float weight = 1f; [Tooltip("Multiplier for the distance of the root to the target.")] public float hangingDistanceMlp = 1.3f; [Tooltip("Where does the root of the character land when weight is blended out?")] [HideInInspector] public Vector3 rootTargetPosition; [Tooltip("How is the root of the character rotated when weight is blended out?")] [HideInInspector] public Quaternion rootTargetRotation; public Transform target; public Transform leftHandTarget; public Transform rightHandTarget; public Transform leftFootTarget; public Transform rightFootTarget; public Transform pelvisTarget; public Transform bodyTarget; public Transform headTarget; public Vector3 pelvisDownAxis = Vector3.right; private FullBodyBipedIK ik; private Quaternion rootRelativeToPelvis; private Vector3 pelvisToRoot; private float lastWeight; private void Start() { //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_0025: 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_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) ik = ((Component)this).GetComponent(); Quaternion rotation = target.rotation; target.rotation = leftHandTarget.rotation; FixedJoint val = ((Component)target).gameObject.AddComponent(); ((Joint)val).connectedBody = ((Component)leftHandTarget).GetComponent(); ((Component)target).GetComponent().MoveRotation(rotation); rootRelativeToPelvis = Quaternion.Inverse(pelvisTarget.rotation) * ((Component)this).transform.rotation; pelvisToRoot = Quaternion.Inverse(ik.references.pelvis.rotation) * (((Component)this).transform.position - ik.references.pelvis.position); rootTargetPosition = ((Component)this).transform.position; rootTargetRotation = ((Component)this).transform.rotation; lastWeight = weight; } private void LateUpdate() { //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_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_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_011c: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: 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_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_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_0299: 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_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) if (weight > 0f) { ik.solver.leftHandEffector.positionWeight = weight; ik.solver.leftHandEffector.rotationWeight = weight; } else { rootTargetPosition = ((Component)this).transform.position; rootTargetRotation = ((Component)this).transform.rotation; if (lastWeight > 0f) { ik.solver.leftHandEffector.positionWeight = 0f; ik.solver.leftHandEffector.rotationWeight = 0f; } } lastWeight = weight; if (!(weight <= 0f)) { ((Component)this).transform.position = Vector3.Lerp(rootTargetPosition, pelvisTarget.position + pelvisTarget.rotation * pelvisToRoot * hangingDistanceMlp, weight); ((Component)this).transform.rotation = Quaternion.Lerp(rootTargetRotation, pelvisTarget.rotation * rootRelativeToPelvis, weight); ik.solver.leftHandEffector.position = leftHandTarget.position; ik.solver.leftHandEffector.rotation = leftHandTarget.rotation; Vector3 val = ik.references.pelvis.rotation * pelvisDownAxis; Quaternion val2 = Quaternion.FromToRotation(val, rightHandTarget.position - headTarget.position); ik.references.rightUpperArm.rotation = Quaternion.Lerp(Quaternion.identity, val2, weight) * ik.references.rightUpperArm.rotation; Quaternion val3 = Quaternion.FromToRotation(val, leftFootTarget.position - bodyTarget.position); ik.references.leftThigh.rotation = Quaternion.Lerp(Quaternion.identity, val3, weight) * ik.references.leftThigh.rotation; Quaternion val4 = Quaternion.FromToRotation(val, rightFootTarget.position - bodyTarget.position); ik.references.rightThigh.rotation = Quaternion.Lerp(Quaternion.identity, val4, weight) * ik.references.rightThigh.rotation; } } } public abstract class PickUp2Handed : MonoBehaviour { public int GUIspace; public InteractionSystem interactionSystem; public InteractionObject obj; public Transform pivot; public Transform holdPoint; public float pickUpTime = 0.3f; private float holdWeight; private float holdWeightVel; private Vector3 pickUpPosition; private Quaternion pickUpRotation; private bool holding => holdingLeft || holdingRight; private bool holdingLeft => interactionSystem.IsPaused((FullBodyBipedEffector)5) && (Object)(object)interactionSystem.GetInteractionObject((FullBodyBipedEffector)5) == (Object)(object)obj; private bool holdingRight => interactionSystem.IsPaused((FullBodyBipedEffector)6) && (Object)(object)interactionSystem.GetInteractionObject((FullBodyBipedEffector)6) == (Object)(object)obj; private void OnGUI() { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Space((float)GUIspace); if (!holding) { if (GUILayout.Button("Pick Up " + ((Object)obj).name, (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.StartInteraction((FullBodyBipedEffector)5, obj, false); interactionSystem.StartInteraction((FullBodyBipedEffector)6, obj, false); } } else { GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]); if (holdingRight && GUILayout.Button("Release Right", (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.ResumeInteraction((FullBodyBipedEffector)6); } if (holdingLeft && GUILayout.Button("Release Left", (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.ResumeInteraction((FullBodyBipedEffector)5); } if (GUILayout.Button("Drop " + ((Object)obj).name, (GUILayoutOption[])(object)new GUILayoutOption[0])) { interactionSystem.ResumeAll(); } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } protected abstract void RotatePivot(); private void Start() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown InteractionSystem obj = interactionSystem; obj.OnInteractionStart = (InteractionDelegate)Delegate.Combine((Delegate?)(object)obj.OnInteractionStart, (Delegate?)new InteractionDelegate(OnStart)); InteractionSystem obj2 = interactionSystem; obj2.OnInteractionPause = (InteractionDelegate)Delegate.Combine((Delegate?)(object)obj2.OnInteractionPause, (Delegate?)new InteractionDelegate(OnPause)); InteractionSystem obj3 = interactionSystem; obj3.OnInteractionResume = (InteractionDelegate)Delegate.Combine((Delegate?)(object)obj3.OnInteractionResume, (Delegate?)new InteractionDelegate(OnDrop)); } private void OnPause(FullBodyBipedEffector effectorType, InteractionObject interactionObject) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //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_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) if ((int)effectorType == 5 && !((Object)(object)interactionObject != (Object)(object)obj)) { ((Component)obj).transform.parent = ((Component)interactionSystem).transform; Rigidbody component = ((Component)obj).GetComponent(); if ((Object)(object)component != (Object)null) { component.isKinematic = true; } pickUpPosition = ((Component)obj).transform.position; pickUpRotation = ((Component)obj).transform.rotation; holdWeight = 0f; holdWeightVel = 0f; } } private void OnStart(FullBodyBipedEffector effectorType, InteractionObject interactionObject) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) if ((int)effectorType == 5 && !((Object)(object)interactionObject != (Object)(object)obj)) { RotatePivot(); holdPoint.rotation = ((Component)obj).transform.rotation; } } private void OnDrop(FullBodyBipedEffector effectorType, InteractionObject interactionObject) { if (!holding && !((Object)(object)interactionObject != (Object)(object)obj)) { ((Component)obj).transform.parent = null; if ((Object)(object)((Component)obj).GetComponent() != (Object)null) { ((Component)obj).GetComponent().isKinematic = false; } } } private void LateUpdate() { //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_0051: 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_0072: 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 (holding) { holdWeight = Mathf.SmoothDamp(holdWeight, 1f, ref holdWeightVel, pickUpTime); ((Component)obj).transform.position = Vector3.Lerp(pickUpPosition, holdPoint.position, holdWeight); ((Component)obj).transform.rotation = Quaternion.Lerp(pickUpRotation, holdPoint.rotation, holdWeight); } } private void OnDestroy() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown if (!((Object)(object)interactionSystem == (Object)null)) { InteractionSystem obj = interactionSystem; obj.OnInteractionStart = (InteractionDelegate)Delegate.Remove((Delegate?)(object)obj.OnInteractionStart, (Delegate?)new InteractionDelegate(OnStart)); InteractionSystem obj2 = interactionSystem; obj2.OnInteractionPause = (InteractionDelegate)Delegate.Remove((Delegate?)(object)obj2.OnInteractionPause, (Delegate?)new InteractionDelegate(OnPause)); InteractionSystem obj3 = interactionSystem; obj3.OnInteractionResume = (InteractionDelegate)Delegate.Remove((Delegate?)(object)obj3.OnInteractionResume, (Delegate?)new InteractionDelegate(OnDrop)); } } } public class PickUpBox : PickUp2Handed { protected override void RotatePivot() { //IL_0007: 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_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) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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) Vector3 val = pivot.position - ((Component)interactionSystem).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; normalized.y = 0f; Vector3 val2 = ((Component)obj).transform.InverseTransformDirection(normalized); Vector3 axis = QuaTools.GetAxis(val2); Vector3 axis2 = QuaTools.GetAxis(((Component)obj).transform.InverseTransformDirection(((Component)interactionSystem).transform.up)); pivot.localRotation = Quaternion.LookRotation(axis, axis2); } } public class PickUpSphere : PickUp2Handed { protected override void RotatePivot() { //IL_001b: 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_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_005a: 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_0060: 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_0068: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Lerp(interactionSystem.ik.solver.leftHandEffector.bone.position, interactionSystem.ik.solver.rightHandEffector.bone.position, 0.5f); Vector3 val2 = ((Component)obj).transform.position - val; pivot.rotation = Quaternion.LookRotation(val2); } } public class RagdollUtilityDemo : MonoBehaviour { public RagdollUtility ragdollUtility; public Transform root; public Rigidbody pelvis; private void OnGUI() { GUILayout.Label(" Press R to switch to ragdoll. \n Weigh in one of the FBBIK effectors to make kinematic changes to the ragdoll pose.\n A to blend back to animation", (GUILayoutOption[])(object)new GUILayoutOption[0]); } private void Update() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown((KeyCode)114)) { ragdollUtility.EnableRagdoll(); } if (Input.GetKeyDown((KeyCode)97)) { Vector3 val = pelvis.position - root.position; Transform obj = root; obj.position += val; Transform transform = ((Component)pelvis).transform; transform.position -= val; ragdollUtility.DisableRagdoll(); } } } public class RecoilTest : MonoBehaviour { public float magnitude = 1f; private Recoil recoil; private void Start() { recoil = ((Component)this).GetComponent(); } private void Update() { if (Input.GetKeyDown((KeyCode)114) || Input.GetMouseButtonDown(0)) { recoil.Fire(magnitude); } } private void OnGUI() { GUILayout.Label("Press R or LMB for procedural recoil.", (GUILayoutOption[])(object)new GUILayoutOption[0]); } } public class ResetInteractionObject : MonoBehaviour { public float resetDelay = 1f; private Vector3 defaultPosition; private Quaternion defaultRotation; private Transform defaultParent; private Rigidbody r; private void Start() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) defaultPosition = ((Component)this).transform.position; defaultRotation = ((Component)this).transform.rotation; defaultParent = ((Component)this).transform.parent; r = ((Component)this).GetComponent(); } private void OnPickUp(Transform t) { ((MonoBehaviour)this).StopAllCoroutines(); ((MonoBehaviour)this).StartCoroutine(ResetObject(Time.time + resetDelay)); } private IEnumerator ResetObject(float resetTime) { while (Time.time < resetTime) { yield return null; } Poser poser = ((Component)((Component)this).transform.parent).GetComponent(); if ((Object)(object)poser != (Object)null) { poser.poseRoot = null; poser.weight = 0f; } ((Component)this).transform.parent = defaultParent; ((Component)this).transform.position = defaultPosition; ((Component)this).transform.rotation = defaultRotation; if ((Object)(object)r != (Object)null) { r.isKinematic = false; } } } public class SoccerDemo : MonoBehaviour { private Animator animator; private Vector3 defaultPosition; private Quaternion defaultRotation; private void Start() { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) animator = ((Component)this).GetComponent(); defaultPosition = ((Component)this).transform.position; defaultRotation = ((Component)this).transform.rotation; ((MonoBehaviour)this).StartCoroutine(ResetDelayed()); } private IEnumerator ResetDelayed() { while (true) { yield return (object)new WaitForSeconds(3f); ((Component)this).transform.position = defaultPosition; ((Component)this).transform.rotation = defaultRotation; animator.CrossFade("SoccerKick", 0f, 0, 0f); yield return null; } } } public class TouchWalls : MonoBehaviour { [Serializable] public class EffectorLink { public bool enabled = true; public FullBodyBipedEffector effectorType; public InteractionObject interactionObject; public Transform spherecastFrom; public float spherecastRadius = 0.1f; public float minDistance = 0.3f; public float distanceMlp = 1f; public LayerMask touchLayers; public float lerpSpeed = 10f; public float minSwitchTime = 0.2f; public float releaseDistance = 0.4f; public bool sliding; private Vector3 raycastDirectionLocal; private float raycastDistance; private bool inTouch; private RaycastHit hit = default(RaycastHit); private Vector3 targetPosition; private Quaternion targetRotation; private bool initiated; private float nextSwitchTime; private float speedF; public void Initiate(InteractionSystem interactionSystem) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00c4: 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_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) raycastDirectionLocal = spherecastFrom.InverseTransformDirection(((Component)interactionObject).transform.position - spherecastFrom.position); raycastDistance = Vector3.Distance(spherecastFrom.position, ((Component)interactionObject).transform.position); interactionSystem.OnInteractionStart = (InteractionDelegate)Delegate.Combine((Delegate?)(object)interactionSystem.OnInteractionStart, (Delegate?)new InteractionDelegate(OnInteractionStart)); interactionSystem.OnInteractionResume = (InteractionDelegate)Delegate.Combine((Delegate?)(object)interactionSystem.OnInteractionResume, (Delegate?)new InteractionDelegate(OnInteractionResume)); interactionSystem.OnInteractionStop = (InteractionDelegate)Delegate.Combine((Delegate?)(object)interactionSystem.OnInteractionStop, (Delegate?)new InteractionDelegate(OnInteractionStop)); ((RaycastHit)(ref hit)).normal = Vector3.forward; targetPosition = ((Component)interactionObject).transform.position; targetRotation = ((Component)interactionObject).transform.rotation; initiated = true; } private bool FindWalls(Vector3 direction) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!enabled) { return false; } bool result = Physics.SphereCast(spherecastFrom.position, spherecastRadius, direction, ref hit, raycastDistance * distanceMlp, LayerMask.op_Implicit(touchLayers)); if (((RaycastHit)(ref hit)).distance < minDistance) { result = false; } return result; } public void Update(InteractionSystem interactionSystem) { //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_0022: 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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017e: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) if (!initiated) { return; } Vector3 val = spherecastFrom.TransformDirection(raycastDirectionLocal); ((RaycastHit)(ref hit)).point = spherecastFrom.position + val; bool flag = FindWalls(val); if (!inTouch) { if (flag && Time.time > nextSwitchTime) { ((Component)interactionObject).transform.parent = null; interactionSystem.StartInteraction(effectorType, interactionObject, true); nextSwitchTime = Time.time + minSwitchTime / interactionSystem.speed; targetPosition = ((RaycastHit)(ref hit)).point; targetRotation = Quaternion.LookRotation(-((RaycastHit)(ref hit)).normal); ((Component)interactionObject).transform.position = targetPosition; ((Component)interactionObject).transform.rotation = targetRotation; } } else { if (!flag) { StopTouch(interactionSystem); } else if (!interactionSystem.IsPaused(effectorType) || sliding) { targetPosition = ((RaycastHit)(ref hit)).point; targetRotation = Quaternion.LookRotation(-((RaycastHit)(ref hit)).normal); } if (Vector3.Distance(((Component)interactionObject).transform.position, ((RaycastHit)(ref hit)).point) > releaseDistance) { if (flag) { targetPosition = ((RaycastHit)(ref hit)).point; targetRotation = Quaternion.LookRotation(-((RaycastHit)(ref hit)).normal); } else { StopTouch(interactionSystem); } } } float num = ((inTouch && (!interactionSystem.IsPaused(effectorType) || !(((Component)interactionObject).transform.position == targetPosition))) ? 1f : 0f); speedF = Mathf.Lerp(speedF, num, Time.deltaTime * 3f * interactionSystem.speed); float num2 = Time.deltaTime * lerpSpeed * speedF * interactionSystem.speed; ((Component)interactionObject).transform.position = Vector3.Lerp(((Component)interactionObject).transform.position, targetPosition, num2); ((Component)interactionObject).transform.rotation = Quaternion.Slerp(((Component)interactionObject).transform.rotation, targetRotation, num2); } private void StopTouch(InteractionSystem interactionSystem) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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) ((Component)interactionObject).transform.parent = ((Component)interactionSystem).transform; nextSwitchTime = Time.time + minSwitchTime / interactionSystem.speed; if (interactionSystem.IsPaused(effectorType)) { interactionSystem.ResumeInteraction(effectorType); return; } speedF = 0f; targetPosition = ((RaycastHit)(ref hit)).point; targetRotation = Quaternion.LookRotation(-((RaycastHit)(ref hit)).normal); } private void OnInteractionStart(FullBodyBipedEffector effectorType, InteractionObject interactionObject) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) if (effectorType == this.effectorType && !((Object)(object)interactionObject != (Object)(object)this.interactionObject)) { inTouch = true; } } private void OnInteractionResume(FullBodyBipedEffector effectorType, InteractionObject interactionObject) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) if (effectorType == this.effectorType && !((Object)(object)interactionObject != (Object)(object)this.interactionObject)) { inTouch = false; } } private void OnInteractionStop(FullBodyBipedEffector effectorType, InteractionObject interactionObject) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) if (effectorType == this.effectorType && !((Object)(object)interactionObject != (Object)(object)this.interactionObject)) { inTouch = false; } } public void Destroy(InteractionSystem interactionSystem) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown if (initiated) { interactionSystem.OnInteractionStart = (InteractionDelegate)Delegate.Remove((Delegate?)(object)interactionSystem.OnInteractionStart, (Delegate?)new InteractionDelegate(OnInteractionStart)); interactionSystem.OnInteractionResume = (InteractionDelegate)Delegate.Remove((Delegate?)(object)interactionSystem.OnInteractionResume, (Delegate?)new InteractionDelegate(OnInteractionResume)); interactionSystem.OnInteractionStop = (InteractionDelegate)Delegate.Remove((Delegate?)(object)interactionSystem.OnInteractionStop, (Delegate?)new InteractionDelegate(OnInteractionStop)); } } } public InteractionSystem interactionSystem; public EffectorLink[] effectorLinks; private void Start() { EffectorLink[] array = effectorLinks; foreach (EffectorLink effectorLink in array) { effectorLink.Initiate(interactionSystem); } } private void FixedUpdate() { for (int i = 0; i < effectorLinks.Length; i++) { effectorLinks[i].Update(interactionSystem); } } private void OnDestroy() { if ((Object)(object)interactionSystem != (Object)null) { for (int i = 0; i < effectorLinks.Length; i++) { effectorLinks[i].Destroy(interactionSystem); } } } } public class TransferMotion : MonoBehaviour { [Tooltip("The Transform to transfer motion to.")] public Transform to; [Tooltip("The amount of motion to transfer.")] [Range(0f, 1f)] public float transferMotion = 0.9f; private Vector3 lastPosition; private void OnEnable() { //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) lastPosition = ((Component)this).transform.position; } private void Update() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.position - lastPosition; Transform obj = to; obj.position += val * transferMotion; lastPosition = ((Component)this).transform.position; } } public class TwoHandedProp : MonoBehaviour { [Tooltip("The left hand target parented to the right hand.")] public Transform leftHandTarget; private FullBodyBipedIK ik; private Vector3 targetPosRelativeToRight; private Quaternion targetRotRelativeToRight; private void Start() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown ik = ((Component)this).GetComponent(); IKSolverFullBodyBiped solver = ik.solver; ((IKSolver)solver).OnPostUpdate = (UpdateDelegate)Delegate.Combine((Delegate?)(object)((IKSolver)solver).OnPostUpdate, (Delegate?)new UpdateDelegate(AfterFBBIK)); ik.solver.leftHandEffector.positionWeight = 1f; ik.solver.rightHandEffector.positionWeight = 1f; if ((Object)(object)ik.solver.rightHandEffector.target == (Object)null) { Debug.LogError((object)"Right Hand Effector needs a Target in this demo."); } } private void LateUpdate() { //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_0022: 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_003d: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) targetPosRelativeToRight = ik.references.rightHand.InverseTransformPoint(leftHandTarget.position); targetRotRelativeToRight = Quaternion.Inverse(ik.references.rightHand.rotation) * leftHandTarget.rotation; ik.solver.leftHandEffector.position = ik.solver.rightHandEffector.target.position + ik.solver.rightHandEffector.target.rotation * targetPosRelativeToRight; ik.solver.leftHandEffector.rotation = ik.solver.rightHandEffector.target.rotation * targetRotRelativeToRight; } private void AfterFBBIK() { //IL_0026: 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) ik.solver.leftHandEffector.bone.rotation = ik.solver.leftHandEffector.rotation; ik.solver.rightHandEffector.bone.rotation = ik.solver.rightHandEffector.rotation; } private void OnDestroy() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown if ((Object)(object)ik != (Object)null) { IKSolverFullBodyBiped solver = ik.solver; ((IKSolver)solver).OnPostUpdate = (UpdateDelegate)Delegate.Remove((Delegate?)(object)((IKSolver)solver).OnPostUpdate, (Delegate?)new UpdateDelegate(AfterFBBIK)); } } } public class UserControlInteractions : UserControlThirdPerson { public CharacterThirdPerson character; public InteractionSystem interactionSystem; public bool disableInputInInteraction = true; public float enableInputAtProgress = 0.8f; protected override void Update() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (disableInputInInteraction && (Object)(object)interactionSystem != (Object)null && (interactionSystem.inInteraction || interactionSystem.IsPaused())) { float minActiveProgress = interactionSystem.GetMinActiveProgress(); if (minActiveProgress > 0f && minActiveProgress < enableInputAtProgress) { state.move = Vector3.zero; state.jump = false; return; } } base.Update(); } private void OnGUI() { if (!character.onGround) { return; } if (interactionSystem.IsPaused() && interactionSystem.IsInSync()) { GUILayout.Label("Press E to resume interaction", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (Input.GetKey((KeyCode)101)) { interactionSystem.ResumeAll(); } return; } int closestTriggerIndex = interactionSystem.GetClosestTriggerIndex(); if (closestTriggerIndex != -1 && interactionSystem.TriggerEffectorsReady(closestTriggerIndex)) { GUILayout.Label("Press E to start interaction", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (Input.GetKey((KeyCode)101)) { interactionSystem.TriggerInteraction(closestTriggerIndex, false); } } } } public class GrounderDemo : MonoBehaviour { public GameObject[] characters; private void OnGUI() { if (GUILayout.Button("Biped", (GUILayoutOption[])(object)new GUILayoutOption[0])) { Activate(0); } if (GUILayout.Button("Quadruped", (GUILayoutOption[])(object)new GUILayoutOption[0])) { Activate(1); } if (GUILayout.Button("Mech", (GUILayoutOption[])(object)new GUILayoutOption[0])) { Activate(2); } if (GUILayout.Button("Bot", (GUILayoutOption[])(object)new GUILayoutOption[0])) { Activate(3); } } public void Activate(int index) { for (int i = 0; i < characters.Length; i++) { characters[i].SetActive(i == index); } } } public class PlatformRotator : MonoBehaviour { public float maxAngle = 70f; public float switchRotationTime = 0.5f; public float random = 0.5f; public float rotationSpeed = 50f; public Vector3 movePosition; public float moveSpeed = 5f; public int characterLayer; private Quaternion defaultRotation; private Quaternion targetRotation; private Vector3 targetPosition; private Vector3 velocity; private Rigidbody r; private void Start() { //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_0019: 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_0029: Unknown result type (might be due to invalid IL or missing references) defaultRotation = ((Component)this).transform.rotation; targetPosition = ((Component)this).transform.position + movePosition; r = ((Component)this).GetComponent(); ((MonoBehaviour)this).StartCoroutine(SwitchRotation()); } private void FixedUpdate() { //IL_000d: 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_0029: 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_003f: 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_008f: 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_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_0060: 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_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_0077: Unknown result type (might be due to invalid IL or missing references) r.MovePosition(Vector3.SmoothDamp(r.position, targetPosition, ref velocity, 1f, moveSpeed)); if (Vector3.Distance(((Component)this).GetComponent().position, targetPosition) < 0.1f) { movePosition = -movePosition; targetPosition += movePosition; } r.MoveRotation(Quaternion.RotateTowards(r.rotation, targetRotation, rotationSpeed * Time.deltaTime)); } private IEnumerator SwitchRotation() { while (true) { float angle = Random.Range(0f - maxAngle, maxAngle); Vector3 axis = Random.onUnitSphere; targetRotation = Quaternion.AngleAxis(angle, axis) * defaultRotation; yield return (object)new WaitForSeconds(switchRotationTime + Random.value * random); } } private void OnCollisionEnter(Collision collision) { if (collision.gameObject.layer == characterLayer) { CharacterThirdPerson component = collision.gameObject.GetComponent(); if (!((Object)(object)component == (Object)null) && component.smoothPhysics) { component.smoothPhysics = false; } } } private void OnCollisionExit(Collision collision) { if (collision.gameObject.layer == characterLayer) { CharacterThirdPerson component = collision.gameObject.GetComponent(); if (!((Object)(object)component == (Object)null)) { component.smoothPhysics = true; } } } } public class BendGoal : MonoBehaviour { public LimbIK limbIK; [Range(0f, 1f)] public float weight = 1f; private void Start() { Debug.Log((object)"BendGoal is deprecated, you can now a bend goal from the custom inspector of the LimbIK component."); } private void LateUpdate() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)limbIK == (Object)null)) { ((IKSolverTrigonometric)limbIK.solver).SetBendGoalPosition(((Component)this).transform.position, weight); } } } public class Turret : MonoBehaviour { [Serializable] public class Part { public Transform transform; private RotationLimit rotationLimit; public void AimAt(Transform target) { //IL_0008: 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) transform.LookAt(target.position, transform.up); if ((Object)(object)rotationLimit == (Object)null) { rotationLimit = ((Component)transform).GetComponent(); rotationLimit.Disable(); } rotationLimit.Apply(); } } public Transform target; public Part[] parts; private void Update() { Part[] array = parts; foreach (Part part in array) { part.AimAt(target); } } } public class HitReactionVRIKTrigger : MonoBehaviour { public HitReactionVRIK hitReaction; public float hitForce = 1f; private string colliderName; private void Update() { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0052: 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) if (Input.GetMouseButtonDown(0)) { Ray val = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, ref val2, 100f)) { hitReaction.Hit(((RaycastHit)(ref val2)).collider, ((Ray)(ref val)).direction * hitForce, ((RaycastHit)(ref val2)).point); colliderName = ((Object)((RaycastHit)(ref val2)).collider).name; } } } private void OnGUI() { GUILayout.Label("LMB to shoot the Dummy, RMB to rotate the camera.", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (colliderName != string.Empty) { GUILayout.Label("Last Bone Hit: " + colliderName, (GUILayoutOption[])(object)new GUILayoutOption[0]); } } } } namespace RootMotion1.Demos { public class VRIKCalibrationBasic : MonoBehaviour { [Tooltip("The VRIK component.")] public VRIK ik; [Header("Head")] [Tooltip("HMD.")] public Transform centerEyeAnchor; [Tooltip("Position offset of the camera from the head bone (root space).")] public Vector3 headAnchorPositionOffset; [Tooltip("Rotation offset of the camera from the head bone (root space).")] public Vector3 headAnchorRotationOffset; [Header("Hands")] [Tooltip("Left Hand Controller")] public Transform leftHandAnchor; [Tooltip("Right Hand Controller")] public Transform rightHandAnchor; [Tooltip("Position offset of the hand controller from the hand bone (controller space).")] public Vector3 handAnchorPositionOffset; [Tooltip("Rotation offset of the hand controller from the hand bone (controller space).")] public Vector3 handAnchorRotationOffset; [Header("Scale")] [Tooltip("Multiplies the scale of the root.")] public float scaleMlp = 1f; [Header("Data stored by Calibration")] public VRIKCalibrator.CalibrationData data = new VRIKCalibrator.CalibrationData(); private void LateUpdate() { //IL_0028: 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_0034: 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) if (Input.GetKeyDown((KeyCode)99)) { data = VRIKCalibrator.Calibrate(ik, centerEyeAnchor, leftHandAnchor, rightHandAnchor, headAnchorPositionOffset, headAnchorRotationOffset, handAnchorPositionOffset, handAnchorRotationOffset, scaleMlp); } if (Input.GetKeyDown((KeyCode)100)) { if (data.scale == 0f) { Debug.LogError((object)"No Calibration Data to calibrate to, please calibrate with 'C' first."); } else { VRIKCalibrator.Calibrate(ik, data, centerEyeAnchor, null, leftHandAnchor, rightHandAnchor); } } if (Input.GetKeyDown((KeyCode)115)) { if (data.scale == 0f) { Debug.LogError((object)"Avatar needs to be calibrated before RecalibrateScale is called."); } VRIKCalibrator.RecalibrateScale(ik, data, scaleMlp); } } } public class VRIKCalibrationController : MonoBehaviour { [Tooltip("Reference to the VRIK component on the avatar.")] public VRIK ik; [Tooltip("The settings for VRIK calibration.")] public VRIKCalibrator.Settings settings; [Tooltip("The HMD.")] public Transform headTracker; [Tooltip("(Optional) A tracker placed anywhere on the body of the player, preferrably close to the pelvis, on the belt area.")] public Transform bodyTracker; [Tooltip("(Optional) A tracker or hand controller device placed anywhere on or in the player's left hand.")] public Transform leftHandTracker; [Tooltip("(Optional) A tracker or hand controller device placed anywhere on or in the player's right hand.")] public Transform rightHandTracker; [Tooltip("(Optional) A tracker placed anywhere on the ankle or toes of the player's left leg.")] public Transform leftFootTracker; [Tooltip("(Optional) A tracker placed anywhere on the ankle or toes of the player's right leg.")] public Transform rightFootTracker; [Header("Data stored by Calibration")] public VRIKCalibrator.CalibrationData data = new VRIKCalibrator.CalibrationData(); private void LateUpdate() { if (Input.GetKeyDown((KeyCode)99)) { data = VRIKCalibrator.Calibrate(ik, settings, headTracker, bodyTracker, leftHandTracker, rightHandTracker, leftFootTracker, rightFootTracker); } if (Input.GetKeyDown((KeyCode)100)) { if (data.scale == 0f) { Debug.LogError((object)"No Calibration Data to calibrate to, please calibrate with settings first."); } else { VRIKCalibrator.Calibrate(ik, data, headTracker, bodyTracker, leftHandTracker, rightHandTracker, leftFootTracker, rightFootTracker); } } if (Input.GetKeyDown((KeyCode)115)) { if (data.scale == 0f) { Debug.LogError((object)"Avatar needs to be calibrated before RecalibrateScale is called."); } VRIKCalibrator.RecalibrateScale(ik, data, settings); } } } } namespace RootMotion.Demos { public class VRIKPlatform : MonoBehaviour { public VRIK ik; private Vector3 lastPosition; private Quaternion lastRotation = Quaternion.identity; private void OnEnable() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) lastPosition = ((Component)this).transform.position; lastRotation = ((Component)this).transform.rotation; } private void LateUpdate() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_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) ik.solver.AddPlatformMotion(((Component)this).transform.position - lastPosition, ((Component)this).transform.rotation * Quaternion.Inverse(lastRotation), ((Component)this).transform.position); lastRotation = ((Component)this).transform.rotation; lastPosition = ((Component)this).transform.position; } } public class VRIKPlatformController : MonoBehaviour { public VRIK ik; public Transform trackingSpace; public Transform platform; public bool moveToPlatform = true; private Transform lastPlatform; private Vector3 lastPosition; private Quaternion lastRotation = Quaternion.identity; private void LateUpdate() { //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: 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_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0106: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)platform != (Object)(object)lastPlatform) { if ((Object)(object)platform != (Object)null) { if (moveToPlatform) { lastPosition = ((Component)ik).transform.position; lastRotation = ((Component)ik).transform.rotation; ((Component)ik).transform.position = platform.position; ((Component)ik).transform.rotation = platform.rotation; trackingSpace.position = platform.position; trackingSpace.rotation = platform.rotation; ik.solver.AddPlatformMotion(platform.position - lastPosition, platform.rotation * Quaternion.Inverse(lastRotation), platform.position); } lastPosition = platform.position; lastRotation = platform.rotation; } ((Component)ik).transform.parent = platform; trackingSpace.parent = platform; lastPlatform = platform; } if ((Object)(object)platform != (Object)null) { ik.solver.AddPlatformMotion(platform.position - lastPosition, platform.rotation * Quaternion.Inverse(lastRotation), platform.position); lastRotation = platform.rotation; lastPosition = platform.position; } } } } namespace RootMotion1 { public class CameraController : MonoBehaviour { [Serializable] public enum UpdateMode { Update, FixedUpdate, LateUpdate, FixedLateUpdate } public Transform target; public Transform rotationSpace; public UpdateMode updateMode = UpdateMode.LateUpdate; public bool lockCursor = true; [Header("Position")] public bool smoothFollow; public Vector3 offset = new Vector3(0f, 1.5f, 0.5f); public float followSpeed = 10f; [Header("Rotation")] public float rotationSensitivity = 3.5f; public float yMinLimit = -20f; public float yMaxLimit = 80f; public bool rotateAlways = true; public bool rotateOnLeftButton; public bool rotateOnRightButton; public bool rotateOnMiddleButton; [Header("Distance")] public float distance = 10f; public float minDistance = 4f; public float maxDistance = 10f; public float zoomSpeed = 10f; public float zoomSensitivity = 1f; [Header("Blocking")] public LayerMask blockingLayers; public float blockingRadius = 1f; public float blockingSmoothTime = 0.1f; public float blockingOriginOffset; [Range(0f, 1f)] public float blockedOffset = 0.5f; private Vector3 targetDistance; private Vector3 position; private Quaternion rotation = Quaternion.identity; private Vector3 smoothPosition; private Camera cam; private bool fixedFrame; private float fixedDeltaTime; private Quaternion r = Quaternion.identity; private Vector3 lastUp; private float blockedDistance = 10f; private float blockedDistanceV; public float x { get; private set; } public float y { get; private set; } public float distanceTarget { get; private set; } private float zoomAdd { get { float axis = Input.GetAxis("Mouse ScrollWheel"); if (axis > 0f) { return 0f - zoomSensitivity; } if (axis < 0f) { return zoomSensitivity; } return 0f; } } public void SetAngles(Quaternion rotation) { //IL_0003: 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) Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles; x = eulerAngles.y; y = eulerAngles.x; } public void SetAngles(float yaw, float pitch) { x = yaw; y = pitch; } protected virtual void Awake() { //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0077: Unknown result type (might be due to invalid IL or missing references) Vector3 eulerAngles = ((Component)this).transform.eulerAngles; x = eulerAngles.y; y = eulerAngles.x; distanceTarget = distance; smoothPosition = ((Component)this).transform.position; cam = ((Component)this).GetComponent(); lastUp = ((!((Object)(object)rotationSpace != (Object)null)) ? Vector3.up : rotationSpace.up); } protected virtual void Update() { if (updateMode == UpdateMode.Update) { UpdateTransform(); } } protected virtual void FixedUpdate() { fixedFrame = true; fixedDeltaTime += Time.deltaTime; if (updateMode == UpdateMode.FixedUpdate) { UpdateTransform(); } } protected virtual void LateUpdate() { UpdateInput(); if (updateMode == UpdateMode.LateUpdate) { UpdateTransform(); } if (updateMode == UpdateMode.FixedLateUpdate && fixedFrame) { UpdateTransform(fixedDeltaTime); fixedDeltaTime = 0f; fixedFrame = false; } } public void UpdateInput() { if (((Behaviour)cam).enabled) { Cursor.lockState = (CursorLockMode)(lockCursor ? 1 : 0); Cursor.visible = ((!lockCursor) ? true : false); if (rotateAlways || (rotateOnLeftButton && Input.GetMouseButton(0)) || (rotateOnRightButton && Input.GetMouseButton(1)) || (rotateOnMiddleButton && Input.GetMouseButton(2))) { x += Input.GetAxis("Mouse X") * rotationSensitivity; y = ClampAngle(y - Input.GetAxis("Mouse Y") * rotationSensitivity, yMinLimit, yMaxLimit); } distanceTarget = Mathf.Clamp(distanceTarget + zoomAdd, minDistance, maxDistance); } } public void UpdateTransform() { UpdateTransform(Time.deltaTime); } public void UpdateTransform(float deltaTime) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_007c: 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_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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_0241: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_0219: 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_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_017a: 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) if (!((Behaviour)cam).enabled) { return; } rotation = Quaternion.AngleAxis(x, Vector3.up) * Quaternion.AngleAxis(y, Vector3.right); if ((Object)(object)rotationSpace != (Object)null) { r = Quaternion.FromToRotation(lastUp, rotationSpace.up) * r; rotation = r * rotation; lastUp = rotationSpace.up; } if ((Object)(object)target != (Object)null) { distance += (distanceTarget - distance) * zoomSpeed * deltaTime; if (!smoothFollow) { smoothPosition = target.position; } else { smoothPosition = Vector3.Lerp(smoothPosition, target.position, deltaTime * followSpeed); } Vector3 val = smoothPosition + rotation * offset; Vector3 val2 = rotation * -Vector3.forward; if (LayerMask.op_Implicit(blockingLayers) != -1) { RaycastHit val3 = default(RaycastHit); if (Physics.SphereCast(val - val2 * blockingOriginOffset, blockingRadius, val2, ref val3, blockingOriginOffset + distanceTarget - blockingRadius, LayerMask.op_Implicit(blockingLayers))) { blockedDistance = Mathf.SmoothDamp(blockedDistance, ((RaycastHit)(ref val3)).distance + blockingRadius * (1f - blockedOffset) - blockingOriginOffset, ref blockedDistanceV, blockingSmoothTime); } else { blockedDistance = distanceTarget; } distance = Mathf.Min(distance, blockedDistance); } position = val + val2 * distance; ((Component)this).transform.position = position; } ((Component)this).transform.rotation = rotation; } private float ClampAngle(float angle, float min, float max) { if (angle < -360f) { angle += 360f; } if (angle > 360f) { angle -= 360f; } return Mathf.Clamp(angle, min, max); } } public class CameraControllerFPS : MonoBehaviour { public float rotationSensitivity = 3f; public float yMinLimit = -89f; public float yMaxLimit = 89f; private float x; private float y; private void Awake() { //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) Vector3 eulerAngles = ((Component)this).transform.eulerAngles; x = eulerAngles.y; y = eulerAngles.x; } public void LateUpdate() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) Cursor.lockState = (CursorLockMode)1; x += Input.GetAxis("Mouse X") * rotationSensitivity; y = ClampAngle(y - Input.GetAxis("Mouse Y") * rotationSensitivity, yMinLimit, yMaxLimit); ((Component)this).transform.rotation = Quaternion.AngleAxis(x, Vector3.up) * Quaternion.AngleAxis(y, Vector3.right); } private float ClampAngle(float angle, float min, float max) { if (angle < -360f) { angle += 360f; } if (angle > 360f) { angle -= 360f; } return Mathf.Clamp(angle, min, max); } } } namespace RootMotion.Demos { public abstract class CharacterAnimationBase : MonoBehaviour { public bool smoothFollow = true; public float smoothFollowSpeed = 20f; protected bool animatePhysics; private Vector3 lastPosition; private Vector3 localPosition; private Quaternion localRotation; private Quaternion lastRotation; public virtual bool animationGrounded => true; public virtual Vector3 GetPivotPoint() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return ((Component)this).transform.position; } public float GetAngleFromForward(Vector3 worldDirection) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.InverseTransformDirection(worldDirection); return Mathf.Atan2(val.x, val.z) * 57.29578f; } protected virtual void Start() { //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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((Component)((Component)this).transform.parent).GetComponent() == (Object)null) { Debug.LogWarning((object)"Animation controllers should be parented to character controllers!", (Object)(object)((Component)this).transform); } lastPosition = ((Component)this).transform.position; localPosition = ((Component)this).transform.localPosition; lastRotation = ((Component)this).transform.rotation; localRotation = ((Component)this).transform.localRotation; } protected virtual void LateUpdate() { if (!animatePhysics) { SmoothFollow(); } } protected virtual void FixedUpdate() { if (animatePhysics) { SmoothFollow(); } } private void SmoothFollow() { //IL_0090: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0078: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) if (smoothFollow) { ((Component)this).transform.position = Vector3.Lerp(lastPosition, ((Component)this).transform.parent.TransformPoint(localPosition), Time.deltaTime * smoothFollowSpeed); ((Component)this).transform.rotation = Quaternion.Lerp(lastRotation, ((Component)this).transform.parent.rotation * localRotation, Time.deltaTime * smoothFollowSpeed); } else { ((Component)this).transform.localPosition = localPosition; ((Component)this).transform.localRotation = localRotation; } lastPosition = ((Component)this).transform.position; lastRotation = ((Component)this).transform.rotation; } } public class CharacterAnimationSimple : CharacterAnimationBase { public CharacterThirdPerson characterController; public float pivotOffset; public AnimationCurve moveSpeed; private Animator animator; protected override void Start() { base.Start(); animator = ((Component)this).GetComponentInChildren(); } public override Vector3 GetPivotPoint() { //IL_0028: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_001c: 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) if (pivotOffset == 0f) { return ((Component)this).transform.position; } return ((Component)this).transform.position + ((Component)this).transform.forward * pivotOffset; } private void Update() { //IL_0044: 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) float num = moveSpeed.Evaluate(characterController.animState.moveDirection.z); animator.SetFloat("Speed", num); characterController.Move(((Component)characterController).transform.forward * Time.deltaTime * num, Quaternion.identity); } } public class CharacterAnimationThirdPerson : CharacterAnimationBase { public CharacterThirdPerson characterController; [SerializeField] private float turnSensitivity = 0.2f; [SerializeField] private float turnSpeed = 5f; [SerializeField] private float runCycleLegOffset = 0.2f; [Range(0.1f, 3f)] [SerializeField] private float animSpeedMultiplier = 1f; protected Animator animator; private Vector3 lastForward; private const string groundedDirectional = "Grounded Directional"; private const string groundedStrafe = "Grounded Strafe"; private float deltaAngle; private float jumpLeg; private bool lastJump; public override bool animationGrounded { get { //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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0); int result; if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Grounded Directional")) { AnimatorStateInfo currentAnimatorStateInfo2 = animator.GetCurrentAnimatorStateInfo(0); result = (((AnimatorStateInfo)(ref currentAnimatorStateInfo2)).IsName("Grounded Strafe") ? 1 : 0); } else { result = 1; } return (byte)result != 0; } } protected override void Start() { //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) base.Start(); animator = ((Component)this).GetComponent(); lastForward = ((Component)this).transform.forward; } public override Vector3 GetPivotPoint() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) return animator.pivotPosition; } protected virtual void Update() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Invalid comparison between Unknown and I4 //IL_00c6: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (Time.deltaTime != 0f) { animatePhysics = (int)animator.updateMode == 1; if (characterController.animState.jump && !lastJump) { AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0); float num = Mathf.Repeat(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime + runCycleLegOffset, 1f); float num2 = (float)((num < 0.5f) ? 1 : (-1)) * characterController.animState.moveDirection.z; animator.SetFloat("JumpLeg", num2); } lastJump = characterController.animState.jump; float num3 = 0f - GetAngleFromForward(lastForward) - deltaAngle; deltaAngle = 0f; lastForward = ((Component)this).transform.forward; num3 *= turnSensitivity * 0.01f; num3 = Mathf.Clamp(num3 / Time.deltaTime, -1f, 1f); animator.SetFloat("Turn", Mathf.Lerp(animator.GetFloat("Turn"), num3, Time.deltaTime * turnSpeed)); animator.SetFloat("Forward", characterController.animState.moveDirection.z); animator.SetFloat("Right", characterController.animState.moveDirection.x); animator.SetBool("Crouch", characterController.animState.crouch); animator.SetBool("OnGround", characterController.animState.onGround); animator.SetBool("IsStrafing", characterController.animState.isStrafing); if (!characterController.animState.onGround) { animator.SetFloat("Jump", characterController.animState.yVelocity); } if (characterController.doubleJumpEnabled) { animator.SetBool("DoubleJump", characterController.animState.doubleJump); } characterController.animState.doubleJump = false; if (characterController.animState.onGround && characterController.animState.moveDirection.z > 0f) { animator.speed = animSpeedMultiplier; } else { animator.speed = 1f; } } } private void OnAnimatorMove() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) Vector3 val = animator.deltaRotation * Vector3.forward; deltaAngle += Mathf.Atan2(val.x, val.z) * 57.29578f; characterController.Move(animator.deltaPosition, animator.deltaRotation); } } public abstract class CharacterBase : MonoBehaviour { [Header("Base Parameters")] [Tooltip("If specified, will use the direction from the character to this Transform as the gravity vector instead of Physics.gravity. Physics.gravity.magnitude will be used as the magnitude of the gravity vector.")] public Transform gravityTarget; [Tooltip("Multiplies gravity applied to the character even if 'Individual Gravity' is unchecked.")] public float gravityMultiplier = 2f; public float airborneThreshold = 0.6f; public float slopeStartAngle = 50f; public float slopeEndAngle = 85f; public float spherecastRadius = 0.1f; public LayerMask groundLayers; private PhysicMaterial zeroFrictionMaterial; private PhysicMaterial highFrictionMaterial; protected Rigidbody r; protected const float half = 0.5f; protected float originalHeight; protected Vector3 originalCenter; protected CapsuleCollider capsule; public abstract void Move(Vector3 deltaPosition, Quaternion deltaRotation); protected Vector3 GetGravity() { //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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0059: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gravityTarget != (Object)null) { Vector3 val = gravityTarget.position - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 gravity = Physics.gravity; return normalized * ((Vector3)(ref gravity)).magnitude; } return Physics.gravity; } protected virtual void Start() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown ref CapsuleCollider reference = ref capsule; Collider component = ((Component)this).GetComponent(); reference = (CapsuleCollider)(object)((component is CapsuleCollider) ? component : null); r = ((Component)this).GetComponent(); originalHeight = capsule.height; originalCenter = capsule.center; zeroFrictionMaterial = new PhysicMaterial(); zeroFrictionMaterial.dynamicFriction = 0f; zeroFrictionMaterial.staticFriction = 0f; zeroFrictionMaterial.frictionCombine = (PhysicMaterialCombine)2; zeroFrictionMaterial.bounciness = 0f; zeroFrictionMaterial.bounceCombine = (PhysicMaterialCombine)2; highFrictionMaterial = new PhysicMaterial(); r.constraints = (RigidbodyConstraints)112; } protected virtual RaycastHit GetSpherecastHit() { //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_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0038: 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_0056: 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_0066: 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_0082: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) Vector3 up = ((Component)this).transform.up; Ray val = default(Ray); ((Ray)(ref val))..ctor(r.position + up * airborneThreshold, -up); RaycastHit result = default(RaycastHit); ((RaycastHit)(ref result)).point = ((Component)this).transform.position - ((Component)((Component)this).transform).transform.up * airborneThreshold; ((RaycastHit)(ref result)).normal = ((Component)this).transform.up; Physics.SphereCast(val, spherecastRadius, ref result, airborneThreshold * 2f, LayerMask.op_Implicit(groundLayers)); return result; } public float GetAngleFromForward(Vector3 worldDirection) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)this).transform.InverseTransformDirection(worldDirection); return Mathf.Atan2(val.x, val.z) * 57.29578f; } protected void RigidbodyRotateAround(Vector3 point, Vector3 axis, float angle) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0029: 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_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) Quaternion val = Quaternion.AngleAxis(angle, axis); Vector3 val2 = ((Component)this).transform.position - point; r.MovePosition(point + val * val2); r.MoveRotation(val * ((Component)this).transform.rotation); } protected void ScaleCapsule(float mlp) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) if (capsule.height != originalHeight * mlp) { capsule.height = Mathf.MoveTowards(capsule.height, originalHeight * mlp, Time.deltaTime * 4f); capsule.center = Vector3.MoveTowards(capsule.center, originalCenter * mlp, Time.deltaTime * 2f); } } protected void HighFriction() { ((Collider)capsule).material = highFrictionMaterial; } protected void ZeroFriction() { ((Collider)capsule).material = zeroFrictionMaterial; } protected float GetSlopeDamper(Vector3 velocity, Vector3 groundNormal) { //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) float num = 90f - Vector3.Angle(velocity, groundNormal); num -= slopeStartAngle; float num2 = slopeEndAngle - slopeStartAngle; return 1f - Mathf.Clamp(num / num2, 0f, 1f); } } public class CharacterThirdPerson : CharacterBase { [Serializable] public enum MoveMode { Directional, Strafe } public struct AnimState { public Vector3 moveDirection; public bool jump; public bool crouch; public bool onGround; public bool isStrafing; public float yVelocity; public bool doubleJump; } [Header("References")] public CharacterAnimationBase characterAnimation; public UserControlThirdPerson userControl; public CameraController cam; [Header("Movement")] public MoveMode moveMode; public bool smoothPhysics = true; public float smoothAccelerationTime = 0.2f; public float linearAccelerationSpeed = 3f; public float platformFriction = 7f; public float groundStickyEffect = 4f; public float maxVerticalVelocityOnGround = 3f; public float velocityToGroundTangentWeight = 0f; [Header("Rotation")] public bool lookInCameraDirection; public float turnSpeed = 5f; public float stationaryTurnSpeedMlp = 1f; [Header("Jumping and Falling")] public bool smoothJump = true; public float airSpeed = 6f; public float airControl = 2f; public float jumpPower = 12f; public float jumpRepeatDelayTime = 0f; public bool doubleJumpEnabled; public float doubleJumpPowerMlp = 1f; [Header("Wall Running")] public LayerMask wallRunLayers; public float wallRunMaxLength = 1f; public float wallRunMinMoveMag = 0.6f; public float wallRunMinVelocityY = -1f; public float wallRunRotationSpeed = 1.5f; public float wallRunMaxRotationAngle = 70f; public float wallRunWeightSpeed = 5f; [Header("Crouching")] public float crouchCapsuleScaleMlp = 0.6f; public AnimState animState = default(AnimState); protected Vector3 moveDirection; private Animator animator; private Vector3 normal; private Vector3 platformVelocity; private Vector3 platformAngularVelocity; private RaycastHit hit; private float jumpLeg; private float jumpEndTime; private float forwardMlp; private float groundDistance; private float lastAirTime; private float stickyForce; private Vector3 wallNormal = Vector3.up; private Vector3 moveDirectionVelocity; private float wallRunWeight; private float lastWallRunWeight; private float fixedDeltaTime; private Vector3 fixedDeltaPosition; private Quaternion fixedDeltaRotation = Quaternion.identity; private bool fixedFrame; private float wallRunEndTime; private Vector3 gravity; private Vector3 verticalVelocity; private float velocityY; private bool doubleJumped; private bool jumpReleased; public bool onGround { get; private set; } protected override void Start() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) base.Start(); animator = ((Component)this).GetComponent(); if ((Object)(object)animator == (Object)null) { animator = ((Component)characterAnimation).GetComponent(); } wallNormal = -((Vector3)(ref gravity)).normalized; onGround = true; animState.onGround = true; if ((Object)(object)cam != (Object)null) { ((Behaviour)cam).enabled = false; } } private void OnAnimatorMove() { //IL_0008: 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) Move(animator.deltaPosition, animator.deltaRotation); } public override void Move(Vector3 deltaPosition, Quaternion deltaRotation) { //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_0020: 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_0032: Unknown result type (might be due to invalid IL or missing references) fixedDeltaTime += Time.deltaTime; fixedDeltaPosition += deltaPosition; fixedDeltaRotation *= deltaRotation; } private void FixedUpdate() { //IL_0003: 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_0014: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0097: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) gravity = GetGravity(); verticalVelocity = V3Tools.ExtractVertical(r.velocity, gravity, 1f); velocityY = ((Vector3)(ref verticalVelocity)).magnitude; if (Vector3.Dot(verticalVelocity, gravity) > 0f) { velocityY = 0f - velocityY; } r.interpolation = (RigidbodyInterpolation)(smoothPhysics ? 1 : 0); characterAnimation.smoothFollow = smoothPhysics; MoveFixed(fixedDeltaPosition); fixedDeltaTime = 0f; fixedDeltaPosition = Vector3.zero; r.MoveRotation(((Component)this).transform.rotation * fixedDeltaRotation); fixedDeltaRotation = Quaternion.identity; Rotate(); GroundCheck(); if (userControl.state.move == Vector3.zero && groundDistance < airborneThreshold * 0.5f) { HighFriction(); } else { ZeroFriction(); } int num; if (onGround && userControl.state.move == Vector3.zero) { Vector3 velocity = r.velocity; if (((Vector3)(ref velocity)).magnitude < 0.5f) { num = ((groundDistance < airborneThreshold * 0.5f) ? 1 : 0); goto IL_0194; } } num = 0; goto IL_0194; IL_0194: bool flag = (byte)num != 0; if ((Object)(object)gravityTarget != (Object)null) { r.useGravity = false; if (!flag) { r.AddForce(gravity); } } if (flag) { r.useGravity = false; r.velocity = Vector3.zero; } else if ((Object)(object)gravityTarget == (Object)null) { r.useGravity = true; } if (onGround) { animState.jump = Jump(); jumpReleased = false; doubleJumped = false; } else { if (!userControl.state.jump) { jumpReleased = true; } if (jumpReleased && userControl.state.jump && !doubleJumped && doubleJumpEnabled) { jumpEndTime = Time.time + 0.1f; animState.doubleJump = true; Vector3 velocity2 = userControl.state.move * airSpeed; r.velocity = velocity2; Rigidbody obj = r; obj.velocity += ((Component)this).transform.up * jumpPower * doubleJumpPowerMlp; doubleJumped = true; } } ScaleCapsule((!userControl.state.crouch) ? 1f : crouchCapsuleScaleMlp); fixedFrame = true; } protected virtual void Update() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) animState.onGround = onGround; animState.moveDirection = GetMoveDirection(); animState.yVelocity = Mathf.Lerp(animState.yVelocity, velocityY, Time.deltaTime * 10f); animState.crouch = userControl.state.crouch; animState.isStrafing = moveMode == MoveMode.Strafe; } protected virtual void LateUpdate() { //IL_004e: 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) if (!((Object)(object)cam == (Object)null)) { cam.UpdateInput(); if (fixedFrame || (int)r.interpolation != 0) { cam.UpdateTransform(((int)r.interpolation != 0) ? Time.deltaTime : Time.fixedDeltaTime); fixedFrame = false; } } } private void MoveFixed(Vector3 deltaPosition) { //IL_0028: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_015e: 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_016a: 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_01a9: 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_01ac: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) WallRun(); Vector3 val = ((!(fixedDeltaTime > 0f)) ? Vector3.zero : (deltaPosition / fixedDeltaTime)); val += V3Tools.ExtractHorizontal(platformVelocity, gravity, 1f); if (onGround) { if (velocityToGroundTangentWeight > 0f) { Quaternion val2 = Quaternion.FromToRotation(((Component)this).transform.up, normal); val = Quaternion.Lerp(Quaternion.identity, val2, velocityToGroundTangentWeight) * val; } } else { Vector3 val3 = V3Tools.ExtractHorizontal(userControl.state.move * airSpeed, gravity, 1f); val = Vector3.Lerp(r.velocity, val3, Time.deltaTime * airControl); } if (onGround && Time.time > jumpEndTime) { r.velocity -= ((Component)this).transform.up * stickyForce * Time.deltaTime; } Vector3 val4 = V3Tools.ExtractVertical(r.velocity, gravity, 1f); Vector3 val5 = V3Tools.ExtractHorizontal(val, gravity, 1f); if (onGround && Vector3.Dot(val4, gravity) < 0f) { val4 = Vector3.ClampMagnitude(val4, maxVerticalVelocityOnGround); } r.velocity = val5 + val4; forwardMlp = 1f; } private void WallRun() { //IL_009b: 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_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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: 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_01ac: 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_012d: 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: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) bool flag = CanWallRun(); if (wallRunWeight > 0f && !flag) { wallRunEndTime = Time.time; } if (Time.time < wallRunEndTime + 0.5f) { flag = false; } wallRunWeight = Mathf.MoveTowards(wallRunWeight, (!flag) ? 0f : 1f, Time.deltaTime * wallRunWeightSpeed); if (wallRunWeight <= 0f && lastWallRunWeight > 0f) { Vector3 val = V3Tools.ExtractHorizontal(((Component)this).transform.forward, gravity, 1f); ((Component)this).transform.rotation = Quaternion.LookRotation(val, -gravity); wallNormal = -((Vector3)(ref gravity)).normalized; } lastWallRunWeight = wallRunWeight; if (!(wallRunWeight <= 0f)) { if (onGround && velocityY < 0f) { r.velocity = V3Tools.ExtractHorizontal(r.velocity, gravity, 1f); } Vector3 val2 = V3Tools.ExtractHorizontal(((Component)this).transform.forward, gravity, 1f); RaycastHit val3 = default(RaycastHit); ((RaycastHit)(ref val3)).normal = -((Vector3)(ref gravity)).normalized; Vector3 val4; if (onGround) { val4 = ((Component)this).transform.position; } else { Bounds bounds = ((Collider)capsule).bounds; val4 = ((Bounds)(ref bounds)).center; } Physics.Raycast(val4, val2, ref val3, 3f, LayerMask.op_Implicit(wallRunLayers)); wallNormal = Vector3.Lerp(wallNormal, ((RaycastHit)(ref val3)).normal, Time.deltaTime * wallRunRotationSpeed); wallNormal = Vector3.RotateTowards(-((Vector3)(ref gravity)).normalized, wallNormal, wallRunMaxRotationAngle * ((float)Math.PI / 180f), 0f); Vector3 forward = ((Component)this).transform.forward; Vector3 val5 = wallNormal; Vector3.OrthoNormalize(ref val5, ref forward); ((Component)this).transform.rotation = Quaternion.Slerp(Quaternion.LookRotation(val2, -gravity), Quaternion.LookRotation(forward, wallNormal), wallRunWeight); } } private bool CanWallRun() { if (Time.time < jumpEndTime - 0.1f) { return false; } if (Time.time > jumpEndTime - 0.1f + wallRunMaxLength) { return false; } if (velocityY < wallRunMinVelocityY) { return false; } if (((Vector3)(ref userControl.state.move)).magnitude < wallRunMinMoveMag) { return false; } return true; } private Vector3 GetMoveDirection() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0129: Unknown result type (might be due to invalid IL or missing references) switch (moveMode) { case MoveMode.Directional: moveDirection = Vector3.SmoothDamp(moveDirection, new Vector3(0f, 0f, ((Vector3)(ref userControl.state.move)).magnitude), ref moveDirectionVelocity, smoothAccelerationTime); moveDirection = Vector3.MoveTowards(moveDirection, new Vector3(0f, 0f, ((Vector3)(ref userControl.state.move)).magnitude), Time.deltaTime * linearAccelerationSpeed); return moveDirection * forwardMlp; case MoveMode.Strafe: moveDirection = Vector3.SmoothDamp(moveDirection, userControl.state.move, ref moveDirectionVelocity, smoothAccelerationTime); moveDirection = Vector3.MoveTowards(moveDirection, userControl.state.move, Time.deltaTime * linearAccelerationSpeed); return ((Component)this).transform.InverseTransformDirection(moveDirection); default: return Vector3.zero; } } protected virtual void Rotate() { //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_001e: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)gravityTarget != (Object)null) { r.MoveRotation(Quaternion.FromToRotation(((Component)this).transform.up, ((Component)this).transform.position - gravityTarget.position) * ((Component)this).transform.rotation); } if (platformAngularVelocity != Vector3.zero) { r.MoveRotation(Quaternion.Euler(platformAngularVelocity) * ((Component)this).transform.rotation); } float num = GetAngleFromForward(GetForwardDirection()); if (userControl.state.move == Vector3.zero) { num *= (1.01f - Mathf.Abs(num) / 180f) * stationaryTurnSpeedMlp; } r.MoveRotation(Quaternion.AngleAxis(num * Time.deltaTime * turnSpeed, ((Component)this).transform.up) * r.rotation); } private Vector3 GetForwardDirection() { //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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0072: 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_010a: 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_00ae: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00d4: 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_00e4: 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) bool flag = userControl.state.move != Vector3.zero; switch (moveMode) { case MoveMode.Directional: if (flag) { return userControl.state.move; } return (!lookInCameraDirection) ? ((Component)this).transform.forward : (userControl.state.lookPos - r.position); case MoveMode.Strafe: if (flag) { return userControl.state.lookPos - r.position; } return (!lookInCameraDirection) ? ((Component)this).transform.forward : (userControl.state.lookPos - r.position); default: return Vector3.zero; } } protected virtual bool Jump() { //IL_0091: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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) if (!userControl.state.jump) { return false; } if (userControl.state.crouch) { return false; } if (!characterAnimation.animationGrounded) { return false; } if (Time.time < lastAirTime + jumpRepeatDelayTime) { return false; } onGround = false; jumpEndTime = Time.time + 0.1f; Vector3 val = userControl.state.move * airSpeed; val += ((Component)this).transform.up * jumpPower; if (smoothJump) { ((MonoBehaviour)this).StopAllCoroutines(); ((MonoBehaviour)this).StartCoroutine(JumpSmooth(val - r.velocity)); } else { r.velocity = val; } return true; } private IEnumerator JumpSmooth(Vector3 jumpVelocity) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) int steps = 0; int stepsToTake = 3; while (steps < stepsToTake) { r.AddForce(jumpVelocity / (float)stepsToTake, (ForceMode)2); steps++; yield return (object)new WaitForFixedUpdate(); } } private void GroundCheck() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_003c: 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_004c: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.zero; platformAngularVelocity = Vector3.zero; float num = 0f; hit = GetSpherecastHit(); normal = ((Component)this).transform.up; Vector3 val2 = Vector3.Project(r.position - ((RaycastHit)(ref hit)).point, ((Component)this).transform.up); groundDistance = ((Vector3)(ref val2)).magnitude; if (Time.time > jumpEndTime && velocityY < jumpPower * 0.5f) { bool flag = onGround; onGround = false; float num2 = (flag ? airborneThreshold : (airborneThreshold * 0.5f)); Vector3 val3 = V3Tools.ExtractHorizontal(r.velocity, gravity, 1f); float magnitude = ((Vector3)(ref val3)).magnitude; if (groundDistance < num2) { num = groundStickyEffect * magnitude * num2; if ((Object)(object)((RaycastHit)(ref hit)).rigidbody != (Object)null) { val = ((RaycastHit)(ref hit)).rigidbody.GetPointVelocity(((RaycastHit)(ref hit)).point); platformAngularVelocity = Vector3.Project(((RaycastHit)(ref hit)).rigidbody.angularVelocity, ((Component)this).transform.up); } onGround = true; } } platformVelocity = Vector3.Lerp(platformVelocity, val, Time.deltaTime * platformFriction); stickyForce = num; if (!onGround) { lastAirTime = Time.time; } } } public class SimpleLocomotion : MonoBehaviour { [Serializable] public enum RotationMode { Smooth, Linear } [Tooltip("The component that updates the camera.")] public CameraController cameraController; [Tooltip("Acceleration of movement.")] public float accelerationTime = 0.2f; [Tooltip("Turning speed.")] public float turnTime = 0.2f; [Tooltip("If true, will run on left shift, if not will walk on left shift.")] public bool walkByDefault = true; [Tooltip("Smooth or linear rotation.")] public RotationMode rotationMode; [Tooltip("Procedural motion speed (if not using root motion).")] public float moveSpeed = 3f; private Animator animator; private float speed; private float angleVel; private float speedVel; private Vector3 linearTargetDirection; private CharacterController characterController; public bool isGrounded { get; private set; } private void Start() { animator = ((Component)this).GetComponent(); characterController = ((Component)this).GetComponent(); ((Behaviour)cameraController).enabled = false; } private void Update() { //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) isGrounded = ((Component)this).transform.position.y < 0.1f; Rotate(); Move(); } private void LateUpdate() { cameraController.UpdateInput(); cameraController.UpdateTransform(); } private void Rotate() { //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_0019: 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_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) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) if (!isGrounded) { return; } Vector3 inputVector = GetInputVector(); if (inputVector == Vector3.zero) { return; } Vector3 forward = ((Component)this).transform.forward; switch (rotationMode) { case RotationMode.Smooth: { Vector3 val = ((Component)cameraController).transform.rotation * inputVector; float num = Mathf.Atan2(forward.x, forward.z) * 57.29578f; float num2 = Mathf.Atan2(val.x, val.z) * 57.29578f; float num3 = Mathf.SmoothDampAngle(num, num2, ref angleVel, turnTime); ((Component)this).transform.rotation = Quaternion.AngleAxis(num3, Vector3.up); break; } case RotationMode.Linear: { Vector3 inputVectorRaw = GetInputVectorRaw(); if (inputVectorRaw != Vector3.zero) { linearTargetDirection = ((Component)cameraController).transform.rotation * inputVectorRaw; } forward = Vector3.RotateTowards(forward, linearTargetDirection, Time.deltaTime * (1f / turnTime), 1f); forward.y = 0f; ((Component)this).transform.rotation = Quaternion.LookRotation(forward); break; } } } private void Move() { //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_00ba: 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_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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //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_00ea: Unknown result type (might be due to invalid IL or missing references) float num = (walkByDefault ? ((!Input.GetKey((KeyCode)304)) ? 0.5f : 1f) : ((!Input.GetKey((KeyCode)304)) ? 1f : 0.5f)); speed = Mathf.SmoothDamp(speed, num, ref speedVel, accelerationTime); Vector3 inputVector = GetInputVector(); float num2 = ((Vector3)(ref inputVector)).magnitude * speed; animator.SetFloat("Speed", num2); if (!animator.hasRootMotion && isGrounded) { Vector3 val = ((Component)this).transform.forward * num2 * moveSpeed; if ((Object)(object)characterController != (Object)null) { characterController.SimpleMove(val); return; } Transform transform = ((Component)this).transform; transform.position += val * Time.deltaTime; } } private Vector3 GetInputVector() { //IL_0061: 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_0068: Unknown result type (might be due to invalid IL or missing references) Vector3 result = default(Vector3); ((Vector3)(ref result))..ctor(Input.GetAxis("Horizontal"), 0f, Input.GetAxis("Vertical")); result.z += Mathf.Abs(result.x) * 0.05f; result.x -= Mathf.Abs(result.z) * 0.05f; return result; } private Vector3 GetInputVectorRaw() { //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_0025: Unknown result type (might be due to invalid IL or missing references) return new Vector3(Input.GetAxisRaw("Horizontal"), 0f, Input.GetAxisRaw("Vertical")); } } public class UserControlAI : UserControlThirdPerson { public Transform moveTarget; public float stoppingDistance = 0.5f; public float stoppingThreshold = 1.5f; public Navigator navigator; protected override void Start() { base.Start(); navigator.Initiate(((Component)this).transform); } protected override void Update() { //IL_006c: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) float num = ((!walkByDefault) ? 1f : 0.5f); if (navigator.activeTargetSeeking) { navigator.Update(moveTarget.position); state.move = navigator.normalizedDeltaPosition * num; return; } Vector3 val = moveTarget.position - ((Component)this).transform.position; float magnitude = ((Vector3)(ref val)).magnitude; Vector3 up = ((Component)this).transform.up; Vector3.OrthoNormalize(ref up, ref val); float num2 = ((!(state.move != Vector3.zero)) ? (stoppingDistance * stoppingThreshold) : stoppingDistance); state.move = ((!(magnitude > num2)) ? Vector3.zero : (val * num)); state.lookPos = moveTarget.position; } private void OnDrawGizmos() { if (navigator.activeTargetSeeking) { navigator.Visualize(); } } } public class UserControlThirdPerson : MonoBehaviour { public struct State { public Vector3 move; public Vector3 lookPos; public bool crouch; public bool jump; public int actionIndex; } public bool walkByDefault; public bool canCrouch = true; public bool canJump = true; public State state = default(State); protected Transform cam; protected virtual void Start() { cam = ((Component)Camera.main).transform; } protected virtual void Update() { //IL_0060: 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_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_0081: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) state.crouch = canCrouch && Input.GetKey((KeyCode)99); state.jump = canJump && Input.GetButton("Jump"); float axisRaw = Input.GetAxisRaw("Horizontal"); float axisRaw2 = Input.GetAxisRaw("Vertical"); Quaternion rotation = cam.rotation; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(axisRaw, 0f, axisRaw2); Vector3 val2 = rotation * ((Vector3)(ref val)).normalized; if (val2 != Vector3.zero) { Vector3 up = ((Component)this).transform.up; Vector3.OrthoNormalize(ref up, ref val2); state.move = val2; } else { state.move = Vector3.zero; } bool key = Input.GetKey((KeyCode)304); float num = (walkByDefault ? ((!key) ? 0.5f : 1f) : ((!key) ? 1f : 0.5f)); ref State reference = ref state; reference.move *= num; state.lookPos = ((Component)this).transform.position + cam.forward * 100f; } } public class ApplicationQuit : MonoBehaviour { private void Update() { if (Input.GetKeyDown((KeyCode)113) || Input.GetKeyDown((KeyCode)27)) { Application.Quit(); } } } public class SlowMo : MonoBehaviour { public KeyCode[] keyCodes; public bool mouse0; public bool mouse1; public float slowMoTimeScale = 0.3f; private void Update() { Time.timeScale = ((!IsSlowMotion()) ? 1f : slowMoTimeScale); } private bool IsSlowMotion() { if (mouse0 && Input.GetMouseButton(0)) { return true; } if (mouse1 && Input.GetMouseButton(1)) { return true; } for (int i = 0; i < keyCodes.Length; i++) { if (Input.GetKey(keyCodes[i])) { return true; } } return false; } } } namespace RootMotion1 { [Serializable] public enum Axis { X, Y, Z } public class AxisTools { public static Vector3 ToVector3(Axis axis) { //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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(axis switch { Axis.X => Vector3.right, Axis.Y => Vector3.up, _ => Vector3.forward, }); } public static Axis ToAxis(Vector3 v) { float num = Mathf.Abs(v.x); float num2 = Mathf.Abs(v.y); float num3 = Mathf.Abs(v.z); Axis result = Axis.X; if (num2 > num && num2 > num3) { result = Axis.Y; } if (num3 > num && num3 > num2) { result = Axis.Z; } return result; } public static Axis GetAxisToPoint(Transform t, Vector3 worldPosition) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Vector3 axisVectorToPoint = GetAxisVectorToPoint(t, worldPosition); if (axisVectorToPoint == Vector3.right) { return Axis.X; } if (axisVectorToPoint == Vector3.up) { return Axis.Y; } return Axis.Z; } public static Axis GetAxisToDirection(Transform t, Vector3 direction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) Vector3 axisVectorToDirection = GetAxisVectorToDirection(t, direction); if (axisVectorToDirection == Vector3.right) { return Axis.X; } if (axisVectorToDirection == Vector3.up) { return Axis.Y; } return Axis.Z; } public static Vector3 GetAxisVectorToPoint(Transform t, Vector3 worldPosition) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) return GetAxisVectorToDirection(t, worldPosition - t.position); } public static Vector3 GetAxisVectorToDirection(Transform t, Vector3 direction) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) return GetAxisVectorToDirection(t.rotation, direction); } public static Vector3 GetAxisVectorToDirection(Quaternion r, Vector3 direction) { //IL_0003: 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_000a: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_008d: 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) direction = ((Vector3)(ref direction)).normalized; Vector3 result = Vector3.right; float num = Mathf.Abs(Vector3.Dot(Vector3.Normalize(r * Vector3.right), direction)); float num2 = Mathf.Abs(Vector3.Dot(Vector3.Normalize(r * Vector3.up), direction)); if (num2 > num) { result = Vector3.up; } float num3 = Mathf.Abs(Vector3.Dot(Vector3.Normalize(r * Vector3.forward), direction)); if (num3 > num && num3 > num2) { result = Vector3.forward; } return result; } } [Serializable] public class BipedLimbOrientations { [Serializable] public class LimbOrientation { public Vector3 upperBoneForwardAxis; public Vector3 lowerBoneForwardAxis; public Vector3 lastBoneLeftAxis; public LimbOrientation(Vector3 upperBoneForwardAxis, Vector3 lowerBoneForwardAxis, Vector3 lastBoneLeftAxis) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) this.upperBoneForwardAxis = upperBoneForwardAxis; this.lowerBoneForwardAxis = lowerBoneForwardAxis; this.lastBoneLeftAxis = lastBoneLeftAxis; } } public LimbOrientation leftArm; public LimbOrientation rightArm; public LimbOrientation leftLeg; public LimbOrientation rightLeg; public static BipedLimbOrientations UMA => new BipedLimbOrientations(new LimbOrientation(Vector3.forward, Vector3.forward, Vector3.forward), new LimbOrientation(Vector3.forward, Vector3.forward, Vector3.back), new LimbOrientation(Vector3.forward, Vector3.forward, Vector3.down), new LimbOrientation(Vector3.forward, Vector3.forward, Vector3.down)); public static BipedLimbOrientations MaxBiped => new BipedLimbOrientations(new LimbOrientation(Vector3.down, Vector3.down, Vector3.down), new LimbOrientation(Vector3.down, Vector3.down, Vector3.up), new LimbOrientation(Vector3.up, Vector3.up, Vector3.back), new LimbOrientation(Vector3.up, Vector3.up, Vector3.back)); public BipedLimbOrientations(LimbOrientation leftArm, LimbOrientation rightArm, LimbOrientation leftLeg, LimbOrientation rightLeg) { this.leftArm = leftArm; this.rightArm = rightArm; this.leftLeg = leftLeg; this.rightLeg = rightLeg; } } public static class BipedNaming { [Serializable] public enum BoneType { Unassigned, Spine, Head, Arm, Leg, Tail, Eye } [Serializable] public enum BoneSide { Center, Left, Right } public static string[] typeLeft = new string[9] { " L ", "_L_", "-L-", " l ", "_l_", "-l-", "Left", "left", "CATRigL" }; public static string[] typeRight = new string[9] { " R ", "_R_", "-R-", " r ", "_r_", "-r-", "Right", "right", "CATRigR" }; public static string[] typeSpine = new string[16] { "Spine", "spine", "Pelvis", "pelvis", "Root", "root", "Torso", "torso", "Body", "body", "Hips", "hips", "Neck", "neck", "Chest", "chest" }; public static string[] typeHead = new string[2] { "Head", "head" }; public static string[] typeArm = new string[10] { "Arm", "arm", "Hand", "hand", "Wrist", "Wrist", "Elbow", "elbow", "Palm", "palm" }; public static string[] typeLeg = new string[16] { "Leg", "leg", "Thigh", "thigh", "Calf", "calf", "Femur", "femur", "Knee", "knee", "Foot", "foot", "Ankle", "ankle", "Hip", "hip" }; public static string[] typeTail = new string[2] { "Tail", "tail" }; public static string[] typeEye = new string[2] { "Eye", "eye" }; public static string[] typeExclude = new string[6] { "Nub", "Dummy", "dummy", "Tip", "IK", "Mesh" }; public static string[] typeExcludeSpine = new string[2] { "Head", "head" }; public static string[] typeExcludeHead = new string[2] { "Top", "End" }; public static string[] typeExcludeArm = new string[19] { "Collar", "collar", "Clavicle", "clavicle", "Finger", "finger", "Index", "index", "Mid", "mid", "Pinky", "pinky", "Ring", "Thumb", "thumb", "Adjust", "adjust", "Twist", "twist" }; public static string[] typeExcludeLeg = new string[7] { "Toe", "toe", "Platform", "Adjust", "adjust", "Twist", "twist" }; public static string[] typeExcludeTail = new string[0]; public static string[] typeExcludeEye = new string[6] { "Lid", "lid", "Brow", "brow", "Lash", "lash" }; public static string[] pelvis = new string[4] { "Pelvis", "pelvis", "Hip", "hip" }; public static string[] hand = new string[6] { "Hand", "hand", "Wrist", "wrist", "Palm", "palm" }; public static string[] foot = new string[4] { "Foot", "foot", "Ankle", "ankle" }; public static Transform[] GetBonesOfType(BoneType boneType, Transform[] bones) { Transform[] array = (Transform[])(object)new Transform[0]; foreach (Transform val in bones) { if ((Object)(object)val != (Object)null && GetBoneType(((Object)val).name) == boneType) { Array.Resize(ref array, array.Length + 1); array[^1] = val; } } return array; } public static Transform[] GetBonesOfSide(BoneSide boneSide, Transform[] bones) { Transform[] array = (Transform[])(object)new Transform[0]; foreach (Transform val in bones) { if ((Object)(object)val != (Object)null && GetBoneSide(((Object)val).name) == boneSide) { Array.Resize(ref array, array.Length + 1); array[^1] = val; } } return array; } public static Transform[] GetBonesOfTypeAndSide(BoneType boneType, BoneSide boneSide, Transform[] bones) { Transform[] bonesOfType = GetBonesOfType(boneType, bones); return GetBonesOfSide(boneSide, bonesOfType); } public static Transform GetFirstBoneOfTypeAndSide(BoneType boneType, BoneSide boneSide, Transform[] bones) { Transform[] bonesOfTypeAndSide = GetBonesOfTypeAndSide(boneType, boneSide, bones); if (bonesOfTypeAndSide.Length == 0) { return null; } return bonesOfTypeAndSide[0]; } public static Transform GetNamingMatch(Transform[] transforms, params string[][] namings) { foreach (Transform val in transforms) { bool flag = true; foreach (string[] namingConvention in namings) { if (!matchesNaming(((Object)val).name, namingConvention)) { flag = false; break; } } if (flag) { return val; } } return null; } public static BoneType GetBoneType(string boneName) { if (isSpine(boneName)) { return BoneType.Spine; } if (isHead(boneName)) { return BoneType.Head; } if (isArm(boneName)) { return BoneType.Arm; } if (isLeg(boneName)) { return BoneType.Leg; } if (isTail(boneName)) { return BoneType.Tail; } if (isEye(boneName)) { return BoneType.Eye; } return BoneType.Unassigned; } public static BoneSide GetBoneSide(string boneName) { if (isLeft(boneName)) { return BoneSide.Left; } if (isRight(boneName)) { return BoneSide.Right; } return BoneSide.Center; } public static Transform GetBone(Transform[] transforms, BoneType boneType, BoneSide boneSide = BoneSide.Center, params string[][] namings) { Transform[] bonesOfTypeAndSide = GetBonesOfTypeAndSide(boneType, boneSide, transforms); return GetNamingMatch(bonesOfTypeAndSide, namings); } private static bool isLeft(string boneName) { return matchesNaming(boneName, typeLeft) || lastLetter(boneName) == "L" || firstLetter(boneName) == "L"; } private static bool isRight(string boneName) { return matchesNaming(boneName, typeRight) || lastLetter(boneName) == "R" || firstLetter(boneName) == "R"; } private static bool isSpine(string boneName) { return matchesNaming(boneName, typeSpine) && !excludesNaming(boneName, typeExcludeSpine); } private static bool isHead(string boneName) { return matchesNaming(boneName, typeHead) && !excludesNaming(boneName, typeExcludeHead); } private static bool isArm(string boneName) { return matchesNaming(boneName, typeArm) && !excludesNaming(boneName, typeExcludeArm); } private static bool isLeg(string boneName) { return matchesNaming(boneName, typeLeg) && !excludesNaming(boneName, typeExcludeLeg); } private static bool isTail(string boneName) { return matchesNaming(boneName, typeTail) && !excludesNaming(boneName, typeExcludeTail); } private static bool isEye(string boneName) { return matchesNaming(boneName, typeEye) && !excludesNaming(boneName, typeExcludeEye); } private static bool isTypeExclude(string boneName) { return matchesNaming(boneName, typeExclude); } private static bool matchesNaming(string boneName, string[] namingConvention) { if (excludesNaming(boneName, typeExclude)) { return false; } foreach (string value in namingConvention) { if (boneName.Contains(value)) { return true; } } return false; } private static bool excludesNaming(string boneName, string[] namingConvention) { foreach (string value in namingConvention) { if (boneName.Contains(value)) { return true; } } return false; } private static bool matchesLastLetter(string boneName, string[] namingConvention) { foreach (string letter in namingConvention) { if (LastLetterIs(boneName, letter)) { return true; } } return false; } private static bool LastLetterIs(string boneName, string letter) { string text = boneName.Substring(boneName.Length - 1, 1); return text == letter; } private static string firstLetter(string boneName) { if (boneName.Length > 0) { return boneName.Substring(0, 1); } return ""; } private static string lastLetter(string boneName) { if (boneName.Length > 0) { return boneName.Substring(boneName.Length - 1, 1); } return ""; } } [Serializable] public class BipedReferences { public struct AutoDetectParams { public bool legsParentInSpine; public bool includeEyes; public static AutoDetectParams Default => new AutoDetectParams(legsParentInSpine: true, includeEyes: true); public AutoDetectParams(bool legsParentInSpine, bool includeEyes) { this.legsParentInSpine = legsParentInSpine; this.includeEyes = includeEyes; } } public Transform root; public Transform pelvis; public Transform leftThigh; public Transform leftCalf; public Transform leftFoot; public Transform rightThigh; public Transform rightCalf; public Transform rightFoot; public Transform leftUpperArm; public Transform leftForearm; public Transform leftHand; public Transform rightUpperArm; public Transform rightForearm; public Transform rightHand; public Transform head; public Transform[] spine = (Transform[])(object)new Transform[0]; public Transform[] eyes = (Transform[])(object)new Transform[0]; public virtual bool isFilled { get { if ((Object)(object)root == (Object)null) { return false; } if ((Object)(object)pelvis == (Object)null) { return false; } if ((Object)(object)leftThigh == (Object)null || (Object)(object)leftCalf == (Object)null || (Object)(object)leftFoot == (Object)null) { return false; } if ((Object)(object)rightThigh == (Object)null || (Object)(object)rightCalf == (Object)null || (Object)(object)rightFoot == (Object)null) { return false; } if ((Object)(object)leftUpperArm == (Object)null || (Object)(object)leftForearm == (Object)null || (Object)(object)leftHand == (Object)null) { return false; } if ((Object)(object)rightUpperArm == (Object)null || (Object)(object)rightForearm == (Object)null || (Object)(object)rightHand == (Object)null) { return false; } Transform[] array = spine; foreach (Transform val in array) { if ((Object)(object)val == (Object)null) { return false; } } Transform[] array2 = eyes; foreach (Transform val2 in array2) { if ((Object)(object)val2 == (Object)null) { return false; } } return true; } } public bool isEmpty => IsEmpty(includeRoot: true); public virtual bool IsEmpty(bool includeRoot) { if (includeRoot && (Object)(object)root != (Object)null) { return false; } if ((Object)(object)pelvis != (Object)null || (Object)(object)head != (Object)null) { return false; } if ((Object)(object)leftThigh != (Object)null || (Object)(object)leftCalf != (Object)null || (Object)(object)leftFoot != (Object)null) { return false; } if ((Object)(object)rightThigh != (Object)null || (Object)(object)rightCalf != (Object)null || (Object)(object)rightFoot != (Object)null) { return false; } if ((Object)(object)leftUpperArm != (Object)null || (Object)(object)leftForearm != (Object)null || (Object)(object)leftHand != (Object)null) { return false; } if ((Object)(object)rightUpperArm != (Object)null || (Object)(object)rightForearm != (Object)null || (Object)(object)rightHand != (Object)null) { return false; } Transform[] array = spine; foreach (Transform val in array) { if ((Object)(object)val != (Object)null) { return false; } } Transform[] array2 = eyes; foreach (Transform val2 in array2) { if ((Object)(object)val2 != (Object)null) { return false; } } return true; } public virtual bool Contains(Transform t, bool ignoreRoot = false) { if (!ignoreRoot && (Object)(object)root == (Object)(object)t) { return true; } if ((Object)(object)pelvis == (Object)(object)t) { return true; } if ((Object)(object)leftThigh == (Object)(object)t) { return true; } if ((Object)(object)leftCalf == (Object)(object)t) { return true; } if ((Object)(object)leftFoot == (Object)(object)t) { return true; } if ((Object)(object)rightThigh == (Object)(object)t) { return true; } if ((Object)(object)rightCalf == (Object)(object)t) { return true; } if ((Object)(object)rightFoot == (Object)(object)t) { return true; } if ((Object)(object)leftUpperArm == (Object)(object)t) { return true; } if ((Object)(object)leftForearm == (Object)(object)t) { return true; } if ((Object)(object)leftHand == (Object)(object)t) { return true; } if ((Object)(object)rightUpperArm == (Object)(object)t) { return true; } if ((Object)(object)rightForearm == (Object)(object)t) { return true; } if ((Object)(object)rightHand == (Object)(object)t) { return true; } if ((Object)(object)head == (Object)(object)t) { return true; } Transform[] array = spine; foreach (Transform val in array) { if ((Object)(object)val == (Object)(object)t) { return true; } } Transform[] array2 = eyes; foreach (Transform val2 in array2) { if ((Object)(object)val2 == (Object)(object)t) { return true; } } return false; } public static bool AutoDetectReferences(ref BipedReferences references, Transform root, AutoDetectParams autoDetectParams) { if (references == null) { references = new BipedReferences(); } references.root = root; Animator component = ((Component)root).GetComponent(); if ((Object)(object)component != (Object)null && component.isHuman) { AssignHumanoidReferences(ref references, component, autoDetectParams); return true; } DetectReferencesByNaming(ref references, root, autoDetectParams); Warning.logged = false; if (!references.isFilled) { Warning.Log("BipedReferences contains one or more missing Transforms.", root, logInEditMode: true); return false; } string errorMessage = ""; if (SetupError(references, ref errorMessage)) { Warning.Log(errorMessage, references.root, logInEditMode: true); return false; } if (SetupWarning(references, ref errorMessage)) { Warning.Log(errorMessage, references.root, logInEditMode: true); } return true; } public static void DetectReferencesByNaming(ref BipedReferences references, Transform root, AutoDetectParams autoDetectParams) { if (references == null) { references = new BipedReferences(); } Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(); DetectLimb(BipedNaming.BoneType.Arm, BipedNaming.BoneSide.Left, ref references.leftUpperArm, ref references.leftForearm, ref references.leftHand, componentsInChildren); DetectLimb(BipedNaming.BoneType.Arm, BipedNaming.BoneSide.Right, ref references.rightUpperArm, ref references.rightForearm, ref references.rightHand, componentsInChildren); DetectLimb(BipedNaming.BoneType.Leg, BipedNaming.BoneSide.Left, ref references.leftThigh, ref references.leftCalf, ref references.leftFoot, componentsInChildren); DetectLimb(BipedNaming.BoneType.Leg, BipedNaming.BoneSide.Right, ref references.rightThigh, ref references.rightCalf, ref references.rightFoot, componentsInChildren); references.head = BipedNaming.GetBone(componentsInChildren, BipedNaming.BoneType.Head, BipedNaming.BoneSide.Center); references.pelvis = BipedNaming.GetNamingMatch(componentsInChildren, BipedNaming.pelvis); if (((Object)(object)references.pelvis == (Object)null || !Hierarchy.IsAncestor(references.leftThigh, references.pelvis)) && (Object)(object)references.leftThigh != (Object)null) { references.pelvis = references.leftThigh.parent; } if ((Object)(object)references.leftUpperArm != (Object)null && (Object)(object)references.rightUpperArm != (Object)null && (Object)(object)references.pelvis != (Object)null && (Object)(object)references.leftThigh != (Object)null) { Transform firstCommonAncestor = Hierarchy.GetFirstCommonAncestor(references.leftUpperArm, references.rightUpperArm); if ((Object)(object)firstCommonAncestor != (Object)null) { Transform[] array = (Transform[])(object)new Transform[1] { firstCommonAncestor }; Hierarchy.AddAncestors(array[0], references.pelvis, ref array); references.spine = (Transform[])(object)new Transform[0]; for (int num = array.Length - 1; num > -1; num--) { if (AddBoneToSpine(array[num], ref references, autoDetectParams)) { Array.Resize(ref references.spine, references.spine.Length + 1); references.spine[references.spine.Length - 1] = array[num]; } } if ((Object)(object)references.head == (Object)null) { for (int i = 0; i < firstCommonAncestor.childCount; i++) { Transform child = firstCommonAncestor.GetChild(i); if (!Hierarchy.ContainsChild(child, references.leftUpperArm) && !Hierarchy.ContainsChild(child, references.rightUpperArm)) { references.head = child; break; } } } } } Transform[] bonesOfType = BipedNaming.GetBonesOfType(BipedNaming.BoneType.Eye, componentsInChildren); references.eyes = (Transform[])(object)new Transform[0]; if (!autoDetectParams.includeEyes) { return; } for (int j = 0; j < bonesOfType.Length; j++) { if (AddBoneToEyes(bonesOfType[j], ref references, autoDetectParams)) { Array.Resize(ref references.eyes, references.eyes.Length + 1); references.eyes[references.eyes.Length - 1] = bonesOfType[j]; } } } public static void AssignHumanoidReferences(ref BipedReferences references, Animator animator, AutoDetectParams autoDetectParams) { if (references == null) { references = new BipedReferences(); } if (!((Object)(object)animator == (Object)null) && animator.isHuman) { references.spine = (Transform[])(object)new Transform[0]; references.eyes = (Transform[])(object)new Transform[0]; references.head = animator.GetBoneTransform((HumanBodyBones)10); references.leftThigh = animator.GetBoneTransform((HumanBodyBones)1); references.leftCalf = animator.GetBoneTransform((HumanBodyBones)3); references.leftFoot = animator.GetBoneTransform((HumanBodyBones)5); references.rightThigh = animator.GetBoneTransform((HumanBodyBones)2); references.rightCalf = animator.GetBoneTransform((HumanBodyBones)4); references.rightFoot = animator.GetBoneTransform((HumanBodyBones)6); references.leftUpperArm = animator.GetBoneTransform((HumanBodyBones)13); references.leftForearm = animator.GetBoneTransform((HumanBodyBones)15); references.leftHand = animator.GetBoneTransform((HumanBodyBones)17); references.rightUpperArm = animator.GetBoneTransform((HumanBodyBones)14); references.rightForearm = animator.GetBoneTransform((HumanBodyBones)16); references.rightHand = animator.GetBoneTransform((HumanBodyBones)18); references.pelvis = animator.GetBoneTransform((HumanBodyBones)0); AddBoneToHierarchy(ref references.spine, animator.GetBoneTransform((HumanBodyBones)7)); AddBoneToHierarchy(ref references.spine, animator.GetBoneTransform((HumanBodyBones)8)); if ((Object)(object)references.leftUpperArm != (Object)null && !IsNeckBone(animator.GetBoneTransform((HumanBodyBones)9), references.leftUpperArm)) { AddBoneToHierarchy(ref references.spine, animator.GetBoneTransform((HumanBodyBones)9)); } if (autoDetectParams.includeEyes) { AddBoneToHierarchy(ref references.eyes, animator.GetBoneTransform((HumanBodyBones)21)); AddBoneToHierarchy(ref references.eyes, animator.GetBoneTransform((HumanBodyBones)22)); } } } public static bool SetupError(BipedReferences references, ref string errorMessage) { if (!references.isFilled) { errorMessage = "BipedReferences contains one or more missing Transforms."; return true; } if (LimbError(references.leftThigh, references.leftCalf, references.leftFoot, ref errorMessage)) { return true; } if (LimbError(references.rightThigh, references.rightCalf, references.rightFoot, ref errorMessage)) { return true; } if (LimbError(references.leftUpperArm, references.leftForearm, references.leftHand, ref errorMessage)) { return true; } if (LimbError(references.rightUpperArm, references.rightForearm, references.rightHand, ref errorMessage)) { return true; } if (SpineError(references, ref errorMessage)) { return true; } if (EyesError(references, ref errorMessage)) { return true; } return false; } public static bool SetupWarning(BipedReferences references, ref string warningMessage) { if (LimbWarning(references.leftThigh, references.leftCalf, references.leftFoot, ref warningMessage)) { return true; } if (LimbWarning(references.rightThigh, references.rightCalf, references.rightFoot, ref warningMessage)) { return true; } if (LimbWarning(references.leftUpperArm, references.leftForearm, references.leftHand, ref warningMessage)) { return true; } if (LimbWarning(references.rightUpperArm, references.rightForearm, references.rightHand, ref warningMessage)) { return true; } if (SpineWarning(references, ref warningMessage)) { return true; } if (EyesWarning(references, ref warningMessage)) { return true; } if (RootHeightWarning(references, ref warningMessage)) { return true; } if (FacingAxisWarning(references, ref warningMessage)) { return true; } return false; } private static bool IsNeckBone(Transform bone, Transform leftUpperArm) { if ((Object)(object)leftUpperArm.parent != (Object)null && (Object)(object)leftUpperArm.parent == (Object)(object)bone) { return false; } if (Hierarchy.IsAncestor(leftUpperArm, bone)) { return false; } return true; } private static bool AddBoneToEyes(Transform bone, ref BipedReferences references, AutoDetectParams autoDetectParams) { if ((Object)(object)references.head != (Object)null && !Hierarchy.IsAncestor(bone, references.head)) { return false; } if ((Object)(object)((Component)bone).GetComponent() != (Object)null) { return false; } return true; } private static bool AddBoneToSpine(Transform bone, ref BipedReferences references, AutoDetectParams autoDetectParams) { if ((Object)(object)bone == (Object)(object)references.root) { return false; } if ((Object)(object)bone == (Object)(object)references.leftThigh.parent && !autoDetectParams.legsParentInSpine) { return false; } if ((Object)(object)references.pelvis != (Object)null) { if ((Object)(object)bone == (Object)(object)references.pelvis) { return false; } if (Hierarchy.IsAncestor(references.pelvis, bone)) { return false; } } return true; } private static void DetectLimb(BipedNaming.BoneType boneType, BipedNaming.BoneSide boneSide, ref Transform firstBone, ref Transform secondBone, ref Transform lastBone, Transform[] transforms) { Transform[] bonesOfTypeAndSide = BipedNaming.GetBonesOfTypeAndSide(boneType, boneSide, transforms); if (bonesOfTypeAndSide.Length >= 3) { if (bonesOfTypeAndSide.Length == 3) { firstBone = bonesOfTypeAndSide[0]; secondBone = bonesOfTypeAndSide[1]; lastBone = bonesOfTypeAndSide[2]; } if (bonesOfTypeAndSide.Length > 3) { firstBone = bonesOfTypeAndSide[0]; secondBone = bonesOfTypeAndSide[2]; lastBone = bonesOfTypeAndSide[^1]; } } } private static void AddBoneToHierarchy(ref Transform[] bones, Transform transform) { if (!((Object)(object)transform == (Object)null)) { Array.Resize(ref bones, bones.Length + 1); bones[bones.Length - 1] = transform; } } private static bool LimbError(Transform bone1, Transform bone2, Transform bone3, ref string errorMessage) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0096: 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_00bb: 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)bone1 == (Object)null) { errorMessage = "Bone 1 of a BipedReferences limb is null."; return true; } if ((Object)(object)bone2 == (Object)null) { errorMessage = "Bone 2 of a BipedReferences limb is null."; return true; } if ((Object)(object)bone3 == (Object)null) { errorMessage = "Bone 3 of a BipedReferences limb is null."; return true; } Transform val = (Transform)Hierarchy.ContainsDuplicate((Object[])(object)new Transform[3] { bone1, bone2, bone3 }); if ((Object)(object)val != (Object)null) { errorMessage = ((Object)val).name + " is represented multiple times in the same BipedReferences limb."; return true; } if (bone2.position == bone1.position) { errorMessage = "Second bone's position equals first bone's position in the biped's limb."; return true; } if (bone3.position == bone2.position) { errorMessage = "Third bone's position equals second bone's position in the biped's limb."; return true; } if (!Hierarchy.HierarchyIsValid((Transform[])(object)new Transform[3] { bone1, bone2, bone3 })) { errorMessage = "BipedReferences limb hierarchy is invalid. Bone transforms in a limb do not belong to the same ancestry. Please make sure the bones are parented to each other. Bones: " + ((Object)bone1).name + ", " + ((Object)bone2).name + ", " + ((Object)bone3).name; return true; } return false; } private static bool LimbWarning(Transform bone1, Transform bone2, Transform bone3, ref string warningMessage) { //IL_0002: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(bone2.position - bone1.position, bone3.position - bone1.position); if (val == Vector3.zero) { warningMessage = "BipedReferences limb is completely stretched out in the initial pose. IK solver can not calculate the default bend plane for the limb. Please make sure you character's limbs are at least slightly bent in the initial pose. First bone: " + ((Object)bone1).name + ", second bone: " + ((Object)bone2).name + "."; return true; } return false; } private static bool SpineError(BipedReferences references, ref string errorMessage) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_010a: 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 (references.spine.Length == 0) { return false; } for (int i = 0; i < references.spine.Length; i++) { if ((Object)(object)references.spine[i] == (Object)null) { errorMessage = "BipedReferences spine bone at index " + i + " is null."; return true; } } Transform val = (Transform)Hierarchy.ContainsDuplicate((Object[])(object)references.spine); if ((Object)(object)val != (Object)null) { errorMessage = ((Object)val).name + " is represented multiple times in BipedReferences spine."; return true; } if (!Hierarchy.HierarchyIsValid(references.spine)) { errorMessage = "BipedReferences spine hierarchy is invalid. Bone transforms in the spine do not belong to the same ancestry. Please make sure the bones are parented to each other."; return true; } for (int j = 0; j < references.spine.Length; j++) { bool flag = false; if (j == 0 && references.spine[j].position == references.pelvis.position) { flag = true; } if (j != 0 && references.spine.Length > 1 && references.spine[j].position == references.spine[j - 1].position) { flag = true; } if (flag) { errorMessage = "Biped's spine bone nr " + j + " position is the same as it's parent spine/pelvis bone's position. Please remove this bone from the spine."; return true; } } return false; } private static bool SpineWarning(BipedReferences references, ref string warningMessage) { return false; } private static bool EyesError(BipedReferences references, ref string errorMessage) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown if (references.eyes.Length == 0) { return false; } for (int i = 0; i < references.eyes.Length; i++) { if ((Object)(object)references.eyes[i] == (Object)null) { errorMessage = "BipedReferences eye bone at index " + i + " is null."; return true; } } Transform val = (Transform)Hierarchy.ContainsDuplicate((Object[])(object)references.eyes); if ((Object)(object)val != (Object)null) { errorMessage = ((Object)val).name + " is represented multiple times in BipedReferences eyes."; return true; } return false; } private static bool EyesWarning(BipedReferences references, ref string warningMessage) { return false; } private static bool RootHeightWarning(BipedReferences references, ref string warningMessage) { //IL_001f: 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_0035: 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_0051: 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 ((Object)(object)references.head == (Object)null) { return false; } float verticalOffset = GetVerticalOffset(references.head.position, references.leftFoot.position, references.root.rotation); float verticalOffset2 = GetVerticalOffset(references.root.position, references.leftFoot.position, references.root.rotation); if (verticalOffset2 / verticalOffset > 0.2f) { warningMessage = "Biped's root Transform's position should be at ground level relative to the character (at the character's feet not at it's pelvis)."; return true; } return false; } private static bool FacingAxisWarning(BipedReferences references, ref string warningMessage) { //IL_0007: 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_001c: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_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_0053: 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) Vector3 val = references.rightHand.position - references.leftHand.position; Vector3 val2 = references.rightFoot.position - references.leftFoot.position; float num = Vector3.Dot(((Vector3)(ref val)).normalized, references.root.right); float num2 = Vector3.Dot(((Vector3)(ref val2)).normalized, references.root.right); if (num < 0f || num2 < 0f) { warningMessage = "Biped does not seem to be facing it's forward axis. Please make sure that in the initial pose the character is facing towards the positive Z axis of the Biped root gameobject."; return true; } return false; } private static float GetVerticalOffset(Vector3 p1, Vector3 p2, Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_0013: Unknown result type (might be due to invalid IL or missing references) return (Quaternion.Inverse(rotation) * (p1 - p2)).y; } } public class Comments : MonoBehaviour { [Multiline] public string text; } public class DemoGUIMessage : MonoBehaviour { public string text; public Color color = Color.white; private void OnGUI() { //IL_0002: 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) GUI.color = color; GUILayout.Label(text, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUI.color = Color.white; } } public class Hierarchy { public static bool HierarchyIsValid(Transform[] bones) { for (int i = 1; i < bones.Length; i++) { if (!IsAncestor(bones[i], bones[i - 1])) { return false; } } return true; } public static Object ContainsDuplicate(Object[] objects) { for (int i = 0; i < objects.Length; i++) { for (int j = 0; j < objects.Length; j++) { if (i != j && objects[i] == objects[j]) { return objects[i]; } } } return null; } public static bool IsAncestor(Transform transform, Transform ancestor) { if ((Object)(object)transform == (Object)null) { return true; } if ((Object)(object)ancestor == (Object)null) { return true; } if ((Object)(object)transform.parent == (Object)null) { return false; } if ((Object)(object)transform.parent == (Object)(object)ancestor) { return true; } return IsAncestor(transform.parent, ancestor); } public static bool ContainsChild(Transform transform, Transform child) { if ((Object)(object)transform == (Object)(object)child) { return true; } Transform[] componentsInChildren = ((Component)transform).GetComponentsInChildren(); Transform[] array = componentsInChildren; foreach (Transform val in array) { if ((Object)(object)val == (Object)(object)child) { return true; } } return false; } public static void AddAncestors(Transform transform, Transform blocker, ref Transform[] array) { //IL_002a: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)transform.parent != (Object)null && (Object)(object)transform.parent != (Object)(object)blocker) { if (transform.parent.position != transform.position && transform.parent.position != blocker.position) { Array.Resize(ref array, array.Length + 1); array[array.Length - 1] = transform.parent; } AddAncestors(transform.parent, blocker, ref array); } } public static Transform GetAncestor(Transform transform, int minChildCount) { if ((Object)(object)transform == (Object)null) { return null; } if ((Object)(object)transform.parent != (Object)null) { if (transform.parent.childCount >= minChildCount) { return transform.parent; } return GetAncestor(transform.parent, minChildCount); } return null; } public static Transform GetFirstCommonAncestor(Transform t1, Transform t2) { if ((Object)(object)t1 == (Object)null) { return null; } if ((Object)(object)t2 == (Object)null) { return null; } if ((Object)(object)t1.parent == (Object)null) { return null; } if ((Object)(object)t2.parent == (Object)null) { return null; } if (IsAncestor(t2, t1.parent)) { return t1.parent; } return GetFirstCommonAncestor(t1.parent, t2); } public static Transform GetFirstCommonAncestor(Transform[] transforms) { if (transforms == null) { Debug.LogWarning((object)"Transforms is null."); return null; } if (transforms.Length == 0) { Debug.LogWarning((object)"Transforms.Length is 0."); return null; } for (int i = 0; i < transforms.Length; i++) { if ((Object)(object)transforms[i] == (Object)null) { return null; } if (IsCommonAncestor(transforms[i], transforms)) { return transforms[i]; } } return GetFirstCommonAncestorRecursive(transforms[0], transforms); } public static Transform GetFirstCommonAncestorRecursive(Transform transform, Transform[] transforms) { if ((Object)(object)transform == (Object)null) { Debug.LogWarning((object)"Transform is null."); return null; } if (transforms == null) { Debug.LogWarning((object)"Transforms is null."); return null; } if (transforms.Length == 0) { Debug.LogWarning((object)"Transforms.Length is 0."); return null; } if (IsCommonAncestor(transform, transforms)) { return transform; } if ((Object)(object)transform.parent == (Object)null) { return null; } return GetFirstCommonAncestorRecursive(transform.parent, transforms); } public static bool IsCommonAncestor(Transform transform, Transform[] transforms) { if ((Object)(object)transform == (Object)null) { Debug.LogWarning((object)"Transform is null."); return false; } for (int i = 0; i < transforms.Length; i++) { if ((Object)(object)transforms[i] == (Object)null) { Debug.Log((object)("Transforms[" + i + "] is null.")); return false; } if (!IsAncestor(transforms[i], transform) && (Object)(object)transforms[i] != (Object)(object)transform) { return false; } } return true; } } public class InspectorComment : PropertyAttribute { public string name; public string color = "white"; public InspectorComment(string name) { this.name = name; color = "white"; } public InspectorComment(string name, string color) { this.name = name; this.color = color; } } [Serializable] public enum InterpolationMode { None, InOutCubic, InOutQuintic, InOutSine, InQuintic, InQuartic, InCubic, InQuadratic, InElastic, InElasticSmall, InElasticBig, InSine, InBack, OutQuintic, OutQuartic, OutCubic, OutInCubic, OutInQuartic, OutElastic, OutElasticSmall, OutElasticBig, OutSine, OutBack, OutBackCubic, OutBackQuartic, BackInCubic, BackInQuartic } public class Interp { public static float Float(float t, InterpolationMode mode) { float num = 0f; return mode switch { InterpolationMode.None => None(t, 0f, 1f), InterpolationMode.InOutCubic => InOutCubic(t, 0f, 1f), InterpolationMode.InOutQuintic => InOutQuintic(t, 0f, 1f), InterpolationMode.InQuintic => InQuintic(t, 0f, 1f), InterpolationMode.InQuartic => InQuartic(t, 0f, 1f), InterpolationMode.InCubic => InCubic(t, 0f, 1f), InterpolationMode.InQuadratic => InQuadratic(t, 0f, 1f), InterpolationMode.OutQuintic => OutQuintic(t, 0f, 1f), InterpolationMode.OutQuartic => OutQuartic(t, 0f, 1f), InterpolationMode.OutCubic => OutCubic(t, 0f, 1f), InterpolationMode.OutInCubic => OutInCubic(t, 0f, 1f), InterpolationMode.OutInQuartic => OutInCubic(t, 0f, 1f), InterpolationMode.BackInCubic => BackInCubic(t, 0f, 1f), InterpolationMode.BackInQuartic => BackInQuartic(t, 0f, 1f), InterpolationMode.OutBackCubic => OutBackCubic(t, 0f, 1f), InterpolationMode.OutBackQuartic => OutBackQuartic(t, 0f, 1f), InterpolationMode.OutElasticSmall => OutElasticSmall(t, 0f, 1f), InterpolationMode.OutElasticBig => OutElasticBig(t, 0f, 1f), InterpolationMode.InElasticSmall => InElasticSmall(t, 0f, 1f), InterpolationMode.InElasticBig => InElasticBig(t, 0f, 1f), InterpolationMode.InSine => InSine(t, 0f, 1f), InterpolationMode.OutSine => OutSine(t, 0f, 1f), InterpolationMode.InOutSine => InOutSine(t, 0f, 1f), InterpolationMode.InElastic => OutElastic(t, 0f, 1f), InterpolationMode.OutElastic => OutElastic(t, 0f, 1f), InterpolationMode.InBack => InBack(t, 0f, 1f), InterpolationMode.OutBack => OutBack(t, 0f, 1f), _ => 0f, }; } public static Vector3 V3(Vector3 v1, Vector3 v2, float t, InterpolationMode mode) { //IL_0010: 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_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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) float num = Float(t, mode); return (1f - num) * v1 + num * v2; } public static float LerpValue(float value, float target, float increaseSpeed, float decreaseSpeed) { if (value == target) { return target; } if (value < target) { return Mathf.Clamp(value + Time.deltaTime * increaseSpeed, float.NegativeInfinity, target); } return Mathf.Clamp(value - Time.deltaTime * decreaseSpeed, target, float.PositiveInfinity); } private static float None(float t, float b, float c) { return b + c * t; } private static float InOutCubic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (-2f * num2 + 3f * num); } private static float InOutQuintic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (6f * num2 * num + -15f * num * num + 10f * num2); } private static float InQuintic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (num2 * num); } private static float InQuartic(float t, float b, float c) { float num = t * t; return b + c * (num * num); } private static float InCubic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * num2; } private static float InQuadratic(float t, float b, float c) { float num = t * t; return b + c * num; } private static float OutQuintic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (num2 * num + -5f * num * num + 10f * num2 + -10f * num + 5f * t); } private static float OutQuartic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (-1f * num * num + 4f * num2 + -6f * num + 4f * t); } private static float OutCubic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (num2 + -3f * num + 3f * t); } private static float OutInCubic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (4f * num2 + -6f * num + 3f * t); } private static float OutInQuartic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (6f * num2 + -9f * num + 4f * t); } private static float BackInCubic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (4f * num2 + -3f * num); } private static float BackInQuartic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (2f * num * num + 2f * num2 + -3f * num); } private static float OutBackCubic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (4f * num2 + -9f * num + 6f * t); } private static float OutBackQuartic(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (-2f * num * num + 10f * num2 + -15f * num + 8f * t); } private static float OutElasticSmall(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (33f * num2 * num + -106f * num * num + 126f * num2 + -67f * num + 15f * t); } private static float OutElasticBig(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (56f * num2 * num + -175f * num * num + 200f * num2 + -100f * num + 20f * t); } private static float InElasticSmall(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (33f * num2 * num + -59f * num * num + 32f * num2 + -5f * num); } private static float InElasticBig(float t, float b, float c) { float num = t * t; float num2 = num * t; return b + c * (56f * num2 * num + -105f * num * num + 60f * num2 + -10f * num); } private static float InSine(float t, float b, float c) { c -= b; return (0f - c) * Mathf.Cos(t / 1f * ((float)Math.PI / 2f)) + c + b; } private static float OutSine(float t, float b, float c) { c -= b; return c * Mathf.Sin(t / 1f * ((float)Math.PI / 2f)) + b; } private static float InOutSine(float t, float b, float c) { c -= b; return (0f - c) / 2f * (Mathf.Cos((float)Math.PI * t / 1f) - 1f) + b; } private static float InElastic(float t, float b, float c) { c -= b; float num = 1f; float num2 = num * 0.3f; float num3 = 0f; float num4 = 0f; if (t == 0f) { return b; } if ((t /= num) == 1f) { return b + c; } if (num4 == 0f || num4 < Mathf.Abs(c)) { num4 = c; num3 = num2 / 4f; } else { num3 = num2 / ((float)Math.PI * 2f) * Mathf.Asin(c / num4); } return 0f - num4 * Mathf.Pow(2f, 10f * (t -= 1f)) * Mathf.Sin((t * num - num3) * ((float)Math.PI * 2f) / num2) + b; } private static float OutElastic(float t, float b, float c) { c -= b; float num = 1f; float num2 = num * 0.3f; float num3 = 0f; float num4 = 0f; if (t == 0f) { return b; } if ((t /= num) == 1f) { return b + c; } if (num4 == 0f || num4 < Mathf.Abs(c)) { num4 = c; num3 = num2 / 4f; } else { num3 = num2 / ((float)Math.PI * 2f) * Mathf.Asin(c / num4); } return num4 * Mathf.Pow(2f, -10f * t) * Mathf.Sin((t * num - num3) * ((float)Math.PI * 2f) / num2) + c + b; } private static float InBack(float t, float b, float c) { c -= b; t /= 1f; float num = 1.70158f; return c * t * t * ((num + 1f) * t - num) + b; } private static float OutBack(float t, float b, float c) { float num = 1.70158f; c -= b; t = t / 1f - 1f; return c * (t * t * ((num + 1f) * t + num) + 1f) + b; } } public class LargeHeader : PropertyAttribute { public string name; public string color = "white"; public LargeHeader(string name) { this.name = name; color = "white"; } public LargeHeader(string name, string color) { this.name = name; this.color = color; } } public static class LayerMaskExtensions { public static bool Contains(LayerMask mask, int layer) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return LayerMask.op_Implicit(mask) == (LayerMask.op_Implicit(mask) | (1 << layer)); } public static LayerMask Create(params string[] layerNames) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return NamesToMask(layerNames); } public static LayerMask Create(params int[] layerNumbers) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return LayerNumbersToMask(layerNumbers); } public static LayerMask NamesToMask(params string[] layerNames) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_003d: 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_0045: Unknown result type (might be due to invalid IL or missing references) LayerMask val = LayerMask.op_Implicit(0); foreach (string text in layerNames) { val = LayerMask.op_Implicit(LayerMask.op_Implicit(val) | (1 << LayerMask.NameToLayer(text))); } return val; } public static LayerMask LayerNumbersToMask(params int[] layerNumbers) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0029: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) LayerMask val = LayerMask.op_Implicit(0); foreach (int num in layerNumbers) { val = LayerMask.op_Implicit(LayerMask.op_Implicit(val) | (1 << num)); } return val; } public static LayerMask Inverse(this LayerMask original) { //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_0013: Unknown result type (might be due to invalid IL or missing references) return LayerMask.op_Implicit(~LayerMask.op_Implicit(original)); } public static LayerMask AddToMask(this LayerMask original, params string[] layerNames) { //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_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) return LayerMask.op_Implicit(LayerMask.op_Implicit(original) | LayerMask.op_Implicit(NamesToMask(layerNames))); } public static LayerMask RemoveFromMask(this LayerMask original, params string[] layerNames) { //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_000e: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) LayerMask val = LayerMask.op_Implicit(~LayerMask.op_Implicit(original)); return LayerMask.op_Implicit(~(LayerMask.op_Implicit(val) | LayerMask.op_Implicit(NamesToMask(layerNames)))); } public static string[] MaskToNames(this LayerMask original) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (int i = 0; i < 32; i++) { int num = 1 << i; if ((LayerMask.op_Implicit(original) & num) == num) { string text = LayerMask.LayerToName(i); if (!string.IsNullOrEmpty(text)) { list.Add(text); } } } return list.ToArray(); } public static int[] MaskToNumbers(this LayerMask original) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) List list = new List(); for (int i = 0; i < 32; i++) { int num = 1 << i; if ((LayerMask.op_Implicit(original) & num) == num) { list.Add(i); } } return list.ToArray(); } public static string MaskToString(this LayerMask original) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return original.MaskToString(", "); } public static string MaskToString(this LayerMask original, string delimiter) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return string.Join(delimiter, original.MaskToNames()); } } } namespace RootMotion.Demos { [Serializable] public class Navigator { public enum State { Idle, Seeking, OnPath } [Tooltip("Should this Navigator be actively seeking a path.")] public bool activeTargetSeeking; [Tooltip("Increase this value if the character starts running in a circle, not able to reach the corner because of a too large turning radius.")] public float cornerRadius = 0.5f; [Tooltip("Recalculate path if target position has moved by this distance from the position it was at when the path was originally calculated")] public float recalculateOnPathDistance = 1f; [Tooltip("Sample within this distance from sourcePosition.")] public float maxSampleDistance = 5f; [Tooltip("Interval of updating the path")] public float nextPathInterval = 3f; private Transform transform; private int cornerIndex; private Vector3[] corners = (Vector3[])(object)new Vector3[0]; private NavMeshPath path; private Vector3 lastTargetPosition; private bool initiated; private float nextPathTime; public Vector3 normalizedDeltaPosition { get; private set; } public State state { get; private set; } public void Initiate(Transform transform) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //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) this.transform = transform; path = new NavMeshPath(); initiated = true; cornerIndex = 0; corners = (Vector3[])(object)new Vector3[0]; state = State.Idle; lastTargetPosition = new Vector3(float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity); } public void Update(Vector3 targetPosition) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Invalid comparison between Unknown and I4 //IL_0154: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_0124: 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) if (!initiated) { Debug.LogError((object)"Trying to update an uninitiated Navigator."); return; } switch (state) { case State.Seeking: normalizedDeltaPosition = Vector3.zero; if ((int)path.status == 0) { corners = path.corners; cornerIndex = 0; if (corners.Length == 0) { Debug.LogWarning((object)"Zero Corner Path", (Object)(object)transform); Stop(); } else { state = State.OnPath; } } if ((int)path.status == 1) { Debug.LogWarning((object)"Path Partial", (Object)(object)transform); } if ((int)path.status == 2) { Debug.LogWarning((object)"Path Invalid", (Object)(object)transform); } break; case State.OnPath: if (activeTargetSeeking && Time.time > nextPathTime && HorDistance(targetPosition, lastTargetPosition) > recalculateOnPathDistance) { CalculatePath(targetPosition); } else { if (cornerIndex >= corners.Length) { break; } Vector3 val = corners[cornerIndex] - transform.position; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude > 0f) { normalizedDeltaPosition = val / ((Vector3)(ref val)).magnitude; } else { normalizedDeltaPosition = Vector3.zero; } if (magnitude < cornerRadius) { cornerIndex++; if (cornerIndex >= corners.Length) { Stop(); } } } break; case State.Idle: if (activeTargetSeeking && Time.time > nextPathTime) { CalculatePath(targetPosition); } break; } } private void CalculatePath(Vector3 targetPosition) { //IL_0002: 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) if (Find(targetPosition)) { lastTargetPosition = targetPosition; state = State.Seeking; } else { Stop(); } nextPathTime = Time.time + nextPathInterval; } private bool Find(Vector3 targetPosition) { //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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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) if (HorDistance(transform.position, targetPosition) < cornerRadius * 2f) { return false; } if (NavMesh.CalculatePath(transform.position, targetPosition, -1, path)) { return true; } NavMeshHit val = default(NavMeshHit); if (NavMesh.SamplePosition(targetPosition, ref val, maxSampleDistance, -1) && NavMesh.CalculatePath(transform.position, ((NavMeshHit)(ref val)).position, -1, path)) { return true; } return false; } private void Stop() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) state = State.Idle; normalizedDeltaPosition = Vector3.zero; } private float HorDistance(Vector3 p1, Vector3 p2) { //IL_000f: 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) return Vector2.Distance(new Vector2(p1.x, p1.z), new Vector2(p2.x, p2.z)); } public void Visualize() { //IL_000c: 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_0038: 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_006e: 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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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) if (state == State.Idle) { Gizmos.color = Color.gray; } if (state == State.Seeking) { Gizmos.color = Color.red; } if (state == State.OnPath) { Gizmos.color = Color.green; } if (corners.Length > 0 && state == State.OnPath && cornerIndex == 0) { Gizmos.DrawLine(transform.position, corners[0]); } for (int i = 0; i < corners.Length; i++) { Gizmos.DrawSphere(corners[i], 0.1f); } if (corners.Length > 1) { for (int j = 0; j < corners.Length - 1; j++) { Gizmos.DrawLine(corners[j], corners[j + 1]); } } Gizmos.color = Color.white; } } } namespace RootMotion1 { public static class QuaTools { public static float GetYaw(Quaternion space, Vector3 forward) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Quaternion.Inverse(space) * forward; return Mathf.Atan2(val.x, val.z) * 57.29578f; } public static float GetPitch(Quaternion space, Vector3 forward) { //IL_0003: 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_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) forward = ((Vector3)(ref forward)).normalized; return (0f - Mathf.Asin((Quaternion.Inverse(space) * forward).y)) * 57.29578f; } public static float GetBank(Quaternion space, Vector3 forward, Vector3 up) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_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_0026: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_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) Vector3 val = space * Vector3.up; Quaternion val2 = Quaternion.Inverse(space); forward = val2 * forward; up = val2 * up; Quaternion val3 = Quaternion.Inverse(Quaternion.LookRotation(val, forward)); up = val3 * up; return Mathf.Atan2(up.x, up.z) * 57.29578f; } public static float GetYaw(Quaternion space, Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val = Quaternion.Inverse(space) * (rotation * Vector3.forward); return Mathf.Atan2(val.x, val.z) * 57.29578f; } public static float GetPitch(Quaternion space, Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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) return (0f - Mathf.Asin((Quaternion.Inverse(space) * (rotation * Vector3.forward)).y)) * 57.29578f; } public static float GetBank(Quaternion space, Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = space * Vector3.up; Quaternion val2 = Quaternion.Inverse(space); Vector3 val3 = val2 * (rotation * Vector3.forward); Vector3 val4 = val2 * (rotation * Vector3.up); Quaternion val5 = Quaternion.Inverse(Quaternion.LookRotation(val, val3)); val4 = val5 * val4; return Mathf.Atan2(val4.x, val4.z) * 57.29578f; } public static Quaternion Lerp(Quaternion fromRotation, Quaternion toRotation, float weight) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return fromRotation; } if (weight >= 1f) { return toRotation; } return Quaternion.Lerp(fromRotation, toRotation, weight); } public static Quaternion Slerp(Quaternion fromRotation, Quaternion toRotation, float weight) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return fromRotation; } if (weight >= 1f) { return toRotation; } return Quaternion.Slerp(fromRotation, toRotation, weight); } public static Quaternion LinearBlend(Quaternion q, float weight) { //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_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_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_0022: 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_003b: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return Quaternion.identity; } if (weight >= 1f) { return q; } return Quaternion.Lerp(Quaternion.identity, q, weight); } public static Quaternion SphericalBlend(Quaternion q, float weight) { //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_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_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_0022: 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_003b: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return Quaternion.identity; } if (weight >= 1f) { return q; } return Quaternion.Slerp(Quaternion.identity, q, weight); } public static Quaternion FromToAroundAxis(Vector3 fromDirection, Vector3 toDirection, Vector3 axis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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) Quaternion val = Quaternion.FromToRotation(fromDirection, toDirection); float num = 0f; Vector3 zero = Vector3.zero; ((Quaternion)(ref val)).ToAngleAxis(ref num, ref zero); float num2 = Vector3.Dot(zero, axis); if (num2 < 0f) { num = 0f - num; } return Quaternion.AngleAxis(num, axis); } public static Quaternion RotationToLocalSpace(Quaternion space, Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_0018: Unknown result type (might be due to invalid IL or missing references) return Quaternion.Inverse(Quaternion.Inverse(space) * rotation); } public static Quaternion FromToRotation(Quaternion from, Quaternion to) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_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_002a: Unknown result type (might be due to invalid IL or missing references) if (to == from) { return Quaternion.identity; } return to * Quaternion.Inverse(from); } public static Vector3 GetAxis(Vector3 v) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_0099: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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) Vector3 val = Vector3.right; bool flag = false; float num = Vector3.Dot(v, Vector3.right); float num2 = Mathf.Abs(num); if (num < 0f) { flag = true; } float num3 = Vector3.Dot(v, Vector3.up); float num4 = Mathf.Abs(num3); if (num4 > num2) { num2 = num4; val = Vector3.up; flag = num3 < 0f; } float num5 = Vector3.Dot(v, Vector3.forward); num4 = Mathf.Abs(num5); if (num4 > num2) { val = Vector3.forward; flag = num5 < 0f; } if (flag) { val = -val; } return val; } public static Quaternion ClampRotation(Quaternion rotation, float clampWeight, int clampSmoothing) { //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_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_0022: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (clampWeight >= 1f) { return Quaternion.identity; } if (clampWeight <= 0f) { return rotation; } float num = Quaternion.Angle(Quaternion.identity, rotation); float num2 = 1f - num / 180f; float num3 = Mathf.Clamp(1f - (clampWeight - num2) / (1f - num2), 0f, 1f); float num4 = Mathf.Clamp(num2 / clampWeight, 0f, 1f); for (int i = 0; i < clampSmoothing; i++) { float num5 = num4 * (float)Math.PI * 0.5f; num4 = Mathf.Sin(num5); } return Quaternion.Slerp(Quaternion.identity, rotation, num4 * num3); } public static float ClampAngle(float angle, float clampWeight, int clampSmoothing) { if (clampWeight >= 1f) { return 0f; } if (clampWeight <= 0f) { return angle; } float num = 1f - Mathf.Abs(angle) / 180f; float num2 = Mathf.Clamp(1f - (clampWeight - num) / (1f - num), 0f, 1f); float num3 = Mathf.Clamp(num / clampWeight, 0f, 1f); for (int i = 0; i < clampSmoothing; i++) { float num4 = num3 * (float)Math.PI * 0.5f; num3 = Mathf.Sin(num4); } return Mathf.Lerp(0f, angle, num3 * num2); } public static Quaternion MatchRotation(Quaternion targetRotation, Vector3 targetforwardAxis, Vector3 targetUpAxis, Vector3 forwardAxis, Vector3 upAxis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: 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_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) //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) Quaternion val = Quaternion.LookRotation(forwardAxis, upAxis); Quaternion val2 = Quaternion.LookRotation(targetforwardAxis, targetUpAxis); Quaternion val3 = targetRotation * val2; return val3 * Quaternion.Inverse(val); } public static Vector3 ToBiPolar(Vector3 euler) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) return new Vector3(ToBiPolar(euler.x), ToBiPolar(euler.y), ToBiPolar(euler.z)); } public static float ToBiPolar(float angle) { angle %= 360f; if (angle >= 180f) { return angle - 360f; } if (angle <= -180f) { return angle + 360f; } return angle; } } public abstract class Singleton : MonoBehaviour where T : Singleton { private static T sInstance = (T)null; public static T instance => sInstance; protected virtual void Awake() { if ((Object)(object)sInstance != (Object)null) { Debug.LogError((object)(((Object)this).name + "error: already initialized"), (Object)(object)this); } sInstance = (T)this; } } public class SolverManager : MonoBehaviour { [Tooltip("If true, will fix all the Transforms used by the solver to their initial state in each Update. This prevents potential problems with unanimated bones and animator culling with a small cost of performance. Not recommended for CCD and FABRIK solvers.")] public bool fixTransforms = true; private Animator animator; private Animation legacy; private bool updateFrame; private bool componentInitiated; private bool skipSolverUpdate; private bool animatePhysics { get { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 if ((Object)(object)animator != (Object)null) { return (int)animator.updateMode == 1; } if ((Object)(object)legacy != (Object)null) { return legacy.animatePhysics; } return false; } } private bool isAnimated => (Object)(object)animator != (Object)null || (Object)(object)legacy != (Object)null; public void Disable() { Debug.Log((object)"IK.Disable() is deprecated. Use enabled = false instead", (Object)(object)((Component)this).transform); ((Behaviour)this).enabled = false; } protected virtual void InitiateSolver() { } protected virtual void UpdateSolver() { } protected virtual void FixTransforms() { } private void OnDisable() { if (Application.isPlaying) { Initiate(); } } private void Start() { Initiate(); } private void Initiate() { if (!componentInitiated) { FindAnimatorRecursive(((Component)this).transform, findInChildren: true); InitiateSolver(); componentInitiated = true; } } private void Update() { if (!skipSolverUpdate && !animatePhysics && fixTransforms) { FixTransforms(); } } private void FindAnimatorRecursive(Transform t, bool findInChildren) { if (isAnimated) { return; } animator = ((Component)t).GetComponent(); legacy = ((Component)t).GetComponent(); if (!isAnimated) { if ((Object)(object)animator == (Object)null && findInChildren) { animator = ((Component)t).GetComponentInChildren(); } if ((Object)(object)legacy == (Object)null && findInChildren) { legacy = ((Component)t).GetComponentInChildren(); } if (!isAnimated && (Object)(object)t.parent != (Object)null) { FindAnimatorRecursive(t.parent, findInChildren: false); } } } private void FixedUpdate() { if (skipSolverUpdate) { skipSolverUpdate = false; } updateFrame = true; if (animatePhysics && fixTransforms) { FixTransforms(); } } private void LateUpdate() { if (!skipSolverUpdate) { if (!animatePhysics) { updateFrame = true; } if (updateFrame) { updateFrame = false; UpdateSolver(); } } } public void UpdateSolverExternal() { if (((Behaviour)this).enabled) { skipSolverUpdate = true; UpdateSolver(); } } } public class TriggerEventBroadcaster : MonoBehaviour { public GameObject target; private void OnTriggerEnter(Collider collider) { if ((Object)(object)target != (Object)null) { target.SendMessage("OnTriggerEnter", (object)collider, (SendMessageOptions)1); } } private void OnTriggerStay(Collider collider) { if ((Object)(object)target != (Object)null) { target.SendMessage("OnTriggerStay", (object)collider, (SendMessageOptions)1); } } private void OnTriggerExit(Collider collider) { if ((Object)(object)target != (Object)null) { target.SendMessage("OnTriggerExit", (object)collider, (SendMessageOptions)1); } } } public static class V2Tools { public static Vector2 XZ(Vector3 v) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) return new Vector2(v.x, v.z); } public static float DeltaAngle(Vector2 dir1, Vector2 dir2) { float num = Mathf.Atan2(dir1.x, dir1.y) * 57.29578f; float num2 = Mathf.Atan2(dir2.x, dir2.y) * 57.29578f; return Mathf.DeltaAngle(num, num2); } public static float DeltaAngleXZ(Vector3 dir1, Vector3 dir2) { float num = Mathf.Atan2(dir1.x, dir1.z) * 57.29578f; float num2 = Mathf.Atan2(dir2.x, dir2.z) * 57.29578f; return Mathf.DeltaAngle(num, num2); } public static bool LineCircleIntersect(Vector2 p1, Vector2 p2, Vector2 c, float r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0027: 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) Vector2 val = p2 - p1; Vector2 val2 = c - p1; float num = Vector2.Dot(val, val); float num2 = 2f * Vector2.Dot(val2, val); float num3 = Vector2.Dot(val2, val2) - r * r; float num4 = num2 * num2 - 4f * num * num3; if (num4 < 0f) { return false; } num4 = Mathf.Sqrt(num4); float num5 = 2f * num; float num6 = (num2 - num4) / num5; float num7 = (num2 + num4) / num5; if (num6 >= 0f && num6 <= 1f) { return true; } if (num7 >= 0f && num7 <= 1f) { return true; } return false; } public static bool RayCircleIntersect(Vector2 p1, Vector2 dir, Vector2 c, float r) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0019: Unknown result type (might be due to invalid IL or missing references) Vector2 val = p1 + dir; p1 -= c; val -= c; float num = val.x - p1.x; float num2 = val.y - p1.y; float num3 = Mathf.Sqrt(Mathf.Pow(num, 2f) + Mathf.Pow(num2, 2f)); float num4 = p1.x * val.y - val.x * p1.y; float num5 = Mathf.Pow(r, 2f) * Mathf.Pow(num3, 2f) - Mathf.Pow(num4, 2f); return num5 >= 0f; } } public static class V3Tools { public static float GetYaw(Vector3 forward) { return Mathf.Atan2(forward.x, forward.z) * 57.29578f; } public static float GetPitch(Vector3 forward) { //IL_0003: 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) forward = ((Vector3)(ref forward)).normalized; return (0f - Mathf.Asin(forward.y)) * 57.29578f; } public static float GetBank(Vector3 forward, Vector3 up) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_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_0019: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.Inverse(Quaternion.LookRotation(Vector3.up, forward)); up = val * up; return Mathf.Atan2(up.x, up.z) * 57.29578f; } public static float GetYaw(Vector3 spaceForward, Vector3 spaceUp, Vector3 forward) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_000e: 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_0015: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.Inverse(Quaternion.LookRotation(spaceForward, spaceUp)); Vector3 val2 = val * forward; return Mathf.Atan2(val2.x, val2.z) * 57.29578f; } public static float GetPitch(Vector3 spaceForward, Vector3 spaceUp, Vector3 forward) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_000e: 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_0015: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.Inverse(Quaternion.LookRotation(spaceForward, spaceUp)); return (0f - Mathf.Asin((val * forward).y)) * 57.29578f; } public static float GetBank(Vector3 spaceForward, Vector3 spaceUp, Vector3 forward, Vector3 up) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_000e: 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_0015: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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_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) Quaternion val = Quaternion.Inverse(Quaternion.LookRotation(spaceForward, spaceUp)); forward = val * forward; up = val * up; Quaternion val2 = Quaternion.Inverse(Quaternion.LookRotation(spaceUp, forward)); up = val2 * up; return Mathf.Atan2(up.x, up.z) * 57.29578f; } public static Vector3 Lerp(Vector3 fromVector, Vector3 toVector, float weight) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return fromVector; } if (weight >= 1f) { return toVector; } return Vector3.Lerp(fromVector, toVector, weight); } public static Vector3 Slerp(Vector3 fromVector, Vector3 toVector, float weight) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0033: Unknown result type (might be due to invalid IL or missing references) if (weight <= 0f) { return fromVector; } if (weight >= 1f) { return toVector; } return Vector3.Slerp(fromVector, toVector, weight); } public static Vector3 ExtractVertical(Vector3 v, Vector3 verticalAxis, float weight) { //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_0019: 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_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_002a: Unknown result type (might be due to invalid IL or missing references) if (weight == 0f) { return Vector3.zero; } return Vector3.Project(v, verticalAxis) * weight; } public static Vector3 ExtractHorizontal(Vector3 v, Vector3 normal, float weight) { //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_0022: 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_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_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_0035: Unknown result type (might be due to invalid IL or missing references) if (weight == 0f) { return Vector3.zero; } Vector3 val = v; Vector3.OrthoNormalize(ref normal, ref val); return Vector3.Project(v, val) * weight; } public static Vector3 ClampDirection(Vector3 direction, Vector3 normalDirection, float clampWeight, int clampSmoothing) { //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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_00ea: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00e4: Unknown result type (might be due to invalid IL or missing references) if (clampWeight <= 0f) { return direction; } if (clampWeight >= 1f) { return normalDirection; } float num = Vector3.Angle(normalDirection, direction); float num2 = 1f - num / 180f; if (num2 > clampWeight) { return direction; } float num3 = ((!(clampWeight > 0f)) ? 1f : Mathf.Clamp(1f - (clampWeight - num2) / (1f - num2), 0f, 1f)); float num4 = ((!(clampWeight > 0f)) ? 1f : Mathf.Clamp(num2 / clampWeight, 0f, 1f)); for (int i = 0; i < clampSmoothing; i++) { float num5 = num4 * (float)Math.PI * 0.5f; num4 = Mathf.Sin(num5); } return Vector3.Slerp(normalDirection, direction, num4 * num3); } public static Vector3 ClampDirection(Vector3 direction, Vector3 normalDirection, float clampWeight, int clampSmoothing, out bool changed) { //IL_0010: 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_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_0027: 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_00f7: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) changed = false; if (clampWeight <= 0f) { return direction; } if (clampWeight >= 1f) { changed = true; return normalDirection; } float num = Vector3.Angle(normalDirection, direction); float num2 = 1f - num / 180f; if (num2 > clampWeight) { return direction; } changed = true; float num3 = ((!(clampWeight > 0f)) ? 1f : Mathf.Clamp(1f - (clampWeight - num2) / (1f - num2), 0f, 1f)); float num4 = ((!(clampWeight > 0f)) ? 1f : Mathf.Clamp(num2 / clampWeight, 0f, 1f)); for (int i = 0; i < clampSmoothing; i++) { float num5 = num4 * (float)Math.PI * 0.5f; num4 = Mathf.Sin(num5); } return Vector3.Slerp(normalDirection, direction, num4 * num3); } public static Vector3 ClampDirection(Vector3 direction, Vector3 normalDirection, float clampWeight, int clampSmoothing, out float clampValue) { //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) //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_0027: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) clampValue = 1f; if (clampWeight <= 0f) { return direction; } if (clampWeight >= 1f) { return normalDirection; } float num = Vector3.Angle(normalDirection, direction); float num2 = 1f - num / 180f; if (num2 > clampWeight) { clampValue = 0f; return direction; } float num3 = ((!(clampWeight > 0f)) ? 1f : Mathf.Clamp(1f - (clampWeight - num2) / (1f - num2), 0f, 1f)); float num4 = ((!(clampWeight > 0f)) ? 1f : Mathf.Clamp(num2 / clampWeight, 0f, 1f)); for (int i = 0; i < clampSmoothing; i++) { float num5 = num4 * (float)Math.PI * 0.5f; num4 = Mathf.Sin(num5); } float num6 = num4 * num3; clampValue = 1f - num6; return Vector3.Slerp(normalDirection, direction, num6); } public static Vector3 LineToPlane(Vector3 origin, Vector3 direction, Vector3 planeNormal, Vector3 planePoint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_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_0031: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_004a: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Dot(planePoint - origin, planeNormal); float num2 = Vector3.Dot(direction, planeNormal); if (num2 == 0f) { return Vector3.zero; } float num3 = num / num2; return origin + ((Vector3)(ref direction)).normalized * num3; } public static Vector3 PointToPlane(Vector3 point, Vector3 planePosition, Vector3 planeNormal) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_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_0058: 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_005e: Unknown result type (might be due to invalid IL or missing references) if (planeNormal == Vector3.up) { return new Vector3(point.x, planePosition.y, point.z); } Vector3 val = point - planePosition; Vector3 val2 = planeNormal; Vector3.OrthoNormalize(ref val2, ref val); return planePosition + Vector3.Project(point - planePosition, val); } public static Vector3 TransformPointUnscaled(Transform t, Vector3 point) { //IL_0002: 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_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) return t.position + t.rotation * point; } public static Vector3 InverseTransformPointUnscaled(Transform t, Vector3 point) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_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_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) return Quaternion.Inverse(t.rotation) * (point - t.position); } public static Vector3 InverseTransformPoint(Vector3 tPos, Quaternion tRot, Vector3 tScale, Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0019: 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) return Div(Quaternion.Inverse(tRot) * (point - tPos), tScale); } public static Vector3 TransformPoint(Vector3 tPos, Quaternion tRot, Vector3 tScale, Vector3 point) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_0014: 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) return tPos + Vector3.Scale(tRot * point, tScale); } public static Vector3 Div(Vector3 v1, Vector3 v2) { //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) return new Vector3(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z); } } public static class Warning { public delegate void Logger(string message); public static bool logged; public static void Log(string message, Logger logger, bool logInEditMode = false) { if ((logInEditMode || Application.isPlaying) && !logged) { logger?.Invoke(message); logged = true; } } public static void Log(string message, Transform context, bool logInEditMode = false) { if ((logInEditMode || Application.isPlaying) && !logged) { Debug.LogWarning((object)message, (Object)(object)context); logged = true; } } } } public class DynamicBoneDemo1 : MonoBehaviour { public GameObject m_Player; private float m_weight = 1f; private void Update() { //IL_002c: 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_0056: 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_006a: Unknown result type (might be due to invalid IL or missing references) m_Player.transform.Rotate(new Vector3(0f, Input.GetAxis("Horizontal") * Time.deltaTime * 200f, 0f)); m_Player.transform.Translate(((Component)this).transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * 4f); } private void OnGUI() { //IL_0015: 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_007f: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) GUI.Label(new Rect(50f, 50f, 200f, 24f), "Press arrow key to move"); Animation componentInChildren = m_Player.GetComponentInChildren(); ((Behaviour)componentInChildren).enabled = GUI.Toggle(new Rect(50f, 70f, 200f, 24f), ((Behaviour)componentInChildren).enabled, "Play Animation"); DynamicBone[] components = m_Player.GetComponents(); GUI.Label(new Rect(50f, 100f, 200f, 24f), "Choose dynamic bone:"); DynamicBone obj = components[0]; bool enabled = GUI.Toggle(new Rect(50f, 120f, 100f, 24f), ((Behaviour)components[0]).enabled, "Breasts"); ((Behaviour)components[1]).enabled = enabled; ((Behaviour)obj).enabled = enabled; ((Behaviour)components[2]).enabled = GUI.Toggle(new Rect(50f, 140f, 100f, 24f), ((Behaviour)components[2]).enabled, "Tail"); GUI.Label(new Rect(50f, 160f, 200f, 24f), "Weight"); m_weight = GUI.HorizontalSlider(new Rect(100f, 160f, 100f, 24f), m_weight, 0f, 1f); DynamicBone[] array = components; foreach (DynamicBone dynamicBone in array) { dynamicBone.SetWeight(m_weight); } } } [AddComponentMenu("Dynamic Bone/Dynamic Bone")] public class DynamicBone : MonoBehaviour { public enum UpdateMode { Normal, AnimatePhysics, UnscaledTime } public enum FreezeAxis { None, X, Y, Z } private class Particle { public Transform m_Transform = null; public int m_ParentIndex = -1; public float m_Damping = 0f; public float m_Elasticity = 0f; public float m_Stiffness = 0f; public float m_Inert = 0f; public float m_Friction = 0f; public float m_Radius = 0f; public float m_BoneLength = 0f; public bool m_isCollide = false; public Vector3 m_Position = Vector3.zero; public Vector3 m_PrevPosition = Vector3.zero; public Vector3 m_EndOffset = Vector3.zero; public Vector3 m_InitLocalPosition = Vector3.zero; public Quaternion m_InitLocalRotation = Quaternion.identity; } [Tooltip("The root of the transform hierarchy to apply physics.")] public Transform m_Root = null; [Tooltip("Internal physics simulation rate.")] public float m_UpdateRate = 60f; public UpdateMode m_UpdateMode = UpdateMode.Normal; [Tooltip("How much the bones slowed down.")] [Range(0f, 1f)] public float m_Damping = 0.1f; public AnimationCurve m_DampingDistrib = null; [Tooltip("How much the force applied to return each bone to original orientation.")] [Range(0f, 1f)] public float m_Elasticity = 0.1f; public AnimationCurve m_ElasticityDistrib = null; [Tooltip("How much bone's original orientation are preserved.")] [Range(0f, 1f)] public float m_Stiffness = 0.1f; public AnimationCurve m_StiffnessDistrib = null; [Tooltip("How much character's position change is ignored in physics simulation.")] [Range(0f, 1f)] public float m_Inert = 0f; public AnimationCurve m_InertDistrib = null; [Tooltip("How much the bones slowed down when collide.")] public float m_Friction = 0f; public AnimationCurve m_FrictionDistrib = null; [Tooltip("Each bone can be a sphere to collide with colliders. Radius describe sphere's size.")] public float m_Radius = 0f; public AnimationCurve m_RadiusDistrib = null; [Tooltip("If End Length is not zero, an extra bone is generated at the end of transform hierarchy.")] public float m_EndLength = 0f; [Tooltip("If End Offset is not zero, an extra bone is generated at the end of transform hierarchy.")] public Vector3 m_EndOffset = Vector3.zero; [Tooltip("The force apply to bones. Partial force apply to character's initial pose is cancelled out.")] public Vector3 m_Gravity = Vector3.zero; [Tooltip("The force apply to bones.")] public Vector3 m_Force = Vector3.zero; [Tooltip("Collider objects interact with the bones.")] public List m_Colliders = null; [Tooltip("Bones exclude from physics simulation.")] public List m_Exclusions = null; [Tooltip("Constrain bones to move on specified plane.")] public FreezeAxis m_FreezeAxis = FreezeAxis.None; [Tooltip("Disable physics simulation automatically if character is far from camera or player.")] public bool m_DistantDisable = false; public Transform m_ReferenceObject = null; public float m_DistanceToObject = 20f; private Vector3 m_LocalGravity = Vector3.zero; private Vector3 m_ObjectMove = Vector3.zero; private Vector3 m_ObjectPrevPosition = Vector3.zero; private float m_BoneTotalLength = 0f; private float m_ObjectScale = 1f; private float m_Time = 0f; private float m_Weight = 1f; private bool m_DistantDisabled = false; private List m_Particles = new List(); private void Start() { SetupParticles(); } private void FixedUpdate() { if (m_UpdateMode == UpdateMode.AnimatePhysics) { PreUpdate(); } } private void Update() { if (m_UpdateMode != UpdateMode.AnimatePhysics) { PreUpdate(); } } private void LateUpdate() { if (m_DistantDisable) { CheckDistance(); } if (m_Weight > 0f && (!m_DistantDisable || !m_DistantDisabled)) { float t = ((m_UpdateMode != UpdateMode.UnscaledTime) ? Time.deltaTime : Time.unscaledDeltaTime); UpdateDynamicBones(t); } } private void PreUpdate() { if (m_Weight > 0f && (!m_DistantDisable || !m_DistantDisabled)) { InitTransforms(); } } private void CheckDistance() { //IL_003d: 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_0052: Unknown result type (might be due to invalid IL or missing references) Transform val = m_ReferenceObject; if ((Object)(object)val == (Object)null && (Object)(object)Camera.main != (Object)null) { val = ((Component)Camera.main).transform; } if (!((Object)(object)val != (Object)null)) { return; } Vector3 val2 = val.position - ((Component)this).transform.position; float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; bool flag = sqrMagnitude > m_DistanceToObject * m_DistanceToObject; if (flag != m_DistantDisabled) { if (!flag) { ResetParticlesPosition(); } m_DistantDisabled = flag; } } private void OnEnable() { ResetParticlesPosition(); } private void OnDisable() { InitTransforms(); } private void OnValidate() { m_UpdateRate = Mathf.Max(m_UpdateRate, 0f); m_Damping = Mathf.Clamp01(m_Damping); m_Elasticity = Mathf.Clamp01(m_Elasticity); m_Stiffness = Mathf.Clamp01(m_Stiffness); m_Inert = Mathf.Clamp01(m_Inert); m_Friction = Mathf.Clamp01(m_Friction); m_Radius = Mathf.Max(m_Radius, 0f); if (Application.isEditor && Application.isPlaying) { InitTransforms(); SetupParticles(); } } private void OnDrawGizmosSelected() { //IL_0054: 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_0099: 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) if (!((Behaviour)this).enabled || (Object)(object)m_Root == (Object)null) { return; } if (Application.isEditor && !Application.isPlaying && ((Component)this).transform.hasChanged) { InitTransforms(); SetupParticles(); } Gizmos.color = Color.white; for (int i = 0; i < m_Particles.Count; i++) { Particle particle = m_Particles[i]; if (particle.m_ParentIndex >= 0) { Particle particle2 = m_Particles[particle.m_ParentIndex]; Gizmos.DrawLine(particle.m_Position, particle2.m_Position); } if (particle.m_Radius > 0f) { Gizmos.DrawWireSphere(particle.m_Position, particle.m_Radius * m_ObjectScale); } } } public void SetWeight(float w) { if (m_Weight != w) { if (w == 0f) { InitTransforms(); } else if (m_Weight == 0f) { ResetParticlesPosition(); } m_Weight = w; } } public float GetWeight() { return m_Weight; } private void UpdateDynamicBones(float t) { //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_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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_Root == (Object)null) { return; } m_ObjectScale = Mathf.Abs(((Component)this).transform.lossyScale.x); m_ObjectMove = ((Component)this).transform.position - m_ObjectPrevPosition; m_ObjectPrevPosition = ((Component)this).transform.position; int num = 1; if (m_UpdateRate > 0f) { float num2 = 1f / m_UpdateRate; m_Time += t; num = 0; while (m_Time >= num2) { m_Time -= num2; if (++num >= 3) { m_Time = 0f; break; } } } if (num > 0) { for (int i = 0; i < num; i++) { UpdateParticles1(); UpdateParticles2(); m_ObjectMove = Vector3.zero; } } else { SkipUpdateParticles(); } ApplyParticlesToTransforms(); } private void SetupParticles() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_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) m_Particles.Clear(); if (!((Object)(object)m_Root == (Object)null)) { m_LocalGravity = m_Root.InverseTransformDirection(m_Gravity); m_ObjectScale = Mathf.Abs(((Component)this).transform.lossyScale.x); m_ObjectPrevPosition = ((Component)this).transform.position; m_ObjectMove = Vector3.zero; m_BoneTotalLength = 0f; AppendParticles(m_Root, -1, 0f); UpdateParameters(); } } private void AppendParticles(Transform b, int parentIndex, float boneLength) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0032: 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_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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_0282: 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_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) Particle particle = new Particle(); particle.m_Transform = b; particle.m_ParentIndex = parentIndex; Vector3 val; if ((Object)(object)b != (Object)null) { val = (particle.m_Position = (particle.m_PrevPosition = b.position)); particle.m_InitLocalPosition = b.localPosition; particle.m_InitLocalRotation = b.localRotation; } else { Transform transform = m_Particles[parentIndex].m_Transform; if (m_EndLength > 0f) { Transform parent = transform.parent; if ((Object)(object)parent != (Object)null) { particle.m_EndOffset = transform.InverseTransformPoint(transform.position * 2f - parent.position) * m_EndLength; } else { particle.m_EndOffset = new Vector3(m_EndLength, 0f, 0f); } } else { particle.m_EndOffset = transform.InverseTransformPoint(((Component)this).transform.TransformDirection(m_EndOffset) + transform.position); } val = (particle.m_Position = (particle.m_PrevPosition = transform.TransformPoint(particle.m_EndOffset))); } if (parentIndex >= 0) { float num = boneLength; val = m_Particles[parentIndex].m_Transform.position - particle.m_Position; boneLength = num + ((Vector3)(ref val)).magnitude; particle.m_BoneLength = boneLength; m_BoneTotalLength = Mathf.Max(m_BoneTotalLength, boneLength); } int count = m_Particles.Count; m_Particles.Add(particle); if (!((Object)(object)b != (Object)null)) { return; } for (int i = 0; i < b.childCount; i++) { bool flag = false; if (m_Exclusions != null) { for (int j = 0; j < m_Exclusions.Count; j++) { Transform val2 = m_Exclusions[j]; if ((Object)(object)val2 == (Object)(object)b.GetChild(i)) { flag = true; break; } } } if (!flag) { AppendParticles(b.GetChild(i), count, boneLength); } else if (m_EndLength > 0f || m_EndOffset != Vector3.zero) { AppendParticles(null, count, boneLength); } } if (b.childCount == 0 && (m_EndLength > 0f || m_EndOffset != Vector3.zero)) { AppendParticles(null, count, boneLength); } } public void UpdateParameters() { //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_0029: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_Root == (Object)null) { return; } m_LocalGravity = m_Root.InverseTransformDirection(m_Gravity); for (int i = 0; i < m_Particles.Count; i++) { Particle particle = m_Particles[i]; particle.m_Damping = m_Damping; particle.m_Elasticity = m_Elasticity; particle.m_Stiffness = m_Stiffness; particle.m_Inert = m_Inert; particle.m_Friction = m_Friction; particle.m_Radius = m_Radius; if (m_BoneTotalLength > 0f) { float num = particle.m_BoneLength / m_BoneTotalLength; if (m_DampingDistrib != null && m_DampingDistrib.keys.Length > 0) { particle.m_Damping *= m_DampingDistrib.Evaluate(num); } if (m_ElasticityDistrib != null && m_ElasticityDistrib.keys.Length > 0) { particle.m_Elasticity *= m_ElasticityDistrib.Evaluate(num); } if (m_StiffnessDistrib != null && m_StiffnessDistrib.keys.Length > 0) { particle.m_Stiffness *= m_StiffnessDistrib.Evaluate(num); } if (m_InertDistrib != null && m_InertDistrib.keys.Length > 0) { particle.m_Inert *= m_InertDistrib.Evaluate(num); } if (m_FrictionDistrib != null && m_FrictionDistrib.keys.Length > 0) { particle.m_Friction *= m_FrictionDistrib.Evaluate(num); } if (m_RadiusDistrib != null && m_RadiusDistrib.keys.Length > 0) { particle.m_Radius *= m_RadiusDistrib.Evaluate(num); } } particle.m_Damping = Mathf.Clamp01(particle.m_Damping); particle.m_Elasticity = Mathf.Clamp01(particle.m_Elasticity); particle.m_Stiffness = Mathf.Clamp01(particle.m_Stiffness); particle.m_Inert = Mathf.Clamp01(particle.m_Inert); particle.m_Friction = Mathf.Clamp01(particle.m_Friction); particle.m_Radius = Mathf.Max(particle.m_Radius, 0f); } } private void InitTransforms() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_Particles.Count; i++) { Particle particle = m_Particles[i]; if ((Object)(object)particle.m_Transform != (Object)null) { particle.m_Transform.localPosition = particle.m_InitLocalPosition; particle.m_Transform.localRotation = particle.m_InitLocalRotation; } } } private void ResetParticlesPosition() { //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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0076: 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_0036: 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_003d: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_Particles.Count; i++) { Particle particle = m_Particles[i]; if ((Object)(object)particle.m_Transform != (Object)null) { particle.m_Position = (particle.m_PrevPosition = particle.m_Transform.position); } else { Transform transform = m_Particles[particle.m_ParentIndex].m_Transform; particle.m_Position = (particle.m_PrevPosition = transform.TransformPoint(particle.m_EndOffset)); } particle.m_isCollide = false; } m_ObjectPrevPosition = ((Component)this).transform.position; } private void UpdateParticles1() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0129: Unknown result type (might be due to invalid IL or missing references) Vector3 gravity = m_Gravity; Vector3 normalized = ((Vector3)(ref m_Gravity)).normalized; Vector3 val = m_Root.TransformDirection(m_LocalGravity); Vector3 val2 = normalized * Mathf.Max(Vector3.Dot(val, normalized), 0f); gravity -= val2; gravity = (gravity + m_Force) * m_ObjectScale; for (int i = 0; i < m_Particles.Count; i++) { Particle particle = m_Particles[i]; if (particle.m_ParentIndex >= 0) { Vector3 val3 = particle.m_Position - particle.m_PrevPosition; Vector3 val4 = m_ObjectMove * particle.m_Inert; particle.m_PrevPosition = particle.m_Position + val4; float num = particle.m_Damping; if (particle.m_isCollide) { num += particle.m_Friction; if (num > 1f) { num = 1f; } particle.m_isCollide = false; } particle.m_Position += val3 * (1f - num) + gravity + val4; } else { particle.m_PrevPosition = particle.m_Position; particle.m_Position = particle.m_Transform.position; } } } private void UpdateParticles2() { //IL_0003: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0130: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: 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_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: 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_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) Plane val = default(Plane); for (int i = 1; i < m_Particles.Count; i++) { Particle particle = m_Particles[i]; Particle particle2 = m_Particles[particle.m_ParentIndex]; float magnitude; if ((Object)(object)particle.m_Transform != (Object)null) { Vector3 val2 = particle2.m_Transform.position - particle.m_Transform.position; magnitude = ((Vector3)(ref val2)).magnitude; } else { Matrix4x4 localToWorldMatrix = particle2.m_Transform.localToWorldMatrix; Vector3 val3 = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyVector(particle.m_EndOffset); magnitude = ((Vector3)(ref val3)).magnitude; } float num = Mathf.Lerp(1f, particle.m_Stiffness, m_Weight); if (num > 0f || particle.m_Elasticity > 0f) { Matrix4x4 localToWorldMatrix2 = particle2.m_Transform.localToWorldMatrix; ((Matrix4x4)(ref localToWorldMatrix2)).SetColumn(3, Vector4.op_Implicit(particle2.m_Position)); Vector3 val4 = ((!((Object)(object)particle.m_Transform != (Object)null)) ? ((Matrix4x4)(ref localToWorldMatrix2)).MultiplyPoint3x4(particle.m_EndOffset) : ((Matrix4x4)(ref localToWorldMatrix2)).MultiplyPoint3x4(particle.m_Transform.localPosition)); Vector3 val5 = val4 - particle.m_Position; particle.m_Position += val5 * particle.m_Elasticity; if (num > 0f) { val5 = val4 - particle.m_Position; float magnitude2 = ((Vector3)(ref val5)).magnitude; float num2 = magnitude * (1f - num) * 2f; if (magnitude2 > num2) { particle.m_Position += val5 * ((magnitude2 - num2) / magnitude2); } } } if (m_Colliders != null) { float particleRadius = particle.m_Radius * m_ObjectScale; for (int j = 0; j < m_Colliders.Count; j++) { DynamicBoneColliderBase dynamicBoneColliderBase = m_Colliders[j]; if ((Object)(object)dynamicBoneColliderBase != (Object)null && ((Behaviour)dynamicBoneColliderBase).enabled) { particle.m_isCollide |= dynamicBoneColliderBase.Collide(ref particle.m_Position, particleRadius); } } } if (m_FreezeAxis != 0) { switch (m_FreezeAxis) { case FreezeAxis.X: ((Plane)(ref val)).SetNormalAndPosition(particle2.m_Transform.right, particle2.m_Position); break; case FreezeAxis.Y: ((Plane)(ref val)).SetNormalAndPosition(particle2.m_Transform.up, particle2.m_Position); break; case FreezeAxis.Z: ((Plane)(ref val)).SetNormalAndPosition(particle2.m_Transform.forward, particle2.m_Position); break; } particle.m_Position -= ((Plane)(ref val)).normal * ((Plane)(ref val)).GetDistanceToPoint(particle.m_Position); } Vector3 val6 = particle2.m_Position - particle.m_Position; float magnitude3 = ((Vector3)(ref val6)).magnitude; if (magnitude3 > 0f) { particle.m_Position += val6 * ((magnitude3 - magnitude) / magnitude3); } } } private void SkipUpdateParticles() { //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_004c: 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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_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_007a: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < m_Particles.Count; i++) { Particle particle = m_Particles[i]; if (particle.m_ParentIndex >= 0) { particle.m_PrevPosition += m_ObjectMove; particle.m_Position += m_ObjectMove; Particle particle2 = m_Particles[particle.m_ParentIndex]; float magnitude; if ((Object)(object)particle.m_Transform != (Object)null) { Vector3 val = particle2.m_Transform.position - particle.m_Transform.position; magnitude = ((Vector3)(ref val)).magnitude; } else { Matrix4x4 localToWorldMatrix = particle2.m_Transform.localToWorldMatrix; Vector3 val2 = ((Matrix4x4)(ref localToWorldMatrix)).MultiplyVector(particle.m_EndOffset); magnitude = ((Vector3)(ref val2)).magnitude; } float num = Mathf.Lerp(1f, particle.m_Stiffness, m_Weight); if (num > 0f) { Matrix4x4 localToWorldMatrix2 = particle2.m_Transform.localToWorldMatrix; ((Matrix4x4)(ref localToWorldMatrix2)).SetColumn(3, Vector4.op_Implicit(particle2.m_Position)); Vector3 val3 = ((!((Object)(object)particle.m_Transform != (Object)null)) ? ((Matrix4x4)(ref localToWorldMatrix2)).MultiplyPoint3x4(particle.m_EndOffset) : ((Matrix4x4)(ref localToWorldMatrix2)).MultiplyPoint3x4(particle.m_Transform.localPosition)); Vector3 val4 = val3 - particle.m_Position; float magnitude2 = ((Vector3)(ref val4)).magnitude; float num2 = magnitude * (1f - num) * 2f; if (magnitude2 > num2) { particle.m_Position += val4 * ((magnitude2 - num2) / magnitude2); } } Vector3 val5 = particle2.m_Position - particle.m_Position; float magnitude3 = ((Vector3)(ref val5)).magnitude; if (magnitude3 > 0f) { particle.m_Position += val5 * ((magnitude3 - magnitude) / magnitude3); } } else { particle.m_PrevPosition = particle.m_Position; particle.m_Position = particle.m_Transform.position; } } } private static Vector3 MirrorVector(Vector3 v, Vector3 axis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_001a: 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) return v - axis * (Vector3.Dot(v, axis) * 2f); } private void ApplyParticlesToTransforms() { //IL_00c1: 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) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_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_0091: 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) for (int i = 1; i < m_Particles.Count; i++) { Particle particle = m_Particles[i]; Particle particle2 = m_Particles[particle.m_ParentIndex]; if (particle2.m_Transform.childCount <= 1) { Vector3 val = ((!((Object)(object)particle.m_Transform != (Object)null)) ? particle.m_EndOffset : particle.m_Transform.localPosition); Vector3 val2 = particle.m_Position - particle2.m_Position; Quaternion val3 = Quaternion.FromToRotation(particle2.m_Transform.TransformDirection(val), val2); particle2.m_Transform.rotation = val3 * particle2.m_Transform.rotation; } if ((Object)(object)particle.m_Transform != (Object)null) { particle.m_Transform.position = particle.m_Position; } } } } [AddComponentMenu("Dynamic Bone/Dynamic Bone Collider")] public class DynamicBoneCollider : DynamicBoneColliderBase { [Tooltip("The radius of the sphere or capsule.")] public float m_Radius = 0.5f; [Tooltip("The height of the capsule.")] public float m_Height = 0f; private void OnValidate() { m_Radius = Mathf.Max(m_Radius, 0f); m_Height = Mathf.Max(m_Height, 0f); } public override bool Collide(ref Vector3 particlePosition, float particleRadius) { //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_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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0163: 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_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) float num = m_Radius * Mathf.Abs(((Component)this).transform.lossyScale.x); float num2 = m_Height * 0.5f - m_Radius; if (num2 <= 0f) { if (m_Bound == Bound.Outside) { return OutsideSphere(ref particlePosition, particleRadius, ((Component)this).transform.TransformPoint(m_Center), num); } return InsideSphere(ref particlePosition, particleRadius, ((Component)this).transform.TransformPoint(m_Center), num); } Vector3 center = m_Center; Vector3 center2 = m_Center; switch (m_Direction) { case Direction.X: center.x -= num2; center2.x += num2; break; case Direction.Y: center.y -= num2; center2.y += num2; break; case Direction.Z: center.z -= num2; center2.z += num2; break; } if (m_Bound == Bound.Outside) { return OutsideCapsule(ref particlePosition, particleRadius, ((Component)this).transform.TransformPoint(center), ((Component)this).transform.TransformPoint(center2), num); } return InsideCapsule(ref particlePosition, particleRadius, ((Component)this).transform.TransformPoint(center), ((Component)this).transform.TransformPoint(center2), num); } private static bool OutsideSphere(ref Vector3 particlePosition, float particleRadius, Vector3 sphereCenter, float sphereRadius) { //IL_000a: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: Unknown result type (might be due to invalid IL or missing references) float num = sphereRadius + particleRadius; float num2 = num * num; Vector3 val = particlePosition - sphereCenter; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude > 0f && sqrMagnitude < num2) { float num3 = Mathf.Sqrt(sqrMagnitude); particlePosition = sphereCenter + val * (num / num3); return true; } return false; } private static bool InsideSphere(ref Vector3 particlePosition, float particleRadius, Vector3 sphereCenter, float sphereRadius) { //IL_000a: 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_0015: 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_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_003f: Unknown result type (might be due to invalid IL or missing references) float num = sphereRadius - particleRadius; float num2 = num * num; Vector3 val = particlePosition - sphereCenter; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude > num2) { float num3 = Mathf.Sqrt(sqrMagnitude); particlePosition = sphereCenter + val * (num / num3); return true; } return false; } private static bool OutsideCapsule(ref Vector3 particlePosition, float particleRadius, Vector3 capsuleP0, Vector3 capsuleP1, float capsuleRadius) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_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_009b: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) float num = capsuleRadius + particleRadius; float num2 = num * num; Vector3 val = capsuleP1 - capsuleP0; Vector3 val2 = particlePosition - capsuleP0; float num3 = Vector3.Dot(val2, val); if (num3 <= 0f) { float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude > 0f && sqrMagnitude < num2) { float num4 = Mathf.Sqrt(sqrMagnitude); particlePosition = capsuleP0 + val2 * (num / num4); return true; } } else { float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude; if (num3 >= sqrMagnitude2) { val2 = particlePosition - capsuleP1; float sqrMagnitude3 = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude3 > 0f && sqrMagnitude3 < num2) { float num5 = Mathf.Sqrt(sqrMagnitude3); particlePosition = capsuleP1 + val2 * (num / num5); return true; } } else if (sqrMagnitude2 > 0f) { num3 /= sqrMagnitude2; val2 -= val * num3; float sqrMagnitude4 = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude4 > 0f && sqrMagnitude4 < num2) { float num6 = Mathf.Sqrt(sqrMagnitude4); particlePosition += val2 * ((num - num6) / num6); return true; } } } return false; } private static bool InsideCapsule(ref Vector3 particlePosition, float particleRadius, Vector3 capsuleP0, Vector3 capsuleP1, float capsuleRadius) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) float num = capsuleRadius - particleRadius; float num2 = num * num; Vector3 val = capsuleP1 - capsuleP0; Vector3 val2 = particlePosition - capsuleP0; float num3 = Vector3.Dot(val2, val); if (num3 <= 0f) { float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude > num2) { float num4 = Mathf.Sqrt(sqrMagnitude); particlePosition = capsuleP0 + val2 * (num / num4); return true; } } else { float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude; if (num3 >= sqrMagnitude2) { val2 = particlePosition - capsuleP1; float sqrMagnitude3 = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude3 > num2) { float num5 = Mathf.Sqrt(sqrMagnitude3); particlePosition = capsuleP1 + val2 * (num / num5); return true; } } else if (sqrMagnitude2 > 0f) { num3 /= sqrMagnitude2; val2 -= val * num3; float sqrMagnitude4 = ((Vector3)(ref val2)).sqrMagnitude; if (sqrMagnitude4 > num2) { float num6 = Mathf.Sqrt(sqrMagnitude4); particlePosition += val2 * ((num - num6) / num6); return true; } } } return false; } private void OnDrawGizmosSelected() { //IL_002b: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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) if (!((Behaviour)this).enabled) { return; } if (m_Bound == Bound.Outside) { Gizmos.color = Color.yellow; } else { Gizmos.color = Color.magenta; } float num = m_Radius * Mathf.Abs(((Component)this).transform.lossyScale.x); float num2 = m_Height * 0.5f - m_Radius; if (num2 <= 0f) { Gizmos.DrawWireSphere(((Component)this).transform.TransformPoint(m_Center), num); return; } Vector3 center = m_Center; Vector3 center2 = m_Center; switch (m_Direction) { case Direction.X: center.x -= num2; center2.x += num2; break; case Direction.Y: center.y -= num2; center2.y += num2; break; case Direction.Z: center.z -= num2; center2.z += num2; break; } Gizmos.DrawWireSphere(((Component)this).transform.TransformPoint(center), num); Gizmos.DrawWireSphere(((Component)this).transform.TransformPoint(center2), num); } } public class DynamicBoneColliderBase : MonoBehaviour { public enum Direction { X, Y, Z } public enum Bound { Outside, Inside } [Tooltip("The axis of the capsule's height.")] public Direction m_Direction = Direction.Y; [Tooltip("The center of the sphere or capsule, in the object's local space.")] public Vector3 m_Center = Vector3.zero; [Tooltip("Constrain bones to outside bound or inside bound.")] public Bound m_Bound = Bound.Outside; public virtual bool Collide(ref Vector3 particlePosition, float particleRadius) { return false; } } [AddComponentMenu("Dynamic Bone/Dynamic Bone Plane Collider")] public class DynamicBonePlaneCollider : DynamicBoneColliderBase { private void OnValidate() { } public override bool Collide(ref Vector3 particlePosition, float particleRadius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.up; switch (m_Direction) { case Direction.X: val = ((Component)this).transform.right; break; case Direction.Y: val = ((Component)this).transform.up; break; case Direction.Z: val = ((Component)this).transform.forward; break; } Vector3 val2 = ((Component)this).transform.TransformPoint(m_Center); Plane val3 = default(Plane); ((Plane)(ref val3))..ctor(val, val2); float distanceToPoint = ((Plane)(ref val3)).GetDistanceToPoint(particlePosition); if (m_Bound == Bound.Outside) { if (distanceToPoint < 0f) { particlePosition -= val * distanceToPoint; return true; } } else if (distanceToPoint > 0f) { particlePosition -= val * distanceToPoint; return true; } return false; } private void OnDrawGizmosSelected() { //IL_002b: 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_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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_0072: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) if (((Behaviour)this).enabled) { if (m_Bound == Bound.Outside) { Gizmos.color = Color.yellow; } else { Gizmos.color = Color.magenta; } Vector3 val = Vector3.up; switch (m_Direction) { case Direction.X: val = ((Component)this).transform.right; break; case Direction.Y: val = ((Component)this).transform.up; break; case Direction.Z: val = ((Component)this).transform.forward; break; } Vector3 val2 = ((Component)this).transform.TransformPoint(m_Center); Gizmos.DrawLine(val2, val2 + val); } } } namespace JerryComponent { public class RandomSpawn : MonoBehaviour { public GameObject[] _Outfits; public GameObject _Selected; public Random Rand; public int _MaxNum; public void Awake() { Rand = new Random(); Rand.Next(_MaxNum); _Selected = _Outfits[Rand.Next(_MaxNum)]; _Selected.SetActive(true); } private void Start() { } private void Update() { } } public class OnlyOne : MonoBehaviour { private void Start() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown int num = 0; Object[] array = Object.FindObjectsOfType(typeof(FVRPhysicalObject)); for (int i = 0; i < array.Length; i++) { FVRPhysicalObject val = (FVRPhysicalObject)array[i]; num++; if (((Object)((Component)val).gameObject).name == ((Object)((Component)this).gameObject).name && !((Object)(object)((Component)val).gameObject == (Object)(object)((Component)this).gameObject) && (Object)(object)((Component)val).gameObject != (Object)(object)((Component)this).gameObject) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } private void Update() { } } } [RequireComponent(typeof(ParticleSystem))] public class CFX_AutoStopLoopedEffect : MonoBehaviour { public float effectDuration = 2.5f; private float d; private void OnEnable() { d = effectDuration; } private void Update() { if (!(d > 0f)) { return; } d -= Time.deltaTime; if (d <= 0f) { ((Component)this).GetComponent().Stop(true); CFX_Demo_Translate component = ((Component)this).gameObject.GetComponent(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = false; } } } } public class CFX_Demo : MonoBehaviour { public bool orderedSpawns = true; public float step = 1f; public float range = 5f; private float order = -5f; public Material groundMat; public Material waterMat; public GameObject[] ParticleExamples; private Dictionary ParticlesYOffsetD = new Dictionary { { "CFX_ElectricGround", 0.15f }, { "CFX_ElectricityBall", 1f }, { "CFX_ElectricityBolt", 1f }, { "CFX_Explosion", 2f }, { "CFX_SmallExplosion", 1.5f }, { "CFX_SmokeExplosion", 2.5f }, { "CFX_Flame", 1f }, { "CFX_DoubleFlame", 1f }, { "CFX_Hit", 1f }, { "CFX_CircularLightWall", 0.05f }, { "CFX_LightWall", 0.05f }, { "CFX_Flash", 2f }, { "CFX_Poof", 1.5f }, { "CFX_Virus", 1f }, { "CFX_SmokePuffs", 2f }, { "CFX_Slash", 1f }, { "CFX_Splash", 0.05f }, { "CFX_Fountain", 0.05f }, { "CFX_Ripple", 0.05f }, { "CFX_Magic", 2f }, { "CFX_SoftStar", 1f }, { "CFX_SpikyAura_Sphere", 1f }, { "CFX_Firework", 2.4f }, { "CFX_GroundA", 0.05f } }; private int exampleIndex; private string randomSpawnsDelay = "0.5"; private bool randomSpawns; private bool slowMo; private void OnMouseDown() { //IL_0003: 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_0019: 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_004f: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (((Component)this).GetComponent().Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), ref val, 9999f)) { GameObject val2 = spawnParticle(); val2.transform.position = ((RaycastHit)(ref val)).point + val2.transform.position; } } private GameObject spawnParticle() { //IL_00c6: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate(ParticleExamples[exampleIndex]); val.SetActive(true); for (int i = 0; i < val.transform.childCount; i++) { ((Component)val.transform.GetChild(i)).gameObject.SetActive(true); } float num = 0f; foreach (KeyValuePair item in ParticlesYOffsetD) { if (((Object)val).name.StartsWith(item.Key)) { num = item.Value; break; } } val.transform.position = new Vector3(0f, num, 0f); return val; } private void OnGUI() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginArea(new Rect(5f, 20f, (float)(Screen.width - 10), 30f)); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Effect", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) }); if (GUILayout.Button("<", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(20f) })) { prevParticle(); } GUILayout.Label(((Object)ParticleExamples[exampleIndex]).name, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) }); if (GUILayout.Button(">", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(20f) })) { nextParticle(); } GUILayout.Label("Click on the ground to spawn selected particles", (GUILayoutOption[])(object)new GUILayoutOption[0]); if (GUILayout.Button((!CFX_Demo_RotateCamera.rotating) ? "Rotate Camera" : "Pause Camera", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { CFX_Demo_RotateCamera.rotating = !CFX_Demo_RotateCamera.rotating; } if (GUILayout.Button((!randomSpawns) ? "Start Random Spawns" : "Stop Random Spawns", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) })) { randomSpawns = !randomSpawns; if (randomSpawns) { ((MonoBehaviour)this).StartCoroutine("RandomSpawnsCoroutine"); } else { ((MonoBehaviour)this).StopCoroutine("RandomSpawnsCoroutine"); } } randomSpawnsDelay = GUILayout.TextField(randomSpawnsDelay, 10, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(42f) }); randomSpawnsDelay = Regex.Replace(randomSpawnsDelay, "[^0-9.]", ""); if (GUILayout.Button((!((Component)this).GetComponent().enabled) ? "Show Ground" : "Hide Ground", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(90f) })) { ((Component)this).GetComponent().enabled = !((Component)this).GetComponent().enabled; } if (GUILayout.Button((!slowMo) ? "Slow Motion" : "Normal Speed", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(100f) })) { slowMo = !slowMo; if (slowMo) { Time.timeScale = 0.33f; } else { Time.timeScale = 1f; } } GUILayout.EndHorizontal(); GUILayout.EndArea(); } private IEnumerator RandomSpawnsCoroutine() { while (true) { GameObject particles = spawnParticle(); if (orderedSpawns) { particles.transform.position = ((Component)this).transform.position + new Vector3(order, particles.transform.position.y, 0f); order -= step; if (order < 0f - range) { order = range; } } else { particles.transform.position = ((Component)this).transform.position + new Vector3(Random.Range(0f - range, range), 0f, Random.Range(0f - range, range)) + new Vector3(0f, particles.transform.position.y, 0f); } yield return (object)new WaitForSeconds(float.Parse(randomSpawnsDelay)); } } private void Update() { if (Input.GetKeyDown((KeyCode)276)) { prevParticle(); } else if (Input.GetKeyDown((KeyCode)275)) { nextParticle(); } } private void prevParticle() { exampleIndex--; if (exampleIndex < 0) { exampleIndex = ParticleExamples.Length - 1; } if (((Object)ParticleExamples[exampleIndex]).name.Contains("Splash") || ((Object)ParticleExamples[exampleIndex]).name == "CFX_Ripple" || ((Object)ParticleExamples[exampleIndex]).name == "CFX_Fountain") { ((Component)this).GetComponent().material = waterMat; } else { ((Component)this).GetComponent().material = groundMat; } } private void nextParticle() { exampleIndex++; if (exampleIndex >= ParticleExamples.Length) { exampleIndex = 0; } if (((Object)ParticleExamples[exampleIndex]).name.Contains("Splash") || ((Object)ParticleExamples[exampleIndex]).name == "CFX_Ripple" || ((Object)ParticleExamples[exampleIndex]).name == "CFX_Fountain") { ((Component)this).GetComponent().material = waterMat; } else { ((Component)this).GetComponent().material = groundMat; } } } public class CFX_Demo_New : MonoBehaviour { public Renderer groundRenderer; public Collider groundCollider; [Space] [Space] public Image slowMoBtn; public Text slowMoLabel; public Image camRotBtn; public Text camRotLabel; public Image groundBtn; public Text groundLabel; [Space] public Text EffectLabel; public Text EffectIndexLabel; private GameObject[] ParticleExamples; private int exampleIndex; private bool slowMo; private Vector3 defaultCamPosition; private Quaternion defaultCamRotation; private List onScreenParticles = new List(); private void Awake() { //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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) List list = new List(); int childCount = ((Component)this).transform.childCount; for (int i = 0; i < childCount; i++) { GameObject gameObject = ((Component)((Component)this).transform.GetChild(i)).gameObject; list.Add(gameObject); } list.Sort((GameObject o1, GameObject o2) => ((Object)o1).name.CompareTo(((Object)o2).name)); ParticleExamples = list.ToArray(); defaultCamPosition = ((Component)Camera.main).transform.position; defaultCamRotation = ((Component)Camera.main).transform.rotation; ((MonoBehaviour)this).StartCoroutine("CheckForDeletedParticles"); UpdateUI(); } private void Update() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) if (Input.GetKeyDown((KeyCode)276)) { prevParticle(); } else if (Input.GetKeyDown((KeyCode)275)) { nextParticle(); } else if (Input.GetKeyDown((KeyCode)127)) { destroyParticles(); } if (Input.GetMouseButtonDown(0)) { RaycastHit val = default(RaycastHit); if (groundCollider.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), ref val, 9999f)) { GameObject val2 = spawnParticle(); val2.transform.position = ((RaycastHit)(ref val)).point + val2.transform.position; } } float axis = Input.GetAxis("Mouse ScrollWheel"); if (axis != 0f) { ((Component)Camera.main).transform.Translate(Vector3.forward * ((!(axis < 0f)) ? 1f : (-1f)), (Space)1); } if (Input.GetMouseButtonDown(2)) { ((Component)Camera.main).transform.position = defaultCamPosition; ((Component)Camera.main).transform.rotation = defaultCamRotation; } } public void OnToggleGround() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) Color white = Color.white; groundRenderer.enabled = !groundRenderer.enabled; white.a = ((!groundRenderer.enabled) ? 0.33f : 1f); ((Graphic)groundBtn).color = white; ((Graphic)groundLabel).color = white; } public void OnToggleCamera() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Color white = Color.white; CFX_Demo_RotateCamera.rotating = !CFX_Demo_RotateCamera.rotating; white.a = ((!CFX_Demo_RotateCamera.rotating) ? 0.33f : 1f); ((Graphic)camRotBtn).color = white; ((Graphic)camRotLabel).color = white; } public void OnToggleSlowMo() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) Color white = Color.white; slowMo = !slowMo; if (slowMo) { Time.timeScale = 0.33f; white.a = 1f; } else { Time.timeScale = 1f; white.a = 0.33f; } ((Graphic)slowMoBtn).color = white; ((Graphic)slowMoLabel).color = white; } public void OnPreviousEffect() { prevParticle(); } public void OnNextEffect() { nextParticle(); } private void UpdateUI() { EffectLabel.text = ((Object)ParticleExamples[exampleIndex]).name; EffectIndexLabel.text = string.Format("{0}/{1}", (exampleIndex + 1).ToString("00"), ParticleExamples.Length.ToString("00")); } private GameObject spawnParticle() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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) GameObject val = Object.Instantiate(ParticleExamples[exampleIndex]); val.transform.position = new Vector3(0f, val.transform.position.y, 0f); val.SetActive(true); ParticleSystem component = val.GetComponent(); if ((Object)(object)component != (Object)null) { MainModule main = component.main; if (((MainModule)(ref main)).loop) { ((Component)component).gameObject.AddComponent(); ((Component)component).gameObject.AddComponent(); } } onScreenParticles.Add(val); return val; } private IEnumerator CheckForDeletedParticles() { while (true) { yield return (object)new WaitForSeconds(5f); for (int num = onScreenParticles.Count - 1; num >= 0; num--) { if ((Object)(object)onScreenParticles[num] == (Object)null) { onScreenParticles.RemoveAt(num); } } } } private void prevParticle() { exampleIndex--; if (exampleIndex < 0) { exampleIndex = ParticleExamples.Length - 1; } UpdateUI(); } private void nextParticle() { exampleIndex++; if (exampleIndex >= ParticleExamples.Length) { exampleIndex = 0; } UpdateUI(); } private void destroyParticles() { for (int num = onScreenParticles.Count - 1; num >= 0; num--) { if ((Object)(object)onScreenParticles[num] != (Object)null) { Object.Destroy((Object)(object)onScreenParticles[num]); } onScreenParticles.RemoveAt(num); } } } public class CFX_Demo_RandomDir : MonoBehaviour { public Vector3 min = new Vector3(0f, 0f, 0f); public Vector3 max = new Vector3(0f, 360f, 0f); private void Start() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.eulerAngles = new Vector3(Random.Range(min.x, max.x), Random.Range(min.y, max.y), Random.Range(min.z, max.z)); } } public class CFX_Demo_RandomDirectionTranslate : MonoBehaviour { public float speed = 30f; public Vector3 baseDir = Vector3.zero; public Vector3 axis = Vector3.forward; public bool gravity; private Vector3 dir; private void Start() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0065: Unknown result type (might be due to invalid IL or missing references) Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Random.Range(0f, 360f), Random.Range(0f, 360f), Random.Range(0f, 360f)); dir = ((Vector3)(ref val)).normalized; ((Vector3)(ref dir)).Scale(axis); dir += baseDir; } private void Update() { //IL_0008: 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_001d: 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_0043: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.Translate(dir * speed * Time.deltaTime); if (gravity) { ((Component)this).transform.Translate(Physics.gravity * Time.deltaTime); } } } public class CFX_Demo_RotateCamera : MonoBehaviour { public static bool rotating = true; public float speed = 30f; public Transform rotationCenter; private void Update() { //IL_0017: 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) if (rotating) { ((Component)this).transform.RotateAround(rotationCenter.position, Vector3.up, speed * Time.deltaTime); } } } public class CFX_Demo_Translate : MonoBehaviour { public float speed = 30f; public Vector3 rotation = Vector3.forward; public Vector3 axis = Vector3.forward; public bool gravity; private Vector3 dir; private void Start() { //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_0040: 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) dir = new Vector3(Random.Range(0f, 360f), Random.Range(0f, 360f), Random.Range(0f, 360f)); ((Vector3)(ref dir)).Scale(rotation); ((Component)this).transform.localEulerAngles = dir; } private void Update() { //IL_0008: 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_001d: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.Translate(axis * speed * Time.deltaTime, (Space)1); } } [RequireComponent(typeof(ParticleSystem))] public class CFX_AutoDestructShuriken : MonoBehaviour { public bool OnlyDeactivate; private void OnEnable() { ((MonoBehaviour)this).StartCoroutine("CheckIfAlive"); } private IEnumerator CheckIfAlive() { ParticleSystem ps = ((Component)this).GetComponent(); while (true && (Object)(object)ps != (Object)null) { yield return (object)new WaitForSeconds(0.5f); if (!ps.IsAlive(true)) { if (OnlyDeactivate) { ((Component)this).gameObject.SetActive(false); } else { Object.Destroy((Object)(object)((Component)this).gameObject); } break; } } } } public class CFX_AutoRotate : MonoBehaviour { public Vector3 rotation; public Space space = (Space)1; private void Update() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.Rotate(rotation * Time.deltaTime, space); } } public class CFX_AutodestructWhenNoChildren : MonoBehaviour { private void Update() { if (((Component)this).transform.childCount == 0) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } public class CFX_InspectorHelp : MonoBehaviour { public bool Locked; public string Title; public string HelpText; public int MsgType; [ContextMenu("Unlock editing")] private void Unlock() { Locked = false; } } [RequireComponent(typeof(Light))] public class CFX_LightIntensityFade : MonoBehaviour { public float duration = 1f; public float delay = 0f; public float finalIntensity = 0f; private float baseIntensity; public bool autodestruct; private float p_lifetime = 0f; private float p_delay; private void Start() { baseIntensity = ((Component)this).GetComponent().intensity; } private void OnEnable() { p_lifetime = 0f; p_delay = delay; if (delay > 0f) { ((Behaviour)((Component)this).GetComponent()).enabled = false; } } private void Update() { if (p_delay > 0f) { p_delay -= Time.deltaTime; if (p_delay <= 0f) { ((Behaviour)((Component)this).GetComponent()).enabled = true; } } else if (p_lifetime / duration < 1f) { ((Component)this).GetComponent().intensity = Mathf.Lerp(baseIntensity, finalIntensity, p_lifetime / duration); p_lifetime += Time.deltaTime; } else if (autodestruct) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } public class CFX_ShurikenThreadFix : MonoBehaviour { private ParticleSystem[] systems; private void OnEnable() { systems = ((Component)this).GetComponentsInChildren(); ParticleSystem[] array = systems; foreach (ParticleSystem val in array) { val.Stop(true); val.Clear(true); } ((MonoBehaviour)this).StartCoroutine("WaitFrame"); } private IEnumerator WaitFrame() { yield return null; ParticleSystem[] array = systems; foreach (ParticleSystem val in array) { val.Play(true); } } } public class CFX_SpawnSystem : MonoBehaviour { private static CFX_SpawnSystem instance; public GameObject[] objectsToPreload = (GameObject[])(object)new GameObject[0]; public int[] objectsToPreloadTimes = new int[0]; public bool hideObjectsInHierarchy = false; public bool spawnAsChildren = true; public bool onlyGetInactiveObjects = false; public bool instantiateIfNeeded = false; private bool allObjectsLoaded; private Dictionary> instantiatedObjects = new Dictionary>(); private Dictionary poolCursors = new Dictionary(); public static bool AllObjectsLoaded => instance.allObjectsLoaded; public static GameObject GetNextObject(GameObject sourceObj, bool activateObject = true) { int instanceID = ((Object)sourceObj).GetInstanceID(); if (!instance.poolCursors.ContainsKey(instanceID)) { Debug.LogError((object)("[CFX_SpawnSystem.GetNextObject()] Object hasn't been preloaded: " + ((Object)sourceObj).name + " (ID:" + instanceID + ")\n"), (Object)(object)instance); return null; } int num = instance.poolCursors[instanceID]; GameObject val = null; if (instance.onlyGetInactiveObjects) { int num2 = num; while (true) { val = instance.instantiatedObjects[instanceID][num]; instance.increasePoolCursor(instanceID); num = instance.poolCursors[instanceID]; if ((Object)(object)val != (Object)null && !val.activeSelf) { break; } if (num == num2) { if (instance.instantiateIfNeeded) { Debug.Log((object)("[CFX_SpawnSystem.GetNextObject()] A new instance has been created for \"" + ((Object)sourceObj).name + "\" because no active instance were found in the pool.\n"), (Object)(object)instance); PreloadObject(sourceObj); List list = instance.instantiatedObjects[instanceID]; val = list[list.Count - 1]; break; } Debug.LogWarning((object)("[CFX_SpawnSystem.GetNextObject()] There are no active instances available in the pool for \"" + ((Object)sourceObj).name + "\"\nYou may need to increase the preloaded object count for this prefab?"), (Object)(object)instance); return null; } } } else { val = instance.instantiatedObjects[instanceID][num]; instance.increasePoolCursor(instanceID); } if (activateObject && (Object)(object)val != (Object)null) { val.SetActive(true); } return val; } public static void PreloadObject(GameObject sourceObj, int poolSize = 1) { instance.addObjectToPool(sourceObj, poolSize); } public static void UnloadObjects(GameObject sourceObj) { instance.removeObjectsFromPool(sourceObj); } private void addObjectToPool(GameObject sourceObject, int number) { int instanceID = ((Object)sourceObject).GetInstanceID(); if (!instantiatedObjects.ContainsKey(instanceID)) { instantiatedObjects.Add(instanceID, new List()); poolCursors.Add(instanceID, 0); } for (int i = 0; i < number; i++) { GameObject val = Object.Instantiate(sourceObject); val.SetActive(false); CFX_AutoDestructShuriken[] componentsInChildren = val.GetComponentsInChildren(true); CFX_AutoDestructShuriken[] array = componentsInChildren; foreach (CFX_AutoDestructShuriken cFX_AutoDestructShuriken in array) { cFX_AutoDestructShuriken.OnlyDeactivate = true; } CFX_LightIntensityFade[] componentsInChildren2 = val.GetComponentsInChildren(true); CFX_LightIntensityFade[] array2 = componentsInChildren2; foreach (CFX_LightIntensityFade cFX_LightIntensityFade in array2) { cFX_LightIntensityFade.autodestruct = false; } instantiatedObjects[instanceID].Add(val); if (hideObjectsInHierarchy) { ((Object)val).hideFlags = (HideFlags)1; } if (spawnAsChildren) { val.transform.parent = ((Component)this).transform; } } } private void removeObjectsFromPool(GameObject sourceObject) { int instanceID = ((Object)sourceObject).GetInstanceID(); if (!instantiatedObjects.ContainsKey(instanceID)) { Debug.LogWarning((object)("[CFX_SpawnSystem.removeObjectsFromPool()] There aren't any preloaded object for: " + ((Object)sourceObject).name + " (ID:" + instanceID + ")\n"), (Object)(object)((Component)this).gameObject); return; } for (int num = instantiatedObjects[instanceID].Count - 1; num >= 0; num--) { GameObject val = instantiatedObjects[instanceID][num]; instantiatedObjects[instanceID].RemoveAt(num); Object.Destroy((Object)(object)val); } instantiatedObjects.Remove(instanceID); poolCursors.Remove(instanceID); } private void increasePoolCursor(int uniqueId) { instance.poolCursors[uniqueId]++; if (instance.poolCursors[uniqueId] >= instance.instantiatedObjects[uniqueId].Count) { instance.poolCursors[uniqueId] = 0; } } private void Awake() { if ((Object)(object)instance != (Object)null) { Debug.LogWarning((object)"CFX_SpawnSystem: There should only be one instance of CFX_SpawnSystem per Scene!\n", (Object)(object)((Component)this).gameObject); } instance = this; } private void Start() { allObjectsLoaded = false; for (int i = 0; i < objectsToPreload.Length; i++) { PreloadObject(objectsToPreload[i], objectsToPreloadTimes[i]); } allObjectsLoaded = true; } } namespace Sora_101_Ven.Motofreak_PlayerBody { [BepInPlugin("Sora_101_Ven.Motofreak_PlayerBody", "Motofreak_PlayerBody", "1.0.0")] [BepInProcess("h3vr.exe")] [Description("Built with MeatKit")] [BepInDependency("h3vr.otherloader", "1.3.0")] [BepInDependency("VIP.TommySoucy.H3MP", "1.7.0")] public class Motofreak_PlayerBodyPlugin : BaseUnityPlugin { private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); internal static ManualLogSource Logger; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; LoadAssets(); } private void LoadAssets() { OtherLoader.RegisterDirectLoad(BasePath, "Sora_101_Ven.Motofreak_PlayerBody", "", "", "motofreakpb", ""); GameManager.AddPlayerPrefabID("Motofreak PlayerBody"); } } } namespace JerryComponent { public class BlinkCal : MonoBehaviour { public SkinnedMeshRenderer skin; private float blendOne = 0f; private float blendSpeed = 100f; private bool blinked; private float nextTime; private float rate = 5f; private void Start() { ((MonoBehaviour)this).InvokeRepeating("blinkeyes25", 5.02f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes50", 5.04f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes75", 5.06f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes100", 5.08f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes0", 5.1f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes25", 5.12f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes50", 5.14f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes75", 5.16f, 5f); } public void blinkeyes25() { skin.SetBlendShapeWeight(5, 25f); } public void blinkeyes50() { skin.SetBlendShapeWeight(5, 50f); } public void blinkeyes75() { skin.SetBlendShapeWeight(5, 75f); } public void blinkeyes100() { skin.SetBlendShapeWeight(5, 100f); } public void openeyes0() { skin.SetBlendShapeWeight(5, 75f); } public void openeyes25() { skin.SetBlendShapeWeight(5, 50f); } public void openeyes50() { skin.SetBlendShapeWeight(5, 25f); } public void openeyes75() { skin.SetBlendShapeWeight(5, 0f); } private void Update() { } } public class BlinkCustom : MonoBehaviour { public SkinnedMeshRenderer skin; public int num; private float blendOne = 0f; private float blendSpeed = 100f; private bool blinked; private float nextTime; private float rate = 5f; private void Start() { ((MonoBehaviour)this).InvokeRepeating("blinkeyes25", 5.02f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes50", 5.04f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes75", 5.06f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes100", 5.08f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes0", 5.1f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes25", 5.12f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes50", 5.14f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes75", 5.16f, 5f); } public void blinkeyes25() { skin.SetBlendShapeWeight(num, 25f); } public void blinkeyes50() { skin.SetBlendShapeWeight(num, 50f); } public void blinkeyes75() { skin.SetBlendShapeWeight(num, 75f); } public void blinkeyes100() { skin.SetBlendShapeWeight(num, 100f); } public void openeyes0() { skin.SetBlendShapeWeight(num, 75f); } public void openeyes25() { skin.SetBlendShapeWeight(num, 50f); } public void openeyes50() { skin.SetBlendShapeWeight(num, 25f); } public void openeyes75() { skin.SetBlendShapeWeight(num, 0f); } private void Update() { } } public class BlinkLena : MonoBehaviour { public SkinnedMeshRenderer skin; private float blendOne = 0f; private float blendSpeed = 100f; private bool blinked; private float nextTime; private float rate = 5f; private void Start() { ((MonoBehaviour)this).InvokeRepeating("blinkeyes25", 5.02f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes50", 5.04f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes75", 5.06f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes100", 5.08f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes0", 5.1f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes25", 5.12f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes50", 5.14f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes75", 5.16f, 5f); } public void blinkeyes25() { skin.SetBlendShapeWeight(44, 25f); } public void blinkeyes50() { skin.SetBlendShapeWeight(44, 50f); } public void blinkeyes75() { skin.SetBlendShapeWeight(44, 75f); } public void blinkeyes100() { skin.SetBlendShapeWeight(44, 100f); } public void openeyes0() { skin.SetBlendShapeWeight(44, 75f); } public void openeyes25() { skin.SetBlendShapeWeight(44, 50f); } public void openeyes50() { skin.SetBlendShapeWeight(44, 25f); } public void openeyes75() { skin.SetBlendShapeWeight(44, 0f); } private void Update() { } } public class BlinkLyn : MonoBehaviour { public SkinnedMeshRenderer skin; private float blendOne = 0f; private float blendSpeed = 100f; private bool blinked; private float nextTime; private float rate = 5f; private void Start() { ((MonoBehaviour)this).InvokeRepeating("blinkeyes25", 5.02f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes50", 5.04f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes75", 5.06f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes100", 5.08f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes0", 5.1f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes25", 5.12f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes50", 5.14f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes75", 5.16f, 5f); } public void blinkeyes25() { skin.SetBlendShapeWeight(4, 25f); } public void blinkeyes50() { skin.SetBlendShapeWeight(4, 50f); } public void blinkeyes75() { skin.SetBlendShapeWeight(4, 75f); } public void blinkeyes100() { skin.SetBlendShapeWeight(4, 100f); } public void openeyes0() { skin.SetBlendShapeWeight(4, 75f); } public void openeyes25() { skin.SetBlendShapeWeight(4, 50f); } public void openeyes50() { skin.SetBlendShapeWeight(4, 25f); } public void openeyes75() { skin.SetBlendShapeWeight(4, 0f); } private void Update() { } } public class BlinkShinra : MonoBehaviour { public SkinnedMeshRenderer skin; private float blendOne = 0f; private float blendSpeed = 100f; private bool blinked; private float nextTime; private float rate = 5f; private void Start() { ((MonoBehaviour)this).InvokeRepeating("blinkeyes25", 5.02f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes50", 5.04f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes75", 5.06f, 5f); ((MonoBehaviour)this).InvokeRepeating("blinkeyes100", 5.08f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes0", 5.1f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes25", 5.12f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes50", 5.14f, 5f); ((MonoBehaviour)this).InvokeRepeating("openeyes75", 5.16f, 5f); } public void blinkeyes25() { skin.SetBlendShapeWeight(9, 25f); } public void blinkeyes50() { skin.SetBlendShapeWeight(9, 50f); } public void blinkeyes75() { skin.SetBlendShapeWeight(9, 75f); } public void blinkeyes100() { skin.SetBlendShapeWeight(9, 100f); } public void openeyes0() { skin.SetBlendShapeWeight(9, 75f); } public void openeyes25() { skin.SetBlendShapeWeight(9, 50f); } public void openeyes50() { skin.SetBlendShapeWeight(9, 25f); } public void openeyes75() { skin.SetBlendShapeWeight(9, 0f); } private void Update() { } } }