public static void SaveTnt(IReadOnlyMapModel map, string filename) { using (var s = new TntWriter(File.Create(filename))) { s.WriteTnt(new MapModelTntAdapter(map)); } }
public MapModelTntAdapter(IReadOnlyMapModel model) { this.model = model; this.tiles = Util.GetUsedTiles(model.Tile).ToArray(); this.reverseTiles = Util.ReverseMapping(this.tiles); this.features = model.EnumerateFeatureInstances().Select(x => x.FeatureName).Distinct().ToArray(); this.reverseFeatures = Util.ReverseMapping(this.features); }
public static void SaveHpi(IReadOnlyMapModel map, string filename) { var namePart = Path.GetFileNameWithoutExtension(filename); var tmpTntName = Path.GetTempFileName(); var tmpOtaName = Path.GetTempFileName(); try { using (var s = new TntWriter(File.Create(tmpTntName))) { s.WriteTnt(new MapModelTntAdapter(map)); } using (Stream s = File.Create(tmpOtaName)) { map.Attributes.WriteOta(s); } var fname = "maps\\" + namePart; using (var wr = new HpiWriter(filename, HpiWriter.CompressionMethod.ZLib)) { wr.AddFile(fname + ".tnt", tmpTntName); wr.AddFile(fname + ".ota", tmpOtaName); } } finally { if (File.Exists(tmpTntName)) { File.Delete(tmpTntName); } if (File.Exists(tmpOtaName)) { File.Delete(tmpOtaName); } } }