GKLGameplayAbility.h
Click a line number to link it. Shift-click to select a range.
| 1 | // Copyright (c) 2026 Reignance Studios. MIT License, see LICENSE. |
| 2 | |
| 3 | #pragma once |
| 4 | |
| 5 | #include "CoreMinimal.h" |
| 6 | #include "Abilities/GameplayAbility.h" |
| 7 | #include "GKLGameplayAbility.generated.h" |
| 8 | |
| 9 | class AGKLCharacter; |
| 10 | |
| 11 | /** |
| 12 | * Base ability: LocalPredicted, instanced per actor, blocked while State.Dead. |
| 13 | * |
| 14 | * Cost and cooldown are set as numbers on the ability, not as one effect asset per ability: |
| 15 | * - StaminaCost / ManaCost feed UGKLCostEffect through SetByCaller. |
| 16 | * - CooldownDuration feeds UGKLCooldownEffect; CooldownTags are added to it at runtime and |
| 17 | * returned from GetCooldownTags, so CheckCooldown blocks activation while they are present. |
| 18 | * Both effects are applied with ApplyGameplayEffectSpecToOwner, which carries the activation's |
| 19 | * prediction key: the owning client sees the cost and cooldown immediately. |
| 20 | */ |
| 21 | UCLASS(Abstract) |
| 22 | class GASKITLITE_API UGKLGameplayAbility : public UGameplayAbility |
| 23 | { |
| 24 | GENERATED_BODY() |
| 25 | |
| 26 | public: |
| 27 | UGKLGameplayAbility(); |
| 28 | |
| 29 | virtual UGameplayEffect* GetCostGameplayEffect() const override; |
| 30 | virtual UGameplayEffect* GetCooldownGameplayEffect() const override; |
| 31 | virtual const FGameplayTagContainer* GetCooldownTags() const override; |
| 32 | |
| 33 | virtual bool CheckCost(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, |
| 34 | FGameplayTagContainer* OptionalRelevantTags = nullptr) const override; |
| 35 | virtual void ApplyCost(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, |
| 36 | const FGameplayAbilityActivationInfo ActivationInfo) const override; |
| 37 | virtual void ApplyCooldown(const FGameplayAbilitySpecHandle Handle, const FGameplayAbilityActorInfo* ActorInfo, |
| 38 | const FGameplayAbilityActivationInfo ActivationInfo) const override; |
| 39 | |
| 40 | protected: |
| 41 | UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GASKit Lite|Cost") |
| 42 | float StaminaCost = 0.f; |
| 43 | |
| 44 | UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GASKit Lite|Cost") |
| 45 | float ManaCost = 0.f; |
| 46 | |
| 47 | /** Seconds. 0 = no cooldown. */ |
| 48 | UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GASKit Lite|Cooldown") |
| 49 | float CooldownDuration = 0.f; |
| 50 | |
| 51 | /** Granted while on cooldown, e.g. Cooldown.Heal. Required when CooldownDuration > 0. */ |
| 52 | UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "GASKit Lite|Cooldown") |
| 53 | FGameplayTagContainer CooldownTags; |
| 54 | |
| 55 | /** The avatar as a GASKit Lite character, or null. */ |
| 56 | UFUNCTION(BlueprintPure, Category = "GASKit Lite") |
| 57 | AGKLCharacter* GetLiteCharacter() const; |
| 58 | |
| 59 | /** Adds an identity tag (Ability.Heal...). Constructor only. Wraps the 5.5 AbilityTags change. */ |
| 60 | void AddAbilityTag(const FGameplayTag& Tag); |
| 61 | |
| 62 | private: |
| 63 | mutable FGameplayTagContainer TempCooldownTags; |
| 64 | }; |