diff --git a/Source/ComboInput/Private/ComboActionGraph.cpp b/Source/ComboInput/Private/ComboActionGraph.cpp index 8776d6a..8b8aea4 100644 --- a/Source/ComboInput/Private/ComboActionGraph.cpp +++ b/Source/ComboInput/Private/ComboActionGraph.cpp @@ -26,24 +26,6 @@ UComboActionGraph::UComboActionGraph() #endif } -bool UComboActionGraph::CanStartDialogueGraph() const -{ - if (this->AllNodes.Num() == 0) - { - return false; - } - - for (const UComboActionGraphNode *Itr : this->AllNodes) - { - if (!Itr || !Itr->ValidateNodeRuntime()) - { - return false; - } - } - - return true; -} - void UComboActionGraph::CreateGraph() { #if WITH_EDITOR diff --git a/Source/ComboInput/Private/Components/ComboManagerComponent.cpp b/Source/ComboInput/Private/Components/ComboManagerComponent.cpp index f588f10..330541b 100644 --- a/Source/ComboInput/Private/Components/ComboManagerComponent.cpp +++ b/Source/ComboInput/Private/Components/ComboManagerComponent.cpp @@ -142,6 +142,8 @@ void UComboManagerComponent::ResetCombo() const UComboActionGraphNode *UComboManagerComponent::FindActiveNodeData(const UComboActionGraphNode *CurrentNode, const UComboInputAsset *Input, const EComboActionTriggerEvent TriggerEvent, const UComboAction *&ComboAction) { + checkf(CurrentNode, TEXT("Attempting to find an active node from a null node.")); + // Find a node that matches both the combo input and the trigger action. const UComboActionGraphNode *NextNode = nullptr; for (const UComboActionGraphNode *GraphNode : CurrentNode->ChildrenNodes) @@ -150,10 +152,11 @@ const UComboActionGraphNode *UComboManagerComponent::FindActiveNodeData(const UC { if (ActionNode->GetComboInput() == Input && ActionNode->GetTriggerEvent() == EComboActionTriggerEvent::Activated) { - // If we found the right node, only acknowledge it if it's enabled. Otherwise just skip it. - if (ActionNode->bEnabled) + // If we found the right node, only acknowledge it if it's enabled. + const UComboAction *CheckAction = ActionNode->GetComboAction(); + if (ActionNode->bEnabled || this->ComboGraph->UnlockedActions.Contains(CheckAction)) { - ComboAction = ActionNode->GetComboAction(); + ComboAction = CheckAction; NextNode = ActionNode; } break; diff --git a/Source/ComboInput/Public/ComboActionGraph.h b/Source/ComboInput/Public/ComboActionGraph.h index 9066700..6d14bb4 100644 --- a/Source/ComboInput/Public/ComboActionGraph.h +++ b/Source/ComboInput/Public/ComboActionGraph.h @@ -43,17 +43,17 @@ public: UPROPERTY(BlueprintReadOnly, Category="Combo Input|Action") class UComboActionGraphNode *StartNode = nullptr; /** - * The class of the dialogue node represented by this instance. + * The class of the action node represented by this instance. */ UPROPERTY(BlueprintReadOnly, Category="Combo Input|Action") TSubclassOf NodeType; /** - * The class of the dialogue edge represented by this instance. + * The class of the action edge represented by this instance. */ UPROPERTY(BlueprintReadOnly, Category="Combo Input|Action") TSubclassOf EdgeType; /** - * An array of root nodes in the dialogue graph. These are the nodes that do not have any incoming connections. + * An array of root nodes in the action graph. These are the nodes that do not have any incoming connections. */ UPROPERTY(BlueprintReadOnly, Category="Combo Input|Action") TArray RootNodes; @@ -62,6 +62,13 @@ public: */ UPROPERTY(BlueprintReadOnly, Category="Combo Input|Action") TArray AllNodes; + + /** + * Set containing actions to be unlocked if their associated nodes are currently locked. + */ + UPROPERTY(BlueprintReadWrite, Category="Combo Input|Action") + TSet UnlockedActions; + // Flag indicating whether an edge is enabled UPROPERTY(BlueprintReadOnly, Category="Combo Input|Action") bool bEdgeEnabled; @@ -88,18 +95,12 @@ public: UFUNCTION(BlueprintCallable, Category="Combo Input|Action") TArray GetRootNodes() const { return this->RootNodes; } /** - * Returns the root nodes of the dialogue graph. + * Returns the first node in the graph. * - * @return An array of all root nodes. + * @return The start node of this graph. */ UFUNCTION(BlueprintCallable, Category="Combo Input|Action") UComboActionGraphNode *GetStartNode() const { return this->StartNode; } - /** - * Determines whether the dialogue graph can be started. - * - * @return true if the graph can be started, false otherwise. - */ - bool CanStartDialogueGraph() const; public: void CreateGraph();