public CoverSpot GetCoverTowardsTarget(Soldier soldier, Vector3 targetPosition, float maxAttackDistance, float minAttackDistance, CoverSpot prevCoverSpot)
    {
        CoverSpot bestCover       = null;
        Vector3   soldierPosition = soldier.transform.position;

        CoverSpot[] possibleCoverSpots = unOccupiedCoverSpots.ToArray();

        for (int i = 0; i < possibleCoverSpots.Length; i++)
        {
            CoverSpot spot = possibleCoverSpots[i];

            if (!spot.IsOccupied() && spot.AmICoveredFrom(targetPosition) && Vector3.Distance(spot.transform.position, targetPosition) >= minAttackDistance && !CoverIsPastEnemyLine(soldier, spot))
            {
                if (bestCover == null)
                {
                    bestCover = spot;
                }
                else if (prevCoverSpot != spot && Vector3.Distance(bestCover.transform.position, soldierPosition) > Vector3.Distance(spot.transform.position, soldierPosition) && Vector3.Distance(spot.transform.position, targetPosition) < Vector3.Distance(soldierPosition, targetPosition))
                {
                    if (Vector3.Distance(spot.transform.position, soldierPosition) < Vector3.Distance(targetPosition, soldierPosition))
                    {
                        bestCover = spot;
                    }
                }
            }
        }

        if (bestCover != null)
        {
            bestCover.SetOccupier(soldier.transform);
            AddToOccupied(bestCover);
        }

        return(bestCover);
    }
    public void ExitCover(CoverSpot spot)
    {
        if (spot != null)
        {
            spot.SetOccupier(null);

            AddToUnoccupied(spot);
        }
    }