using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Animations.Rigging;

namespace VOID.Generic.Objects.Unit.Animations.Helpers
{
    public struct ExtractTransformConstraintJob : IWeightedAnimationJob
    {
        public ReadWriteTransformHandle bone;

        public FloatProperty jobWeight { get; set; }
  
        public Vector3Property position;
        public Vector4Property rotation;
  
        public void ProcessRootMotion(AnimationStream stream)
        { }
  
        public void ProcessAnimation(AnimationStream stream)
        {
            AnimationRuntimeUtils.PassThrough(stream, this.bone);

            var pos = this.bone.GetPosition(stream);
            var rot = this.bone.GetRotation(stream);
      
            this.position.Set(stream, pos);
            this.rotation.Set(stream, new Vector4(rot.x, rot.y, rot.z, rot.w));
        }
    }
}