using System; using System.Linq; using RootMotion.FinalIK; using UnityEngine; public abstract class LimbIKData : IKCtrlData { public LimbIKData(FullBodyIKCtrl ik_ctrl, FBIKChain chain, IKMappingLimb ik_mapping, Transform tgt_bone, bool use_old = false) : base(ik_ctrl, tgt_bone, use_old, false) { this.Chain = chain; this.IKMapping = ik_mapping; this.m_ChainBones = (from node in this.Chain.nodes select node.transform).ToArray(); } public override bool NeedFullbodySolverUpdate { get { return base.IsIKExec && !base.OldIkExec && this.m_IsPullBody; } } public override void SetPullState(bool pull_on) { this.m_IsPullBody = pull_on; if (this.m_OrijinPull < 0f) { this.m_OrijinPull = this.Chain.pull; } if (pull_on) { this.Chain.pull = this.m_OrijinPull; } else { this.Chain.pull = 0.1f; } } public override void TagetTransCpy() { base.TagetTransCpy(); if (this.m_IsUpperBody) { this.IKMapping.weight = 0f; } } public override void ApplyIKSetting() { base.ApplyIKSetting(); if (this.m_IsUpperBody) { this.IKMapping.weight = Mathf.Max(this.IKMapping.weight, Mathf.Max(base.PositionWeight, base.RotationWeight)); } } public readonly FBIKChain Chain; public readonly IKMappingLimb IKMapping; protected bool m_IsUpperBody; protected float m_OrijinPull = -1f; protected bool m_IsPullBody = true; }