public int findNextUnoccupiedNode(Vector2 pos) { int i = currentPath.getClosestSegement(pos); for (; i < currentPath.Length; i++) { int[] mapCoords = Map.map.worldToMapPoint(currentPath[i]); if (Map.map.getObj(mapCoords) == null) { break; } } return(i); }