Example #1
0
    private void FillCaveGaps(int steps, int minNeighboursToFill, int blockId, FindNeighboursMode findMode = FindNeighboursMode.NEIGHBOURS_4)
    {
        CavesGenerator caveGenerator = new CavesGenerator(this);

        caveGenerator.FillGaps(steps, blockId, findMode, minNeighboursToFill);
        GenerateImg();
    }
Example #2
0
        private void GenerateChunk(MapGenerationInfo info, ChunkColumnStorage chunk, int x, int z, GeneratorSettings settings)
        {
            // 生物群系生成
            // 获取生物群系
            int[,] biomeIds = _genlayer.GetInts(x * 16 - 8, z * 16 - 8, 32, 32);

            for (int i = 0; i < 10; ++i)
            {
                for (int j = 0; j < 10; ++j)
                {
                    _biomesForGeneration[j, i] = Biome.GetBiome(biomeIds[(int)(0.861111F * j * 4), (int)(0.861111F * i * 4)], settings);
                }
            }

            // 基本地形生成
            GenerateBasicTerrain(chunk, x, z, settings);

            // 获取生物群系
            biomeIds = _genlayer.GetInts(x * 16, z * 16, 16, 16);

            for (int i = 0; i < 16; ++i)
            {
                for (int j = 0; j < 16; ++j)
                {
                    _biomesForGeneration[j, i] = Biome.GetBiome(biomeIds[j, i], settings);
                }
            }

            // 设置生物群系
            for (int height = 0; height < 64; ++height)
            {
                for (int i = 0; i < 4; ++i)
                {
                    for (int j = 0; j < 4; ++j)
                    {
                        chunk.Biomes[(height * 4 + i) * 4 + j] = (int)_biomesForGeneration[j * 4, i * 4].GetBiomeId();
                    }
                }
            }

            // 添加生物群系特有方块
            ReplaceBiomeBlocks(settings, x, z, chunk, _biomesForGeneration);

            // Todo genrate structure
            // 生成洞穴
            if (settings.UseCaves)
            {
                CavesGenerator generator = new CavesGenerator(info);
                generator.Generate(info, x, z, chunk, _biomesForGeneration[8, 8]);
            }

            // 计算skylight
            GenerateSkylightMap(chunk);
        }
Example #3
0
    //Old code
    //private void GenerateCaves (int caves = 1) {
    //    for (int i = 0; i < caves; i++) {
    //        CavesGenerator caveGenerator = new CavesGenerator(this);
    //        List<Vector2> caveBlocks = caveGenerator.GenerateCave();

    //        for (int j = 0; j < caveBlocks.Count; j++) {
    //            int x = (int)caveBlocks[j].x;
    //            int y = (int)caveBlocks[j].y;

    //            //print("X|Y: " + x + "|" + y);

    //            if (map[x,y] == 1) {
    //                map[x, y] = 3;
    //            }
    //        }
    //    }

    //    GenerateImg();
    //}

    private void GenerateCaves(int cavesAmmount = 1, int blockId = 3, int voidBlockId = 0, int stps = 3, float density = .5f, FindNeighboursMode findMode = FindNeighboursMode.NEIGHBOURS_4)
    {
        CavesGenerator caveGenerator = new CavesGenerator(this);

        for (int i = 0; i < cavesAmmount; i++)
        {
            caveGenerator.GenerateCave(blockId, voidBlockId, steps, density, findMode, true);
        }

        GenerateImg();
    }