Implemented fallback actions, so combo inputs that aren't mapped to the current combo sequence node, or any node, can still have an action associated with them.
This commit is contained in:
parent
b24d7af1a3
commit
1d2dcdd693
@ -64,16 +64,22 @@ void UComboManagerComponent::ActivateComboInput(const UComboInputAsset *Input)
|
||||
const TObjectPtr<const UComboSequenceNode> CurrentNode = (this->ActiveNode ? this->ActiveNode : this->DefaultStartNode);
|
||||
checkf(CurrentNode, TEXT("No combo sequence nodes available."));
|
||||
|
||||
if (CurrentNode->ComboBranch.Contains(Input))
|
||||
const FComboSequenceAction *ActionData = CurrentNode->ComboBranch.Find(Input);
|
||||
// If this node has an action we can activate, then activate it.
|
||||
if (ActionData && ActionData->ComboAction)
|
||||
{
|
||||
const FComboSequenceAction &ActionData = CurrentNode->ComboBranch[Input];
|
||||
if (ActionData.ComboAction)
|
||||
this->BeginNodeTransition(ActionData->NextNode);
|
||||
this->BroadcastDelegates(ActionData->ComboAction, EComboActionTriggerEvent::Activated);
|
||||
UE_LOG(LogComboManagerComponent, Verbose, TEXT("%s activated"), *ActionData->ComboAction->ActionName.ToString());
|
||||
}
|
||||
// Otherwise, see if we have a fallback we can use.
|
||||
else if (const TObjectPtr<const UComboAction> &ComboAction = *this->FallbackActions.Find(Input))
|
||||
{
|
||||
this->BeginNodeTransition(ActionData.NextNode);
|
||||
this->BroadcastDelegates(ActionData.ComboAction, EComboActionTriggerEvent::Activated);
|
||||
UE_LOG(LogComboManagerComponent, Verbose, TEXT("%s activated"), *ActionData.ComboAction->ActionName.ToString());
|
||||
}
|
||||
this->ResetCombo();
|
||||
this->BroadcastDelegates(ComboAction, EComboActionTriggerEvent::Activated);
|
||||
UE_LOG(LogComboManagerComponent, Verbose, TEXT("Fallback action %s activated"), *ComboAction->ActionName.ToString());
|
||||
}
|
||||
// Simply do nothing if there is no action to be performed.
|
||||
else
|
||||
{
|
||||
UE_LOG(LogComboManagerComponent, Verbose, TEXT("No branch found for this action"));
|
||||
@ -93,11 +99,7 @@ void UComboManagerComponent::BeginNodeTransition(const UComboSequenceNode *NextN
|
||||
this->ActiveNode = NextNode;
|
||||
this->GetWorld()->GetTimerManager().SetTimer(this->FinishTransitionTimer, this, &UComboManagerComponent::FinishTransition, 0.5f);
|
||||
|
||||
this->GetWorld()->GetTimerManager().SetTimer(this->DEBUG__ResetComboTimer, this, &UComboManagerComponent::DEBUG__ResetCombo, 1.0f);
|
||||
}
|
||||
void UComboManagerComponent::DEBUG__ResetCombo()
|
||||
{
|
||||
this->ActiveNode = this->PreviousNode = nullptr;
|
||||
this->GetWorld()->GetTimerManager().SetTimer(this->DEBUG__ResetComboTimer, this, &UComboManagerComponent::ResetCombo, 1.0f);
|
||||
}
|
||||
|
||||
void UComboManagerComponent::FinishTransition()
|
||||
@ -105,6 +107,12 @@ void UComboManagerComponent::FinishTransition()
|
||||
this->PreviousNode = this->ActiveNode;
|
||||
}
|
||||
|
||||
void UComboManagerComponent::ResetCombo()
|
||||
{
|
||||
this->GetWorld()->GetTimerManager().ClearTimer(this->DEBUG__ResetComboTimer);
|
||||
this->ActiveNode = this->PreviousNode = nullptr;
|
||||
}
|
||||
|
||||
|
||||
void UComboManagerComponent::BroadcastDelegates(const UComboAction *ComboAction, const EComboActionTriggerEvent &TriggerEvent)
|
||||
{
|
||||
|
||||
@ -66,6 +66,11 @@ protected:
|
||||
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
|
||||
FComboOffsetMap OffsetMap;
|
||||
|
||||
// A list of inputs to map to actions by default. If the active combo sequence node
|
||||
// doesn't handle this action, this list will be used as a fallback whenever possible.
|
||||
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
|
||||
TMap<TObjectPtr<const class UComboInputAsset>, TObjectPtr<const class UComboAction>> FallbackActions;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, EditDefaultsOnly)
|
||||
TMap<TObjectPtr<const class UComboInputAsset>, float> DEBUG__UnlockTimers;
|
||||
|
||||
@ -75,11 +80,11 @@ protected:
|
||||
private:
|
||||
void BeginNodeTransition(const class UComboSequenceNode *NextNode);
|
||||
void FinishTransition();
|
||||
void ResetCombo();
|
||||
|
||||
void BroadcastDelegates(const class UComboAction *ComboAction, const EComboActionTriggerEvent &TriggerEvent);
|
||||
|
||||
void DEBUG__UnlockAction(TObjectPtr<const class UComboInputAsset> Unlock);
|
||||
void DEBUG__ResetCombo();
|
||||
|
||||
const class UComboSequenceNode *ActiveNode = nullptr;
|
||||
const class UComboSequenceNode *PreviousNode = nullptr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user