using System; using RootMotion.FinalIK; using UnityEngine; [Serializable] public class ShoulderThighIKData : LimbIKData { public ShoulderThighIKData(IKEffector root_effector, FBIKChain chain, IKMappingLimb ik_mapping, FullBodyIKCtrl ik_ctrl, Transform tgt_bone) : base(ik_ctrl, chain, ik_mapping, tgt_bone, false) { this.Effector = root_effector; this.Effector.target = base.IKTarget; this.m_IsUpperBody = (this.TargetBone == this.MyIKCtrl.GetIKBone(FullBodyIKCtrl.IKBoneType.UpperArm_L) || this.TargetBone == this.MyIKCtrl.GetIKBone(FullBodyIKCtrl.IKBoneType.UpperArm_R)); this.m_ForceIKEnable = true; } public ElbowKneeIKData ElbowKneeData { get { return this.m_ElbowKneeData; } } public HandFootIKData HandFootData { get { return this.m_HandFootData; } } protected override void SetTargetTransform(IKCtrlData.IKSettingData data, Vector3 pos, Quaternion rot) { base.SetTargetTransform(data, pos, rot); Transform iktarget = this.m_HandFootData.IKTarget; Transform iktarget2 = this.m_ElbowKneeData.IKTarget; Vector3 position = this.TargetBone.InverseTransformPoint(this.m_ElbowKneeData.TargetBone.position); Vector3 position2 = this.m_ElbowKneeData.TargetBone.InverseTransformPoint(this.m_HandFootData.TargetBone.position); if (!data.IsPointAttach) { if (!this.m_ElbowKneeData.GetIKSettingData(IKCtrlData.IKAttachType.Rotate).IsIKExec) { iktarget2.rotation = base.IKTarget.rotation * this.m_ElbowKneeData.TargetBone.localRotation; } if (!this.m_HandFootData.GetIKSettingData(IKCtrlData.IKAttachType.Rotate).IsIKExec) { iktarget.rotation = iktarget2.rotation * this.m_HandFootData.TargetBone.localRotation; } } if (!this.m_ElbowKneeData.GetIKSettingData(IKCtrlData.IKAttachType.NewPoint).IsIKExec) { iktarget2.position = base.IKTarget.TransformPoint(position); } if (!this.m_HandFootData.GetIKSettingData(IKCtrlData.IKAttachType.NewPoint).IsIKExec) { iktarget.position = iktarget2.TransformPoint(position2); } } public void SetChainData(HandFootIKData handfoot_data, ElbowKneeIKData elbowknee_data) { this.m_HandFootData = handfoot_data; this.m_ElbowKneeData = elbowknee_data; } protected override void OnPostSetPositionWeight(float val) { if (this.m_IsPullBody) { this.Effector.positionWeight = val; } } protected override void OnPostSetRotationWeight(float val) { if (this.m_IsPullBody) { this.Effector.rotationWeight = val; } } public override void Update() { if (!this.m_IsPullBody && base.RotateIK.IsIKExec) { this.TargetBone.rotation = Quaternion.Lerp(this.TargetBone.rotation, base.IKTarget.rotation, base.RotationWeight); } } public readonly IKEffector Effector; private ElbowKneeIKData m_ElbowKneeData; private HandFootIKData m_HandFootData; }