2021-12-23 11:37:37 +00:00
using System ;
using System.Collections.Generic ;
using System.Xml.Linq ;
using UnityEngine ;
2022-02-24 22:04:54 -08:00
namespace QSB.EyeOfTheUniverse.GalaxyMap ;
internal class QSBCharacterDialogueTree : MonoBehaviour
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
public TextAsset _xmlCharacterDialogueAsset ;
public Transform _attentionPoint ;
public Vector3 _attentionPointOffset = Vector3 . zero ;
public bool _turnOffFlashlight = true ;
public bool _turnOnFlashlight = true ;
private SingleInteractionVolume _interactVolume ;
private string _characterName ;
private bool _initialized ;
private IDictionary < string , QSBDialogueNode > _mapDialogueNodes ;
private List < DialogueOption > _listOptionNodes ;
private QSBDialogueNode _currentNode ;
private DialogueBoxVer2 _currentDialogueBox ;
private bool _wasFlashlightOn ;
private bool _timeFrozen ;
private const string SIGN_NAME = "SIGN" ;
private const string RECORDING_NAME = "RECORDING" ;
private const float MINIMUM_TIME_TEXT_VISIBLE = 0.1f ;
private void Awake ( )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
_attentionPoint ? ? = transform ;
_initialized = false ;
_interactVolume = this . GetRequiredComponent < SingleInteractionVolume > ( ) ;
GlobalMessenger . AddListener ( "DialogueConditionsReset" , new Callback ( OnDialogueConditionsReset ) ) ;
GlobalMessenger < DeathType > . AddListener ( "PlayerDeath" , new Callback < DeathType > ( OnPlayerDeath ) ) ;
enabled = false ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
private void OnDestroy ( )
{
GlobalMessenger . RemoveListener ( "DialogueConditionsReset" , new Callback ( OnDialogueConditionsReset ) ) ;
GlobalMessenger < DeathType > . RemoveListener ( "PlayerDeath" , new Callback < DeathType > ( OnPlayerDeath ) ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
public void LateInitialize ( )
{
_mapDialogueNodes = new Dictionary < string , QSBDialogueNode > ( ComparerLibrary . stringEqComparer ) ;
_listOptionNodes = new List < DialogueOption > ( ) ;
_initialized = LoadXml ( ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
public void VerifyInitialized ( )
{
if ( ! _initialized )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
LateInitialize ( ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
public void SetTextXml ( TextAsset textAsset )
{
_xmlCharacterDialogueAsset = textAsset ;
if ( _initialized )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
LoadXml ( ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
public bool InConversation ( ) = > enabled ;
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
public InteractVolume GetInteractVolume ( ) = > _interactVolume ;
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
private void Update ( )
{
if ( _currentDialogueBox ! = null & & OWInput . GetInputMode ( ) = = InputMode . Dialogue )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
if ( OWInput . IsNewlyPressed ( InputLibrary . interact ) | | OWInput . IsNewlyPressed ( InputLibrary . cancel ) | | OWInput . IsNewlyPressed ( InputLibrary . enter ) | | OWInput . IsNewlyPressed ( InputLibrary . enter2 ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
if ( ! _currentDialogueBox . AreTextEffectsComplete ( ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
_currentDialogueBox . FinishAllTextEffects ( ) ;
return ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( _currentDialogueBox . TimeCompletelyRevealed ( ) < 0.1f )
{
return ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
var selectedOption = _currentDialogueBox . GetSelectedOption ( ) ;
if ( ! InputDialogueOption ( selectedOption ) )
{
EndConversation ( ) ;
return ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
}
else
{
if ( OWInput . IsNewlyPressed ( InputLibrary . down ) | | OWInput . IsNewlyPressed ( InputLibrary . down2 ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
_currentDialogueBox . OnDownPressed ( ) ;
return ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( OWInput . IsNewlyPressed ( InputLibrary . up ) | | OWInput . IsNewlyPressed ( InputLibrary . up2 ) )
{
_currentDialogueBox . OnUpPressed ( ) ;
2021-12-23 11:37:37 +00:00
}
}
}
2022-02-24 22:04:54 -08:00
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
private void SetEntryNode ( )
{
var list = new List < QSBDialogueNode > ( ) ;
list . AddRange ( _mapDialogueNodes . Values ) ;
for ( var i = list . Count - 1 ; i > = 0 ; i - - )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
if ( list [ i ] . EntryConditionsSatisfied ( ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
_currentNode = list [ i ] ;
return ;
2021-12-23 11:37:37 +00:00
}
}
2022-02-24 22:04:54 -08:00
Debug . LogWarning ( "CharacterDialogueTree " + _characterName + " no EntryConditions satisfied. Did you forget to add <EntryCondition>DEFAULT</EntryCondition> to a node?" ) ;
}
private bool LoadXml ( )
{
try
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
_mapDialogueNodes . Clear ( ) ;
_listOptionNodes . Clear ( ) ;
var sharedInstance = DialogueConditionManager . SharedInstance ;
var xelement = XDocument . Parse ( OWUtilities . RemoveByteOrderMark ( _xmlCharacterDialogueAsset ) ) . Element ( "DialogueTree" ) ;
var xelement2 = xelement . Element ( "NameField" ) ;
if ( xelement2 = = null )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
_characterName = "" ;
}
else
{
_characterName = xelement2 . Value ;
}
foreach ( var xelement3 in xelement . Elements ( "DialogueNode" ) )
{
var dialogueNode = new QSBDialogueNode ( ) ;
if ( xelement3 . Element ( "Name" ) ! = null )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
dialogueNode . Name = xelement3 . Element ( "Name" ) . Value ;
2021-12-23 11:37:37 +00:00
}
else
{
2022-02-24 22:04:54 -08:00
Debug . LogWarning ( "Missing name on a Node" ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
var randomize = xelement3 . Element ( "Randomize" ) ! = null ;
dialogueNode . DisplayTextData = new DialogueText ( xelement3 . Elements ( "Dialogue" ) , randomize ) ;
var xelement4 = xelement3 . Element ( "DialogueTarget" ) ;
if ( xelement4 ! = null )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
dialogueNode . TargetName = xelement4 . Value ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
var enumerable = xelement3 . Elements ( "EntryCondition" ) ;
if ( enumerable ! = null )
{
foreach ( var xelement5 in enumerable )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
dialogueNode . ListEntryCondition . Add ( xelement5 . Value ) ;
if ( ! sharedInstance . ConditionExists ( xelement5 . Value ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
sharedInstance . AddCondition ( xelement5 . Value ) ;
2021-12-23 11:37:37 +00:00
}
}
2022-02-24 22:04:54 -08:00
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
var enumerable2 = xelement3 . Elements ( "DialogueTargetShipLogCondition" ) ;
if ( enumerable2 ! = null )
{
foreach ( var xelement6 in enumerable2 )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
dialogueNode . ListTargetCondition . Add ( xelement6 . Value ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
foreach ( var xelement7 in xelement3 . Elements ( "SetCondition" ) )
{
dialogueNode . ConditionsToSet . Add ( xelement7 . Value ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
var xelement8 = xelement3 . Element ( "SetPersistentCondition" ) ;
if ( xelement8 ! = null )
{
dialogueNode . PersistentConditionToSet = xelement8 . Value ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
var xelement9 = xelement3 . Element ( "DisablePersistentCondition" ) ;
if ( xelement9 ! = null )
{
dialogueNode . PersistentConditionToDisable = xelement9 . Value ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
var xelement10 = xelement3 . Element ( "RevealFacts" ) ;
if ( xelement10 ! = null )
{
var enumerable3 = xelement10 . Elements ( "FactID" ) ;
if ( enumerable3 ! = null )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
var list = new List < string > ( ) ;
foreach ( var xelement11 in enumerable3 )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
list . Add ( xelement11 . Value ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
dialogueNode . DBEntriesToSet = new string [ list . Count ] ;
for ( var i = 0 ; i < list . Count ; i + + )
{
dialogueNode . DBEntriesToSet [ i ] = list [ i ] ;
2021-12-23 11:37:37 +00:00
}
}
2022-02-24 22:04:54 -08:00
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
var list2 = new List < DialogueOption > ( ) ;
var xelement12 = xelement3 . Element ( "DialogueOptionsList" ) ;
if ( xelement12 ! = null )
{
var enumerable4 = xelement12 . Elements ( "DialogueOption" ) ;
if ( enumerable4 ! = null )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
foreach ( var xelement13 in enumerable4 )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
var dialogueOption = new DialogueOption
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
Text = OWUtilities . CleanupXmlText ( xelement13 . Element ( "Text" ) . Value , false )
} ;
dialogueOption . SetNodeId ( dialogueNode . Name , _characterName ) ;
var xelement14 = xelement13 . Element ( "DialogueTarget" ) ;
if ( xelement14 ! = null )
{
dialogueOption . TargetName = xelement14 . Value ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( xelement13 . Element ( "RequiredCondition" ) ! = null )
{
dialogueOption . ConditionRequirement = xelement13 . Element ( "RequiredCondition" ) . Value ;
if ( ! sharedInstance . ConditionExists ( dialogueOption . ConditionRequirement ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
sharedInstance . AddCondition ( dialogueOption . ConditionRequirement ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
foreach ( var xelement15 in xelement13 . Elements ( "RequiredPersistentCondition" ) )
{
dialogueOption . PersistentCondition . Add ( xelement15 . Value ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( xelement13 . Element ( "CancelledCondition" ) ! = null )
{
dialogueOption . CancelledRequirement = xelement13 . Element ( "CancelledCondition" ) . Value ;
if ( ! sharedInstance . ConditionExists ( dialogueOption . CancelledRequirement ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
sharedInstance . AddCondition ( dialogueOption . CancelledRequirement ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
foreach ( var xelement16 in xelement13 . Elements ( "CancelledPersistentCondition" ) )
{
dialogueOption . CancelledPersistentRequirement . Add ( xelement16 . Value ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
foreach ( var xelement17 in xelement13 . Elements ( "RequiredLogCondition" ) )
{
dialogueOption . LogConditionRequirement . Add ( xelement17 . Value ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( xelement13 . Element ( "ConditionToSet" ) ! = null )
{
dialogueOption . ConditionToSet = xelement13 . Element ( "ConditionToSet" ) . Value ;
if ( ! sharedInstance . ConditionExists ( dialogueOption . ConditionToSet ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
sharedInstance . AddCondition ( dialogueOption . ConditionToSet ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( xelement13 . Element ( "ConditionToCancel" ) ! = null )
{
dialogueOption . ConditionToCancel = xelement13 . Element ( "ConditionToCancel" ) . Value ;
if ( ! sharedInstance . ConditionExists ( dialogueOption . ConditionToCancel ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
sharedInstance . AddCondition ( dialogueOption . ConditionToCancel ) ;
2021-12-23 11:37:37 +00:00
}
}
2022-02-24 22:04:54 -08:00
list2 . Add ( dialogueOption ) ;
_listOptionNodes . Add ( dialogueOption ) ;
2021-12-23 11:37:37 +00:00
}
}
}
2022-02-24 22:04:54 -08:00
dialogueNode . ListDialogueOptions = list2 ;
_mapDialogueNodes . Add ( dialogueNode . Name , dialogueNode ) ;
}
var list3 = new List < QSBDialogueNode > ( ) ;
list3 . AddRange ( _mapDialogueNodes . Values ) ;
for ( var j = 0 ; j < list3 . Count ; j + + )
{
var dialogueNode2 = list3 [ j ] ;
var targetName = dialogueNode2 . TargetName ;
if ( targetName ! = "" )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
if ( _mapDialogueNodes . ContainsKey ( targetName ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
dialogueNode2 . Target = _mapDialogueNodes [ targetName ] ;
2021-12-23 11:37:37 +00:00
}
else
{
2022-02-24 22:04:54 -08:00
Debug . LogError ( "Target Node: " + targetName + " does not exist" , this ) ;
2021-12-23 11:37:37 +00:00
}
}
2022-02-24 22:04:54 -08:00
else
{
dialogueNode2 . Target = null ;
}
2021-12-23 11:37:37 +00:00
}
}
2022-02-24 22:04:54 -08:00
catch ( Exception ex )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
Debug . LogError ( "XML Error in CharacterDialogueTree!\n" + ex . Message , this ) ;
return false ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
return true ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
public void StartConversation ( )
{
VerifyInitialized ( ) ;
enabled = true ;
if ( ! _timeFrozen & & PlayerData . GetFreezeTimeWhileReadingConversations ( ) & & ! Locator . GetGlobalMusicController ( ) . IsEndTimesPlaying ( ) )
{
_timeFrozen = true ;
OWTime . Pause ( OWTime . PauseType . Reading ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
Locator . GetToolModeSwapper ( ) . UnequipTool ( ) ;
GlobalMessenger . FireEvent ( "EnterConversation" ) ;
Locator . GetPlayerAudioController ( ) . PlayDialogueEnter ( ) ;
_wasFlashlightOn = Locator . GetFlashlight ( ) . IsFlashlightOn ( ) ;
if ( _wasFlashlightOn & & _turnOffFlashlight )
{
Locator . GetFlashlight ( ) . TurnOff ( false ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
DialogueConditionManager . SharedInstance . ReadPlayerData ( ) ;
SetEntryNode ( ) ;
_currentDialogueBox = DisplayDialogueBox2 ( ) ;
if ( _attentionPoint ! = null & & ! PlayerState . InZeroG ( ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
Locator . GetPlayerTransform ( ) . GetRequiredComponent < PlayerLockOnTargeting > ( ) . LockOn ( _attentionPoint , _attentionPointOffset , 2f ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( PlayerState . InZeroG ( ) & & ! _timeFrozen )
{
Locator . GetPlayerBody ( ) . GetComponent < Autopilot > ( ) . StartMatchVelocity ( this . GetAttachedOWRigidbody ( ) . GetReferenceFrame ( ) ) ;
}
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
public void EndConversation ( )
{
if ( ! enabled )
{
return ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
enabled = false ;
if ( _timeFrozen )
{
_timeFrozen = false ;
OWTime . Unpause ( OWTime . PauseType . Reading ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
_interactVolume . ResetInteraction ( ) ;
Locator . GetPlayerTransform ( ) . GetRequiredComponent < PlayerLockOnTargeting > ( ) . BreakLock ( ) ;
GlobalMessenger . FireEvent ( "ExitConversation" ) ;
Locator . GetPlayerAudioController ( ) . PlayDialogueExit ( ) ;
if ( _wasFlashlightOn & & _turnOffFlashlight & & _turnOnFlashlight )
{
Locator . GetFlashlight ( ) . TurnOn ( false ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
GameObject . FindWithTag ( "DialogueGui" ) . GetRequiredComponent < DialogueBoxVer2 > ( ) . OnEndDialogue ( ) ;
if ( _currentNode ! = null )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
_currentNode . SetNodeCompleted ( ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( PlayerState . InZeroG ( ) )
{
var component = Locator . GetPlayerBody ( ) . GetComponent < Autopilot > ( ) ;
if ( component . enabled )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
component . Abort ( ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
}
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
private bool InputDialogueOption ( int optionIndex )
{
var result = true ;
var flag = true ;
if ( optionIndex > = 0 )
{
var selectedOption = _currentDialogueBox . OptionFromUIIndex ( optionIndex ) ;
ContinueToNextNode ( selectedOption ) ;
}
else if ( ! _currentNode . HasNext ( ) )
{
ContinueToNextNode ( ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( _currentNode = = null )
{
_currentDialogueBox = null ;
flag = false ;
result = false ;
}
else
{
_currentDialogueBox = DisplayDialogueBox2 ( ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
if ( flag )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
Locator . GetPlayerAudioController ( ) . PlayDialogueAdvance ( ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
return result ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
private DialogueBoxVer2 DisplayDialogueBox2 ( )
{
var richText = "" ;
var listOptions = new List < DialogueOption > ( ) ;
_currentNode . RefreshConditionsData ( ) ;
if ( _currentNode . HasNext ( ) )
{
_currentNode . GetNextPage ( out richText , ref listOptions ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
var requiredComponent = GameObject . FindWithTag ( "DialogueGui" ) . GetRequiredComponent < DialogueBoxVer2 > ( ) ;
requiredComponent . SetVisible ( true ) ;
requiredComponent . SetDialogueText ( richText , listOptions ) ;
if ( _characterName = = "" )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
requiredComponent . SetNameFieldVisible ( false ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
else
{
requiredComponent . SetNameFieldVisible ( true ) ;
requiredComponent . SetNameField ( TextTranslation . Translate ( _characterName ) ) ;
}
return requiredComponent ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
private void ContinueToNextNode ( )
{
_currentNode . SetNodeCompleted ( ) ;
if ( _currentNode . ListTargetCondition . Count > 0 & & ! _currentNode . TargetNodeConditionsSatisfied ( ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
_currentNode = null ;
return ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
_currentNode = _currentNode . Target ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
private void ContinueToNextNode ( DialogueOption selectedOption )
{
_currentNode . SetNodeCompleted ( ) ;
if ( selectedOption . ConditionToSet ! = string . Empty )
{
DialogueConditionManager . SharedInstance . SetConditionState ( selectedOption . ConditionToSet , true ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( selectedOption . ConditionToCancel ! = string . Empty )
{
DialogueConditionManager . SharedInstance . SetConditionState ( selectedOption . ConditionToCancel ) ;
}
2021-12-23 11:37:37 +00:00
2022-02-24 22:04:54 -08:00
if ( selectedOption . TargetName = = string . Empty )
{
_currentNode = null ;
return ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
if ( ! _mapDialogueNodes . ContainsKey ( selectedOption . TargetName ) )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
Debug . LogError ( "Cannot find target node " + selectedOption . TargetName ) ;
Debug . Break ( ) ;
2021-12-23 11:37:37 +00:00
}
2022-02-24 22:04:54 -08:00
_currentNode = _mapDialogueNodes [ selectedOption . TargetName ] ;
}
private void OnDialogueConditionsReset ( )
{
if ( _initialized )
2021-12-23 11:37:37 +00:00
{
2022-02-24 22:04:54 -08:00
LoadXml ( ) ;
}
}
private void OnPlayerDeath ( DeathType deathType )
{
if ( enabled )
{
EndConversation ( ) ;
2021-12-23 11:37:37 +00:00
}
}
2022-02-24 22:04:54 -08:00
}