// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trad`emark is strictly prohibited and may result in legal action. #pragma once #include "CoreMinimal.h" #include "GameplayAbilitySpec.h" #include "GameplayTagContainer.h" #include "Abilities/GameplayAbilityTypes.h" #include "OLSAbilityCost.generated.h" /** * UOLSAbilityCost * * Base class for costs that a LyraGameplayAbility has (e.g., ammo or charges) */ UCLASS(DefaultToInstanced, EditInlineNew, Abstract) class OLS_API UOLSAbilityCost : public UObject { GENERATED_BODY() public: UOLSAbilityCost(); /** * Checks if we can afford this cost. * * A failure reason tag can be added to OptionalRelevantTags (if non-null), which can be queried * elsewhere to determine how to provide user feedback (e.g., a clicking noise if a weapon is out of ammo) * * Ability and ActorInfo are guaranteed to be non-null on entry, but OptionalRelevantTags can be nullptr. * * @return true if we can pay for the ability, false otherwise. */ virtual bool CheckCost(const class UOLSGameplayAbility* ability, const FGameplayAbilitySpecHandle handle, const FGameplayAbilityActorInfo* actorInfo, FGameplayTagContainer* optionalRelevantTags) const; /** * Applies the ability's cost to the target * * Notes: * - Your implementation don't need to check ShouldOnlyApplyCostOnHit(), the caller does that for you. * - Ability and ActorInfo are guaranteed to be non-null on entry. */ virtual void ApplyCost(const class UOLSGameplayAbility* ability, const FGameplayAbilitySpecHandle handle, const FGameplayAbilityActorInfo* actorInfo, const FGameplayAbilityActivationInfo activationInfo); /** If true, this cost should only be applied if this ability hits successfully */ bool ShouldOnlyApplyCostOnHit() const; protected: /** If true, this cost should only be applied if this ability hits successfully */ UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "OLS|Costs") uint8 bShouldOnlyApplyCostOnHit : 1 = false; };