Components now use InitializeComponent instead of BeginPlay.

This commit is contained in:
Jamie Greunbaum 2023-10-04 13:05:15 -04:00
parent 13172b3b60
commit c50c9c6bf7
4 changed files with 23 additions and 6 deletions

View File

@ -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)
{

View File

@ -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))
{

View File

@ -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);

View File

@ -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);