using Godot;
using Rokojori;

[GlobalClass]
public partial class FollowPath : Action
{
  [Export]
  public Spline spline;

  [Export]
  public Node3D target;

  [Export]
  public float duration;

  [Export]
  public TimeLine timeLine;

  SplineCurve _curve;
  protected override void _OnTrigger()
  {
    var phase = timeLine.ComputePhase( duration ); 

    if ( _curve == null )
    {
      _curve = spline.GetCurve();
    }

    var pose = _curve.PoseAt( phase );
    
    pose.Set( target );
  }

}
