From 2a95f4442f50c3c8b412c7ff5b9ffb4f94dae14d Mon Sep 17 00:00:00 2001 From: B-DeshiDev Date: Thu, 11 Jul 2024 10:43:00 +0600 Subject: [PATCH] Add startnode parameter to graph play events --- .../Runtime/Core/DialogueSystem.cs | 12 +-- .../Samples/DialogueChoiceDemo/DialogueUI.cs | 4 +- .../Graphs/Dialogue Graph 1.asset | 81 +------------------ 3 files changed, 9 insertions(+), 88 deletions(-) diff --git a/Assets/Packages/com.studio23.ss2.dialoguesystem/Runtime/Core/DialogueSystem.cs b/Assets/Packages/com.studio23.ss2.dialoguesystem/Runtime/Core/DialogueSystem.cs index 3dfdaa9..0f2e7c0 100644 --- a/Assets/Packages/com.studio23.ss2.dialoguesystem/Runtime/Core/DialogueSystem.cs +++ b/Assets/Packages/com.studio23.ss2.dialoguesystem/Runtime/Core/DialogueSystem.cs @@ -24,10 +24,10 @@ public class DialogueSystem : MonoBehaviour public bool IsSkipActive => _isSkipActive; public bool ShouldShowLineWhenSkipped => _shouldShowLineWhenSkipped; public float ShowLineDurationWhenSkipping => _showLineDurationWhenSkipping; - public event Action OnSkipToggled; - - public event Action OnDialogueStarted; - public event Action OnDialogueEnded; + public event Action OnSkipToggled; + public delegate void DialoguePlayEvent(DialogueGraph graph, DialogueNodeBase startNode); + public event DialoguePlayEvent OnDialogueStarted; + public event DialoguePlayEvent OnDialogueEnded; public event Action OnDialogueChoiceStarted; public event Action OnDialogueChoiceEnded; @@ -102,7 +102,7 @@ public async UniTask PlayDialogue(DialogueGraph graph, DialogueNodeBase startNod _currentGraph.HandleDialogueStarted(); _isSkipActive = false; - OnDialogueStarted?.Invoke(_currentGraph); + OnDialogueStarted?.Invoke(_currentGraph, startNode); while (_curNode != null) { Debug.Log("Play = " + _curNode, _curNode); @@ -112,7 +112,7 @@ public async UniTask PlayDialogue(DialogueGraph graph, DialogueNodeBase startNod } _currentGraph.HandleDialogueEnded(); - OnDialogueEnded?.Invoke(_currentGraph); + OnDialogueEnded?.Invoke(_currentGraph, startNode); } public void AdvanceDialogue() diff --git a/Assets/Packages/com.studio23.ss2.dialoguesystem/Samples/DialogueChoiceDemo/DialogueUI.cs b/Assets/Packages/com.studio23.ss2.dialoguesystem/Samples/DialogueChoiceDemo/DialogueUI.cs index b78459b..0b4560e 100644 --- a/Assets/Packages/com.studio23.ss2.dialoguesystem/Samples/DialogueChoiceDemo/DialogueUI.cs +++ b/Assets/Packages/com.studio23.ss2.dialoguesystem/Samples/DialogueChoiceDemo/DialogueUI.cs @@ -64,7 +64,7 @@ private void UnRegisterEvents() } } - private void ShowUI(DialogueGraph obj) => ShowUI(); + private void ShowUI(DialogueGraph obj, DialogueNodeBase startNode) => ShowUI(); private void ShowUI(DialogueChoicesNode obj) => ShowUI(); public override void ShowUI() @@ -77,7 +77,7 @@ protected override void HandleDialogueLineCompleted(DialogueLineNodeBase dialogu DialogueBox.HideUI(); } - private void HideUI(DialogueGraph obj) => HideUI(); + private void HideUI(DialogueGraph graph, DialogueNodeBase startnode) => HideUI(); protected override void HandleDialogueLineStarted(DialogueLineNodeBase dialogueLineNodeBase) { diff --git a/Assets/Packages/com.studio23.ss2.dialoguesystem/Samples/DialogueChoiceDemo/Resources/DialogueSystem/Graphs/Dialogue Graph 1.asset b/Assets/Packages/com.studio23.ss2.dialoguesystem/Samples/DialogueChoiceDemo/Resources/DialogueSystem/Graphs/Dialogue Graph 1.asset index e13174e..d93614b 100644 --- a/Assets/Packages/com.studio23.ss2.dialoguesystem/Samples/DialogueChoiceDemo/Resources/DialogueSystem/Graphs/Dialogue Graph 1.asset +++ b/Assets/Packages/com.studio23.ss2.dialoguesystem/Samples/DialogueChoiceDemo/Resources/DialogueSystem/Graphs/Dialogue Graph 1.asset @@ -574,7 +574,6 @@ MonoBehaviour: - {fileID: -6051422413199044520} - {fileID: -5885707281620676963} - {fileID: 2428574908935260580} - - {fileID: 805789522290095862} SkippableDialogue: 0 _startNode: {fileID: -1822135301059774123} _conditions: [] @@ -599,81 +598,6 @@ MonoBehaviour: keys: [] values: [] IsTrue: 0 ---- !u!114 &805789522290095862 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0e5e901d523a4dce81016208dff46900, type: 3} - m_Name: Dialogue Choice - m_EditorClassIdentifier: - graph: {fileID: 11400000} - position: {x: -536, y: 1528} - ports: - keys: - - ParentChoice - - Exit - - Events - values: - - _fieldName: ParentChoice - _node: {fileID: 805789522290095862} - _typeQualifiedName: Studio23.SS2.DialogueSystem.Data.DialogueChoicesNode, com.studio23.ss2.dialoguesystem, - Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - connections: - - fieldName: ForceExitChoice - node: {fileID: 8927815714544073783} - reroutePoints: [] - _direction: 0 - _connectionType: 0 - _typeConstraint: 0 - _dynamic: 0 - - _fieldName: Exit - _node: {fileID: 805789522290095862} - _typeQualifiedName: Studio23.SS2.DialogueSystem.Data.DialogueLineNodeBase, - com.studio23.ss2.dialoguesystem, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - connections: [] - _direction: 1 - _connectionType: 1 - _typeConstraint: 2 - _dynamic: 0 - - _fieldName: Events - _node: {fileID: 805789522290095862} - _typeQualifiedName: Studio23.SS2.DialogueSystem.Data.EventNodeBase, com.studio23.ss2.dialoguesystem, - Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - connections: [] - _direction: 1 - _connectionType: 0 - _typeConstraint: 3 - _dynamic: 0 - DialogueLocalizedString: - m_TableReference: - m_TableCollectionName: GUID:2fefaa175576a0e48bf5b28cb5260137 - m_TableEntryReference: - m_KeyId: 60536405610639360 - m_Key: - m_FallbackState: 0 - m_WaitForCompletion: 0 - m_LocalVariables: [] - SpeakerData: - Character: {fileID: 0} - Expression: {fileID: 0} - FMODEvent: - Exit: {fileID: 0} - Events: {fileID: 0} - ParentChoice: {fileID: 0} - _conditions: - - rid: 4806151239593623552 - references: - version: 2 - RefIds: - - rid: 4806151239593623552 - type: {class: TestBoolNodeInteraction, ns: , asm: Assembly-CSharp} - data: - BoolNode: {fileID: 401710227361937087} --- !u!114 &1247732052999767825 MonoBehaviour: m_ObjectHideFlags: 0 @@ -1204,10 +1128,7 @@ MonoBehaviour: _node: {fileID: 8927815714544073783} _typeQualifiedName: Studio23.SS2.DialogueSystem.Data.DialogueChoicesNode, com.studio23.ss2.dialoguesystem, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null - connections: - - fieldName: ParentChoice - node: {fileID: 805789522290095862} - reroutePoints: [] + connections: [] _direction: 1 _connectionType: 0 _typeConstraint: 0