public static Map ReadFromXml(string fileName, ICreator creator, out MapExport outMap) { MapExport mapExport = null; bool status = MapExport.Load(ref mapExport, fileName); Map map = new Map(mapExport.Name, mapExport.Height, mapExport.Width, mapExport.ViewWidth); for (int i = 0; i < mapExport.Data.Count; i++) { string line = mapExport.Data[i]; for (int j = 0; j < line.Length; j++) { int n = int.Parse(line[j].ToString()); Tile tile = null; if (n != 0) { string tileName = mapExport.GetTileExport(n).Name; tile = creator.CreateInstance <Tile>(tileName); tile.Map = map; tile.IsAlive = true; tile.Position = new Vector2(j * Tile.DefaultWidth, i * Tile.DefaultHeight); } map.Tiles[i, j] = tile; } } outMap = mapExport; return(map); }
public static void ScanPathfinding() { if (!Paths.HasExecutablePath()) { EditorUtility.DisplayDialog("Could not export map", "No executable set. Please find your game executable file with Ravenfield Tools -> Set Game Executable", "Ok"); return; } // Remove existing graph cache files because some users have been unable to update the existing files. // Also this guarantees that if we run scan pathfinding, either we will get an up to date cache or none at all. RemoveGraphCache(); string filepath; bool ok = MapExport.BuildBundle(BuildTarget.StandaloneWindows, out filepath, true); if (!ok) { Debug.Log("Cancelling Scan Pathfinding as map export failed."); return; } Debug.Log("Export completed, launching pathfinding generator!"); string cacheWritebackPath = Paths.GraphCachePath(EditorSceneManager.GetSceneAt(0)); string parameters = "-nointro \"-generatenavcache " + cacheWritebackPath + "\" \"-custommap " + filepath + "\""; Paths.LaunchGame(parameters); }
static void Main(string[] args) { // register URL with a specific WFS reader WfsReaderFactory.RegisterHandler(URL, typeof(WfsReader)); // Get the WFS capabilities of the WFS server using the HTTP GET method. try { // Get the WFS capabilities of the WFS server using the HTTP GET method. WfsCapabilities Capabilities = WfsClient.GetCapabilities(RequestMethod.GET, URL); } catch { MessageBox.Show("Please check if " + URL + " is a valid WFS URL"); return; } // Do something with the the WfsCapabilities here... // Get the schema for the USA feature type string[] TypeNames = new string[] { "miwfs:USA" }; // Do something with the schema here... XmlSchema usaSchema = WfsClient.DescribeFeatureType(URL, TypeNames); // Get all features from the USA feature type MultiFeatureCollection usa = WfsClient.GetFeature(URL, TypeNames, null, null, -1, null); IFeatureCollection fc = usa[0]; // iterate over the Usa MultiFeatureCollection and add each // IFeatureCollection to a MemTable, etc... TableInfoMemTable memTableInfo = new TableInfoMemTable("myMemTable"); foreach (Column c in fc.Columns) { memTableInfo.Columns.Add(c); } Table memTable = Session.Current.Catalog.CreateTable(memTableInfo); memTable.InsertFeatures(fc); // create a layer from the MemTable FeatureLayer featureLayer = new FeatureLayer(memTable); // create the map and add the layer Map map = Session.Current.MapFactory.CreateEmptyMap(new Size(500, 500)); map.Layers.Add(featureLayer); // export the map to a file if (args.Length > 0 && args[0] != null && args[0].Trim().Length != 0) { using (MapExport me = new MapExport(map)) { me.Format = ExportFormat.Gif; me.Export(args[0]); } } // clean up the map Session.Current.MapFactory.Remove(map); }
private void ExportMap(MapParams mapParams) { Texture2D tex = MapExport.TexFromMap(GraphicsDevice, map); Directory.CreateDirectory("Maps/Tests/create"); using (FileStream file = File.Open("Maps/Tests/create/map" + mapParams.seed + ".png", FileMode.Create)) { tex.SaveAsPng(file, mapParams.size.X, mapParams.size.Y); } }
static void ExportSelected() { if (IsContentModObject(Selection.activeGameObject)) { ExportContent(); } else if (FindObjectOfType <SpawnPointNeighborManager>() != null) { MapExport.ExportMap(); } else { EditorUtility.DisplayDialog("Nothing to export", "There is no open map or content mod to export", "Ok"); } }
static void TestSelected() { if (IsContentModObject(Selection.activeGameObject)) { string contentModPath = ""; bool ok = ExportContentModObject(Selection.activeGameObject, out contentModPath); if (ok) { string parameters = "-nointro -noworkshopmods -nocontentmods \"-testcontentmod " + contentModPath + "\" \"-map Vehicle Testing\""; Paths.LaunchGame(parameters); } else { EditorUtility.DisplayDialog("Export failed", "Content mod couldn't be built. Please see the console for error messages.", "Ok"); } } else if (FindObjectOfType <SpawnPointNeighborManager>() != null) { if (!Paths.HasExecutablePath()) { EditorUtility.DisplayDialog("Could not export map", "No executable set. Please find your game executable file with Ravenfield Tools -> Set Game Executable", "Ok"); return; } string path; bool ok = MapExport.BuildBundle(BuildTarget.StandaloneWindows, out path, false); if (ok) { string parameters = "-nointro -noworkshopmods -nocontentmods \"-custommap " + path + "\""; Paths.LaunchGame(parameters); } else { EditorUtility.DisplayDialog("Export failed", "Map couldn't export properly. Please see the console for error messages.", "Ok"); } } else { EditorUtility.DisplayDialog("Nothing to export", "There is no open map or content mod to export", "Ok"); } }
/// <summary> /// Exports a map with a given MapAlias, width, and height into a stream and returns it. /// </summary> /// <remarks>The stream containing the map is written to the response and streamed back to the client.</remarks> /// <param name="mapAlias">MapAlias of the requested map.</param> /// <param name="mapWidth">Width of the map.</param> /// <param name="mapHeight">Height of the map.</param> /// <param name="exportFormat">Export format to be used to export the map.</param> /// <returns>Returns the stream containing the map.</returns> public virtual MemoryStream GetMap(string mapAlias, int mapWidth, int mapHeight, string exportFormat) { Map map = GetMapObj(mapAlias); map.Size = new Size(mapWidth, mapHeight); ExportFormat ef = (ExportFormat)ExportFormat.Parse(typeof(ExportFormat), exportFormat); MemoryStream memStream = null; if (map != null) { MapExport mapExport = new MapExport(map); mapExport.ExportSize = new ExportSize(mapWidth, mapHeight); memStream = new MemoryStream(); mapExport.Format = ef; mapExport.Export(memStream); memStream.Position = 0; mapExport.Dispose(); } return(memStream); }
void OnEnable() { exporter = (MapExport)target; exporter.Init(); Tools.hidden = true; }