Esempio n. 1
0
        private void GenerateInitialObjects()
        {
            float maxHeight = Overworld.GetMaxHeight(SpawnRect);
            Dictionary <string, Dictionary <string, int> > creatures = new Dictionary <string, Dictionary <string, int> >();

            foreach (var chunk in ChunkManager.ChunkData.GetChunkEnumerator())
            {
                ChunkManager.ChunkGen.GenerateSurfaceLife(creatures, chunk, maxHeight);
            }
        }
Esempio n. 2
0
        // Todo: Move to ChunkGenerator
        public void GenerateInitialChunks(Rectangle spawnRect, GlobalChunkCoordinate origin, Action <String> SetLoadingMessage)
        {
            var initialChunkCoordinates = new List <GlobalChunkCoordinate>();

            for (int dx = 0; dx < WorldSize.X; dx++)
            {
                for (int dz = 0; dz < WorldSize.Z; dz++)
                {
                    initialChunkCoordinates.Add(new GlobalChunkCoordinate(dx, 0, dz));
                }
            }

            SetLoadingMessage("Generating Chunks...");
            float maxHeight = Math.Max(Overworld.GetMaxHeight(spawnRect), 0.17f);

            foreach (var box in initialChunkCoordinates)
            {
                Vector3 worldPos = new Vector3(
                    box.X * VoxelConstants.ChunkSizeX,
                    box.Y * VoxelConstants.ChunkSizeY,
                    box.Z * VoxelConstants.ChunkSizeZ);
                VoxelChunk chunk = ChunkGen.GenerateChunk(worldPos, World, maxHeight);
                ChunkData.AddChunk(chunk);
            }


            // This is critical at the beginning to allow trees to spawn on ramps correctly,
            // and also to ensure no inconsistencies in chunk geometry due to ramps.
            foreach (var chunk in ChunkData.ChunkMap)
            {
                ChunkGen.GenerateChunkData(chunk, World, maxHeight);
                for (var i = 0; i < VoxelConstants.ChunkSizeY; ++i)
                {
                    chunk.InvalidateSlice(i);
                }
            }
            RecalculateBounds();
            SetLoadingMessage("Generating Ores...");

            GenerateOres();
            NeedsMinimapUpdate = true;
        }