using System;
using KINEMATION.MagicBlend.Runtime;
using RootMotion.FinalIK;
using UnityEngine;

namespace NBF
{
    public class PlayerModelAsset : MonoBehaviour
    {
        public Animator Animator { get; private set; }
        public PlayerIK IK { get; private set; }
        public PlayerAnimator PlayerAnimator { get; private set; }
        public MagicBlending MagicBlending { get; private set; }

        public Transform NeckTransform;
        public LookAtIK LookIk;

        public PlayerArm LeftArm;
        public PlayerArm RightArm;


        public Transform RodRoot
        {
            get
            {
                if (RightArm == null)
                {
                    return transform;
                }

                return RightArm.RodContainer;
            }
        }
        // public Transform RodRoot;


        private void Awake()
        {
            LookIk = GetComponent<LookAtIK>();
            Animator = GetComponent<Animator>();
            Animator.keepAnimatorStateOnDisable = true;
            MagicBlending = GetComponent<MagicBlending>();
            IK = GetComponent<PlayerIK>();
            PlayerAnimator = GetComponent<PlayerAnimator>();
        }

        public void SetPlayer(FPlayer player)
        {
            LookIk.solver.target = player.FppLook;
        }
    }
}