/// <summary>
        /// Renders an export snippet function
        /// </summary>
        /// <param name="functionTemplate">Function template</param>
        /// <param name="function"></param>
        /// <returns></returns>
        private async Task <string> RenderExportSnippetFunction(ExportTemplate functionTemplate, ExportSnippetFunction function)
        {
            ExportObjectData objectData = new ExportObjectData();

            objectData.ExportData.Add(ExportConstants.ExportDataObject, function);

            ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectExportSnippetFunction, functionTemplate.Code, objectData, functionTemplate.RenderingEngine);

            _errorCollection.Merge(fillResult.Errors);

            return(fillResult.Code);
        }
        /// <summary>
        /// Renders the inventory based on the shared template
        /// </summary>
        /// <param name="data">Export Data</param>
        /// <param name="indent">Indentation</param>
        /// <returns>Item List</returns>
        private async Task <string> RenderInventory(ExportObjectData data, string indent)
        {
            GoNorthProject project = await _cachedDbAccess.GetUserProject();

            ExportTemplate inventoryTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.ObjectInventory);

            ExportPlaceholderFillResult fillResult = await _placeholderResolver.FillPlaceholders(TemplateType.ObjectInventory, inventoryTemplate.Code, data, inventoryTemplate.RenderingEngine);

            _errorCollection.Merge(fillResult.Errors);

            return(ExportUtil.IndentListTemplate(fillResult.Code, indent));
        }
示例#3
0
        /// <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="valueObject">Value object 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="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, LearnForgetSkillActionData parsedData, IFlexFieldExportable valueObject, FlexFieldObject flexFieldObject,
                                                                ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeSkill);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            string actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(template.Code, flexFieldExportData).Result;

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <summary>
        /// Renders a function for a list
        /// </summary>
        /// <param name="project">Current Project</param>
        /// <param name="functionCode">Function code to use</param>
        /// <returns>Function</returns>
        public async Task <string> RenderFunctionForList(GoNorthProject project, ExportDialogFunctionCode functionCode)
        {
            ExportTemplate functionTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.TaleDialogFunction);

            ExportObjectData objectData = new ExportObjectData();

            objectData.ExportData.Add(ExportConstants.ExportDataObject, functionCode);

            ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.TaleDialogFunction, functionTemplate.Code, objectData, functionTemplate.RenderingEngine);

            _errorCollection.Merge(fillResult.Errors);

            return(fillResult.Code);
        }
示例#5
0
        /// <summary>
        /// Builds an action from parsed data
        /// </summary>
        /// <param name="template">Template to export</param>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="data">Dialog data</param>
        /// <param name="nextStep">Next step in the dialog</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>
        /// <param name="stepRenderer">Action Step renderer</param>
        /// <returns>Action string</returns>
        public override async Task <string> BuildActionFromParsedData(ExportTemplate template, ChangeTargetNpcStateActionData parsedData, ExportDialogData data, ExportDialogData nextStep, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection,
                                                                      FlexFieldObject flexFieldObject, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_State).Replace(template.Code, ExportUtil.EscapeCharacters(parsedData.ObjectState, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, flexFieldObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeSkill);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = await _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData);

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, data, nextStep, flexFieldObject));
        }
        /// <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="valueObject">Value object 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="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, InventoryActionData parsedData, IFlexFieldExportable valueObject, FlexFieldObject flexFieldObject, ExportDialogData curStep,
                                                                ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Quantity).Replace(template.Code, parsedData.Quantity.HasValue ? parsedData.Quantity.Value.ToString() : "1");

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeItem);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = await _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData);

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <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="valueObject">Value object to use</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="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, PlayAnimationActionData parsedData, IFlexFieldExportable valueObject, FlexFieldObject flexFieldObject,
                                                                ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Animation).Replace(template.Code, ExportUtil.EscapeCharacters(parsedData.AnimationName, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result;

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <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)
        {
            string actionCode = await _dailyRoutineEventPlaceholderResolver.ResolveDailyRoutineEventPlaceholders(template.Code, eventNpc, exportEvent);

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, eventNpc);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result;

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
示例#9
0
        /// <summary>
        /// Builds an action from parsed data
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="data">Dialog data</param>
        /// <param name="project">Project</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="npc">Npc to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Action string</returns>
        public override async Task <string> BuildActionFromParsedData(ValueActionRenderBase.ValueFieldActionData parsedData, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, KortistoNpc npc, ExportSettings exportSettings)
        {
            ExportTemplate actionTemplate = await GetExportTemplate(project);

            IFlexFieldExportable valueObject = await GetValueObject(parsedData, npc, errorCollection);

            if (valueObject == null)
            {
                return(string.Empty);
            }

            FlexField exportField = DialogFlexFieldUtil.GetFlexField(valueObject, parsedData.FieldId);

            if (exportField == null)
            {
                errorCollection.AddErrorFlexField(parsedData.FieldName, valueObject.Name);
                return(string.Empty);
            }

            string actionCode = actionTemplate.Code;

            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ValueName).Replace(actionCode, m => {
                return(DialogFlexFieldUtil.GetFieldName(exportField, parsedData.FieldName, errorCollection));
            });
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(actionCode, GetOperatorFromTemplate(project, parsedData.Operator, errorCollection));
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsSetTo_Start, Placeholder_OperatorIsSetTo_End, parsedData.Operator == "=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_OperatorIsNotSetTo_Start, Placeholder_OperatorIsNotSetTo_End, parsedData.Operator != "=");
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_ValueIsString_Start, Placeholder_ValueIsString_End, exportField.FieldType != ExportConstants.FlexFieldType_Number);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_ValueIsNumber_Start, Placeholder_ValueIsNumber_End, exportField.FieldType == ExportConstants.FlexFieldType_Number);
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ValueChange).Replace(actionCode, m => {
                if (exportField.FieldType != ExportConstants.FlexFieldType_Number)
                {
                    return(ExportUtil.EscapeCharacters(parsedData.ValueChange, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));
                }

                return(parsedData.ValueChange);
            });

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, GetFlexFieldExportObjectType());

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result;

            return(actionCode);
        }
        /// <summary>
        /// Builds a condition element from parsed data
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="project">Project</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="npc">Npc to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Condition string</returns>
        public override string BuildConditionElementFromParsedData(ValueConditionResolverBase.ValueFieldConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, KortistoNpc npc, ExportSettings exportSettings)
        {
            ExportTemplate       conditionTemplate = GetExportTemplate(project);
            IFlexFieldExportable valueObject       = GetValueObject(parsedData, npc, errorCollection);

            if (valueObject == null)
            {
                return(string.Empty);
            }

            FlexField exportField = DialogFlexFieldUtil.GetFlexField(valueObject, parsedData.FieldId);

            if (exportField == null)
            {
                errorCollection.AddErrorFlexField(parsedData.FieldName, valueObject.Name);
                return(string.Empty);
            }

            string conditionCode = conditionTemplate.Code;

            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_IsOperatorPrimitiveStart, Placeholder_IsOperatorPrimitiveEnd, IsOperatorPrimitiveOperator(parsedData.Operator));
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_IsOperatorNonPrimitiveStart, Placeholder_IsOperatorNonPrimitiveEnd, !IsOperatorPrimitiveOperator(parsedData.Operator));
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ValueName).Replace(conditionCode, m => {
                return(DialogFlexFieldUtil.GetFieldName(exportField, parsedData.FieldName, errorCollection));
            });
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Operator).Replace(conditionCode, GetOperatorFromTemplate(project, parsedData.Operator, errorCollection));
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_ValueIsString_Start, Placeholder_ValueIsString_End, exportField.FieldType != ExportConstants.FlexFieldType_Number);
            conditionCode = ExportUtil.RenderPlaceholderIfTrue(conditionCode, Placeholder_ValueIsNumber_Start, Placeholder_ValueIsNumber_End, exportField.FieldType == ExportConstants.FlexFieldType_Number);
            conditionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_CompareValue).Replace(conditionCode, m => {
                if (exportField.FieldType != ExportConstants.FlexFieldType_Number)
                {
                    return(ExportUtil.EscapeCharacters(parsedData.CompareValue, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));
                }

                return(parsedData.CompareValue);
            });

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, GetFlexFieldExportObjectType());

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            conditionCode = _flexFieldPlaceholderResolver.FillPlaceholders(conditionCode, flexFieldExportData).Result;

            return(conditionCode);
        }
        /// <summary>
        /// Renders an attribute list
        /// </summary>
        /// <param name="project">Current project</param>
        /// <param name="fields">Fields to render</param>
        /// <param name="data">Export data</param>
        /// <param name="indent">Indentation</param>
        /// <returns>Rendered attribute list</returns>
        private async Task <string> RenderAttributeList(GoNorthProject project, List <FlexField> fields, ExportObjectData data, string indent)
        {
            ExportTemplate attributeListTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.ObjectAttributeList);

            ExportObjectData objectData = data.Clone();

            if (objectData.ExportData.ContainsKey(ExportConstants.ExportDataObject) && objectData.ExportData[ExportConstants.ExportDataObject] is IFlexFieldExportable)
            {
                ((IFlexFieldExportable)objectData.ExportData[ExportConstants.ExportDataObject]).Fields = fields;
            }

            ExportPlaceholderFillResult fillResult = await _placeholderResolver.FillPlaceholders(TemplateType.ObjectAttributeList, attributeListTemplate.Code, objectData, attributeListTemplate.RenderingEngine);

            _errorCollection.Merge(fillResult.Errors);

            return(ExportUtil.IndentListTemplate(fillResult.Code, indent));
        }
示例#12
0
        /// <summary>
        /// Exports an object
        /// </summary>
        /// <param name="template">Template to use</param>
        /// <param name="objectData">Object data</param>
        /// <returns>Export Result</returns>
        public async Task <ExportObjectResult> ExportObject(ExportTemplate template, ExportObjectData objectData)
        {
            GoNorthProject project = await _projectDbAccess.GetDefaultProject();

            ExportSettings exportSettings = await _exportSettingsDbAccess.GetExportSettings(project.Id);

            ExportObjectResult result = new ExportObjectResult();

            result.FileExtension = exportSettings.ScriptExtension;

            ExportPlaceholderFillResult filledResult = await _placeholderResolver.FillPlaceholders(template.TemplateType, template.Code, objectData);

            result.Code   = filledResult.Code;
            result.Errors = filledResult.Errors.ToErrorList();

            return(result);
        }
示例#13
0
        /// <summary>
        /// Exports an object
        /// </summary>
        /// <param name="template">Template to use</param>
        /// <param name="objectData">Object data</param>
        /// <returns>Export Result</returns>
        public async Task <ExportObjectResult> ExportObject(ExportTemplate template, ExportObjectData objectData)
        {
            ExportObjectResult result = new ExportObjectResult();

            result.FileExtension = "json";

            object exportResult = null;

            if (template.TemplateType == TemplateType.ObjectNpc)
            {
                NpcJsonExportObject exportObject = new NpcJsonExportObject((KortistoNpc)objectData.ExportData[ExportConstants.ExportDataObject]);
                exportObject.Dialog         = objectData.ExportData[ExportConstants.ExportDataDialog] as TaleDialog;
                exportObject.StateMachine   = objectData.ExportData[ExportConstants.ExportDataStateMachine] as StateMachine;
                exportObject.ExportSnippets = await _objectExportSnippetDbAccess.GetExportSnippets(exportObject.Id);

                exportResult = exportObject;
            }
            else if (template.TemplateType == TemplateType.ObjectItem)
            {
                ItemJsonExportObject exportObject = new ItemJsonExportObject((StyrItem)objectData.ExportData[ExportConstants.ExportDataObject]);
                exportObject.ExportSnippets = await _objectExportSnippetDbAccess.GetExportSnippets(exportObject.Id);

                exportResult = exportObject;
            }
            else if (template.TemplateType == TemplateType.ObjectSkill)
            {
                SkillJsonExportObject exportObject = new SkillJsonExportObject((EvneSkill)objectData.ExportData[ExportConstants.ExportDataObject]);
                exportObject.ExportSnippets = await _objectExportSnippetDbAccess.GetExportSnippets(exportObject.Id);

                exportResult = exportObject;
            }
            else
            {
                exportResult = objectData.ExportData[ExportConstants.ExportDataObject];
            }

            JsonSerializerOptions options = new JsonSerializerOptions
            {
                WriteIndented = true,
                Encoder       = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
            };

            result.Code = JsonSerializer.Serialize(exportResult, options);
            return(result);
        }
        /// <summary>
        /// Fills the placeholders of a code
        /// </summary>
        /// <param name="code">Code to fill</param>
        /// <param name="data">Export Data</param>
        /// <returns>Filled Code</returns>
        public Task <string> FillPlaceholders(string code, ExportObjectData data)
        {
            // Check Data
            if (!data.ExportData.ContainsKey(ExportConstants.ExportDataObject))
            {
                return(Task.FromResult(code));
            }

            IFlexFieldExportable flexFieldObject = data.ExportData[ExportConstants.ExportDataObject] as IFlexFieldExportable;

            if (flexFieldObject == null)
            {
                return(Task.FromResult(code));
            }

            // Replace Flex Field Placeholders
            return(FillFlexFieldPlaceholders(code, flexFieldObject, data.ExportData[ExportConstants.ExportDataObjectType].ToString(), data));
        }
示例#15
0
        /// <summary>
        /// Fills the placeholders of a code
        /// </summary>
        /// <param name="code">Code to fill</param>
        /// <param name="data">Export Data</param>
        /// <returns>Filled Code</returns>
        public async Task <string> FillPlaceholders(string code, ExportObjectData data)
        {
            // Check Data
            if (!data.ExportData.ContainsKey(ExportConstants.ExportDataObject))
            {
                return(code);
            }

            KortistoNpc npc = data.ExportData[ExportConstants.ExportDataObject] as KortistoNpc;

            if (npc == null)
            {
                return(code);
            }

            // Replace Dialog Placeholders
            return(await FillDialogPlaceholders(code, npc));
        }
        /// <summary>
        /// Builds an action from parsed data
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="data">Dialog 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>Action string</returns>
        public override async Task <string> BuildActionFromParsedData(MoveNpcToNpcActionRenderer.MoveNpcToNpcActionData parsedData, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ExportTemplate actionTemplate = await GetExportTemplate(project);

            KortistoNpc foundNpc = await GetNpc(parsedData, flexFieldObject);

            if (foundNpc == null)
            {
                errorCollection.AddDialogNpcNotFoundError();
                return(string.Empty);
            }

            KortistoNpc targetResult = await GetTargetNpc(parsedData);

            if (targetResult == null)
            {
                errorCollection.AddDialogNpcNotFoundError();
                return(string.Empty);
            }

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, foundNpc);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            string actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionTemplate.Code, flexFieldExportData).Result;

            if (!_isTeleport)
            {
                actionCode = BuildDirectContinueFunction(data, actionCode);
                actionCode = BuildMovementState(parsedData, actionCode);
            }

            ExportObjectData flexFieldTargetExportData = new ExportObjectData();

            flexFieldTargetExportData.ExportData.Add(ExportConstants.ExportDataObject, targetResult);
            flexFieldTargetExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);

            _flexFieldTargetPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = _flexFieldTargetPlaceholderResolver.FillPlaceholders(actionCode, flexFieldTargetExportData).Result;

            return(actionCode);
        }
示例#17
0
        /// <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="valueObject">Value object</param>
        /// <param name="marker">Marker at which to spawn the object</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="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, SpawnObjectActionData parsedData, IFlexFieldExportable valueObject, KartaMapNamedMarkerQueryResult marker,
                                                                FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TargetMarker_Name).Replace(template.Code, marker.MarkerName);

            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Rotation_Pitch).Replace(actionCode, parsedData.Pitch.ToString());
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Rotation_Yaw).Replace(actionCode, parsedData.Yaw.ToString());
            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_Rotation_Roll).Replace(actionCode, parsedData.Roll.ToString());

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, GetFlexFieldExportObjectType());

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result;

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <summary>
        /// Fills the placeholders of a code
        /// </summary>
        /// <param name="code">Code to fill</param>
        /// <param name="data">Export Data</param>
        /// <returns>Filled Code</returns>
        public async Task <string> FillPlaceholders(string code, ExportObjectData data)
        {
            // Check Data
            if (!data.ExportData.ContainsKey(ExportConstants.ExportDataObject))
            {
                return(code);
            }

            KortistoNpc npc = data.ExportData[ExportConstants.ExportDataObject] as KortistoNpc;

            if (npc == null)
            {
                return(code);
            }

            // Replace Inventory Placeholders
            _itemPlaceholderResolver.SetErrorMessageCollection(_errorCollection);
            return(await FillInventoryPlaceholders(code, npc));
        }
示例#19
0
        /// <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="valueObject">Value object</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="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, SetQuestStateActionData parsedData, IFlexFieldExportable valueObject, FlexFieldObject flexFieldObject,
                                                                ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.RenderPlaceholderIfTrue(template.Code, Placeholder_QuestState_NotStarted_Start, Placeholder_QuestState_NotStarted_End, parsedData.QuestState == SetQuestStateActionData.QuestState_NotStarted);

            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_QuestState_InProgress_Start, Placeholder_QuestState_InProgress_End, parsedData.QuestState == SetQuestStateActionData.QuestState_InProgress);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_QuestState_Success_Start, Placeholder_QuestState_Success_End, parsedData.QuestState == SetQuestStateActionData.QuestState_Success);
            actionCode = ExportUtil.RenderPlaceholderIfTrue(actionCode, Placeholder_QuestState_Failed_Start, Placeholder_QuestState_Failed_End, parsedData.QuestState == SetQuestStateActionData.QuestState_Failed);

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeQuest);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result;

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
示例#20
0
        /// <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="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="valueObject">Value object to export</param>
        /// <param name="curStep">Current step that is rendered</param>
        /// <param name="nextStep">Next step that is being rendered</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, AddQuestTextData parsedData, IFlexFieldExportable valueObject, FlexFieldObject flexFieldObject,
                                                                ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_QuestText).Replace(template.Code, ExportUtil.EscapeCharacters(parsedData.QuestText, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));

            actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_QuestText_Preview).Replace(actionCode, ExportUtil.BuildTextPreview(parsedData.QuestText));
            actionCode = await ExportUtil.BuildPlaceholderRegex(Placeholder_QuestText_LangKey).ReplaceAsync(actionCode, async m => {
                return(await _languageKeyGenerator.GetDialogTextLineKey(flexFieldObject.Id, valueObject.Name, ExportConstants.LanguageKeyTypeQuest, curStep.Id, parsedData.QuestText));
            });

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeQuest);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = await _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData);

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <summary>
        /// Fills the placeholders of a code
        /// </summary>
        /// <param name="code">Code to fill</param>
        /// <param name="data">Export Data</param>
        /// <returns>Filled Code</returns>
        public async Task <string> FillPlaceholders(string code, ExportObjectData data)
        {
            // Check Data
            if (!data.ExportData.ContainsKey(ExportConstants.ExportDataObject))
            {
                return(code);
            }

            IExportSnippetExportable exportObject = data.ExportData[ExportConstants.ExportDataObject] as IExportSnippetExportable;

            if (exportObject == null)
            {
                return(code);
            }

            // Replace Export Snippet Placeholders
            FlexFieldObject flexFieldObject = data.ExportData[ExportConstants.ExportDataObject] as FlexFieldObject;

            return(await FillExportSnippetPlaceholders(code, exportObject, flexFieldObject));
        }
        /// <summary>
        /// Builds an action from parsed data
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="data">Dialog 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>Action string</returns>
        public override async Task<string> BuildActionFromParsedData(ChangeNpcStateActionRenderer.ChangeNpcStateActionData parsedData, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ExportTemplate actionTemplate = await GetExportTemplate(project);
            IFlexFieldExportable valueObject = await GetNpc(flexFieldObject, errorCollection);
            if(valueObject == null)
            {
                return string.Empty;
            }

            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_State).Replace(actionTemplate.Code, ExportUtil.EscapeCharacters(parsedData.ObjectState, exportSettings.EscapeCharacter, exportSettings.CharactersNeedingEscaping, exportSettings.NewlineCharacter));

            ExportObjectData flexFieldExportData = new ExportObjectData();
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result;

            return actionCode;
        }
示例#23
0
        /// <summary>
        /// Builds a condition element from parsed data
        /// </summary>
        /// <param name="template">Export template to use</param>
        /// <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>Condition string</returns>
        public override async Task <string> BuildConditionElementFromParsedData(ExportTemplate template, LearnedSkillConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            EvneSkill skill = await _cachedDbAccess.GetSkillById(parsedData.SelectedSkillId);

            if (skill == null)
            {
                errorCollection.AddDialogSkillNotFoundError();
                return(string.Empty);
            }

            ExportObjectData skillExportData = new ExportObjectData();

            skillExportData.ExportData.Add(ExportConstants.ExportDataObject, skill);
            skillExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeSkill);

            _skillPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            string conditionCode = await _skillPlaceholderResolver.FillPlaceholders(template.Code, skillExportData);

            return(conditionCode);
        }
示例#24
0
        /// <summary>
        /// Exports an object
        /// </summary>
        /// <param name="template">Template to use</param>
        /// <param name="objectData">Object data</param>
        /// <returns>Export Result</returns>
        public async Task <ExportObjectResult> ExportObject(ExportTemplate template, ExportObjectData objectData)
        {
            // Run script export to refresh language keys
            IFlexFieldExportable flexFieldObject = null;

            if (objectData.ExportData.ContainsKey(ExportConstants.ExportDataObject))
            {
                flexFieldObject = objectData.ExportData[ExportConstants.ExportDataObject] as IFlexFieldExportable;
            }

            if (flexFieldObject != null)
            {
                _languageKeyReferenceCollector.PrepareCollectionForGroup(flexFieldObject.Id);
            }
            else
            {
                _languageKeyReferenceCollector.PrepareCollectionForGroup(null);
            }

            await _scriptExporter.ExportObject(template, objectData);

            objectData.ExportData[ExportConstants.ExportDataReferencedLanguageIds] = _languageKeyReferenceCollector.GetReferencedLanguageKeys();

            // Export language keys
            GoNorthProject project = await _userProjectAccess.GetUserProject();

            ExportSettings exportSettings = await _exportSettingsDbAccess.GetExportSettings(project.Id);

            ExportTemplate exportTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.LanguageFile);

            ExportObjectResult result = new ExportObjectResult();

            result.FileExtension = exportSettings.LanguageFileExtension;

            ExportPlaceholderFillResult filledResult = await _placeholderResolver.FillPlaceholders(TemplateType.LanguageFile, exportTemplate.Code, objectData, exportTemplate.RenderingEngine);

            result.Code   = filledResult.Code;
            result.Errors = filledResult.Errors.ToErrorList();

            return(result);
        }
示例#25
0
        /// <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="valueItem">Item to export</param>
        /// <param name="valueNpc">Npc 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="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, UseItemActionData parsedData, IFlexFieldExportable valueItem, IFlexFieldExportable valueNpc,
                                                                FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = template.Code;

            ExportObjectData flexFieldExportDataItem = new ExportObjectData();

            flexFieldExportDataItem.ExportData.Add(ExportConstants.ExportDataObject, valueItem);
            flexFieldExportDataItem.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeItem);
            _flexFieldPlaceholderResolverItem.SetErrorMessageCollection(errorCollection);
            actionCode = await _flexFieldPlaceholderResolverItem.FillPlaceholders(actionCode, flexFieldExportDataItem);

            ExportObjectData flexFieldExportDataNpc = new ExportObjectData();

            flexFieldExportDataNpc.ExportData.Add(ExportConstants.ExportDataObject, valueNpc);
            flexFieldExportDataNpc.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);
            _flexFieldPlaceholderResolverNpc.SetErrorMessageCollection(errorCollection);
            actionCode = await _flexFieldPlaceholderResolverNpc.FillPlaceholders(actionCode, flexFieldExportDataNpc);

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
示例#26
0
        /// <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="npc">Npc to move</param>
        /// <param name="markerName">Target marker name</param>
        /// <param name="directContinueFunction">Direct continue function</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="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, MoveNpcActionData parsedData, KortistoNpc npc, string markerName, string directContinueFunction,
                                                                FlexFieldObject flexFieldObject, ExportDialogData curStep, ExportDialogData nextStep, ExportSettings exportSettings, IActionStepRenderer stepRenderer)
        {
            string actionCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TargetMarker_Name).Replace(template.Code, markerName);

            if (!_isTeleport)
            {
                actionCode = BuildDirectContinueFunction(directContinueFunction, actionCode);
                actionCode = BuildMovementState(parsedData, actionCode);
            }

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, npc);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionCode, flexFieldExportData).Result;

            return(await stepRenderer.ReplaceBasePlaceholders(errorCollection, actionCode, curStep, nextStep, flexFieldObject));
        }
        /// <summary>
        /// Builds an action from parsed data
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="data">Dialog data</param>
        /// <param name="project">Project</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <param name="npc">Npc to which the dialog belongs</param>
        /// <param name="exportSettings">Export Settings</param>
        /// <returns>Action string</returns>
        public override async Task <string> BuildActionFromParsedData(LearnForgetSkillActionRenderer.LearnForgetSkillActionData parsedData, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, KortistoNpc npc, ExportSettings exportSettings)
        {
            ExportTemplate actionTemplate = await GetExportTemplate(project);

            IFlexFieldExportable valueObject = await GetSkill(parsedData, errorCollection);

            if (valueObject == null)
            {
                return(string.Empty);
            }

            ExportObjectData flexFieldExportData = new ExportObjectData();

            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, valueObject);
            flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeSkill);

            _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            string actionCode = _flexFieldPlaceholderResolver.FillPlaceholders(actionTemplate.Code, flexFieldExportData).Result;

            return(actionCode);
        }
        /// <summary>
        /// Builds a condition element from parsed data
        /// </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>Condition string</returns>
        public override string BuildConditionElementFromParsedData(LearnedSkillConditionResolver.LearnedSkillConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings)
        {
            ExportTemplate conditionTemplate = _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, GetTemplateType()).Result;

            EvneSkill skill = _cachedDbAccess.GetSkillById(parsedData.SelectedSkillId).Result;

            if (skill == null)
            {
                errorCollection.AddDialogSkillNotFoundError();
                return(string.Empty);
            }

            ExportObjectData skillExportData = new ExportObjectData();

            skillExportData.ExportData.Add(ExportConstants.ExportDataObject, skill);
            skillExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeSkill);

            _skillPlaceholderResolver.SetErrorMessageCollection(errorCollection);
            string conditionCode = _skillPlaceholderResolver.FillPlaceholders(conditionTemplate.Code, skillExportData).Result;

            return(conditionCode);
        }
示例#29
0
        /// <summary>
        /// Exports an object
        /// </summary>
        /// <param name="template">Template to use</param>
        /// <param name="objectData">Object data</param>
        /// <returns>Export Result</returns>
        public async Task <ExportObjectResult> ExportObject(ExportTemplate template, ExportObjectData objectData)
        {
            // Run script export to refresh language keys
            await _scriptExporter.ExportObject(template, objectData);

            // Export language keys
            GoNorthProject project = await _projectDbAccess.GetDefaultProject();

            ExportSettings exportSettings = await _exportSettingsDbAccess.GetExportSettings(project.Id);

            ExportTemplate exportTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.LanguageFile);

            ExportObjectResult result = new ExportObjectResult();

            result.FileExtension = exportSettings.LanguageFileExtension;

            ExportPlaceholderFillResult filledResult = await _placeholderResolver.FillPlaceholders(TemplateType.LanguageFile, exportTemplate.Code, objectData);

            result.Code   = filledResult.Code;
            result.Errors = filledResult.Errors.ToErrorList();

            return(result);
        }
示例#30
0
        /// <summary>
        /// Renders an state machine function
        /// </summary>
        /// <param name="context">Template context</param>
        /// <param name="callerContext">Caller context</param>
        /// <param name="arguments">Arguments to render the function with</param>
        /// <returns>Rendered state machine function</returns>
        private async ValueTask <object> RenderStateMachineFunction(TemplateContext context, ScriptNode callerContext, ScriptArray arguments)
        {
            if (arguments.Count != 1 || !(arguments[0] is ScribanExportStateFunction))
            {
                _errorCollection.AddInvalidParameter(ScribanErrorUtil.FormatScribanSpan(callerContext.Span));
                return("<<DID NOT PROVIDE VALID STATE MACHINE FUNCTION>>");
            }
            ScribanExportStateFunction exportFunction = (ScribanExportStateFunction)arguments[0];

            GoNorthProject curProject = await _exportCachedDbAccess.GetUserProject();

            ExportTemplate eventFunctionTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(curProject.Id, TemplateType.ObjectStateFunction);

            ExportObjectData objectData = new ExportObjectData();

            objectData.ExportData.Add(ExportConstants.ExportDataObject, exportFunction.ToStateFunction());

            ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectStateFunction, eventFunctionTemplate.Code, objectData, eventFunctionTemplate.RenderingEngine);

            _errorCollection.Merge(fillResult.Errors);

            return(ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code));
        }