diff --git a/Source/ComboInput/Private/Components/ComboManagerComponent.cpp b/Source/ComboInput/Private/Components/ComboManagerComponent.cpp index 330541b..32b19b3 100644 --- a/Source/ComboInput/Private/Components/ComboManagerComponent.cpp +++ b/Source/ComboInput/Private/Components/ComboManagerComponent.cpp @@ -19,16 +19,25 @@ UComboManagerComponent::UComboManagerComponent() this->PrimaryComponentTick.bStartWithTickEnabled = false; this->PrimaryComponentTick.bTickEvenWhenPaused = false; this->PrimaryComponentTick.bCanEverTick = false; + + this->bWantsInitializeComponent = true; } -void UComboManagerComponent::BeginPlay() +void UComboManagerComponent::InitializeComponent() { - Super::BeginPlay(); + Super::InitializeComponent(); checkf(this->ComboGraph, TEXT("No combo graph is set for %s in actor %s"), *UComboManagerComponent::StaticClass()->GetName(), *this->GetOwner()->GetName()); this->ActiveNode = this->ComboGraph->StartNode; } +void UComboManagerComponent::SetComboGraph(const UComboActionGraph *Graph) +{ + this->ComboGraph = Graph; + this->ActiveNode = this->ComboGraph->StartNode; + this->PreviousNode = nullptr; +} + void UComboManagerComponent::HandleComboInput(const UComboInputAsset *Input, const EComboActionTriggerEvent &TriggerEvent) { diff --git a/Source/ComboInput/Private/Components/InputBufferComponent.cpp b/Source/ComboInput/Private/Components/InputBufferComponent.cpp index 2d8cc89..57f41fb 100644 --- a/Source/ComboInput/Private/Components/InputBufferComponent.cpp +++ b/Source/ComboInput/Private/Components/InputBufferComponent.cpp @@ -12,9 +12,14 @@ DEFINE_LOG_CATEGORY(LogInputBufferComponent); -void UInputBufferComponent::BeginPlay() +UInputBufferComponent::UInputBufferComponent() { - Super::BeginPlay(); + this->bWantsInitializeComponent = true; +} + +void UInputBufferComponent::InitializeComponent() +{ + Super::InitializeComponent(); if (APlayerController *PlayerController = UGameplayStatics::GetPlayerController(this, 0)) { diff --git a/Source/ComboInput/Public/Components/ComboManagerComponent.h b/Source/ComboInput/Public/Components/ComboManagerComponent.h index b939698..ab29e9b 100644 --- a/Source/ComboInput/Public/Components/ComboManagerComponent.h +++ b/Source/ComboInput/Public/Components/ComboManagerComponent.h @@ -42,8 +42,10 @@ class COMBOINPUT_API UComboManagerComponent : public UActorComponent public: UComboManagerComponent(); + virtual void InitializeComponent() override; - virtual void BeginPlay() override; + UFUNCTION(BlueprintCallable) + void SetComboGraph(const class UComboActionGraph *Graph); UFUNCTION(BlueprintCallable) void HandleComboInput(const class UComboInputAsset *Input, const EComboActionTriggerEvent &TriggerEvent); diff --git a/Source/ComboInput/Public/Components/InputBufferComponent.h b/Source/ComboInput/Public/Components/InputBufferComponent.h index 3835635..f4a2bd0 100644 --- a/Source/ComboInput/Public/Components/InputBufferComponent.h +++ b/Source/ComboInput/Public/Components/InputBufferComponent.h @@ -21,7 +21,8 @@ class COMBOINPUT_API UInputBufferComponent : public UEnhancedInputComponent GENERATED_BODY() public: - virtual void BeginPlay() override; + UInputBufferComponent(); + virtual void InitializeComponent() override; UFUNCTION(BlueprintCallable) void LockComboInput(const class UComboInputAsset *Input);