public static bool CheckPositionForSkipping(Vector3 Position)
{
foreach (var v in UsedSkipAheadAreaCache)
{
if (Position.Distance(v.Position) <= v.Radius)
return true;
}
bool valid = false;
if (SkipAheadAreaCache.Count > 0)
{
int validIndex = -1;
for (int i = 0; i < SkipAheadAreaCache.Count - 1; i++)
{
SkipAheadNavigation v = SkipAheadAreaCache[i];
if (Position.Distance(v.Position) <= v.Radius)
{
validIndex = i;
valid = true;
break;
}
}
if (valid && validIndex > 0)
{
UsedSkipAheadAreaCache.Add(SkipAheadAreaCache[validIndex].Clone());
SkipAheadAreaCache.RemoveRange(0, validIndex - 1);
SkipAheadAreaCache.TrimExcess();
}
}
return valid;
}