Пример #1
0
        public override void Generate(IWorld world, ChunkPos pos, BlockData[,,] blocks, Quaternion[,,] rotations, byte[,] heightMap, GenerationHelper helper, GenerationContext context)
        {
            pos = ChunkPos.Get(pos.X / ChunkWidth, pos.Z / ChunkWidth); // 。。。

            int       range  = m_Range;
            BiomeData biome  = context.Biomes[ChunkWidth / 2, ChunkWidth / 2];
            Random    random = new Random(helper.Seed);

            int rand1 = random.Next();
            int rand2 = random.Next();

            // 遍历周围 (range * 2 + 1) * (range * 2 + 1) 的区块,默认 range = 8
            for (int x = pos.X - range; x <= pos.X + range; x++)
            {
                for (int z = pos.Z - range; z <= pos.Z + range; z++)
                {
                    int randX = x * rand1;
                    int randZ = z * rand2;
                    random = new Random(randX ^ randZ ^ helper.Seed);

                    RecursiveGenerate(world, ChunkPos.Get(x, z), pos, blocks, biome, random);
                }
            }
        }