/// <summary> /// Renders a condition /// </summary> /// <param name="project">Project</param> /// <param name="condition">Condition render</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>Result of rendering the condition</returns> public async Task <string> RenderCondition(GoNorthProject project, Condition condition, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings) { if (string.IsNullOrEmpty(condition.ConditionElements)) { return(string.Empty); } ExportTemplate andTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.GeneralLogicAnd); JsonSerializerOptions jsonOptions = new JsonSerializerOptions(); jsonOptions.Converters.Add(new JsonStringEnumConverter()); jsonOptions.Converters.Add(new JsonConditionDataParser()); jsonOptions.PropertyNameCaseInsensitive = true; List <ParsedConditionData> parsedConditionData = JsonSerializer.Deserialize <List <ParsedConditionData> >(condition.ConditionElements, jsonOptions); return(RenderConditionElements(project, parsedConditionData, andTemplate.Code, errorCollection, flexFieldObject, exportSettings)); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step 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(ExportDialogData data, FlexFieldObject flexFieldObject) { KortistoNpc npc = flexFieldObject as KortistoNpc; if (npc == null) { return(null); } TaleChoiceNode choiceNode = data.Choice; if (choiceNode == null) { return(null); } ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleChoice); if (!_renderers.ContainsKey(template.RenderingEngine)) { throw new KeyNotFoundException(string.Format("Unknown rendering engine {0} for ChoiceNode", template.RenderingEngine.ToString())); } string oldContext = _errorCollection.CurrentErrorContext; _errorCollection.CurrentErrorContext = _localizer["ErrorContextChoice"]; try { return(await _renderers[template.RenderingEngine].RenderDialogStep(template, data, npc, choiceNode)); } catch (Exception ex) { _errorCollection.AddException(ex); return(new ExportDialogStepRenderResult { StepCode = "<<ERROR_RENDERING_CHOICE>>" }); } finally { _errorCollection.CurrentErrorContext = oldContext; } }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step 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(ExportDialogData data, FlexFieldObject flexFieldObject) { KortistoNpc npc = flexFieldObject as KortistoNpc; if (npc == null) { return(null); } TextNode textNode = GetValidTextNode(data); if (textNode == null) { return(null); } ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, _isPlayerLine?TemplateType.TalePlayerTextLine : TemplateType.TaleNpcTextLine); if (!_renderers.ContainsKey(template.RenderingEngine)) { throw new KeyNotFoundException(string.Format("Unknown rendering engine {0} for TextNode", template.RenderingEngine.ToString())); } string oldContext = _errorCollection.CurrentErrorContext; _errorCollection.CurrentErrorContext = _localizer[_isPlayerLine ? "ErrorContextPlayerLine" : "ErrorContextNpcLine"]; try { return(await _renderers[template.RenderingEngine].RenderDialogStep(template, data, npc, textNode)); } catch (Exception ex) { _errorCollection.AddException(ex); return(new ExportDialogStepRenderResult { StepCode = _isPlayerLine ? "<<ERROR_RENDERING_PLAYER_TEXTLINE>>" : "<<ERROR_RENDERING_NPC_TEXTLINE>>" }); } finally { _errorCollection.CurrentErrorContext = oldContext; } }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step Data</param> /// <param name="npc">Npc to which the dialog belongs</param> /// <returns>Dialog Step Render Result</returns> public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, KortistoNpc npc) { TaleChoiceNode choiceNode = data.Choice; if (choiceNode == null) { return(null); } ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleChoice); ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult(); renderResult.StepCode = ReplaceNodeId(template.Code, data); renderResult.StepCode = ExportUtil.BuildRangePlaceholderRegex(Placeholder_ChoicesStart, Placeholder_ChoicesEnd).Replace(renderResult.StepCode, m => { return(ExportUtil.TrimEmptyLines(ExportUtil.IndentListTemplate(BuildChoices(m.Groups[1].Value, data, choiceNode, npc), m.Groups[2].Value))); }); return(renderResult); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step Data</param> /// <param name="npc">Npc to which the dialog belongs</param> /// <returns>Dialog Step Render Result</returns> public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, KortistoNpc npc) { ActionNode actionNode = data.Action; if (actionNode == null) { return(null); } string actionContent = await BuildActionContent(actionNode, data, npc); ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleAction); ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult(); renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ActionContent).Replace(template.Code, actionContent); renderResult.StepCode = ReplaceBaseStepPlaceholders(renderResult.StepCode, data, data.Children.FirstOrDefault() != null ? data.Children.FirstOrDefault().Child : null); return(renderResult); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step 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(ExportDialogData data, FlexFieldObject flexFieldObject) { if (data.Reference == null) { return(null); } ReferenceNodeData referenceNode = await GetReferenceNodeData(data.Reference); if (referenceNode == null) { return(null); } ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.ReferenceNode); if (!_renderers.ContainsKey(template.RenderingEngine)) { throw new KeyNotFoundException(string.Format("Unknown rendering engine {0} for ReferenceNode", template.RenderingEngine.ToString())); } string oldContext = _errorCollection.CurrentErrorContext; _errorCollection.CurrentErrorContext = _localizer["ErrorContextReference"]; try { return(await _renderers[template.RenderingEngine].RenderDialogStep(template, data, _project, referenceNode, flexFieldObject)); } catch (Exception ex) { _errorCollection.AddException(ex); return(new ExportDialogStepRenderResult { StepCode = "<<ERROR_RENDERING_REFERENCE_NODE>>" }); } finally { _errorCollection.CurrentErrorContext = oldContext; } }
/// <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); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step Data</param> /// <param name="npc">Npc to which the dialog belongs</param> /// <returns>Dialog Step Render Result</returns> public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, KortistoNpc npc) { TextNode textNode = GetValidTextNode(data); if (textNode == null) { return(null); } ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, _isPlayerLine?TemplateType.TalePlayerTextLine : TemplateType.TaleNpcTextLine); ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult(); renderResult.StepCode = ReplaceBaseStepPlaceholders(template.Code, data, data.Children.FirstOrDefault() != null ? data.Children.FirstOrDefault().Child : null); renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TextLine).Replace(renderResult.StepCode, ExportUtil.EscapeCharacters(textNode.Text, _exportSettings.EscapeCharacter, _exportSettings.CharactersNeedingEscaping, _exportSettings.NewlineCharacter)); renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TextLine_Preview).Replace(renderResult.StepCode, ExportUtil.BuildTextPreview(textNode.Text)); renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_TextLine_LangKey).Replace(renderResult.StepCode, m => { return(_languageKeyGenerator.GetDialogTextLineKey(npc.Id, npc.Name, _isPlayerLine ? "player" : "npc", textNode.Id, textNode.Text).Result); }); return(renderResult); }
/// <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)); }
/// <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(DailyRoutineEventStateConditionResolver.DailyRoutineEventStateConditionData parsedData, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, KortistoNpc npc, ExportSettings exportSettings) { ExportTemplate conditionTemplate = _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, _isDisabled ? TemplateType.TaleConditionDailyRoutineEventDisabled : TemplateType.TaleConditionDailyRoutineEventEnabled).Result; KortistoNpc eventNpc = _cachedDbAccess.GetNpcById(parsedData.NpcId).Result; if (eventNpc == null) { return(string.Empty); } KortistoNpcDailyRoutineEvent exportEvent = null; if (eventNpc.DailyRoutine != null) { exportEvent = eventNpc.DailyRoutine.FirstOrDefault(e => e.EventId == parsedData.EventId); } if (exportEvent == null) { errorCollection.AddDialogDailyRoutineEventNotFoundError(eventNpc.Name); return(string.Empty); } MiscProjectConfig projectConfig = _cachedDbAccess.GetMiscProjectConfig().Result; string conditionCode = _dailyRoutineEventPlaceholderResolver.ResolveDailyRoutineEventPlaceholders(conditionTemplate.Code, eventNpc, exportEvent).Result; ExportObjectData flexFieldExportData = new ExportObjectData(); flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObject, eventNpc); flexFieldExportData.ExportData.Add(ExportConstants.ExportDataObjectType, ExportConstants.ExportObjectTypeNpc); _flexFieldPlaceholderResolver.SetErrorMessageCollection(errorCollection); conditionCode = _flexFieldPlaceholderResolver.FillPlaceholders(conditionCode, flexFieldExportData).Result; return(conditionCode); }
/// <summary> /// Exports the code snippet additional functions /// </summary> /// <param name="renderedFunctions">Rendered function cache</param> /// <param name="objectExportSnippet">Object export snippet to export</param> /// <param name="flexFieldObject">Flex field object</param> /// <param name="listIndent">Indent of the code</param> /// <returns>Result of the snippet render</returns> private async Task <string> ExportCodeSnippetAdditionalFunctions(Dictionary <string, List <ExportSnippetFunction> > renderedFunctions, ObjectExportSnippet objectExportSnippet, FlexFieldObject flexFieldObject, string listIndent) { if (objectExportSnippet == null) { return(string.Empty); } GoNorthProject project = await _cachedDbAccess.GetUserProject(); ExportTemplate functionContentTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.ObjectExportSnippetFunction); List <ExportSnippetFunction> functions = await RenderFunctions(renderedFunctions, objectExportSnippet, flexFieldObject); List <ExportSnippetFunction> additionalFunctions = functions.Skip(1).ToList(); string functionList = string.Empty; foreach (ExportSnippetFunction curFunction in additionalFunctions) { functionList += await RenderExportSnippetFunction(functionContentTemplate, curFunction); } return(ExportUtil.IndentListTemplate(functionList, listIndent)); }
/// <summary> /// Renders a dialog step /// </summary> /// <param name="data">Dialog Step Data</param> /// <param name="flexFieldObject">Flex Field to which the dialog belongs</param> /// <returns>Dialog Step Render Result</returns> public async Task <ExportDialogStepRenderResult> RenderDialogStep(ExportDialogData data, FlexFieldObject flexFieldObject) { ActionNode actionNode = data.Action; if (actionNode == null) { return(null); } IActionRenderer actionRenderer = GetActionRenderForNode(actionNode); ExportDialogDataChild nextStep = null; if (data.Children != null) { if (actionRenderer != null) { nextStep = actionRenderer.GetNextStep(data.Children); } else { nextStep = data.Children.FirstOrDefault(); } } string actionContent = await BuildActionContent(actionRenderer, actionNode, data, flexFieldObject); ExportTemplate template = await _defaultTemplateProvider.GetDefaultTemplateByType(_project.Id, TemplateType.TaleAction); ExportDialogStepRenderResult renderResult = new ExportDialogStepRenderResult(); renderResult.StepCode = ExportUtil.BuildPlaceholderRegex(Placeholder_ActionContent).Replace(template.Code, actionContent); renderResult.StepCode = ReplaceBaseStepPlaceholders(renderResult.StepCode, data, nextStep != null ? nextStep.Child : null); return(renderResult); }
/// <summary> /// Renders an daily routine function list /// </summary> /// <param name="context">Template context</param> /// <param name="callerContext">Caller context</param> /// <param name="arguments">Arguments to render the list with</param> /// <returns>Rendered daily routine function list</returns> private async ValueTask <object> RenderDailyRoutineFunctionList(TemplateContext context, ScriptNode callerContext, ScriptArray arguments) { List <ScribanExportDailyRoutineFunction> functionList = ScribanParsingUtil.GetArrayFromScribanArgument <ScribanExportDailyRoutineFunction>(arguments, 0); if (functionList == null) { _errorCollection.AddInvalidParameter(ScribanErrorUtil.FormatScribanSpan(callerContext.Span)); return("<<DID NOT PROVIDE VALID FUNCTION LIST>>"); } GoNorthProject curProject = await _exportCachedDbAccess.GetUserProject(); ExportTemplate functionListTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(curProject.Id, TemplateType.ObjectDailyRoutineFunctionList); ExportObjectData objectData = new ExportObjectData(); objectData.ExportData.Add(ExportConstants.ExportDataObject, functionList.Select(f => f.ToDailyRoutineFunction()).ToList()); ExportPlaceholderFillResult fillResult = await _templatePlaceholderResolver.FillPlaceholders(TemplateType.ObjectDailyRoutineFunctionList, functionListTemplate.Code, objectData, functionListTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); return(ScribanOutputUtil.IndentMultilineCode(context, fillResult.Code)); }
/// <summary> /// Returns the export template to use /// </summary> /// <param name="project">Project</param> /// <returns>Export template to use</returns> private async Task <ExportTemplate> GetExportTemplate(GoNorthProject project) { return(await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, GetValidTemplateType())); }
/// <summary> /// Returns the export template to use /// </summary> /// <param name="project">Project</param> /// <returns>Export template to use</returns> private async Task <ExportTemplate> GetExportTemplate(GoNorthProject project) { return(await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, _isDisable?TemplateType.TaleActionDisableDailyRoutineEvent : TemplateType.TaleActionEnableDailyRoutineEvent)); }
/// <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(PersistDialogStateActionRenderer.PersistDialogStateActionData parsedData, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, KortistoNpc npc, ExportSettings exportSettings) { ExportTemplate actionTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.TaleActionPersistDialogState); return(actionTemplate.Code); }
/// <summary> /// Returns the export template to use /// </summary> /// <param name="project">Project</param> /// <returns>Export template to use</returns> private async Task <ExportTemplate> GetExportTemplate(GoNorthProject project) { return(await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, _isRemoval?TemplateType.TaleActionRemoveItemFromChooseNpc : TemplateType.TaleActionSpawnItemForChooseNpc)); }
/// <summary> /// Fills the Flex Field Placeholders /// </summary> /// <param name="code">Code to fill</param> /// <param name="flexFieldObject">Flex Field Object</param> /// <param name="objectType">Object Type</param> /// <returns>Filled Code</returns> private async Task <string> FillFlexFieldPlaceholders(string code, IFlexFieldExportable flexFieldObject, string objectType) { GoNorthProject project = await _exportCachedDbAccess.GetDefaultProject(); ExportSettings exportSettings = await _exportCachedDbAccess.GetExportSettings(project.Id); ExportTemplate attributeListTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.ObjectAttributeList); HashSet <string> usedFields = new HashSet <string>(); code = ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_Name)).Replace(code, flexFieldObject.Name); code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_Field_Value_Equals_Start), BuildFinalPlaceholder(Placeholder_Field_Value_Equals_End), m => { string fieldName = m.Groups[1].Value; FlexField field = FindFlexField(flexFieldObject, fieldName); if (field == null) { return(false); } return(m.Groups[2].Value == field.Value); }); code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_Field_Value_NotEquals_Start), BuildFinalPlaceholder(Placeholder_Field_Value_NotEquals_End), m => { string fieldName = m.Groups[1].Value; FlexField field = FindFlexField(flexFieldObject, fieldName); if (field == null) { return(true); } return(m.Groups[2].Value != field.Value); }); code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_FlexField_HasField_Start), BuildFinalPlaceholder(Placeholder_FlexField_HasField_End), m => { string fieldName = m.Groups[1].Value; FlexField field = FindFlexField(flexFieldObject, fieldName); return(field != null); }); code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_FlexField_NotHasField_Start), BuildFinalPlaceholder(Placeholder_FlexField_NotHasField_End), m => { string fieldName = m.Groups[1].Value; FlexField field = FindFlexField(flexFieldObject, fieldName); return(field == null); }); code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_FlexField_FieldIsBlank_Start), BuildFinalPlaceholder(Placeholder_FlexField_FieldIsBlank_End), m => { string fieldName = m.Groups[1].Value; FlexField field = FindFlexField(flexFieldObject, fieldName); if (field == null) { return(true); } return(string.IsNullOrEmpty(field.Value)); }); code = ExportUtil.RenderPlaceholderIfFuncTrue(code, BuildFinalPlaceholder(Placeholder_FlexField_FieldIsNotBlank_Start), BuildFinalPlaceholder(Placeholder_FlexField_FieldIsNotBlank_End), m => { string fieldName = m.Groups[1].Value; FlexField field = FindFlexField(flexFieldObject, fieldName); if (field == null) { return(false); } return(!string.IsNullOrEmpty(field.Value)); }); code = ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_Name_LangKey)).Replace(code, m => { // Run in function to only create language key if required string key = _languageKeyGenerator.GetFlexFieldNameKey(flexFieldObject.Id, flexFieldObject.Name, objectType).Result; return(key); }); code = ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_Field_Value)).Replace(code, m => { string fieldName = m.Groups[1].Value; FlexField field = FindFlexField(flexFieldObject, fieldName); if (field != null) { usedFields.Add(field.Id); return(EscapedFieldValue(field, exportSettings)); } _errorCollection.AddErrorFlexField(fieldName, flexFieldObject.Name); return("<<" + flexFieldObject.Name + "[" + fieldName + "] MISSING>>"); }); code = ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_Field_LangKey)).Replace(code, m => { string fieldName = m.Groups[1].Value; FlexField field = FindFlexField(flexFieldObject, fieldName); if (field != null && (field.FieldType == ExportConstants.FlexFieldType_String || field.FieldType == ExportConstants.FlexFieldType_Option)) { usedFields.Add(field.Id); return(BuildFlexFieldLangKey(flexFieldObject, field, objectType)); } _errorCollection.AddErrorFlexField(fieldName, flexFieldObject.Name); return("<<" + flexFieldObject.Name + "[" + fieldName + "] MISSING>>"); }); code = ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_UnusedFields), ExportConstants.ListIndentPrefix).Replace(code, m => { return(BuildFlexFieldListTemplate(attributeListTemplate.Code, Placeholder_UnusedFields_Start, Placeholder_UnusedFields_End, m.Groups[1].Value)); }); code = ExportUtil.BuildPlaceholderRegex(BuildFinalPlaceholder(Placeholder_AllFields), ExportConstants.ListIndentPrefix).Replace(code, m => { return(BuildFlexFieldListTemplate(attributeListTemplate.Code, Placeholder_AllFields_Start, Placeholder_AllFields_End, m.Groups[1].Value)); }); code = ExportUtil.BuildRangePlaceholderRegex(BuildFinalPlaceholder(Placeholder_UnusedFields_Start), BuildFinalPlaceholder(Placeholder_UnusedFields_End)).Replace(code, m => { List <FlexField> fieldsToUse = flexFieldObject.Fields.Where(f => !usedFields.Contains(f.Id)).ToList(); return(BuildFlexFieldList(m.Groups[1].Value, fieldsToUse, flexFieldObject, exportSettings, objectType)); }); code = ExportUtil.BuildRangePlaceholderRegex(BuildFinalPlaceholder(Placeholder_AllFields_Start), BuildFinalPlaceholder(Placeholder_AllFields_End)).Replace(code, m => { return(BuildFlexFieldList(m.Groups[1].Value, flexFieldObject.Fields, flexFieldObject, exportSettings, objectType)); }); return(code); }
/// <summary> /// Returns the export template to use /// </summary> /// <param name="project">Project</param> /// <returns>Export template to use</returns> private async Task <ExportTemplate> GetExportTemplate(GoNorthProject project) { return(await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, _isPlayer?TemplateType.TaleActionPlayerPlayAnimation : TemplateType.TaleActionNpcPlayAnimation)); }
/// <summary> /// Returns the export template to use /// </summary> /// <param name="project">Project</param> /// <returns>Export template to use</returns> private async Task <ExportTemplate> GetExportTemplate(GoNorthProject project) { return(await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.TaleActionSetTargetNpcState)); }
/// <summary> /// Returns the export template to use /// </summary> /// <param name="project">Project</param> /// <returns>Export template to use</returns> private async Task <ExportTemplate> GetExportTemplate(GoNorthProject project) { return(await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, _isFadingToBlack?TemplateType.TaleActionFadeToBlack : TemplateType.TaleActionFadeFromBlack)); }
/// <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(OpenShopActionRenderer.OpenShopActionData parsedData, ExportDialogData data, GoNorthProject project, ExportPlaceholderErrorCollection errorCollection, FlexFieldObject flexFieldObject, ExportSettings exportSettings) { ExportTemplate actionTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.TaleActionOpenShop); return(actionTemplate.Code); }
/// <summary> /// Returns the export template to use /// </summary> /// <param name="project">Project</param> /// <returns>Export template to use</returns> private async Task <ExportTemplate> GetExportTemplate(GoNorthProject project) { return(await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.TaleActionAddQuestText)); }
/// <summary> /// Returns the export template to use /// </summary> /// <param name="project">Project</param> /// <returns>Export template to use</returns> private async Task<ExportTemplate> GetExportTemplate(GoNorthProject project) { return await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, _isPlayer ? TemplateType.TaleActionSetPlayerState : TemplateType.TaleActionSetNpcState); }