Exemplo n.º 1
0
        public override Chunk DoGenerate(Vector3i index)
        {
            Chunk chunk = world.viewableChunks.load(index);

            try
            {
                if (chunk == null)
                {
                    // Create a new chunk
                    chunk = new Chunk(world, index);

                    if (chunk.State == ChunkState.AwaitingGenerate)
                    {
                        // Generate the chunk with the current generator
                        chunk.State = ChunkState.Generating;
                        world.Generator.Generate(chunk);
                        _lightingChunkProcessor.ProcessChunk(chunk);
                        chunk.State = ChunkState.AwaitingLighting;
                    }
                }
                // Assign a renderer
                // ChunkRenderer cRenderer = new MultiThreadLightingChunkRenderer(GraphicsDevice, world, chunk);
                // this.ChunkRenderers.TryAdd(chunk.Index,cRenderer);
            }
            catch (Exception e)
            {
                //Debug.WriteLine("DoGenerate Exception {0}", e);
                Debug.WriteLine("DoGenerate Exception Chunk = {0},{1} - State = {2}", chunk.Position.X, chunk.Position.Z, chunk.State);
                throw e;
            }
            return(chunk);
        }
Exemplo n.º 2
0
        public override Chunk DoGenerate(Vector3i index)
        {
            Chunk chunk = world.viewableChunks.load(index);

            if (chunk == null)
            {
                // Create a new chunk
                chunk = new Chunk(world, index);
            }

            // Generate the chunk with the current generator

            world.Generator.Generate(chunk);
            _lightingChunkProcessor.ProcessChunk(chunk);
            chunk.State = ChunkState.AwaitingBuild;
            return(chunk);
        }