-
Notifications
You must be signed in to change notification settings - Fork 7
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
Input buffer #260
Changes from 1 commit
dfadd7c
6390933
4f17a39
726a242
83458a8
df0db85
72edbd4
ddd7262
528ecbc
d872059
b1c1266
a9b11b0
0b3e854
261a243
de401d7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ) | ||
{ | ||
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 !" ) ) ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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() ) | ||
|
@@ -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() | ||
|
@@ -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() | ||
|
@@ -200,4 +227,4 @@ FGameplayTag UGBFAbilityInputBufferComponent::GetMostTriggeredInput() | |
} | ||
|
||
return most_triggered_tag; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 ); | ||
|
||
|
@@ -38,4 +41,8 @@ class GAMEBASEFRAMEWORK_API UGBFAbilityInputBufferComponent : public UPawnCompon | |
FGameplayTagContainer InputTagsToCheck; | ||
TArray< FGameplayTag > TriggeredTags; | ||
TArray< uint32 > BindHandles; | ||
}; | ||
|
||
UPROPERTY( EditDefaultsOnly ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
}; |
There was a problem hiding this comment.
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