示例#1
0
		public SavedWorldInfo(World world, TerrainGen terrain)
		{
			colorA = new VoxColor(terrain.colorA);
			colorB = new VoxColor(terrain.colorB);
			terrainSeed = terrain.randomSeed;

			chunkInfos = new List<SavedChunkInfo>();
			
			foreach (var chunk in world.Chunks)
			{
				var chunkInfo = new SavedChunkInfo(chunk.Value);

				if(chunkInfo.hasBlocks) chunkInfos.Add(chunkInfo);
			}
		}
示例#2
0
		public static bool DeleteSaves(World world)
		{
			//var path = Path.Combine(SaveLocation(world.WorldName), FileName(chunk.Pos));

			var path = SaveLocation(world.WorldName);

			if (!Directory.Exists(path))
				return false;

			var files = Directory.GetFiles(path);

			foreach (var file in files)
			{
				File.Delete(file);
			}

			return true;


			//if (!File.Exists(path))
			//	return false;

			//IFormatter formatter = new BinaryFormatter();
			//var stream = new FileStream(path, FileMode.Open);

			//var save = (VoxSave)formatter.Deserialize(stream);

			//foreach (var block in save.Blocks)
			//{
			//	chunk.Blocks[block.Key.x, block.Key.y, block.Key.z] = block.Value;
			//}

			//stream.Close();
			//return true;

			
		}
示例#3
0
		public static SavedWorldInfo LoadWorldInfo(World world)
		{
			var path = Path.Combine(SaveLocation(world.WorldName), WorldInfoName + ".bin");

			if (!File.Exists(path))
				return null;

			IFormatter formatter = new BinaryFormatter();
			var stream = new FileStream(path, FileMode.Open);

			var save = (SavedWorldInfo)formatter.Deserialize(stream);

			//foreach (var block in save.Blocks)
			//{
			//	chunk.Blocks[block.Key.x, block.Key.y, block.Key.z] = block.Value;
			//}

			stream.Close();
			return save;
		}
示例#4
0
		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();
		}