public static byte[] SerializeVoxelAreaData (VoxelArea v) { #if !ASTAR_RECAST_CLASS_BASED_LINKED_LIST System.IO.MemoryStream stream = new System.IO.MemoryStream(); System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); writer.Write (v.width); writer.Write (v.depth); writer.Write (v.linkedSpans.Length); for (int i=0;i<v.linkedSpans.Length;i++) { writer.Write(v.linkedSpans[i].area); writer.Write(v.linkedSpans[i].bottom); writer.Write(v.linkedSpans[i].next); writer.Write(v.linkedSpans[i].top); } //writer.Close(); writer.Flush(); Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(); stream.Position = 0; zip.AddEntry ("data",stream); System.IO.MemoryStream stream2 = new System.IO.MemoryStream(); zip.Save(stream2); byte[] bytes = stream2.ToArray(); stream.Close(); stream2.Close(); return bytes; #else throw new System.NotImplementedException ("This method only works with !ASTAR_RECAST_CLASS_BASED_LINKED_LIST"); #endif }
public static byte[] SerializeVoxelAreaData (VoxelArea v) { System.IO.MemoryStream stream = new System.IO.MemoryStream(); System.IO.BinaryWriter writer = new System.IO.BinaryWriter(stream); writer.Write (v.width); writer.Write (v.depth); writer.Write (v.linkedSpans.Length); for (int i=0;i<v.linkedSpans.Length;i++) { writer.Write(v.linkedSpans[i].area); writer.Write(v.linkedSpans[i].bottom); writer.Write(v.linkedSpans[i].next); writer.Write(v.linkedSpans[i].top); } //writer.Close(); writer.Flush(); Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile(); stream.Position = 0; zip.AddEntry ("data",stream); System.IO.MemoryStream stream2 = new System.IO.MemoryStream(); zip.Save(stream2); byte[] bytes = stream2.ToArray(); stream.Close(); stream2.Close(); return bytes; }