/// <summary> /// Barks if the condition is true. /// </summary> /// <param name="target">Target.</param> /// <param name="interactor">Interactor to test the condition against.</param> public void TryBark(Transform target, Transform interactor) { if (!tryingToBark) { tryingToBark = true; try { if ((condition == null) || condition.IsTrue(interactor)) { if (string.IsNullOrEmpty(conversation)) { if (DialogueDebug.logWarnings) { Debug.LogWarning(string.Format("{0}: Bark triggered on {1}, but conversation name is blank.", new System.Object[] { DialogueDebug.Prefix, name }), GetBarker()); } } else if (DialogueManager.isConversationActive && !allowDuringConversations) { if (DialogueDebug.logWarnings) { Debug.LogWarning(string.Format("{0}: Bark triggered on {1}, but a conversation is already active.", new System.Object[] { DialogueDebug.Prefix, name }), GetBarker()); } } else if (cacheBarkLines) { BarkCachedLine(GetBarker(), target); } else { if (barkGroupMember != null) { barkGroupMember.GroupBark(conversation, target, barkHistory); } else { DialogueManager.Bark(conversation, GetBarker(), target, barkHistory); } sequencer = BarkController.LastSequencer; } DestroyIfOnce(); } } finally { tryingToBark = false; } } }
protected virtual void DoBarkAction(Transform actor) { switch (barkSource) { case BarkSource.Conversation: if (string.IsNullOrEmpty(barkConversation)) { return; } if (DialogueManager.isConversationActive && !allowBarksDuringConversations) { if (DialogueDebug.logWarnings) { Debug.LogWarning("Dialogue System: Bark triggered on " + name + ", but a conversation is already active.", GetBarker(barkConversation)); } } else if (cacheBarkLines) { BarkCachedLine(GetBarker(barkConversation), Tools.Select(barkTarget, actor)); } else { if (barkGroupMember != null) { barkGroupMember.GroupBark(barkConversation, Tools.Select(barkTarget, actor), barkHistory); } else { DialogueManager.Bark(barkConversation, GetBarker(barkConversation), Tools.Select(barkTarget, actor), barkHistory); } sequencer = BarkController.LastSequencer; } break; case BarkSource.Text: if (string.IsNullOrEmpty(barkText)) { return; } if (DialogueManager.isConversationActive && !allowBarksDuringConversations) { if (DialogueDebug.logWarnings) { Debug.LogWarning("Dialogue System: Bark triggered on " + name + ", but a conversation is already active.", GetBarker(null)); } } else { if (barkGroupMember != null) { barkGroupMember.GroupBarkString(barkText, Tools.Select(barkTarget, actor), barkTextSequence); } else { DialogueManager.BarkString(barkText, GetBarker(null), Tools.Select(barkTarget, actor), barkTextSequence); } sequencer = BarkController.LastSequencer; } break; } }