コード例 #1
0
        /// <summary>
        /// Builds the function list
        /// </summary>
        /// <param name="functionCode">Code for the functions to repeat</param>
        /// <param name="project">Project to export for</param>
        /// <param name="npc">Npc</param>
        /// <returns>Daily Routine function list of the npc</returns>
        private async Task <string> BuildFunctionList(string functionCode, GoNorthProject project, KortistoNpc npc)
        {
            if (npc.DailyRoutine == null)
            {
                return(string.Empty);
            }

            SharedDailyRoutineExportUtil.SortDailyRoutine(npc.DailyRoutine);

            int    eventIndex    = 0;
            string eventListCode = string.Empty;

            foreach (KortistoNpcDailyRoutineEvent curEvent in npc.DailyRoutine)
            {
                string curEventCode = ExportUtil.BuildPlaceholderRegex(Placeholder_CurEvent_Index).Replace(functionCode, eventIndex.ToString());

                try
                {
                    _errorCollection.CurrentErrorContext = _localizer["DailyRoutineErrorContext", curEvent.EarliestTime.Hours.ToString().PadLeft(2, '0'), curEvent.EarliestTime.Minutes.ToString().PadLeft(2, '0')].Value;
                    _eventContentPlaceholderResolver.SetErrorCollection(_errorCollection);
                    curEventCode = await _eventContentPlaceholderResolver.ResolveDailyRoutineEventContentPlaceholders(curEventCode, npc, curEvent, _errorCollection);

                    curEventCode = await _eventPlaceholderResolver.ResolveDailyRoutineEventPlaceholders(curEventCode, npc, curEvent);
                }
                finally
                {
                    _errorCollection.CurrentErrorContext = string.Empty;
                }

                eventListCode += curEventCode;
                ++eventIndex;
            }

            return(eventListCode);
        }
コード例 #2
0
        /// <summary>
        /// Collects the values for an export
        /// </summary>
        /// <param name="templateType">Template type</param>
        /// <param name="parsedTemplate">Parsed scriban template</param>
        /// <param name="scriptObject">Scriban script object to fill</param>
        /// <param name="data">Export Data</param>
        /// <returns>Task</returns>
        public override async Task CollectValues(TemplateType templateType, Template parsedTemplate, ScriptObject scriptObject, ExportObjectData data)
        {
            KortistoNpc inputNpc = data.ExportData[ExportConstants.ExportDataObject] as KortistoNpc;

            if (inputNpc == null)
            {
                return;
            }

            SharedDailyRoutineExportUtil.SortDailyRoutine(inputNpc.DailyRoutine);

            List <ScribanExportDailyRoutineEvent> events = await ScribanDailyRoutineEventUtil.MapNpcDailyRoutineEvents(_cachedDbAccess, _dailyRoutineFunctionNameGenerator, inputNpc, inputNpc.DailyRoutine);

            scriptObject.AddOrUpdate(ExportConstants.ScribanDailyRoutineEventsObjectKey, events);
        }
コード例 #3
0
        /// <summary>
        /// Collects the values for an export
        /// </summary>
        /// <param name="templateType">Template type</param>
        /// <param name="parsedTemplate">Parsed scriban template</param>
        /// <param name="scriptObject">Scriban script object to fill</param>
        /// <param name="data">Export Data</param>
        /// <returns>Task</returns>
        public override async Task CollectValues(TemplateType templateType, Template parsedTemplate, ScriptObject scriptObject, ExportObjectData data)
        {
            KortistoNpc inputNpc = data.ExportData[ExportConstants.ExportDataObject] as KortistoNpc;

            if (inputNpc == null)
            {
                return;
            }

            SharedDailyRoutineExportUtil.SortDailyRoutine(inputNpc.DailyRoutine);

            ScribanExportDailyRoutine dailyRoutine = new ScribanExportDailyRoutine();

            dailyRoutine.Events = await ScribanDailyRoutineEventUtil.MapNpcDailyRoutineEvents(_cachedDbAccess, _dailyRoutineFunctionNameGenerator, inputNpc, inputNpc.DailyRoutine);

            dailyRoutine.EventFunctions = await BuildDailyRoutineFunctions(inputNpc, inputNpc.DailyRoutine);

            scriptObject.AddOrUpdate(ExportConstants.ScribanDailyRoutineObjectKey, dailyRoutine);

            scriptObject.AddOrUpdate(DailyRoutineEventListRenderer.DailyRoutineEventListFunctionName, new DailyRoutineEventListRenderer(_templatePlaceholderResolver, _cachedDbAccess, _defaultTemplateProvider, _errorCollection, data));
            scriptObject.AddOrUpdate(DailyRoutineEventFunctionRenderer.DailyRoutineEventFunctionName, new DailyRoutineEventFunctionRenderer(_templatePlaceholderResolver, _cachedDbAccess, _defaultTemplateProvider, _errorCollection));
            scriptObject.AddOrUpdate(DailyRoutineEventFunctionListRenderer.DailyRoutineEventFunctionListFunctionName, new DailyRoutineEventFunctionListRenderer(_templatePlaceholderResolver, _cachedDbAccess, _defaultTemplateProvider, _errorCollection));
        }
コード例 #4
0
        /// <summary>
        /// Builds the event list
        /// </summary>
        /// <param name="eventCode">Code for the events to repeat</param>
        /// <param name="project">Project to export for</param>
        /// <param name="npc">Npc</param>
        /// <returns>Daily Routine event list of the npc</returns>
        private string BuildEventList(string eventCode, GoNorthProject project, KortistoNpc npc)
        {
            if (npc.DailyRoutine == null)
            {
                return(string.Empty);
            }

            SharedDailyRoutineExportUtil.SortDailyRoutine(npc.DailyRoutine);

            int    eventIndex    = 0;
            string eventListCode = string.Empty;

            foreach (KortistoNpcDailyRoutineEvent curEvent in npc.DailyRoutine)
            {
                string curEventCode = ExportUtil.BuildPlaceholderRegex(Placeholder_CurEvent_Index).Replace(eventCode, eventIndex.ToString());

                curEventCode = _eventPlaceholderResolver.ResolveDailyRoutineEventPlaceholders(curEventCode, npc, curEvent).Result;

                eventListCode += curEventCode;
                ++eventIndex;
            }

            return(eventListCode);
        }