Files
Cog/Source/CogSample/CogSampleTask_WaitAttributeChanged.h
T
2023-10-06 17:22:23 -04:00

40 lines
1.2 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "AbilitySystemComponent.h"
#include "Kismet/BlueprintAsyncActionBase.h"
#include "CogSampleTask_WaitAttributeChanged.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnAttributeChangedDelegate, FGameplayAttribute, Attribute, float, NewValue, float, OldValue)
;
/**
* Blueprint node to automatically register a listener for all attribute changes in an AbilitySystemComponent.
*/
UCLASS(BlueprintType, meta = (ExposedAsyncProxy = AsyncTask))
class UCogSampleTask_WaitAttributeChanged : public UBlueprintAsyncActionBase
{
GENERATED_BODY()
public:
UPROPERTY(BlueprintAssignable)
FOnAttributeChangedDelegate OnAttributeChanged;
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true"))
static UCogSampleTask_WaitAttributeChanged* ListenForAttributeChange(UAbilitySystemComponent* AbilitySystemComponent, FGameplayAttribute Attribute);
virtual void Activate() override;
UFUNCTION(BlueprintCallable)
void EndTask();
protected:
UPROPERTY()
UAbilitySystemComponent* AbilitySystemComponent = nullptr;
FGameplayAttribute AttributeToListenFor;
void AttributeChanged(const FOnAttributeChangeData& Data);
};