public void SaveAll() { var worldSaveInfo = new SavedWorldInfo(this, terrainGenerator); Serialization.SaveWorldInfo(this, worldSaveInfo); VoxManager.ShowMessage("World Saved"); //DeleteAllChunks(); }
IEnumerator ProceduralLoad(SavedWorldInfo worldInfo) { while (buildingTerrain) { yield return new WaitForEndOfFrame(); } foreach (var chunkInfo in worldInfo.chunkInfos) { var chunk = Chunks.ContainsKey(chunkInfo.worldPos) ? Chunks[chunkInfo.worldPos] : CreateChunk(chunkInfo.worldPos.x, chunkInfo.worldPos.y, chunkInfo.worldPos.z, chunkInfo.initEmpty); foreach (var block in chunkInfo.Blocks) { block.Value.JustCreated = false; chunk.Blocks[block.Key.x, block.Key.y, block.Key.z] = block.Value; } chunk.RebuildNeeded = true; } vignette.ToggleVignette(false); VoxManager.ShowMessage(""); //var allEmpty = false; //while (!allEmpty) //{ // allEmpty = true; // var playerPos = VoxTerrain.GetBlockPos(VoxManager.Player.position); // for (var px = -3; px < 3; px++) // { // for (var py = -3; py < 5; py++) // { // for (var pz = -3; pz < 3; pz++) // { // var p = playerPos + new WorldPos(px, py, pz); // var b = GetBlock(p); // if (!b.IsEmpty()) // { // allEmpty = false; // break; // } // } // } // } // VoxManager.Player.position = VoxManager.Player.position + Vector3.up*2; //} //Debug.Log("Initial Building Finished"); InitialBuildFinished = true; }
public static void SaveWorldInfo(World world, SavedWorldInfo worldInfo) { var path = Path.Combine(SaveLocation(world.WorldName), WorldInfoName + ".bin"); IFormatter formatter = new BinaryFormatter(); var stream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None); formatter.Serialize(stream, worldInfo); stream.Close(); }