//Initializes the world data given its initial state public void initWorldData(string filePath = "", int width = 0, int height = 0, string behavior = null, List <ActorData> actors = null) { this.worldName = ResourceComponent.getKeyFromPath(filePath); this.filePath = ResourceComponent.getFullPathFromKey(filePath); this.worldBehaviorKey = behavior; this.worldTileData = new TileData[1, width, height]; this.worldActorData = actors; if (this.worldActorData == null) { this.worldActorData = new List <ActorData>(); } if (this.worldBehaviorKey == null) { this.worldBehaviorKey = ""; } //Construct tiles for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { worldTileData[0, x, y] = new TileData(""); } } }
private void setTileBehavior() { string openFile = ""; DialogResult res; try { res = openDlg.ShowDialog(); if (res == DialogResult.OK) { openFile = openDlg.FileName; } } catch (Exception e) { } if (!openFile.Equals("")) { string key = ResourceComponent.getKeyFromPath(openFile); editor.currentValues.behavior = key; editor.currentTile.behavior = key; if (!behaviorOverwriteBox.isDown) { behaviorOverwriteBox.toggle(); } } }
internal ILoadable resource; //Resource that this handle represents /* Handle constructor * * Initialize the handle. Sets up the internal data, but does not actually perform loading from disk. * * @param rc The engine resource component object * @param s The relative path to the resource (see key above) * */ public Handle(ResourceComponent rc, string s) { this.rc = rc; //In order to load the resource from disk, we need the full path to it. this.fullPath = ResourceComponent.getFullPathFromKey(s); if (s.Length < 1) { key = ""; return; } //Makes sure the key is well-formed to be a handle-key this.key = ResourceComponent.getKeyFromPath(s); }
/** * Sets the currently running world * * @param filePath the map-key to load * @param mapFile the mapFile to load, overrides the filePath */ public virtual void setWorld(string filePath, Mapfile mapFile = null) { string worldName = ResourceComponent.getKeyFromPath(filePath); if (worldName != currentWorldName) { resourceComponent.discardScriptStates(); } if (!resourceComponent.loadWorld(filePath, mapFile)) { return; } world = resourceComponent.getWorld(worldName); world.firstUpdate = true; currentWorldName = worldName; }
public void load(ResourceComponent resourceComponent, string path) { rc = resourceComponent; this.scriptKey = ResourceComponent.getKeyFromPath(path); ScriptEngine engine = rc.scriptEngine; try { script = engine.CreateScriptSourceFromFile(path).Compile(); } catch (SyntaxErrorException e) { ExceptionOperations eo; eo = engine.GetService <ExceptionOperations>(); string error = eo.FormatException(e); throw new Exception("\nPython syntax error:\n" + error); } }
public void selectBehaviorAction(Vector2 pos, MouseKeyBinding.MouseButton button) { openFile = ""; DialogResult res; try { res = openDlg.ShowDialog(); if (res == DialogResult.OK) { openFile = openDlg.FileName; } } catch (Exception e) { } if (!openFile.Equals("")) { string key = ResourceComponent.getKeyFromPath(openFile); editor.engine.world.setWorldBehavior(editor.engine.resourceComponent.get(key)); editor.engine.world.file.worldBehaviorKey = key; } }