private void UpdatePath()
    {
        recomputePathTimer -= Time.deltaTime;
        if (recomputePathTimer <= 0 && movementState != MovementBehaviorState.WANDER)
        {
            GetNewPath();
            movementState      = MovementBehaviorState.PURSUE;
            recomputePathTimer = recomputePathTime;
        }

        float distanceToTarget = Vector2.Distance(targetLocation, transform.position);
        float epsilon          = movementState == MovementBehaviorState.ARRIVE ? arriveEpsilon : pursueEpsilon;

        if (distanceToTarget <= epsilon && pathToFollow != null)
        {
            if (pathIndex >= pathToFollow.trimmedPathCoordList.Count - 1)
            {
                movementState  = MovementBehaviorState.ARRIVE;
                targetLocation = transform.position;
                return;
            }
            pathIndex++;
            targetLocation = pathToFollow.trimmedPathCoordList[pathIndex];
        }
    }
 public void RefocusToVision()
 {
     if (IsPlayerSeen() && movementState != MovementBehaviorState.ARRIVE)
     {
         ForceUpdatePath(player.transform.position);
         movementState = MovementBehaviorState.PURSUE;
     }
 }
 // Start is called before the first frame update
 void Start()
 {
     movementState        = MovementBehaviorState.WANDER;
     targetLocation       = transform.position;
     recomputePathTimer   = 3f;
     targetForPathfinding = transform.position;
     player = FindObjectOfType <PlayerMovement>();
 }
 public void ChangeMovementState(MovementBehaviorState state)
 {
     this.movementState = state;
 }