/// <summary>
        /// Renders a node graph
        /// </summary>
        /// <param name="exportNodeGraph">Node graph snippet to parse</param>
        /// <param name="npc">Npc to which the dialog belongs</param>
        /// <returns>Result of parsing the node graph</returns>
        public async Task <ExportNodeGraphRenderResult> RenderNodeGraph(ExportDialogData exportNodeGraph, KortistoNpc npc)
        {
            _curProject = await _cachedDbAccess.GetDefaultProject();

            _exportSettings = await _cachedDbAccess.GetExportSettings(_curProject.Id);

            SetupStepRenderes();

            ExportNodeGraphRenderResult renderResult = new ExportNodeGraphRenderResult();

            renderResult.StartStepCode           = string.Empty;
            renderResult.AdditionalFunctionsCode = string.Empty;

            // Group to Functions
            ExportDialogFunction rootFunction = new ExportDialogFunction(exportNodeGraph);

            AddNodesToFunction(rootFunction, exportNodeGraph);
            List <ExportDialogFunction> additionalFunctions = ExtractAdditionalFunctions(exportNodeGraph);

            // Render functions
            string startStepCode = await RenderDialogStepList(rootFunction.FunctionSteps, npc);

            string additionalFunctionsCode = string.Empty;

            foreach (ExportDialogFunction curAdditionalFunction in additionalFunctions)
            {
                additionalFunctionsCode += await RenderDialogFunction(curAdditionalFunction, npc);
            }

            renderResult.StartStepCode           = startStepCode;
            renderResult.AdditionalFunctionsCode = additionalFunctionsCode;

            return(renderResult);
        }
示例#2
0
        /// <summary>
        /// Renders a node graph system
        /// </summary>
        /// <param name="dailyRoutineEvent">Daily routine event</param>
        /// <param name="npc">Npc</param>
        /// <param name="errorCollection">Error collection</param>
        /// <returns>Node graph render result</returns>
        private ExportNodeGraphRenderResult RenderNodeGraph(KortistoNpcDailyRoutineEvent dailyRoutineEvent, KortistoNpc npc, ExportPlaceholderErrorCollection errorCollection)
        {
            if (dailyRoutineEvent == null || dailyRoutineEvent.ScriptNodeGraph == null)
            {
                return(new ExportNodeGraphRenderResult());
            }

            if (_renderedEvents.ContainsKey(dailyRoutineEvent.EventId))
            {
                return(_renderedEvents[dailyRoutineEvent.EventId]);
            }

            _nodeGraphExporter.SetErrorCollection(errorCollection);
            _nodeGraphExporter.SetNodeGraphFunctionGenerator(_dailyRoutineNodeGraphFunctionGenerator);
            _nodeGraphExporter.SetNodeGraphRenderer(_dailyRoutineNodeGraphRenderer);
            ExportNodeGraphRenderResult renderResult = _nodeGraphExporter.RenderNodeGraph(dailyRoutineEvent.ScriptNodeGraph, npc).Result;

            _renderedEvents.Add(dailyRoutineEvent.EventId, renderResult);
            return(renderResult);
        }