// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "Containers/Array.h" #include "Engine/DataAsset.h" #include "GameplayAbilitySpec.h" #include "GameplayEffectTypes.h" #include "GameplayTagContainer.h" #include "HAL/Platform.h" #include "Templates/SubclassOf.h" #include "UObject/ObjectPtr.h" #include "UObject/UObjectGlobals.h" #include "LyraAbilitySet.generated.h" class UAttributeSet; class UGameplayEffect; class ULyraAbilitySystemComponent; class ULyraGameplayAbility; class UObject; /** * FLyraAbilitySet_GameplayAbility * * Data used by the ability set to grant gameplay abilities. */ USTRUCT(BlueprintType) struct FLyraAbilitySet_GameplayAbility { GENERATED_BODY() public: // Gameplay ability to grant. UPROPERTY(EditDefaultsOnly) TSubclassOf Ability = nullptr; // Level of ability to grant. UPROPERTY(EditDefaultsOnly) int32 AbilityLevel = 1; // Tag used to process input for the ability. UPROPERTY(EditDefaultsOnly, Meta = (Categories = "InputTag")) FGameplayTag InputTag; }; /** * FLyraAbilitySet_GameplayEffect * * Data used by the ability set to grant gameplay effects. */ USTRUCT(BlueprintType) struct FLyraAbilitySet_GameplayEffect { GENERATED_BODY() public: // Gameplay effect to grant. UPROPERTY(EditDefaultsOnly) TSubclassOf GameplayEffect = nullptr; // Level of gameplay effect to grant. UPROPERTY(EditDefaultsOnly) float EffectLevel = 1.0f; }; /** * FLyraAbilitySet_AttributeSet * * Data used by the ability set to grant attribute sets. */ USTRUCT(BlueprintType) struct FLyraAbilitySet_AttributeSet { GENERATED_BODY() public: // Gameplay effect to grant. UPROPERTY(EditDefaultsOnly) TSubclassOf AttributeSet; }; /** * FLyraAbilitySet_GrantedHandles * * Data used to store handles to what has been granted by the ability set. */ USTRUCT(BlueprintType) struct FLyraAbilitySet_GrantedHandles { GENERATED_BODY() public: void AddAbilitySpecHandle(const FGameplayAbilitySpecHandle& Handle); void AddGameplayEffectHandle(const FActiveGameplayEffectHandle& Handle); void AddAttributeSet(UAttributeSet* Set); void TakeFromAbilitySystem(ULyraAbilitySystemComponent* LyraASC); protected: // Handles to the granted abilities. UPROPERTY() TArray AbilitySpecHandles; // Handles to the granted gameplay effects. UPROPERTY() TArray GameplayEffectHandles; // Pointers to the granted attribute sets UPROPERTY() TArray> GrantedAttributeSets; }; /** * ULyraAbilitySet * * Non-mutable data asset used to grant gameplay abilities and gameplay effects. */ UCLASS(BlueprintType, Const) class ULyraAbilitySet : public UPrimaryDataAsset { GENERATED_BODY() public: ULyraAbilitySet(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get()); // Grants the ability set to the specified ability system component. // The returned handles can be used later to take away anything that was granted. void GiveToAbilitySystem(ULyraAbilitySystemComponent* LyraASC, FLyraAbilitySet_GrantedHandles* OutGrantedHandles, UObject* SourceObject = nullptr) const; protected: // Gameplay abilities to grant when this ability set is granted. UPROPERTY(EditDefaultsOnly, Category = "Gameplay Abilities", meta=(TitleProperty=Ability)) TArray GrantedGameplayAbilities; // Gameplay effects to grant when this ability set is granted. UPROPERTY(EditDefaultsOnly, Category = "Gameplay Effects", meta=(TitleProperty=GameplayEffect)) TArray GrantedGameplayEffects; // Attribute sets to grant when this ability set is granted. UPROPERTY(EditDefaultsOnly, Category = "Attribute Sets", meta=(TitleProperty=AttributeSet)) TArray GrantedAttributes; };