Skip to content

Commit

Permalink
Dialogue line chain skip added
Browse files Browse the repository at this point in the history
  • Loading branch information
BDeshiDev committed Aug 7, 2024
1 parent 6d9e6c2 commit d0fc8d9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ public class DialogueSystem : MonoBehaviour
[Header("Execution Data")]
[SerializeField] private DialogueNodeBase _curNode;

[FormerlySerializedAs("_skipDialogueLines")]
[Header("Skip")]
[SerializeField] private bool _skipToEndOfDialogueChain = true;
[SerializeField] private bool _resetSkipAfterChoice = true;
[SerializeField] private bool _isSkipActive = false;
[SerializeField] private bool _shouldShowLineWhenSkipped = true;
Expand Down Expand Up @@ -101,19 +103,40 @@ public async UniTask PlayDialogue(DialogueGraph graph, DialogueNodeBase startNod
_curNode = startNode;
_currentGraph.HandleDialogueStarted(startNode);
_isSkipActive = false;
_skipToEndOfDialogueChain = false;

OnDialogueStarted?.Invoke(_currentGraph, startNode);
while (_curNode != null)
{
if(_skipToEndOfDialogueChain)
{
if (_curNode is DialogueLineNodeBase dialogueLineNodeBase)
{
var nextNode = _curNode.GetNextNode();
Debug.Log($"Skip {_curNode} -> {(nextNode == null?"null": nextNode)}");
_curNode = nextNode;
continue;
}
else
{
_skipToEndOfDialogueChain = false;
}
}

Debug.Log("Play = " + _curNode, _curNode);
await _curNode.Play();

_curNode = _curNode.GetNextNode();
}

_currentGraph.HandleDialogueEnded();
OnDialogueEnded?.Invoke(_currentGraph, startNode);
}
[ContextMenu("SkipTOEnd")]
public void SkipToEndOfDialogueChain()
{
_skipToEndOfDialogueChain = true;
_curNode.HandleDialogueAdvance();
}

public void AdvanceDialogue()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ MonoBehaviour:
- fieldName: Exit
node: {fileID: -6227106332496004794}
reroutePoints: []
- fieldName: Exit
node: {fileID: -6489933969369151722}
reroutePoints: []
_direction: 0
_connectionType: 0
_typeConstraint: 0
Expand Down Expand Up @@ -191,7 +194,10 @@ MonoBehaviour:
_node: {fileID: -6489933969369151722}
_typeQualifiedName: Studio23.SS2.DialogueSystem.Data.DialogueLineNodeBase,
com.studio23.ss2.dialoguesystem, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
connections: []
connections:
- fieldName: Entry
node: {fileID: -7717196668193487428}
reroutePoints: []
_direction: 1
_connectionType: 1
_typeConstraint: 2
Expand Down

0 comments on commit d0fc8d9

Please sign in to comment.