OLS/Source/ols/Public/AbilitySystem/Abilities/OLSGameplayAbility.h

113 lines
3.4 KiB
C++

// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
#pragma once
#include "CoreMinimal.h"
#include "Abilities/GameplayAbility.h"
#include "OLSGameplayAbility.generated.h"
/**
* ELyraAbilityActivationPolicy
*
* Defines how an ability is meant to activate.
*/
UENUM(BlueprintType)
enum class EOLSAbilityActivationPolicy : uint8
{
// Try to activate the ability when the input is triggered.
OnInputTriggered,
// Continually try to activate the ability while the input is active.
WhileInputActive,
// Try to activate the ability when an avatar is assigned.
OnSpawn
};
/**
* ELyraAbilityActivationGroup
*
* Defines how an ability activates in relation to other abilities.
*/
UENUM(BlueprintType)
enum class EOLSAbilityActivationGroup : uint8
{
// Ability runs independently of all other abilities.
Independent,
// Ability is canceled and replaced by other exclusive abilities.
Exclusive_Replaceable,
// Ability blocks all other exclusive abilities from activating.
Exclusive_Blocking,
MAX UMETA(Hidden)
};
/** Failure reason that can be used to play an animation montage when a failure occurs */
USTRUCT(BlueprintType)
struct FOLSAbilityMontageFailureMessage
{
GENERATED_BODY()
public:
// Player controller that failed to activate the ability, if the AbilitySystemComponent was player owned
UPROPERTY(BlueprintReadWrite)
TObjectPtr<APlayerController> PlayerController = nullptr;
// Avatar actor that failed to activate the ability
UPROPERTY(BlueprintReadWrite)
TObjectPtr<AActor> AvatarActor = nullptr;
// All the reasons why this ability has failed
UPROPERTY(BlueprintReadWrite)
FGameplayTagContainer FailureTags;
UPROPERTY(BlueprintReadWrite)
TObjectPtr<UAnimMontage> FailureMontage = nullptr;
};
/**
* UOLSGameplayAbility
*
* The base gameplay ability class used by this project.
*/
UCLASS(Abstract, HideCategories = Input, Meta = (ShortTooltip = "The base gameplay ability class used by this project."))
class OLS_API UOLSGameplayAbility : public UGameplayAbility
{
GENERATED_BODY()
public:
protected:
// Defines how this ability is meant to activate.
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "OLS|Ability Activation")
EOLSAbilityActivationPolicy ActivationPolicy;
// Defines the relationship between this ability activating and other abilities activating.
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "OLS|Ability Activation")
EOLSAbilityActivationGroup ActivationGroup;
// Additional costs that must be paid to activate this ability
UPROPERTY(EditDefaultsOnly, Instanced, Category = Costs)
TArray<TObjectPtr<class UOLSAbilityCost>> AdditionalCosts;
// Map of failure tags to simple error messages
UPROPERTY(EditDefaultsOnly, Category = "Advanced")
TMap<FGameplayTag, FText> FailureTagToUserFacingMessages;
// Map of failure tags to anim montages that should be played with them
UPROPERTY(EditDefaultsOnly, Category = "Advanced")
TMap<FGameplayTag, TObjectPtr<UAnimMontage>> FailureTagToAnimMontage;
// If true, extra information should be logged when this ability is canceled. This is temporary, used for tracking a bug.
UPROPERTY(EditDefaultsOnly, Category = "Advanced")
uint8 bShouldLogCancellation : 1 = false;
// Current camera mode set by the ability.
// TSubclassOf<ULyraCameraMode> ActiveCameraMode;
};