示例#1
0
 public static void MakeMineshaft(BetaWorld world, BlockManager bm, int intFarmLength, int intMapLength, Buildings.structPoint spMineshaftEntrance)
 {
     _intBlockStartBuildings = intFarmLength + 13;
     int intMineshaftSize = (1 + intMapLength) - (_intBlockStartBuildings * 2);
     if (intMineshaftSize % 5 > 0)
     {
         intMineshaftSize += 5 - (intMineshaftSize % 5);
     }
     _intBlockStartBuildings -= 2;
     for (int intLevel = 1; intLevel <= 7; intLevel++)
     {
         MakeLevel(world, bm, intLevel, intMineshaftSize, spMineshaftEntrance);
     }
     int intBlockToReplace = bm.GetID(spMineshaftEntrance.x, 63, spMineshaftEntrance.z + 1);
     BlockShapes.MakeSolidBox(spMineshaftEntrance.x, spMineshaftEntrance.x,
                              3, 63, spMineshaftEntrance.z + 1, spMineshaftEntrance.z + 1, BlockType.WOOD, 0);
     BlockHelper.MakeLadder(spMineshaftEntrance.x, 4, 63, spMineshaftEntrance.z, 0, BlockType.WOOD);
     BlockShapes.MakeSolidBox(spMineshaftEntrance.x, spMineshaftEntrance.x, 3, 63, spMineshaftEntrance.z + 1,
                              spMineshaftEntrance.z + 1, BlockType.STONE, 0);
     bm.SetID(spMineshaftEntrance.x, 63, spMineshaftEntrance.z + 1, intBlockToReplace);
 }
示例#2
0
 public static void PositionRails(BetaWorld worldDest, BlockManager bm, int intCitySize)
 {
     int intReplaced = 0;
     for (int x = 0; x < intCitySize; x++)
     {
         for (int z = 0; z < intCitySize; z++)
         {
             for (int y = 0; y < 128; y++)
             {
                 if (bm.GetID(x, y, z) == BlockType.RAILS)
                 {
                     BlockHelper.MakeRail(x, y, z);
                     if (++intReplaced > 100)
                     {
                         worldDest.Save();
                         intReplaced = 0;
                     }
                 }
             }
         }
     }
 }
示例#3
0
        public static void MakeFarms(BetaWorld world, BlockManager bm, int intFarmLength, int intMapLength)
        {
            AddBuildings(bm, intFarmLength, intMapLength);
            int intFail = 0;
            int intFarms = 0;
            while (intFail <= 500)
            {
                int xlen = RandomHelper.Next(8, 26);
                int x1 = RandomHelper.Next(4, intMapLength - (4 + xlen));
                int zlen = RandomHelper.Next(8, 26);
                int z1 = RandomHelper.Next(4, intMapLength - (4 + zlen));
                if (!(x1 >= intFarmLength && z1 >= intFarmLength &&
                      x1 <= intMapLength - intFarmLength && z1 <= intMapLength - intFarmLength))
                {
                    bool booValid = true;
                    for (int x = x1 - 2; x <= x1 + xlen + 2 && booValid; x++)
                    {
                        for (int z = z1 - 2; z <= z1 + zlen + 2 && booValid; z++)
                        {
                            // make sure it doesn't overlap with the spawn point or another farm
                            if ((x == intMapLength / 2 && z == intMapLength - (intFarmLength - 10)) ||
                                bm.GetID(x, 63, z) != BlockType.GRASS || bm.GetID(x, 64, z) != BlockType.AIR)
                            {
                                booValid = false;
                                intFail++;
                            }
                        }
                    }
                    if (booValid)
                    {
                        // first there is a 25% chance of a hill or pond
                        // if not, for large farms, there is a 50% chance it'll be an orchard
                        // if not, 33% are cactus, 33% are wheat and 33% are sugarcane

                        FarmTypes curFarm;
                        int intFarmType = RandomHelper.Next(100);
                        if (xlen >= 10 && zlen >= 10 && intFarmType > 75)
                        {
                            if (RandomHelper.NextDouble() > 0.5)
                            {
                                curFarm = FarmTypes.Pond;
                                MakePond(bm, x1, xlen, z1, zlen, false);
                            }
                            else
                            {
                                curFarm = FarmTypes.Hill;
                                MakeHill(bm, x1, xlen, z1, zlen, false);
                            }
                        }
                        else
                        {
                            intFarmType = RandomHelper.Next(100);
                            if (((xlen >= 11 && zlen >= 16) || (xlen >= 16 && zlen >= 11)) && intFarmType > 50)
                            {
                                curFarm = FarmTypes.Orchard;
                                xlen = ((int)((xlen - 1) / 5) * 5) + 1;
                                zlen = ((int)((zlen - 1) / 5) * 5) + 1;
                            }
                            else
                            {
                                intFarmType = RandomHelper.Next(3);
                                if (intFarmType == 2)
                                {
                                    curFarm = FarmTypes.Cactus;
                                }
                                else if (intFarmType == 1)
                                {
                                    curFarm = FarmTypes.Wheat;
                                    xlen += (xlen % 2) - 1;
                                    zlen += (zlen % 2) - 1;
                                }
                                else
                                {
                                    curFarm = FarmTypes.SugarCane;
                                    xlen += (xlen % 2) - 1;
                                    zlen += (zlen % 2) - 1;
                                }
                            }
                        }

                        int intWallMaterial = RandomHelper.NextDouble() > 0.5 ? BlockType.FENCE : BlockType.LEAVES;

                        switch (curFarm)
                        {
                            case FarmTypes.Hill:
                            case FarmTypes.Pond:
                                intWallMaterial = 0;
                                break;
                            case FarmTypes.SugarCane:
                            case FarmTypes.Mushroom:
                                if (RandomHelper.NextDouble() > 0.5)
                                {
                                    intWallMaterial = 0;
                                }
                                break;
                            case FarmTypes.Wheat:
                                intWallMaterial = BlockType.LEAVES;
                                break;
                                // no need for default - the other types don't need anything here
                        }
                        switch (intWallMaterial)
                        {
                            case BlockType.FENCE:
                                BlockShapes.MakeHollowLayers(x1, x1 + xlen, 64, 64, z1, z1 + zlen,
                                                             BlockType.FENCE, 0, -1);
                                break;
                            case BlockType.LEAVES:
                                // the saplings will all disappear if one of them is broken.
                                // so we put wood beneath them to stop that happening
                                BlockShapes.MakeHollowLayers(x1, x1 + xlen, 63, 63, z1, z1 + zlen,
                                                             BlockType.WOOD, 0, -1);
                                BlockShapes.MakeHollowLayers(x1, x1 + xlen, 64, 65, z1, z1 + zlen, BlockType.LEAVES, 0,
                                  RandomHelper.RandomNumber((int)LeafType.OAK, (int)LeafType.SPRUCE,
                                                            (int)LeafType.BIRCH));
                                break;
                            case 0:
                                // no wall
                                break;
                            default:
                                Debug.Fail("Invalid switch result");
                                break;
                        }

                        switch (curFarm)
                        {
                            case FarmTypes.Orchard:
                                int intSaplingType = RandomHelper.RandomNumber(SaplingBirchDataID,
                                                                               SaplingOakDataID,
                                                                               SaplingSpruceDataID);
                                for (int x = x1 + 3; x <= x1 + xlen - 3; x += 5)
                                {
                                    for (int z = z1 + 3; z <= z1 + zlen - 3; z += 5)
                                    {
                                        bm.SetID(x, 63, z, BlockType.GRASS);
                                        BlockShapes.MakeBlock(x, 64, z, BlockType.SAPLING, intSaplingType);
                                    }
                                }
                                break;
                            case FarmTypes.Cactus:
                                int intAttempts = 0;
                                do
                                {
                                    int xCactus = RandomHelper.Next(x1 + 1, x1 + xlen);
                                    int zCactus = RandomHelper.Next(z1 + 1, z1 + zlen);
                                    bool booValidFarm = true;
                                    for (int xCheck = xCactus - 1; xCheck <= xCactus + 1 && booValidFarm; xCheck++)
                                    {
                                        for (int zCheck = zCactus - 1; zCheck <= zCactus + 1 && booValidFarm; zCheck++)
                                        {
                                            if (bm.GetID(xCheck, 64, zCheck) != BlockType.AIR)
                                            {
                                                booValidFarm = false;
                                            }
                                        }
                                    }
                                    if (booValidFarm)
                                    {
                                        bm.SetID(xCactus, 64, zCactus, BlockType.CACTUS);
                                        if (RandomHelper.NextDouble() > 0.5)
                                        {
                                            bm.SetID(xCactus, 65, zCactus, BlockType.CACTUS);
                                        }
                                    }
                                }
                                while (++intAttempts < 100);
                                break;
                            case FarmTypes.Wheat:
                                BlockShapes.MakeHollowLayers(x1, x1 + xlen, 66, 66, z1, z1 + zlen,
                                                             BlockType.GLASS, 0, -1);
                                BlockShapes.MakeSolidBox(x1 + 1, x1 + xlen - 1, 67, 67, z1 + 1, z1 + zlen - 1,
                                                         BlockType.GLASS, 0);
                                break;
                            // no need for a default, because there's nothing to do for the other farms
                        }

                        for (int x = x1 + 1; x <= x1 + xlen - 1; x++)
                        {
                            for (int z = z1 + 1; z <= z1 + zlen - 1; z++)
                            {
                                switch (curFarm)
                                {
                                    case FarmTypes.Cactus:
                                        bm.SetID(x, 63, z, BlockType.SAND);
                                        break;
                                    case FarmTypes.Wheat:
                                        if (z == z1 + 1)
                                        {
                                            bm.SetID(x, 63, z, BlockType.DOUBLE_SLAB);
                                        }
                                        else if (x % 2 == 0)
                                        {
                                            BlockShapes.MakeBlock(x, 63, z, BlockType.FARMLAND, 1);
                                            bm.SetID(x, 64, z, BlockType.CROPS);
                                        }
                                        else
                                        {
                                            bm.SetID(x, 63, z, BlockType.STATIONARY_WATER);
                                        }
                                        break;
                                    case FarmTypes.SugarCane:
                                        if (z != z1 + 1)
                                        {
                                            if (x % 2 == 0)
                                            {
                                                bm.SetID(x, 64, z, BlockType.SUGAR_CANE);
                                                if (RandomHelper.Next(100) > 50)
                                                {
                                                    bm.SetID(x, 65, z, BlockType.SUGAR_CANE);
                                                }
                                            }
                                            else
                                            {
                                                bm.SetID(x, 63, z, BlockType.STATIONARY_WATER);
                                            }
                                        }
                                        break;
                                    // no need for a default, because there's nothing to do for the other farms
                                }
                            }
                        }
                        int intDoorPosition = x1 + RandomHelper.Next(1, xlen - 1);
                        if (curFarm == FarmTypes.Wheat)
                        {
                            bm.SetID(intDoorPosition, 63, z1, BlockType.DOUBLE_SLAB);
                        }
                        if (intWallMaterial != 0)
                        {
                            BlockShapes.MakeBlock(intDoorPosition, 64, z1, BlockType.WOOD_DOOR, 4);
                            BlockShapes.MakeBlock(intDoorPosition, 65, z1, BlockType.WOOD_DOOR,
                                                  4 + (int)DoorState.TOPHALF);
                        }
                        intFail = 0;
                        if (++intFarms > 10)
                        {
                            world.Save();
                            intFarms = 0;
                        }
                    }
                }
            }
            MakeMiniPondsAndHills(world, bm, intFarmLength, intMapLength);
            MakeFlowers(bm, intFarmLength, intMapLength);
        }
示例#4
0
 private static void MakeMiniPondsAndHills(BetaWorld world, BlockManager bm, int intFarmLength, int intMapLength)
 {
     int intFail = 0;
     int intAdded = 0;
     do
     {
         int xlen = RandomHelper.Next(4, 12);
         int x1 = RandomHelper.Next(1, intMapLength - (1 + xlen));
         int zlen = RandomHelper.Next(4, 12);
         int z1 = RandomHelper.Next(1, intMapLength - (1 + zlen));
         if (!(x1 >= intFarmLength && z1 >= intFarmLength &&
               x1 <= intMapLength - intFarmLength && z1 <= intMapLength - intFarmLength))
         {
             bool booValid = true;
             for (int x = x1 - 1; x <= x1 + xlen + 1 && booValid; x++)
             {
                 for (int z = z1 - 1; z <= z1 + zlen + 1 && booValid; z++)
                 {
                     // make sure it doesn't overlap with the spawn point or another farm
                     if ((x == intMapLength / 2 && z == intMapLength - (intFarmLength - 10)) ||
                         bm.GetID(x, 63, z) != BlockType.GRASS || bm.GetID(x, 64, z) != BlockType.AIR)
                     {
                         booValid = false;
                     }
                 }
             }
             if (booValid)
             {
                 if (RandomHelper.NextDouble() > 0.5)
                 {
                     MakePond(bm, x1, xlen, z1, zlen, true);
                 }
                 else
                 {
                     MakeHill(bm, x1, xlen, z1, zlen, true);
                 }
                 intFail = 0;
                 if (++intAdded % 25 == 0)
                 {
                     world.Save();
                 }
             }
             else
             {
                 intFail++;
             }
         }
     } while (intFail < 500);
 }
示例#5
0
 private static void MakeFlowers(BlockManager bm, int intFarmLength, int intMapLength)
 {
     for (int x = 0; x <= intMapLength; x++)
     {
         for (int z = 0; z <= intMapLength; z++)
         {
             if (x <= intFarmLength || z <= intFarmLength ||
                 x >= intMapLength - intFarmLength || z >= intMapLength - intFarmLength)
             {
                 bool booFree = true;
                 for (int xCheck = x - 1; xCheck <= x + 1 && booFree; xCheck++)
                 {
                     for (int zCheck = z - 1; zCheck <= z + 1 && booFree; zCheck++)
                     {
                         booFree = bm.GetID(xCheck, 63, zCheck) == BlockType.GRASS &&
                                   bm.GetID(xCheck, 64, zCheck) == BlockType.AIR;
                     }
                 }
                 if (booFree && RandomHelper.NextDouble() > 0.90)
                 {
                     switch (RandomHelper.Next(4))
                     {
                         case 0:
                             bm.SetID(x, 64, z, BlockType.RED_ROSE);
                             break;
                         case 1:
                             bm.SetID(x, 64, z, BlockType.YELLOW_FLOWER);
                             break;
                         case 2:
                         case 3:
                             bm.SetID(x, 64, z, BlockType.TALL_GRASS);
                             bm.SetData(x, 64, z, RandomHelper.Next(1, 3));
                             break;
                         default:
                             Debug.Fail("Invalid switch result");
                             break;
                     }
                 }
             }
         }
     }
 }
示例#6
0
 private static void AddBuilding(BlockManager bm, int intFarmLength, int intMapLength, int intBuildingID)
 {
     bool booAddedBuilding = false;
     SourceWorld.Building bldInsert = SourceWorld.GetBuilding(intBuildingID);
     int intLen = bldInsert.intSizeX;
     bool booValid;
     do
     {
         booValid = false;
         int x1 = RandomHelper.Next(2, intMapLength - (2 + intLen));
         int z1 = RandomHelper.Next(2, intMapLength - (2 + intLen));
         if (!(x1 >= intFarmLength && z1 >= intFarmLength &&
               x1 <= intMapLength - intFarmLength && z1 <= intMapLength - intFarmLength))
         {
             booValid = true;
             for (int x = x1 - 2; x <= x1 + intLen + 2 && booValid; x++)
             {
                 for (int z = z1 - 2; z <= z1 + intLen + 2 && booValid; z++)
                 {
                     // make sure it doesn't overlap with the spawn point or another farm
                     if ((x == intMapLength / 2 && z == intMapLength - (intFarmLength - 10)) ||
                         bm.GetID(x, 63, z) != BlockType.GRASS ||
                         bm.GetID(x, 64, z) != BlockType.AIR ||
                         bm.GetID(x, 53, z) == BlockType.AIR)
                     {
                         booValid = false;
                     }
                 }
             }
         }
         if (booValid)
         {
             SourceWorld.InsertBuilding(bm, new int[intMapLength, intMapLength], 0, x1, z1, bldInsert, 0);
             booAddedBuilding = true;
         }
     } while (!booAddedBuilding);
 }
示例#7
0
 private static void JoinPathsToRoad(BlockManager bmDest, int intMapLength, int intFarmLength)
 {
     int intBlockStart = intFarmLength + 13;
     int intPlotBlocksLength = (1 + intMapLength) - (intBlockStart * 2);
     for (int a = 0; a <= intPlotBlocksLength; a++)
     {
         for (int b = -2; b <= 2; b+=4)
         {
             if (bmDest.GetID(intBlockStart + a, 63, intBlockStart + (intPlotBlocksLength / 2) + (int)(b * 1.5)) == BlockType.DOUBLE_SLAB &&
                 bmDest.GetID(intBlockStart + a, 63, intBlockStart + (intPlotBlocksLength / 2) + (int)(b / 2)) == BlockType.DOUBLE_SLAB &&
                 bmDest.GetID(intBlockStart + a, 63, intBlockStart + (intPlotBlocksLength / 2) + b) == BlockType.GRASS &&
                 bmDest.GetID(intBlockStart + a, 64, intBlockStart + (intPlotBlocksLength / 2) + b) == BlockType.AIR)
             {
                 bmDest.SetID(intBlockStart + a, 63, intBlockStart + (intPlotBlocksLength / 2) + b, BlockType.DOUBLE_SLAB);
             }
             if (bmDest.GetID(intBlockStart + (intPlotBlocksLength / 2) + (int)(b * 1.5), 63, intBlockStart + a) == BlockType.DOUBLE_SLAB &&
                 bmDest.GetID(intBlockStart + (intPlotBlocksLength / 2) + (int)(b / 2), 63, intBlockStart + a) == BlockType.DOUBLE_SLAB &&
                 bmDest.GetID(intBlockStart + (intPlotBlocksLength / 2) + b, 63, intBlockStart + a) == BlockType.GRASS &&
                 bmDest.GetID(intBlockStart + (intPlotBlocksLength / 2) + b, 64, intBlockStart + a) == BlockType.AIR)
             {
                 bmDest.SetID(intBlockStart + (intPlotBlocksLength / 2) + b, 63, intBlockStart + a, BlockType.DOUBLE_SLAB);
             }
         }
     }
 }
示例#8
0
 private static void MakeStreetLight(BlockManager bm, StreetLights slCurrent, int x1, int z1, int x2, int z2)
 {
     if (bm.GetID(x1, 63, z1) == BlockType.GRASS && bm.GetID(x1, 64, z1) == BlockType.AIR
         && bm.GetID(x1, 65, z1) == BlockType.AIR)
     {
         switch (slCurrent)
         {
             case StreetLights.Glowstone:
                 bm.SetID(x1, 64, z1, BlockType.FENCE);
                 bm.SetID(x1, 65, z1, BlockType.FENCE);
                 bm.SetID(x1, 66, z1, BlockType.FENCE);
                 bm.SetID(x1, 67, z1, BlockType.FENCE);
                 bm.SetID(x1, 68, z1, BlockType.FENCE);
                 bm.SetID(x2, 68, z2, BlockType.FENCE);
                 bm.SetID(x2, 67, z2, BlockType.GLOWSTONE_BLOCK);
                 break;
             case StreetLights.Torches:
                 bm.SetID(x1, 64, z1, BlockType.FENCE);
                 bm.SetID(x1, 65, z1, BlockType.FENCE);
                 bm.SetID(x1, 66, z1, BlockType.FENCE);
                 bm.SetID(x1, 67, z1, BlockType.FENCE);
                 bm.SetID(x1, 68, z1, BlockType.FENCE);
                 bm.SetID(x2, 68, z2, BlockType.FENCE);
                 bm.SetID(x2, 67, z2, BlockType.WOOD_PLANK);
                 if (z1 == z2)
                 {
                     BlockHelper.MakeTorch(x2, 67, z2 - 1, BlockType.WOOD_PLANK, 0);
                     BlockHelper.MakeTorch(x2, 67, z2 + 1, BlockType.WOOD_PLANK, 0);
                 }
                 else
                 {
                     BlockHelper.MakeTorch(x2 - 1, 67, z2, BlockType.WOOD_PLANK, 0);
                     BlockHelper.MakeTorch(x2 + 1, 67, z2, BlockType.WOOD_PLANK, 0);
                 }
                 break;
         }
     }
 }
示例#9
0
 private static void MakeFlowers(BlockManager bmDest, BetaWorld worldDest, int intFarmLength, int intMapLength)
 {
     int intFlowers = 0;
     for (int x = intFarmLength + 11; x <= intMapLength - (intFarmLength + 11); x++)
     {
         for (int z = intFarmLength + 11; z <= intMapLength - (intFarmLength + 11); z++)
         {
             if (bmDest.GetID(x, 63, z) == BlockType.GRASS &&
                 bmDest.GetID(x, 64, z) == BlockType.AIR)
             {
                 bool booFree = true;
                 int intFree = 0;
                 for (int xCheck = x - 1; xCheck <= x + 1 && booFree; xCheck++)
                 {
                     for (int zCheck = z - 1; zCheck <= z + 1 && booFree; zCheck++)
                     {
                         if (bmDest.GetID(xCheck, 63, zCheck) == BlockType.GRASS &&
                             bmDest.GetID(xCheck, 64, zCheck) == BlockType.AIR)
                         {
                             intFree++;
                         }
                     }
                 }
                 if (intFree >= MinimumFreeNeighboursNeededForFlowers &&
                     RandomHelper.NextDouble() <= FlowerChance)
                 {
                     AddFlowersToBlock(bmDest, x, z);
                     if (++intFlowers >= NumberOfFlowersBetweenSaves)
                     {
                         worldDest.Save();
                         intFlowers = 0;
                     }
                 }
             }
         }
     }
 }
示例#10
0
        public static void InsertBuilding(BlockManager bmDest, int[,] intArea, int intBlockStart,
                                          int x1dest, int z1dest, Building bldInsert, int y1dest)
        {
            List<Spawner> lstSpawners = new List<Spawner>();
            _lstInstanceSigns.Clear();
            int intRandomWoolColour = RandomHelper.Next(16);
            int intSourceX = 0, intSourceZ = 0;
            int intRotate = -1;
            if (bldInsert.btThis == BuildingTypes.MineshaftSection)
            {
                intRotate = 0;
            }
            else
            {
                for (int intDistance = 0; intRotate == -1 && intDistance < 10; intDistance++)
                {
                    for (int intCheck = 0; intRotate == -1 && intCheck <= bldInsert.intSizeX; intCheck++)
                    {
                        if (CheckArea(intArea, x1dest + intCheck, z1dest - intDistance) == 1)
                        {
                            intRotate = 0;
                        }
                        else if (CheckArea(intArea, x1dest - intDistance, z1dest + intCheck) == 1)
                        {
                            intRotate = 1;
                        }
                        else if (CheckArea(intArea, x1dest + bldInsert.intSizeX + intDistance, z1dest + intCheck) == 1)
                        {
                            intRotate = 2;
                        }
                        else if (CheckArea(intArea, x1dest + intCheck, z1dest + bldInsert.intSizeZ + intDistance) == 1)
                        {
                            intRotate = 3;
                        }
                    }
                }
            }
            if (intRotate == -1)
            {
                intRotate = RandomHelper.Next(4);
            }

            for (int x = 0; x < bldInsert.intSizeX; x++)
            {
                for (int z = 0; z < bldInsert.intSizeZ; z++)
                {
                    switch (intRotate)
                    {
                        case 0:
                            intSourceX = x;
                            intSourceZ = z;
                            break;
                        case 1:
                            intSourceX = (bldInsert.intSizeX - 1) - z;
                            intSourceZ = x;
                            break;
                        case 2:
                            intSourceX = z;
                            intSourceZ = (bldInsert.intSizeZ - 1) - x;
                            break;
                        case 3:
                            intSourceX = (bldInsert.intSizeX - 1) - x;
                            intSourceZ = (bldInsert.intSizeZ - 1) - z;
                            break;
                        default:
                            Debug.Fail("Invalid switch result");
                            break;
                    }

                    int intSourceEndY;
                    if (bldInsert.btThis == BuildingTypes.MineshaftSection)
                    {
                        intSourceEndY = bldInsert.intSourceStartY + 4;
                    }
                    else
                    {
                        for (intSourceEndY = 128; intSourceEndY > 64; intSourceEndY--)
                        {
                            if (_bmSource.GetID(intSourceX + bldInsert.intSourceX, intSourceEndY,
                                                intSourceZ + bldInsert.intSourceZ) != BlockType.AIR)
                            {
                                break;
                            }
                        }
                    }
                    for (int ySource = bldInsert.intSourceStartY; ySource <= intSourceEndY; ySource++)
                    {
                        int yDest = ySource;
                        if (bldInsert.btThis == BuildingTypes.MineshaftSection)
                        {
                            yDest = y1dest + (ySource - bldInsert.intSourceStartY);
                        }

                        if (bldInsert.btThis == BuildingTypes.MineshaftSection ||
                            ((yDest != 64 || bmDest.GetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest) == BlockType.AIR) &&
                            bmDest.GetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest) != BlockType.WOOD_PLANK))
                        {
                            int intBlockID = _bmSource.GetID(intSourceX + bldInsert.intSourceX, ySource,
                                                             intSourceZ + bldInsert.intSourceZ);
                            int intBlockData = _bmSource.GetData(intSourceX + bldInsert.intSourceX, ySource,
                                                                 intSourceZ + bldInsert.intSourceZ);
                            bmDest.SetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, intBlockID);
                            bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, intBlockData);

                            #region import paintings
                            // todo: test for mineshaft features
                            foreach (EntityPainting entPainting in _AllEntityPainting)
                            {
                                if (entPainting.TileX == intSourceX + bldInsert.intSourceX &&
                                    entPainting.TileY == ySource &&
                                    entPainting.TileZ == intSourceZ + bldInsert.intSourceZ)
                                {
                                    EntityPainting entNewPainting = (EntityPainting)entPainting.Copy();
                                    entNewPainting.TileX = intBlockStart + x + x1dest;
                                    entNewPainting.TileY = yDest;
                                    entNewPainting.TileZ = intBlockStart + z + z1dest;
                                    entNewPainting.Position.X = entNewPainting.TileX;
                                    entNewPainting.Position.Z = entNewPainting.TileZ;
                                    entNewPainting.Direction = BlockHelper.RotatePortrait(entPainting.Direction,
                                                                                          intRotate);
                                    ChunkRef chunkBuilding = _cmDest.GetChunkRef((intBlockStart + x + x1dest) / 16,
                                                                                 (intBlockStart + z + z1dest) / 16);
                                    chunkBuilding.Entities.Add(entNewPainting);
                                    _cmDest.Save();
                                }
                            }
                            #endregion
                            #region Rotation
                            if (intRotate > 0)
                            {
                                switch (intBlockID)
                                {
                                    case BlockType.PORTAL:
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                       BlockHelper.RotatePortal(intBlockData, intRotate));
                                        break;
                                    case BlockType.SIGN_POST:
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                       BlockHelper.RotateSignPost(intBlockData, intRotate));
                                        break;
                                    case BlockType.STONE_BUTTON:
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                       BlockHelper.RotateButton(intBlockData, intRotate));
                                        break;
                                    case BlockType.PUMPKIN:
                                    case BlockType.JACK_O_LANTERN:
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                       BlockHelper.RotatePumpkin(intBlockData, intRotate));
                                        break;
                                    case BlockType.IRON_DOOR:
                                    case BlockType.WOOD_DOOR:
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                       BlockHelper.RotateDoor(intBlockData, intRotate));
                                        break;
                                    case BlockType.TRAPDOOR:
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                       BlockHelper.RotateTrapdoor(intBlockData, intRotate));
                                        break;
                                    case BlockType.BED:
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                       BlockHelper.RotateBed(intBlockData, intRotate));
                                        break;
                                    case BlockType.REDSTONE_TORCH_OFF:
                                    case BlockType.REDSTONE_TORCH_ON:
                                    case BlockType.TORCH:
                                    case BlockType.LEVER:
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                       BlockHelper.RotateTorchOrLever(intBlockData, intRotate));
                                        break;
                                    case BlockType.WALL_SIGN:
                                    case BlockType.LADDER:
                                    case BlockType.DISPENSER:
                                    case BlockType.FURNACE:
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                        BlockHelper.RotateWallSignOrLadderOrFurnanceOrDispenser(
                                                          intBlockData, intRotate));
                                        break;
                                    case BlockType.COBBLESTONE_STAIRS:
                                    case BlockType.WOOD_STAIRS:
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                        BlockHelper.RotateStairs(intBlockData, intRotate));
                                        break;
                                    // no need for a default - all other blocks are okay
                                }
                            }
                            #endregion
                            #region Handle entities
                            switch (intBlockID)
                            {
                                case BlockType.SPONGE:
                                    bmDest.SetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockType.WOOL);
                                    bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                   intRandomWoolColour);
                                    break;
                                case BlockType.CHEST:
                                    TileEntityChest tec = (TileEntityChest)_bmSource.GetTileEntity(
                                        intSourceX + bldInsert.intSourceX, ySource, intSourceZ + bldInsert.intSourceZ);
                                    if (_booIncludeItemsInChests)
                                    {
                                        if (tec.Items[0] != null)
                                        {
                                            if (tec.Items[0].ID == ItemInfo.Paper.ID &&
                                                tec.Items[0].Count == 3)
                                            {
                                                tec = MakeHouseChest();
                                            }
                                            if (tec.Items[0].ID == ItemInfo.Paper.ID &&
                                                tec.Items[0].Count == 4)
                                            {
                                                tec = MakeTreasureChest();
                                            }
                                        }
                                    }
                                    else
                                    {
                                        tec.Items.ClearAllItems();
                                    }
                                    bmDest.SetTileEntity(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, tec);
                                    break;
                                case BlockType.FURNACE:
                                case BlockType.MONSTER_SPAWNER:
                                case BlockType.NOTE_BLOCK:
                                    bmDest.SetTileEntity(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                         _bmSource.GetTileEntity(intSourceX + bldInsert.intSourceX, ySource,
                                                                                 intSourceZ + bldInsert.intSourceZ));
                                    break;
                                case BlockType.SIGN_POST:
                                case BlockType.WALL_SIGN:
                                    #region Determine sign text
                                    int intUniqueType = 0;
                                    TileEntitySign tes = (TileEntitySign)_bmSource.
                                        GetTileEntity(intSourceX + bldInsert.intSourceX, ySource,
                                                      intSourceZ + bldInsert.intSourceZ);
                                    string strSourceSign = tes.Text1 + " " + tes.Text2 + " " + tes.Text3 + " " + tes.Text4;
                                    switch (strSourceSign.Substring(0, 1))
                                    {
                                        case "2":
                                        case "1":
                                        case "0":
                                            intUniqueType = Convert.ToInt32(strSourceSign.Substring(0, 1));
                                            strSourceSign = strSourceSign.Remove(0, 1);
                                            break;
                                        default:
                                            intUniqueType = 0;
                                            break;
                                    }
                                    if (tes.Text1.ToLower() == "commentsign" || tes.Text1.ToLower() == "comment sign")
                                    {
                                        // these exist to give advice to people in the resource world.
                                        // so we just remove them from the real world
                                        bmDest.SetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest,
                                                     BlockType.AIR);
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, 0);
                                    }
                                    if (tes.Text1.ToLower() == "spawner" || tes.Text1.ToLower() == "gspawner")
                                    {
                                        if (!tes.Text2.ToLower().StartsWith("g") || tes.Text2.ToLower() == "[randomenemy]" || _booIncludeGhostdancerSpawners)
                                        {
                                            Spawner spawnerCurrent = new Spawner();
                                            if (tes.Text2.ToLower() == "[randomenemy]")
                                            {
                                                if (_booIncludeGhostdancerSpawners)
                                                {
                                                    spawnerCurrent.strEntityID = RandomHelper.RandomString("Creeper", "Skeleton", "Spider", "Zombie", "GGeist", "GGrim");
                                                }
                                                else
                                                {
                                                    spawnerCurrent.strEntityID = RandomHelper.RandomString("Creeper", "Skeleton", "Spider", "Zombie");
                                                }
                                            }
                                            else
                                            {
                                                spawnerCurrent.strEntityID = tes.Text2;
                                            }

                                            if (tes.Text3.Split(' ').GetUpperBound(0) == 2)
                                            {
                                                spawnerCurrent.sy = yDest + Convert.ToInt32(tes.Text3.Split(' ')[1]);
                                                spawnerCurrent.sx = 0;
                                                spawnerCurrent.sz = 0;
                                                switch (intRotate)
                                                {
                                                    case 0:
                                                        spawnerCurrent.sx = intBlockStart + x + x1dest +
                                                                            (Convert.ToInt32(tes.Text3.Split(' ')[0]));
                                                        spawnerCurrent.sz = intBlockStart + z + z1dest +
                                                                            (Convert.ToInt32(tes.Text3.Split(' ')[2]));
                                                        break;
                                                    case 1:
                                                        spawnerCurrent.sx = intBlockStart + x + x1dest +
                                                                            (Convert.ToInt32(tes.Text3.Split(' ')[2]));
                                                        spawnerCurrent.sz = intBlockStart + z + z1dest +
                                                                            (-1 * Convert.ToInt32(tes.Text3.Split(' ')[0]));
                                                        break;
                                                    case 2:
                                                        spawnerCurrent.sx = intBlockStart + x + x1dest +
                                                                            (-1 * Convert.ToInt32(tes.Text3.Split(' ')[2]));
                                                        spawnerCurrent.sz = intBlockStart + z + z1dest +
                                                                            (Convert.ToInt32(tes.Text3.Split(' ')[0]));
                                                        break;
                                                    case 3:
                                                        spawnerCurrent.sx = intBlockStart + x + x1dest +
                                                                            (-1 * Convert.ToInt32(tes.Text3.Split(' ')[0]));
                                                        spawnerCurrent.sz = intBlockStart + z + z1dest +
                                                                            (-1 * Convert.ToInt32(tes.Text3.Split(' ')[2]));
                                                        break;
                                                }
                                            }
                                            else
                                            {
                                                spawnerCurrent.sx = intBlockStart + x + x1dest;
                                                spawnerCurrent.sy = yDest - 2;
                                                spawnerCurrent.sz = intBlockStart + z + z1dest;
                                            }
                                            if (tes.Text4.ToLower() == "no")
                                            {
                                                spawnerCurrent.booGrass = false;
                                            }
                                            else if (tes.Text4.Split(' ').GetUpperBound(0) == 2)
                                            {
                                                spawnerCurrent.gy = yDest + Convert.ToInt32(tes.Text4.Split(' ')[1]);
                                                switch (intRotate)
                                                {
                                                    case 0:
                                                        spawnerCurrent.gx = intBlockStart + x + x1dest +
                                                                            (Convert.ToInt32(tes.Text4.Split(' ')[0]));
                                                        spawnerCurrent.gz = intBlockStart + z + z1dest +
                                                                            (Convert.ToInt32(tes.Text4.Split(' ')[2]));
                                                        break;
                                                    case 1:
                                                        spawnerCurrent.gx = intBlockStart + x + x1dest +
                                                                            (-1 * Convert.ToInt32(tes.Text4.Split(' ')[2]));
                                                        spawnerCurrent.gz = intBlockStart + z + z1dest +
                                                                            (Convert.ToInt32(tes.Text4.Split(' ')[0]));
                                                        break;
                                                    case 2:
                                                        spawnerCurrent.gx = intBlockStart + x + x1dest +
                                                                            (Convert.ToInt32(tes.Text4.Split(' ')[2]));
                                                        spawnerCurrent.gz = intBlockStart + z + z1dest +
                                                                            (-1 * Convert.ToInt32(tes.Text4.Split(' ')[0]));
                                                        break;
                                                    case 3:
                                                        spawnerCurrent.gx = intBlockStart + x + x1dest +
                                                                            (-1 * Convert.ToInt32(tes.Text4.Split(' ')[0]));
                                                        spawnerCurrent.gz = intBlockStart + z + z1dest +
                                                                            (-1 * Convert.ToInt32(tes.Text4.Split(' ')[2]));
                                                        break;
                                                }
                                                spawnerCurrent.booGrass = true;
                                            }
                                            else
                                            {
                                                spawnerCurrent.gx = intBlockStart + x + x1dest;
                                                spawnerCurrent.gy = yDest - 1;
                                                spawnerCurrent.gz = intBlockStart + z + z1dest;
                                                spawnerCurrent.booGrass = true;
                                            }
                                            lstSpawners.Add(spawnerCurrent);
                                        }
                                        bmDest.SetID(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, BlockType.AIR);
                                        bmDest.SetData(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, 0);
                                    }
                                    else if (strSourceSign.Contains("["))
                                    {
                                        string strSignText;
                                        bool booDuplicate;
                                        int intFail = 0;
                                        do
                                        {
                                            strSignText = SignText(strSourceSign);
                                            booDuplicate = false;
                                            switch (intUniqueType)
                                            {
                                                case 1: // unique by instance
                                                    booDuplicate = _lstInstanceSigns.Contains(strSignText);
                                                    break;
                                                case 2: // unique by city
                                                    booDuplicate = _lstCitySigns.Contains(strSignText);
                                                    break;
                                            }
                                            if (++intFail > 100)
                                            {
                                                Debug.WriteLine("Could not make a unique sign for " + strSourceSign);
                                                booDuplicate = false;
                                            }
                                        } while (booDuplicate);
                                        _lstCitySigns.Add(strSignText);
                                        _lstInstanceSigns.Add(strSignText);
                                        string[] strRandomSign = Utils.TextToSign(Utils.ConvertStringToSignText(strSignText));
                                        tes.Text1 = strRandomSign[0];
                                        tes.Text2 = strRandomSign[1];
                                        tes.Text3 = strRandomSign[2];
                                        tes.Text4 = strRandomSign[3];
                                        bmDest.SetTileEntity(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, tes);
                                    }
                                    else
                                    {
                                        bmDest.SetTileEntity(intBlockStart + x + x1dest, yDest, intBlockStart + z + z1dest, tes);
                                    }
                                    break;
                                    #endregion
                                // no need for a default - all the other blocks are okay
                            }
                            #endregion
                        }
                    }
                }
            }
            foreach (Spawner spnAdd in lstSpawners)
            {
                bmDest.SetID(spnAdd.sx, spnAdd.sy, spnAdd.sz, BlockType.MONSTER_SPAWNER);
                TileEntityMobSpawner tems = new TileEntityMobSpawner();
                tems.EntityID = spnAdd.strEntityID;
                bmDest.SetTileEntity(spnAdd.sx, spnAdd.sy, spnAdd.sz, tems);
                if (spnAdd.booGrass)
                {
                    bmDest.SetID(spnAdd.gx, spnAdd.gy, spnAdd.gz, BlockType.GRASS);
                }
            }
        }
示例#11
0
 public static void ReplaceValuableBlocks(BetaWorld worldDest, BlockManager bm, int intCitySize,
                                          int intWallMaterial)
 {
     int intReplaced = 0;
     for (int x = 0; x < intCitySize; x++)
     {
         for (int z = 0; z < intCitySize; z++)
         {
             for (int y = 32; y < 128; y++)
             {
                 if ((int)bm.GetID(x, y, z) != intWallMaterial)
                 {
                     switch ((int)bm.GetID(x, y, z))
                     {
                         case BlockType.GOLD_BLOCK:
                             BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.YELLOW);
                             intReplaced++;
                             break;
                         case BlockType.IRON_BLOCK:
                             BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.LIGHT_GRAY);
                             intReplaced++;
                             break;
                         case BlockType.OBSIDIAN:
                             BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.BLACK);
                             intReplaced++;
                             break;
                         case BlockType.DIAMOND_BLOCK:
                             BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.LIGHT_BLUE);
                             intReplaced++;
                             break;
                         case BlockType.LAPIS_BLOCK:
                             BlockShapes.MakeBlock(x, y, z, BlockType.WOOL, (int)WoolColor.BLUE);
                             intReplaced++;
                             break;
                         // no need for a default, because we purposefully want to skip all the other blocks
                     }
                     if (intReplaced > 25)
                     {
                         worldDest.Save();
                         intReplaced = 0;
                     }
                 }
             }
         }
     }
 }
示例#12
0
        private static void MakeLevel(BetaWorld world, BlockManager bm, int intDepth, int intMineshaftSize, Buildings.structPoint spMineshaftEntrance)
        {
            Debug.WriteLine("----- Mineshaft Level " + intDepth + " -----");

            string[] strResourceNames = Utils.ValueFromXMLElement(Path.Combine("Resources", "Mineshaft.xml"),
                                                          "level" + intDepth, "names").Split(',');
            int[] intResourceChances = Utils.StringArrayToIntArray(Utils.ValueFromXMLElement(
                Path.Combine("Resources", "Mineshaft.xml"), "level" + intDepth, "chances").Split(','));
            int intTorchChance = Convert.ToInt32(Utils.ValueFromXMLElement(Path.Combine("Resources", "Mineshaft.xml"),
                                                                           "level" + intDepth, "torch_chance"));
            int[,] intAreaFull = new int[intMineshaftSize + (MULTIPLIER * 2), intMineshaftSize + (MULTIPLIER * 2)];
            int intXPosOriginal = spMineshaftEntrance.x - _intBlockStartBuildings;
            int intZPosOriginal = spMineshaftEntrance.z - _intBlockStartBuildings;

            _intBlockStartBuildings -= 2;
            int[,] intAreaOverview = new int[(intAreaFull.GetLength(0) / MULTIPLIER), (intAreaFull.GetLength(1) / MULTIPLIER)];
            int intXPos = intXPosOriginal / MULTIPLIER;
            int intZPos = intZPosOriginal / MULTIPLIER;
            intAreaOverview[intXPos, intZPos] = (int)MineshaftBlocks.Air;
            CreateRouteXPlus(intAreaOverview, intXPos + 1, intZPos, 0);
            CreateRouteZPlus(intAreaOverview, intXPos, intZPos + 1, 1);
            CreateRouteXMinus(intAreaOverview, intXPos - 1, intZPos, 2);
            CreateRouteZMinus(intAreaOverview, intXPos, intZPos - 1, 3);
            int intOffsetX = (intXPosOriginal - (intXPos * MULTIPLIER)) - 2;
            int intOffsetZ = (intZPosOriginal - (intZPos * MULTIPLIER)) - 2;

            List<structSection> lstSections = new List<structSection>();

            intAreaOverview[intXPos, intZPos] = (int)MineshaftBlocks.Placeholder;
            intAreaOverview = AddMineshaftSections(intAreaOverview, intDepth);
            intAreaOverview[intXPos, intZPos] = (int)MineshaftBlocks.Air;

            for (int x = 0; x < intAreaOverview.GetLength(0); x++)
            {
                for (int z = 0; z < intAreaOverview.GetLength(1); z++)
                {
                    if (intAreaOverview[x, z] >= 100)
                    {
                        structSection structCurrentSection = new structSection();
                        structCurrentSection.bldMineshaftSection = SourceWorld.GetBuilding(intAreaOverview[x, z] - 100);
                        structCurrentSection.x = ((x * MULTIPLIER) + intOffsetX) - 1;
                        structCurrentSection.z = ((z * MULTIPLIER) + intOffsetZ) - 1;
                        for (int x2 = x; x2 <= x + (structCurrentSection.bldMineshaftSection.intSizeX - 1) / 7; x2++)
                        {
                            for (int z2 = z; z2 <= z + (structCurrentSection.bldMineshaftSection.intSizeZ - 1) / 7; z2++)
                            {
                                if (intAreaOverview[x2, z2] == structCurrentSection.bldMineshaftSection.intID + 100)
                                {
                                    intAreaOverview[x2, z2] = (int)MineshaftBlocks.Structure;
                                }
                            }
                        }
                        lstSections.Add(structCurrentSection);
                    }
                }
            }
            for (int x = 4; x < intAreaFull.GetLength(0) - 4; x++)
            {
                for (int z = 4; z < intAreaFull.GetLength(1) - 4; z++)
                {
                    if (intAreaOverview.GetLength(0) > x / MULTIPLIER && intAreaOverview.GetLength(1) > z / MULTIPLIER)
                    {
                        if (intAreaFull[x + intOffsetX, z + intOffsetZ] < 4)
                        {
                            intAreaFull[x + intOffsetX, z + intOffsetZ] = intAreaOverview[x / MULTIPLIER, z / MULTIPLIER];
                        }
                    }
                    if ((x + 3) % 5 == 0 && (z + 3) % 5 == 0 && intAreaOverview[x / MULTIPLIER, z / MULTIPLIER] == (int)MineshaftBlocks.Air)
                    {
                        if (intAreaOverview[(x / MULTIPLIER) + 1, z / MULTIPLIER] >= 100)
                        {
                            for (int x2 = 0; x2 < 5; x2++)
                            {
                                intAreaFull[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = (int)MineshaftBlocks.Structure;
                            }
                        }
                        if (intAreaOverview[(x / MULTIPLIER) + 1, z / MULTIPLIER] == (int)MineshaftBlocks.Air)
                        {
                            for (int x2 = 0; x2 < 5; x2++)
                            {
                                if (x2 == 1 || x2 == 3)
                                {
                                    intAreaFull[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = (int)MineshaftBlocks.CeilingSupport;
                                    intAreaFull[x + intOffsetX + 2, z + intOffsetZ + x2 - 2] = (int)MineshaftBlocks.CeilingSupport;
                                }
                                else
                                {
                                    intAreaFull[x + intOffsetX + 3, z + intOffsetZ + x2 - 2] = (int)MineshaftBlocks.Support;
                                    intAreaFull[x + intOffsetX + 2, z + intOffsetZ + x2 - 2] = (int)MineshaftBlocks.Support;
                                }
                            }
                            for (int x2 = 0; x2 <= 5; x2++)
                            {
                                if (intAreaFull[x + intOffsetX + x2, z + intOffsetZ] == (int)MineshaftBlocks.Support)
                                {
                                    intAreaFull[x + intOffsetX + x2, z + intOffsetZ] = (int)MineshaftBlocks.RailWithSupport;
                                }
                                else
                                {
                                    intAreaFull[x + intOffsetX + x2, z + intOffsetZ] = (int)MineshaftBlocks.Rail;
                                }
                            }
                        }
                        if (intAreaOverview[x / MULTIPLIER, (z / MULTIPLIER) + 1] == (int)MineshaftBlocks.Air)
                        {
                            for (int z2 = 0; z2 < 5; z2++)
                            {
                                if (z2 == 1 || z2 == 3)
                                {
                                    intAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 3] = (int)MineshaftBlocks.CeilingSupport;
                                    intAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 2] = (int)MineshaftBlocks.CeilingSupport;
                                }
                                else
                                {
                                    intAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 3] = (int)MineshaftBlocks.Support;
                                    intAreaFull[x + intOffsetX + z2 - 2, z + intOffsetZ + 2] = (int)MineshaftBlocks.Support;
                                }
                            }
                            for (int z2 = 0; z2 <= 5; z2++)
                            {
                                if (intAreaFull[x + intOffsetX, z + intOffsetZ + z2] == (int)MineshaftBlocks.Support)
                                {
                                    intAreaFull[x + intOffsetX, z + intOffsetZ + z2] = (int)MineshaftBlocks.RailWithSupport;
                                }
                                else
                                {
                                    intAreaFull[x + intOffsetX, z + intOffsetZ + z2] = (int)MineshaftBlocks.Rail;
                                }
                            }
                        }
                        if (intAreaOverview[x / MULTIPLIER, z / MULTIPLIER] == (int)MineshaftBlocks.Air)
                        {
                            MakeChestAndOrTorch(intAreaOverview, intAreaFull, (x - 3) / MULTIPLIER, z / MULTIPLIER,
                                                x + intOffsetX - 2, z + intOffsetZ);
                            MakeChestAndOrTorch(intAreaOverview, intAreaFull, (x + 3) / MULTIPLIER, z / MULTIPLIER,
                                                x + intOffsetX + 2, z + intOffsetZ);
                            MakeChestAndOrTorch(intAreaOverview, intAreaFull, x / MULTIPLIER, (z - 3) / MULTIPLIER,
                                                x + intOffsetX, z + intOffsetZ - 2);
                            MakeChestAndOrTorch(intAreaOverview, intAreaFull, x / MULTIPLIER, (z + 3) / MULTIPLIER,
                                                x + intOffsetX, z + intOffsetZ + 2);
                        }
                    }
                }
            }
            intAreaFull[intXPosOriginal, intZPosOriginal] = (int)MineshaftBlocks.EntranceSection;
            int intSupportMaterial = RandomHelper.RandomNumber(BlockType.WOOD, BlockType.WOOD_PLANK, BlockType.FENCE);
            for (int x = 0; x < intAreaFull.GetLength(0); x++)
            {
                for (int z = 0; z < intAreaFull.GetLength(1); z++)
                {
                    if (intDepth <= 4)
                    {
                        if (bm.GetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings) == BlockType.GRAVEL)
                        {
                            bm.SetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings, BlockType.STONE);
                        }
                    }
                    if (intDepth <= 2)
                    {
                        if (bm.GetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings) == BlockType.SAND ||
                            bm.GetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings) == BlockType.SANDSTONE)
                        {
                            bm.SetID(x + _intBlockStartBuildings, 42 - (5 * intDepth), z + _intBlockStartBuildings, BlockType.DIRT);
                        }
                    }
                    switch(intAreaFull[x, z])
                    {
                        case (int)MineshaftBlocks.NaturalTerrain:
                            break;
                        case (int)MineshaftBlocks.Air:
                            for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockType.AIR);
                            }
                            break;
                        case (int)MineshaftBlocks.EntranceSection:
                        case (int)MineshaftBlocks.Rail:
                            for (int y = 38 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                            {
                                if (y == 38 - (5 * intDepth))
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                             BlockType.GRAVEL);
                                }
                                else if (y == 39 - (5 * intDepth))
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                             BlockType.RAILS);
                                }
                                else
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                             BlockType.AIR);
                                }
                            }
                            break;
                        case (int)MineshaftBlocks.RailWithSupport:
                            for (int y = 38 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                            {
                                if (y == 38 - (5 * intDepth))
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                             BlockType.GRAVEL);
                                }
                                else if (y == 39 - (5 * intDepth))
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                             BlockType.RAILS);
                                }
                                else if (y == 40 - (5 * intDepth))
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                             BlockType.AIR);
                                }
                                else
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                             intSupportMaterial);
                                }
                            }
                            break;
                        case (int)MineshaftBlocks.Support:
                            for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                         intSupportMaterial);
                            }
                            break;
                        case (int)MineshaftBlocks.ChestAndOrTorch:
                            for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                            {
                                if (y == 39 - (5 * intDepth) &&
                                    RandomHelper.NextDouble() > 0.9)
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockType.CHEST);
                                    MakeChestItems(bm, x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, intResourceChances, strResourceNames);
                                }
                                else if (y == 41 - (5 * intDepth) &&
                                         RandomHelper.NextDouble() < (double)intTorchChance / 100)
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                             BlockType.TORCH);
                                    if (intAreaFull[x - 1, z] == 0)
                                    {
                                        bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 1);
                                    }
                                    else if (intAreaFull[x + 1, z] == 0)
                                    {
                                        bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 2);
                                    }
                                    else if (intAreaFull[x, z - 1] == 0)
                                    {
                                        bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 3);
                                    }
                                    else
                                    {
                                        bm.SetData(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, 4);
                                    }
                                }
                                else
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockType.AIR);
                                }
                            }
                            break;
                        case (int)MineshaftBlocks.CeilingSupport:
                            for (int y = 39 - (5 * intDepth); y <= 41 - (5 * intDepth); y++)
                            {
                                if (y == 41 - (5 * intDepth))
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings,
                                             intSupportMaterial);
                                }
                                else
                                {
                                    bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockType.AIR);
                                }
                            }
                            break;
                        case (int)MineshaftBlocks.Unused9:
                            for (int y = 39 - (5 * intDepth); y <= 41 - (5 * (intDepth - 1)); y++)
                            {
                                bm.SetID(x + _intBlockStartBuildings, y, z + _intBlockStartBuildings, BlockType.AIR);
                            }
                            break;
                        case (int)MineshaftBlocks.Structure:
                            // this will be overwritten later
                            break;
                        default:
                            Debug.Fail("Invalid switch result");
                            break;
                    }
                }
            }
            foreach (structSection MineshaftSection in lstSections)
            {
                SourceWorld.InsertBuilding(bm, new int[0, 0], _intBlockStartBuildings, MineshaftSection.x, MineshaftSection.z,
                                           MineshaftSection.bldMineshaftSection, 38 - (5 * intDepth));
            }
            world.Save();
            _intBlockStartBuildings += 2;
            //#if DEBUG
            //    File.WriteAllText("output_area_" + intDepth + ".txt", Utils.TwoDimensionalArrayToString(intAreaOverview));
            //    File.WriteAllText("output_map_" + intDepth + ".txt", Utils.TwoDimensionalArrayToString(intAreaFull));
            //#endif
        }