using System;
using System.Linq;
using RootMotion.FinalIK;
using UnityEngine;

[Serializable]
public class CCDIKCtrlData : IKCtrlData
{
	public CCDIKCtrlData(CCDIK ccd_ik, Transform[] chain_bones, FullBodyIKCtrl ik_ctrl, bool weight_fade = true, bool attach_ik = false) : base(ik_ctrl, chain_bones.Last<Transform>(), false, attach_ik)
	{
		this.CCDIK = ccd_ik;
		this.CCDIK.fixTransforms = false;
		this.IKSolver.target = base.IKTarget;
		this.IKSolver.useRotationLimits = false;
		this.IKSolver.maxIterations = 4;
		this.IKSolver.Initiate(chain_bones[0]);
		this.IKSolver.SetChain(chain_bones, chain_bones[0]);
		if (weight_fade)
		{
			this.IKSolver.FadeOutBoneWeights();
		}
		this.CCDIK.enabled = false;
		this.m_ForceIKEnable = false;
	}

	public IKSolverCCD IKSolver
	{
		get
		{
			return this.CCDIK.solver;
		}
	}

	public override Transform[] ChainBones
	{
		get
		{
			return (from bone in this.IKSolver.bones
			select bone.transform).ToArray<Transform>();
		}
	}

	public override float PositionWeight
	{
		get
		{
			return this.IKSolver.IKPositionWeight;
		}
		set
		{
			this.IKSolver.IKPositionWeight = value;
		}
	}

	public override float RotationWeight { get; set; }

	public override void Update()
	{
		this.CCDIK.solver.Update();
	}

	public readonly CCDIK CCDIK;
}
