using UnityEngine;
using System.Collections;
namespace RootMotion.FinalIK {
	/// 
	/// The base abstract class for all class that are translating a hierarchy of bones to match the translation of bones in another hierarchy.
	/// 
	public abstract class Poser: SolverManager {
		/// 
		/// Reference to the other Transform (should be identical to this one)
		/// 
		public Transform poseRoot;
		/// 
		/// The master weight.
		/// 
		[Range(0f, 1f)] public float weight = 1f;
		/// 
		/// Weight of localRotation matching
		/// 
		[Range(0f, 1f)] public float localRotationWeight = 1f;
		/// 
		/// Weight of localPosition matching
		/// 
		[Range(0f, 1f)] public float localPositionWeight;
		/// 
		/// Map this instance to the poseRoot.
		/// 
		public abstract void AutoMapping();
		public virtual void AutoMapping(Transform[] bones) { }
		/// 
		/// For manual update of the poser.
		/// 
		public void UpdateManual() {
			UpdatePoser();
		}
		private bool initiated;
		protected abstract void InitiatePoser();
		protected abstract void UpdatePoser();
		protected abstract void FixPoserTransforms();
		/*
		 * Updates the solver. If you need full control of the execution order of your IK solvers, disable this script and call UpdateSolver() instead.
		 * */
		protected override void UpdateSolver() {
			if (!initiated) InitiateSolver();
			if (!initiated) return;
			
			UpdatePoser();
		}
		
		/*
		 * Initiates the %IK solver
		 * */
		protected override void InitiateSolver() {
			if (initiated) return;
			InitiatePoser();
			initiated = true;
		}
		
		protected override void FixTransforms() {
			if (!initiated) return;
 			FixPoserTransforms();
		}
	}
}