private static void WriteBoxes(EU2.Map.ProvinceBoundBox[] boxes, EU2.IO.CSVWriter writer) { writer.EndRow( "ProvinceId;Left;Top;Right;Bottom;" ); foreach(EU2.Map.ProvinceBoundBox box in boxes) { writer.Write(box.ProvinceID); writer.Write(box.Left); writer.Write(box.Top); writer.Write(box.Right); writer.Write(box.Bottom); writer.EndRow(); } writer.Flush(); }
private static void WriteRegions(EU2.Map.IDGrid idgrid, EU2.Data.ProvinceList provinces, IDMap idmap, EU2.IO.CSVWriter writer) { writer.EndRow( "region-index-x;region-index-y;region-offset-x;region-offset-x;region-provinceCount;index;provinceId;name" ); for(int y=0; y<idgrid.Height; ++y ) { for(int x=0; x<idgrid.Width; ++x ) { ushort[] list = idgrid.GetIDs(x,y); if ( list.Length == 0 ) { writer.Write(x); writer.Write(y); writer.Write(x*EU2.Map.IDGrid.RegionWidth); writer.Write(y*EU2.Map.IDGrid.RegionHeight); writer.Write(0); Rectangle rect = Rectangle.Empty; if ( !EU2.Map.IDGrid.CheckAreaForOverflow(idmap, EU2.Map.IDGrid.GetRegionRect(x,y), out rect) ) { writer.Write("Overflow"); writer.Write(rect.X); writer.Write(rect.Y); writer.Write(rect.Width); writer.Write(rect.Height); } writer.EndRow(); } else { int i=0; for(; i<list.Length; ++i) { if ( list[i] == 0 && i>0 ) break; } int cnt = i; for(i=0; i<list.Length; ++i) { if ( list[i] == 0 && i>0 ) break; writer.Write(x); writer.Write(y); writer.Write(x*EU2.Map.IDGrid.RegionWidth); writer.Write(y*EU2.Map.IDGrid.RegionHeight); writer.Write(cnt); writer.Write(i); writer.Write(list[i]); writer.Write(provinces[list[i]].Name); writer.EndRow(); } } } } writer.Flush(); }
private static void WriteAdjacencies(EU2.Map.AdjacencyTable adjtable, EU2.Data.ProvinceList provinces, EU2.IO.CSVWriter writer) { writer.EndRow( "fromProvinceId;fromProvinceName;toProvinceId;toProvinceName;type" ); for(int i=Province.MinID; i<=Province.MaxID; ++i) { EU2.Map.Adjacent[] adj = adjtable[i]; for(int t=0; t<adj.Length; ++t) { writer.Write(i); writer.Write(provinces[i].Name); writer.Write(adj[t].ID); writer.Write(provinces[adj[t].ID].Name); writer.Write(adj[t].Type.ToString().ToLower()); writer.EndRow(); } } writer.Flush(); }