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);
            }
        }
Example #2
0
        public override IWorkshopTree New(ActionSet actionSet, Constructor constructor, IWorkshopTree[] constructorValues, object[] additionalParameterData)
        {
            // Create the class.
            var objectData = actionSet.Translate.DeltinScript.SetupClasses().CreateObject(actionSet, "_new_PathMap");

            // Get the pathmap data.
            PathMap pathMap = (PathMap)additionalParameterData[0];

            actionSet.AddAction(objectData.ClassObject.SetVariable(pathMap.NodesAsWorkshopData(), null, 0));
            actionSet.AddAction(objectData.ClassObject.SetVariable(pathMap.SegmentsAsWorkshopData(), null, 1));

            return(objectData.ClassReference.GetVariable());
        }
        protected override void New(ActionSet actionSet, NewClassInfo newClassInfo)
        {
            // Get the pathmap data.
            PathMap pathMap = (PathMap)newClassInfo.AdditionalParameterData[0];

            actionSet.AddAction(Nodes.SetVariable(
                                    value: pathMap.NodesAsWorkshopData(),
                                    index: (Element)newClassInfo.ObjectReference.GetVariable()
                                    ));
            actionSet.AddAction(Segments.SetVariable(
                                    value: pathMap.SegmentsAsWorkshopData(),
                                    index: (Element)newClassInfo.ObjectReference.GetVariable()
                                    ));
        }
Example #4
0
        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
            }));
        }