第一次提交
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayAbilitySpec.h"
|
||||
#include "Abilities/GameplayAbility.h"
|
||||
#include "GGA_AbilityCost.generated.h"
|
||||
|
||||
/**
|
||||
* Base class for defining costs associated with a gameplay ability (e.g., ammo, charges).
|
||||
* 定义与游戏技能相关成本的基类(例如弹药、次数)。
|
||||
*/
|
||||
UCLASS(Blueprintable, DefaultToInstanced, EditInlineNew, Abstract)
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilityCost : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor for the ability cost.
|
||||
* 技能成本构造函数。
|
||||
*/
|
||||
UGGA_AbilityCost()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the ability cost can be afforded.
|
||||
* 检查是否能支付技能成本。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param OptionalRelevantTags Tags for failure reasons (optional, output). 失败原因标签(可选,输出)。
|
||||
* @return True if the cost can be paid, false otherwise. 如果成本可支付则返回true,否则返回false。
|
||||
*/
|
||||
virtual bool CheckCost(const UGameplayAbility* Ability, const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, FGameplayTagContainer* OptionalRelevantTags) const;
|
||||
|
||||
/**
|
||||
* Applies the ability cost to the target.
|
||||
* 将技能成本应用于目标。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
*/
|
||||
virtual void ApplyCost(const UGameplayAbility* Ability, const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo);
|
||||
|
||||
/**
|
||||
* Checks if the cost should only be applied on a successful hit.
|
||||
* 检查成本是否仅在成功命中时应用。
|
||||
* @return True if the cost applies only on hit, false otherwise. 如果成本仅在命中时应用则返回true,否则返回false。
|
||||
*/
|
||||
bool ShouldOnlyApplyCostOnHit() const { return bOnlyApplyCostOnHit; }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Blueprint event for checking the ability cost.
|
||||
* 检查技能成本的蓝图事件。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param OptionalRelevantTags Tags for failure reasons. 失败原因标签。
|
||||
* @return True if the cost can be paid, false otherwise. 如果成本可支付则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category=Costs, meta=(DisplayName="Check Cost"))
|
||||
bool BlueprintCheckCost(const UGameplayAbility* Ability, const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo& ActorInfo,
|
||||
const FGameplayTagContainer& OptionalRelevantTags) const;
|
||||
|
||||
/**
|
||||
* Blueprint event for applying the ability cost.
|
||||
* 应用技能成本的蓝图事件。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category=Costs, meta=(DisplayName="Apply Cost"))
|
||||
void BlueprintApplyCost(const UGameplayAbility* Ability, const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo& ActorInfo, const FGameplayAbilityActivationInfo& ActivationInfo);
|
||||
|
||||
/**
|
||||
* Determines if the cost applies only on a successful hit.
|
||||
* 确定成本是否仅在成功命中时应用。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category=Costs)
|
||||
bool bOnlyApplyCostOnHit = false;
|
||||
};
|
||||
@@ -0,0 +1,321 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ActiveGameplayEffectHandle.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "GameplayAbilitySpecHandle.h"
|
||||
#include "GGA_AbilitySet.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogGGA_AbilitySet, Log, All)
|
||||
|
||||
class UGameplayEffect;
|
||||
class UGameplayAbility;
|
||||
class UGAbilitySystemComponent;
|
||||
class UObject;
|
||||
|
||||
/**
|
||||
* Struct for granting gameplay abilities in an ability set.
|
||||
* 用于在技能集赋予游戏技能的结构体。
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_AbilitySet_GameplayAbility
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* The gameplay ability class to grant.
|
||||
* 要赋予的技能类。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA", BlueprintReadWrite, meta=(AllowAbstract=false))
|
||||
TSoftClassPtr<UGameplayAbility> Ability = nullptr;
|
||||
|
||||
/**
|
||||
* The level of the ability to grant.
|
||||
* 要赋予的技能等级。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA", BlueprintReadWrite)
|
||||
int32 AbilityLevel = 1;
|
||||
|
||||
/**
|
||||
* The input ID for activating/cancelling the ability.
|
||||
* 用于激活/取消技能的输入ID。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA", BlueprintReadWrite)
|
||||
int32 InputID = -1;
|
||||
|
||||
/**
|
||||
* Dynamic tags to add to the ability.
|
||||
* 添加到技能的动态标签。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA", BlueprintReadWrite)
|
||||
FGameplayTagContainer DynamicTags;
|
||||
|
||||
#if WITH_EDITORONLY_DATA
|
||||
/**
|
||||
* Generates an editor-friendly name.
|
||||
* 生成编辑器友好的名称。
|
||||
*/
|
||||
void MakeEditorFriendlyName();
|
||||
|
||||
/**
|
||||
* Editor-friendly name for the ability.
|
||||
* 技能的编辑器友好名称。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category=AlwaysHidden, Meta=(EditCondition=False, EditConditionHides))
|
||||
FString EditorFriendlyName;
|
||||
|
||||
/**
|
||||
* Toggles whether the ability is granted (editor-only, for debugging).
|
||||
* 切换是否赋予技能(仅编辑器,用于调试)。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA")
|
||||
bool bAbilityEnabled{true};
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct for granting gameplay effects in an ability set.
|
||||
* 用于在技能集赋予游戏效果的结构体。
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_AbilitySet_GameplayEffect
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* The gameplay effect class to grant.
|
||||
* 要赋予的效果类。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Category = "GGA")
|
||||
TSoftClassPtr<UGameplayEffect> GameplayEffect = nullptr;
|
||||
|
||||
/**
|
||||
* The level of the gameplay effect to grant.
|
||||
* 要赋予的效果等级。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Category = "GGA")
|
||||
float EffectLevel = 1.0f;
|
||||
|
||||
#if WITH_EDITORONLY_DATA
|
||||
/**
|
||||
* Generates an editor-friendly name.
|
||||
* 生成编辑器友好的名称。
|
||||
*/
|
||||
void MakeEditorFriendlyName();
|
||||
|
||||
/**
|
||||
* Editor-friendly name for the effect.
|
||||
* 效果的编辑器友好名称。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category=AlwaysHidden, Meta=(EditCondition=False, EditConditionHides))
|
||||
FString EditorFriendlyName;
|
||||
|
||||
/**
|
||||
* Toggles whether the effect is granted (editor-only, for debugging).
|
||||
* 切换是否赋予效果(仅编辑器,用于调试)。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA")
|
||||
bool bEffectEnabled{true};
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct for granting attribute sets in an ability set.
|
||||
* 用于在技能集赋予属性集的结构体。
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_AbilitySet_AttributeSet
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* The attribute set class to grant.
|
||||
* 要赋予的属性集类。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Category = "GGA")
|
||||
TSoftClassPtr<UAttributeSet> AttributeSet;
|
||||
|
||||
#if WITH_EDITORONLY_DATA
|
||||
/**
|
||||
* Generates an editor-friendly name.
|
||||
* 生成编辑器友好的名称。
|
||||
*/
|
||||
void MakeEditorFriendlyName();
|
||||
|
||||
/**
|
||||
* Editor-friendly name for the attribute set.
|
||||
* 属性集的编辑器友好名称。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category=AlwaysHidden, Meta=(EditCondition=False, EditConditionHides))
|
||||
FString EditorFriendlyName;
|
||||
|
||||
/**
|
||||
* Toggles whether the attribute set is granted (editor-only, for debugging).
|
||||
* 切换是否赋予属性集(仅编辑器,用于调试)。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA")
|
||||
bool bAttributeSetEnabled{true};
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct for storing handles to granted abilities, effects, and attribute sets.
|
||||
* 存储已赋予的技能、效果和属性集句柄的结构体。
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_AbilitySet_GrantedHandles
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* Adds an ability spec handle.
|
||||
* 添加技能句柄。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
*/
|
||||
void AddAbilitySpecHandle(const FGameplayAbilitySpecHandle& Handle);
|
||||
|
||||
/**
|
||||
* Adds a gameplay effect handle.
|
||||
* 添加游戏效果句柄。
|
||||
* @param Handle The gameplay effect handle. 游戏效果句柄。
|
||||
*/
|
||||
void AddGameplayEffectHandle(const FActiveGameplayEffectHandle& Handle);
|
||||
|
||||
/**
|
||||
* Adds an attribute set.
|
||||
* 添加属性集。
|
||||
* @param Set The attribute set to add. 要添加的属性集。
|
||||
*/
|
||||
void AddAttributeSet(UAttributeSet* Set);
|
||||
|
||||
/**
|
||||
* Removes granted items from an ability system component.
|
||||
* 从技能系统组件移除已赋予的项。
|
||||
* @param ASC The ability system component. 技能系统组件。
|
||||
*/
|
||||
void TakeFromAbilitySystem(UAbilitySystemComponent* ASC);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Handles to granted abilities.
|
||||
* 已赋予的技能句柄。
|
||||
*/
|
||||
UPROPERTY(BlueprintReadOnly, Category="GGA")
|
||||
TArray<FGameplayAbilitySpecHandle> AbilitySpecHandles;
|
||||
|
||||
/**
|
||||
* Handles to granted gameplay effects.
|
||||
* 已赋予的游戏效果句柄。
|
||||
*/
|
||||
UPROPERTY(BlueprintReadOnly, Category="GGA")
|
||||
TArray<FActiveGameplayEffectHandle> GameplayEffectHandles;
|
||||
|
||||
/**
|
||||
* Pointers to granted attribute sets.
|
||||
* 已赋予的属性集指针。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TArray<TObjectPtr<UAttributeSet>> GrantedAttributeSets;
|
||||
};
|
||||
|
||||
/**
|
||||
* Data asset for granting gameplay abilities, effects, and attribute sets.
|
||||
* 用于赋予游戏技能、效果和属性集的数据资产。
|
||||
*/
|
||||
UCLASS(BlueprintType, Const)
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilitySet : public UPrimaryDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor for the ability set.
|
||||
* 技能集构造函数。
|
||||
*/
|
||||
UGGA_AbilitySet(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
/**
|
||||
* Grants the ability set to an ability system component.
|
||||
* 将技能集赋予技能系统组件。
|
||||
* @param ASC The ability system component. 技能系统组件。
|
||||
* @param OutGrantedHandles Handles for granted items (output). 已赋予项的句柄(输出)。
|
||||
* @param SourceObject Optional source object. 可选的源对象。
|
||||
* @param OverrideLevel Optional level override. 可选的等级覆盖。
|
||||
*/
|
||||
void GiveToAbilitySystem(UAbilitySystemComponent* ASC, FGGA_AbilitySet_GrantedHandles* OutGrantedHandles, UObject* SourceObject = nullptr, int32 OverrideLevel = -1) const;
|
||||
|
||||
/**
|
||||
* Grants an ability set to an ability system component (static).
|
||||
* 将技能集赋予技能系统组件(静态)。
|
||||
* @param AbilitySet The ability set to grant. 要赋予的技能集。
|
||||
* @param ASC The ability system component. 技能系统组件。
|
||||
* @param SourceObject Optional source object. 可选的源对象。
|
||||
* @param OverrideLevel Optional level override. 可选的等级覆盖。
|
||||
* @return Handles for granted items. 已赋予项的句柄。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySet", BlueprintAuthorityOnly)
|
||||
static FGGA_AbilitySet_GrantedHandles GiveAbilitySetToAbilitySystem(TSoftObjectPtr<UGGA_AbilitySet> AbilitySet, UAbilitySystemComponent* ASC, UObject* SourceObject, int32 OverrideLevel = -1);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySet", BlueprintAuthorityOnly)
|
||||
static TArray<FGGA_AbilitySet_GrantedHandles> GiveAbilitySetsToAbilitySystem(TArray<TSoftObjectPtr<UGGA_AbilitySet>> AbilitySets, UAbilitySystemComponent* ASC, UObject* SourceObject,
|
||||
int32 OverrideLevel = -1);
|
||||
|
||||
/**
|
||||
* Removes granted ability sets from an ability system component.
|
||||
* 从技能系统组件移除已赋予的技能集。
|
||||
* @param GrantedHandles Handles for granted items. 已赋予项的句柄。
|
||||
* @param ASC The ability system component. 技能系统组件。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySet", BlueprintAuthorityOnly)
|
||||
static void TakeAbilitySetFromAbilitySystem(UPARAM(ref)
|
||||
FGGA_AbilitySet_GrantedHandles& GrantedHandles, UAbilitySystemComponent* ASC);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySet", BlueprintAuthorityOnly)
|
||||
static void TakeAbilitySetsFromAbilitySystem(UPARAM(ref)
|
||||
TArray<FGGA_AbilitySet_GrantedHandles>& GrantedHandles, UAbilitySystemComponent* ASC);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Gameplay abilities to grant.
|
||||
* 要赋予的游戏技能。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "GGA|AbilitySet", meta=(TitleProperty=EditorFriendlyName, NoElementDuplicate))
|
||||
TArray<FGGA_AbilitySet_GameplayAbility> GrantedGameplayAbilities;
|
||||
|
||||
/**
|
||||
* Gameplay effects to grant.
|
||||
* 要赋予的游戏效果。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "GGA|AbilitySet", meta=(TitleProperty=EditorFriendlyName, NoElementDuplicate))
|
||||
TArray<FGGA_AbilitySet_GameplayEffect> GrantedGameplayEffects;
|
||||
|
||||
/**
|
||||
* Attribute sets to grant.
|
||||
* 要赋予的属性集。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "GGA|AbilitySet", meta=(TitleProperty=EditorFriendlyName, NoElementDuplicate))
|
||||
TArray<FGGA_AbilitySet_AttributeSet> GrantedAttributes;
|
||||
|
||||
#if WITH_EDITOR
|
||||
/**
|
||||
* Pre-save processing for editor.
|
||||
* 编辑器预保存处理。
|
||||
*/
|
||||
virtual void PreSave(FObjectPreSaveContext SaveContext) override;
|
||||
|
||||
/**
|
||||
* Handles property changes in the editor.
|
||||
* 处理编辑器中的属性更改。
|
||||
*/
|
||||
virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||
|
||||
/**
|
||||
* Handles chain property changes in the editor.
|
||||
* 处理编辑器中的链式属性更改。
|
||||
*/
|
||||
virtual void PostEditChangeChainProperty(FPropertyChangedChainEvent& PropertyChangedEvent) override;
|
||||
#endif
|
||||
};
|
||||
@@ -0,0 +1,452 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GGA_AbilitySystemEnumLibrary.h"
|
||||
#include "GGA_AbilitySystemStructLibrary.h"
|
||||
#include "GGA_GameplayAbilityInterface.h"
|
||||
#include "Tickable.h"
|
||||
#include "Abilities/GameplayAbility.h"
|
||||
#include "GGA_GameplayAbility.generated.h"
|
||||
|
||||
class UGGA_AbilityCost;
|
||||
|
||||
DECLARE_STATS_GROUP(TEXT("GameplayAbility"), STATGROUP_GameplayAbility, STATCAT_Advanced)
|
||||
|
||||
/**
|
||||
* Extended gameplay ability class for custom functionality.
|
||||
* 扩展的游戏技能类,提供自定义功能。
|
||||
*/
|
||||
UCLASS(Abstract)
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_GameplayAbility : public UGameplayAbility, public FTickableGameObject, public IGGA_GameplayAbilityInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
friend class UGGA_AbilitySystemComponent;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor for the gameplay ability.
|
||||
* 游戏技能构造函数。
|
||||
*/
|
||||
UGGA_GameplayAbility(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
/**
|
||||
* Updates the ability each frame.
|
||||
* 每帧更新技能逻辑。
|
||||
* @param DeltaTime Time since last frame. 自上一帧以来的时间。
|
||||
*/
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
/**
|
||||
* Retrieves the stat ID for performance tracking.
|
||||
* 获取用于性能跟踪的统计ID。
|
||||
* @return The stat ID. 统计ID。
|
||||
*/
|
||||
virtual TStatId GetStatId() const override;
|
||||
|
||||
/**
|
||||
* Checks if the ability can be ticked.
|
||||
* 检查技能是否可被Tick。
|
||||
* @return True if tickable, false otherwise. 如果可Tick则返回true,否则返回false。
|
||||
*/
|
||||
virtual bool IsTickable() const override;
|
||||
|
||||
/**
|
||||
* Blueprint event for per-frame ability updates.
|
||||
* 每帧技能更新的蓝图事件。
|
||||
* @param DeltaTime Time since last frame. 自上一帧以来的时间。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "GGA|Ability")
|
||||
void AbilityTick(float DeltaTime);
|
||||
virtual void AbilityTick_Implementation(float DeltaTime);
|
||||
|
||||
/**
|
||||
* Checks if the input bound to this ability is pressed.
|
||||
* 检查绑定到此技能的输入是否被按下。
|
||||
* @return True if the input is pressed, false otherwise. 如果输入被按下则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Ability|Input")
|
||||
virtual bool IsInputPressed() const;
|
||||
|
||||
/**
|
||||
* Retrieves the controller associated with this ability.
|
||||
* 获取与此技能相关的控制器。
|
||||
* @return The controller. 控制器。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Ability")
|
||||
virtual AController* GetControllerFromActorInfo() const;
|
||||
|
||||
/**
|
||||
* Retrieves the activation group for this ability.
|
||||
* 获取此技能的激活组。
|
||||
* @return The activation group. 激活组。
|
||||
*/
|
||||
virtual EGGA_AbilityActivationGroup GetActivationGroup() const override { return ActivationGroup; }
|
||||
|
||||
/**
|
||||
* Sets the activation group for this ability.
|
||||
* 设置此技能的激活组。
|
||||
* @param NewGroup The new activation group. 新激活组。
|
||||
*/
|
||||
virtual void SetActivationGroup(EGGA_AbilityActivationGroup NewGroup) override;
|
||||
|
||||
/**
|
||||
* Attempts to activate the ability on spawn.
|
||||
* 尝试在生成时激活技能。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param Spec The ability spec. 技能规格。
|
||||
*/
|
||||
virtual void TryActivateAbilityOnSpawn(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) const override;
|
||||
|
||||
/**
|
||||
* Handles ability activation failure.
|
||||
* 处理技能激活失败。
|
||||
* @param FailedReason The reason for failure. 失败原因。
|
||||
*/
|
||||
virtual void HandleActivationFailed(const FGameplayTagContainer& FailedReason) const override;
|
||||
|
||||
/**
|
||||
* Checks if an effect container exists for a given tag.
|
||||
* 检查是否存在指定标签的效果容器。
|
||||
* @param ContainerTag The container tag to check. 要检查的容器标签。
|
||||
* @return True if the container exists, false otherwise. 如果容器存在则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|Ability|EffectContainer")
|
||||
virtual bool HasEffectContainer(FGameplayTag ContainerTag);
|
||||
|
||||
/**
|
||||
* Creates an effect container spec from the effect container map.
|
||||
* 从效果容器映射创建效果容器规格。
|
||||
* @param ContainerTag The container tag. 容器标签。
|
||||
* @param EventData The event data. 事件数据。
|
||||
* @param OverrideGameplayLevel Optional gameplay level override. 可选的游戏等级覆盖。
|
||||
* @return The effect container spec. 效果容器规格。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Ability|EffectContainer", meta = (AutoCreateRefTerm = "EventData"))
|
||||
virtual FGGA_GameplayEffectContainerSpec MakeEffectContainerSpec(FGameplayTag ContainerTag, const FGameplayEventData& EventData, int32 OverrideGameplayLevel = -1);
|
||||
|
||||
/**
|
||||
* Applies an effect container by creating and applying its spec.
|
||||
* 通过创建并应用规格来应用效果容器。
|
||||
* @param ContainerTag The container tag. 容器标签。
|
||||
* @param EventData The event data. 事件数据。
|
||||
* @param OverrideGameplayLevel Optional gameplay level override. 可选的游戏等级覆盖。
|
||||
* @return Array of active gameplay effect handles. 激活的游戏效果句柄数组。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Ability|EffectContainer", meta = (AutoCreateRefTerm = "EventData"))
|
||||
virtual TArray<FActiveGameplayEffectHandle> ApplyEffectContainer(FGameplayTag ContainerTag, const FGameplayEventData& EventData, int32 OverrideGameplayLevel = -1);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Prepares the ability for activation.
|
||||
* 为技能激活做准备。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
* @param OnGameplayAbilityEndedDelegate Delegate for ability end. 技能结束委托。
|
||||
* @param TriggerEventData Optional trigger event data. 可选的触发事件数据。
|
||||
*/
|
||||
virtual void PreActivate(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo,
|
||||
FOnGameplayAbilityEnded::FDelegate* OnGameplayAbilityEndedDelegate, const FGameplayEventData* TriggerEventData = nullptr) override;
|
||||
|
||||
/**
|
||||
* Ends the ability.
|
||||
* 结束技能。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
* @param bReplicateEndAbility Whether to replicate ability end. 是否复制技能结束。
|
||||
* @param bWasCancelled Whether the ability was cancelled. 技能是否被取消。
|
||||
*/
|
||||
virtual void EndAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, bool bReplicateEndAbility,
|
||||
bool bWasCancelled) override;
|
||||
|
||||
/**
|
||||
* Blueprint event for handling ability activation failure.
|
||||
* 处理技能激活失败的蓝图事件。
|
||||
* @param FailedReason The reason for failure. 失败原因。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintNativeEvent, Category="Ability")
|
||||
void OnActivationFailed(const FGameplayTagContainer& FailedReason) const;
|
||||
|
||||
/**
|
||||
* Checks if the ability can be activated.
|
||||
* 检查技能是否可以激活。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param SourceTags Optional source tags. 可选的源标签。
|
||||
* @param TargetTags Optional target tags. 可选的目标标签。
|
||||
* @param OptionalRelevantTags Optional relevant tags (output). 可选的相关标签(输出)。
|
||||
* @return True if the ability can be activated, false otherwise. 如果技能可激活则返回true,否则返回false。
|
||||
*/
|
||||
virtual bool CanActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayTagContainer* SourceTags,
|
||||
const FGameplayTagContainer* TargetTags, FGameplayTagContainer* OptionalRelevantTags) const override;
|
||||
|
||||
/**
|
||||
* Sets whether the ability can be canceled.
|
||||
* 设置技能是否可被取消。
|
||||
* @param bCanBeCanceled Whether the ability can be canceled. 技能是否可取消。
|
||||
*/
|
||||
virtual void SetCanBeCanceled(bool bCanBeCanceled) override;
|
||||
|
||||
/**
|
||||
* Called when the ability is granted to the ability system component.
|
||||
* 技能被授予技能系统组件时调用。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param Spec The ability spec. 技能规格。
|
||||
*/
|
||||
virtual void OnGiveAbility(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) override;
|
||||
|
||||
/**
|
||||
* Blueprint event for when the ability is granted.
|
||||
* 技能被授予时的蓝图事件。
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "Ability", DisplayName = "On Give Ability")
|
||||
void K2_OnGiveAbility();
|
||||
|
||||
/**
|
||||
* Called when the ability is removed from the ability system component.
|
||||
* 技能从技能系统组件移除时调用。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param Spec The ability spec. 技能规格。
|
||||
*/
|
||||
virtual void OnRemoveAbility(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) override;
|
||||
|
||||
/**
|
||||
* Blueprint event for when the ability is removed.
|
||||
* 技能移除时的蓝图事件。
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "Ability", DisplayName = "On Remove Ability")
|
||||
void K2_OnRemoveAbility();
|
||||
|
||||
/**
|
||||
* Called when the avatar is set for the ability.
|
||||
* 技能的化身设置时调用。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param Spec The ability spec. 技能规格。
|
||||
*/
|
||||
virtual void OnAvatarSet(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) override;
|
||||
|
||||
/**
|
||||
* Blueprint event for when the avatar is set.
|
||||
* 化身设置时的蓝图事件。
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "Ability", DisplayName = "On Avatar Set")
|
||||
void K2_OnAvatarSet();
|
||||
|
||||
/**
|
||||
* Checks if the ability should activate for a given network role.
|
||||
* 检查技能是否应为特定网络角色激活。
|
||||
* @param Role The network role. 网络角色。
|
||||
* @return True if the ability should activate, false otherwise. 如果技能应激活则返回true,否则返回false。
|
||||
*/
|
||||
virtual bool ShouldActivateAbility(ENetRole Role) const override;
|
||||
|
||||
/**
|
||||
* Blueprint event for checking if the ability should activate for a network role.
|
||||
* 检查技能是否应为网络角色激活的蓝图事件。
|
||||
* @param Role The network role. 网络角色。
|
||||
* @return True if the ability should activate, false otherwise. 如果技能应激活则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "Ability", DisplayName = "Should Activate Ability")
|
||||
bool K2_ShouldActivateAbility(ENetRole Role) const;
|
||||
|
||||
/**
|
||||
* Handles input press for the ability.
|
||||
* 处理技能的输入按下。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
*/
|
||||
virtual void InputPressed(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo) override;
|
||||
|
||||
/**
|
||||
* Blueprint event for handling input press.
|
||||
* 处理输入按下的蓝图事件。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "Ability|Input", meta=(DisplayName="On Input Pressed"))
|
||||
void K2_OnInputPressed(const FGameplayAbilitySpecHandle Handle, FGameplayAbilityActorInfo ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo);
|
||||
|
||||
/**
|
||||
* Handles input release for the ability.
|
||||
* 处理技能的输入释放。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
*/
|
||||
virtual void InputReleased(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo) override;
|
||||
|
||||
/**
|
||||
* Blueprint event for handling input release.
|
||||
* 处理输入释放的蓝图事件。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "Ability|Input", meta=(DisplayName="On Input Released"))
|
||||
void K2_OnInputReleased(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo);
|
||||
|
||||
/**
|
||||
* Checks if the ability cost can be paid.
|
||||
* 检查是否能支付技能成本。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param OptionalRelevantTags Optional relevant tags (output). 可选的相关标签(输出)。
|
||||
* @return True if the cost can be paid, false otherwise. 如果成本可支付则返回true,否则返回false。
|
||||
*/
|
||||
virtual bool CheckCost(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, OUT FGameplayTagContainer* OptionalRelevantTags = nullptr) const override;
|
||||
|
||||
/**
|
||||
* Blueprint event for checking the ability cost.
|
||||
* 检查技能成本的蓝图事件。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @return True if the cost can be paid, false otherwise. 如果成本可支付则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "Ability|Cost", meta=(DisplayName="On Check Cost"))
|
||||
bool K2_OnCheckCost(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo& ActorInfo) const;
|
||||
virtual bool K2_OnCheckCost_Implementation(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo& ActorInfo) const;
|
||||
|
||||
/**
|
||||
* Applies the ability cost.
|
||||
* 应用技能成本。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
*/
|
||||
virtual void ApplyCost(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo) const override;
|
||||
|
||||
/**
|
||||
* Retrieves the gameplay effect for the ability cost.
|
||||
* 获取技能成本的游戏效果。
|
||||
* @return The gameplay effect class. 游戏效果类。
|
||||
*/
|
||||
virtual UGameplayEffect* GetCostGameplayEffect() const override;
|
||||
|
||||
/**
|
||||
* Blueprint event for retrieving the cost gameplay effect.
|
||||
* 获取成本游戏效果的蓝图事件。
|
||||
* @return The gameplay effect class. 游戏效果类。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Ability|Cost", meta=(DisplayName="Get Cost Gameplay Effect"))
|
||||
TSubclassOf<UGameplayEffect> K2_GetCostGameplayEffect() const;
|
||||
|
||||
/**
|
||||
* Blueprint event for applying additional ability costs.
|
||||
* 应用额外技能成本的蓝图事件。
|
||||
* @param Handle The ability spec handle. 技能句柄。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
*/
|
||||
UFUNCTION(BlueprintNativeEvent, Category = "Ability|Cost", meta=(DisplayName="On Apply Cost"))
|
||||
void K2_OnApplyCost(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo& ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo) const;
|
||||
virtual void K2_OnApplyCost_Implementation(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo& ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo) const;
|
||||
|
||||
/**
|
||||
* Applies ability tags to a gameplay effect spec.
|
||||
* 将技能标签应用于游戏效果规格。
|
||||
* @param Spec The gameplay effect spec. 游戏效果规格。
|
||||
* @param AbilitySpec The ability spec. 技能规格。
|
||||
*/
|
||||
virtual void ApplyAbilityTagsToGameplayEffectSpec(FGameplayEffectSpec& Spec, FGameplayAbilitySpec* AbilitySpec) const override;
|
||||
|
||||
/**
|
||||
* Checks if the ability satisfies tag requirements.
|
||||
* 检查技能是否满足标签要求。
|
||||
* @param AbilitySystemComponent The ability system component. 技能系统组件。
|
||||
* @param SourceTags Optional source tags. 可选的源标签。
|
||||
* @param TargetTags Optional target tags. 可选的目标标签。
|
||||
* @param OptionalRelevantTags Optional relevant tags (output). 可选的相关标签(输出)。
|
||||
* @return True if requirements are satisfied, false otherwise. 如果满足要求则返回true,否则返回false。
|
||||
*/
|
||||
virtual bool DoesAbilitySatisfyTagRequirements(const UAbilitySystemComponent& AbilitySystemComponent, const FGameplayTagContainer* SourceTags, const FGameplayTagContainer* TargetTags,
|
||||
FGameplayTagContainer* OptionalRelevantTags) const override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Defines the activation group for the ability.
|
||||
* 定义技能的激活组。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "Ability")
|
||||
EGGA_AbilityActivationGroup ActivationGroup;
|
||||
|
||||
/**
|
||||
* Additional costs required to activate the ability.
|
||||
* 激活技能所需的额外成本。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, Instanced, Category = "Costs")
|
||||
TArray<TObjectPtr<UGGA_AbilityCost>> AdditionalCosts;
|
||||
|
||||
/**
|
||||
* Loose tags applied to the owner while the ability is active.
|
||||
* 技能激活时应用于所有者的松散标签。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="Tags")
|
||||
TArray<FGGA_GameplayTagCount> ActivationOwnedLooseTags;
|
||||
|
||||
/**
|
||||
* Map of gameplay effect containers, each associated with a tag.
|
||||
* 游戏效果容器映射,每个容器与一个标签关联。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GameplayEffects", meta=(ForceInlineRow))
|
||||
TMap<FGameplayTag, FGGA_GameplayEffectContainer> EffectContainerMap;
|
||||
|
||||
/**
|
||||
* Enables ticking for instanced-per-actor abilities when active.
|
||||
* 为每演员实例化的技能启用Tick,仅在技能激活时有效。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Ability")
|
||||
bool bEnableTick;
|
||||
|
||||
#pragma region Net
|
||||
|
||||
public:
|
||||
/**
|
||||
* Attempts to activate the ability with batched RPCs.
|
||||
* 尝试使用批处理RPC激活技能。
|
||||
* @param InAbilityHandle The ability handle. 技能句柄。
|
||||
* @param EndAbilityImmediately Whether to end the ability immediately. 是否立即结束技能。
|
||||
* @return True if activation was successful, false otherwise. 如果激活成功则返回true,否则返回false。
|
||||
*/
|
||||
virtual bool BatchRPCTryActivateAbility(FGameplayAbilitySpecHandle InAbilityHandle, bool EndAbilityImmediately) override;
|
||||
|
||||
/**
|
||||
* Ends the ability externally.
|
||||
* 外部结束技能。
|
||||
*/
|
||||
virtual void ExternalEndAbility() override;
|
||||
|
||||
/**
|
||||
* Sends target data to the server from the predicting client.
|
||||
* 从预测客户端向服务器发送目标数据。
|
||||
* @note This call will create a prediction key. 此调用会创建一个预测Key。
|
||||
* @param TargetData The target data to send. 要发送的目标数据。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "Ability|Net")
|
||||
virtual void SendTargetDataToServer(const FGameplayAbilityTargetDataHandle& TargetData);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region DataValidation
|
||||
#if WITH_EDITOR
|
||||
/**
|
||||
* Validates data in the editor.
|
||||
* 在编辑器中验证数据。
|
||||
* @param Context The data validation context. 数据验证上下文。
|
||||
* @return The validation result. 验证结果。
|
||||
*/
|
||||
virtual EDataValidationResult IsDataValid(FDataValidationContext& Context) const override;
|
||||
|
||||
/**
|
||||
* Pre-save processing for editor.
|
||||
* 编辑器预保存处理。
|
||||
*/
|
||||
virtual void PreSave(FObjectPreSaveContext SaveContext) override;
|
||||
#endif
|
||||
#pragma endregion
|
||||
};
|
||||
@@ -0,0 +1,77 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GGA_AbilitySystemEnumLibrary.h"
|
||||
#include "Abilities/GameplayAbilityTypes.h"
|
||||
#include "UObject/Interface.h"
|
||||
#include "GGA_GameplayAbilityInterface.generated.h"
|
||||
|
||||
/**
|
||||
* Interface for gameplay abilities to integrate with GGA_AbilitySystemComponent.
|
||||
* 与GGA_AbilitySystemComponent集成的游戏技能接口。
|
||||
*/
|
||||
UINTERFACE(MinimalAPI, BlueprintType, meta=(CannotImplementInterfaceInBlueprint))
|
||||
class UGGA_GameplayAbilityInterface : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation class for gameplay ability interface.
|
||||
* 游戏技能接口的实现类。
|
||||
*/
|
||||
class GENERICGAMEPLAYABILITIES_API IGGA_GameplayAbilityInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Retrieves the activation group for the ability.
|
||||
* 获取技能的激活组。
|
||||
* @return The activation group. 激活组。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="Ability")
|
||||
virtual EGGA_AbilityActivationGroup GetActivationGroup() const = 0;
|
||||
|
||||
/**
|
||||
* Sets the activation group for the ability.
|
||||
* 设置技能的激活组。
|
||||
* @param NewGroup The new activation group. 新激活组。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="Ability")
|
||||
virtual void SetActivationGroup(EGGA_AbilityActivationGroup NewGroup) = 0;
|
||||
|
||||
/**
|
||||
* Attempts to activate the ability on spawn.
|
||||
* 尝试在生成时激活技能。
|
||||
* @param ActorInfo The actor info. Actor信息。
|
||||
* @param Spec The ability spec. 技能规格。
|
||||
*/
|
||||
virtual void TryActivateAbilityOnSpawn(const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilitySpec& Spec) const = 0;
|
||||
|
||||
/**
|
||||
* Handles ability activation failure.
|
||||
* 处理技能激活失败。
|
||||
* @param FailureReason The reason for failure. 失败原因。
|
||||
*/
|
||||
virtual void HandleActivationFailed(const FGameplayTagContainer& FailureReason) const = 0;
|
||||
|
||||
/**
|
||||
* Attempts to activate the ability with batched RPCs.
|
||||
* 尝试使用批处理RPC激活技能。
|
||||
* @param InAbilityHandle The ability handle. 技能句柄。
|
||||
* @param EndAbilityImmediately Whether to end the ability immediately. 是否立即结束技能。
|
||||
* @return True if activation was successful, false otherwise. 如果激活成功则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "Ability|Net")
|
||||
virtual bool BatchRPCTryActivateAbility(FGameplayAbilitySpecHandle InAbilityHandle, bool EndAbilityImmediately) = 0;
|
||||
|
||||
/**
|
||||
* Ends the ability externally.
|
||||
* 外部结束技能。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="Ability")
|
||||
virtual void ExternalEndAbility() = 0;
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/Tasks/AbilityTask_NetworkSyncPoint.h"
|
||||
#include "GGA_AbilityTask_NetworkSyncPoint.generated.h"
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FGGA_SyncTimeOutDelegate);
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilityTask_NetworkSyncPoint : public UAbilityTask_NetworkSyncPoint
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
*
|
||||
* Synchronize execution flow between Client and Server. Depending on SyncType, the Client and Server will wait for the other to reach this node or another WaitNetSync node in the ability before continuing execution.
|
||||
*
|
||||
* BothWait - Both Client and Server will wait until the other reaches the node. (Whoever gets their first, waits for the other before continueing).
|
||||
* OnlyServerWait - Only server will wait for the client signal. Client will signal and immediately continue without waiting to hear from Server.
|
||||
* OnlyClientWait - Only client will wait for the server signal. Server will signal and immediately continue without waiting to hear from Client.
|
||||
*
|
||||
* Note that this is "ability instance wide". These sync points never affect sync points in other abilities.
|
||||
*
|
||||
* In most cases you will have both client and server execution paths connected to the same WaitNetSync node. However it is possible to use separate nodes
|
||||
* for cleanliness of the graph. The "signal" is "ability instance wide".
|
||||
*
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="Ability|Tasks", meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE"))
|
||||
static UGGA_AbilityTask_NetworkSyncPoint* WaitNetSyncWithTimeout(UGameplayAbility* OwningAbility, EAbilityTaskNetSyncType SyncType, float WaitTime = 0.2f);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
protected:
|
||||
void OnTimeFinish();
|
||||
|
||||
|
||||
float Time;
|
||||
float TimeStarted;
|
||||
};
|
||||
@@ -0,0 +1,223 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Animation/AnimInstance.h"
|
||||
#include "Abilities/Tasks/AbilityTask.h"
|
||||
#include "GGA_AbilityTask_PlayMontageAndWaitForEvent.generated.h"
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FGGA_PlayMontageAndWaitForEventTaskParams
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* Set to override the name of this task, for later querying
|
||||
* 为此任务设置重载名,以便以后查询
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
FName TaskInstanceName;
|
||||
|
||||
/**
|
||||
* The montage to play on the character
|
||||
* 角色要播放的蒙太奇。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
TObjectPtr<UAnimMontage> MontageToPlay = nullptr;
|
||||
|
||||
/**
|
||||
* Any gameplay events matching this tag will activate the EventReceived callback. If empty, all events will trigger callback
|
||||
* 任何与此标签匹配的游戏事件都将激活 EventReceived 回调。如果为空,所有事件都将触发回调
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
FGameplayTagContainer EventTags;
|
||||
|
||||
/**
|
||||
* Change to play the montage faster or slower
|
||||
* 更改蒙太奇的播放速度快慢
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
float Rate = 1.f;
|
||||
|
||||
/**
|
||||
* If not empty, named montage section to start from
|
||||
* 如果不为空,则从命名的蒙太奇部分开始播放
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
FName StartSection = NAME_None;
|
||||
|
||||
/**
|
||||
* If true, this montage will be aborted if the ability ends normally. It is always stopped when the ability is explicitly cancelled
|
||||
* 如果为 "true",那么Ability正常结束时,蒙太奇会中止。当该Ability被明确取消时,蒙太奇总是会停止。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
bool bStopWhenAbilityEnds = true;
|
||||
|
||||
/**
|
||||
* Change to modify size of root motion or set to 0 to block it entirely
|
||||
* 更改以修改根运动的大小,或设置为 0 以完全阻止它
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
float AnimRootMotionTranslationScale = 1.f;
|
||||
|
||||
/**
|
||||
* Starting time offset in montage, this will be overridden by StartSection if that is also set
|
||||
* 蒙太奇中的起始时间偏移,如果也设置了 StartSection,则会被 StartSection 覆盖
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
float StartTimeSeconds = 0.f;
|
||||
|
||||
/**
|
||||
* If true, you can receive OnInterrupted after an OnBlendOut started (otherwise OnInterrupted will not fire when interrupted, but you will not get OnComplete).
|
||||
* 如果为 "true",则可以在 OnBlendOut 开始后接收 OnInterrupted(否则,被中断时不会触发 OnInterrupted,但也不会收到 OnComplete)。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
bool bAllowInterruptAfterBlendOut = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* This task combines PlayMontageAndWait and WaitForEvent into one task, so you can wait for multiple types of activations such as from a melee combo
|
||||
* Much of this code is copied from one of those two ability tasks
|
||||
* This is a good task to look at as an example when creating game-specific tasks
|
||||
* It is expected that each game will have a set of game-specific tasks to do what they want
|
||||
* 此任务将 PlayMontageAndWait 和 WaitForEvent 合并为一个任务,因此您可以等待多种类型的激活,例如来自近战连击的激活。
|
||||
* 本任务的大部分代码都是从这两个能力任务中的一个复制过来的
|
||||
* 在创建特定游戏任务时,这是一个很好的任务示例
|
||||
* 预计每个游戏都会有一套特定于游戏的任务来完成他们想要做的事情
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilityTask_PlayMontageAndWaitForEvent : public UAbilityTask
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Constructor and overrides
|
||||
UGGA_AbilityTask_PlayMontageAndWaitForEvent(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
/** Delegate type used, EventTag and Payload may be empty if it came from the montage callbacks */
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FPlayMontageAndWaitForEventDelegate, FGameplayTag, EventTag, FGameplayEventData, EventData);
|
||||
|
||||
/** The montage completely finished playing */
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FPlayMontageAndWaitForEventDelegate OnCompleted;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FPlayMontageAndWaitForEventDelegate OnBlendedIn;
|
||||
|
||||
/** The montage started blending out */
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FPlayMontageAndWaitForEventDelegate OnBlendOut;
|
||||
|
||||
/** The montage was interrupted */
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FPlayMontageAndWaitForEventDelegate OnInterrupted;
|
||||
|
||||
/** The ability task was explicitly cancelled by another ability */
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FPlayMontageAndWaitForEventDelegate OnCancelled;
|
||||
|
||||
/** One of the triggering gameplay events happened */
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FPlayMontageAndWaitForEventDelegate EventReceived;
|
||||
|
||||
UFUNCTION()
|
||||
void OnMontageBlendedIn(UAnimMontage* Montage);
|
||||
|
||||
UFUNCTION()
|
||||
void OnMontageBlendingOut(UAnimMontage* Montage, bool bInterrupted);
|
||||
|
||||
/** Callback function for when the owning Gameplay Ability is cancelled */
|
||||
UFUNCTION()
|
||||
void OnGameplayAbilityCancelled();
|
||||
|
||||
void OnMontageEnded(UAnimMontage* Montage, bool bInterrupted);
|
||||
|
||||
void OnGameplayEvent(FGameplayTag EventTag, const FGameplayEventData* Payload);
|
||||
|
||||
/**
|
||||
* See PlayMontageAndWaitForEventExt for details。
|
||||
* 查看 PlayMontageAndWaitForEventExt 以获得更多注释。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE"))
|
||||
static UGGA_AbilityTask_PlayMontageAndWaitForEvent* PlayMontageAndWaitForEvent(
|
||||
UGameplayAbility* OwningAbility,
|
||||
FName TaskInstanceName,
|
||||
UAnimMontage* MontageToPlay,
|
||||
FGameplayTagContainer EventTags,
|
||||
float Rate = 1.f,
|
||||
FName StartSection = NAME_None,
|
||||
bool bStopWhenAbilityEnds = true,
|
||||
float AnimRootMotionTranslationScale = 1.f,
|
||||
float StartTimeSeconds = 0.f,
|
||||
bool bAllowInterruptAfterBlendOut = false);
|
||||
|
||||
/**
|
||||
* Play a montage and wait for it end. If a gameplay event happens that matches EventTags (or EventTags is empty), the EventReceived delegate will fire with a tag and event data.
|
||||
* If StopWhenAbilityEnds is true, this montage will be aborted if the ability ends normally. It is always stopped when the ability is explicitly cancelled.
|
||||
* On normal execution, OnBlendOut is called when the montage is blending out, and OnCompleted when it is completely done playing
|
||||
* OnInterrupted is called if another montage overwrites this, and OnCancelled is called if the ability or task is cancelled
|
||||
* 播放蒙太奇并等待结束。如果发生了符合 EventTags 的游戏事件(或 EventTags 为空),EventReceived 委托就会触发,并带有标签和事件数据。
|
||||
* 如果 StopWhenAbilityEnds 为 true,那么如果能力正常结束,蒙太奇将会中止。当能力被明确取消时,蒙太奇始终会停止。
|
||||
* 在正常执行时,蒙太奇混合结束时会调用 OnBlendOut,完全结束时会调用 OnCompleted。
|
||||
* 如果其他蒙太奇覆盖了该功能,则调用 OnInterrupted,如果取消了该功能或任务,则调用 OnCancelled。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE"))
|
||||
static UGGA_AbilityTask_PlayMontageAndWaitForEvent* PlayMontageAndWaitForEventExt(UGameplayAbility* OwningAbility, FGGA_PlayMontageAndWaitForEventTaskParams Params);
|
||||
|
||||
/**
|
||||
* The Blueprint node for this task, PlayMontageAndWaitForEvent, has some black magic from the plugin that automagically calls Activate()
|
||||
* inside of K2Node_LatentAbilityCall as stated in the AbilityTask.h. Ability logic written in C++ probably needs to call Activate() itself manually.
|
||||
*/
|
||||
virtual void Activate() override;
|
||||
|
||||
/** Called when the ability is asked to cancel from an outside node. What this means depends on the individual task. By default, this does nothing other than ending the task. */
|
||||
virtual void ExternalCancel() override;
|
||||
|
||||
virtual FString GetDebugString() const override;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="GGA|Tasks")
|
||||
void EndTaskByOwner();
|
||||
|
||||
protected:
|
||||
virtual void OnDestroy(bool AbilityEnded) override;
|
||||
|
||||
/** Checks if the ability is playing a montage and stops that montage, returns true if a montage was stopped, false if not. */
|
||||
bool StopPlayingMontage();
|
||||
|
||||
FOnMontageBlendedInEnded BlendedInDelegate;
|
||||
FOnMontageBlendingOutStarted BlendingOutDelegate;
|
||||
FOnMontageEnded MontageEndedDelegate;
|
||||
FDelegateHandle InterruptedHandle;
|
||||
FDelegateHandle EventHandle;
|
||||
|
||||
/** Montage that is playing */
|
||||
UPROPERTY()
|
||||
TObjectPtr<UAnimMontage> MontageToPlay;
|
||||
|
||||
/** List of tags to match against gameplay events */
|
||||
UPROPERTY()
|
||||
FGameplayTagContainer EventTags;
|
||||
|
||||
/** Playback rate */
|
||||
UPROPERTY()
|
||||
float Rate;
|
||||
|
||||
/** Section to start montage from */
|
||||
UPROPERTY()
|
||||
FName StartSection;
|
||||
|
||||
/** Modifies how root motion movement to apply */
|
||||
UPROPERTY()
|
||||
float AnimRootMotionTranslationScale;
|
||||
|
||||
UPROPERTY()
|
||||
float StartTimeSeconds;
|
||||
|
||||
/** Rather montage should be aborted if ability ends */
|
||||
UPROPERTY()
|
||||
bool bStopWhenAbilityEnds;
|
||||
|
||||
UPROPERTY()
|
||||
bool bAllowInterruptAfterBlendOut;
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
//// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
//
|
||||
//#pragma once
|
||||
//
|
||||
//#include "CoreMinimal.h"
|
||||
//#include "Abilities/Tasks/AbilityTask.h"
|
||||
//#include "Runtime/Launch/Resources/Version.h"
|
||||
//#if ENGINE_MINOR_VERSION < 5
|
||||
//#include "InstancedStruct.h"
|
||||
//#else
|
||||
//#include "StructUtils/InstancedStruct.h"
|
||||
//#endif
|
||||
//#include "GGA_AbilityTask_RunCustomAbilityTask.generated.h"
|
||||
//
|
||||
//
|
||||
//class UGGA_CustomAbilityTask;
|
||||
//DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FGGA_CustomAbilityTaskDelegate, const FGameplayTag, EventTag, const FInstancedStruct&, Payload);
|
||||
//
|
||||
///**
|
||||
// * A special ability task runs GGA_CustomAbilityTask internally.
|
||||
// */
|
||||
//UCLASS()
|
||||
//class GENERICGAMEPLAYABILITIES_API UGGA_AbilityTask_RunCustomAbilityTask : public UAbilityTask
|
||||
//{
|
||||
// GENERATED_BODY()
|
||||
//
|
||||
//public:
|
||||
// UGGA_AbilityTask_RunCustomAbilityTask();
|
||||
//
|
||||
// UPROPERTY(BlueprintAssignable)
|
||||
// FGGA_CustomAbilityTaskDelegate OnEvent;
|
||||
//
|
||||
// virtual void GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const override;
|
||||
//
|
||||
// // Like WaitDelay but only delays one frame (tick).
|
||||
// UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE"))
|
||||
// static UGGA_AbilityTask_RunCustomAbilityTask* RunCustomAbilityTask(UGameplayAbility* OwningAbility, TSoftClassPtr<UGGA_CustomAbilityTask> AbilityTaskClass);
|
||||
//
|
||||
// virtual void Activate() override;
|
||||
// virtual void TickTask(float DeltaTime) override;
|
||||
// virtual void OnDestroy(bool bInOwnerFinished) override;
|
||||
//
|
||||
// virtual void InitSimulatedTask(UGameplayTasksComponent& InGameplayTasksComponent) override;
|
||||
//
|
||||
//private:
|
||||
// UPROPERTY(Replicated)
|
||||
// TObjectPtr<UGGA_CustomAbilityTask> TaskInstance{nullptr};
|
||||
//};
|
||||
@@ -0,0 +1,37 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/Tasks/AbilityTask.h"
|
||||
#include "Abilities/Tasks/AbilityTask_WaitTargetData.h"
|
||||
#include "GGA_AbilityTask_ServerWaitForClientTargetData.generated.h"
|
||||
|
||||
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilityTask_ServerWaitForClientTargetData : public UAbilityTask
|
||||
{
|
||||
|
||||
GENERATED_UCLASS_BODY()
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FWaitTargetDataDelegate ValidData;
|
||||
|
||||
/**
|
||||
* The server side waits for target data from the client.
|
||||
* Client execution of this node will return directly from ActivatePin and continue execution
|
||||
* 服务端等待客户端的目标数据。
|
||||
* 客户端执行这个节点会直接从ActivatePin返回并继续执行
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "true", HideSpawnParms = "Instigator"), Category = "GGA|Tasks")
|
||||
static UGGA_AbilityTask_ServerWaitForClientTargetData* ServerWaitForClientTargetData(UGameplayAbility* OwningAbility, FName TaskInstanceName, bool TriggerOnce);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
UFUNCTION()
|
||||
void OnTargetDataReplicatedCallback(const FGameplayAbilityTargetDataHandle& Data, FGameplayTag ActivationTag);
|
||||
|
||||
protected:
|
||||
virtual void OnDestroy(bool AbilityEnded) override;
|
||||
|
||||
bool bTriggerOnce;
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/Tasks/AbilityTask.h"
|
||||
#include "GGA_AbilityTask_WaitDelayOneFrame.generated.h"
|
||||
|
||||
|
||||
/**
|
||||
* Like WaitDelay but only delays one frame (tick).
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilityTask_WaitDelayOneFrame : public UAbilityTask
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FWaitDelayOneFrameDelegate);
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FWaitDelayOneFrameDelegate OnFinish;
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
// Like WaitDelay but only delays one frame (tick).
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE"))
|
||||
static UGGA_AbilityTask_WaitDelayOneFrame* WaitDelayOneFrame(UGameplayAbility* OwningAbility);
|
||||
|
||||
private:
|
||||
void OnDelayFinish();
|
||||
};
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "Abilities/GameplayAbilityTypes.h"
|
||||
#include "Abilities/Tasks/AbilityTask.h"
|
||||
#include "GGA_AbilityTask_WaitGameplayEvents.generated.h"
|
||||
|
||||
class UAbilitySystemComponent;
|
||||
|
||||
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilityTask_WaitGameplayEvents : public UAbilityTask
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FWaitGameplayEventsDelegate, FGameplayTag, EventTag, FGameplayEventData, EventData);
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FWaitGameplayEventsDelegate EventReceived;
|
||||
|
||||
/**
|
||||
* Wait until the specified gameplay tags event is triggered. By default this will look at the owner of this ability. OptionalExternalTarget can be set to make this look at another actor's tags for changes
|
||||
* It will keep listening as long as OnlyTriggerOnce = false
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE"))
|
||||
static UGGA_AbilityTask_WaitGameplayEvents* WaitGameplayEvents(UGameplayAbility* OwningAbility, FGameplayTagContainer EventTags, AActor* OptionalExternalTarget = nullptr,
|
||||
bool OnlyTriggerOnce = false);
|
||||
|
||||
void SetExternalTarget(AActor* Actor);
|
||||
|
||||
UAbilitySystemComponent* GetTargetASC();
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
virtual void GameplayEventContainerCallback(FGameplayTag MatchingTag, const FGameplayEventData* Payload);
|
||||
|
||||
void OnDestroy(bool AbilityEnding) override;
|
||||
|
||||
/** List of tags to match against gameplay events */
|
||||
UPROPERTY()
|
||||
FGameplayTagContainer EventTags;
|
||||
|
||||
UPROPERTY()
|
||||
TObjectPtr<UAbilitySystemComponent> OptionalExternalTarget;
|
||||
|
||||
bool UseExternalTarget;
|
||||
bool OnlyTriggerOnce;
|
||||
|
||||
FDelegateHandle MyHandle;
|
||||
};
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/Tasks/AbilityTask.h"
|
||||
#include "GGA_AbilityTask_WaitInputPressWithTags.generated.h"
|
||||
|
||||
|
||||
/**
|
||||
* Waits until the input is pressed from activating an ability and the ASC has the required tags and not the ignored tags.
|
||||
* This should be true immediately upon starting the ability, since the key was pressed to activate it. We expect server to
|
||||
* execute this task in parallel and keep its own time.
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilityTask_WaitInputPressWithTags : public UAbilityTask
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FInputPressWithTagsDelegate, float, TimeWaited);
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FInputPressWithTagsDelegate OnPress;
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
UFUNCTION()
|
||||
void OnPressCallback();
|
||||
|
||||
/**
|
||||
* Wait until the user presses the input button for this ability's activation. Returns time this node spent waiting for the press. Will return 0 if input was already down.
|
||||
* This is hardcoded for GA_InteractPassive to not fire when State.Interacting TagCount is > State.InteractingRemoval TagCount.
|
||||
* //TODO Ideally the RequiredTags, IgnoredTags, and State.Interacting TagCount would get moved into a subclass of FGameplayTagQuery and then we'd only expose that as one
|
||||
* parameter and rename the task to WaitInputPress_Query.
|
||||
*
|
||||
* @param RequiredTags Ability Owner must have all of these tags otherwise the input is ignored.
|
||||
* @param IgnoredTags Ability Owner cannot have any of these tags otherwise the input is ignored.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks",
|
||||
meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE", DeprecatedFunction, DeprecationMessage="Use WaitInputPressWithTagQuery"))
|
||||
static UGGA_AbilityTask_WaitInputPressWithTags* WaitInputPressWithTags(UGameplayAbility* OwningAbility, FGameplayTagContainer RequiredTags, FGameplayTagContainer IgnoredTags,
|
||||
bool bTestAlreadyPressed = false);
|
||||
|
||||
/**
|
||||
* Wait until the user presses the input button for this ability's activation. Returns time this node spent waiting for the press. Will return 0 if input was already down.
|
||||
* @param OwningAbility The ability owning this task.
|
||||
* @param TagQuery Ability Owner must match this tag query otherwise the input is ignored.
|
||||
* @param bTestAlreadyPressed Test if already pressed.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks",
|
||||
meta = (HidePin = "OwningAbility", DefaultToSelf = "OwningAbility", BlueprintInternalUseOnly = "TRUE", DeprecatedFunction, DeprecationMessage="Use WaitInputPressWithQuery"))
|
||||
static UGGA_AbilityTask_WaitInputPressWithTags* WaitInputPressWithTagQuery(UGameplayAbility* OwningAbility, const FGameplayTagQuery& TagQuery, bool bTestAlreadyPressed = false);
|
||||
|
||||
protected:
|
||||
float StartTime;
|
||||
bool bTestInitialState;
|
||||
FDelegateHandle DelegateHandle;
|
||||
|
||||
FGameplayTagQuery TagQuery;
|
||||
|
||||
virtual void OnDestroy(bool AbilityEnded) override;
|
||||
|
||||
/**
|
||||
* We can only listen for one input pressed event. I think it's because
|
||||
* UAbilitySystemComponent::InvokeReplicatedEvent sets ReplicatedData->GenericEvents[(uint8)EventType].bTriggered = true;
|
||||
* So if we want to keep listening for more input events, we just clear the delegate handle and bind again.
|
||||
*/
|
||||
virtual void Reset();
|
||||
};
|
||||
@@ -0,0 +1,86 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/GameplayAbilityTargetActor.h"
|
||||
#include "Abilities/Tasks/AbilityTask.h"
|
||||
#include "GGA_AbilityTask_WaitTargetDataUsingActor.generated.h"
|
||||
|
||||
|
||||
/**
|
||||
* 从一个已经生成的TargetActor中等待TargetData,当接收到有效数据后,并不销毁这个TargetActor。
|
||||
* 是原版本的WaitTargetData的重写,并添加了bCreateKeyIfNotValidForMorePredicting的功能。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilityTask_WaitTargetDataUsingActor : public UAbilityTask
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FWaitTargetDataUsingActorDelegate, const FGameplayAbilityTargetDataHandle&,Data);
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FWaitTargetDataUsingActorDelegate ValidData;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FWaitTargetDataUsingActorDelegate Cancelled;
|
||||
|
||||
/** 传入一个已经生成的TargetActor并等待返回有效数据或者取消,这个TargetActor在使用后不会被销毁。
|
||||
*
|
||||
* @param bCreateKeyIfNotValidForMorePredicting Will create a new scoped prediction key if the current scoped prediction key is not valid for more predicting.
|
||||
* If false, it will always create a new scoped prediction key. We would want to set this to true if we want to use a potentially existing valid scoped prediction
|
||||
* key like the ability's activation key in a batched ability.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Tasks", meta=(HidePin = "OwningAbility", DefaultToSelf =
|
||||
"OwningAbility",
|
||||
BlueprintInternalUseOnly=
|
||||
"true", HideSpawnParms="Instigator"))
|
||||
static UGGA_AbilityTask_WaitTargetDataUsingActor* WaitTargetDataWithReusableActor(
|
||||
UGameplayAbility* OwningAbility, FName TaskInstanceName,
|
||||
TEnumAsByte<EGameplayTargetingConfirmation::Type> ConfirmationType,
|
||||
AGameplayAbilityTargetActor* InTargetActor, bool bCreateKeyIfNotValidForMorePrediction = false);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
/** server处理TargetDataSet事件 */
|
||||
UFUNCTION()
|
||||
virtual void OnTargetDataReplicatedCallback(const FGameplayAbilityTargetDataHandle& Data,
|
||||
FGameplayTag ActivationTag);
|
||||
/** server处理TargetDataCancelled事件 */
|
||||
UFUNCTION()
|
||||
virtual void OnTargetDataReplicatedCancelledCallback();
|
||||
|
||||
/** 玩家Confirm目标后触发(TargetActor->ConfirmTargeting) */
|
||||
UFUNCTION()
|
||||
virtual void OnTargetDataReadyCallback(const FGameplayAbilityTargetDataHandle& Data);
|
||||
|
||||
/** 玩家Cancel目标后触发(TargetActor->CancelTargeting) */
|
||||
UFUNCTION()
|
||||
virtual void OnTargetDataCancelledCallback(const FGameplayAbilityTargetDataHandle& Data);
|
||||
|
||||
// Called when the ability is asked to confirm from an outside node. What this means depends on the individual task. By default, this does nothing other than ending if bEndTask is true.
|
||||
virtual void ExternalConfirm(bool bEndTask) override;
|
||||
|
||||
// Called when the ability is asked to cancel from an outside node. What this means depends on the individual task. By default, this does nothing other than ending the task.
|
||||
virtual void ExternalCancel() override;
|
||||
|
||||
protected:
|
||||
UPROPERTY()
|
||||
TObjectPtr<AGameplayAbilityTargetActor> TargetActor;
|
||||
|
||||
bool bCreateKeyIfNotValidForMorePrediction;
|
||||
|
||||
TEnumAsByte<EGameplayTargetingConfirmation::Type> ConfirmationType;
|
||||
|
||||
virtual void InitializeTargetActor() const;
|
||||
virtual void RegisterTargetDataCallbacks();
|
||||
virtual void FinalizeTargetActor() const;
|
||||
|
||||
void OnDestroy(bool AbilityEnded) override;
|
||||
|
||||
/**
|
||||
* 如果是客户端且传入的TargetActor不能在服务端产生TargetData则返回真
|
||||
*/
|
||||
virtual bool ShouldReplicateDataToServer() const;
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
@@ -0,0 +1,65 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AttributeSet.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "GGA_AttributeSet.generated.h"
|
||||
|
||||
|
||||
class UGGA_AbilitySystemComponent;
|
||||
struct FGameplayEffectSpec;
|
||||
|
||||
/**
|
||||
* This macro defines a set of helper functions for accessing and initializing attributes.
|
||||
*
|
||||
* The following example of the macro:
|
||||
* ATTRIBUTE_ACCESSORS(ULyraHealthSet, Health)
|
||||
* will create the following functions:
|
||||
* static FGameplayAttribute GetHealthAttribute();
|
||||
* float GetHealth() const;
|
||||
* void SetHealth(float NewVal);
|
||||
* void InitHealth(float NewVal);
|
||||
*/
|
||||
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
|
||||
GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
|
||||
|
||||
/**
|
||||
* Delegate used to broadcast attribute events, some of these parameters may be null on clients:
|
||||
* @param EffectInstigator The original instigating actor for this event
|
||||
* @param EffectCauser The physical actor that caused the change
|
||||
* @param EffectSpec The full effect spec for this change
|
||||
* @param EffectMagnitude The raw magnitude, this is before clamping
|
||||
* @param OldValue The value of the attribute before it was changed
|
||||
* @param NewValue The value after it was changed
|
||||
*/
|
||||
DECLARE_MULTICAST_DELEGATE_SixParams(FGGA_AttributeEvent, AActor* /*EffectInstigator*/, AActor* /*EffectCauser*/, const FGameplayEffectSpec* /*EffectSpec*/, float /*EffectMagnitude*/,
|
||||
float /*OldValue*/, float /*NewValue*/);
|
||||
|
||||
|
||||
// typedef is specific to the FGameplayAttribute() signature, but TStaticFunPtr is generic to any signature chosen
|
||||
//typedef TBaseStaticDelegateInstance<FGameplayAttribute(), FDefaultDelegateUserPolicy>::FFuncPtr FAttributeFuncPtr;
|
||||
template <class T>
|
||||
using TStaticFuncPtr = typename TBaseStaticDelegateInstance<T, FDefaultDelegateUserPolicy>::FFuncPtr;
|
||||
|
||||
/**
|
||||
* UGGA_AttributeSet
|
||||
*
|
||||
* Base attribute set class for the project.
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AttributeSet : public UAttributeSet
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UGGA_AttributeSet();
|
||||
|
||||
UWorld* GetWorld() const override;
|
||||
|
||||
UGGA_AbilitySystemComponent* GetGGA_AbilitySystemComponent() const;
|
||||
};
|
||||
@@ -0,0 +1,498 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "GGA_AbilitySet.h"
|
||||
#include "GGA_AbilitySystemEnumLibrary.h"
|
||||
#include "GGA_AbilitySystemStructLibrary.h"
|
||||
#include "GGA_AbilitySystemComponent.generated.h"
|
||||
|
||||
class UGGA_AbilityTagRelationshipMapping;
|
||||
class UGGA_GameplayAbility;
|
||||
class UGGA_AbilitySet;
|
||||
|
||||
/**
|
||||
* Delegate for when the ability system is initialized.
|
||||
* 技能系统初始化时的委托。
|
||||
*/
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FGGA_AbilitySystemInitializedSignature);
|
||||
|
||||
/**
|
||||
* Delegate for when the ability system is uninitialized.
|
||||
* 技能系统取消初始化时的委托。
|
||||
*/
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FGGA_AbilitySystemUninitializedSignature);
|
||||
|
||||
/**
|
||||
* Delegate for when an ability is activated.
|
||||
* 技能激活时的委托。
|
||||
*/
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FGGA_OnAbilityActivatedSignature, const FGameplayAbilitySpecHandle, Handle, const UGameplayAbility*, Ability);
|
||||
|
||||
/**
|
||||
* Delegate for when an ability ends.
|
||||
* 技能结束时的委托。
|
||||
*/
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FGGA_OnAbilityEndedSignature, FGameplayAbilitySpecHandle, Handle, UGameplayAbility*, Ability, bool, bWasCancelled);
|
||||
|
||||
/**
|
||||
* Delegate for when an ability fails to activate.
|
||||
* 技能激活失败时的委托。
|
||||
*/
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FGGA_OnAbilityFailedSignature, const UGameplayAbility*, Ability, const FGameplayTagContainer&, ReasonTags);
|
||||
|
||||
/**
|
||||
* Extended ability system component with custom functionality.
|
||||
* 扩展的技能系统组件,包含自定义功能。
|
||||
*/
|
||||
UCLASS(ClassGroup=GGA, meta=(BlueprintSpawnableComponent))
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilitySystemComponent : public UAbilitySystemComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
#pragma region Common
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor for the ability system component.
|
||||
* 技能系统组件构造函数。
|
||||
*/
|
||||
UGGA_AbilitySystemComponent(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
/**
|
||||
* Initializes the ability system with owner and avatar actors.
|
||||
* 使用拥有者和化身演员初始化技能系统。
|
||||
* @param InOwnerActor The owner actor. 拥有者演员。
|
||||
* @param InAvatarActor The avatar actor. 化身演员。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Abilities")
|
||||
virtual void InitializeAbilitySystem(AActor* InOwnerActor, AActor* InAvatarActor);
|
||||
|
||||
/**
|
||||
* Uninitializes the ability system.
|
||||
* 取消初始化技能系统。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Abilities")
|
||||
virtual void UninitializeAbilitySystem();
|
||||
|
||||
/**
|
||||
* Initializes actor info for the ability system.
|
||||
* 初始化技能系统的Actor信息。
|
||||
* @param InOwnerActor The owner actor. 拥有者演员。
|
||||
* @param InAvatarActor The avatar actor. 化身演员。
|
||||
*/
|
||||
virtual void InitAbilityActorInfo(AActor* InOwnerActor, AActor* InAvatarActor) override;
|
||||
|
||||
/**
|
||||
* Delegate triggered when the ability system is initialized.
|
||||
* 技能系统初始化时触发的委托。
|
||||
*/
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGGA_AbilitySystemInitializedSignature OnAbilitySystemInitialized;
|
||||
|
||||
/**
|
||||
* Delegate triggered when the ability system is uninitialized.
|
||||
* 技能系统取消初始化时触发的委托。
|
||||
*/
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGGA_AbilitySystemUninitializedSignature OnAbilitySystemUninitialized;
|
||||
|
||||
/**
|
||||
* Called when the component ends play.
|
||||
* 组件结束播放时调用。
|
||||
* @param EndPlayReason The reason for ending play. 结束播放的原因。
|
||||
*/
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
|
||||
/**
|
||||
* Initializes the component.
|
||||
* 初始化组件。
|
||||
*/
|
||||
virtual void InitializeComponent() override;
|
||||
|
||||
/**
|
||||
* Initializes ability sets for the ability system.
|
||||
* 为技能系统初始化技能集。
|
||||
* @param InOwnerActor The owner actor. 拥有者演员。
|
||||
* @param InAvatarActor The avatar actor. 化身演员。
|
||||
*/
|
||||
virtual void InitializeAbilitySets(AActor* InOwnerActor, AActor* InAvatarActor);
|
||||
|
||||
/**
|
||||
* Initializes attributes for the ability system.
|
||||
* 为技能系统初始化属性。
|
||||
* @param GroupName The attribute group name. 属性组名称。
|
||||
* @param Level The level to initialize. 初始化等级。
|
||||
* @param bInitialInit Whether this is the initial initialization. 是否为初始初始化。
|
||||
*/
|
||||
virtual void InitializeAttributes(FGGA_AttributeGroupName GroupName, int32 Level, bool bInitialInit);
|
||||
|
||||
/**
|
||||
* Sends a replicated gameplay event to an actor.
|
||||
* 向演员发送复制的游戏事件。
|
||||
* @param Actor The target actor. 目标演员。
|
||||
* @param EventTag The event tag. 事件标签。
|
||||
* @param Payload The event data payload. 事件数据负载。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Abilities", meta=(DisplayName="Send Gameplay Event To Actor (Replicated)"))
|
||||
void SendGameplayEventToActor_Replicated(AActor* Actor, FGameplayTag EventTag, FGameplayEventData Payload);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Server RPC for sending gameplay events.
|
||||
* 发送游戏事件的服务器RPC。
|
||||
* @param Actor The target actor. 目标演员。
|
||||
* @param EventTag The event tag. 事件标签。
|
||||
* @param Payload The event data payload. 事件数据负载。
|
||||
*/
|
||||
UFUNCTION(Server, Reliable, WithValidation, Category = "GGA|Abilities")
|
||||
void ServerSendGameplayEventToActor(AActor* Actor, FGameplayTag EventTag, FGameplayEventData Payload);
|
||||
|
||||
/**
|
||||
* Multicast RPC for sending gameplay events.
|
||||
* 发送游戏事件的多播RPC。
|
||||
* @param Actor The target actor. 目标演员。
|
||||
* @param EventTag The event tag. 事件标签。
|
||||
* @param Payload The event data payload. 事件数据负载。
|
||||
*/
|
||||
UFUNCTION(NetMulticast, Reliable, Category = "GGA|Abilities")
|
||||
void MulticastSendGameplayEventToActor(AActor* Actor, FGameplayTag EventTag, FGameplayEventData Payload);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Post-initialization property setup.
|
||||
* 初始化后属性设置。
|
||||
*/
|
||||
virtual void PostInitProperties() override;
|
||||
|
||||
/**
|
||||
* Registers the component with the global ability system.
|
||||
* 将组件注册到全局技能系统。
|
||||
*/
|
||||
void RegisterToGlobalAbilitySystem();
|
||||
|
||||
/**
|
||||
* Unregisters the component from the global ability system.
|
||||
* 从全局技能系统取消注册组件。
|
||||
*/
|
||||
void UnregisterToGlobalAbilitySystem();
|
||||
|
||||
/**
|
||||
* Default ability sets to grant on initialization.
|
||||
* 初始化时赋予的默认技能集。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GGA|Abilities")
|
||||
TArray<TObjectPtr<const UGGA_AbilitySet>> DefaultAbilitySets;
|
||||
|
||||
/**
|
||||
* Attribute group name for initializing gameplay attributes.
|
||||
* 用于初始化游戏属性的属性组名称。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GGA|Attributes")
|
||||
FGGA_AttributeGroupName AttributeSetInitializeGroupName;
|
||||
|
||||
/**
|
||||
* Level for initializing attributes.
|
||||
* 初始化属性的等级。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GGA|Attributes", meta=(ClampMin=1))
|
||||
int32 AttributeSetInitializeLevel{1};
|
||||
|
||||
private:
|
||||
/**
|
||||
* Tracks if the ability system is initialized.
|
||||
* 跟踪技能系统是否已初始化。
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, Category = "GGA|Abilities")
|
||||
bool bAbilitySystemInitialized{false};
|
||||
|
||||
/**
|
||||
* Handles for granted default ability sets.
|
||||
* 已赋予默认技能集的句柄。
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, Category = "GGA|Abilities")
|
||||
TArray<FGGA_AbilitySet_GrantedHandles> DefaultAbilitySet_GrantedHandles;
|
||||
|
||||
/**
|
||||
* Tracks if the component is registered with the global ability system.
|
||||
* 跟踪组件是否注册到全局技能系统。
|
||||
*/
|
||||
UPROPERTY(VisibleInstanceOnly, Category = "GGA|Abilities")
|
||||
bool bRegisteredToGlobalAbilitySystem{false};
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region AbilitiesActivation
|
||||
|
||||
public:
|
||||
/**
|
||||
* Checks if an activation group is blocked.
|
||||
* 检查激活组是否被阻挡。
|
||||
* @param Group The activation group to check. 要检查的激活组。
|
||||
* @return True if blocked, false otherwise. 如果被阻挡则返回true,否则返回false。
|
||||
*/
|
||||
bool IsActivationGroupBlocked(EGGA_AbilityActivationGroup Group) const;
|
||||
|
||||
/**
|
||||
* Adds an ability to an activation group.
|
||||
* 将技能添加到激活组。
|
||||
* @param Group The activation group. 激活组。
|
||||
* @param Ability The ability to add. 要添加的技能。
|
||||
*/
|
||||
void AddAbilityToActivationGroup(EGGA_AbilityActivationGroup Group, UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Removes an ability from an activation group.
|
||||
* 从激活组移除技能。
|
||||
* @param Group The activation group. 激活组。
|
||||
* @param Ability The ability to remove. 要移除的技能。
|
||||
*/
|
||||
void RemoveAbilityFromActivationGroup(EGGA_AbilityActivationGroup Group, UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Checks if an ability can change its activation group.
|
||||
* 检查技能是否可以更改激活组。
|
||||
* @param NewGroup The new activation group. 新激活组。
|
||||
* @param Ability The ability to check. 要检查的技能。
|
||||
* @return True if the change is allowed, false otherwise. 如果允许更改则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GGA|Ability", Meta = (ExpandBoolAsExecs = "ReturnValue"))
|
||||
bool CanChangeActivationGroup(EGGA_AbilityActivationGroup NewGroup, UGameplayAbility* Ability) const;
|
||||
|
||||
/**
|
||||
* Changes the activation group of an ability.
|
||||
* 更改技能的激活组。
|
||||
* @param NewGroup The new activation group. 新激活组。
|
||||
* @param Ability The ability to change. 要更改的技能。
|
||||
* @return True if the change was successful, false otherwise. 如果更改成功则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GGA|Ability", Meta = (ExpandBoolAsExecs = "ReturnValue"))
|
||||
bool ChangeActivationGroup(EGGA_AbilityActivationGroup NewGroup, UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Delegate triggered when an ability is activated.
|
||||
* 技能激活时触发的委托。
|
||||
*/
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGGA_OnAbilityActivatedSignature OnAbilityActivated;
|
||||
|
||||
/**
|
||||
* Delegate triggered when an ability fails to activate.
|
||||
* 技能激活失败时触发的委托。
|
||||
*/
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGGA_OnAbilityFailedSignature OnAbilityActivationFailed;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Notifies when an ability is activated.
|
||||
* 技能激活时通知。
|
||||
* @param Handle The ability spec handle. 技能规格句柄。
|
||||
* @param Ability The activated ability. 激活的技能。
|
||||
*/
|
||||
virtual void NotifyAbilityActivated(const FGameplayAbilitySpecHandle Handle, UGameplayAbility* Ability) override;
|
||||
|
||||
/**
|
||||
* Notifies when an ability fails to activate.
|
||||
* 技能激活失败时通知。
|
||||
* @param Handle The ability spec handle. 技能规格句柄。
|
||||
* @param Ability The ability that failed. 失败的技能。
|
||||
* @param FailureReason The reason for failure. 失败原因。
|
||||
*/
|
||||
virtual void NotifyAbilityFailed(const FGameplayAbilitySpecHandle Handle, UGameplayAbility* Ability, const FGameplayTagContainer& FailureReason) override;
|
||||
|
||||
/**
|
||||
* Client RPC for notifying ability activation failure.
|
||||
* 通知技能激活失败的客户端RPC。
|
||||
* @param Ability The ability that failed. 失败的技能。
|
||||
* @param FailureReason The reason for failure. 失败原因。
|
||||
*/
|
||||
UFUNCTION(Client, Unreliable)
|
||||
void ClientNotifyAbilityActivationFailed(const UGameplayAbility* Ability, const FGameplayTagContainer& FailureReason);
|
||||
|
||||
/**
|
||||
* Implementation of client notification for ability activation failure.
|
||||
* 技能激活失败客户端通知的实现。
|
||||
*/
|
||||
void ClientNotifyAbilityActivationFailed_Implementation(const UGameplayAbility* Ability, const FGameplayTagContainer& FailureReason);
|
||||
|
||||
/**
|
||||
* Handles ability activation failure.
|
||||
* 处理技能激活失败。
|
||||
* @param Ability The ability that failed. 失败的技能。
|
||||
* @param FailureReason The reason for failure. 失败原因。
|
||||
*/
|
||||
virtual void HandleAbilityActivationFailed(const UGameplayAbility* Ability, const FGameplayTagContainer& FailureReason);
|
||||
|
||||
/**
|
||||
* Tracks the number of abilities in each activation group.
|
||||
* 跟踪每个激活组中的技能数量。
|
||||
*/
|
||||
int32 ActivationGroupCounts[(uint8)EGGA_AbilityActivationGroup::MAX];
|
||||
|
||||
#pragma endregion
|
||||
|
||||
public:
|
||||
/**
|
||||
* Function type for determining whether to cancel an ability.
|
||||
* 确定是否取消技能的函数类型。
|
||||
*/
|
||||
typedef TFunctionRef<bool(const UGameplayAbility* Ability, FGameplayAbilitySpecHandle Handle)> TShouldCancelAbilityFunc;
|
||||
|
||||
/**
|
||||
* Cancels abilities based on a provided function.
|
||||
* 根据提供的函数取消技能。
|
||||
* @param ShouldCancelFunc Function to determine cancellation. 确定取消的函数。
|
||||
* @param bReplicateCancelAbility Whether to replicate cancellation. 是否复制取消。
|
||||
*/
|
||||
void CancelAbilitiesByFunc(TShouldCancelAbilityFunc ShouldCancelFunc, bool bReplicateCancelAbility);
|
||||
|
||||
/**
|
||||
* Cancels abilities in a specific activation group.
|
||||
* 取消特定激活组中的技能。
|
||||
* @param Group The activation group. 激活组。
|
||||
* @param IgnoreAbility Ability to ignore. 要忽略的技能。
|
||||
* @param bReplicateCancelAbility Whether to replicate cancellation. 是否复制取消。
|
||||
*/
|
||||
void CancelActivationGroupAbilities(EGGA_AbilityActivationGroup Group, UGameplayAbility* IgnoreAbility, bool bReplicateCancelAbility);
|
||||
|
||||
/**
|
||||
* Delegate triggered when an ability ends.
|
||||
* 技能结束时触发的委托。
|
||||
*/
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FGGA_OnAbilityEndedSignature AbilityEndedEvent;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Notifies when an ability ends.
|
||||
* 技能结束时通知。
|
||||
* @param Handle The ability spec handle. 技能规格句柄。
|
||||
* @param Ability The ability that ended. 结束的技能。
|
||||
* @param bWasCancelled Whether the ability was cancelled. 技能是否被取消。
|
||||
*/
|
||||
virtual void NotifyAbilityEnded(FGameplayAbilitySpecHandle Handle, UGameplayAbility* Ability, bool bWasCancelled) override;
|
||||
|
||||
/**
|
||||
* Handles changes to whether an ability can be canceled.
|
||||
* 处理技能是否可取消的更改。
|
||||
* @param AbilityTags The ability tags. 技能标签。
|
||||
* @param RequestingAbility The requesting ability. 请求的技能。
|
||||
* @param bCanBeCanceled Whether the ability can be canceled. 技能是否可取消。
|
||||
*/
|
||||
virtual void HandleChangeAbilityCanBeCanceled(const FGameplayTagContainer& AbilityTags, UGameplayAbility* RequestingAbility, bool bCanBeCanceled) override;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Retrieves cooldown information for specified tags.
|
||||
* 获取指定标签的冷却信息。
|
||||
* @param CooldownTags The cooldown tags. 冷却标签。
|
||||
* @param TimeRemaining Remaining cooldown time (output). 剩余冷却时间(输出)。
|
||||
* @param CooldownDuration Total cooldown duration (output). 总冷却持续时间(输出)。
|
||||
* @return True if active cooldowns found, false otherwise. 如果找到激活的冷却则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Abilities")
|
||||
bool GetCooldownRemainingForTags(FGameplayTagContainer CooldownTags, float& TimeRemaining, float& CooldownDuration);
|
||||
|
||||
/**
|
||||
* Determines if server ability RPC batching is enabled.
|
||||
* 确定是否启用服务器技能RPC批处理。
|
||||
* @return True if batching is enabled. 如果启用批处理则返回true。
|
||||
*/
|
||||
virtual bool ShouldDoServerAbilityRPCBatch() const override { return true; }
|
||||
|
||||
/**
|
||||
* Attempts to activate an ability with batched RPCs.
|
||||
* 尝试使用批处理RPC激活技能。
|
||||
* @param InAbilityHandle The ability handle. 技能句柄。
|
||||
* @param EndAbilityImmediately Whether to end the ability immediately. 是否立即结束技能。
|
||||
* @return True if activation was successful, false otherwise. 如果激活成功则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Abilities")
|
||||
virtual bool BatchRPCTryActivateAbility(FGameplayAbilitySpecHandle InAbilityHandle, bool EndAbilityImmediately);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Gameplay effect replication mode.
|
||||
* 游戏效果复制模式。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GGA|GameplayEffects")
|
||||
EGameplayEffectReplicationMode AbilitySystemReplicationMode;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Retrieves owned gameplay tags.
|
||||
* 获取拥有的游戏标签。
|
||||
* @param TagContainer The container for owned tags (output). 拥有的标签容器(输出)。
|
||||
*/
|
||||
virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override;
|
||||
|
||||
/**
|
||||
* Retrieves owned gameplay tags as a string.
|
||||
* 以字符串形式获取拥有的游戏标签。
|
||||
* @return The owned tags as a string. 拥有的标签字符串。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayTags")
|
||||
FString GetOwnedGameplayTagsString();
|
||||
|
||||
/**
|
||||
* Retrieves additional required and blocked activation tags.
|
||||
* 获取额外的所需和阻止的激活标签。
|
||||
* @param AbilityTags The ability tags. 技能标签。
|
||||
* @param OutActivationRequired Required activation tags (output). 所需激活标签(输出)。
|
||||
* @param OutActivationBlocked Blocked activation tags (output). 阻止激活标签(输出)。
|
||||
*/
|
||||
virtual void GetAdditionalActivationTagRequirements(const FGameplayTagContainer& AbilityTags, FGameplayTagContainer& OutActivationRequired, FGameplayTagContainer& OutActivationBlocked) const;
|
||||
|
||||
/**
|
||||
* Applies ability block and cancel tags.
|
||||
* 应用技能阻挡和取消标签。
|
||||
* @param AbilityTags The ability tags. 技能标签。
|
||||
* @param RequestingAbility The requesting ability. 请求的技能。
|
||||
* @param bEnableBlockTags Whether to enable block tags. 是否启用阻挡标签。
|
||||
* @param BlockTags The block tags. 阻挡标签。
|
||||
* @param bExecuteCancelTags Whether to execute cancel tags. 是否执行取消标签。
|
||||
* @param CancelTags The cancel tags. 取消标签。
|
||||
*/
|
||||
virtual void ApplyAbilityBlockAndCancelTags(const FGameplayTagContainer& AbilityTags, UGameplayAbility* RequestingAbility, bool bEnableBlockTags, const FGameplayTagContainer& BlockTags,
|
||||
bool bExecuteCancelTags, const FGameplayTagContainer& CancelTags) override;
|
||||
|
||||
/**
|
||||
* Sets the tag relationship mapping.
|
||||
* 设置标签关系映射。
|
||||
* @param NewMapping The new tag relationship mapping. 新标签关系映射。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Gameplay Tags")
|
||||
void SetTagRelationshipMapping(UGGA_AbilityTagRelationshipMapping* NewMapping);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Tag relationship mapping for ability activation and cancellation.
|
||||
* 用于技能激活和取消的标签关系映射。
|
||||
*/
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GGA|Gameplay Tags")
|
||||
TObjectPtr<UGGA_AbilityTagRelationshipMapping> TagRelationshipMapping;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Retrieves owned attribute sets as a string.
|
||||
* 以字符串形式获取拥有的属性集。
|
||||
* @return The owned attribute sets as a string. 拥有的属性集字符串。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|Attributes")
|
||||
FString GetOwnedGameplayAttributeSetString();
|
||||
|
||||
#pragma region TargetData
|
||||
|
||||
public:
|
||||
/**
|
||||
* Retrieves ability target data for a given ability handle and activation info.
|
||||
* 获取指定技能句柄和激活信息的技能目标数据。
|
||||
* @param AbilityHandle The ability handle. 技能句柄。
|
||||
* @param ActivationInfo The activation info. 激活信息。
|
||||
* @param OutTargetDataHandle The target data handle (output). 目标数据句柄(输出)。
|
||||
*/
|
||||
void GetAbilityTargetData(const FGameplayAbilitySpecHandle AbilityHandle, FGameplayAbilityActivationInfo ActivationInfo, FGameplayAbilityTargetDataHandle& OutTargetDataHandle);
|
||||
#pragma endregion
|
||||
};
|
||||
@@ -0,0 +1,38 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GGA_AbilitySystemEnumLibrary.generated.h"
|
||||
|
||||
/**
|
||||
* Enum defining how an ability activates relative to other abilities.
|
||||
* 定义技能相对于其他技能的激活方式的枚举。
|
||||
*/
|
||||
UENUM(BlueprintType)
|
||||
enum class EGGA_AbilityActivationGroup : uint8
|
||||
{
|
||||
/**
|
||||
* Ability runs independently of other abilities.
|
||||
* 技能独立于其他技能运行。
|
||||
*/
|
||||
Independent,
|
||||
|
||||
/**
|
||||
* Ability is canceled and replaced by other exclusive abilities.
|
||||
* 技能被其他独占技能取消并替换。
|
||||
*/
|
||||
Exclusive_Replaceable,
|
||||
|
||||
/**
|
||||
* Ability blocks all other exclusive abilities from activating.
|
||||
* 技能阻止其他独占技能激活。
|
||||
*/
|
||||
Exclusive_Blocking,
|
||||
|
||||
/**
|
||||
* Maximum value (hidden).
|
||||
* 最大值(隐藏)。
|
||||
*/
|
||||
MAX UMETA(Hidden)
|
||||
};
|
||||
@@ -0,0 +1,214 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/GameplayAbilityTypes.h"
|
||||
#include "GGA_AbilitySystemStructLibrary.generated.h"
|
||||
|
||||
class UTargetingPreset;
|
||||
class UGameplayEffect;
|
||||
|
||||
/**
|
||||
* Struct for defining an attribute group name.
|
||||
* 定义属性组名称的结构体。
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_AttributeGroupName
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Main name of the attribute group.
|
||||
* 属性组的主名称。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
FName MainName{NAME_None};
|
||||
|
||||
/**
|
||||
* Sub-name of the attribute group.
|
||||
* 属性组的子名称。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="GGA")
|
||||
FName SubName{NAME_None};
|
||||
|
||||
/**
|
||||
* Checks if the group name is valid.
|
||||
* 检查组名称是否有效。
|
||||
* @return True if valid, false otherwise. 如果有效则返回true,否则返回false。
|
||||
*/
|
||||
bool IsValid() const { return !MainName.IsNone(); }
|
||||
|
||||
/**
|
||||
* Retrieves the combined group name.
|
||||
* 获取组合的组名称。
|
||||
* @return The combined name. 组合名称。
|
||||
*/
|
||||
FName GetName() const
|
||||
{
|
||||
FName Ref = MainName;
|
||||
if (!SubName.IsNone())
|
||||
{
|
||||
Ref = FName(*FString::Printf(TEXT("%s.%s"), *Ref.ToString(), *SubName.ToString()));
|
||||
}
|
||||
return Ref;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct for tracking gameplay tag counts.
|
||||
* 跟踪游戏标签计数的结构体。
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_GameplayTagCount
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* The gameplay tag.
|
||||
* 游戏标签。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "GGA")
|
||||
FGameplayTag Tag;
|
||||
|
||||
/**
|
||||
* The count of the tag.
|
||||
* 标签的计数。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "GGA")
|
||||
int32 Count{0};
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct for storing an array of gameplay tags.
|
||||
* 存储游戏标签数组的结构体。
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_GameplayTagArray
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* Array of gameplay tags.
|
||||
* 游戏标签数组。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "GGA")
|
||||
TArray<FGameplayTag> GameplayTags;
|
||||
|
||||
/**
|
||||
* Converts the array to a gameplay tag container.
|
||||
* 将数组转换为游戏标签容器。
|
||||
* @return The gameplay tag container. 游戏标签容器。
|
||||
*/
|
||||
FORCEINLINE FGameplayTagContainer GetGameplayTagContainer() const
|
||||
{
|
||||
return FGameplayTagContainer::CreateFromArray(GameplayTags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a tag array from a gameplay tag container.
|
||||
* 从游戏标签容器创建标签数组。
|
||||
* @param Container The gameplay tag container. 游戏标签容器。
|
||||
* @return The created tag array. 创建的标签数组。
|
||||
*/
|
||||
FORCEINLINE static FGGA_GameplayTagArray CreateFromContainer(const FGameplayTagContainer& Container)
|
||||
{
|
||||
FGGA_GameplayTagArray TagArray;
|
||||
Container.GetGameplayTagArray(TagArray.GameplayTags);
|
||||
return TagArray;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct for storing an array of gameplay effects.
|
||||
* 存储游戏效果数组的结构体。
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_GameplayEffectArray
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* Array of gameplay effect classes.
|
||||
* 游戏效果类数组。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "GGA")
|
||||
TArray<TSubclassOf<UGameplayEffect>> GameplayEffects;
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct defining a gameplay effect container with targeting info.
|
||||
* 定义带有目标信息的游戏效果容器的结构体。
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_GameplayEffectContainer
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
FGGA_GameplayEffectContainer() {}
|
||||
|
||||
/**
|
||||
* Targeting preset for the effect container.
|
||||
* 效果容器的目标预设。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GGA")
|
||||
TObjectPtr<UTargetingPreset> TargetingPreset;
|
||||
|
||||
/**
|
||||
* List of gameplay effect classes to apply.
|
||||
* 要应用的游戏效果类列表。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GGA")
|
||||
TArray<TSubclassOf<UGameplayEffect>> TargetGameplayEffectClasses;
|
||||
};
|
||||
|
||||
/**
|
||||
* Processed gameplay effect container spec for application.
|
||||
* 用于应用的处理过的游戏效果容器规格。
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_GameplayEffectContainerSpec
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
FGGA_GameplayEffectContainerSpec() {}
|
||||
|
||||
/**
|
||||
* Computed target data for the effect.
|
||||
* 效果的计算目标数据。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "GGA")
|
||||
FGameplayAbilityTargetDataHandle TargetData;
|
||||
|
||||
/**
|
||||
* List of gameplay effect specs to apply.
|
||||
* 要应用的游戏效果规格列表。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "GGA")
|
||||
TArray<FGameplayEffectSpecHandle> TargetGameplayEffectSpecs;
|
||||
|
||||
/**
|
||||
* Checks if the spec has valid effects.
|
||||
* 检查规格是否具有有效效果。
|
||||
* @return True if valid effects exist, false otherwise. 如果存在有效效果则返回true,否则返回false。
|
||||
*/
|
||||
bool HasValidEffects() const;
|
||||
|
||||
/**
|
||||
* Checks if the spec has valid targets.
|
||||
* 检查规格是否具有有效目标。
|
||||
* @return True if valid targets exist, false otherwise. 如果存在有效目标则返回true,否则返回false。
|
||||
*/
|
||||
bool HasValidTargets() const;
|
||||
|
||||
/**
|
||||
* Adds targets to the target data.
|
||||
* 将目标添加到目标数据。
|
||||
* @param HitResults Array of hit results. 命中结果数组。
|
||||
* @param TargetActors Array of target actors. 目标演员数组。
|
||||
*/
|
||||
void AddTargets(const TArray<FHitResult>& HitResults, const TArray<AActor*>& TargetActors);
|
||||
};
|
||||
@@ -0,0 +1,184 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "GGA_AbilityTagRelationshipMapping.generated.h"
|
||||
|
||||
/**
|
||||
* Struct defining the relationship between different ability tags.
|
||||
* 定义不同技能标签之间关系的结构体。
|
||||
*/
|
||||
USTRUCT()
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_AbilityTagRelationship
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* The ability tag these rules apply to.
|
||||
* 这些规则适用的技能标签。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA|Abilities")
|
||||
FGameplayTag AbilityTag;
|
||||
|
||||
/**
|
||||
* Tags of abilities blocked while this ability is active.
|
||||
* 此技能激活时被阻挡的技能标签。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA|Abilities")
|
||||
FGameplayTagContainer AbilityTagsToBlock;
|
||||
|
||||
/**
|
||||
* Tags of abilities cancelled when this ability is executed.
|
||||
* 此技能执行时被取消的技能标签。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA|Abilities")
|
||||
FGameplayTagContainer AbilityTagsToCancel;
|
||||
|
||||
/**
|
||||
* Tags required on the activating actor/component to activate this ability.
|
||||
* 激活此技能所需的演员/组件标签。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA|Abilities")
|
||||
FGameplayTagContainer ActivationRequiredTags;
|
||||
|
||||
/**
|
||||
* Tags that block activation if present on the activating actor/component.
|
||||
* 如果演员/组件具有这些标签,将阻止激活。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA|Abilities")
|
||||
FGameplayTagContainer ActivationBlockedTags;
|
||||
|
||||
#if WITH_EDITORONLY_DATA
|
||||
/**
|
||||
* Description for developers in the editor.
|
||||
* 编辑器中用于开发者的描述。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA|Abilities")
|
||||
FString DevDescription;
|
||||
|
||||
/**
|
||||
* Editor-friendly name for the relationship.
|
||||
* 关系在编辑器中的友好名称。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category=AlwaysHidden, Meta=(EditCondition=False, EditConditionHides))
|
||||
FString EditorFriendlyName;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct defining ability tag relationships with a tag query condition.
|
||||
* 定义带有标签查询条件的技能标签关系的结构体。
|
||||
*/
|
||||
USTRUCT()
|
||||
struct FGGA_AbilityTagRelationshipsWithQuery
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* Tag query to determine when these relationships apply.
|
||||
* 用于确定何时应用这些关系的标签查询。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA|Abilities")
|
||||
FGameplayTagQuery ActorTagQuery;
|
||||
|
||||
/**
|
||||
* Array of ability tag relationships.
|
||||
* 技能标签关系数组。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA|Abilities", meta=(TitleProperty="EditorFriendlyName"))
|
||||
TArray<FGGA_AbilityTagRelationship> AbilityTagRelationships;
|
||||
|
||||
#if WITH_EDITORONLY_DATA
|
||||
/**
|
||||
* Editor-friendly name for the query.
|
||||
* 查询在编辑器中的友好名称。
|
||||
*/
|
||||
UPROPERTY(VisibleAnywhere, Category=AlwaysHidden, Meta=(EditCondition=False, EditConditionHides))
|
||||
FString EditorFriendlyName;
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
* Data asset for mapping ability tag relationships (block or cancel).
|
||||
* 用于映射技能标签关系(阻挡或取消)的数据资产。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilityTagRelationshipMapping : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
private:
|
||||
/**
|
||||
* List of ability tag relationships.
|
||||
* 技能标签关系列表。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GGA|Abilities", meta=(TitleProperty="EditorFriendlyName"))
|
||||
TArray<FGGA_AbilityTagRelationship> AbilityTagRelationships;
|
||||
|
||||
/**
|
||||
* Conditional ability tag relationships based on tag queries.
|
||||
* 基于标签查询的条件技能标签关系。
|
||||
*/
|
||||
UPROPERTY(EditAnywhere, Category = "GCS", meta=(TitleProperty="EditorFriendlyName"))
|
||||
TArray<FGGA_AbilityTagRelationshipsWithQuery> Layered;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Retrieves tags to block and cancel based on actor and ability tags.
|
||||
* 根据演员和技能标签获取要阻挡和取消的标签。
|
||||
* @param ActorTags Tags on the actor. 演员标签。
|
||||
* @param AbilityTags Tags of the ability. 技能标签。
|
||||
* @param OutTagsToBlock Tags to block (output). 要阻挡的标签(输出)。
|
||||
* @param OutTagsToCancel Tags to cancel (output). 要取消的标签(输出)。
|
||||
*/
|
||||
void GetAbilityTagsToBlockAndCancelV2(const FGameplayTagContainer& ActorTags, const FGameplayTagContainer& AbilityTags, FGameplayTagContainer* OutTagsToBlock,
|
||||
FGameplayTagContainer* OutTagsToCancel) const;
|
||||
|
||||
/**
|
||||
* Retrieves tags to block and cancel based on ability tags.
|
||||
* 根据技能标签获取要阻挡和取消的标签。
|
||||
* @param AbilityTags Tags of the ability. 技能标签。
|
||||
* @param OutTagsToBlock Tags to block (output). 要阻挡的标签(输出)。
|
||||
* @param OutTagsToCancel Tags to cancel (output). 要取消的标签(输出)。
|
||||
*/
|
||||
void GetAbilityTagsToBlockAndCancel(const FGameplayTagContainer& AbilityTags, FGameplayTagContainer* OutTagsToBlock, FGameplayTagContainer* OutTagsToCancel) const;
|
||||
|
||||
/**
|
||||
* Retrieves required and blocked activation tags based on actor and ability tags.
|
||||
* 根据演员和技能标签获取所需和阻止的激活标签。
|
||||
* @param ActorTags Tags on the actor. 演员标签。
|
||||
* @param AbilityTags Tags of the ability. 技能标签。
|
||||
* @param OutActivationRequired Required activation tags (output). 所需激活标签(输出)。
|
||||
* @param OutActivationBlocked Blocked activation tags (output). 阻止激活标签(输出)。
|
||||
*/
|
||||
void GetRequiredAndBlockedActivationTagsV2(const FGameplayTagContainer& ActorTags, const FGameplayTagContainer& AbilityTags, FGameplayTagContainer* OutActivationRequired,
|
||||
FGameplayTagContainer* OutActivationBlocked) const;
|
||||
|
||||
/**
|
||||
* Retrieves required and blocked activation tags based on ability tags.
|
||||
* 根据技能标签获取所需和阻止的激活标签。
|
||||
* @param AbilityTags Tags of the ability. 技能标签。
|
||||
* @param OutActivationRequired Required activation tags (output). 所需激活标签(输出)。
|
||||
* @param OutActivationBlocked Blocked activation tags (output). 阻止激活标签(输出)。
|
||||
*/
|
||||
void GetRequiredAndBlockedActivationTags(const FGameplayTagContainer& AbilityTags, FGameplayTagContainer* OutActivationRequired, FGameplayTagContainer* OutActivationBlocked) const;
|
||||
|
||||
/**
|
||||
* Checks if an ability is cancelled by a specific action tag.
|
||||
* 检查技能是否被特定动作标签取消。
|
||||
* @param AbilityTags Tags of the ability. 技能标签。
|
||||
* @param ActionTag The action tag to check. 要检查的动作标签。
|
||||
* @return True if the ability is cancelled, false otherwise. 如果技能被取消则返回true,否则返回false。
|
||||
*/
|
||||
bool IsAbilityCancelledByTag(const FGameplayTagContainer& AbilityTags, const FGameplayTag& ActionTag) const;
|
||||
|
||||
#if WITH_EDITOR
|
||||
/**
|
||||
* Pre-save processing for editor.
|
||||
* 编辑器预保存处理。
|
||||
*/
|
||||
virtual void PreSave(FObjectPreSaveContext SaveContext) override;
|
||||
#endif
|
||||
};
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "NativeGameplayTags.h"
|
||||
|
||||
|
||||
namespace GGA_AbilityActivateFailTags
|
||||
{
|
||||
GENERICGAMEPLAYABILITIES_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(IsDead)
|
||||
GENERICGAMEPLAYABILITIES_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Cooldown)
|
||||
GENERICGAMEPLAYABILITIES_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Cost)
|
||||
GENERICGAMEPLAYABILITIES_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TagsBlocked);
|
||||
GENERICGAMEPLAYABILITIES_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(TagsMissing);
|
||||
GENERICGAMEPLAYABILITIES_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Networking);
|
||||
GENERICGAMEPLAYABILITIES_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(ActivationGroup);
|
||||
}
|
||||
|
||||
namespace GGA_AbilityTraitTags
|
||||
{
|
||||
GENERICGAMEPLAYABILITIES_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(ActivationOnSpawn)
|
||||
GENERICGAMEPLAYABILITIES_API UE_DECLARE_GAMEPLAY_TAG_EXTERN(Persistent)
|
||||
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Subsystems/WorldSubsystem.h"
|
||||
#include "GameplayAbilitySpec.h"
|
||||
#include "GameplayEffectTypes.h"
|
||||
#include "GGA_GlobalAbilitySystem.generated.h"
|
||||
|
||||
class UGGA_AbilitySystemComponent;
|
||||
class UAbilitySystemComponent;
|
||||
class UGameplayEffect;
|
||||
class UGameplayAbility;
|
||||
|
||||
/**
|
||||
* Struct to track globally applied abilities.
|
||||
* 跟踪全局应用的技能的结构体。
|
||||
*/
|
||||
USTRUCT()
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_GlobalAppliedAbilityList
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* Map of ability system components to their ability spec handles.
|
||||
* 技能系统组件到技能规格句柄的映射。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TMap<TObjectPtr<UGGA_AbilitySystemComponent>, FGameplayAbilitySpecHandle> Handles;
|
||||
|
||||
/**
|
||||
* Adds an ability to an ability system component.
|
||||
* 将技能添加到技能系统组件。
|
||||
* @param Ability The ability class to add. 要添加的技能类。
|
||||
* @param ASC The ability system component. 技能系统组件。
|
||||
*/
|
||||
void AddToASC(TSubclassOf<UGameplayAbility> Ability, UGGA_AbilitySystemComponent* ASC);
|
||||
|
||||
/**
|
||||
* Removes an ability from an ability system component.
|
||||
* 从技能系统组件移除技能。
|
||||
* @param ASC The ability system component. 技能系统组件。
|
||||
*/
|
||||
void RemoveFromASC(UGGA_AbilitySystemComponent* ASC);
|
||||
|
||||
/**
|
||||
* Removes all abilities from all components.
|
||||
* 从所有组件移除所有技能。
|
||||
*/
|
||||
void RemoveFromAll();
|
||||
};
|
||||
|
||||
/**
|
||||
* Struct to track globally applied effects.
|
||||
* 跟踪全局应用的效果的结构体。
|
||||
*/
|
||||
USTRUCT()
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_GlobalAppliedEffectList
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/**
|
||||
* Map of ability system components to their effect handles.
|
||||
* 技能系统组件到效果句柄的映射。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TMap<TObjectPtr<UGGA_AbilitySystemComponent>, FActiveGameplayEffectHandle> Handles;
|
||||
|
||||
/**
|
||||
* Adds an effect to an ability system component.
|
||||
* 将效果添加到技能系统组件。
|
||||
* @param Effect The effect class to add. 要添加的效果类。
|
||||
* @param ASC The ability system component. 技能系统组件。
|
||||
*/
|
||||
void AddToASC(TSubclassOf<UGameplayEffect> Effect, UGGA_AbilitySystemComponent* ASC);
|
||||
|
||||
/**
|
||||
* Removes an effect from an ability system component.
|
||||
* 从技能系统组件移除效果。
|
||||
* @param ASC The ability system component. 技能系统组件。
|
||||
*/
|
||||
void RemoveFromASC(UGGA_AbilitySystemComponent* ASC);
|
||||
|
||||
/**
|
||||
* Removes all effects from all components.
|
||||
* 从所有组件移除所有效果。
|
||||
*/
|
||||
void RemoveFromAll();
|
||||
};
|
||||
|
||||
/**
|
||||
* World subsystem for managing global abilities and effects.
|
||||
* 管理全局技能和效果的世界子系统。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_GlobalAbilitySystem : public UWorldSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructor for the global ability system.
|
||||
* 全局技能系统构造函数。
|
||||
*/
|
||||
UGGA_GlobalAbilitySystem();
|
||||
|
||||
/**
|
||||
* Applies an ability to all registered ability system components.
|
||||
* 将技能应用到所有注册的技能系统组件。
|
||||
* @param Ability The ability class to apply. 要应用的技能类。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GGA|Global")
|
||||
void ApplyAbilityToAll(TSubclassOf<UGameplayAbility> Ability);
|
||||
|
||||
/**
|
||||
* Applies an effect to all registered ability system components.
|
||||
* 将效果应用到所有注册的技能系统组件。
|
||||
* @param Effect The effect class to apply. 要应用的效果类。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GGA|Global")
|
||||
void ApplyEffectToAll(TSubclassOf<UGameplayEffect> Effect);
|
||||
|
||||
/**
|
||||
* Removes an ability from all registered ability system components.
|
||||
* 从所有注册的技能系统组件移除技能。
|
||||
* @param Ability The ability class to remove. 要移除的技能类。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GGA|Global")
|
||||
void RemoveAbilityFromAll(TSubclassOf<UGameplayAbility> Ability);
|
||||
|
||||
/**
|
||||
* Removes an effect from all registered ability system components.
|
||||
* 从所有注册的技能系统组件移除效果。
|
||||
* @param Effect The effect class to remove. 要移除的效果类。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GGA|Global")
|
||||
void RemoveEffectFromAll(TSubclassOf<UGameplayEffect> Effect);
|
||||
|
||||
/**
|
||||
* Registers an ability system component with the global system.
|
||||
* 将技能系统组件注册到全局系统。
|
||||
* @param ASC The ability system component to register. 要注册的技能系统组件。
|
||||
*/
|
||||
void RegisterASC(UGGA_AbilitySystemComponent* ASC);
|
||||
|
||||
/**
|
||||
* Unregisters an ability system component from the global system.
|
||||
* 从全局系统取消注册技能系统组件。
|
||||
* @param ASC The ability system component to unregister. 要取消注册的技能系统组件。
|
||||
*/
|
||||
void UnregisterASC(UGGA_AbilitySystemComponent* ASC);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Map of applied abilities.
|
||||
* 已应用的技能映射。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TMap<TSubclassOf<UGameplayAbility>, FGGA_GlobalAppliedAbilityList> AppliedAbilities;
|
||||
|
||||
/**
|
||||
* Map of applied effects.
|
||||
* 已应用的效果映射。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TMap<TSubclassOf<UGameplayEffect>, FGGA_GlobalAppliedEffectList> AppliedEffects;
|
||||
|
||||
/**
|
||||
* List of registered ability system components.
|
||||
* 注册的技能系统组件列表。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TArray<TObjectPtr<UGGA_AbilitySystemComponent>> RegisteredASCs;
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Object.h"
|
||||
|
||||
|
||||
GENERICGAMEPLAYABILITIES_API DECLARE_LOG_CATEGORY_EXTERN(LogGGA_Ability, Log, All);
|
||||
|
||||
GENERICGAMEPLAYABILITIES_API DECLARE_LOG_CATEGORY_EXTERN(LogGGA_AbilitySystem, Log, All);
|
||||
|
||||
GENERICGAMEPLAYABILITIES_API DECLARE_LOG_CATEGORY_EXTERN(LogGGA_Tasks, Log, All);
|
||||
|
||||
#define GGA_LOG(Verbosity, Format, ...) \
|
||||
{ \
|
||||
UE_LOG(LogGGA_AbilitySystem, Verbosity, TEXT("%S: %s"),__FUNCTION__, *FString::Printf(TEXT(Format), ##__VA_ARGS__)) \
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "GameplayTagAssetInterface.h"
|
||||
#include "GameFramework/Character.h"
|
||||
#include "GGA_Character.generated.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief A character with ability system.
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_Character : public ACharacter, public IAbilitySystemInterface, public IGameplayTagAssetInterface
|
||||
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this character's properties
|
||||
AGGA_Character(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
virtual void PreInitializeComponents() override;
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
|
||||
#pragma region Pawn
|
||||
|
||||
protected:
|
||||
virtual void OnRep_Controller() override;
|
||||
virtual void OnRep_PlayerState() override;
|
||||
|
||||
/**
|
||||
* @brief Called when controller replicated to client.
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category=Character, meta=(DisplayName="Receive Player Controller"))
|
||||
void ReceivePlayerController();
|
||||
|
||||
/**
|
||||
* @brief Called when player state replicated to client.
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent, Category=Character, meta=(DisplayName="Receive Player State"))
|
||||
void ReceivePlayerState();
|
||||
|
||||
#pragma endregion Pawn
|
||||
|
||||
|
||||
#pragma region AbilitySystem
|
||||
|
||||
public:
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
|
||||
protected:
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
UAbilitySystemComponent* CustomGetAbilitySystemComponent() const;
|
||||
|
||||
private:
|
||||
#pragma endregion AbilitySystem
|
||||
|
||||
public:
|
||||
virtual void GetOwnedGameplayTags(FGameplayTagContainer& TagContainer) const override;
|
||||
|
||||
|
||||
// Called to bind functionality to input
|
||||
virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GGA_AbilitySystemComponent.h"
|
||||
#include "GGA_Character.h"
|
||||
#include "GGA_CharacterWithAbilities.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_CharacterWithAbilities : public AGGA_Character
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AGGA_CharacterWithAbilities(const FObjectInitializer& ObjectInitializer);
|
||||
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
|
||||
private:
|
||||
UPROPERTY(Category=Character, VisibleAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess = "true"))
|
||||
TObjectPtr<UGGA_AbilitySystemComponent> AbilitySystemComponent;
|
||||
};
|
||||
@@ -0,0 +1,78 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "Engine/EngineTypes.h"
|
||||
#include "GameFramework/GameState.h"
|
||||
#include "GameFramework/GameStateBase.h"
|
||||
#include "GGA_GameState.generated.h"
|
||||
|
||||
class UGGA_AbilitySystemComponent;
|
||||
class UObject;
|
||||
|
||||
|
||||
/**
|
||||
* @brief A Game State base with ability system component.
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_GameStateBase : public AGameStateBase, public IAbilitySystemInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
AGGA_GameStateBase(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
//~ Begin AActor interface
|
||||
virtual void PreInitializeComponents() override;
|
||||
virtual void PostInitializeComponents() override;
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
//~ End AActor interface
|
||||
|
||||
//~IAbilitySystemInterface
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
//~End of IAbilitySystemInterface
|
||||
|
||||
private:
|
||||
// The ability system component subobject for game-wide things (primarily gameplay cues)
|
||||
UPROPERTY(VisibleAnywhere, Category = "GGA|GameState")
|
||||
TObjectPtr<UGGA_AbilitySystemComponent> AbilitySystemComponent;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief A Game State with ability system component.
|
||||
*/
|
||||
UCLASS(Blueprintable)
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_GameState : public AGameState, public IAbilitySystemInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
AGGA_GameState(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
//~ Begin AActor interface
|
||||
virtual void PreInitializeComponents() override;
|
||||
virtual void PostInitializeComponents() override;
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
//~ End AActor interface
|
||||
|
||||
protected:
|
||||
//~ Begin AGameState interface
|
||||
virtual void HandleMatchHasStarted() override;
|
||||
//~ Begin AGameState interface
|
||||
|
||||
|
||||
//~IAbilitySystemInterface
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
//~End of IAbilitySystemInterface
|
||||
|
||||
private:
|
||||
// The ability system component subobject for game-wide things (primarily gameplay cues)
|
||||
UPROPERTY(VisibleAnywhere, Category = "GameState")
|
||||
TObjectPtr<UGGA_AbilitySystemComponent> AbilitySystemComponent;
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemInterface.h"
|
||||
#include "GGA_AbilitySystemComponent.h"
|
||||
#include "GameFramework/PlayerState.h"
|
||||
#include "GGA_PlayerState.generated.h"
|
||||
|
||||
/**
|
||||
* @brief Minimal PlayerState class that supports extension by game feature plugins.
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_PlayerState : public APlayerState, public IAbilitySystemInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AGGA_PlayerState(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
//~ Begin AActor interface
|
||||
virtual void PreInitializeComponents() override;
|
||||
virtual void BeginPlay() override;
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
virtual void Reset() override;
|
||||
virtual void ClientInitialize(AController* C) override;
|
||||
//~ End AActor interface
|
||||
|
||||
virtual UAbilitySystemComponent* GetAbilitySystemComponent() const override;
|
||||
|
||||
protected:
|
||||
//~ Begin APlayerState interface
|
||||
virtual void CopyProperties(APlayerState* PlayerState);
|
||||
//~ End APlayerState interface
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Called by Controller when its PlayerState is initially replicated.
|
||||
* @param Controller
|
||||
*/
|
||||
UFUNCTION(BlueprintImplementableEvent)
|
||||
void ReceiveClientInitialize(AController* Controller);
|
||||
|
||||
private:
|
||||
UPROPERTY(Category=PlayerState, VisibleAnywhere, BlueprintReadOnly, meta=(AllowPrivateAccess = "true"))
|
||||
TObjectPtr<UGGA_AbilitySystemComponent> AbilitySystemComponent;
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class FGenericGameplayAbilitiesModule : public IModuleInterface
|
||||
{
|
||||
public:
|
||||
|
||||
/** IModuleInterface implementation */
|
||||
virtual void StartupModule() override;
|
||||
virtual void ShutdownModule() override;
|
||||
};
|
||||
@@ -0,0 +1,153 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "AbilitySystemGlobals.h"
|
||||
#include "GGA_AbilitySystemStructLibrary.h"
|
||||
#include "GGA_AbilitySystemGlobals.generated.h"
|
||||
|
||||
class IGGA_AbilitySystemGlobalsEventReceiver;
|
||||
|
||||
/**
|
||||
* Extended ability system globals for custom functionality.
|
||||
* 扩展的技能系统全局类,提供自定义功能。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilitySystemGlobals : public UAbilitySystemGlobals
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Processes gameplay effect specs before application.
|
||||
* 在应用游戏效果规格前进行处理。
|
||||
* @param Spec The gameplay effect spec. 游戏效果规格。
|
||||
* @param AbilitySystemComponent The ability system component. 技能系统组件。
|
||||
*/
|
||||
virtual void GlobalPreGameplayEffectSpecApply(FGameplayEffectSpec& Spec, UAbilitySystemComponent* AbilitySystemComponent) override;
|
||||
|
||||
/**
|
||||
* Allocate a GGA_GameplayEffectContext struct. Caller is responsible for deallocation
|
||||
* 分配一个GGA_GameplayEffectContext.
|
||||
*/
|
||||
virtual FGameplayEffectContext* AllocGameplayEffectContext() const override;
|
||||
|
||||
/**
|
||||
* Retrieves the ability system globals instance.
|
||||
* 获取技能系统全局实例。
|
||||
* @return The ability system globals instance. 技能系统全局实例。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|Globals")
|
||||
static const UAbilitySystemGlobals* GetAbilitySystemGlobals();
|
||||
|
||||
/**
|
||||
* Retrieves a typed ability system globals instance.
|
||||
* 获取特定类型的技能系统全局实例。
|
||||
* @param DesiredClass The desired class type. 所需的类类型。
|
||||
* @return The typed ability system globals instance. 特定类型的技能系统全局实例。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|Globals", meta=(DynamicOutputParam=ReturnValue, DeterminesOutputType=DesiredClass))
|
||||
static const UAbilitySystemGlobals* GetTypedAbilitySystemGloabls(TSubclassOf<UAbilitySystemGlobals> DesiredClass);
|
||||
|
||||
/**
|
||||
* Registers an event receiver for global events.
|
||||
* 为全局事件注册事件接收器。
|
||||
* @param NewReceiver The event receiver to register. 要注册的事件接收器。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Globals", meta=(DefaultToSelf="NewReceiver"))
|
||||
static void RegisterEventReceiver(TScriptInterface<IGGA_AbilitySystemGlobalsEventReceiver> NewReceiver);
|
||||
|
||||
/**
|
||||
* Unregisters an event receiver from global events.
|
||||
* 从全局事件取消注册事件接收器。
|
||||
* @param NewReceiver The event receiver to unregister. 要取消注册的事件接收器。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Globals", meta=(DefaultToSelf="NewReceiver"))
|
||||
static void UnregisterEventReceiver(TScriptInterface<IGGA_AbilitySystemGlobalsEventReceiver> NewReceiver);
|
||||
|
||||
/**
|
||||
* Retrieves all currently loaded attribute default curve tables.
|
||||
* 获取当前加载的所有属性默认曲线表。
|
||||
* @return Array of curve tables. 曲线表数组。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|Globals")
|
||||
TArray<UCurveTable*> GetAttributeDefaultsTables() const;
|
||||
|
||||
/**
|
||||
* Initializes attribute set defaults for an ability system component.
|
||||
* 为技能系统组件初始化属性集默认值。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param GroupName The attribute group name. 属性组名称。
|
||||
* @param Level The level to initialize. 初始化等级。
|
||||
* @param bInitialInit Whether this is the initial initialization. 是否为初始初始化。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure=false, Category = "GGA|Globals")
|
||||
void InitAttributeSetDefaults(UAbilitySystemComponent* AbilitySystem, const FGGA_AttributeGroupName& GroupName, int32 Level = 1, bool bInitialInit = false) const;
|
||||
|
||||
/**
|
||||
* Applies a single attribute default to an ability system component.
|
||||
* 为技能系统组件应用单个属性默认值。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param InAttribute The attribute to apply. 要应用的属性。
|
||||
* @param GroupName The attribute group name. 属性组名称。
|
||||
* @param Level The level to apply. 应用等级。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure=false, Category = "GGA|Globals")
|
||||
void ApplyAttributeDefault(UAbilitySystemComponent* AbilitySystem, FGameplayAttribute& InAttribute, const FGGA_AttributeGroupName& GroupName, int32 Level) const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* List of registered event receivers.
|
||||
* 注册的事件接收器列表。
|
||||
*/
|
||||
UPROPERTY()
|
||||
TArray<TScriptInterface<IGGA_AbilitySystemGlobalsEventReceiver>> Receivers;
|
||||
};
|
||||
|
||||
/**
|
||||
* Interface for receiving global ability system events.
|
||||
* 接收全局技能系统事件的接口。
|
||||
*/
|
||||
UINTERFACE()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilitySystemGlobalsEventReceiver : public UInterface
|
||||
{
|
||||
GENERATED_BODY()
|
||||
};
|
||||
|
||||
/**
|
||||
* Implementation class for global ability system event receiver.
|
||||
* 全局技能系统事件接收器的实现类。
|
||||
*/
|
||||
class GENERICGAMEPLAYABILITIES_API IGGA_AbilitySystemGlobalsEventReceiver
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Handles global pre-gameplay effect spec application.
|
||||
* 处理全局游戏效果规格应用前的事件。
|
||||
* @param Spec The gameplay effect spec. 游戏效果规格。
|
||||
* @param AbilitySystemComponent The ability system component. 技能系统组件。
|
||||
*/
|
||||
virtual void ReceiveGlobalPreGameplayEffectSpecApply(FGameplayEffectSpec& Spec, UAbilitySystemComponent* AbilitySystemComponent);
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Virtual function for handling pre-gameplay effect spec application.
|
||||
* 处理游戏效果规格应用前的虚函数。
|
||||
* @param Spec The gameplay effect spec. 游戏效果规格。
|
||||
* @param AbilitySystemComponent The ability system component. 技能系统组件。
|
||||
*/
|
||||
virtual void OnGlobalPreGameplayEffectSpecApply(FGameplayEffectSpec& Spec, UAbilitySystemComponent* AbilitySystemComponent) = 0;
|
||||
|
||||
/**
|
||||
* Blueprint event for handling pre-gameplay effect spec application.
|
||||
* 处理游戏效果规格应用前的蓝图事件。
|
||||
* @param Spec The gameplay effect spec. 游戏效果规格。
|
||||
* @param AbilitySystemComponent The ability system component. 技能系统组件。
|
||||
* @param OutDynamicTagsAppendToSpec Tags to append to the spec (output). 要附加到规格的标签(输出)。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category="GGA|Global", meta=(DisplayName="On Global Pre Gameplay Effect Spec Apply"))
|
||||
void OnGlobalPreGameplayEffectSpecApply_Bp(const FGameplayEffectSpec& Spec, UAbilitySystemComponent* AbilitySystemComponent, FGameplayTagContainer& OutDynamicTagsAppendToSpec);
|
||||
};
|
||||
@@ -0,0 +1,58 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "StructUtils/InstancedStruct.h"
|
||||
#include "Abilities/GameplayAbilityTargetTypes.h"
|
||||
#include "GGA_GameplayAbilityTargetData_Payload.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_GameplayAbilityTargetData_Payload : public FGameplayAbilityTargetData
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
virtual ~FGGA_GameplayAbilityTargetData_Payload() override
|
||||
{
|
||||
}
|
||||
|
||||
FGGA_GameplayAbilityTargetData_Payload()
|
||||
{
|
||||
};
|
||||
|
||||
FGGA_GameplayAbilityTargetData_Payload(const FInstancedStruct& InPayload)
|
||||
: Payload(InPayload)
|
||||
{
|
||||
}
|
||||
|
||||
virtual UScriptStruct* GetScriptStruct() const override
|
||||
{
|
||||
return FGGA_GameplayAbilityTargetData_Payload::StaticStruct();
|
||||
}
|
||||
|
||||
virtual FString ToString() const override
|
||||
{
|
||||
return TEXT("FGGA_GameplayAbilityTargetData_Payload");
|
||||
}
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = Targeting)
|
||||
FInstancedStruct Payload;
|
||||
|
||||
bool NetSerialize(FArchive& Ar, class UPackageMap* Map, bool& bOutSuccess)
|
||||
{
|
||||
return Payload.NetSerialize(Ar, Map, bOutSuccess);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct TStructOpsTypeTraits<FGGA_GameplayAbilityTargetData_Payload> : public TStructOpsTypeTraitsBase2<FGGA_GameplayAbilityTargetData_Payload>
|
||||
{
|
||||
enum
|
||||
{
|
||||
WithNetSerializer = true, // For now this is REQUIRED for FGameplayAbilityTargetDataHandle net serialization to work
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,108 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayEffectTypes.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
#if ENGINE_MINOR_VERSION < 5
|
||||
#include "InstancedStruct.h"
|
||||
#else
|
||||
#include "StructUtils/InstancedStruct.h"
|
||||
#endif
|
||||
#include "GGA_GameplayEffectContext.generated.h"
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
USTRUCT()
|
||||
struct GENERICGAMEPLAYABILITIES_API FGGA_GameplayEffectContext : public FGameplayEffectContext
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
virtual FGameplayEffectContext* Duplicate() const override;
|
||||
virtual UScriptStruct* GetScriptStruct() const override;
|
||||
virtual bool NetSerialize(FArchive& Ar, UPackageMap* Map, bool& bOutSuccess) override;
|
||||
|
||||
TArray<FInstancedStruct>& GetPayloads();
|
||||
|
||||
void AddOrOverwriteData(const FInstancedStruct& DataInstance);
|
||||
const FInstancedStruct* FindPayloadByType(const UScriptStruct* PayloadType) const;
|
||||
FInstancedStruct* FindPayloadByType(const UScriptStruct* PayloadType);
|
||||
FInstancedStruct* FindOrAddPayloadByType(const UScriptStruct* PayloadType);
|
||||
FInstancedStruct* AddPayloadByType(const UScriptStruct* PayloadType);
|
||||
bool RemovePayloadByType(const UScriptStruct* PayloadType);
|
||||
|
||||
/** Find payload of a specific type in this context (mutable version). If not found, null will be returned. */
|
||||
template <typename T>
|
||||
T* FindMutablePayloadByType()
|
||||
{
|
||||
if (FInstancedStruct* FoundData = FindPayloadByType(T::StaticStruct()))
|
||||
{
|
||||
return FoundData->GetMutablePtr<T>();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** Find payload of a specific type in this context. If not found, null will be returned. */
|
||||
template <typename T>
|
||||
const T* FindPayload() const
|
||||
{
|
||||
if (const FInstancedStruct* FoundData = FindPayloadByType(T::StaticStruct()))
|
||||
{
|
||||
return FoundData->GetPtr<T>();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/** Find payload of a specific type in this context. If not found, a new default instance will be added. */
|
||||
template <typename T>
|
||||
const T& FindOrAddPayload()
|
||||
{
|
||||
if (const T* ExistingData = FindPayload<T>())
|
||||
{
|
||||
return *ExistingData;
|
||||
}
|
||||
FInstancedStruct* NewData = AddPayloadByType(T::StaticStruct());
|
||||
return NewData->Get<T>();
|
||||
}
|
||||
|
||||
/** Find payload of a specific type in this context. (mutable version). If not found, a new default instance will be added. */
|
||||
template <typename T>
|
||||
T& FindOrAddMutablePayload()
|
||||
{
|
||||
if (T* ExistingData = FindMutablePayloadByType<T>())
|
||||
{
|
||||
return *ExistingData;
|
||||
}
|
||||
FInstancedStruct* NewData = AddPayloadByType(T::StaticStruct());
|
||||
return NewData->GetMutable<T>();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T* FindOrAddMutablePayloadPtr()
|
||||
{
|
||||
if (T* ExistingData = FindMutablePayloadByType<T>())
|
||||
{
|
||||
return ExistingData;
|
||||
}
|
||||
FInstancedStruct* NewData = AddPayloadByType(T::StaticStruct());
|
||||
return NewData->GetMutablePtr<T>();
|
||||
}
|
||||
|
||||
protected:
|
||||
UPROPERTY()
|
||||
TArray<FInstancedStruct> Payloads;
|
||||
};
|
||||
|
||||
|
||||
template <>
|
||||
struct TStructOpsTypeTraits<FGGA_GameplayEffectContext> : TStructOpsTypeTraitsBase2<FGGA_GameplayEffectContext>
|
||||
{
|
||||
enum
|
||||
{
|
||||
WithNetSerializer = true,
|
||||
WithCopy = true
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "Animation/AnimNotifies/AnimNotify.h"
|
||||
#include "GGA_AnimNotify_SendGameplayEvent.generated.h"
|
||||
|
||||
/**
|
||||
* An anim notify to send gameplay event to owner.
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AnimNotify_SendGameplayEvent : public UAnimNotify
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
virtual void Notify(USkeletalMeshComponent* MeshComp, UAnimSequenceBase* Animation, const FAnimNotifyEventReference& EventReference) override;
|
||||
|
||||
virtual FString GetNotifyName_Implementation() const override;
|
||||
|
||||
protected:
|
||||
UPROPERTY(EditAnywhere, Category="GGA", BlueprintReadWrite)
|
||||
FGameplayTag EventTag;
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Abilities/GGA_GameplayAbility.h"
|
||||
#include "GGA_GamePhaseAbility.generated.h"
|
||||
|
||||
/**
|
||||
* UGGA_GamePhaseAbility
|
||||
*
|
||||
* The base gameplay ability for any ability that is used to change the active game phase.
|
||||
*/
|
||||
UCLASS(Abstract, HideCategories = Input)
|
||||
class UGGA_GamePhaseAbility : public UGGA_GameplayAbility
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UGGA_GamePhaseAbility(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
|
||||
|
||||
const FGameplayTag& GetGamePhaseTag() const { return GamePhaseTag; }
|
||||
|
||||
#if WITH_EDITOR
|
||||
#if ENGINE_MINOR_VERSION > 2
|
||||
virtual EDataValidationResult IsDataValid(class FDataValidationContext& Context) const override;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
virtual void ActivateAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, const FGameplayEventData* TriggerEventData) override;
|
||||
virtual void EndAbility(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, const FGameplayAbilityActivationInfo ActivationInfo, bool bReplicateEndAbility, bool bWasCancelled) override;
|
||||
|
||||
protected:
|
||||
|
||||
// Defines the game phase that this game phase ability is part of. So for example,
|
||||
// if your game phase is GamePhase.RoundStart, then it will cancel all sibling phases.
|
||||
// So if you had a phase such as GamePhase.WaitingToStart that was active, starting
|
||||
// the ability part of RoundStart would end WaitingToStart. However to get nested behaviors
|
||||
// you can also nest the phases. So for example, GamePhase.Playing.NormalPlay, is a sub-phase
|
||||
// of the parent GamePhase.Playing, so changing the sub-phase to GamePhase.Playing.SuddenDeath,
|
||||
// would stop any ability tied to GamePhase.Playing.*, but wouldn't end any ability
|
||||
// tied to the GamePhase.Playing phase.
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GGA|GamePhase")
|
||||
FGameplayTag GamePhaseTag;
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Logging/LogMacros.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogGGA_GamePhase, Log, All);
|
||||
@@ -0,0 +1,103 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "GameplayAbilitySpecHandle.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "Subsystems/WorldSubsystem.h"
|
||||
|
||||
#include "GGA_GamePhaseSubsystem.generated.h"
|
||||
|
||||
class UGGA_GamePhaseAbility;
|
||||
|
||||
DECLARE_DYNAMIC_DELEGATE_OneParam(FGGamePhaseDynamicDelegate, const UGGA_GamePhaseAbility*, Phase);
|
||||
|
||||
DECLARE_DELEGATE_OneParam(FGGamePhaseDelegate, const UGGA_GamePhaseAbility* Phase);
|
||||
|
||||
DECLARE_DYNAMIC_DELEGATE_OneParam(FGGamePhaseTagDynamicDelegate, const FGameplayTag&, PhaseTag);
|
||||
|
||||
DECLARE_DELEGATE_OneParam(FGGamePhaseTagDelegate, const FGameplayTag& PhaseTag);
|
||||
|
||||
// Match rule for message receivers
|
||||
UENUM(BlueprintType)
|
||||
enum class EGGA_PhaseTagMatchType : uint8
|
||||
{
|
||||
// An exact match will only receive messages with exactly the same channel
|
||||
// (e.g., registering for "A.B" will match a broadcast of A.B but not A.B.C)
|
||||
ExactMatch,
|
||||
|
||||
// A partial match will receive any messages rooted in the same channel
|
||||
// (e.g., registering for "A.B" will match a broadcast of A.B as well as A.B.C)
|
||||
PartialMatch
|
||||
};
|
||||
|
||||
|
||||
/** Subsystem for managing game phases using gameplay tags in a nested manner, which allows parent and child
|
||||
* phases to be active at the same time, but not sibling phases.
|
||||
* Example: Game.Playing and Game.Playing.WarmUp can coexist, but Game.Playing and Game.ShowingScore cannot.
|
||||
* When a new phase is started, any active phases that are not ancestors will be ended.
|
||||
* Example: if Game.Playing and Game.Playing.CaptureTheFlag are active when Game.Playing.PostGame is started,
|
||||
* Game.Playing will remain active, while Game.Playing.CaptureTheFlag will end.
|
||||
*/
|
||||
UCLASS()
|
||||
class UGGA_GamePhaseSubsystem : public UWorldSubsystem
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UGGA_GamePhaseSubsystem();
|
||||
|
||||
//virtual void PostInitialize() override;
|
||||
|
||||
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
|
||||
|
||||
void StartPhase(TSubclassOf<UGGA_GamePhaseAbility> PhaseAbility, FGGamePhaseDelegate PhaseEndedCallback = FGGamePhaseDelegate());
|
||||
|
||||
//TODO Return a handle so folks can delete these. They will just grow until the world resets.
|
||||
//TODO Should we just occasionally clean these observers up? It's not as if everyone will properly unhook them even if there is a handle.
|
||||
void WhenPhaseStartsOrIsActive(FGameplayTag PhaseTag, EGGA_PhaseTagMatchType MatchType, const FGGamePhaseTagDelegate& WhenPhaseActive);
|
||||
void WhenPhaseEnds(FGameplayTag PhaseTag, EGGA_PhaseTagMatchType MatchType, const FGGamePhaseTagDelegate& WhenPhaseEnd);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GamePhase", BlueprintAuthorityOnly, BlueprintPure = false, meta = (AutoCreateRefTerm = "PhaseTag"))
|
||||
bool IsPhaseActive(const FGameplayTag& PhaseTag) const;
|
||||
|
||||
protected:
|
||||
virtual bool DoesSupportWorldType(const EWorldType::Type WorldType) const override;
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GGA|GamePhase", meta = (DisplayName="Start Phase", AutoCreateRefTerm = "PhaseEnded"))
|
||||
void K2_StartPhase(TSubclassOf<UGGA_GamePhaseAbility> Phase, const FGGamePhaseDynamicDelegate& PhaseEnded);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GGA|GamePhase", meta = (DisplayName = "When Phase Starts or Is Active", AutoCreateRefTerm = "WhenPhaseActive"))
|
||||
void K2_WhenPhaseStartsOrIsActive(FGameplayTag PhaseTag, EGGA_PhaseTagMatchType MatchType, FGGamePhaseTagDynamicDelegate WhenPhaseActive);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "GGA|GamePhase", meta = (DisplayName = "When Phase Ends", AutoCreateRefTerm = "WhenPhaseEnd"))
|
||||
void K2_WhenPhaseEnds(FGameplayTag PhaseTag, EGGA_PhaseTagMatchType MatchType, FGGamePhaseTagDynamicDelegate WhenPhaseEnd);
|
||||
|
||||
void OnBeginPhase(const UGGA_GamePhaseAbility* PhaseAbility, const FGameplayAbilitySpecHandle PhaseAbilityHandle);
|
||||
void OnEndPhase(const UGGA_GamePhaseAbility* PhaseAbility, const FGameplayAbilitySpecHandle PhaseAbilityHandle);
|
||||
|
||||
private:
|
||||
struct FGGamePhaseEntry
|
||||
{
|
||||
public:
|
||||
FGameplayTag PhaseTag;
|
||||
FGGamePhaseDelegate PhaseEndedCallback;
|
||||
};
|
||||
|
||||
TMap<FGameplayAbilitySpecHandle, FGGamePhaseEntry> ActivePhaseMap;
|
||||
|
||||
struct FGPhaseObserver
|
||||
{
|
||||
public:
|
||||
bool IsMatch(const FGameplayTag& ComparePhaseTag) const;
|
||||
|
||||
FGameplayTag PhaseTag;
|
||||
EGGA_PhaseTagMatchType MatchType = EGGA_PhaseTagMatchType::ExactMatch;
|
||||
FGGamePhaseTagDelegate PhaseCallback;
|
||||
};
|
||||
|
||||
TArray<FGPhaseObserver> PhaseStartObservers;
|
||||
TArray<FGPhaseObserver> PhaseEndObservers;
|
||||
|
||||
friend class UGGA_GamePhaseAbility;
|
||||
};
|
||||
@@ -0,0 +1,95 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GGA_AbilityTargetActor_Trace.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
#include "Engine/CollisionProfile.h"
|
||||
#include "GGA_AbilityTargetActor_LineTrace.generated.h"
|
||||
|
||||
/**
|
||||
* 可重用、配置的线形检测目标捕获Actor。
|
||||
* 与UGAT_WaitTargetDataUsingActor配合使用。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_AbilityTargetActor_LineTrace : public AGGA_AbilityTargetActor_Trace
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AGGA_AbilityTargetActor_LineTrace();
|
||||
|
||||
/**
|
||||
* Configure the TargetActor for use. This TargetActor could be used in multiple abilities and there's no guarantee
|
||||
* what state it will be in. You will need to make sure that only one ability is using this TargetActor at a time.
|
||||
*
|
||||
* @param InStartLocation Location to trace from.
|
||||
* @param InAimingTag Optional. Predicted GameplayTag for aiming. Only used if we mofify spread while aiming. If used,
|
||||
* must set InAimingRemovalTag also.
|
||||
* @param InAimingRemovalTag Optional. Predicted GameplayTag for aiming removal. Only used if we mofify spread while
|
||||
* aiming. If used, must set InAimingTag also.
|
||||
* @param InTraceProfile Collision profile to use for tracing.
|
||||
* @param InFilter Hit Actors must pass this filter to be returned in the TargetData.
|
||||
* @param InReticleClass Reticle that will appear on top of acquired targets. Reticles will be spawned/despawned as targets are acquired/lost.
|
||||
* @param InReticleParams Parameters for world reticle. Usage of these parameters is dependent on the reticle.
|
||||
* @param bInIgnoreBlockingHits Ignore blocking collision hits in the trace. Useful if you want to target through walls.
|
||||
* @param bInShouldProduceTargetDataOnServer If set, this TargetActor will produce TargetData on the Server in addition
|
||||
* to the client and the client will just send a generic "Confirm" event to the server. If false, the client will send
|
||||
* the TargetData to the Server. This is handled by the WaitTargetDataUsingActor AbilityTask.
|
||||
* @param bInUsePersistentHitResults Should HitResults persist while targeting? HitResults are cleared on Confirm/Cancel or
|
||||
* when new HitResults take their place.
|
||||
* @param bInDebug When true, this TargetActor will show debug lines of the trace and hit results.
|
||||
* @param bInTraceAffectsAimPitch Does the trace affect the aiming pitch?
|
||||
* @param bInTraceFromPlayerViewPoint Should we trace from the player ViewPoint instead of the StartLocation? The
|
||||
* TargetData HitResults will still have the StartLocation for the TraceStart. This is useful for FPS where we want
|
||||
* to trace from the player ViewPoint but draw the bullet tracer from the weapon muzzle.
|
||||
* TODO: AI Controllers should fall back to muzzle location. Not implemented yet.
|
||||
* @param bInUseAImingSpreadMod Should we modify spread based on if we're aiming? If true, must set InAimingTag and
|
||||
* InAimingRemovalTag.
|
||||
* @param InMaxRange Max range for this trace.
|
||||
* @param InBaseSpread Base targeting spread in degrees.
|
||||
* @param InAimingSpreadMod Optional. Multiplicative modifier to spread if aiming.
|
||||
* @param InTargetingSpreadIncrement Amount spread increments from continuous targeting in degrees.
|
||||
* @param InTargetingSpreadMax Maximum amount of spread for continuous targeting in degrees.
|
||||
* @param InMaxHitResultsPerTrace Max hit results that a trace can return. < 1 just returns the trace end point.
|
||||
* @param InNumberOfTraces Number of traces to perform. Intended to be used with BaseSpread for multi-shot weapons
|
||||
* like shotguns. Not intended to be used with PersistentHitsResults. If using PersistentHitResults, NumberOfTraces is
|
||||
* hardcoded to 1. You will need to add support for this in your project if you need it.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|TargetActor")
|
||||
void Configure(
|
||||
UPARAM(DisplayName = "Start Location") const FGameplayAbilityTargetingLocationInfo& InStartLocation,
|
||||
UPARAM(DisplayName = "Aiming Tag") FGameplayTag InAimingTag,
|
||||
UPARAM(DisplayName = "Aiming Removal Tag") FGameplayTag InAimingRemovalTag,
|
||||
UPARAM(DisplayName = "Trace Profile") FCollisionProfileName InTraceProfile,
|
||||
UPARAM(DisplayName = "Filter") FGameplayTargetDataFilterHandle InFilter,
|
||||
UPARAM(DisplayName = "Reticle Class") TSubclassOf<AGameplayAbilityWorldReticle> InReticleClass,
|
||||
UPARAM(DisplayName = "Reticle Params") FWorldReticleParameters InReticleParams,
|
||||
UPARAM(DisplayName = "Ignore Blocking Hits") bool bInIgnoreBlockingHits = false,
|
||||
UPARAM(DisplayName = "Should Produce Target Data on Server") bool bInShouldProduceTargetDataOnServer = false,
|
||||
UPARAM(DisplayName = "Use Persistent Hit Results") bool bInUsePersistentHitResults = false,
|
||||
UPARAM(DisplayName = "Debug") bool bInDebug = false,
|
||||
UPARAM(DisplayName = "Trace Affects Aim Pitch") bool bInTraceAffectsAimPitch = true,
|
||||
UPARAM(DisplayName = "Trace From Player ViewPoint") bool bInTraceFromPlayerViewPoint = false,
|
||||
UPARAM(DisplayName = "Use Aiming Spread Mod") bool bInUseAimingSpreadMod = false,
|
||||
UPARAM(DisplayName = "Max Range") float InMaxRange = 999999.0f,
|
||||
UPARAM(DisplayName = "Base Targeting Spread") float InBaseSpread = 0.0f,
|
||||
UPARAM(DisplayName = "Aiming Spread Mod") float InAimingSpreadMod = 0.0f,
|
||||
UPARAM(DisplayName = "Targeting Spread Increment") float InTargetingSpreadIncrement = 0.0f,
|
||||
UPARAM(DisplayName = "Targeting Spread Max") float InTargetingSpreadMax = 0.0f,
|
||||
UPARAM(DisplayName = "Max Hit Results Per Trace") int32 InMaxHitResultsPerTrace = 1,
|
||||
UPARAM(DisplayName = "Number of Traces") int32 InNumberOfTraces = 1
|
||||
);
|
||||
|
||||
protected:
|
||||
virtual void DoTrace(TArray<FHitResult>& HitResults, const UWorld* World, const FGameplayTargetDataFilterHandle FilterHandle, const FVector& Start, const FVector& End, FName ProfileName,
|
||||
const FCollisionQueryParams Params) override;
|
||||
virtual void ShowDebugTrace(TArray<FHitResult>& HitResults, EDrawDebugTrace::Type DrawDebugType, float Duration = 2.0f) override;
|
||||
|
||||
#if ENABLE_DRAW_DEBUG
|
||||
// Util for drawing result of multi line trace from KismetTraceUtils.h
|
||||
void DrawDebugLineTraceMulti(const UWorld* World, const FVector& Start, const FVector& End, EDrawDebugTrace::Type DrawDebugType, bool bHit, const TArray<FHitResult>& OutHits,
|
||||
FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime);
|
||||
#endif // ENABLE_DRAW_DEBUG
|
||||
};
|
||||
@@ -0,0 +1,105 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GGA_AbilityTargetActor_Trace.h"
|
||||
#include "DrawDebugHelpers.h"
|
||||
#include "GGA_AbilityTargetActor_SphereTrace.generated.h"
|
||||
|
||||
/**
|
||||
* 可重用、配置的球形检测目标捕获Actor。
|
||||
* 与UETA_WaitTargetDataUsingActor配合使用。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_AbilityTargetActor_SphereTrace : public AGGA_AbilityTargetActor_Trace
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AGGA_AbilityTargetActor_SphereTrace();
|
||||
|
||||
/**球形检测半径*/
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ExposeOnSpawn = true), Category = "GGA|TargetActor")
|
||||
float TraceSphereRadius;
|
||||
|
||||
/**
|
||||
* Configure the TargetActor for use. This TargetActor could be used in multiple abilities and there's no guarantee
|
||||
* what state it will be in. You will need to make sure that only one ability is using this TargetActor at a time.
|
||||
*
|
||||
* @param InStartLocation Location to trace from.
|
||||
* @param InAimingTag Optional. Predicted GameplayTag for aiming. Only used if we mofify spread while aiming. If used,
|
||||
* must set InAimingRemovalTag also.
|
||||
* @param InAimingRemovalTag Optional. Predicted GameplayTag for aiming removal. Only used if we mofify spread while
|
||||
* aiming. If used, must set InAimingTag also.
|
||||
* @param InTraceProfile Collision profile to use for tracing.
|
||||
* @param InFilter Hit Actors must pass this filter to be returned in the TargetData.
|
||||
* @param InReticleClass Reticle that will appear on top of acquired targets. Reticles will be spawned/despawned as targets are acquired/lost.
|
||||
* @param InReticleParams Parameters for world reticle. Usage of these parameters is dependent on the reticle.
|
||||
* @param bInIgnoreBlockingHits Ignore blocking collision hits in the trace. Useful if you want to target through walls.
|
||||
* @param bInShouldProduceTargetDataOnServer If set, this TargetActor will produce TargetData on the Server in addition
|
||||
* to the client and the client will just send a generic "Confirm" event to the server. If false, the client will send
|
||||
* the TargetData to the Server. This is handled by the WaitTargetDataUsingActor AbilityTask.
|
||||
* @param bInUsePersistentHitResults Should HitResults persist while targeting? HitResults are cleared on Confirm/Cancel or
|
||||
* when new HitResults take their place.
|
||||
* @param bInDebug When true, this TargetActor will show debug lines of the trace and hit results.
|
||||
* @param bInTraceAffectsAimPitch Does the trace affect the aiming pitch?
|
||||
* @param bInTraceFromPlayerViewPoint Should we trace from the player ViewPoint instead of the StartLocation? The
|
||||
* TargetData HitResults will still have the StartLocation for the TraceStart. This is useful for FPS where we want
|
||||
* to trace from the player ViewPoint but draw the bullet tracer from the weapon muzzle.
|
||||
* TODO: AI Controllers should fall back to muzzle location. Not implemented yet.
|
||||
* @param bInUseAImingSpreadMod Should we modify spread based on if we're aiming? If true, must set InAimingTag and
|
||||
* InAimingRemovalTag.
|
||||
* @param InMaxRange Max range for this trace.
|
||||
* @param InTraceSphereRadius Radius for the sphere trace.
|
||||
* @param InBaseSpread Base targeting spread in degrees.
|
||||
* @param InAimingSpreadMod Optional. Multiplicative modifier to spread if aiming.
|
||||
* @param InTargetingSpreadIncrement Amount spread increments from continuous targeting in degrees.
|
||||
* @param InTargetingSpreadMax Maximum amount of spread for continuous targeting in degrees.
|
||||
* @param InMaxHitResultsPerTrace Max hit results that a trace can return. < 1 just returns the trace end point.
|
||||
* @param InNumberOfTraces Number of traces to perform. Intended to be used with BaseSpread for multi-shot weapons
|
||||
* like shotguns. Not intended to be used with PersistentHitsResults. If using PersistentHitResults, NumberOfTraces is
|
||||
* hardcoded to 1. You will need to add support for this in your project if you need it.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|TargetActor")
|
||||
void Configure(
|
||||
UPARAM(DisplayName = "Start Location") const FGameplayAbilityTargetingLocationInfo& InStartLocation,
|
||||
UPARAM(DisplayName = "Aiming Tag") FGameplayTag InAimingTag,
|
||||
UPARAM(DisplayName = "Aiming Removal Tag") FGameplayTag InAimingRemovalTag,
|
||||
UPARAM(DisplayName = "Trace Profile") FCollisionProfileName InTraceProfile,
|
||||
UPARAM(DisplayName = "Filter") FGameplayTargetDataFilterHandle InFilter,
|
||||
UPARAM(DisplayName = "Reticle Class") TSubclassOf<AGameplayAbilityWorldReticle> InReticleClass,
|
||||
UPARAM(DisplayName = "Reticle Params") FWorldReticleParameters InReticleParams,
|
||||
UPARAM(DisplayName = "Ignore Blocking Hits") bool bInIgnoreBlockingHits = false,
|
||||
UPARAM(DisplayName = "Should Produce Target Data on Server") bool bInShouldProduceTargetDataOnServer = false,
|
||||
UPARAM(DisplayName = "Use Persistent Hit Results") bool bInUsePersistentHitResults = false,
|
||||
UPARAM(DisplayName = "Debug") bool bInDebug = false,
|
||||
UPARAM(DisplayName = "Trace Affects Aim Pitch") bool bInTraceAffectsAimPitch = true,
|
||||
UPARAM(DisplayName = "Trace From Player ViewPoint") bool bInTraceFromPlayerViewPoint = false,
|
||||
UPARAM(DisplayName = "Use Aiming Spread Mod") bool bInUseAimingSpreadMod = false,
|
||||
UPARAM(DisplayName = "Max Range") float InMaxRange = 999999.0f,
|
||||
UPARAM(DisplayName = "Trace Sphere Radius") float InTraceSphereRadius = 100.0f,
|
||||
UPARAM(DisplayName = "Base Targeting Spread") float InBaseSpread = 0.0f,
|
||||
UPARAM(DisplayName = "Aiming Spread Mod") float InAimingSpreadMod = 0.0f,
|
||||
UPARAM(DisplayName = "Targeting Spread Increment") float InTargetingSpreadIncrement = 0.0f,
|
||||
UPARAM(DisplayName = "Targeting Spread Max") float InTargetingSpreadMax = 0.0f,
|
||||
UPARAM(DisplayName = "Max Hit Results Per Trace") int32 InMaxHitResultsPerTrace = 1,
|
||||
UPARAM(DisplayName = "Number of Traces") int32 InNumberOfTraces = 1
|
||||
);
|
||||
|
||||
virtual void SphereTraceWithFilter(TArray<FHitResult>& OutHitResults, const UWorld* World, const FGameplayTargetDataFilterHandle FilterHandle, const FVector& Start, const FVector& End,
|
||||
float Radius, FName ProfileName, const FCollisionQueryParams Params);
|
||||
|
||||
protected:
|
||||
virtual void DoTrace(TArray<FHitResult>& HitResults, const UWorld* World, const FGameplayTargetDataFilterHandle FilterHandle, const FVector& Start, const FVector& End, FName ProfileName,
|
||||
const FCollisionQueryParams Params) override;
|
||||
virtual void ShowDebugTrace(TArray<FHitResult>& HitResults, EDrawDebugTrace::Type DrawDebugType, float Duration = 2.0f) override;
|
||||
|
||||
#if ENABLE_DRAW_DEBUG
|
||||
// Utils for drawing result of multi line trace from KismetTraceUtils.h
|
||||
void DrawDebugSweptSphere(const UWorld* InWorld, FVector const& Start, FVector const& End, float Radius, FColor const& Color, bool bPersistentLines = false, float LifeTime = -1.f,
|
||||
uint8 DepthPriority = 0);
|
||||
void DrawDebugSphereTraceMulti(const UWorld* World, const FVector& Start, const FVector& End, float Radius, EDrawDebugTrace::Type DrawDebugType, bool bHit, const TArray<FHitResult>& OutHits,
|
||||
FLinearColor TraceColor, FLinearColor TraceHitColor, float DrawTime);
|
||||
#endif // ENABLE_DRAW_DEBUG
|
||||
};
|
||||
@@ -0,0 +1,163 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/GameplayAbilityTargetActor.h"
|
||||
#include "CollisionQueryParams.h"
|
||||
#include "Engine/CollisionProfile.h"
|
||||
#include "Kismet/KismetSystemLibrary.h"
|
||||
#include "GGA_AbilityTargetActor_Trace.generated.h"
|
||||
|
||||
/**
|
||||
* 可重用、配置的目标捕获Actor。子类继承实现新的检测形状。
|
||||
* 与WaitTargetDataWithResuableActor配合使用。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API AGGA_AbilityTargetActor_Trace : public AGameplayAbilityTargetActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
AGGA_AbilityTargetActor_Trace();
|
||||
|
||||
// 基本瞄准扩散(角度)
|
||||
UPROPERTY(BlueprintReadWrite, Category = "GGA|TargetActor")
|
||||
float BaseSpread;
|
||||
|
||||
// 瞄准扩散修改器
|
||||
UPROPERTY(BlueprintReadWrite, Category = "GGA|TargetActor")
|
||||
float AimingSpreadMod;
|
||||
|
||||
// 连续瞄准: 扩散增量
|
||||
UPROPERTY(BlueprintReadWrite, Category = "GGA|TargetActor")
|
||||
float TargetingSpreadIncrement;
|
||||
|
||||
// 连续瞄准: 最大增量
|
||||
UPROPERTY(BlueprintReadWrite, Category = "GGA|TargetActor")
|
||||
float TargetingSpreadMax;
|
||||
|
||||
// 连续瞄准的当前扩散
|
||||
float CurrentTargetingSpread;
|
||||
|
||||
/** 是否使用瞄准扩散,开启后,检测方向会产生随机扩散(轻微改变检测方向) */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "GGA|TargetActor")
|
||||
bool bUseAimingSpreadMod;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "GGA|TargetActor")
|
||||
FGameplayTag AimingTag;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "GGA|TargetActor")
|
||||
FGameplayTag AimingRemovalTag;
|
||||
|
||||
/** 最大范围 */
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ExposeOnSpawn = true), Category = "GGA|TargetActor")
|
||||
float MaxRange;
|
||||
|
||||
/** 检测预设 */
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, config, meta = (ExposeOnSpawn = true), Category = "GGA|TargetActor")
|
||||
FCollisionProfileName TraceProfile;
|
||||
|
||||
/** 检测是否影响瞄准偏移(沿Y轴的旋转) */
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ExposeOnSpawn = true), Category = "GGA|TargetActor")
|
||||
bool bTraceAffectsAimPitch;
|
||||
|
||||
/** 每次检测所返回的最大碰撞结果数量。0表示只返回检测终点。 */
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ExposeOnSpawn = true), Category = "GGA|TargetActor")
|
||||
int32 MaxHitResultsPerTrace;
|
||||
|
||||
/** 一次性检测的次数,单发射击武器(如来福枪)只会进行一次检测,而多发射击武器(如散弹枪)可以进行多次检测。
|
||||
* 不可与PersistentHits配合使用。
|
||||
* 会影响十字线Actor的数量
|
||||
*/
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ExposeOnSpawn = true), Category = "GGA|TargetActor")
|
||||
int32 NumberOfTraces;
|
||||
|
||||
/**是否忽略阻挡Hits*/
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ExposeOnSpawn = true), Category = "GGA|TargetActor")
|
||||
bool bIgnoreBlockingHits;
|
||||
|
||||
/**是否从玩家控制器的视角开始检测,否则从StartLocation开始检测*/
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ExposeOnSpawn = true), Category = "GGA|TargetActor")
|
||||
bool bTraceFromPlayerViewPoint;
|
||||
|
||||
// HitResults will persist until Confirmation/Cancellation or until a new HitResult takes its place
|
||||
UPROPERTY(BlueprintReadWrite, EditAnywhere, meta = (ExposeOnSpawn = true), Category = "GGA|TargetActor")
|
||||
bool bUsePersistentHitResults;
|
||||
|
||||
/**重置扩散 */
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|TargetActor")
|
||||
virtual void ResetSpread();
|
||||
|
||||
virtual float GetCurrentSpread() const;
|
||||
|
||||
// 设置开始位置信息
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|TargetActor")
|
||||
void SetStartLocation(const FGameplayAbilityTargetingLocationInfo& InStartLocation);
|
||||
|
||||
// 是否在服务端产生目标数据
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|TargetActor")
|
||||
virtual void SetShouldProduceTargetDataOnServer(bool bInShouldProduceTargetDataOnServer);
|
||||
|
||||
// 设置当玩家确认目标后是否销毁此TargetingActor。
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|TargetActor")
|
||||
void SetDestroyOnConfirmation(bool bInDestroyOnConfirmation = false);
|
||||
|
||||
virtual void StartTargeting(UGameplayAbility* Ability) override;
|
||||
|
||||
virtual void ConfirmTargetingAndContinue() override;
|
||||
|
||||
virtual void CancelTargeting() override;
|
||||
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
virtual void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
|
||||
virtual void Tick(float DeltaSeconds) override;
|
||||
|
||||
// Traces as normal, but will manually filter all hit actors
|
||||
virtual void LineTraceWithFilter(TArray<FHitResult>& OutHitResults, const UWorld* World,
|
||||
const FGameplayTargetDataFilterHandle FilterHandle, const FVector& Start,
|
||||
const FVector& End, FName ProfileName, const FCollisionQueryParams Params);
|
||||
|
||||
virtual void AimWithPlayerController(const AActor* InSourceActor, FCollisionQueryParams Params,
|
||||
const FVector& TraceStart, FVector& OutTraceEnd, bool bIgnorePitch = false);
|
||||
|
||||
virtual bool ClipCameraRayToAbilityRange(FVector CameraLocation, FVector CameraDirection, FVector AbilityCenter,
|
||||
float AbilityRange, FVector& ClippedPosition);
|
||||
|
||||
virtual void StopTargeting();
|
||||
|
||||
protected:
|
||||
// 检测终点, useful for debug drawing
|
||||
FVector CurrentTraceEnd;
|
||||
|
||||
// 对准心Actor的引用
|
||||
TArray<TWeakObjectPtr<AGameplayAbilityWorldReticle>> ReticleActors;
|
||||
TArray<FHitResult> PersistentHitResults;
|
||||
|
||||
TArray<FHitResult> CurrentHitResults;
|
||||
|
||||
virtual FGameplayAbilityTargetDataHandle MakeTargetData(const TArray<FHitResult>& HitResults) const;
|
||||
virtual TArray<FHitResult> PerformTrace(AActor* InSourceActor);
|
||||
|
||||
|
||||
//实际的检测,由子类覆写。
|
||||
virtual void DoTrace(TArray<FHitResult>& HitResults, const UWorld* World,
|
||||
const FGameplayTargetDataFilterHandle FilterHandle, const FVector& Start, const FVector& End,
|
||||
FName ProfileName, const FCollisionQueryParams Params) PURE_VIRTUAL(AUETA_Trace, return;);
|
||||
|
||||
virtual void ShowDebugTrace(TArray<FHitResult>& HitResults, EDrawDebugTrace::Type DrawDebugType,
|
||||
float Duration = 2.0f) PURE_VIRTUAL(AUETA_Trace, return;);
|
||||
|
||||
/** 生成准心Actor */
|
||||
virtual AGameplayAbilityWorldReticle* SpawnReticleActor(FVector Location, FRotator Rotation);
|
||||
|
||||
/**销毁所有准心Actor */
|
||||
virtual void DestroyReticleActors();
|
||||
|
||||
public:
|
||||
/**获取当前的hitresult */
|
||||
UFUNCTION(BlueprintPure, Category = "GGA|TargetActor")
|
||||
void GetCurrentHitResult(TArray<FHitResult>& HitResults);
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/GameplayAbilityTypes.h"
|
||||
#include "GGA_TargetType.generated.h"
|
||||
|
||||
/**
|
||||
* Deprecated
|
||||
*/
|
||||
UCLASS(Blueprintable, meta = (ShowWorldContextPin))
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_TargetType : public UObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Constructor and overrides
|
||||
UGGA_TargetType()
|
||||
{
|
||||
}
|
||||
|
||||
/** Called to determine targets to apply gameplay effects to */
|
||||
UFUNCTION(BlueprintNativeEvent)
|
||||
void GetTargets(AActor* TargetingActor, FGameplayEventData EventData, TArray<FHitResult>& OutHitResults, TArray<AActor*>& OutActors) const;
|
||||
virtual void GetTargets_Implementation(AActor* TargetingActor, FGameplayEventData EventData, TArray<FHitResult>& OutHitResults, TArray<AActor*>& OutActors) const;
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GGA_TargetType.h"
|
||||
#include "GGA_TargetType_UseEventData.generated.h"
|
||||
|
||||
/** Trivial target type that pulls the target out of the event data */
|
||||
UCLASS(NotBlueprintable)
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_TargetType_UseEventData : public UGGA_TargetType
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
// Constructor and overrides
|
||||
UGGA_TargetType_UseEventData() {}
|
||||
|
||||
/** Uses the passed in event data */
|
||||
virtual void GetTargets_Implementation(AActor* TargetingActor, FGameplayEventData EventData, TArray<FHitResult>& OutHitResults, TArray<AActor*>& OutActors) const override;
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GGA_TargetType.h"
|
||||
#include "GGA_TargetType_UseOwner.generated.h"
|
||||
|
||||
/** Trivial target type that uses the owner */
|
||||
UCLASS(NotBlueprintable)
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_TargetType_UseOwner : public UGGA_TargetType
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Constructor and overrides
|
||||
UGGA_TargetType_UseOwner()
|
||||
{
|
||||
}
|
||||
|
||||
/** Uses the passed in event data */
|
||||
virtual void GetTargets_Implementation(AActor* TargetingActor, FGameplayEventData EventData, TArray<FHitResult>& OutHitResults, TArray<AActor*>& OutActors) const override;
|
||||
};
|
||||
@@ -0,0 +1,540 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "AbilitySystemComponent.h"
|
||||
#include "GameplayEffectExecutionCalculation.h"
|
||||
#include "GGA_AbilitySystemComponent.h"
|
||||
#include "Abilities/GameplayAbilityTypes.h"
|
||||
#include "GGA_AbilitySystemFunctionLibrary.generated.h"
|
||||
|
||||
/**
|
||||
* Blueprint function library for ability system operations.
|
||||
* 用于技能系统操作的蓝图函数库。
|
||||
* @details Provides utility functions for managing ability system components, abilities, and attributes.
|
||||
* @细节 提供管理技能系统组件、技能和属性的实用函数。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_AbilitySystemFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
#pragma region AbilitySystem
|
||||
/**
|
||||
* Finds an ability system component on an actor.
|
||||
* 在演员上查找技能系统组件。
|
||||
* @param Actor The actor to search. 要搜索的演员。
|
||||
* @param DesiredClass The desired class of the component. 所需的组件类。
|
||||
* @param ASC The found ability system component (output). 找到的技能系统组件(输出)。
|
||||
* @return True if the component was found, false otherwise. 如果找到组件则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem",
|
||||
meta=(DisplayName="Find Typed Ability System Component", DefaultToSelf="Actor", DynamicOutputParam="ASC", DeterminesOutputType="DesiredClass", ExpandBoolAsExecs="ReturnValue"))
|
||||
static bool FindAbilitySystemComponent(AActor* Actor, TSubclassOf<UAbilitySystemComponent> DesiredClass, UAbilitySystemComponent*& ASC);
|
||||
|
||||
/**
|
||||
* Retrieves an ability system component from an actor.
|
||||
* 从演员获取技能系统组件。
|
||||
* @param Actor The actor to search. 要搜索的演员。
|
||||
* @param DesiredClass The desired class of the component. 所需的组件类。
|
||||
* @return The found ability system component, or nullptr if not found. 找到的技能系统组件,未找到时为nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem",
|
||||
meta=(DisplayName="Get Typed Ability System Component", DefaultToSelf="Actor", DynamicOutputParam="ReturnValue", DeterminesOutputType="DesiredClass"))
|
||||
static UAbilitySystemComponent* GetAbilitySystemComponent(AActor* Actor, TSubclassOf<UAbilitySystemComponent> DesiredClass);
|
||||
|
||||
/**
|
||||
* Initializes the actor info for an ability system component.
|
||||
* 初始化技能系统组件的Actor信息。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param InOwnerActor The owner actor. 拥有者演员。
|
||||
* @param InAvatarActor The avatar actor. 化身演员。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void InitAbilityActorInfo(UAbilitySystemComponent* AbilitySystem, AActor* InOwnerActor, AActor* InAvatarActor);
|
||||
|
||||
/**
|
||||
* Retrieves the owner actor of an ability system component.
|
||||
* 获取技能系统组件的拥有者演员。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @return The owner actor. 拥有者演员。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static AActor* GetOwnerActor(UAbilitySystemComponent* AbilitySystem);
|
||||
|
||||
/**
|
||||
* Retrieves the avatar actor of an ability system component.
|
||||
* 获取技能系统组件的化身演员。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @return The avatar actor. 化身演员。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static AActor* GetAvatarActor(UAbilitySystemComponent* AbilitySystem);
|
||||
|
||||
/**
|
||||
* Handles a gameplay event on an ability system component.
|
||||
* 在技能系统组件上处理游戏事件。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param EventTag The event tag. 事件标签。
|
||||
* @param Payload The event data payload. 事件数据负载。
|
||||
* @return The number of successful ability activations. 成功激活的技能数量。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static int32 HandleGameplayEvent(UAbilitySystemComponent* AbilitySystem, FGameplayTag EventTag, const FGameplayEventData& Payload);
|
||||
|
||||
/**
|
||||
* Attempts to activate abilities one by one.
|
||||
* 尝试逐一激活技能。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param AbilitiesToActivate Array of abilities to activate. 要激活的技能数组。
|
||||
* @param bAllowRemoteActivation Whether to allow remote activation. 是否允许远程激活。
|
||||
* @param bFirstOnly Whether to stop after the first successful activation. 是否在第一次成功激活后停止。
|
||||
* @return True if at least one ability was activated, false otherwise. 如果至少激活一个技能则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem", meta=(DisplayName="Try Activate Abilities(one by one)"))
|
||||
static bool TryActivateAbilities(UAbilitySystemComponent* AbilitySystem, TArray<FGameplayAbilitySpecHandle> AbilitiesToActivate, bool bAllowRemoteActivation = true, bool bFirstOnly = true);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
bool HasActivatableTriggeredAbility(UAbilitySystemComponent* AbilitySystem, FGameplayTag Tag);
|
||||
|
||||
/**
|
||||
* Retrieves activatable ability specs matching all tags.
|
||||
* 获取与所有标签匹配的可激活技能规格。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Tags The tags to match. 要匹配的标签。
|
||||
* @param MatchingGameplayAbilities Array to store matching ability specs (output). 存储匹配技能规格的数组(输出)。
|
||||
* @param bOnlyAbilitiesThatSatisfyTagRequirements Whether to include only abilities satisfying tag requirements. 是否仅包括满足标签要求的技能。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void GetActivatableGameplayAbilitySpecsByAllMatchingTags(const UAbilitySystemComponent* AbilitySystem, const FGameplayTagContainer& Tags,
|
||||
TArray<FGameplayAbilitySpecHandle>& MatchingGameplayAbilities, bool bOnlyAbilitiesThatSatisfyTagRequirements = true);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void GetActivatableGameplayAbilitySpecs(const UAbilitySystemComponent* AbilitySystem, const FGameplayTagContainer& Tags, const UObject* SourceObject,
|
||||
TArray<FGameplayAbilitySpecHandle>& MatchingGameplayAbilities, bool bOnlyAbilitiesThatSatisfyTagRequirements = true);
|
||||
|
||||
/**
|
||||
* Retrieves the first activatable ability matching all tags.
|
||||
* 获取与所有标签匹配的第一个可激活技能。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Tags The tags to match. 要匹配的标签。
|
||||
* @param MatchingGameplayAbility The matching ability spec handle (output). 匹配的技能句柄(输出)。
|
||||
* @param bOnlyAbilitiesThatSatisfyTagRequirements Whether to include only abilities satisfying tag requirements. 是否仅包括满足标签要求的技能。
|
||||
* @return True if a matching ability was found, false otherwise. 如果找到匹配技能则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure=false, Category = "GGA|AbilitySystem", meta=(ExpandBoolAsExecs="ReturnValue"))
|
||||
static bool GetFirstActivatableAbilityByAllMatchingTags(const UAbilitySystemComponent* AbilitySystem, FGameplayTagContainer Tags, FGameplayAbilitySpecHandle& MatchingGameplayAbility,
|
||||
bool bOnlyAbilitiesThatSatisfyTagRequirements = true);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure=false, Category = "GGA|AbilitySystem", meta=(ExpandBoolAsExecs="ReturnValue"))
|
||||
static bool GetFirstActivatableAbility(const UAbilitySystemComponent* AbilitySystem, FGameplayTagContainer Tags, FGameplayAbilitySpecHandle& MatchingGameplayAbility, const UObject* SourceObject,
|
||||
bool bOnlyAbilitiesThatSatisfyTagRequirements = true);
|
||||
|
||||
/**
|
||||
* Retrieves active ability instances matching the specified tags.
|
||||
* 获取与指定标签匹配的激活技能实例。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Tags The tags to match. 要匹配的标签。
|
||||
* @param MatchingAbilityInstances Array to store matching ability instances. 存储匹配技能实例的数组。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void GetActiveAbilityInstancesWithTags(const UAbilitySystemComponent* AbilitySystem, const FGameplayTagContainer& Tags, TArray<UGameplayAbility*>& MatchingAbilityInstances);
|
||||
|
||||
/**
|
||||
* Sends a gameplay event to an actor.
|
||||
* 向演员发送游戏事件。
|
||||
* @param Actor The actor to send the event to. 要发送事件的演员。
|
||||
* @param EventTag The event tag. 事件标签。
|
||||
* @param Payload The event data payload. 事件数据负载。
|
||||
* @return True if any abilities were activated, false otherwise. 如果激活了任何技能则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem", Meta = (Tooltip = "This function can be used to trigger an ability on the actor in question with useful payload data."))
|
||||
static bool SendGameplayEventToActor(AActor* Actor, FGameplayTag EventTag, FGameplayEventData Payload);
|
||||
|
||||
/**
|
||||
* Breaks down ability ended data into its components.
|
||||
* 将技能结束数据分解为其组件。
|
||||
* @param AbilityEndedData The ability ended data. 技能结束数据。
|
||||
* @param AbilityThatEnded The ability that ended (output). 结束的技能(输出)。
|
||||
* @param AbilitySpecHandle The ability spec handle (output). 技能句柄(输出)。
|
||||
* @param bReplicateEndAbility Whether to replicate the end ability (output). 是否复制结束技能(输出)。
|
||||
* @param bWasCancelled Whether the ability was cancelled (output). 技能是否被取消(输出)。
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static void BreakAbilityEndedData(const FAbilityEndedData& AbilityEndedData, UGameplayAbility*& AbilityThatEnded, FGameplayAbilitySpecHandle& AbilitySpecHandle, bool& bReplicateEndAbility,
|
||||
bool& bWasCancelled);
|
||||
|
||||
/**
|
||||
* Finds all abilities matching the provided tags in order.
|
||||
* 按顺序查找与提供的标签匹配的所有技能。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Tags The tags to match. 要匹配的标签。
|
||||
* @param OutAbilityHandles Array to store matching ability handles (output). 存储匹配技能句柄的数组(输出)。
|
||||
* @param bExactMatch Whether to require an exact tag match. 是否要求完全标签匹配。
|
||||
* @return True if any abilities were found, false otherwise. 如果找到任何技能则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GGA|AbilitySystem", meta=(ExpandBoolAsExecs="ReturnValue"))
|
||||
static bool FindAllAbilitiesWithTagsInOrder(const UAbilitySystemComponent* AbilitySystem, TArray<FGameplayTag> Tags, TArray<FGameplayAbilitySpecHandle>& OutAbilityHandles,
|
||||
bool bExactMatch = true);
|
||||
|
||||
/**
|
||||
* Finds the first ability matching a gameplay tag query.
|
||||
* 查找与游戏标签查询匹配的第一个技能。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param OutAbilityHandle The matching ability handle (output). 匹配的技能句柄(输出)。
|
||||
* @param Query The gameplay tag query. 游戏标签查询。
|
||||
* @param SourceObject Optional source object filter. 可选的源对象过滤(只会返回源对象与之匹配的Ability)。
|
||||
* @return True if a matching ability was found, false otherwise. 如果找到匹配技能则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GGA|AbilitySystem", meta=(ExpandBoolAsExecs="ReturnValue"))
|
||||
static bool FindAbilityMatchingQuery(const UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle& OutAbilityHandle, FGameplayTagQuery Query, const UObject* SourceObject = nullptr);
|
||||
|
||||
static FGameplayAbilitySpec* FindAbilitySpecFromClass(const UAbilitySystemComponent* AbilitySystem, TSubclassOf<UGameplayAbility> AbilityClass, const UObject* SourceObject = nullptr);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GGA|AbilitySystem", meta=(ExpandBoolAsExecs="ReturnValue"))
|
||||
static bool FindAbilityFromClass(const UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle& OutAbilityHandle, TSubclassOf<UGameplayAbility> AbilityClass,
|
||||
const UObject* SourceObject = nullptr);
|
||||
|
||||
/**
|
||||
* Finds the first ability matching the provided tags.
|
||||
* 查找与提供的标签匹配的第一个技能。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param OutAbilityHandle The matching ability handle (output). 匹配的技能句柄(输出)。
|
||||
* @param Tags The tags to match. 要匹配的标签。
|
||||
* @param bExactMatch Whether to require an exact tag match. 是否要求完全标签匹配。
|
||||
* @param SourceObject Optional source object filter. 可选的源对象过滤(只会返回源对象与之匹配的Ability)。
|
||||
* @return True if a matching ability was found, false otherwise. 如果找到匹配技能则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GGA|AbilitySystem", meta=(ExpandBoolAsExecs="ReturnValue"))
|
||||
static bool FindAbilityWithTags(const UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle& OutAbilityHandle, FGameplayTagContainer Tags, bool bExactMatch = true,
|
||||
const UObject* SourceObject = nullptr);
|
||||
|
||||
/**
|
||||
* Adds a non-replicated gameplay tag to an ability system component.
|
||||
* 向技能系统组件添加非复制的游戏标签。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param GameplayTag The tag to add. 要添加的标签。
|
||||
* @param Count The number of times to add the tag. 添加标签的次数。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void AddLooseGameplayTag(UAbilitySystemComponent* AbilitySystem, const FGameplayTag& GameplayTag, int32 Count = 1);
|
||||
|
||||
/**
|
||||
* Adds multiple non-replicated gameplay tags to an ability system component.
|
||||
* 向技能系统组件添加多个非复制的游戏标签。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param GameplayTags The tags to add. 要添加的标签。
|
||||
* @param Count The number of times to add the tags. 添加标签的次数。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void AddLooseGameplayTags(UAbilitySystemComponent* AbilitySystem, const FGameplayTagContainer& GameplayTags, int32 Count = 1);
|
||||
|
||||
/**
|
||||
* Removes a non-replicated gameplay tag from an ability system component.
|
||||
* 从技能系统组件移除非复制的游戏标签。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param GameplayTag The tag to remove. 要移除的标签。
|
||||
* @param Count The number of times to remove the tag. 移除标签的次数。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void RemoveLooseGameplayTag(UAbilitySystemComponent* AbilitySystem, const FGameplayTag& GameplayTag, int32 Count = 1);
|
||||
|
||||
/**
|
||||
* Removes multiple non-replicated gameplay tags from an ability system component.
|
||||
* 从技能系统组件移除多个非复制的游戏标签。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param GameplayTags The tags to remove. 要移除的标签。
|
||||
* @param Count The number of times to remove the tags. 移除标签的次数。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void RemoveLooseGameplayTags(UAbilitySystemComponent* AbilitySystem, const FGameplayTagContainer& GameplayTags, int32 Count = 1);
|
||||
|
||||
/**
|
||||
* Removes all gameplay cues from an ability system component.
|
||||
* 从技能系统组件移除所有游戏反馈。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void RemoveAllGameplayCues(UAbilitySystemComponent* AbilitySystem);
|
||||
|
||||
#pragma endregion AbilitySystem
|
||||
|
||||
#pragma region AnimMontage Support
|
||||
|
||||
/** Plays a montage and handles replication and prediction based on passed in ability/activation info */
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static float PlayMontage(UAbilitySystemComponent* AbilitySystem, UGameplayAbility* AnimatingAbility, FGameplayAbilityActivationInfo ActivationInfo, UAnimMontage* Montage, float InPlayRate,
|
||||
FName StartSectionName = NAME_None,
|
||||
float StartTimeSeconds = 0.0f);
|
||||
|
||||
/** Stops whatever montage is currently playing. Expectation is caller should only be stopping it if they are the current animating ability (or have good reason not to check) */
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void CurrentMontageStop(UAbilitySystemComponent* AbilitySystem, float OverrideBlendOutTime = -1.0f);
|
||||
|
||||
/** Stops current montage if it's the one given as the Montage param */
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void StopMontageIfCurrent(UAbilitySystemComponent* AbilitySystem, const UAnimMontage* Montage, float OverrideBlendOutTime = -1.0f);
|
||||
|
||||
/** Clear the animating ability that is passed in, if it's still currently animating */
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void ClearAnimatingAbility(UAbilitySystemComponent* AbilitySystem, UGameplayAbility* Ability);
|
||||
|
||||
/** Jumps current montage to given section. Expectation is caller should only be stopping it if they are the current animating ability (or have good reason not to check) */
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void CurrentMontageJumpToSection(UAbilitySystemComponent* AbilitySystem, FName SectionName);
|
||||
|
||||
/** Sets current montages next section name. Expectation is caller should only be stopping it if they are the current animating ability (or have good reason not to check) */
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void CurrentMontageSetNextSectionName(UAbilitySystemComponent* AbilitySystem, FName FromSectionName, FName ToSectionName);
|
||||
|
||||
/** Sets current montage's play rate */
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void CurrentMontageSetPlayRate(UAbilitySystemComponent* AbilitySystem, float InPlayRate);
|
||||
|
||||
/**
|
||||
* Checks if the specified ability is the current animating ability.
|
||||
* 检查指定技能是否为当前播放动画的技能。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability to check. 要检查的技能。
|
||||
* @return True if the ability is animating, false otherwise. 如果技能正在播放动画则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static bool IsAnimatingAbility(UAbilitySystemComponent* AbilitySystem, UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Retrieves the ability instance playing the specified animation.
|
||||
* 获取播放指定动画的技能实例。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @return The ability instance, or nullptr if not found. 技能实例,未找到时为nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static UGameplayAbility* GetAnimatingAbility(UAbilitySystemComponent* AbilitySystem);
|
||||
|
||||
/**
|
||||
* Retrieves the ability instance playing the specified animation on an actor.
|
||||
* 获取在演员上播放指定动画的技能实例。
|
||||
* @param Actor The actor to search. 要搜索的演员。
|
||||
* @param Animation The animation to check. 要检查的动画。
|
||||
* @return The ability instance, or nullptr if not found. 技能实例,未找到时为nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem", meta=(DefaultToSelf="Actor"))
|
||||
static UGameplayAbility* GetAnimatingAbilityFromActor(AActor* Actor, UAnimSequenceBase* Animation);
|
||||
|
||||
/**
|
||||
* Finds the ability instance playing the specified animation with a desired class.
|
||||
* 查找播放指定动画且具有所需类的技能实例。
|
||||
* @param Actor The actor to search. 要搜索的演员。
|
||||
* @param Animation The animation to check. 要检查的动画。
|
||||
* @param DesiredClass The desired ability class. 所需的技能类。
|
||||
* @param AbilityInstance The found ability instance. 找到的技能实例。
|
||||
* @return True if an ability was found, false otherwise. 如果找到技能则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem",
|
||||
meta=(DefaultToSelf="Actor", DisplayName="Get Animating Ability from Actor", DeterminesOutputType=DesiredClass, DynamicOutputParam=AbilityInstance, ExpandBoolAsExecs=ReturnValue))
|
||||
static bool FindAnimatingAbilityFromActor(AActor* Actor, UAnimSequenceBase* Animation, TSubclassOf<UGameplayAbility> DesiredClass, UGameplayAbility*& AbilityInstance);
|
||||
|
||||
/** Returns montage that is currently playing */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static UAnimMontage* GetCurrentMontage(UAbilitySystemComponent* AbilitySystem);
|
||||
|
||||
/** Get SectionID of currently playing AnimMontage */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static int32 GetCurrentMontageSectionID(UAbilitySystemComponent* AbilitySystem);
|
||||
|
||||
/** Get SectionName of currently playing AnimMontage */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static FName GetCurrentMontageSectionName(UAbilitySystemComponent* AbilitySystem);
|
||||
|
||||
/** Get length in time of current section */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static float GetCurrentMontageSectionLength(UAbilitySystemComponent* AbilitySystem);
|
||||
|
||||
/** Returns amount of time left in current section */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static float GetCurrentMontageSectionTimeLeft(UAbilitySystemComponent* AbilitySystem);
|
||||
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Ability
|
||||
|
||||
/**
|
||||
* Sets the input pressed state for an ability.
|
||||
* 为技能设置输入按下状态。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void SetAbilityInputPressed(UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Sets the input released state for an ability.
|
||||
* 为技能设置输入释放状态。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void SetAbilityInputReleased(UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Checks if an ability can be activated.
|
||||
* 检查技能是否可以激活。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param AbilityToActivate The ability to activate. 要激活的技能。
|
||||
* @param RelevantTags Tags relevant to the activation check (output). 与激活检查相关的标签(输出)。
|
||||
* @return True if the ability can be activated, false otherwise. 如果技能可以激活则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure=false, Category = "GGA|AbilitySystem", meta=(ExpandBoolAsExecs="ReturnValue"))
|
||||
static bool CanActivateAbility(const UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle AbilityToActivate, FGameplayTagContainer& RelevantTags);
|
||||
|
||||
/**
|
||||
* Selects the first ability that can be activated from a list.
|
||||
* 从列表中选择第一个可以激活的技能。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Abilities Array of abilities to check. 要检查的技能数组。
|
||||
* @param OutAbilityHandle The selected ability handle (output). 选中的技能句柄(输出)。
|
||||
* @return True if an ability was selected, false otherwise. 如果选中技能则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem", meta=(ExpandBoolAsExecs="ReturnValue"))
|
||||
static bool SelectFirstCanActivateAbility(const UAbilitySystemComponent* AbilitySystem, TArray<FGameplayAbilitySpecHandle> Abilities, FGameplayAbilitySpecHandle& OutAbilityHandle);
|
||||
|
||||
/**
|
||||
* Cancels an ability.
|
||||
* 取消一个技能。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle to cancel. 要取消的技能句柄。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void CancelAbility(UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Cancels abilities based on tags.
|
||||
* 根据标签取消技能。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param WithTags Tags to include for cancellation. 要包含的标签。
|
||||
* @param WithoutTags Tags to exclude from cancellation. 要排除的标签。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|AbilitySystem")
|
||||
static void CancelAbilities(UAbilitySystemComponent* AbilitySystem, FGameplayTagContainer WithTags, FGameplayTagContainer WithoutTags);
|
||||
|
||||
/**
|
||||
* Checks if an ability's primary instance is active.
|
||||
* 检查技能的主要实例是否激活。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
* @return True if the ability instance is active, false otherwise. 如果技能实例激活则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem", meta=(DisplayName="Is Ability Primary Instance Active"))
|
||||
static bool IsAbilityInstanceActive(const UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Retrieves all ability instances from ability spec, including replicated and non-replicated instances.
|
||||
* 从技能规格获取所有技能实例(含复制的和未网络复制的)。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
* @return Array of spec's replicated and non-replicated ability instances. 复制以及非复制技能实例的组合。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static TArray<UGameplayAbility*> GetAbilityInstances(UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Retrieves the ability definition from ability spec.
|
||||
* 从技能规格获取技能定义。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
* @return The ability CDO. 技能CDO。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static const UGameplayAbility* GetAbilityCDO(UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Retrieves the level from ability spec.
|
||||
* 从技能规格获取技能的等级。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
* @return The ability level. 技能等级。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static int32 GetAbilityLevel(UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Retrieves the input ID from ability spec, if bound.
|
||||
* 从技能规格获取技能的输入ID(如果已绑定)。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
* @return The input ID. 输入ID。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static int32 GetAbilityInputId(UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Retrieves the source object from ability spec.
|
||||
* 从技能规格获取技能的源对象。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
* @return The source object. 源对象。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static UObject* GetAbilitySourceObject(UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Retrieves the dynamic tags from ability spec.
|
||||
* 从技能规格获取技能的动态标签。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
* @return The dynamic tag container. 动态标签容器。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static FGameplayTagContainer GetAbilityDynamicTags(UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Retrieves the primary instance from ability spec.
|
||||
* 从技能规格获取技能的主要实例。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
* @return The primary ability instance. 主要技能实例。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static UGameplayAbility* GetAbilityPrimaryInstance(UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
/**
|
||||
* Checks if an ability spec‘s active count > 0.
|
||||
* 检查技能规格的激活计数是否>0。
|
||||
* @attention Only available on server side,The spec's active acount are not replicated! 仅在服务端有效,实例的ActiveCount未网络同步。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param Ability The ability spec handle. 技能句柄。
|
||||
* @return True if the ability is active, false otherwise. 如果技能激活则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static bool IsAbilityActive(const UAbilitySystemComponent* AbilitySystem, FGameplayAbilitySpecHandle Ability);
|
||||
|
||||
#pragma endregion Ability
|
||||
|
||||
#pragma region AttributeSet
|
||||
/**
|
||||
* Finds an attribute set by class.
|
||||
* 通过类查找属性集。
|
||||
* @param AbilitySystem The ability system component. 技能系统组件。
|
||||
* @param AttributeSetClass The attribute set class to find. 要查找的属性集类。
|
||||
* @return The found attribute set, or nullptr if not found. 找到的属性集,未找到时为nullptr。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|AbilitySystem")
|
||||
static UAttributeSet* GetAttributeSetByClass(const UAbilitySystemComponent* AbilitySystem, const TSubclassOf<UAttributeSet> AttributeSetClass);
|
||||
#pragma endregion
|
||||
|
||||
#pragma region ScalableFloat
|
||||
/**
|
||||
* Retrieves the value of a scalable float at a specific level.
|
||||
* 获取特定级别下可扩展浮点数的值。
|
||||
* @param ScalableFloat The scalable float. 可扩展浮点数。
|
||||
* @param Level The level to evaluate. 要评估的级别。
|
||||
* @param ContextString Context string for debugging. 用于调试的上下文字符串。
|
||||
* @return The evaluated value. 评估值。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|Extensions|ScalableFloat")
|
||||
static float GetValueAtLevel(const FScalableFloat& ScalableFloat, float Level, FString ContextString);
|
||||
#pragma endregion
|
||||
};
|
||||
@@ -0,0 +1,113 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayAbilitySpecHandle.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "Abilities/GameplayAbilityTypes.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "GGA_GameplayAbilityFunctionLibrary.generated.h"
|
||||
|
||||
class UGameplayAbility;
|
||||
|
||||
/**
|
||||
* Blueprint function library for gameplay ability operations.
|
||||
* 用于游戏技能操作的蓝图函数库。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_GameplayAbilityFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Checks if an ability spec handle is valid.
|
||||
* 检查技能规格句柄是否有效。
|
||||
* @param Handle The ability spec handle. 技能规格句柄。
|
||||
* @return True if the handle is valid, false otherwise. 如果句柄有效则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayAbility")
|
||||
static bool IsAbilitySpecHandleValid(FGameplayAbilitySpecHandle Handle);
|
||||
|
||||
/**
|
||||
* Retrieves the default object for an ability class.
|
||||
* 获取技能类的默认对象。
|
||||
* @param AbilityClass The ability class. 技能类。
|
||||
* @return The default object for the ability class. 技能类的默认对象。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayAbility")
|
||||
static const UGameplayAbility* GetAbilityCDOFromClass(TSubclassOf<UGameplayAbility> AbilityClass);
|
||||
|
||||
/**
|
||||
* Retrieves the current ability spec handle.
|
||||
* 获取当前技能规格句柄。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @return The ability spec handle. 技能规格句柄。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category= "GGA|GameplayAbility", meta = (DefaultToSelf="Ability"))
|
||||
static FGameplayAbilitySpecHandle GetCurrentAbilitySpecHandle(const UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Checks if an ability is currently active.
|
||||
* 检查技能是否当前激活。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @return True if the ability is active, false otherwise. 如果技能激活则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category= "GGA|GameplayAbility", meta = (DefaultToSelf="Ability"))
|
||||
static bool IsAbilityActive(const UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Retrieves the replication policy for an ability.
|
||||
* 获取技能的复制策略。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @return The replication policy. 复制策略。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category= "GGA|GameplayAbility", meta = (DefaultToSelf="Ability"))
|
||||
static EGameplayAbilityReplicationPolicy::Type GetReplicationPolicy(const UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Retrieves the instancing policy for an ability.
|
||||
* 获取技能的实例化策略。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @return The instancing policy. 实例化策略。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category= "GGA|GameplayAbility", meta = (DefaultToSelf="Ability"))
|
||||
static EGameplayAbilityInstancingPolicy::Type GetInstancingPolicy(const UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Retrieves the tags associated with an ability.
|
||||
* 获取与技能关联的标签。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @return The gameplay tag container. 游戏标签容器。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayAbility", meta = (DefaultToSelf="Ability"))
|
||||
static FGameplayTagContainer GetAbilityTags(const UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Checks if the ability is running on a predicting client.
|
||||
* 检查技能是否在预测客户端上运行。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @return True if running on a predicting client, false otherwise. 如果在预测客户端上运行则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayAbility", meta = (DefaultToSelf="Ability"))
|
||||
static bool IsPredictingClient(const UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Checks if the ability is for a remote client.
|
||||
* 检查技能是否用于远程客户端。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @return True if for a remote client, false otherwise. 如果用于远程客户端则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayAbility", meta = (DefaultToSelf="Ability"))
|
||||
static bool IsForRemoteClient(const UGameplayAbility* Ability);
|
||||
|
||||
/**
|
||||
* Checks if the ability has authority or a valid prediction key.
|
||||
* 检查技能是否具有权限或有效预测键。
|
||||
* @param Ability The gameplay ability. 游戏技能。
|
||||
* @return True if it has authority or a valid prediction key, false otherwise. 如果具有权限或有效预测键则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayAbility", meta = (DefaultToSelf="Ability"))
|
||||
static bool HasAuthorityOrPredictionKey(const UGameplayAbility* Ability);
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Abilities/GameplayAbilityTargetTypes.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "StructUtils/InstancedStruct.h"
|
||||
#include "GGA_GameplayAbilityTargetDataFunctionLibrary.generated.h"
|
||||
|
||||
/**
|
||||
* Blueprint function library for gameplay ability target data operations.
|
||||
* 用于游戏技能目标数据操作的蓝图函数库。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_GameplayAbilityTargetDataFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|TargetData")
|
||||
static FGameplayAbilityTargetDataHandle AbilityTargetDataFromPayload(const FInstancedStruct& Payload);
|
||||
|
||||
/** Returns the hit result for a given index if it exists */
|
||||
UFUNCTION(BlueprintPure, Category = "Ability|TargetData")
|
||||
static FInstancedStruct GetPayloadFromTargetData(const FGameplayAbilityTargetDataHandle& TargetData, int32 Index);
|
||||
|
||||
/**
|
||||
* Creates a target data handle from hit results.
|
||||
* 从命中结果创建目标数据句柄。
|
||||
* @param HitResults Array of hit results. 命中结果数组。
|
||||
* @param OneTargetPerHandle Whether to create one target per handle. 是否每个句柄一个目标。
|
||||
* @return The target data handle. 目标数据句柄。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|TargetData")
|
||||
static FGameplayAbilityTargetDataHandle AbilityTargetDataFromHitResults(const TArray<FHitResult>& HitResults, bool OneTargetPerHandle);
|
||||
|
||||
/**
|
||||
* Adds target data to an effect context.
|
||||
* 将目标数据添加到效果上下文。
|
||||
* @param TargetData The target data to add. 要添加的目标数据。
|
||||
* @param EffectContext The effect context to modify. 要修改的效果上下文。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|TargetData")
|
||||
static void AddTargetDataToContext(UPARAM(ref)
|
||||
FGameplayAbilityTargetDataHandle TargetData, UPARAM(ref)
|
||||
FGameplayEffectContextHandle EffectContext);
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayEffectTypes.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "GGA_GameplayCueFunctionLibrary.generated.h"
|
||||
|
||||
/**
|
||||
* Blueprint function library for gameplay cue operations.
|
||||
* 用于游戏反馈操作的蓝图函数库。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_GameplayCueFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Executes a local gameplay cue on an actor.
|
||||
* 在演员上执行本地游戏反馈。
|
||||
* @param Actor The actor to execute the cue on. 要执行反馈的演员。
|
||||
* @param GameplayCueTag The gameplay cue tag. 游戏反馈标签。
|
||||
* @param GameplayCueParameters Parameters for the gameplay cue. 游戏反馈参数。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayCue", Meta = (DefaultToSelf="Actor", AutoCreateRefTerm = "GameplayCueParameters", GameplayTagFilter = "GameplayCue"))
|
||||
static void ExecuteGameplayCueLocal(AActor* Actor, const FGameplayTag GameplayCueTag, const FGameplayCueParameters& GameplayCueParameters);
|
||||
|
||||
/**
|
||||
* Adds a local gameplay cue to an actor.
|
||||
* 向演员添加本地游戏反馈。
|
||||
* @param Actor The actor to add the cue to. 要添加反馈的演员。
|
||||
* @param GameplayCueTag The gameplay cue tag. 游戏反馈标签。
|
||||
* @param GameplayCueParameters Parameters for the gameplay cue. 游戏反馈参数。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayCue", Meta = (DefaultToSelf="Actor", AutoCreateRefTerm = "GameplayCueParameters", GameplayTagFilter = "GameplayCue"))
|
||||
static void AddGameplayCueLocal(AActor* Actor, const FGameplayTag GameplayCueTag, const FGameplayCueParameters& GameplayCueParameters);
|
||||
|
||||
/**
|
||||
* Removes a local gameplay cue from an actor.
|
||||
* 从演员移除本地游戏反馈。
|
||||
* @param Actor The actor to remove the cue from. 要移除反馈的演员。
|
||||
* @param GameplayCueTag The gameplay cue tag. 游戏反馈标签。
|
||||
* @param GameplayCueParameters Parameters for the gameplay cue. 游戏反馈参数。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayCue", Meta = (DefaultToSelf="Actor", AutoCreateRefTerm = "GameplayCueParameters", GameplayTagFilter = "GameplayCue"))
|
||||
static void RemoveGameplayCueLocal(AActor* Actor, const FGameplayTag GameplayCueTag, const FGameplayCueParameters& GameplayCueParameters);
|
||||
};
|
||||
@@ -0,0 +1,233 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayEffectExecutionCalculation.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "GGA_GameplayEffectCalculationFunctionLibrary.generated.h"
|
||||
|
||||
/**
|
||||
* Blueprint function library for gameplay effect calculation operations.
|
||||
* 用于游戏效果计算操作的蓝图函数库。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_GameplayEffectCalculationFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Retrieves the owning gameplay effect spec.
|
||||
* 获取拥有的游戏效果规格。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @return The owning gameplay effect spec. 拥有的游戏效果规格。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static const FGameplayEffectSpec& GetOwningSpec(const FGameplayEffectCustomExecutionParameters& InParams);
|
||||
|
||||
/** Simple accessor to the Passed In Tags to this execution */
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static const FGameplayTagContainer& GetPassedInTags(const FGameplayEffectCustomExecutionParameters& InParams);
|
||||
|
||||
/**
|
||||
* Retrieves the effect context from execution parameters.
|
||||
* 从执行参数获取效果上下文。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @return The effect context handle. 效果上下文句柄。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static FGameplayEffectContextHandle GetEffectContext(const FGameplayEffectCustomExecutionParameters& InParams);
|
||||
|
||||
/**
|
||||
* Retrieves the SetByCaller magnitude by tag from execution parameters.
|
||||
* 从执行参数通过标签获取SetByCaller大小。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @param Tag The tag to query. 要查询的标签。
|
||||
* @param WarnIfNotFound Whether to warn if not found. 如果未找到是否警告。
|
||||
* @param DefaultIfNotFound Default value if not found. 如果未找到的默认值。
|
||||
* @return The magnitude value, or default if not found. 大小值,未找到时返回默认值。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GGA|Calculation")
|
||||
static float GetSetByCallerMagnitudeByTag(const FGameplayEffectCustomExecutionParameters& InParams, const FGameplayTag& Tag, bool WarnIfNotFound = false, float DefaultIfNotFound = 0.f);
|
||||
|
||||
/**
|
||||
* Retrieves the SetByCaller magnitude by name from execution parameters.
|
||||
* 从执行参数通过名称获取SetByCaller大小。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @param MagnitudeName The name to query. 要查询的名称。
|
||||
* @param WarnIfNotFound Whether to warn if not found. 如果未找到是否警告。
|
||||
* @param DefaultIfNotFound Default value if not found. 如果未找到的默认值。
|
||||
* @return The magnitude value, or default if not found. 大小值,未找到时返回默认值。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure = false, Category = "GGA|Calculation")
|
||||
static float GetSetByCallerMagnitudeByName(const FGameplayEffectCustomExecutionParameters& InParams, const FName& MagnitudeName, bool WarnIfNotFound = false, float DefaultIfNotFound = 0.f);
|
||||
|
||||
/**
|
||||
* Retrieves source aggregated tags from the owning spec.
|
||||
* 从拥有规格获取源聚合标签。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @return The source aggregated tags. 源聚合标签。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static FGameplayTagContainer GetSourceAggregatedTags(const FGameplayEffectCustomExecutionParameters& InParams);
|
||||
|
||||
/**
|
||||
* Retrieves target aggregated tags from the owning spec.
|
||||
* 从拥有规格获取目标聚合标签。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @return The target aggregated tags. 目标聚合标签。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static FGameplayTagContainer GetTargetAggregatedTags(const FGameplayEffectCustomExecutionParameters& InParams);
|
||||
|
||||
/**
|
||||
* Retrieves the target ability system component.
|
||||
* 获取目标技能系统组件。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @return The target ability system component. 目标技能系统组件。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static UAbilitySystemComponent* GetTargetASC(const FGameplayEffectCustomExecutionParameters& InParams);
|
||||
|
||||
/**
|
||||
* Retrieves the target actor.
|
||||
* 获取目标演员。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @return The target actor. 目标演员。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static AActor* GetTargetActor(const FGameplayEffectCustomExecutionParameters& InParams);
|
||||
|
||||
/**
|
||||
* Retrieves the source ability system component.
|
||||
* 获取源技能系统组件。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @return The source ability system component. 源技能系统组件。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static UAbilitySystemComponent* GetSourceASC(const FGameplayEffectCustomExecutionParameters& InParams);
|
||||
|
||||
/**
|
||||
* Retrieves the source actor.
|
||||
* 获取源演员。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @return The source actor. 源演员。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static AActor* GetSourceActor(const FGameplayEffectCustomExecutionParameters& InParams);
|
||||
|
||||
/**
|
||||
* Attempts to calculate the magnitude of a captured attribute.
|
||||
* 尝试计算捕获属性的值。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @param InAttributeCaptureDefinitions Attribute capture definitions. 属性捕获定义。
|
||||
* @param InAttribute The attribute to calculate. 要计算的属性。
|
||||
* @param OutMagnitude The calculated magnitude (output). 计算出的大小(输出)。
|
||||
* @return True if calculation was successful, false otherwise. 如果计算成功则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static bool AttemptCalculateCapturedAttributeMagnitude(const FGameplayEffectCustomExecutionParameters& InParams, TArray<FGameplayEffectAttributeCaptureDefinition> InAttributeCaptureDefinitions,
|
||||
FGameplayAttribute InAttribute,
|
||||
float& OutMagnitude);
|
||||
|
||||
/**
|
||||
* Attempts to calculate the magnitude of a captured attribute with source and target tags.
|
||||
* 尝试使用源和目标标签计算捕获属性的值。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @param SourceTags Source tags for the calculation. 用于计算的源标签。
|
||||
* @param TargetTags Target tags for the calculation. 用于计算的目标标签。
|
||||
* @param InAttributeCaptureDefinitions Attribute capture definitions. 属性捕获定义。
|
||||
* @param InAttribute The attribute to calculate. 要计算的属性。
|
||||
* @param OutMagnitude The calculated magnitude (output). 计算出的大小(输出)。
|
||||
* @return True if calculation was successful, false otherwise. 如果计算成功则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static bool AttemptCalculateCapturedAttributeMagnitudeExt(const FGameplayEffectCustomExecutionParameters& InParams, const FGameplayTagContainer& SourceTags,
|
||||
const FGameplayTagContainer& TargetTags, TArray<FGameplayEffectAttributeCaptureDefinition> InAttributeCaptureDefinitions,
|
||||
FGameplayAttribute InAttribute,
|
||||
float& OutMagnitude);
|
||||
|
||||
/**
|
||||
* Attempts to calculate the magnitude of a captured attribute with a base value.
|
||||
* 使用基础值尝试计算捕获属性的值。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @param InAttributeCaptureDefinitions Attribute capture definitions. 属性捕获定义。
|
||||
* @param InAttribute The attribute to calculate. 要计算的属性。
|
||||
* @param InBaseValue The base value for the calculation. 计算的基础值。
|
||||
* @param OutMagnitude The calculated magnitude (output). 计算出的大小(输出)。
|
||||
* @return True if calculation was successful, false otherwise. 如果计算成功则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category="GGA|Calculation")
|
||||
static bool AttemptCalculateCapturedAttributeMagnitudeWithBase(const FGameplayEffectCustomExecutionParameters& InParams,
|
||||
TArray<FGameplayEffectAttributeCaptureDefinition> InAttributeCaptureDefinitions,
|
||||
FGameplayAttribute InAttribute, float InBaseValue, float& OutMagnitude);
|
||||
|
||||
/**
|
||||
* Adds an output modifier to the execution output.
|
||||
* 将输出修改器添加到执行输出。
|
||||
* @param InExecutionOutput The execution output to modify. 要修改的执行输出。
|
||||
* @param InAttribute The attribute to modify. 要修改的属性。
|
||||
* @param InModifierOp The modifier operation type. 修改器操作类型。
|
||||
* @param InMagnitude The magnitude of the modifier. 修改器的大小。
|
||||
* @return The modified execution output. 修改后的执行输出。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="GGA|Calculation")
|
||||
static FGameplayEffectCustomExecutionOutput AddOutputModifier(UPARAM(ref)
|
||||
FGameplayEffectCustomExecutionOutput& InExecutionOutput, FGameplayAttribute InAttribute,
|
||||
EGameplayModOp::Type InModifierOp, float InMagnitude);
|
||||
|
||||
/**
|
||||
* Marks conditional gameplay effects to trigger.
|
||||
* 标记条件游戏效果以触发。
|
||||
* @param InExecutionOutput The execution output to modify. 要修改的执行输出。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="GGA|Calculation")
|
||||
static void MarkConditionalGameplayEffectsToTrigger(UPARAM(ref)
|
||||
FGameplayEffectCustomExecutionOutput& InExecutionOutput);
|
||||
|
||||
/**
|
||||
* Marks gameplay cues as handled manually.
|
||||
* 将游戏反馈标记为手动处理。
|
||||
* @param InExecutionOutput The execution output to modify. 要修改的执行输出。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="GGA|Calculation")
|
||||
static void MarkGameplayCuesHandledManually(UPARAM(ref)
|
||||
FGameplayEffectCustomExecutionOutput& InExecutionOutput);
|
||||
|
||||
/**
|
||||
* Marks the stack count as handled manually.
|
||||
* 将堆叠计数标记为手动处理。
|
||||
* @param InExecutionOutput The execution output to modify. 要修改的执行输出。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category="GGA|Calculation")
|
||||
static void MarkStackCountHandledManually(UPARAM(ref)
|
||||
FGameplayEffectCustomExecutionOutput& InExecutionOutput);
|
||||
|
||||
/**
|
||||
* Retrieves the effect context from a gameplay effect spec.
|
||||
* 从游戏效果规格获取效果上下文。
|
||||
* @param EffectSpec The gameplay effect spec. 游戏效果规格。
|
||||
* @return The effect context handle. 效果上下文句柄。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Calculation")
|
||||
static FGameplayEffectContextHandle GetEffectContextFromSpec(const FGameplayEffectSpec& EffectSpec);
|
||||
|
||||
/**
|
||||
* Adds a tag to the spec before applying modifiers.
|
||||
* 在应用修改器前向规格添加标签。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @param NewGameplayTag The tag to add. 要添加的标签。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Calculation")
|
||||
static void AddAssetTagForPreMod(const FGameplayEffectCustomExecutionParameters& InParams, FGameplayTag NewGameplayTag);
|
||||
|
||||
/**
|
||||
* Adds multiple tags to the spec before applying modifiers.
|
||||
* 在应用修改器前向规格添加多个标签。
|
||||
* @param InParams The execution parameters. 执行参数。
|
||||
* @param NewGameplayTags The tags to add. 要添加的标签。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Calculation")
|
||||
static void AddAssetTagsForPreMod(const FGameplayEffectCustomExecutionParameters& InParams, FGameplayTagContainer NewGameplayTags);
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GGA_AbilitySystemStructLibrary.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "GGA_GameplayEffectContainerFunctionLibrary.generated.h"
|
||||
|
||||
/**
|
||||
* Blueprint function library for gameplay effect container operations.
|
||||
* 用于游戏效果容器操作的蓝图函数库。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_GameplayEffectContainerFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Checks if the gameplay effect container is valid.
|
||||
* 检查游戏效果容器是否有效。
|
||||
* @param Container The gameplay effect container. 游戏效果容器。
|
||||
* @return True if the container is valid, false otherwise. 如果容器有效则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Container")
|
||||
static bool IsValidContainer(const FGGA_GameplayEffectContainer& Container);
|
||||
|
||||
/**
|
||||
* Checks if the container spec has valid effects.
|
||||
* 检查容器规格是否具有有效效果。
|
||||
* @param ContainerSpec The gameplay effect container spec. 游戏效果容器规格。
|
||||
* @return True if the spec has valid effects, false otherwise. 如果规格有有效效果则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Container")
|
||||
static bool HasValidEffects(const FGGA_GameplayEffectContainerSpec& ContainerSpec);
|
||||
|
||||
/**
|
||||
* Checks if the container spec has valid targets.
|
||||
* 检查容器规格是否具有有效目标。
|
||||
* @param ContainerSpec The gameplay effect container spec. 游戏效果容器规格。
|
||||
* @return True if the spec has valid targets, false otherwise. 如果规格有有效目标则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Container")
|
||||
static bool HasValidTargets(const FGGA_GameplayEffectContainerSpec& ContainerSpec);
|
||||
|
||||
/**
|
||||
* Adds targets to a copy of the effect container spec.
|
||||
* 将目标添加到效果容器规格的副本。
|
||||
* @param ContainerSpec The gameplay effect container spec. 游戏效果容器规格。
|
||||
* @param HitResults Array of hit results to add. 要添加的命中结果数组。
|
||||
* @param TargetActors Array of target actors to add. 要添加的目标演员数组。
|
||||
* @return The modified container spec. 修改后的容器规格。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayEffect|Container", meta = (AutoCreateRefTerm = "HitResults,TargetActors"))
|
||||
static FGGA_GameplayEffectContainerSpec AddTargets(const FGGA_GameplayEffectContainerSpec& ContainerSpec, const TArray<FHitResult>& HitResults,
|
||||
const TArray<AActor*>& TargetActors);
|
||||
|
||||
/**
|
||||
* Creates a gameplay effect container spec from a container and event data.
|
||||
* 从容器和事件数据创建游戏效果容器规格。
|
||||
* @param Container The gameplay effect container. 游戏效果容器。
|
||||
* @param EventData Event data for creating the spec. 用于创建规格的事件数据。
|
||||
* @param OverrideGameplayLevel Optional override for gameplay effect level. 可选的游戏效果等级覆盖。
|
||||
* @param SourceAbility Optional ability to derive source data. 可选的技能以获取源数据。
|
||||
* @return The created container spec. 创建的容器规格。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayEffect|Container", meta=(AutoCreateRefTerm = "EventData"))
|
||||
static FGGA_GameplayEffectContainerSpec MakeEffectContainerSpec(UPARAM(ref) const FGGA_GameplayEffectContainer& Container, const FGameplayEventData& EventData,
|
||||
int32 OverrideGameplayLevel = -1, UGameplayAbility* SourceAbility = nullptr);
|
||||
|
||||
/**
|
||||
* Applies a gameplay effect container spec.
|
||||
* 应用游戏效果容器规格。
|
||||
* @param ExecutingAbility The ability executing the spec. 执行规格的技能。
|
||||
* @param ContainerSpec The container spec to apply. 要应用的容器规格。
|
||||
* @return Array of active gameplay effect handles. 活动游戏效果句柄数组。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|Ability|EffectContainer",meta=(DefaultToSelf="ExecutingAbility"))
|
||||
static TArray<FActiveGameplayEffectHandle> ApplyEffectContainerSpec(UGameplayAbility* ExecutingAbility, const FGGA_GameplayEffectContainerSpec& ContainerSpec);
|
||||
|
||||
/**
|
||||
* Applies a gameplay effect container spec to all targets in its target data.
|
||||
* 将游戏效果容器规格应用于其目标数据中的所有目标。
|
||||
* @param ContainerSpec The container spec to apply. 要应用的容器规格。
|
||||
* @return Array of active gameplay effect handles. 活动游戏效果句柄数组。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayEffect|Container")
|
||||
static TArray<FActiveGameplayEffectHandle> ApplyExternalEffectContainerSpec(const FGGA_GameplayEffectContainerSpec& ContainerSpec);
|
||||
};
|
||||
@@ -0,0 +1,226 @@
|
||||
// Copyright 2025 https://yuewu.dev/en All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayEffectTypes.h"
|
||||
#include "GGA_GameplayEffectContext.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
#if ENGINE_MINOR_VERSION < 5
|
||||
#include "InstancedStruct.h"
|
||||
#else
|
||||
#include "StructUtils/InstancedStruct.h"
|
||||
#endif
|
||||
#include "GGA_GameplayEffectFunctionLibrary.generated.h"
|
||||
|
||||
UENUM()
|
||||
enum class EGGA_ContextPayloadResult : uint8
|
||||
{
|
||||
Valid,
|
||||
NotValid,
|
||||
};
|
||||
|
||||
/**
|
||||
* Blueprint function library for gameplay effect operations.
|
||||
* 用于游戏效果操作的蓝图函数库。
|
||||
*/
|
||||
UCLASS()
|
||||
class GENERICGAMEPLAYABILITIES_API UGGA_GameplayEffectFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
#pragma region EffectSpecHandle
|
||||
|
||||
/**
|
||||
* Retrieves the magnitude of a SetByCaller modifier by tag.
|
||||
* 通过标签获取SetByCaller修改器的大小。
|
||||
* @param SpecHandle The gameplay effect spec handle. 游戏效果规格句柄。
|
||||
* @param DataTag The tag to query. 要查询的标签。
|
||||
* @param WarnIfNotFound Whether to warn if the tag is not found. 如果未找到标签是否警告。
|
||||
* @param DefaultIfNotFound Default value if the tag is not found. 如果未找到标签的默认值。
|
||||
* @return The magnitude value, or default if not found. 大小值,未找到时返回默认值。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect")
|
||||
static float GetSetByCallerMagnitudeByTag(FGameplayEffectSpecHandle SpecHandle, FGameplayTag DataTag, bool WarnIfNotFound = false, float DefaultIfNotFound = 0.0f);
|
||||
|
||||
/**
|
||||
* Retrieves the magnitude of a SetByCaller modifier by name.
|
||||
* 通过名称获取SetByCaller修改器的大小。
|
||||
* @param SpecHandle The gameplay effect spec handle. 游戏效果规格句柄。
|
||||
* @param DataName The name to query. 要查询的名称。
|
||||
* @return The magnitude value, or zero if not found. 大小值,未找到时返回零。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect")
|
||||
static float GetSetByCallerMagnitudeByName(FGameplayEffectSpecHandle SpecHandle, FName DataName);
|
||||
|
||||
/**
|
||||
* Checks if the active gameplay effect handle is valid.
|
||||
* 检查活动游戏效果句柄是否有效。
|
||||
* @param Handle The active gameplay effect handle. 活动游戏效果句柄。
|
||||
* @return True if the handle is valid, false otherwise. 如果句柄有效则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect")
|
||||
static bool IsActiveGameplayEffectHandleValid(FActiveGameplayEffectHandle Handle);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region EffectSpec
|
||||
/**
|
||||
* Retrieves the magnitude of a SetByCaller modifier by tag.
|
||||
* 通过标签获取SetByCaller修改器的大小。
|
||||
* @param EffectSpec The gameplay effect spec . 游戏效果规格。
|
||||
* @param DataTag The tag to query. 要查询的标签。
|
||||
* @param WarnIfNotFound Whether to warn if the tag is not found. 如果未找到标签是否警告。
|
||||
* @param DefaultIfNotFound Default value if the tag is not found. 如果未找到标签的默认值。
|
||||
* @return The magnitude value, or default if not found. 大小值,未找到时返回默认值。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect")
|
||||
static float GetSetByCallerMagnitudeByTagFromSpec(const FGameplayEffectSpec& EffectSpec, FGameplayTag DataTag, bool WarnIfNotFound = false, float DefaultIfNotFound = 0.0f);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Effect Context
|
||||
/**
|
||||
* Retrieves gameplay tags from the effect context.
|
||||
* 从效果上下文中获取游戏标签。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @param ActorTagContainer Container for actor tags. 演员标签容器。
|
||||
* @param SpecTagContainer Container for spec tags. 规格标签容器。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayEffect|Context")
|
||||
static void GetOwnedGameplayTags(FGameplayEffectContextHandle EffectContext, FGameplayTagContainer& ActorTagContainer, FGameplayTagContainer& SpecTagContainer);
|
||||
|
||||
/**
|
||||
* Sets the instigator and effect causer in the effect context.
|
||||
* 在效果上下文中设置发起者和效果原因。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @param InInstigator The instigator actor. 发起者演员。
|
||||
* @param InEffectCauser The effect causer actor. 效果原因演员。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayEffect|Context")
|
||||
static void AddInstigator(FGameplayEffectContextHandle EffectContext, AActor* InInstigator, AActor* InEffectCauser);
|
||||
|
||||
/**
|
||||
* Sets the effect causer in the effect context.
|
||||
* 在效果上下文中设置效果原因。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @param InEffectCauser The effect causer actor. 效果原因演员。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayEffect|Context")
|
||||
static void SetEffectCauser(FGameplayEffectContextHandle EffectContext, AActor* InEffectCauser);
|
||||
|
||||
/**
|
||||
* Sets the ability in the effect context.
|
||||
* 在效果上下文中设置技能。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @param InGameplayAbility The gameplay ability to set. 要设置的游戏技能。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayEffect|Context")
|
||||
static void SetAbility(FGameplayEffectContextHandle EffectContext, const UGameplayAbility* InGameplayAbility);
|
||||
|
||||
/**
|
||||
* Retrieves the ability CDO from the effect context.
|
||||
* 从效果上下文中获取技能CDO。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @return The ability CDO. 技能CDO。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Context")
|
||||
static const UGameplayAbility* GetAbilityCDO(FGameplayEffectContextHandle EffectContext);
|
||||
|
||||
/**
|
||||
* Retrieves the ability instance from the effect context.
|
||||
* 从效果上下文中获取技能实例。
|
||||
* @attention The ability instance is not replicated so it's only valid on server side. 技能实例未网络复制,因此仅服务端可用。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @return The ability instance. 技能实例。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Context")
|
||||
static const UGameplayAbility* GetAbilityInstance(FGameplayEffectContextHandle EffectContext);
|
||||
|
||||
/**
|
||||
* Retrieves the ability level from the effect context.
|
||||
* 从效果上下文中获取技能等级。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @return The ability level. 技能等级。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Context")
|
||||
static int32 GetAbilityLevel(FGameplayEffectContextHandle EffectContext);
|
||||
|
||||
/**
|
||||
* Retrieves the instigator's ability system component.
|
||||
* 获取发起者的技能系统组件。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @return The instigator's ability system component. 发起者的技能系统组件。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Context")
|
||||
static UAbilitySystemComponent* GetInstigatorAbilitySystemComponent(FGameplayEffectContextHandle EffectContext);
|
||||
|
||||
/**
|
||||
* Retrieves the original instigator's ability system component.
|
||||
* 获取原始发起者的技能系统组件。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @return The original instigator's ability system component. 原始发起者的技能系统组件。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Context")
|
||||
static UAbilitySystemComponent* GetOriginalInstigatorAbilitySystemComponent(FGameplayEffectContextHandle EffectContext);
|
||||
|
||||
/**
|
||||
* Sets the source object in the effect context.
|
||||
* 在效果上下文中设置源对象。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @param NewSourceObject The source object to set. 要设置的源对象。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "GGA|GameplayEffect|Context")
|
||||
static void AddSourceObject(FGameplayEffectContextHandle EffectContext, const UObject* NewSourceObject);
|
||||
|
||||
/**
|
||||
* Checks if the effect context has an origin.
|
||||
* 检查效果上下文是否具有起源。
|
||||
* @param EffectContext The effect context handle. 效果上下文句柄。
|
||||
* @return True if the context has an origin, false otherwise. 如果上下文有起源则返回true,否则返回false。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Context")
|
||||
static bool HasOrigin(FGameplayEffectContextHandle EffectContext);
|
||||
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Custom Effect Context
|
||||
|
||||
/**
|
||||
* Helper method to safely get the pointer of GGA_GameplayEffectContext.
|
||||
* 用于安全地获取GGA_GameplayEffectContext的实用函数。
|
||||
* @param EffectContext The gameplay effect context handle 游戏效果上下文句柄。
|
||||
* @return The actually FGGA_GameplayEffectContext pointer.
|
||||
*/
|
||||
static FGGA_GameplayEffectContext* GetEffectContextPtr(FGameplayEffectContextHandle EffectContext);
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Context")
|
||||
static bool HasContextPayload(FGameplayEffectContextHandle EffectContext, const UScriptStruct* PayloadType);
|
||||
|
||||
static bool GetContextPayload(FGameplayEffectContextHandle EffectContext, const UScriptStruct* PayloadType, FInstancedStruct& OutPayload);
|
||||
|
||||
/**
|
||||
* Do not call this,It's for blueprint only.
|
||||
* 不要调用这个,这是给蓝图专用的。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "GGA|GameplayEffect|Context", meta=(BlueprintInternalUseOnly="true"))
|
||||
static FInstancedStruct GetValidContextPayload(FGameplayEffectContextHandle EffectContext, const UScriptStruct* PayloadType, bool& bValid);
|
||||
|
||||
/**
|
||||
* Do not call this,It's for blueprint only.
|
||||
* 不要调用这个,这是给蓝图专用的。
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, CustomThunk, Category = "GGA|GameplayEffect|Context", meta=(CustomStructureParam = "Value", ExpandEnumAsExecs = "ExecResult", BlueprintInternalUseOnly="true"))
|
||||
static void GetContextPayload(FGameplayEffectContextHandle EffectContext, const UScriptStruct* PayloadType, EGGA_ContextPayloadResult& ExecResult, int32& Value);
|
||||
|
||||
UFUNCTION(BlueprintCallable, CustomThunk, Category = "GGA|GameplayEffect|Context",
|
||||
meta=(CustomStructureParam = "Value", ExpandEnumAsExecs = "ExecResult", BlueprintInternalUseOnly="true"))
|
||||
static void SetContextPayload(FGameplayEffectContextHandle EffectContext, EGGA_ContextPayloadResult& ExecResult, const int32& Value);
|
||||
|
||||
private:
|
||||
DECLARE_FUNCTION(execGetContextPayload);
|
||||
DECLARE_FUNCTION(execSetContextPayload);
|
||||
#pragma endregion
|
||||
};
|
||||
Reference in New Issue
Block a user