第一次提交
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "Abilities/Async/AbilityAsync.h"
|
||||
#include "GGA_AsyncTask_AttributeChanged.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnAttributeChanged, FGameplayAttribute, Attribute, float, NewValue, float, OldValue);
|
||||
|
||||
/**
|
||||
* 蓝图节点,用于监听AbilitySystemComponent上的属性变化。
|
||||
* 一般用于UI。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AsyncTask_AttributeChanged : public UAbilityAsync
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnAttributeChanged OnAttributeChanged;
|
||||
|
||||
// Listens for an attribute changing.
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (BlueprintInternalUseOnly = "true"))
|
||||
static UGGA_AsyncTask_AttributeChanged* ListenForAttributeChange(UAbilitySystemComponent* AbilitySystemComponent, FGameplayAttribute Attribute);
|
||||
|
||||
// Listens for an attribute changing.
|
||||
// Version that takes in an array of Attributes. Check the Attribute output for which Attribute changed.
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (BlueprintInternalUseOnly = "true"))
|
||||
static UGGA_AsyncTask_AttributeChanged* ListenForAttributesChange(UAbilitySystemComponent* AbilitySystemComponent, TArray<FGameplayAttribute> Attributes);
|
||||
|
||||
// You must call this function manually when you want the AsyncTask to end.
|
||||
// For UMG Widgets, you would call it in the Widget's Destruct event.
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta=(DeprecatedFunction, DeprecationMessage="Use EndAction"))
|
||||
void EndTask();
|
||||
|
||||
protected:
|
||||
virtual void Activate() override;
|
||||
virtual void EndAction() override;
|
||||
|
||||
FGameplayAttribute AttributeToListenFor;
|
||||
TArray<FGameplayAttribute> AttributesToListenFor;
|
||||
|
||||
void AttributeChanged(const FOnAttributeChangeData& Data);
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "Abilities/Async/AbilityAsync.h"
|
||||
#include "GGA_AsyncTask_GameplayTagAddedRemoved.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnGameplayTagAddedRemoved, FGameplayTag, Tag);
|
||||
|
||||
/**
|
||||
* 蓝图节点,用于监听AbilitySystemComponent上的标记添加/移除变化。
|
||||
* 一般用于蓝图/UMG
|
||||
*/
|
||||
UCLASS(BlueprintType, meta = (ExposedAsyncProxy = AsyncTask))
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AsyncTask_GameplayTagAddedRemoved : public UAbilityAsync
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnGameplayTagAddedRemoved OnTagAdded;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOnGameplayTagAddedRemoved OnTagRemoved;
|
||||
|
||||
// Listens for FGameplayTags added and removed.
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (BlueprintInternalUseOnly = "true"))
|
||||
static UGGA_AsyncTask_GameplayTagAddedRemoved* ListenForGameplayTagAddedOrRemoved(UAbilitySystemComponent* AbilitySystemComponent, FGameplayTagContainer Tags);
|
||||
|
||||
/**
|
||||
* You must call this function manually when you want the AsyncTask to end. For UMG Widgets, you would call it in the Widget's Destruct event.
|
||||
* 要结束 AsyncTask 时,必须手动调用该函数。对于 UMG Widget,您可以在 Widget 的 Destruct 事件中调用该函数。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta=(DeprecatedFunction, DeprecationMessage="Use EndAction"))
|
||||
void EndTask();
|
||||
|
||||
protected:
|
||||
virtual void EndAction() override;
|
||||
|
||||
FGameplayTagContainer Tags;
|
||||
|
||||
virtual void TagChanged(const FGameplayTag Tag, int32 NewCount);
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/Async/AbilityAsync.h"
|
||||
#include "GGA_AsyncTask_WaitGameplayAbilityActivated.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FGGA_AbilityActivatedDelegate, const UGameplayAbility*, Ability);
|
||||
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AsyncTask_WaitGameplayAbilityActivated : public UAbilityAsync
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE"))
|
||||
static UGGA_AsyncTask_WaitGameplayAbilityActivated* WaitGameplayAbilityActivated(AActor* TargetActor);
|
||||
|
||||
void HandleAbilityActivated(UGameplayAbility* Ability);
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGGA_AbilityActivatedDelegate OnAbilityActivated;
|
||||
|
||||
protected:
|
||||
virtual bool ShouldBroadcastDelegates() const override;
|
||||
virtual void Activate() override;
|
||||
virtual void EndAction() override;
|
||||
|
||||
FDelegateHandle DelegateHandle;
|
||||
};
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/Async/AbilityAsync.h"
|
||||
#include "GGA_AsyncTask_WaitGameplayAbilityEnded.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FGGA_AbilityEndedDelegate, const FAbilityEndedData&, AbilityEndedData);
|
||||
|
||||
/**
|
||||
* Given an Actor, OnAbilityEnded is triggered whenever the AbilityQuery's skill end is satisfied.
|
||||
* 给定一个Actor,只要满足AbilityQuery的技能结束,就会触发OnAbilityEnded。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AsyncTask_WaitGameplayAbilityEnded : public UAbilityAsync
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE"))
|
||||
static UGGA_AsyncTask_WaitGameplayAbilityEnded* WaitGameplayAbilityEnded(AActor* TargetActor, FGameplayTagQuery AbilityQuery);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (DefaultToSelf = "TargetActor", BlueprintInternalUseOnly = "TRUE"))
|
||||
static UGGA_AsyncTask_WaitGameplayAbilityEnded* WaitAbilitySpecHandleEnded(AActor* TargetActor, FGameplayAbilitySpecHandle AbilitySpecHandle);
|
||||
|
||||
void HandleAbilityEnded(const FAbilityEndedData& Data);
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGGA_AbilityEndedDelegate OnAbilityEnded;
|
||||
|
||||
protected:
|
||||
virtual void Activate() override;
|
||||
virtual void EndAction() override;
|
||||
|
||||
FGameplayTagQuery AbilityQuery;
|
||||
FGameplayAbilitySpecHandle AbilitySpecHandle;
|
||||
FDelegateHandle DelegateHandle;
|
||||
};
|
||||
Reference in New Issue
Block a user