using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;

namespace NodeCanvas.Tasks.Conditions {

	[Category("Core/Input")]
	[Description("Returns a float from two Vector3s")]
	public class GetMovementInputDotProduct : ConditionTask<PlayerControls>{
		[SliderField(0f,1f)]
		public BBParameter<Vector3> desiredVector3;
		public BBParameter<float> tolerance;
		public BBParameter<bool> negate;

		//Use for initialization. This is called only once in the lifetime of the task.
		//Return null if init was successfull. Return an error string otherwise
		protected override string OnInit(){
			return null;
		}

		//This is called once each time the task is enabled.
		//Call EndAction() to mark the action as finished, either in success or failure.
		//EndAction can be called from anywhere.
		protected override bool OnCheck(){
			Vector3 rawInputVector3 = new(agent.rawMoveInput.x, 0f, agent.rawMoveInput.y);
			float dotProduct = Vector3.Dot(desiredVector3.value, rawInputVector3);
			
			//Debug.Log(dotProduct);

			if (dotProduct < tolerance.value) {
				return true;
			}

			return false;
		}
		
		//Called when the task is disabled.
		protected override void OnEnable() {
			
		}

		//Called when the task is paused.
		protected override void OnDisable() {
			
		}
	}
}