public static void FromPathmapFile(string file) { PathMap map = PathMap.ImportFromXML(file); string baseEditorFile = Extras.CombinePathWithDotNotation(null, "!PathfindEditor.del"); string baseEditorContent = File.ReadAllText(baseEditorFile); Diagnostics diagnostics = new Diagnostics(); DeltinScript deltinScript = new DeltinScript( new FileGetter(null), diagnostics, new ScriptFile(diagnostics, new Uri(baseEditorFile), baseEditorContent), (varCollection) => { // Set the initial nodes. Rule initialNodes = new Rule("Initial Nodes"); initialNodes.Actions = ArrayBuilder <Element> .Build( WorkshopArrayBuilder.SetVariable(null, map.NodesAsWorkshopData(), null, LoadNodes, false), WorkshopArrayBuilder.SetVariable(null, map.SegmentsAsWorkshopData(), null, LoadSegments, false) ); return(new Rule[] { initialNodes }); } ); string code = deltinScript.WorkshopCode; if (code != null) { Program.WorkshopCodeResult(code); } else { Log.Write(LogLevel.Normal, new ColorMod("Build Failed.", ConsoleColor.Red)); diagnostics.PrintDiagnostics(Log); } }
public static DeltinScript Generate(string fileName, Pathmap map, OutputLanguage language) { string baseEditorFile = Extras.CombinePathWithDotNotation(null, "!PathfindEditor.del"); return(new DeltinScript(new TranslateSettings(baseEditorFile) { AdditionalRules = (varCollection) => { // Set the initial nodes. Rule initialNodes = new Rule("Initial Nodes"); initialNodes.Actions = ArrayBuilder <Element> .Build( // File name HUD. Element.Hud(text: new V_CustomString(fileName), sortOrder: 1, textColor: Color.Orange, location: HudLocation.Right), // Set nodes, segments, and attributes. WorkshopArrayBuilder.SetVariable(null, map.NodesAsWorkshopData(), null, LoadNodes, false), WorkshopArrayBuilder.SetVariable(null, map.SegmentsAsWorkshopData(), null, LoadSegments, false), WorkshopArrayBuilder.SetVariable(null, map.AttributesAsWorkshopData(), null, LoadAttributes, false) ); return new Rule[] { initialNodes }; }, OptimizeOutput = false, OutputLanguage = language })); }
public static DeltinScript Generate(PathMap map, OutputLanguage language) { string baseEditorFile = Extras.CombinePathWithDotNotation(null, "!PathfindEditor.del"); return(new DeltinScript(new TranslateSettings(baseEditorFile) { AdditionalRules = (varCollection) => { // Set the initial nodes. Rule initialNodes = new Rule("Initial Nodes"); initialNodes.Actions = ArrayBuilder <Element> .Build( WorkshopArrayBuilder.SetVariable(null, map.NodesAsWorkshopData(), null, LoadNodes, false), WorkshopArrayBuilder.SetVariable(null, map.SegmentsAsWorkshopData(), null, LoadSegments, false) ); return new Rule[] { initialNodes }; }, OptimizeOutput = false, OutputLanguage = language })); }