/// <summary> /// Starts dialogue with the player. The content of the dialogue will depend on the quest giver's /// offerable quests and the player's quests. /// </summary> /// <param name="player">Player conversing with this QuestGiver. If null, searches the scene for a GameObject tagged Player.</param> public virtual void StartDialogue(GameObject player) { if (questDialogueUI == null && Debug.isDebugBuild) { Debug.LogWarning("Quest Machine: Can't start dialogue with " + name + ". Quest Giver doesn't have access to a quest dialogue UI.", this); return; } // If player isn't specified, find it in the scene and find relevant quest journal: if (player == null) { player = FindPlayerGameObject(); } if (player == null && Debug.isDebugBuild) { Debug.LogWarning("Quest Machine: Can't start dialogue with " + name + ". No quester specified.", this); return; } playerQuestListContainer = player.GetComponent <QuestListContainer>(); if (playerQuestListContainer == null) { var playerID = player.GetComponent <QuestMachineID>(); if (playerID != null && playerID.questListContainer != null) { playerQuestListContainer = playerID.questListContainer; } else { var playerJournalObject = FindPlayerJournalGameObject(); playerQuestListContainer = (playerJournalObject != null) ? playerJournalObject.GetComponent <QuestListContainer>() : null; } } if (playerQuestListContainer == null && Debug.isDebugBuild) { Debug.LogWarning("Quest Machine: Can't start dialogue with " + name + ". Quester " + player.name + " doesn't have a Quest Journal and can't find one in scene.", this); return; } QuestMachineTags.fallbackTextTable = textTable; // Setup player info: this.player = player; playerTextInfo = new QuestParticipantTextInfo(QuestMachineMessages.GetID(player), QuestMachineMessages.GetDisplayName(player), null, null); // Greet before recording quests in case Greet message changes a quest state: QuestMachineMessages.Greet(player, this, id); // Record quests related to this player and me: RecordQuestsByState(); StartMostRelevantDialogue(); // Note: Sends Greeted immediately after opening dialogue UI, not when closing it: QuestMachineMessages.Greeted(player, this, id); }