Skip to content

Commit

Permalink
feat(graph nodes): nested graph playback now available
Browse files Browse the repository at this point in the history
Add a nested graph reference and it will play until complete. Then automatically return to the
parent graph that played it by running the out connection (if any)
  • Loading branch information
ashblue committed Jan 29, 2020
1 parent 854e47a commit ea1a23a
Show file tree
Hide file tree
Showing 14 changed files with 229 additions and 39 deletions.
3 changes: 3 additions & 0 deletions Assembly-CSharp.csproj.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

114 changes: 79 additions & 35 deletions Assets/Examples/BasicConversation/ExampleConversation.asset
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ MonoBehaviour:
_uniqueId: 9b8bf58c-0906-4ca9-a722-d589abfb87c3
rect:
serializedVersion: 2
x: 50693
y: 50161
x: 50700
y: 50156
width: 200
height: 187
height: 205
nodeTitle:
children: []
conditions: []
Expand All @@ -188,6 +188,7 @@ MonoBehaviour:
- {fileID: -6868820908879997394}
- {fileID: -2199788058648552871}
- {fileID: -230701956770334952}
- {fileID: 5960690670116952456}
actor: {fileID: 11400000, guid: aebb863e25cae0a4495c09b6a617ecf6, type: 2}
dialogue: Not great. We only have enough resources to provide relief for one group.
Can't save them all.
Expand Down Expand Up @@ -219,33 +220,6 @@ MonoBehaviour:
choices: []
actor: {fileID: 11400000, guid: aebb863e25cae0a4495c09b6a617ecf6, type: 2}
dialogue: We won't last more than a few days if we're lucky.
--- !u!114 &-5749017562080709619
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: 9f157564dbc846468ec0ac2b6f7d545e, type: 3}
m_Name: Dialogue
m_EditorClassIdentifier:
_uniqueId: 00d2804b-622a-4c1e-a2f9-13124afa8815
rect:
serializedVersion: 2
x: 50215
y: 50345
width: 200
height: 133
nodeTitle:
children: []
conditions: []
enterActions: []
exitActions: []
choices: []
actor: {fileID: 11400000, guid: aebb863e25cae0a4495c09b6a617ecf6, type: 2}
dialogue: Conversation deviated as expected.
--- !u!114 &-5697671711981343180
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -420,6 +394,32 @@ MonoBehaviour:
choices: []
actor: {fileID: 11400000, guid: aebb863e25cae0a4495c09b6a617ecf6, type: 2}
dialogue: All the supplies are gone. Destroyed by the attack on the sea.
--- !u!114 &-1221359623688907011
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: e67818104cf34e2693b49316191c2be0, type: 3}
m_Name: Play Graph
m_EditorClassIdentifier:
_uniqueId: 35cbde59-cfc9-4fe5-b9d2-33cdd8a2b553
rect:
serializedVersion: 2
x: 50988
y: 50575
width: 200
height: 56
nodeTitle:
children:
- {fileID: 3721123120546049034}
conditions: []
enterActions: []
exitActions: []
dialogueGraph: {fileID: 11400000, guid: 3bc587ffa3a101e4591aa09b8280183c, type: 2}
--- !u!114 &-230701956770334952
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -466,9 +466,10 @@ MonoBehaviour:
- {fileID: -3436942782412272395}
- {fileID: -1807495471838374980}
- {fileID: -7347677369531188231}
- {fileID: -5749017562080709619}
- {fileID: -1221359623688907011}
- {fileID: 3721123120546049034}
root: {fileID: 426936237664981933}
scrollPosition: {x: 49917.676, y: 50013}
scrollPosition: {x: 50731.676, y: 50159}
--- !u!114 &373158185418196577
MonoBehaviour:
m_ObjectHideFlags: 0
Expand All @@ -484,8 +485,8 @@ MonoBehaviour:
_uniqueId: d8b91533-197e-475b-a98f-2d8451fba244
rect:
serializedVersion: 2
x: 50454
y: 50172
x: 50467
y: 50163
width: 200
height: 133
nodeTitle:
Expand Down Expand Up @@ -519,7 +520,6 @@ MonoBehaviour:
nodeTitle:
children:
- {fileID: 8793565678756733940}
- {fileID: -5749017562080709619}
conditions: []
enterActions: []
exitActions: []
Expand Down Expand Up @@ -552,6 +552,34 @@ MonoBehaviour:
actor: {fileID: 11400000, guid: d6a8e0fd1eb801d4ca00320f6b2e9e8b, type: 2}
dialogue: My people have suffered more than any other in this war. Please see that
the elves are taken care of first.
--- !u!114 &3721123120546049034
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: 9f157564dbc846468ec0ac2b6f7d545e, type: 3}
m_Name: Dialogue
m_EditorClassIdentifier:
_uniqueId: f1937fd0-ddc0-4791-a967-64bfd733c095
rect:
serializedVersion: 2
x: 51229
y: 50544
width: 200
height: 133
nodeTitle:
children:
- {fileID: -6450186612614065154}
conditions: []
enterActions: []
exitActions: []
choices: []
actor: {fileID: 11400000, guid: d6a8e0fd1eb801d4ca00320f6b2e9e8b, type: 2}
dialogue: Sorry about that. How are things going again?
--- !u!114 &3777311768254997257
MonoBehaviour:
m_ObjectHideFlags: 1
Expand Down Expand Up @@ -629,6 +657,22 @@ MonoBehaviour:
children:
- {fileID: -7347677369531188231}
_uniqueId: 0f90d98f-fdb0-4d11-80e1-0c07dafd771c
--- !u!114 &5960690670116952456
MonoBehaviour:
m_ObjectHideFlags: 1
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: fbb407621a43446dac370b409a9ddc29, type: 3}
m_Name: Choice
m_EditorClassIdentifier:
text: Tangent
children:
- {fileID: -1221359623688907011}
_uniqueId: b6639707-3558-459c-b2e0-01ebc3bc951b
--- !u!114 &6784819468853313292
MonoBehaviour:
m_ObjectHideFlags: 0
Expand Down
100 changes: 100 additions & 0 deletions Assets/Examples/BasicConversation/ExampleNestedDialogue.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &-911914220444734066
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: b2d8d0566afe4d5fa9596c80df966df6, type: 3}
m_Name: Root
m_EditorClassIdentifier:
_uniqueId: f82d26a6-f5f7-449b-95ff-83783674c75e
rect:
serializedVersion: 2
x: 50050
y: 50200
width: 100
height: 55
nodeTitle:
children:
- {fileID: 3628622021116016526}
conditions: []
enterActions: []
exitActions: []
--- !u!114 &11400000
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: b35851dfd8754a74b333944d50d05bbd, type: 3}
m_Name: ExampleNestedDialogue
m_EditorClassIdentifier:
_nodes:
- {fileID: -911914220444734066}
- {fileID: 3628622021116016526}
- {fileID: 6362165008871370358}
root: {fileID: -911914220444734066}
scrollPosition: {x: 49852.5, y: 49931.5}
--- !u!114 &3628622021116016526
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: 9f157564dbc846468ec0ac2b6f7d545e, type: 3}
m_Name: Dialogue
m_EditorClassIdentifier:
_uniqueId: b86fca30-5c32-41d4-a708-bb796c3a3352
rect:
serializedVersion: 2
x: 50221
y: 50156
width: 200
height: 133
nodeTitle:
children:
- {fileID: 6362165008871370358}
conditions: []
enterActions: []
exitActions: []
choices: []
actor: {fileID: 11400000, guid: d6a8e0fd1eb801d4ca00320f6b2e9e8b, type: 2}
dialogue: When is this all going to end.
--- !u!114 &6362165008871370358
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: 9f157564dbc846468ec0ac2b6f7d545e, type: 3}
m_Name: Dialogue
m_EditorClassIdentifier:
_uniqueId: a4dc06ef-6639-4433-8670-365f1db91322
rect:
serializedVersion: 2
x: 50474
y: 50157
width: 200
height: 133
nodeTitle:
children: []
conditions: []
enterActions: []
exitActions: []
choices: []
actor: {fileID: 11400000, guid: d6a8e0fd1eb801d4ca00320f6b2e9e8b, type: 2}
dialogue: Decision after decision, death after death. What's the point anymore?

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Assets/Examples/ExampleCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace CleverCrow.Fluid.Dialogues.Examples {
[CreateMenu("Example/Condition")]
public class ExampleCondition : ConditionDataBase {
[SerializeField]
private bool _isValid;
private bool _isValid = false;

public override bool OnGetIsValid (INode parent) {
Debug.Log($"Example Condition: Returned {_isValid} for node {parent.UniqueId}");
Expand Down
17 changes: 17 additions & 0 deletions Assets/com.fluid.dialogue/Editor/NodeEditors/PlayGraphEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using CleverCrow.Fluid.Dialogues.Nodes;
using UnityEditor;
using UnityEngine;

namespace CleverCrow.Fluid.Dialogues.Editors.NodeDisplays {
[NodeType(typeof(NodePlayGraphData))]
public class PlayGraphEditor : NodeEditorBase {
protected override Color NodeColor { get; } = new Color(0.75f, 0.52f, 0f);
protected override float NodeWidth { get; } = 200;

protected override void OnPrintBody (Event e) {
serializedObject.Update();
EditorGUILayout.PropertyField(serializedObject.FindProperty("dialogueGraph"), GUIContent.none);
serializedObject.ApplyModifiedProperties();
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
using CleverCrow.Fluid.Dialogues.Nodes.PlayGraph;

namespace CleverCrow.Fluid.Dialogues.Nodes {
[CreateMenu("Play Graph")]
public class NodePlayGraphData : NodeDataBase {
public DialogueGraph dialogueGraph;

protected override string DefaultName => "Play Graph";

public override INode GetRuntime (IGraph graphRuntime, IDialogueController dialogue) {
return new NodePlayGraph(
graphRuntime,
Expand Down
2 changes: 1 addition & 1 deletion Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"com.unity.analytics": "3.3.2",
"com.unity.collab-proxy": "1.2.16",
"com.unity.ext.nunit": "1.0.0",
"com.unity.ide.rider": "1.1.0",
"com.unity.ide.rider": "1.2.1",
"com.unity.ide.vscode": "1.1.3",
"com.unity.package-manager-ui": "2.2.0",
"com.unity.purchasing": "2.0.6",
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2019.2.17f1
m_EditorVersionWithRevision: 2019.2.17f1 (8e603399ca02)
m_EditorVersion: 2019.2.19f1
m_EditorVersionWithRevision: 2019.2.19f1 (929ab4d01772)
3 changes: 3 additions & 0 deletions com.fluid.dialogue.Editor.Tests.csproj.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions com.fluid.dialogue.Editor.csproj.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions com.fluid.dialogue.csproj.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ea1a23a

Please sign in to comment.