Skip to content

Input buffer #260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 15 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,24 @@
#include "GAS/Components/GBFAbilitySystemComponent.h"
#include "Input/GBFInputComponent.h"

UGBFAbilityInputBufferComponent::UGBFAbilityInputBufferComponent( const FObjectInitializer & ObjectInitializer ) :
Super( ObjectInitializer )
{
TriggerPriority = ETriggerPriority::LastTriggeredInput;
this->PrimaryComponentTick.bStartWithTickEnabled = false;
this->PrimaryComponentTick.bCanEverTick = true;
}

void UGBFAbilityInputBufferComponent::TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the tick would only be fired #if !UE_BUILD_SHIPPING, you can surround the function by that too, both in .h and cpp

{
Super::TickComponent( DeltaTime, TickType, ThisTickFunction );
MonitoringTime += DeltaTime;
if ( !ensureAlwaysMsgf( MonitoringTime <= MaxMonitoringTime, TEXT( "Ability Input Buffer didn't call Stop Monitor 5 secs after activation, please call it manually !" ) ) )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print the actual MaxMonitoringTime instead of 5

{
StopMonitoring();
}
}

void UGBFAbilityInputBufferComponent::StartMonitoring( FGameplayTagContainer input_tags_to_check, ETriggerPriority trigger_priority )
{
if ( input_tags_to_check.IsEmpty() )
Expand All @@ -16,6 +34,10 @@ void UGBFAbilityInputBufferComponent::StartMonitoring( FGameplayTagContainer inp
TriggerPriority = trigger_priority;
InputTagsToCheck = input_tags_to_check;
BindActions();

#if !UE_BUILD_SHIPPING
SetComponentTickEnabled( true );
#endif
}

void UGBFAbilityInputBufferComponent::StopMonitoring()
Expand All @@ -30,6 +52,11 @@ void UGBFAbilityInputBufferComponent::Reset()
TriggeredTags.Reset();
InputTagsToCheck.Reset();
BindHandles.Reset();
MonitoringTime = 0.0f;

#if !UE_BUILD_SHIPPING
SetComponentTickEnabled( false );
#endif
}

void UGBFAbilityInputBufferComponent::BindActions()
Expand Down Expand Up @@ -200,4 +227,4 @@ FGameplayTag UGBFAbilityInputBufferComponent::GetMostTriggeredInput()
}

return most_triggered_tag;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ UCLASS( Blueprintable )
class GAMEBASEFRAMEWORK_API UGBFAbilityInputBufferComponent : public UPawnComponent
{
GENERATED_BODY()

public:
UGBFAbilityInputBufferComponent( const FObjectInitializer & ObjectInitializer );
void TickComponent( float DeltaTime, ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction ) override;
UFUNCTION( BlueprintCallable )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UFUNCTION before other functions, except for constructor and inline functions

void StartMonitoring( FGameplayTagContainer input_tags_to_check, ETriggerPriority trigger_priority );

Expand All @@ -38,4 +41,8 @@ class GAMEBASEFRAMEWORK_API UGBFAbilityInputBufferComponent : public UPawnCompon
FGameplayTagContainer InputTagsToCheck;
TArray< FGameplayTag > TriggeredTags;
TArray< uint32 > BindHandles;
};

UPROPERTY( EditDefaultsOnly )
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UPROPERTY before all other properties

float MaxMonitoringTime = 5.0f;
float MonitoringTime = 0.0f;
};