HeightIKCtrlData.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using RootMotion.FinalIK;
  3. using UnityEngine;
  4. [Serializable]
  5. public class HeightIKCtrlData : CCDIKCtrlData
  6. {
  7. public HeightIKCtrlData(CCDIK ccd_ik, Transform[] chain_bones, FullBodyIKCtrl ik_ctrl, bool weight_fade = true, bool attach_ik = false) : base(ccd_ik, chain_bones, ik_ctrl, weight_fade, attach_ik)
  8. {
  9. }
  10. public void CheckReachTarget()
  11. {
  12. if (!base.PointIK.IsIKExec || base.PointIK.BlendType == IKCtrlData.IKBlendType.IK_To_Detach)
  13. {
  14. return;
  15. }
  16. float num = Vector3.Distance(base.IKTarget.position, this.TargetBone.position);
  17. if (num <= 0.05f || (num > 1f && base.PointIK.BlendNow))
  18. {
  19. return;
  20. }
  21. int value = this.MyIKCtrl.TgtMaid.GetProp(MPN.sintyou).value;
  22. int value2 = base.PointIK.TgtMaid.GetProp(MPN.sintyou).value;
  23. if (this.m_EachOtherIK && value < value2)
  24. {
  25. IKCtrlData ikdata = base.PointIK.TgtMaid.IKCtrl.GetIKData(base.PointIK.Tgt_AttachName, false);
  26. if (base.PointIK.TgtMaid.IKCtrl.IsUpdateEnd)
  27. {
  28. ikdata.IKTarget.position += (this.TargetBone.position - base.IKTarget.position) * ikdata.PointIK.BlendWeight;
  29. base.PointIK.TgtMaid.IKCtrl.SolverUpdate();
  30. }
  31. }
  32. else if (!this.MyIKCtrl.DoHeightCover && !base.PointIK.BlendNow)
  33. {
  34. Vector3 vector = base.IKTarget.position - this.TargetBone.position;
  35. this.MyIKCtrl.BodyTarget.position += vector;
  36. foreach (IKCtrlData ikctrlData in this.MyIKCtrl.strIKDataPair.Values)
  37. {
  38. ikctrlData.SetTargetOffset(vector, false);
  39. }
  40. this.MyIKCtrl.BodyEffector.positionWeight = 1f;
  41. }
  42. this.MyIKCtrl.DoHeightCover = true;
  43. }
  44. public override void Update()
  45. {
  46. base.Update();
  47. this.CheckReachTarget();
  48. }
  49. }