private Volume LargestVolume_Iterate(CoordinateInt origin, bool allowInvisible)
        {
            Volume largestVolume = new Volume();

            int maxX = 0;

            while (SearchAllBlocks(origin.Offset(maxX, 0, 0), allowInvisible))
            {
                maxX++;
            }
            int maxY = 0;

            while (SearchAllBlocks(origin.Offset(0, maxY, 0), allowInvisible))
            {
                maxY++;
            }
            int maxZ = 0;

            while (SearchAllBlocks(origin.Offset(0, 0, maxZ), allowInvisible))
            {
                maxZ++;
            }

            for (int extentZ = maxZ; extentZ >= 0; extentZ--)
            {
                for (int extentY = maxY; extentY >= 0; extentY--)
                {
                    for (int extentX = maxX; extentX >= 0; extentX--)
                    {
                        int lengthX = extentX + 1;
                        int lengthY = extentY + 1;
                        int lengthZ = extentZ + 1;

                        /* Don't bother considering this volume if it won't get used. */
                        if (lengthX * lengthY * lengthZ <= largestVolume.TotalVolume)
                        {
                            continue;
                        }

                        if (LargestVolume_Valid(origin, lengthX, lengthY, lengthZ, allowInvisible))
                        {
                            int totalVolume = lengthX * lengthY * lengthZ;
                            if (totalVolume >= largestVolume.TotalVolume)
                            {
                                largestVolume = new Volume(origin, lengthX, lengthY, lengthZ);
                            }
                        }
                        //else
                        //  break;
                    }
                }
            }
            return(largestVolume);
        }
示例#2
0
 private static bool ObstructedScanYZ(CoordinateInt coord, int offsetX, int height, int length, HashSet<CoordinateInt> blockCheck)
 {
     for (int dY = 0; dY < height; dY++)
         for (int dZ = 0; dZ < length; dZ++)
             if (!blockCheck.Contains(coord.Offset(offsetX, dY, dZ))) return false;
     totalHiddenFaces++;
     return true;
 }
示例#3
0
 private static bool ObstructedScanXZ(CoordinateInt coord, int width, int offsetY, int length, HashSet<CoordinateInt> blockCheck)
 {
     for (int dX = 0; dX < width; dX++)
         for (int dZ = 0; dZ < length; dZ++)
             if (!blockCheck.Contains(coord.Offset(dX, offsetY, dZ))) return false;
     totalHiddenFaces++;
     return true;
 }
示例#4
0
 private static bool ObstructedScanXY(CoordinateInt coord, int width, int height, int offsetZ, HashSet<CoordinateInt> blockCheck)
 {
     for (int dX = 0; dX < width; dX++)
         for (int dY = 0; dY < height; dY++)
             if (!blockCheck.Contains(coord.Offset(dX, dY, offsetZ))) return false;
     totalHiddenFaces++;
     return true;
 }
示例#5
0
 private static bool ObstructedScanXY(CoordinateInt coord, int width, int height, int offsetZ, HashSet <CoordinateInt> blockCheck)
 {
     for (int dX = 0; dX < width; dX++)
     {
         for (int dY = 0; dY < height; dY++)
         {
             if (!blockCheck.Contains(coord.Offset(dX, dY, offsetZ)))
             {
                 return(false);
             }
         }
     }
     totalHiddenFaces++;
     return(true);
 }
示例#6
0
 private static bool ObstructedScanYZ(CoordinateInt coord, int offsetX, int height, int length, HashSet <CoordinateInt> blockCheck)
 {
     for (int dY = 0; dY < height; dY++)
     {
         for (int dZ = 0; dZ < length; dZ++)
         {
             if (!blockCheck.Contains(coord.Offset(offsetX, dY, dZ)))
             {
                 return(false);
             }
         }
     }
     totalHiddenFaces++;
     return(true);
 }
示例#7
0
 private static bool ObstructedScanXZ(CoordinateInt coord, int width, int offsetY, int length, HashSet <CoordinateInt> blockCheck)
 {
     for (int dX = 0; dX < width; dX++)
     {
         for (int dZ = 0; dZ < length; dZ++)
         {
             if (!blockCheck.Contains(coord.Offset(dX, offsetY, dZ)))
             {
                 return(false);
             }
         }
     }
     totalHiddenFaces++;
     return(true);
 }
示例#8
0
 private static bool IsInvisible(CoordinateInt coord, Dictionary<CoordinateInt, Block> rawWorld)
 {
     bool isInvisible =
         OpaqueBrickAt(coord.Offset(-1, 0, 0), rawWorld) &&
         OpaqueBrickAt(coord.Offset(1, 0, 0), rawWorld) &&
         OpaqueBrickAt(coord.Offset(0, -1, 0), rawWorld) &&
         OpaqueBrickAt(coord.Offset(0, 1, 0), rawWorld) &&
         OpaqueBrickAt(coord.Offset(0, 0, -1), rawWorld) &&
         OpaqueBrickAt(coord.Offset(0, 0, 1), rawWorld);
     return isInvisible;
 }
 private bool LargestVolume_Valid(CoordinateInt coord, int lengthX, int lengthY, int lengthZ, bool allowInvisible)
 {
     for (int gZ = lengthZ - 1; gZ >= 0; gZ--)
     {
         for (int gY = lengthY - 1; gY >= 0; gY--)
         {
             for (int gX = lengthX - 1; gX >= 0; gX--)
             {
                 if (!SearchAllBlocks(coord.Offset(gX, gY, gZ), allowInvisible))
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
示例#10
0
        private static bool IsInvisible(CoordinateInt coord, Dictionary <CoordinateInt, Block> rawWorld)
        {
            bool isInvisible =
                OpaqueBrickAt(coord.Offset(-1, 0, 0), rawWorld) &&
                OpaqueBrickAt(coord.Offset(1, 0, 0), rawWorld) &&
                OpaqueBrickAt(coord.Offset(0, -1, 0), rawWorld) &&
                OpaqueBrickAt(coord.Offset(0, 1, 0), rawWorld) &&
                OpaqueBrickAt(coord.Offset(0, 0, -1), rawWorld) &&
                OpaqueBrickAt(coord.Offset(0, 0, 1), rawWorld);

            return(isInvisible);
        }