fBaseXtensions.Navigation.Gridpoint.GPQuadrant.FindSafeSpot C# (CSharp) Method

FindSafeSpot() public method

Searches through the contained GridPoints and preforms multiple tests to return a successful point for navigation.
public FindSafeSpot ( System.Vector3 CurrentLocation, System.Vector3 &safespot, System.Vector3 LoSCheckV3, PointCheckingFlags Flags, List BlacklistedPoints ) : bool
CurrentLocation System.Vector3
safespot System.Vector3
LoSCheckV3 System.Vector3
Flags PointCheckingFlags
BlacklistedPoints List
return bool
        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;
        }