/// <summary>
        /// Maps a single choice
        /// </summary>
        /// <param name="data">Dialog Step Data</param>
        /// <param name="choice">Choice to map</param>
        /// <param name="npc">Npc object to which the dialog belongs</param>
        /// <param name="parentChoiceData">Choice data to which the choices belong</param>
        /// <returns>Mapped choice</returns>
        private async ValueTask <ScribanChoiceOption> MapSingleChoice(ExportDialogData data, TaleChoice choice, KortistoNpc npc, ScribanChoice parentChoiceData)
        {
            ExportDialogDataChild     choiceData      = data.Children.FirstOrDefault(c => c.NodeChildId == choice.Id);
            ScribanDialogStepBaseData childRenderData = null;

            if (choiceData != null && choiceData.Child != null)
            {
                childRenderData = new ScribanDialogStepBaseData();
                SetRenderObjectBaseDataFromFlexFieldObject(childRenderData, choiceData.Child, npc);
            }

            ScribanChoiceOption choiceOption = new ScribanChoiceOption();

            choiceOption.ChildNode     = childRenderData;
            choiceOption.Id            = choice.Id;
            choiceOption.Text          = ExportUtil.EscapeCharacters(choice.Text, _exportSettings.EscapeCharacter, _exportSettings.CharactersNeedingEscaping, _exportSettings.NewlineCharacter);
            choiceOption.UnescapedText = choice.Text;
            choiceOption.TextPreview   = ExportUtil.BuildTextPreview(choice.Text);
            choiceOption.IsRepeatable  = choice.IsRepeatable;
            choiceOption.Condition     = null;
            if (choice.Condition != null && !string.IsNullOrEmpty(choice.Condition.ConditionElements))
            {
                choiceOption.Condition = await _conditionRenderer.RenderCondition(_project, choice.Condition, _errorCollection, npc, _exportSettings);
            }
            choiceOption.ParentChoice = parentChoiceData;

            return(choiceOption);
        }
 /// <summary>
 /// Sets the render object base data
 /// </summary>
 /// <param name="renderObject">Render object to fill</param>
 /// <param name="stepData">Step data</param>
 /// <param name="exportNpc">Npc to export</param>
 public void SetRenderObjectBaseData(ScribanDialogStepBaseData renderObject, ExportDialogData stepData, ScribanFlexFieldObject exportNpc)
 {
     renderObject.NodeId = stepData.Id;
     renderObject.NodeIndex = stepData.NodeIndex;
     renderObject.NodeType = stepData.GetNodeType();
     renderObject.NodeStepFunctionName = stepData.DialogStepFunctionName;
     renderObject.NodeObject = exportNpc;
 }
示例#3
0
        /// <summary>
        /// Builds the else part
        /// </summary>
        /// <param name="data">Dialog Step Data</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <returns>Mapped else part</returns>
        private ScribanDialogStepBaseData BuildElsePart(ExportDialogData data, FlexFieldObject flexFieldObject)
        {
            ExportDialogDataChild elseChild = data.Children.FirstOrDefault(c => c.NodeChildId == ExportConstants.ConditionElseNodeChildId);

            if (elseChild == null || elseChild.Child == null)
            {
                return(null);
            }

            ScribanDialogStepBaseData childData = new ScribanDialogStepBaseData();

            SetRenderObjectBaseDataFromFlexFieldObject(childData, elseChild.Child, flexFieldObject);
            return(childData);
        }
示例#4
0
        /// <summary>
        /// Builds a condition entry
        /// </summary>
        /// <param name="childElement">Dialog child element</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="condition">Condition to map</param>
        /// <returns>Mapped condition</returns>
        private async Task <ScribanConditionEntry> BuildConditionEntry(ExportDialogDataChild childElement, FlexFieldObject flexFieldObject, Condition condition)
        {
            ScribanConditionEntry conditionEntry = new ScribanConditionEntry();

            conditionEntry.Id        = condition.Id;
            conditionEntry.Condition = await _conditionRenderer.RenderCondition(_project, condition, _errorCollection, flexFieldObject, _exportSettings);

            conditionEntry.ChildNode = null;
            if (childElement != null && childElement.Child != null)
            {
                ScribanDialogStepBaseData childData = new ScribanDialogStepBaseData();
                SetRenderObjectBaseDataFromFlexFieldObject(childData, childElement.Child, flexFieldObject);
                conditionEntry.ChildNode = childData;
            }

            return(conditionEntry);
        }
 /// <summary>
 /// Sets the render object base data
 /// </summary>
 /// <param name="renderObject">Render object to fill</param>
 /// <param name="stepData">Step data</param>
 /// <param name="flexFieldObject">Flexfield object to which the dialog belongs</param>
 public void SetRenderObjectBaseDataFromFlexFieldObject(ScribanDialogStepBaseData renderObject, ExportDialogData stepData, FlexFieldObject flexFieldObject)
 {
     ScribanFlexFieldObject exportObject = FlexFieldValueCollectorUtil.ConvertScribanFlexFieldObject(flexFieldObject, _exportSettings, _errorCollection);
     SetRenderObjectBaseData(renderObject, stepData, exportObject);
 }