public bool FindSafeSpot(Vector3 CurrentLocation, out Vector3 safespot, Vector3 LoSCheckV3, PointCheckingFlags Flags, List<GridPoint> BlacklistedPoints)
{
bool PassedPointNonLOS = false;
bool CheckingLOSV3 = LoSCheckV3 != Vector3.Zero;
for (int curIndex = LastIndexUsed; curIndex < ContainedPoints.Count - 1; curIndex++)
{
GridPoint gp = ContainedPoints[curIndex];
if (BlacklistedPoints.Contains(gp)) continue;
if (!CheckPoint(gp, LoSCheckV3, Flags)) continue;
//LOS Check
if (CheckingLOSV3)
{
if (!Navigation.CheckVectorFlags((Vector3)gp, LoSCheckV3, PointCheckingFlags.AvoidanceOverlap | PointCheckingFlags.RaycastNavProvider))
{
LastIndexUsed = curIndex;
PassedPointNonLOS = true;
continue;
}
}
//PointChecker passed!
LastIndexUsed = curIndex;
safespot = LastSafespotFound;
return true;
}
//Did we find a valid point that didn't pass LOS?
if (PassedPointNonLOS)
{
safespot = LastSafespotFound;
return true;
}
LastSafespotFound = Vector3.Zero;
safespot = LastSafespotFound;
LastIndexUsed = 0;
return false;
}