Ejemplo n.º 1
0
        public void Generate(StructureGenerationInfo info, int chunkX, int chunkZ, ChunkColumnStorage chunk, Biome biome)
        {
            int range = _range;

            _info = info;
            _rand = new Random(info.Seed);
            int rand1 = _rand.Next();
            int rand2 = _rand.Next();

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

                    // 调用子类方法
                    RecursiveGenerate(info, x, z, chunkX, chunkZ, chunk, biome);
                }
            }
        }
Ejemplo n.º 2
0
 protected abstract void RecursiveGenerate(StructureGenerationInfo info, int chunkX, int chunkZ, int centerChunkX, int centerChunkZ, ChunkColumnStorage chunk, Biome biome);
Ejemplo n.º 3
0
 public StructureGenerator(StructureGenerationInfo info, int range = 8)
 {
     _range = range;
     _rand  = null;
     _info  = info;
 }