示例#1
0
        /// <summary>
        /// Gets text tokens for this message.
        /// Will return a random variant if variant = -1 and more than one variant exists.
        /// If only a single variant then same text tokens are returned each time.
        /// It is safe to leave variant as -1 if you don't care about the variant you receive.
        /// </summary>
        /// <param name="randomVariant">True for a random variant, otherwise use first and only variant.</param>
        /// <param name="expandMacros">True to expand text macros like %foo and __foo_.</param>
        /// <returns>Array of text tokens.</returns>
        public TextFile.Token[] GetTextTokens(int variant = -1, bool expandMacros = true)
        {
            // Randomise variant
            int index;

            if (variant == -1)
            {
                index = Random.Range(0, VariantCount);
            }
            else
            {
                index = 0;
            }

            // Get token array
            TextFile.Token[] tokens = variants[index].tokens.ToArray();

            // Expand macros
            if (expandMacros)
            {
                QuestMacroHelper macroHelper = new QuestMacroHelper();

                ParentQuest.CurrentLogMessageId = this.id;

                // note Nystul: reveal dialog linked resources here on purpose (quest popups should reveal them: see this issue: https://forums.dfworkshop.net/viewtopic.php?f=24&t=1678&p=22069#p22069)
                macroHelper.ExpandQuestMessage(ParentQuest, ref tokens, true);

                ParentQuest.CurrentLogMessageId = -1;
            }

            return(tokens);
        }
示例#2
0
        /// <summary>
        /// Gets text tokens for this message.
        /// Will return a random variant if variant = -1 and more than one variant exists.
        /// If only a single variant then same text tokens are returned each time.
        /// It is safe to leave variant as -1 if you don't care about the variant you receive.
        /// </summary>
        /// <param name="randomVariant">True for a random variant, otherwise use first and only variant.</param>
        /// <param name="expandMacros">True to expand text macros like %foo and __foo_.</param>
        /// <returns>Array of text tokens.</returns>
        public TextFile.Token[] GetTextTokens(int variant = -1, bool expandMacros = true)
        {
            // Randomise variant
            int index;

            if (variant == -1)
            {
                index = Random.Range(0, VariantCount);
            }
            else
            {
                index = 0;
            }

            // Get token array
            TextFile.Token[] tokens = variants[index].tokens.ToArray();

            // Expand macros
            if (expandMacros)
            {
                QuestMacroHelper macroHelper = new QuestMacroHelper();
                macroHelper.ExpandQuestMessage(ParentQuest, ref tokens);
            }

            return(tokens);
        }
示例#3
0
        /// <summary>
        /// Gets text tokens for this message for specified variant.
        /// Will return the specified variant
        /// </summary>
        /// <param name="variant">the variant of interest.</param>
        /// <param name="expandMacros">True to expand text macros like %foo and __foo_.</param>
        /// <returns>Array of text tokens.</returns>
        public TextFile.Token[] GetTextTokensByVariant(int variant = 0, bool expandMacros = true)
        {
            // Get token array
            TextFile.Token[] tokens = variants[variant].tokens.ToArray();

            // Expand macros
            if (expandMacros)
            {
                QuestMacroHelper macroHelper = new QuestMacroHelper();
                macroHelper.ExpandQuestMessage(ParentQuest, ref tokens);
            }

            return(tokens);
        }
示例#4
0
        protected virtual Place GetLastPlaceMentionedInMessage(Message message)
        {
            QuestMacroHelper helper = new QuestMacroHelper();

            QuestResource[] resources = helper.GetMessageResources(message);
            if (resources == null || resources.Length == 0)
            {
                return(null);
            }

            Place lastPlace = null;

            foreach (QuestResource resource in resources)
            {
                if (resource is Place)
                {
                    lastPlace = (Place)resource;
                }
            }

            return(lastPlace);
        }