public T[] LoadLayerData <T>(IZone zone, string name) where T : struct { var path = zone.CreateTerrainDataFilename(name); var data = _fileSystem.ReadLayer <T>(path); Logger.Info("Layer data loaded. (" + name + ") zone:" + zone.Id); return(data); }
public void SaveLayerToDisk <T>(IZone zone, ILayer <T> layer) where T : struct { var baseFilename = zone.CreateTerrainDataFilename(layer.LayerType.ToString().ToLower(), ""); using (var md5 = MD5.Create()) { var tmpFn = baseFilename + "tmp" + DateTime.Now.Ticks + ".bin"; var layerData = layer.RawData.ToByteArray(); _fileSystem.WriteLayer(tmpFn, layerData); if (!md5.ComputeHash(layerData).SequenceEqual(md5.ComputeHash(_fileSystem.ReadLayerAsByteArray(tmpFn)))) { return; } _fileSystem.MoveLayerFile(tmpFn, baseFilename + "bin"); Logger.Info("Layer saved. (" + baseFilename + ")"); } }
public void SaveBitmap(IZone zone, Bitmap bitmap, string name) { var fn = _fileSystem.CreatePath("bitmaps", zone.CreateTerrainDataFilename(name, "png")); bitmap.Save(fn, ImageFormat.Png); }