Exemplo n.º 1
0
 public override void GenerateChunk(UngeneratedChunk chunk)
 {
     if (chunk.chunkY < 0)
     {
         chunk.Fill(material);
     }
 }
Exemplo n.º 2
0
        public GenerateChunkTask(WorldPopulator populator, BlockWorld world)
        {
            this.populator = populator;
            this.world     = world;
            chunk          = new UngeneratedChunk();

            world.EnsureFullyGenerated();
        }
Exemplo n.º 3
0
        public void SetChunk(UngeneratedChunk gen)
        {
            Chunk chunk = GetChunkByCoords(gen.chunkX, gen.chunkY, gen.chunkZ, true);

            chunk.LoadFromUngenerated(gen);

            if (autoRemesh)
            {
                chunk.Regenerate();

                Chunk c;

                c = chunk.GetNearbyChunk(0);
                if (c != null)
                {
                    c.Regenerate();
                }

                c = chunk.GetNearbyChunk(1);
                if (c != null)
                {
                    c.Regenerate();
                }

                c = chunk.GetNearbyChunk(2);
                if (c != null)
                {
                    c.Regenerate();
                }

                c = chunk.GetNearbyChunk(3);
                if (c != null)
                {
                    c.Regenerate();
                }

                c = chunk.GetNearbyChunk(4);
                if (c != null)
                {
                    c.Regenerate();
                }

                c = chunk.GetNearbyChunk(5);
                if (c != null)
                {
                    c.Regenerate();
                }
            }
        }
Exemplo n.º 4
0
        public void LoadFromUngenerated(UngeneratedChunk gen)
        {
            blockCount = gen.GetBlockCount();
            Array.Copy(gen.GetBlocks(), blocks, blocks.Length);
            Array.Copy(gen.GetBlockStates(), blockStates, blockStates.Length);
            MarkForRemesh();

            // Update nearby chunks
            {
                Chunk c;

                c = GetNearbyChunk(0);
                if (c != null)
                {
                    c.MarkForRemesh();
                }

                c = GetNearbyChunk(1);
                if (c != null)
                {
                    c.MarkForRemesh();
                }

                c = GetNearbyChunk(2);
                if (c != null)
                {
                    c.MarkForRemesh();
                }

                c = GetNearbyChunk(3);
                if (c != null)
                {
                    c.MarkForRemesh();
                }

                c = GetNearbyChunk(4);
                if (c != null)
                {
                    c.MarkForRemesh();
                }

                c = GetNearbyChunk(5);
                if (c != null)
                {
                    c.MarkForRemesh();
                }
            }
        }
Exemplo n.º 5
0
        public override void GenerateChunk(UngeneratedChunk chunk)
        {
            int x1 = chunk.chunkX * 16;
            int y1 = chunk.chunkY * 16;
            int z1 = chunk.chunkZ * 16;

            int x, y, z, y2, u;

            for (x = 0; x < 16; x++)
            {
                for (z = 0; z < 16; z++)
                {
                    y = GetTerrainHeight(x + x1, z + z1);

                    for (y2 = 0; y2 < 16; y2++)
                    {
                        u = y - (y1 + y2);
                        if (u < 0)
                        {
                            break;
                        }

                        if (u < layersOfGrass)
                        {
                            chunk.SetMaterial(x, y2, z, grass);
                        }
                        else if (u < layersOfGrass + layersOfDirt)
                        {
                            chunk.SetMaterial(x, y2, z, dirt);
                        }
                        else
                        {
                            chunk.SetMaterial(x, y2, z, stone);
                        }
                    }
                }
            }
        }