Esempio n. 1
0
        public override Chunk GenerateChunk(int cx, int cz)
        {
            var chunk = new Chunk(cx, cz);

            // Build terrain map for this chunk
            var terrainHeightmap = new double[16, 16];
            var rockHeightmap    = new double[16, 16];
            var bedrockHeightmap = new double[16, 16];

            for (int bx = 0; bx < 16; bx++)
            {
                for (int bz = 0; bz < 16; bz++)
                {
                    int worldX = bx + (cx << 4);
                    int worldZ = bz + (cz << 4);
                    terrainHeightmap[bx, bz] = noiseGen.Terrain(worldX, worldZ);
                    rockHeightmap[bx, bz]    = noiseGen.Underground(worldX, worldZ) + terrainHeightmap[bx, bz] - 5;
                    bedrockHeightmap[bx, bz] = noiseGen.Bedrock(worldX, worldZ) + 1;

                    // Determine Biome

                    if (bx % 4 == 0 && bz % 4 == 0) // Biomes are in 4x4x4 blocks. Do a 2D array for now and just copy it vertically.
                    {
                        var b = ChunkBiome.GetBiome(worldX, worldZ, noiseGen);
                        for (int y = 0; y < 256; y += 4)
                        {
                            chunk.BiomeContainer.SetBiome(bx, y, bz, b);
                        }
                    }
                }
            }

            ChunkBuilder.FillChunk(chunk, terrainHeightmap, rockHeightmap, bedrockHeightmap);
            OverworldDecorator.Decorate(chunk, terrainHeightmap, noiseGen);
            GenerateCoal(chunk, rockHeightmap);
            ChunkBuilder.CarveCaves(noiseGen, chunk, rockHeightmap, bedrockHeightmap);
            return(chunk);
        }
Esempio n. 2
0
        public override Chunk GenerateChunk(int cx, int cz)
        {
            var chunk = new Chunk(cx, cz);

            // Build terrain map for this chunk
            var terrainHeightmap = new double[16, 16];
            var rockHeightmap    = new double[16, 16];
            var bedrockHeightmap = new double[16, 16];

            for (int bx = 0; bx < 16; bx++)
            {
                for (int bz = 0; bz < 16; bz++)
                {
                    int worldX = bx + (cx << 4);
                    int worldZ = bz + (cz << 4);
                    terrainHeightmap[bx, bz] = noiseGen.Terrain(worldX, worldZ);
                    chunk.Heightmaps[ChunkData.HeightmapType.WorldSurface].Set(bx, bz, (int)terrainHeightmap[bx, bz]);
                    chunk.Heightmaps[ChunkData.HeightmapType.OceanFloor].Set(bx, bz, noiseGen.OceanFloor(bx, bz));
                    rockHeightmap[bx, bz]    = noiseGen.Underground(worldX, worldZ) + terrainHeightmap[bx, bz] - 5;
                    bedrockHeightmap[bx, bz] = noiseGen.Bedrock(worldX, worldZ) + 1;

                    // Determine Biome
                    if (bx % 4 == 0 && bz % 4 == 0) // Biomes are in 4x4x4 blocks. Do a 2D array for now and just copy it vertically.
                    {
                        var b = ChunkBiome.GetBiome(worldX, worldZ, noiseGen);
                        for (int y = 0; y < 256; y += 4)
                        {
                            chunk.BiomeContainer.SetBiome(bx, y, bz, b);
                        }
                    }
                }
            }



            ChunkBuilder.FillChunk(chunk, terrainHeightmap, rockHeightmap, bedrockHeightmap);

            /*            for (int bx = 0; bx < 16; bx++)
             *          {
             *              for (int bz = 0; bz < 16; bz++)
             *              {
             *                  if (noiseGen.isRiver(bx + (cx * 16), bz + (cz * 16)))
             *                      chunk.SetBlock(bx, 106, bz, Registry.GetBlock(Materials.LightBlueStainedGlass));
             *
             *                  if (noiseGen.isMountain(bx + (cx * 16), bz + (cz * 16)))
             *                      chunk.SetBlock(bx, 105, bz, Registry.GetBlock(Materials.BlackStainedGlass));
             *
             *                  if (noiseGen.isHills(bx + (cx * 16), bz + (cz * 16)))
             *                      chunk.SetBlock(bx, 103, bz, Registry.GetBlock(Materials.GreenStainedGlass));
             *
             *                  if (noiseGen.isBadlands(bx + (cx * 16), bz + (cz * 16)))
             *                      chunk.SetBlock(bx, 104, bz, Registry.GetBlock(Materials.RedStainedGlass));
             *
             *                  if (noiseGen.isPlains(bx + (cx * 16), bz + (cz * 16)))
             *                      chunk.SetBlock(bx, 102, bz, Registry.GetBlock(Materials.WhiteStainedGlass));
             *
             *                  if (noiseGen.isOcean(bx + (cx * 16), bz + (cz * 16)))
             *                      chunk.SetBlock(bx, 101, bz, Registry.GetBlock(Materials.BlueStainedGlass));
             *
             *                  if (noiseGen.isDeepOcean(bx + (cx * 16), bz + (cz * 16)))
             *                      chunk.SetBlock(bx, 101, bz, Registry.GetBlock(Materials.BlueStainedGlass));
             *              }
             *          }*/

            OverworldDecorator.Decorate(chunk, terrainHeightmap, noiseGen);
            GenerateCoal(chunk, rockHeightmap);
            ChunkBuilder.CarveCaves(noiseGen, chunk, rockHeightmap, bedrockHeightmap);


            for (int bx = 0; bx < 16; bx++)
            {
                for (int bz = 0; bz < 16; bz++)
                {
                    chunk.Heightmaps[ChunkData.HeightmapType.MotionBlocking].Set(bx, bz, (int)terrainHeightmap[bx, bz]);
                }
            }
            return(chunk);
        }
        public override Chunk GenerateChunk(int cx, int cz)
        {
            var chunk = new Chunk(cx, cz);

            // Build terrain map for this chunk
            var terrainHeightmap = new double[16, 16];
            var rockHeightmap    = new double[16, 16];
            var bedrockHeightmap = new double[16, 16];

            var terrainHeights = new double[256];

            for (int bx = 0; bx < 16; bx++)
            {
                for (int bz = 0; bz < 16; bz++)
                {
                    for (int by = 0; by < 256; by++)
                    {
                        chunk.SetBlock(bx, 26, bz, Registry.GetBlock(Materials.Air));
                    }


                    terrainHeights[(bx * 16) + bz] = terrainHeightmap[bx, bz] = noiseGen.Terrain(bx + (cx * 16), bz + (cz * 16));
                    rockHeightmap[bx, bz]          = noiseGen.Underground(bx + (cx * 16), bz + (cz * 16)) + terrainHeightmap[bx, bz] - 5;
                    bedrockHeightmap[bx, bz]       = noiseGen.Bedrock(bx + (cx * 16), bz + (cz * 16)) + 1;

                    if (noiseGen.isRiver(bx + (cx * 16), bz + (cz * 16)))
                    {
                        chunk.SetBlock(bx, 26, bz, Registry.GetBlock(Materials.LightBlueStainedGlass));
                    }

                    if (noiseGen.isMountain(bx + (cx * 16), bz + (cz * 16)))
                    {
                        chunk.SetBlock(bx, 25, bz, Registry.GetBlock(Materials.LightGrayStainedGlass));
                    }

                    if (noiseGen.isHills(bx + (cx * 16), bz + (cz * 16)))
                    {
                        chunk.SetBlock(bx, 24, bz, Registry.GetBlock(Materials.RedStainedGlass));
                    }

                    if (noiseGen.isBadlands(bx + (cx * 16), bz + (cz * 16)))
                    {
                        chunk.SetBlock(bx, 23, bz, Registry.GetBlock(Materials.BlackStainedGlass));
                    }

                    if (noiseGen.isPlains(bx + (cx * 16), bz + (cz * 16)))
                    {
                        chunk.SetBlock(bx, 22, bz, Registry.GetBlock(Materials.WhiteStainedGlass));
                    }
                    else
                    {
                        chunk.SetBlock(bx, 21, bz, Registry.GetBlock(Materials.BlueStainedGlass));
                    }

                    var biometemp     = noiseGen.GetBiomeTemp(bx + (cx * 16), 0, bz + (cz * 16));
                    var biomeHumidity = noiseGen.GetBiomeHumidity(bx + (cx * 16), 255, bz + (cz * 16));
                    if (biometemp > 0)
                    {
                        chunk.SetBlock(bx, 30, bz, Registry.GetBlock(Materials.RedStainedGlass));
                    }
                    else
                    {
                        chunk.SetBlock(bx, 30, bz, Registry.GetBlock(Materials.GreenStainedGlass));
                    }
                    if (biomeHumidity > 0)
                    {
                        chunk.SetBlock(bx, 31, bz, Registry.GetBlock(Materials.BlueStainedGlass));
                    }
                    else
                    {
                        chunk.SetBlock(bx, 31, bz, Registry.GetBlock(Materials.YellowStainedGlass));
                    }
                }
            }

/*            for (int bx = 0; bx < 16; bx++)
 *          {
 *              for (int bz = 0; bz < 16; bz++)
 *              {
 *                  chunk.SetBlock(bx, (int)terrainHeightmap[bx,bz], bz, Registry.GetBlock(Materials.GreenStainedGlass));
 *                  chunk.SetBlock(bx, (int)rockHeightmap[bx, bz], bz, Registry.GetBlock(Materials.BrownStainedGlass));
 *                  chunk.SetBlock(bx, (int)bedrockHeightmap[bx, bz], bz, Registry.GetBlock(Materials.Bedrock));
 *              }
 *          }*/

            //ChunkBuilder.FillChunk(chunk, terrainHeightmap, rockHeightmap, bedrockHeightmap, true);

            //GenerateCoal(chunk, rockHeightmap);
            //ChunkBuilder.CarveCaves(noiseGen, chunk, rockHeightmap, bedrockHeightmap, true);
            return(chunk);
        }