From e6cb55975cb7753ff2e0d2dc2b08dbbaf338e933 Mon Sep 17 00:00:00 2001 From: Michal Pikulski Date: Mon, 29 Sep 2025 00:15:58 +0200 Subject: [PATCH] Mostly working, double invocation of dialogue progression --- Assets/Dialogue/TestAssDialogue.dialoguegraph | 552 +++++++++++++++++- .../Editor/Dialogue/DialogueGraphImporter.cs | 16 + Assets/Editor/Dialogue/DialogueNodes.cs | 13 + .../Scenes/Levels/AppleHillsOverworld.unity | 4 + Assets/Scripts/Core/ItemManager.cs | 36 ++ Assets/Scripts/Dialogue/DialogueComponent.cs | 80 ++- .../Scripts/Dialogue/RuntimeDialogueGraph.cs | 2 + Assets/Scripts/Interactions/ItemSlot.cs | 2 + Assets/Scripts/Interactions/Pickup.cs | 28 + 9 files changed, 717 insertions(+), 16 deletions(-) diff --git a/Assets/Dialogue/TestAssDialogue.dialoguegraph b/Assets/Dialogue/TestAssDialogue.dialoguegraph index d7d6bb08..b93f9efa 100644 --- a/Assets/Dialogue/TestAssDialogue.dialoguegraph +++ b/Assets/Dialogue/TestAssDialogue.dialoguegraph @@ -35,11 +35,19 @@ MonoBehaviour: - rid: 1226592702090707076 - rid: 1226592702090707083 - rid: 1226592702090707099 + - rid: 1226592736610877523 + - rid: 1226592736610877537 + - rid: 1226592736610877546 + - rid: 1226592736610877567 m_GraphWireModels: - rid: 1226592702090707073 - rid: 1226592702090707082 - rid: 1226592702090707090 - rid: 1226592702090707105 + - rid: 1226592736610877530 + - rid: 1226592736610877544 + - rid: 1226592736610877561 + - rid: 1226592736610877573 m_GraphStickyNoteModels: [] m_GraphPlacematModels: [] m_GraphVariableModels: @@ -51,9 +59,9 @@ MonoBehaviour: m_LastKnownBounds: serializedVersion: 2 x: 114 - y: 142 - width: 1607 - height: 264 + y: 7 + width: 3396 + height: 399 m_GraphElementMetaData: - m_Guid: m_Value0: 15250916379536742066 @@ -135,6 +143,70 @@ MonoBehaviour: Hash: 9add04e2cf7a6fe9863821265f060194 m_Category: 2 m_Index: 3 + - m_Guid: + m_Value0: 11457935833154969843 + m_Value1: 16747455140762270951 + m_HashGuid: + serializedVersion: 2 + Hash: f3e06bfaeec3029fe7bcecfcb7e96ae8 + m_Category: 0 + m_Index: 5 + - m_Guid: + m_Value0: 501849774702942952 + m_Value1: 8676393820580818817 + m_HashGuid: + serializedVersion: 2 + Hash: e85ac70fb6edf606812f1dd735be6878 + m_Category: 2 + m_Index: 4 + - m_Guid: + m_Value0: 17256973715067882500 + m_Value1: 10728149715493522551 + m_HashGuid: + serializedVersion: 2 + Hash: 04ccdf9829167def770c3379530be294 + m_Category: 0 + m_Index: 6 + - m_Guid: + m_Value0: 3030296286289964743 + m_Value1: 18075108795397583455 + m_HashGuid: + serializedVersion: 2 + Hash: c7ae7fcc6ac60d2a5f3236f2aeafd7fa + m_Category: 2 + m_Index: 5 + - m_Guid: + m_Value0: 11902820604143563113 + m_Value1: 6699317486178747255 + m_HashGuid: + serializedVersion: 2 + Hash: 69712d8f46502fa577433f59c2c1f85c + m_Category: 0 + m_Index: 7 + - m_Guid: + m_Value0: 17109984303824179380 + m_Value1: 18426165488533823493 + m_HashGuid: + serializedVersion: 2 + Hash: b410f35d12e072ed05e09ec4e2e3b6ff + m_Category: 2 + m_Index: 6 + - m_Guid: + m_Value0: 15697219088638459537 + m_Value1: 14915215102272919892 + m_HashGuid: + serializedVersion: 2 + Hash: 91bec6fb97b9d7d954d9847f1c7dfdce + m_Category: 0 + m_Index: 8 + - m_Guid: + m_Value0: 15649196733664619169 + m_Value1: 156168040659544779 + m_HashGuid: + serializedVersion: 2 + Hash: a16a482a841d2dd9cbeac76c01d22a02 + m_Category: 2 + m_Index: 7 m_EntryPoint: rid: 1226592702090707069 m_Graph: @@ -618,3 +690,477 @@ MonoBehaviour: type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: Now, go on, chop it! + - rid: 1226592736610877523 + type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} + data: + m_Guid: + m_Value0: 11457935833154969843 + m_Value1: 16747455140762270951 + m_HashGuid: + serializedVersion: 2 + Hash: f3e06bfaeec3029fe7bcecfcb7e96ae8 + m_Version: 2 + m_Position: {x: 1763.6455, y: 116.19321} + m_Title: + m_Tooltip: + m_NodePreviewModel: + rid: -2 + m_State: 0 + m_InputConstantsById: + m_KeyList: + - __option_DialogueLineType + - __option_NoLines + - RequiredResultItem + - DefaultDialogueLine + - LoopThroughDefaultLines + m_ValueList: + - rid: 1226592736610877524 + - rid: 1226592736610877525 + - rid: 1226592736610877526 + - rid: 1226592736610877527 + - rid: 1226592736610877528 + m_InputPortInfos: + expandedPortsById: + m_KeyList: [] + m_ValueList: + m_OutputPortInfos: + expandedPortsById: + m_KeyList: [] + m_ValueList: + m_Collapsed: 0 + m_CurrentModeIndex: 0 + m_ElementColor: + m_Color: {r: 0, g: 0, b: 0, a: 0} + m_HasUserColor: 0 + m_Node: + rid: 1226592736610877529 + - rid: 1226592736610877524 + type: {class: EnumConstant, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + m_Value: 0 + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - rid: 1226592736610877525 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 1 + - rid: 1226592736610877526 + type: {class: 'Constant`1[[PickupItemData, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: {fileID: 11400000, guid: ecae2d83a5ab2a047a2733ebff607380, type: 2} + - rid: 1226592736610877527 + type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: I need my meat :( + - rid: 1226592736610877528 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 1 + - rid: 1226592736610877529 + type: {class: WaitOnCombination, ns: Editor.Dialogue, asm: AppleHillsEditor} + data: + - rid: 1226592736610877530 + type: {class: WireModel, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Guid: + m_Value0: 501849774702942952 + m_Value1: 8676393820580818817 + m_HashGuid: + serializedVersion: 2 + Hash: e85ac70fb6edf606812f1dd735be6878 + m_Version: 2 + m_FromPortReference: + m_NodeModelGuid: + m_Value0: 8076963752207217979 + m_Value1: 14098062078374966352 + m_NodeModelHashGuid: + serializedVersion: 2 + Hash: 3b750432bd23177050f4f1fac360a6c3 + m_UniqueId: out + m_PortDirection: 2 + m_PortOrientation: 0 + m_Title: out + m_ToPortReference: + m_NodeModelGuid: + m_Value0: 11457935833154969843 + m_Value1: 16747455140762270951 + m_NodeModelHashGuid: + serializedVersion: 2 + Hash: f3e06bfaeec3029fe7bcecfcb7e96ae8 + m_UniqueId: in + m_PortDirection: 1 + m_PortOrientation: 0 + m_Title: in + - rid: 1226592736610877537 + type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} + data: + m_Guid: + m_Value0: 17256973715067882500 + m_Value1: 10728149715493522551 + m_HashGuid: + serializedVersion: 2 + Hash: 04ccdf9829167def770c3379530be294 + m_Version: 2 + m_Position: {x: 2258.8298, y: 115.05748} + m_Title: DialogueNode + m_Tooltip: + m_NodePreviewModel: + rid: -2 + m_State: 0 + m_InputConstantsById: + m_KeyList: + - __option_DialogueLineType + - __option_NoLines + - LoopThroughDefaultLines + - DefaultDialogueLine + m_ValueList: + - rid: 1226592736610877538 + - rid: 1226592736610877539 + - rid: 1226592736610877540 + - rid: 1226592736610877545 + m_InputPortInfos: + expandedPortsById: + m_KeyList: [] + m_ValueList: + m_OutputPortInfos: + expandedPortsById: + m_KeyList: [] + m_ValueList: + m_Collapsed: 0 + m_CurrentModeIndex: 0 + m_ElementColor: + m_Color: {r: 0, g: 0, b: 0, a: 0} + m_HasUserColor: 0 + m_Node: + rid: 1226592736610877543 + - rid: 1226592736610877538 + type: {class: EnumConstant, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + m_Value: 0 + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - rid: 1226592736610877539 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 1 + - rid: 1226592736610877540 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 0 + - rid: 1226592736610877543 + type: {class: DialogueNode, ns: Editor.Dialogue, asm: AppleHillsEditor} + data: + - rid: 1226592736610877544 + type: {class: WireModel, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Guid: + m_Value0: 3030296286289964743 + m_Value1: 18075108795397583455 + m_HashGuid: + serializedVersion: 2 + Hash: c7ae7fcc6ac60d2a5f3236f2aeafd7fa + m_Version: 2 + m_FromPortReference: + m_NodeModelGuid: + m_Value0: 11457935833154969843 + m_Value1: 16747455140762270951 + m_NodeModelHashGuid: + serializedVersion: 2 + Hash: f3e06bfaeec3029fe7bcecfcb7e96ae8 + m_UniqueId: out + m_PortDirection: 2 + m_PortOrientation: 0 + m_Title: out + m_ToPortReference: + m_NodeModelGuid: + m_Value0: 17256973715067882500 + m_Value1: 10728149715493522551 + m_NodeModelHashGuid: + serializedVersion: 2 + Hash: 04ccdf9829167def770c3379530be294 + m_UniqueId: in + m_PortDirection: 1 + m_PortOrientation: 0 + m_Title: in + - rid: 1226592736610877545 + type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: Nice, that's the stuff! Now go cook it for me! + - rid: 1226592736610877546 + type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} + data: + m_Guid: + m_Value0: 11902820604143563113 + m_Value1: 6699317486178747255 + m_HashGuid: + serializedVersion: 2 + Hash: 69712d8f46502fa577433f59c2c1f85c + m_Version: 2 + m_Position: {x: 2650.1987, y: 6.86882} + m_Title: + m_Tooltip: + m_NodePreviewModel: + rid: -2 + m_State: 0 + m_InputConstantsById: + m_KeyList: + - __option_DialogueLineType + - __option_NoLines + - __option_IncorrectItemDialogueLineType + - __option_IncorrectItemNoLines + - __option_ForbiddenItemDialogueLineType + - __option_ForbiddenItemNoLines + - RequiredSlot + - DefaultDialogueLine + - LoopThroughDefaultLines + - IncorrectItemDialogueLine + - LoopThroughIncorrectItemLines + - ForbiddenItemDialogueLine + - LoopThroughForbiddenItemLines + m_ValueList: + - rid: 1226592736610877547 + - rid: 1226592736610877548 + - rid: 1226592736610877549 + - rid: 1226592736610877550 + - rid: 1226592736610877551 + - rid: 1226592736610877552 + - rid: 1226592736610877553 + - rid: 1226592736610877554 + - rid: 1226592736610877555 + - rid: 1226592736610877556 + - rid: 1226592736610877557 + - rid: 1226592736610877558 + - rid: 1226592736610877559 + m_InputPortInfos: + expandedPortsById: + m_KeyList: [] + m_ValueList: + m_OutputPortInfos: + expandedPortsById: + m_KeyList: [] + m_ValueList: + m_Collapsed: 0 + m_CurrentModeIndex: 0 + m_ElementColor: + m_Color: {r: 0, g: 0, b: 0, a: 0} + m_HasUserColor: 0 + m_Node: + rid: 1226592736610877560 + - rid: 1226592736610877547 + type: {class: EnumConstant, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + m_Value: 0 + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - rid: 1226592736610877548 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 1 + - rid: 1226592736610877549 + type: {class: EnumConstant, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + m_Value: 0 + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - rid: 1226592736610877550 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 1 + - rid: 1226592736610877551 + type: {class: EnumConstant, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + m_Value: 0 + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - rid: 1226592736610877552 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 1 + - rid: 1226592736610877553 + type: {class: 'Constant`1[[PickupItemData, AppleHillsScripts]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: {fileID: 11400000, guid: e0fad48a84a6b6346ac17c84bc512500, type: 2} + - rid: 1226592736610877554 + type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: Cmon, it's not gonna cook itself! + - rid: 1226592736610877555 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 1 + - rid: 1226592736610877556 + type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: What do you think you're cooking?! + - rid: 1226592736610877557 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 1 + - rid: 1226592736610877558 + type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + - rid: 1226592736610877559 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 0 + - rid: 1226592736610877560 + type: {class: WaitOnSlot, ns: Editor.Dialogue, asm: AppleHillsEditor} + data: + - rid: 1226592736610877561 + type: {class: WireModel, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Guid: + m_Value0: 17109984303824179380 + m_Value1: 18426165488533823493 + m_HashGuid: + serializedVersion: 2 + Hash: b410f35d12e072ed05e09ec4e2e3b6ff + m_Version: 2 + m_FromPortReference: + m_NodeModelGuid: + m_Value0: 17256973715067882500 + m_Value1: 10728149715493522551 + m_NodeModelHashGuid: + serializedVersion: 2 + Hash: 04ccdf9829167def770c3379530be294 + m_UniqueId: out + m_PortDirection: 2 + m_PortOrientation: 0 + m_Title: out + m_ToPortReference: + m_NodeModelGuid: + m_Value0: 11902820604143563113 + m_Value1: 6699317486178747255 + m_NodeModelHashGuid: + serializedVersion: 2 + Hash: 69712d8f46502fa577433f59c2c1f85c + m_UniqueId: in + m_PortDirection: 1 + m_PortOrientation: 0 + m_Title: in + - rid: 1226592736610877567 + type: {class: UserNodeModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} + data: + m_Guid: + m_Value0: 15697219088638459537 + m_Value1: 14915215102272919892 + m_HashGuid: + serializedVersion: 2 + Hash: 91bec6fb97b9d7d954d9847f1c7dfdce + m_Version: 2 + m_Position: {x: 3164.9407, y: 88.21074} + m_Title: DialogueNode + m_Tooltip: + m_NodePreviewModel: + rid: -2 + m_State: 0 + m_InputConstantsById: + m_KeyList: + - __option_DialogueLineType + - __option_NoLines + - LoopThroughDefaultLines + - DefaultDialogueLine + m_ValueList: + - rid: 1226592736610877568 + - rid: 1226592736610877569 + - rid: 1226592736610877570 + - rid: 1226592736610877571 + m_InputPortInfos: + expandedPortsById: + m_KeyList: [] + m_ValueList: + m_OutputPortInfos: + expandedPortsById: + m_KeyList: [] + m_ValueList: + m_Collapsed: 0 + m_CurrentModeIndex: 0 + m_ElementColor: + m_Color: {r: 0, g: 0, b: 0, a: 0} + m_HasUserColor: 0 + m_Node: + rid: 1226592736610877572 + - rid: 1226592736610877568 + type: {class: EnumConstant, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + m_Value: 0 + m_EnumType: + m_Identification: Editor.Dialogue.DialogueType, AppleHillsEditor, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + - rid: 1226592736610877569 + type: {class: 'Constant`1[[System.Int32, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 1 + - rid: 1226592736610877570 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 0 + - rid: 1226592736610877571 + type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: Sweat, delicions steak! + - rid: 1226592736610877572 + type: {class: DialogueNode, ns: Editor.Dialogue, asm: AppleHillsEditor} + data: + - rid: 1226592736610877573 + type: {class: WireModel, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Guid: + m_Value0: 15649196733664619169 + m_Value1: 156168040659544779 + m_HashGuid: + serializedVersion: 2 + Hash: a16a482a841d2dd9cbeac76c01d22a02 + m_Version: 2 + m_FromPortReference: + m_NodeModelGuid: + m_Value0: 11902820604143563113 + m_Value1: 6699317486178747255 + m_NodeModelHashGuid: + serializedVersion: 2 + Hash: 69712d8f46502fa577433f59c2c1f85c + m_UniqueId: out + m_PortDirection: 2 + m_PortOrientation: 0 + m_Title: out + m_ToPortReference: + m_NodeModelGuid: + m_Value0: 15697219088638459537 + m_Value1: 14915215102272919892 + m_NodeModelHashGuid: + serializedVersion: 2 + Hash: 91bec6fb97b9d7d954d9847f1c7dfdce + m_UniqueId: in + m_PortDirection: 1 + m_PortOrientation: 0 + m_Title: in diff --git a/Assets/Editor/Dialogue/DialogueGraphImporter.cs b/Assets/Editor/Dialogue/DialogueGraphImporter.cs index 28f95c01..9255a306 100644 --- a/Assets/Editor/Dialogue/DialogueGraphImporter.cs +++ b/Assets/Editor/Dialogue/DialogueGraphImporter.cs @@ -63,6 +63,10 @@ namespace Editor.Dialogue { ProcessSlotNode(slotNode, runtimeNode); } + else if (iNode is WaitOnCombination combinationNode) + { + ProcessCombinationNode(combinationNode, runtimeNode); + } } else if (iNode is EndNode) { @@ -226,6 +230,18 @@ namespace Editor.Dialogue GetPortValue(node.GetInputPortByName("LoopThroughForbiddenItemLines")); } + // Add new method to process combination nodes + private void ProcessCombinationNode(WaitOnCombination node, RuntimeDialogueNode runtimeNode) + { + runtimeNode.nodeType = RuntimeDialogueNodeType.WaitOnCombination; + + var resultItem = GetPortValue(node.GetInputPortByName("RequiredResultItem")); + if (resultItem != null) + { + runtimeNode.combinationResultItemID = resultItem.itemId; + } + } + private T GetPortValue(IPort port) { if (port == null) return default(T); diff --git a/Assets/Editor/Dialogue/DialogueNodes.cs b/Assets/Editor/Dialogue/DialogueNodes.cs index 8a4a501c..adb4f723 100644 --- a/Assets/Editor/Dialogue/DialogueNodes.cs +++ b/Assets/Editor/Dialogue/DialogueNodes.cs @@ -193,4 +193,17 @@ namespace Editor.Dialogue context.AddInputPort($"{LoopThroughForbiddenItemLinesOptionName}").WithDisplayName("Loop Through Forbidden Item Lines?").Build(); } } + + [Serializable] + public class WaitOnCombination : DialogueNode + { + const string RequiredResultItemOptionName = "RequiredResultItem"; + + protected override void OnDefinePorts(IPortDefinitionContext context) + { + context.AddInputPort(RequiredResultItemOptionName).WithDisplayName("Required Result Item").Build(); + + base.OnDefinePorts(context); + } + } } \ No newline at end of file diff --git a/Assets/Scenes/Levels/AppleHillsOverworld.unity b/Assets/Scenes/Levels/AppleHillsOverworld.unity index 4b4f9aae..8020512f 100644 --- a/Assets/Scenes/Levels/AppleHillsOverworld.unity +++ b/Assets/Scenes/Levels/AppleHillsOverworld.unity @@ -977,6 +977,8 @@ MonoBehaviour: typingSoundSource: {fileID: 0} typingSoundFrequency: 3 useRichText: 1 + dialogueDisplayTime: 1.5 + dialoguePromptText: . . . --- !u!4 &754397347 stripped Transform: m_CorrespondingSourceObject: {fileID: 2844046668579196942, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} @@ -1739,6 +1741,8 @@ MonoBehaviour: typingSoundSource: {fileID: 0} typingSoundFrequency: 3 useRichText: 1 + dialogueDisplayTime: 1.5 + dialoguePromptText: . . . --- !u!4 &1309036670 stripped Transform: m_CorrespondingSourceObject: {fileID: 3823830588451517910, guid: 301b4e0735896334f8f6fb9a68a7e419, type: 3} diff --git a/Assets/Scripts/Core/ItemManager.cs b/Assets/Scripts/Core/ItemManager.cs index 2577f745..e00162dc 100644 --- a/Assets/Scripts/Core/ItemManager.cs +++ b/Assets/Scripts/Core/ItemManager.cs @@ -34,6 +34,7 @@ namespace Core private readonly HashSet _pickups = new HashSet(); private readonly HashSet _itemSlots = new HashSet(); + private readonly HashSet _itemsCreatedThroughCombination = new HashSet(); // Central events forwarded from registered pickups/slots // Broadcasts when any registered pickup was picked up (passes the picked item data) @@ -43,6 +44,10 @@ namespace Core // Args: slot's itemData (the slot definition), then the slotted item data public event Action OnCorrectItemSlotted; + // Broadcasts when any two items are successfully combined + // Args: first item data, second item data, result item data + public event Action OnItemsCombined; + void Awake() { _instance = this; @@ -86,7 +91,10 @@ namespace Core foreach (var p in pickupsCopy) { if (p != null) + { p.OnItemPickedUp -= Pickup_OnItemPickedUp; + p.OnItemsCombined -= Pickup_OnItemsCombined; + } } _pickups.Clear(); @@ -99,9 +107,13 @@ namespace Core } _itemSlots.Clear(); + // Clear item tracking + _itemsCreatedThroughCombination.Clear(); + // Clear manager-level event subscribers OnItemPickedUp = null; OnCorrectItemSlotted = null; + OnItemsCombined = null; } public void RegisterPickup(Pickup pickup) @@ -111,6 +123,7 @@ namespace Core if (_pickups.Add(pickup)) { pickup.OnItemPickedUp += Pickup_OnItemPickedUp; + pickup.OnItemsCombined += Pickup_OnItemsCombined; } } @@ -120,6 +133,7 @@ namespace Core if (_pickups.Remove(pickup)) { pickup.OnItemPickedUp -= Pickup_OnItemPickedUp; + pickup.OnItemsCombined -= Pickup_OnItemsCombined; } } @@ -153,6 +167,28 @@ namespace Core OnCorrectItemSlotted?.Invoke(slotData, slottedItem); } + // Handler that forwards item combination events + private void Pickup_OnItemsCombined(PickupItemData itemA, PickupItemData itemB, PickupItemData resultItem) + { + // Track the created item + if (resultItem != null) + { + _itemsCreatedThroughCombination.Add(resultItem.itemId); + } + + OnItemsCombined?.Invoke(itemA, itemB, resultItem); + } + + /// + /// Checks if a specific item has been created through item combination. + /// + /// The ID of the item to check. + /// True if the item has been created through combination, false otherwise. + public bool WasItemCreatedThroughCombination(string itemId) + { + return !string.IsNullOrEmpty(itemId) && _itemsCreatedThroughCombination.Contains(itemId); + } + /// /// Returns the current slot state for the given item data by searching registered slots. /// If the item is currently slotted in a slot, returns that slot's state; otherwise returns ItemSlotState.None. diff --git a/Assets/Scripts/Dialogue/DialogueComponent.cs b/Assets/Scripts/Dialogue/DialogueComponent.cs index f484b58b..fb20143b 100644 --- a/Assets/Scripts/Dialogue/DialogueComponent.cs +++ b/Assets/Scripts/Dialogue/DialogueComponent.cs @@ -36,6 +36,7 @@ namespace Dialogue { ItemManager.Instance.OnItemPickedUp += OnAnyItemPickedUp; ItemManager.Instance.OnCorrectItemSlotted += OnAnyItemSlotted; + ItemManager.Instance.OnItemsCombined += OnAnyItemsCombined; } speechBubble = GetComponentInChildren(); @@ -86,6 +87,7 @@ namespace Dialogue { ItemManager.Instance.OnItemPickedUp -= OnAnyItemPickedUp; ItemManager.Instance.OnCorrectItemSlotted -= OnAnyItemSlotted; + ItemManager.Instance.OnItemsCombined -= OnAnyItemsCombined; } } @@ -140,7 +142,7 @@ namespace Dialogue { currentLine = currentNode.dialogueLines[currentLineIndex]; } - + Debug.Log("Returning line: " + currentLine); // Return the current line return currentLine; } @@ -242,6 +244,15 @@ namespace Dialogue } break; + case RuntimeDialogueNodeType.WaitOnCombination: + // Check if the result item is already created through combination + if (IsResultItemCreated(currentNode.combinationResultItemID)) + { + // If it's already created, move past this node automatically + MoveToNextNode(); + } + break; + case RuntimeDialogueNodeType.End: // End node, complete the dialogue IsActive = false; @@ -269,8 +280,8 @@ namespace Dialogue MoveToNextNode(); // Notify any listeners about the dialogue change - string line = GetCurrentDialogueLine(); - OnDialogueChanged?.Invoke(line); + // string line = GetCurrentDialogueLine(); + // OnDialogueChanged?.Invoke(line); // Update bubble visibility after state change if (speechBubble != null) @@ -294,8 +305,8 @@ namespace Dialogue MoveToNextNode(); // Notify any listeners about the dialogue change - string line = GetCurrentDialogueLine(); - OnDialogueChanged?.Invoke(line); + // string line = GetCurrentDialogueLine(); + // OnDialogueChanged?.Invoke(line); // Update bubble visibility after state change if (speechBubble != null) @@ -305,14 +316,16 @@ namespace Dialogue } // Always check if any dialogue was unblocked by this pickup - if (speechBubble != null) - { - speechBubble.UpdatePromptVisibility(HasAnyLines()); - } + // if (speechBubble != null) + // { + // speechBubble.UpdatePromptVisibility(HasAnyLines()); + // } } private void OnAnyItemSlotted(PickupItemData slotDefinition, PickupItemData slottedItem) { + Debug.Log("[DialogueComponent] OnAnyItemSlotted"); + // Only react if we're active and waiting on a slot if (!IsActive || IsCompleted || currentNode == null || currentNode.nodeType != RuntimeDialogueNodeType.WaitOnSlot) @@ -325,8 +338,8 @@ namespace Dialogue MoveToNextNode(); // Notify any listeners about the dialogue change - string line = GetCurrentDialogueLine(); - OnDialogueChanged?.Invoke(line); + // string line = GetCurrentDialogueLine(); + // OnDialogueChanged?.Invoke(line); // Update bubble visibility after state change if (speechBubble != null) @@ -336,10 +349,41 @@ namespace Dialogue } // Always check if any dialogue was unblocked by this slotting - if (speechBubble != null) + // if (speechBubble != null) + // { + // speechBubble.UpdatePromptVisibility(HasAnyLines()); + // } + } + + private void OnAnyItemsCombined(PickupItemData itemA, PickupItemData itemB, PickupItemData resultItem) + { + // Only react if we're active and waiting on a combination + if (!IsActive || IsCompleted || currentNode == null || + currentNode.nodeType != RuntimeDialogueNodeType.WaitOnCombination) + return; + + // Check if this is the result item we're waiting for + if (resultItem.itemId == currentNode.combinationResultItemID) { - speechBubble.UpdatePromptVisibility(HasAnyLines()); + // Move to next node automatically when condition is met + MoveToNextNode(); + + // Notify any listeners about the dialogue change + // string line = GetCurrentDialogueLine(); + // OnDialogueChanged?.Invoke(line); + + // Update bubble visibility after state change + if (speechBubble != null) + { + speechBubble.UpdatePromptVisibility(HasAnyLines()); + } } + + // Always check if any dialogue was unblocked by this combination + // if (speechBubble != null) + // { + // speechBubble.UpdatePromptVisibility(HasAnyLines()); + // } } // Helper methods @@ -355,6 +399,8 @@ namespace Dialogue return !IsItemPickedUp(currentNode.pickupItemID); case RuntimeDialogueNodeType.WaitOnSlot: return !IsItemSlotted(currentNode.slotItemID); + case RuntimeDialogueNodeType.WaitOnCombination: + return !IsResultItemCreated(currentNode.combinationResultItemID); default: return false; } @@ -398,6 +444,14 @@ namespace Dialogue return false; } + private bool IsResultItemCreated(string resultItemId) + { + if (ItemManager.Instance == null) return false; + + // Use the ItemManager's tracking of items created through combination + return ItemManager.Instance.WasItemCreatedThroughCombination(resultItemId); + } + /// /// Checks if the dialogue component has any lines available to serve /// diff --git a/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs b/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs index 3b64e35a..51a1cdf2 100644 --- a/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs +++ b/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs @@ -11,6 +11,7 @@ namespace Dialogue WaitOnPuzzleStep, WaitOnPickup, WaitOnSlot, + WaitOnCombination, End } @@ -43,6 +44,7 @@ namespace Dialogue public string puzzleStepID; // For WaitOnPuzzleStep public string pickupItemID; // For WaitOnPickup public string slotItemID; // For WaitOnSlot + public string combinationResultItemID; // For WaitOnCombination // For WaitOnSlot - different responses public List incorrectItemLines = new List(); diff --git a/Assets/Scripts/Interactions/ItemSlot.cs b/Assets/Scripts/Interactions/ItemSlot.cs index 1fcd69cf..23e637ff 100644 --- a/Assets/Scripts/Interactions/ItemSlot.cs +++ b/Assets/Scripts/Interactions/ItemSlot.cs @@ -56,6 +56,8 @@ namespace Interactions protected override void OnCharacterArrived() { + Debug.Log("[ItemSlot] OnCharacterArrived"); + var heldItemData = FollowerController.CurrentlyHeldItemData; var heldItemObj = FollowerController.GetHeldPickupObject(); var config = GameManager.Instance.GetSlotItemConfig(itemData); diff --git a/Assets/Scripts/Interactions/Pickup.cs b/Assets/Scripts/Interactions/Pickup.cs index f9361889..6d77a9fd 100644 --- a/Assets/Scripts/Interactions/Pickup.cs +++ b/Assets/Scripts/Interactions/Pickup.cs @@ -20,6 +20,9 @@ namespace Interactions // Event: invoked when the item was picked up successfully public event Action OnItemPickedUp; + // Event: invoked when this item is successfully combined with another + public event Action OnItemsCombined; + /// /// Unity Awake callback. Sets up icon, interactable, and event handlers. /// @@ -100,10 +103,35 @@ namespace Interactions protected virtual void OnCharacterArrived() { + Debug.Log("[Pickup] OnCharacterArrived"); + var combinationResult = FollowerController.TryCombineItems(this, out var combinationResultItem); if (combinationResultItem != null) { Interactable.BroadcastInteractionComplete(true); + + // Fire the combination event when items are successfully combined + if (combinationResult == FollowerController.CombinationResult.Successful) + { + var resultPickup = combinationResultItem.GetComponent(); + if (resultPickup != null && resultPickup.itemData != null) + { + // Get the combined item data + var resultItemData = resultPickup.itemData; + var heldItem = FollowerController.GetHeldPickupObject(); + + if (heldItem != null) + { + var heldPickup = heldItem.GetComponent(); + if (heldPickup != null && heldPickup.itemData != null) + { + // Trigger the combination event + OnItemsCombined?.Invoke(itemData, heldPickup.itemData, resultItemData); + } + } + } + } + return; }