本文整理汇总了C#中SMP.World.SaveChunk方法的典型用法代码示例。如果您正苦于以下问题:C# World.SaveChunk方法的具体用法?C# World.SaveChunk怎么用?C# World.SaveChunk使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SMP.World
的用法示例。
在下文中一共展示了World.SaveChunk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveLVL
public static void SaveLVL(World w, bool silent = false)
{
if (w.Save != null)
w.Save(w);
if (World.OnSave != null)
World.OnSave(w);
if (cancelsave)
{
cancelsave = false;
return;
}
//TODO Save files
if (!Directory.Exists(w.name)) Directory.CreateDirectory(w.name);
using (StreamWriter sw = new StreamWriter(w.name + "/" + w.name + ".ini"))
{
sw.WriteLine(w.seed);
sw.WriteLine(w.SpawnX);
sw.WriteLine(w.SpawnY);
sw.WriteLine(w.SpawnZ);
sw.WriteLine(w.ChunkLimit);
sw.WriteLine(w.time);
sw.WriteLine(w.dimension);
sw.WriteLine(w.moonPhase);
}
/*using (MemoryStream blocks = new MemoryStream())
{
lock (w.chunkData)
foreach (Chunk ch in w.chunkData.Values)
{
//if (ch == null) continue;
//File.WriteAllBytes(w.name + "/" + ch.x + " " + ch.z, ch.blocks);
blocks.Write(BitConverter.GetBytes(ch.x), 0, 4);
blocks.Write(BitConverter.GetBytes(ch.z), 0, 4);
blocks.Write(ch.blocks, 0, ch.blocks.Length);
}
byte[] bytes;
CompressData(blocks.ToArray(), out bytes);
using (FileStream fs = new FileStream(w.name + "/" + w.name + ".blocks", FileMode.Create))
{
fs.Write(bytes, 0, (int)bytes.Length);
}
}*/
lock (w.chunkData)
{
try
{
Parallel.ForEach(w.chunkData.Keys, delegate(Point pt)
{
w.SaveChunk(pt.x, pt.z);
});
}
catch (NotImplementedException)
{
foreach (Point pt in w.chunkData.Keys)
w.SaveChunk(pt.x, pt.z);
}
}
if (!silent) Logger.Log(w.name + " Saved.");
}