示例#1
0
        public void Test1()
        {
            using (StreamWriter sw = new StreamWriter("../../GenLayer.txt"))
            {
                GenLayer layer = GenLayer.InitAllLayer(1);
                int      x     = -4;
                int      z     = -4;
                int[,] biomeIds = layer.GetInts(16 * x - 16, 16 * z - 16, 48, 48);
                sw.WriteLine("pre: ");
                for (int i = 0; i < 48; ++i)
                {
                    for (int j = 0; j < 48; ++j)
                    {
                        sw.Write(biomeIds[i, j] + " ");
                    }

                    sw.WriteLine();
                }

                biomeIds = layer.GetInts(16 * x, 16 * z, 16, 16);
                sw.WriteLine("suc: ");
                for (int i = 0; i < 16; ++i)
                {
                    for (int j = 0; j < 16; ++j)
                    {
                        sw.Write(biomeIds[i, j] + " ");
                    }

                    sw.WriteLine();
                }
            }
        }
示例#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);
        }
        /// <summary>
        /// Returns a list of integer values generated by this layer. These may be interpreted as temperatures, rainfall
        /// amounts, or biomeList[] indices based on the particular GenLayer subclass.
        /// </summary>
        public override int[] GetInts(int par1, int par2, int par3, int par4)
        {
            int[] ai  = Field_35512_b.GetInts(par1, par2, par3, par4);
            int[] ai1 = Field_35513_c.GetInts(par1, par2, par3, par4);
            int[] ai2 = IntCache.GetIntCache(par3 * par4);

            for (int i = 0; i < par3 * par4; i++)
            {
                if (ai[i] == BiomeGenBase.Ocean.BiomeID)
                {
                    ai2[i] = ai[i];
                    continue;
                }

                if (ai1[i] >= 0)
                {
                    if (ai[i] == BiomeGenBase.IcePlains.BiomeID)
                    {
                        ai2[i] = BiomeGenBase.FrozenRiver.BiomeID;
                        continue;
                    }

                    if (ai[i] == BiomeGenBase.MushroomIsland.BiomeID || ai[i] == BiomeGenBase.MushroomIslandShore.BiomeID)
                    {
                        ai2[i] = BiomeGenBase.MushroomIslandShore.BiomeID;
                    }
                    else
                    {
                        ai2[i] = ai1[i];
                    }
                }
                else
                {
                    ai2[i] = ai[i];
                }
            }

            return(ai2);
        }