/// <summary>
        /// Returns the npc use
        /// </summary>
        /// <param name="flexFieldObject">Flex field object</param>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <returns>Value Object</returns>
        private async Task <IFlexFieldExportable> GetNpc(FlexFieldObject flexFieldObject, UseItemActionRenderer.UseItemActionData parsedData, ExportPlaceholderErrorCollection errorCollection)
        {
            if (_isPickNpc)
            {
                KortistoNpc npc = await _cachedDbAccess.GetNpcById(parsedData.NpcId);

                if (npc == null)
                {
                    errorCollection.AddDialogItemNotFoundError();
                    return(null);
                }

                return(npc);
            }
            else if (_isPlayer)
            {
                GoNorthProject curProject = await _cachedDbAccess.GetDefaultProject();

                KortistoNpc npc = await _cachedDbAccess.GetPlayerNpc(curProject.Id);

                if (npc == null)
                {
                    errorCollection.AddNoPlayerNpcExistsError();
                    return(null);
                }

                return(npc);
            }

            return(flexFieldObject);
        }
        /// <summary>
        /// Returns the npc to use
        /// </summary>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <returns>Value Object</returns>
        private async Task<IFlexFieldExportable> GetNpc(FlexFieldObject flexFieldObject, ExportPlaceholderErrorCollection errorCollection)
        {
            if(_isPlayer)
            {
                GoNorthProject curProject = await _cachedDbAccess.GetDefaultProject();
                flexFieldObject = await _cachedDbAccess.GetPlayerNpc(curProject.Id);
                if(flexFieldObject == null)
                {
                    errorCollection.AddNoPlayerNpcExistsError();
                    return null;
                }
            }

            return flexFieldObject;
        }
        /// <summary>
        /// Loads the npc
        /// </summary>
        /// <param name="cachedDbAccess">Cached database access</param>
        /// <param name="project">Project</param>
        /// <param name="flexFieldObject">Flex field object to which the dialog belongs</param>
        /// <param name="errorCollection">Export settings</param>
        /// <param name="isPlayer">true if the condition resolver is for the player, else false</param>
        /// <returns>Loaded npc, null if no npc could be found</returns>
        public static async Task <KortistoNpc> GetExportNpc(IExportCachedDbAccess cachedDbAccess, GoNorthProject project, FlexFieldObject flexFieldObject, ExportPlaceholderErrorCollection errorCollection, bool isPlayer)
        {
            if (isPlayer)
            {
                flexFieldObject = await cachedDbAccess.GetPlayerNpc(project.Id);

                if (flexFieldObject == null)
                {
                    errorCollection.AddNoPlayerNpcExistsError();
                    return(null);
                }
            }

            return(flexFieldObject as KortistoNpc);
        }
        /// <summary>
        /// Returns the currently valid npc for the action
        /// </summary>
        /// <param name="parsedData">Parsed data</param>
        /// <param name="flexFieldObject">Flex field object</param>
        /// <returns>Npc</returns>
        private async Task <KortistoNpc> GetNpc(MoveNpcActionRenderer.MoveNpcActionData parsedData, FlexFieldObject flexFieldObject)
        {
            if (_isPickedNpc)
            {
                return(await _cachedDbAccess.GetNpcById(parsedData.ObjectId));
            }

            if (_isPlayer)
            {
                GoNorthProject project = await _cachedDbAccess.GetDefaultProject();

                return(await _cachedDbAccess.GetPlayerNpc(project.Id));
            }

            return(flexFieldObject as KortistoNpc);
        }
Example #5
0
        /// <summary>
        /// Returns the npc to use
        /// </summary>
        /// <param name="npc">Npc to which the dialog belongs</param>
        /// <param name="errorCollection">Error Collection</param>
        /// <returns>Value Object</returns>
        private async Task <IFlexFieldExportable> GetNpc(KortistoNpc npc, ExportPlaceholderErrorCollection errorCollection)
        {
            if (_isPlayer)
            {
                GoNorthProject curProject = await _cachedDbAccess.GetDefaultProject();

                npc = await _cachedDbAccess.GetPlayerNpc(curProject.Id);

                if (npc == null)
                {
                    errorCollection.AddNoPlayerNpcExistsError();
                    return(null);
                }
            }

            return(npc);
        }