diff --git a/Assets/Dialogue/Anne Lise/AnaLiseInBushADialogue.dialoguegraph b/Assets/Dialogue/Anne Lise/AnaLiseInBushADialogue.dialoguegraph index 026e53f8..ca6227d8 100644 --- a/Assets/Dialogue/Anne Lise/AnaLiseInBushADialogue.dialoguegraph +++ b/Assets/Dialogue/Anne Lise/AnaLiseInBushADialogue.dialoguegraph @@ -307,6 +307,7 @@ MonoBehaviour: - LoopThroughIncorrectItemLines - ForbiddenItemDialogueContent - LoopThroughForbiddenItemLines + - ShouldAutoPlay m_ValueList: - rid: 4008004961314799713 - rid: 4008004961314799714 @@ -321,6 +322,7 @@ MonoBehaviour: - rid: 4008004961314799723 - rid: 4008004961314799724 - rid: 4008004961314799725 + - rid: 7545630068434796544 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -525,3 +527,7 @@ MonoBehaviour: - rid: 4008004961314799729 type: {class: EndNode, ns: Editor.Dialogue, asm: AppleHillsEditor} data: + - rid: 7545630068434796544 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 1 diff --git a/Assets/Dialogue/Anne Lise/AnaLiseInBushBDialogue.dialoguegraph b/Assets/Dialogue/Anne Lise/AnaLiseInBushBDialogue.dialoguegraph index b26396ad..9c04a252 100644 --- a/Assets/Dialogue/Anne Lise/AnaLiseInBushBDialogue.dialoguegraph +++ b/Assets/Dialogue/Anne Lise/AnaLiseInBushBDialogue.dialoguegraph @@ -168,6 +168,7 @@ MonoBehaviour: - LoopThroughIncorrectItemLines - ForbiddenItemDialogueContent - LoopThroughForbiddenItemLines + - ShouldAutoPlay m_ValueList: - rid: 4008004961314799803 - rid: 4008004961314799804 @@ -182,6 +183,7 @@ MonoBehaviour: - rid: 4008004961314799813 - rid: 4008004961314799814 - rid: 4008004961314799815 + - rid: 7545630068434796549 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -525,3 +527,7 @@ MonoBehaviour: type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: AnneLise + - rid: 7545630068434796549 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 0 diff --git a/Assets/Dialogue/Anne Lise/AnaLiseInBushCDialogue.dialoguegraph b/Assets/Dialogue/Anne Lise/AnaLiseInBushCDialogue.dialoguegraph index 1ad4bf6a..64585a8b 100644 --- a/Assets/Dialogue/Anne Lise/AnaLiseInBushCDialogue.dialoguegraph +++ b/Assets/Dialogue/Anne Lise/AnaLiseInBushCDialogue.dialoguegraph @@ -168,6 +168,7 @@ MonoBehaviour: - LoopThroughIncorrectItemLines - ForbiddenItemDialogueContent - LoopThroughForbiddenItemLines + - ShouldAutoPlay m_ValueList: - rid: 4008004961314799847 - rid: 4008004961314799848 @@ -182,6 +183,7 @@ MonoBehaviour: - rid: 4008004961314799857 - rid: 4008004961314799858 - rid: 4008004961314799859 + - rid: 7545630068434796550 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -525,3 +527,7 @@ MonoBehaviour: type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: AnneLise + - rid: 7545630068434796550 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 0 diff --git a/Assets/Dialogue/Anne Lise/AnaLiseInBushDDialogue.dialoguegraph b/Assets/Dialogue/Anne Lise/AnaLiseInBushDDialogue.dialoguegraph index 856d29b5..92808258 100644 --- a/Assets/Dialogue/Anne Lise/AnaLiseInBushDDialogue.dialoguegraph +++ b/Assets/Dialogue/Anne Lise/AnaLiseInBushDDialogue.dialoguegraph @@ -168,6 +168,7 @@ MonoBehaviour: - LoopThroughIncorrectItemLines - ForbiddenItemDialogueContent - LoopThroughForbiddenItemLines + - ShouldAutoPlay m_ValueList: - rid: 4008004961314799891 - rid: 4008004961314799892 @@ -182,6 +183,7 @@ MonoBehaviour: - rid: 4008004961314799901 - rid: 4008004961314799902 - rid: 4008004961314799903 + - rid: 7545630068434796545 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -525,3 +527,7 @@ MonoBehaviour: type: {class: 'Constant`1[[System.String, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} data: m_Value: AnneLise + - rid: 7545630068434796545 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 0 diff --git a/Assets/Dialogue/Gardener/GardenerDialogueGraph.dialoguegraph b/Assets/Dialogue/Gardener/GardenerDialogueGraph.dialoguegraph index 021bedd8..0964f571 100644 --- a/Assets/Dialogue/Gardener/GardenerDialogueGraph.dialoguegraph +++ b/Assets/Dialogue/Gardener/GardenerDialogueGraph.dialoguegraph @@ -42,12 +42,14 @@ MonoBehaviour: - RequiredPuzzleStep - DefaultDialogueContent - LoopThroughDefaultLines + - ShouldAutoPlay m_ValueList: - rid: 4008004961314799759 - rid: 4008004961314799760 - rid: 4008004961314799761 - rid: 4008004961314799762 - rid: 4008004961314799763 + - rid: 7545630068434796551 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -169,6 +171,10 @@ MonoBehaviour: _text: _image: {fileID: 1487011052474782424, guid: f489e2c9ce64ff34aa3c7a91a4edbd77, type: 3} _audio: {fileID: 8300000, guid: b4ba973891dad4749b465e9a07987e1a, type: 3} + - rid: 7545630068434796551 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 0 - rid: 7772910664224079994 type: {class: GraphModelImp, ns: Unity.GraphToolkit.Editor.Implementation, asm: Unity.GraphToolkit.Editor} data: diff --git a/Assets/Dialogue/TestAssDialogue.dialoguegraph b/Assets/Dialogue/TestAssDialogue.dialoguegraph index 13412bf8..45d8d87e 100644 --- a/Assets/Dialogue/TestAssDialogue.dialoguegraph +++ b/Assets/Dialogue/TestAssDialogue.dialoguegraph @@ -487,6 +487,7 @@ MonoBehaviour: - DefaultDialogueContent1 - DefaultDialogueContent2 - DefaultDialogueContent3 + - ShouldAutoPlay m_ValueList: - rid: 1226592702090707084 - rid: 1226592702090707085 @@ -495,6 +496,7 @@ MonoBehaviour: - rid: 7545629632211976304 - rid: 7545629632211976305 - rid: 7545629632211976306 + - rid: 7545630068434796546 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -689,12 +691,14 @@ MonoBehaviour: - RequiredResultItem - LoopThroughDefaultLines - DefaultDialogueContent + - ShouldAutoPlay m_ValueList: - rid: 1226592736610877524 - rid: 1226592736610877525 - rid: 1226592736610877526 - rid: 1226592736610877528 - rid: 7545629632211976309 + - rid: 7545630068434796547 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -895,6 +899,7 @@ MonoBehaviour: - DefaultDialogueContent - IncorrectItemDialogueContent - ForbiddenItemDialogueContent + - ShouldAutoPlay m_ValueList: - rid: 1226592736610877547 - rid: 1226592736610877548 @@ -909,6 +914,7 @@ MonoBehaviour: - rid: 7545629632211976311 - rid: 7545629632211976312 - rid: 7545629632211976313 + - rid: 7545630068434796548 m_InputPortInfos: expandedPortsById: m_KeyList: [] @@ -1212,3 +1218,15 @@ MonoBehaviour: _text: Yessssss, thanks! _image: {fileID: 0} _audio: {fileID: 0} + - rid: 7545630068434796546 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 0 + - rid: 7545630068434796547 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 0 + - rid: 7545630068434796548 + type: {class: 'Constant`1[[System.Boolean, mscorlib]]', ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor} + data: + m_Value: 0 diff --git a/Assets/Editor/Dialogue/DialogueGraphImporter.cs b/Assets/Editor/Dialogue/DialogueGraphImporter.cs index 3556912c..3008a70b 100644 --- a/Assets/Editor/Dialogue/DialogueGraphImporter.cs +++ b/Assets/Editor/Dialogue/DialogueGraphImporter.cs @@ -164,6 +164,8 @@ namespace Editor.Dialogue { runtimeNode.puzzleStepID = puzzleStep.stepId; } + + runtimeNode.shouldAutoPlay = GetPortValue(node.GetInputPortByName("ShouldAutoPlay")); } private void ProcessPickupNode(WaitOnPickup node, RuntimeDialogueNode runtimeNode) @@ -175,6 +177,8 @@ namespace Editor.Dialogue { runtimeNode.pickupItemID = pickup.itemId; } + + runtimeNode.shouldAutoPlay = GetPortValue(node.GetInputPortByName("ShouldAutoPlay")); } private void ProcessSlotNode(WaitOnSlot node, RuntimeDialogueNode runtimeNode) @@ -187,6 +191,8 @@ namespace Editor.Dialogue runtimeNode.slotItemID = slot.itemId; } + runtimeNode.shouldAutoPlay = GetPortValue(node.GetInputPortByName("ShouldAutoPlay")); + // Get line type and count options for incorrect items var incorrectItemLineTypeOption = node.GetNodeOptionByName("IncorrectItemDialogueLineType"); incorrectItemLineTypeOption.TryGetValue(out var incorrectItemLineType); @@ -296,6 +302,8 @@ namespace Editor.Dialogue { runtimeNode.combinationResultItemID = resultItem.itemId; } + + runtimeNode.shouldAutoPlay = GetPortValue(node.GetInputPortByName("ShouldAutoPlay")); } private T GetPortValue(IPort port) diff --git a/Assets/Editor/Dialogue/DialogueNodes.cs b/Assets/Editor/Dialogue/DialogueNodes.cs index 3c2c8e0d..e9f751d7 100644 --- a/Assets/Editor/Dialogue/DialogueNodes.cs +++ b/Assets/Editor/Dialogue/DialogueNodes.cs @@ -90,10 +90,12 @@ namespace Editor.Dialogue public class WaitOnPuzzleStep : DialogueNode { const string RequiredPuzzleStep = "RequiredPuzzleStep"; + const string ShouldAutoPlayOptionName = "ShouldAutoPlay"; protected override void OnDefinePorts(IPortDefinitionContext context) { context.AddInputPort(RequiredPuzzleStep).WithDisplayName("Required Puzzle Step").Build(); + context.AddInputPort(ShouldAutoPlayOptionName).WithDisplayName("Should Auto-Play?").Build(); base.OnDefinePorts(context); } @@ -103,10 +105,12 @@ namespace Editor.Dialogue public class WaitOnPickup : DialogueNode { const string RequiredPickupsOptionName = "RequiredPickup"; + const string ShouldAutoPlayOptionName = "ShouldAutoPlay"; protected override void OnDefinePorts(IPortDefinitionContext context) { context.AddInputPort(RequiredPickupsOptionName).WithDisplayName("Required Pickup").Build(); + context.AddInputPort(ShouldAutoPlayOptionName).WithDisplayName("Should Auto-Play?").Build(); base.OnDefinePorts(context); } @@ -116,6 +120,7 @@ namespace Editor.Dialogue public class WaitOnSlot : DialogueNode { const string RequiredSlotOptionName = "RequiredSlot"; + const string ShouldAutoPlayOptionName = "ShouldAutoPlay"; const string IncorrectItemLineTypeOptionName = "IncorrectItemDialogueLineType"; const string IncorrectItemNoLinesOptionName = "IncorrectItemNoLines"; const string LoopThroughIncorrectItemLinesOptionName = "LoopThroughIncorrectItemLines"; @@ -156,6 +161,7 @@ namespace Editor.Dialogue protected override void OnDefinePorts(IPortDefinitionContext context) { context.AddInputPort(RequiredSlotOptionName).WithDisplayName("Required Slot").Build(); + context.AddInputPort(ShouldAutoPlayOptionName).WithDisplayName("Should Auto-Play?").Build(); base.OnDefinePorts(context); @@ -219,10 +225,12 @@ namespace Editor.Dialogue public class WaitOnCombination : DialogueNode { const string RequiredResultItemOptionName = "RequiredResultItem"; + const string ShouldAutoPlayOptionName = "ShouldAutoPlay"; protected override void OnDefinePorts(IPortDefinitionContext context) { context.AddInputPort(RequiredResultItemOptionName).WithDisplayName("Required Result Item").Build(); + context.AddInputPort(ShouldAutoPlayOptionName).WithDisplayName("Should Auto-Play?").Build(); base.OnDefinePorts(context); } diff --git a/Assets/Scripts/Dialogue/DialogueComponent.cs b/Assets/Scripts/Dialogue/DialogueComponent.cs index 35e90d53..7ef34822 100644 --- a/Assets/Scripts/Dialogue/DialogueComponent.cs +++ b/Assets/Scripts/Dialogue/DialogueComponent.cs @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Collections.Generic; +using Bootstrap; using Core; using Interactions; using UnityEngine; @@ -46,23 +47,6 @@ namespace Dialogue Debug.LogError("SpeechBubble component is missing on Dialogue Component"); } - // Register for global events - if (PuzzleManager.Instance != null) - PuzzleManager.Instance.OnStepCompleted += OnAnyPuzzleStepCompleted; - - if (ItemManager.Instance != null) - { - ItemManager.Instance.OnItemPickedUp += OnAnyItemPickedUp; - ItemManager.Instance.OnCorrectItemSlotted += OnAnyItemSlotted; - ItemManager.Instance.OnIncorrectItemSlotted += OnAnyIncorrectItemSlotted; - ItemManager.Instance.OnForbiddenItemSlotted += OnAnyForbiddenItemSlotted; - ItemManager.Instance.OnItemSlotCleared += OnAnyItemSlotCleared; - ItemManager.Instance.OnItemsCombined += OnAnyItemsCombined; - } - - // Auto-start the dialogue - // StartDialogue(); - var interactable = GetComponent(); if (interactable != null) { @@ -74,6 +58,20 @@ namespace Dialogue { speechBubble.UpdatePromptVisibility(HasAnyLines()); } + + BootCompletionService.RegisterInitAction(InitializePostBoot); + } + + private void InitializePostBoot() + { + // Register for global events + PuzzleManager.Instance.OnStepCompleted += OnAnyPuzzleStepCompleted; + ItemManager.Instance.OnItemPickedUp += OnAnyItemPickedUp; + ItemManager.Instance.OnCorrectItemSlotted += OnAnyItemSlotted; + ItemManager.Instance.OnIncorrectItemSlotted += OnAnyIncorrectItemSlotted; + ItemManager.Instance.OnForbiddenItemSlotted += OnAnyForbiddenItemSlotted; + ItemManager.Instance.OnItemSlotCleared += OnAnyItemSlotCleared; + ItemManager.Instance.OnItemsCombined += OnAnyItemsCombined; } private void OnCharacterArrived() @@ -457,6 +455,12 @@ namespace Dialogue // Global event handlers private void OnAnyPuzzleStepCompleted(PuzzleStepSO step) { + // Initialize if needed + if (!initialized) + { + StartDialogue(); + } + // Only react if we're active and waiting on a puzzle step if (!IsActive || IsCompleted || currentNode == null || currentNode.nodeType != RuntimeDialogueNodeType.WaitOnPuzzleStep) @@ -465,19 +469,21 @@ namespace Dialogue // Check if this is the step we're waiting for if (step.stepId == currentNode.puzzleStepID) { - // Instead of immediately moving to the next node, set the flag + // Set the flag that condition is satisfied _conditionSatisfiedPendingAdvance = true; - // Update bubble visibility after state change to show interaction prompt - if (speechBubble != null) - { - speechBubble.UpdatePromptVisibility(HasAnyLines()); - } + UpdateDialogueVisibilityOnItemEvent(); } } private void OnAnyItemPickedUp(PickupItemData item) { + // Initialize if needed + if (!initialized) + { + StartDialogue(); + } + // Only react if we're active and waiting on an item pickup if (!IsActive || IsCompleted || currentNode == null || currentNode.nodeType != RuntimeDialogueNodeType.WaitOnPickup) @@ -486,14 +492,10 @@ namespace Dialogue // Check if this is the item we're waiting for if (item.itemId == currentNode.pickupItemID) { - // Instead of immediately moving to the next node, set the flag + // Set the flag that condition is satisfied _conditionSatisfiedPendingAdvance = true; - // Update bubble visibility after state change to show interaction prompt - if (speechBubble != null) - { - speechBubble.UpdatePromptVisibility(HasAnyLines()); - } + UpdateDialogueVisibilityOnItemEvent(); } } @@ -501,6 +503,12 @@ namespace Dialogue { Logging.Debug("[DialogueComponent] OnAnyItemSlotted"); + // Initialize if needed + if (!initialized) + { + StartDialogue(); + } + // Only react if we're active and waiting on a slot if (!IsActive || IsCompleted || currentNode == null || currentNode.nodeType != RuntimeDialogueNodeType.WaitOnSlot) @@ -509,19 +517,21 @@ namespace Dialogue // Check if this is the slot we're waiting for if (slotDefinition.itemId == currentNode.slotItemID) { - // Instead of immediately moving to the next node, set the flag + // Set the flag that condition is satisfied _conditionSatisfiedPendingAdvance = true; - // Update bubble visibility after state change to show interaction prompt - if (speechBubble != null) - { - speechBubble.UpdatePromptVisibility(HasAnyLines()); - } + UpdateDialogueVisibilityOnItemEvent(); } } private void OnAnyItemsCombined(PickupItemData itemA, PickupItemData itemB, PickupItemData resultItem) { + // Initialize if needed + if (!initialized) + { + StartDialogue(); + } + // Only react if we're active and waiting on a combination if (!IsActive || IsCompleted || currentNode == null || currentNode.nodeType != RuntimeDialogueNodeType.WaitOnCombination) @@ -530,19 +540,21 @@ namespace Dialogue // Check if this is the result item we're waiting for if (resultItem.itemId == currentNode.combinationResultItemID) { - // Instead of immediately moving to the next node, set the flag + // Set the flag that condition is satisfied _conditionSatisfiedPendingAdvance = true; - // Update bubble visibility after state change to show interaction prompt - if (speechBubble != null) - { - speechBubble.UpdatePromptVisibility(HasAnyLines()); - } + UpdateDialogueVisibilityOnItemEvent(); } } private void OnAnyIncorrectItemSlotted(PickupItemData slotDefinition, PickupItemData slottedItem) { + // Initialize if needed + if (!initialized) + { + StartDialogue(); + } + // Update the slot state for displaying the correct dialogue lines if (!IsActive || IsCompleted || currentNode == null) return; @@ -554,16 +566,18 @@ namespace Dialogue _currentSlotState = ItemSlotState.Incorrect; _lastSlottedItem = slottedItem; - // Trigger dialogue update - if (speechBubble != null) - { - speechBubble.UpdatePromptVisibility(HasAnyLines()); - } + UpdateDialogueVisibilityOnItemEvent(); } } private void OnAnyForbiddenItemSlotted(PickupItemData slotDefinition, PickupItemData slottedItem) { + // Initialize if needed + if (!initialized) + { + StartDialogue(); + } + // Update the slot state for displaying the correct dialogue lines if (!IsActive || IsCompleted || currentNode == null) return; @@ -575,16 +589,18 @@ namespace Dialogue _currentSlotState = ItemSlotState.Forbidden; _lastSlottedItem = slottedItem; - // Trigger dialogue update - if (speechBubble != null) - { - speechBubble.UpdatePromptVisibility(HasAnyLines()); - } + UpdateDialogueVisibilityOnItemEvent(); } } private void OnAnyItemSlotCleared(PickupItemData removedItem) { + // Initialize if needed + if (!initialized) + { + StartDialogue(); + } + // Update the slot state when an item is removed if (!IsActive || IsCompleted || currentNode == null) return; @@ -594,8 +610,21 @@ namespace Dialogue { _currentSlotState = ItemSlotState.None; _lastSlottedItem = null; - - // Trigger dialogue update + + UpdateDialogueVisibilityOnItemEvent(); + } + } + + private void UpdateDialogueVisibilityOnItemEvent() + { + // If auto-play is enabled, immediately display dialogue + if (currentNode.shouldAutoPlay) + { + OnCharacterArrived(); + } + else + { + // Manual mode: just update bubble visibility to show interaction prompt if (speechBubble != null) { speechBubble.UpdatePromptVisibility(HasAnyLines()); diff --git a/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs b/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs index d08c271b..eaa8651a 100644 --- a/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs +++ b/Assets/Scripts/Dialogue/RuntimeDialogueGraph.cs @@ -50,6 +50,9 @@ namespace Dialogue public string slotItemID; // For WaitOnSlot public string combinationResultItemID; // For WaitOnCombination + // Auto-play dialogue when condition is met (for item-related nodes) + public bool shouldAutoPlay; + // For WaitOnSlot - different responses [HideInInspector] public List incorrectItemLines = new List();