/// <summary>
        /// Returns the value object to use for scriban exporting
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="project">Project</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Value Object</returns>
        protected override async Task <ScribanDailyRoutineEventStateConditionData> GetExportObject(DailyRoutineEventStateConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            KortistoNpc eventNpc = await _cachedDbAccess.GetNpcById(parsedData.NpcId);

            if (eventNpc == null)
            {
                errorCollection.AddDialogNpcNotFoundError();
                return(null);
            }

            KortistoNpcDailyRoutineEvent exportEvent = null;

            if (eventNpc.DailyRoutine != null)
            {
                exportEvent = eventNpc.DailyRoutine.FirstOrDefault(e => e.EventId == parsedData.EventId);
            }
            if (exportEvent == null)
            {
                errorCollection.AddDialogDailyRoutineEventNotFoundError(eventNpc.Name);
                return(null);
            }

            MiscProjectConfig projectConfig = await _cachedDbAccess.GetMiscProjectConfig();

            ScribanDailyRoutineEventStateConditionData conditionData = new ScribanDailyRoutineEventStateConditionData();

            conditionData.Npc = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, eventNpc, exportSettings, errorCollection);
            conditionData.DailyRoutineEvent = await ScribanDailyRoutineEventUtil.ConvertDailyRoutineEvent(_dailyRoutineFunctionNameGenerator, eventNpc, exportEvent, project, projectConfig, exportSettings);

            return(conditionData);
        }
        /// <summary>
        /// Fills the placeholders
        /// </summary>
        /// <param name="template">Template to use</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="parsedData">Parsed config data</param>
        /// <param name="eventNpc">Npc to which the event belongs</param>
        /// <param name="exportEvent">Event to export</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="curStep">Current step that is rendered</param>
        /// <param name="nextStep">Next step that is being rendered</param>
        /// <param name="project">Project</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <param name="stepRenderer">Action Step renderer</param>
        /// <returns>Filled placeholders</returns>
        protected override async Task <string> FillPlaceholders(ExportTemplate template, ExportPlaceholderErrorCollection errorCollection, SetDailyRoutineEventStateData parsedData, KortistoNpc eventNpc, KortistoNpcDailyRoutineEvent exportEvent,
                                                                FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, GoNorthProject project, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            MiscProjectConfig projectConfig = await _cachedDbAccess.GetMiscProjectConfig();

            ScribanSetDailyRoutineEventStateActionData setDailyRoutineEventStateData = new ScribanSetDailyRoutineEventStateActionData();

            setDailyRoutineEventStateData.Npc               = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, eventNpc, exportSettings, errorCollection);
            setDailyRoutineEventStateData.Npc.IsPlayer      = eventNpc.IsPlayerNpc;
            setDailyRoutineEventStateData.DailyRoutineEvent = await ScribanDailyRoutineEventUtil.ConvertDailyRoutineEvent(_dailyRoutineFunctionNameGenerator, eventNpc, exportEvent, project, projectConfig, exportSettings);

            return(await ScribanActionRenderingUtil.FillPlaceholders(_cachedDbAccess, errorCollection, template.Code, setDailyRoutineEventStateData, flexFieldObject, curStep, nextStep, _scribanLanguageKeyGenerator, stepRenderer));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Renders a dialog step
        /// </summary>
        /// <param name="template">Export template</param>
        /// <param name="data">Dialog Step Data</param>
        /// <param name="project">Project for which the epxort is running</param>
        /// <param name="referenceNodeData">Reference node data</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <returns>Dialog Step Render Result</returns>
        public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportTemplate template, ExportDialogData data, GoNorthProject project, ReferenceNodeData referenceNodeData, FlexFieldObject flexFieldObject)
        {
            ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult();

            Template parsedTemplate = ScribanParsingUtil.ParseTemplate(template.Code, _errorCollection);

            if (parsedTemplate == null)
            {
                return(renderResult);
            }

            MiscProjectConfig projectConfig = await _exportCachedDbAccess.GetMiscProjectConfig();

            _languageKeyGenerator.SetErrorCollection(_errorCollection);

            ScribanReferenceData referenceData = BuildDialogRenderObject <ScribanReferenceData>(data, data.Children.FirstOrDefault() != null ? data.Children.FirstOrDefault().Child : null, flexFieldObject);

            referenceData.ReferenceText = referenceNodeData.ReferenceText != null ? referenceNodeData.ReferenceText : string.Empty;
            referenceData.ObjectType    = referenceNodeData.ObjectType;
            if (referenceNodeData.Npc != null)
            {
                referenceData.Npc          = FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportNpc>(null, null, referenceNodeData.Npc, _exportSettings, _errorCollection);
                referenceData.Npc.IsPlayer = referenceNodeData.Npc.IsPlayerNpc;
            }
            else
            {
                referenceData.Npc = null;
            }
            referenceData.Item = referenceNodeData.Item != null?FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportItem>(null, null, referenceNodeData.Item, _exportSettings, _errorCollection) : null;

            referenceData.Skill = referenceNodeData.Skill != null?FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportSkill>(null, null, referenceNodeData.Skill, _exportSettings, _errorCollection) : null;

            referenceData.Quest = referenceNodeData.Quest != null?FlexFieldValueCollectorUtil.BuildFlexFieldValueObject <ScribanExportQuest>(null, null, referenceNodeData.Quest, _exportSettings, _errorCollection) : null;

            referenceData.WikiPage          = referenceNodeData.WikiPage != null ? new ScribanExportWikiPage(referenceNodeData.WikiPage) : null;
            referenceData.DailyRoutineEvent = referenceNodeData.DailyRoutineEvent != null ? await ScribanDailyRoutineEventUtil.ConvertDailyRoutineEvent(_dailyRoutineFunctionNameGenerator, referenceNodeData.Npc, referenceNodeData.DailyRoutineEvent, project, projectConfig, _exportSettings) : null;

            referenceData.Marker = referenceNodeData.Marker != null ? new ScribanExportMapMarker(referenceNodeData.Marker) : null;

            TemplateContext context = BuildTemplateContext(referenceData);

            renderResult.StepCode = await parsedTemplate.RenderAsync(context);

            return(renderResult);
        }