Ejemplo n.º 1
0
        /// <summary>
        /// Try find a gift reaction dialogue text for gifted object to an NPC
        /// </summary>
        /// <param name="npc">NPC had recieved a gift</param>
        /// <param name="obj">Gifted item recieved by this NPC</param>
        /// <param name="dialogue">A reaction dialogue text for this gifted item to this NPC</param>
        /// <returns>True if any gift reaction dialogue was found, otherwise false</returns>
        public static bool FetchGiftReaction(NPC npc, SObject obj, out string dialogue, string suffix = "")
        {
            string[] possibleKeys = new string[] {
                $"GiftReaction_{obj.Name.Replace(' ', '_')}{suffix}",
                $"GiftReactionCategory_{obj.Category}{suffix}",
                $"GiftReactionHoney_{obj.honeyType.Value}{suffix}",
                $"GiftReactionHoney_{(obj.honeyType.Value.HasValue ? "Any" : "")}{suffix}",
                $"GiftReactionPreserved_{obj.preserve.Value}{suffix}",
                $"GiftReactionPreserved_{(obj.preserve.Value.HasValue ? "Any" : "")}{suffix}",
            };

            foreach (string dialogueKey in possibleKeys)
            {
                if (DialogueHelper.GetRawDialogue(npc.Dialogue, dialogueKey, out KeyValuePair <string, string> reaction))
                {
                    dialogue = reaction.Value;
                    return(true);
                }
            }

            dialogue = "";
            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Try find a gift reaction dialogue text for gifted object to an NPC
        /// </summary>
        /// <param name="npc">NPC had recieved a gift</param>
        /// <param name="obj">Gifted item recieved by this NPC</param>
        /// <param name="dialogue">A reaction dialogue text for this gifted item to this NPC</param>
        /// <returns>True if any gift reaction dialogue was found, otherwise false</returns>
        public static bool FetchGiftReaction(NPC npc, SObject obj, out string dialogue, string suffix = "")
        {
            HashSet <string> possibleKeys = new () {
                $"GiftReaction_{obj.Name.Replace(' ', '_')}{suffix}",
                $"GiftReactionCategory_{obj.Category}{suffix}",
                $"GiftReactionPreserved_{obj.preserve.Value}{suffix}",
                $"GiftReactionPreserved_{(obj.preserve.Value.HasValue ? "Any" : "")}{suffix}",
            };

            // Add item context tags as possibly dialogue lines for gift reactions
            possibleKeys.UnionWith(obj.GetContextTags().Select(tag => $"GiftReactionTag_{tag}"));

            foreach (string dialogueKey in possibleKeys)
            {
                if (DialogueHelper.GetRawDialogue(npc.Dialogue, dialogueKey, out KeyValuePair <string, string> reaction))
                {
                    dialogue = reaction.Value;
                    return(true);
                }
            }

            dialogue = "";
            return(false);
        }