private void AcquireTextFromAvailableEntities() { if (_textProviders == null || _textProviders.Length == 0) { return; } EntityText availableEntity = _textProviders.FirstOrDefault(t => t.CanTalk == true); if (DebugMode) { Debug.Log("There is " + (availableEntity == default(EntityText) ? "no" : "an") + " NPC that can talk."); } // Code Case: We no longer have an entity, but we still show there being dialogue. // User Case: Player has left a trigger with text still shown. // Desired Result: Stop showing text, reset line counter. if (availableEntity == default(EntityText) && DialogueAvailable) { if (DebugMode) { Debug.Log("User has left a text trigger, so hide text."); } _currentThread.ResetIndex(); DialogueAvailable = false; HideElements(); } // Code Case: We have an entity, and we do not see any current dialogue. // User Case: Player has initiated a conversation sequence. // Desired Result: Start showing text, set line counter to first item, set speaker name. // Also, lock the player's player control script. else if (availableEntity != default(EntityText) && (!DialogueAvailable)) { if (DebugMode) { Debug.Log("Player has initiated a conversation."); } _currentThread = availableEntity.CurrentThread(_ambassador.SequenceCounters); _currentThread.ResetIndex(); DialogueText currentText = _currentThread.GetCurrentText(); if (currentText != null) { PresentLine(currentText); DialogueAvailable = true; PlayerHasControl(false); ShowElements(); } } // Code Case: We have both an entity and show dialogue // User Case: An conversation is on-going // Desired Result: Do not mess with it! // Code Case: We have no entity and show no dialogue [Default State] // User Case: User is doing some non-conversation activity // Desired Result: Do nothing. }