Skip to content

Commit

Permalink
Merge pull request #11 from Studio-23-xyz/dev
Browse files Browse the repository at this point in the history
Add per graph events
  • Loading branch information
BDeshiDev authored Jan 18, 2024
2 parents b862cef + 7d67492 commit 39c429d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public async UniTask PlayDialogue(DialogueGraph graph)
_curNode = _curNode.GetNextNode();
}

OnDialogueEnded?.Invoke(_currentGraph);
_currentGraph.HandleDialogueEnded();
OnDialogueEnded?.Invoke(_currentGraph);

Debug.Log($"{graph} dialogue completed");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class DialogueGraph : NodeGraph
//certain nodes need a callback to initialize when hitting playmode/at start in build
//ex: condition nodes
private bool _initialized = false;
public event Action<DialogueGraph> OnDialogueStarted;
public event Action<DialogueGraph> OnDialogueEnded;

public void Initialize()
{
Expand Down Expand Up @@ -85,6 +87,12 @@ public void HandleDialogueStarted()
//otherwise we can't have repeating dialogue
FindStartNode();
_currentNode = _startNode;
OnDialogueStarted?.Invoke(this);
}

public void HandleDialogueEnded()
{
OnDialogueEnded?.Invoke(this);
}

private void FindStartNode()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ public virtual void InvokePostPlayEvents()
Debug.LogWarning($"{this} Events port no {i} is connected to {eventNodeConnection.node} but it's not an event node");
}
}
else
{
Debug.LogWarning($"{this} Events port no {i} is connected to {eventNodeConnection} but connection null");
}
}
}

Expand Down

0 comments on commit 39c429d

Please sign in to comment.