/// <summary> /// Builds the daily routine functions /// </summary> /// <param name="inputNpc">Npc</param> /// <param name="dailyRoutine">Daily routine list</param> /// <returns>Function list</returns> private async Task <List <ScribanExportDailyRoutineFunction> > BuildDailyRoutineFunctions(KortistoNpc inputNpc, List <KortistoNpcDailyRoutineEvent> dailyRoutine) { if (dailyRoutine == null || !dailyRoutine.Any()) { return(new List <ScribanExportDailyRoutineFunction>()); } _dailyRoutineFunctionRenderer.SetErrorCollection(_errorCollection); _dailyRoutineFunctionRenderer.SetExportTemplatePlaceholderResolver(_templatePlaceholderResolver); List <DailyRoutineFunction> functions = await _dailyRoutineFunctionRenderer.RenderDailyRoutineFunctions(dailyRoutine, inputNpc); return(functions.Select(f => new ScribanExportDailyRoutineFunction(f)).ToList()); }
/// <summary> /// Renders the daily routine functions /// </summary> /// <param name="dailyRoutineEvent">Daily routine event</param> /// <param name="npc">Npc</param> /// <param name="errorCollection">Error collection</param> /// <returns>Node graph render result</returns> private async Task <List <DailyRoutineFunction> > RenderDailyRoutineFunctions(KortistoNpcDailyRoutineEvent dailyRoutineEvent, KortistoNpc npc, ExportPlaceholderErrorCollection errorCollection) { if (dailyRoutineEvent == null) { return(new List <DailyRoutineFunction>()); } if (_renderedEvents.ContainsKey(dailyRoutineEvent.EventId)) { return(_renderedEvents[dailyRoutineEvent.EventId]); } List <DailyRoutineFunction> functions = await _dailyRoutineFunctionRenderer.RenderDailyRoutineFunctions(new List <KortistoNpcDailyRoutineEvent> { dailyRoutineEvent }, npc); _renderedEvents.Add(dailyRoutineEvent.EventId, functions); return(functions); }
/// <summary> /// Replaces the function list /// </summary> /// <param name="project">Current project</param> /// <param name="npc">Npc for which the daily routine functions must be rendered</param> /// <returns>Rendered function list</returns> private async Task <string> ReplaceFunctionList(GoNorthProject project, KortistoNpc npc) { ExportTemplate dailyRoutineFunctionListTemplate = await _defaultTemplateProvider.GetDefaultTemplateByType(project.Id, TemplateType.ObjectDailyRoutineFunctionList); if (dailyRoutineFunctionListTemplate.RenderingEngine == ExportTemplateRenderingEngine.Scriban) { _dailyRoutineFunctionRenderer.SetErrorCollection(_errorCollection); List <DailyRoutineFunction> functions = await _dailyRoutineFunctionRenderer.RenderDailyRoutineFunctions(npc.DailyRoutine, npc); ExportObjectData objectData = new ExportObjectData(); objectData.ExportData.Add(ExportConstants.ExportDataObject, functions); ExportPlaceholderFillResult fillResult = await _placeholderResolver.FillPlaceholders(TemplateType.ObjectDailyRoutineFunctionList, dailyRoutineFunctionListTemplate.Code, objectData, dailyRoutineFunctionListTemplate.RenderingEngine); _errorCollection.Merge(fillResult.Errors); return(fillResult.Code); } else { return(dailyRoutineFunctionListTemplate.Code); } }