using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UnitWaypoint : Waypoint {
	private Vertex oldPosition;
	private DeployedUnit target;

	public UnitWaypoint(DeployedUnit target) {
		this.oldPosition = target.getPosition();
		this.target = target;
	}

	override public Vertex getVertex() {
		return target.getPosition();
	}

	override public bool isTooFar() {
		return oldPosition.distance(getVertex()) > Constants.MIN_DISTANCE_WAYPOINTS_UPDATE;
	}

	override public bool isValid() {
		return GameController.fromID(target.getID()) != null;
	}

	override public void resetInfo() {
		oldPosition = target.getPosition();
	}

	public DeployedUnit getTarget() {
		return target;
	}
}
