/// <summary> /// Returns an integer indicating if the /// </summary> /// <param name="startCoordinate"></param> /// <param name="sizeToCheck"></param> /// <param name="heightOffset"></param> /// <returns></returns> private PathCoordinate GetSafeCoordinate(UniversalCoords startCoordinate, Size sizeToCheck, int heightOffset) { // Given a coordinate, determine if it is safe to move to allowing Y +- 1 and taking into consideration size of space to check PathCoordinate result = null; if (heightOffset > 0 && CheckOffset(startCoordinate.Offset(0, heightOffset, 0), sizeToCheck) == 1) startCoordinate = startCoordinate.Offset(0, heightOffset, 0); result = GetCoordinateFromCacheOrAdd(startCoordinate); if (result != null) { // Check down the Y axis for unsafe blocks int checkOffsetResult = 0; int loopCount = 0; while(startCoordinate.WorldY > 0 && (checkOffsetResult = CheckOffset(startCoordinate.Offset(0, -1, 0), sizeToCheck)) == 1) { if (++loopCount >= 4) { return null; } startCoordinate = startCoordinate.Offset(0, -1, 0); if (startCoordinate.WorldY > 0) { result = GetCoordinateFromCacheOrAdd(startCoordinate); } } if (checkOffsetResult == -2) { return null; // Lava } } return result; }
/// <summary> /// Returns an integer indicating if the /// </summary> /// <param name="startCoordinate"></param> /// <param name="sizeToCheck"></param> /// <param name="heightOffset"></param> /// <returns></returns> private PathCoordinate GetSafeCoordinate(UniversalCoords startCoordinate, Size sizeToCheck, int heightOffset) { PathCoordinate result = null; if (heightOffset > 0 && CheckOffset(startCoordinate.Offset(0, heightOffset, 0), sizeToCheck) == 1) startCoordinate = startCoordinate.Offset(0, heightOffset, 0); result = GetCoordinateFromCacheOrAdd(startCoordinate); if (result != null) { // Check down the Y axis for unsafe blocks int checkOffsetResult = 0; int loopCount = 0; while(startCoordinate.WorldY > 0 && (checkOffsetResult = CheckOffset(startCoordinate.Offset(0, -1, 0), sizeToCheck)) == 1) { if (++loopCount >= 4) { return null; } startCoordinate = startCoordinate.Offset(0, -1, 0); if (startCoordinate.WorldY > 0) { result = GetCoordinateFromCacheOrAdd(startCoordinate); } } if (checkOffsetResult == -2) { return null; // Lava } } return result; }