2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
# pragma once
2022-09-13 07:18:28 +00:00
# include "AbilitySystemComponent.h"
# include "AttributeSet.h"
2022-05-23 18:41:30 +00:00
# include "LyraAttributeSet.h"
2022-09-13 07:18:28 +00:00
# include "Misc/AssertionMacros.h"
2022-05-23 18:41:30 +00:00
# include "NativeGameplayTags.h"
2022-09-13 07:18:28 +00:00
# include "UObject/Class.h"
# include "UObject/UObjectGlobals.h"
2022-05-23 18:41:30 +00:00
# include "LyraHealthSet.generated.h"
2022-09-13 07:18:28 +00:00
class UObject ;
struct FFrame ;
2022-05-23 18:41:30 +00:00
UE_DECLARE_GAMEPLAY_TAG_EXTERN ( TAG_Gameplay_Damage ) ;
UE_DECLARE_GAMEPLAY_TAG_EXTERN ( TAG_Gameplay_DamageImmunity ) ;
UE_DECLARE_GAMEPLAY_TAG_EXTERN ( TAG_Gameplay_DamageSelfDestruct ) ;
UE_DECLARE_GAMEPLAY_TAG_EXTERN ( TAG_Gameplay_FellOutOfWorld ) ;
UE_DECLARE_GAMEPLAY_TAG_EXTERN ( TAG_Lyra_Damage_Message ) ;
struct FGameplayEffectModCallbackData ;
/**
* ULyraHealthSet
*
* Class that defines attributes that are necessary for taking damage .
* Attribute examples include : health , shields , and resistances .
*/
UCLASS ( BlueprintType )
class ULyraHealthSet : public ULyraAttributeSet
{
GENERATED_BODY ( )
public :
ULyraHealthSet ( ) ;
ATTRIBUTE_ACCESSORS ( ULyraHealthSet , Health ) ;
ATTRIBUTE_ACCESSORS ( ULyraHealthSet , MaxHealth ) ;
ATTRIBUTE_ACCESSORS ( ULyraHealthSet , Healing ) ;
2022-09-13 07:18:28 +00:00
ATTRIBUTE_ACCESSORS ( ULyraHealthSet , Damage ) ;
2022-05-23 18:41:30 +00:00
// Delegate to broadcast when the health attribute reaches zero.
mutable FLyraAttributeEvent OnOutOfHealth ;
protected :
UFUNCTION ( )
void OnRep_Health ( const FGameplayAttributeData & OldValue ) ;
UFUNCTION ( )
void OnRep_MaxHealth ( const FGameplayAttributeData & OldValue ) ;
virtual bool PreGameplayEffectExecute ( FGameplayEffectModCallbackData & Data ) override ;
virtual void PostGameplayEffectExecute ( const FGameplayEffectModCallbackData & Data ) override ;
virtual void PreAttributeBaseChange ( const FGameplayAttribute & Attribute , float & NewValue ) const override ;
virtual void PreAttributeChange ( const FGameplayAttribute & Attribute , float & NewValue ) override ;
virtual void PostAttributeChange ( const FGameplayAttribute & Attribute , float OldValue , float NewValue ) override ;
void ClampAttribute ( const FGameplayAttribute & Attribute , float & NewValue ) const ;
private :
// The current health attribute. The health will be capped by the max health attribute. Health is hidden from modifiers so only executions can modify it.
UPROPERTY ( BlueprintReadOnly , ReplicatedUsing = OnRep_Health , Category = " Lyra|Health " , Meta = ( HideFromModifiers , AllowPrivateAccess = true ) )
FGameplayAttributeData Health ;
// The current max health attribute. Max health is an attribute since gameplay effects can modify it.
UPROPERTY ( BlueprintReadOnly , ReplicatedUsing = OnRep_MaxHealth , Category = " Lyra|Health " , Meta = ( AllowPrivateAccess = true ) )
FGameplayAttributeData MaxHealth ;
// Used to track when the health reaches 0.
bool bOutOfHealth ;
// -------------------------------------------------------------------
// Meta Attribute (please keep attributes that aren't 'stateful' below
// -------------------------------------------------------------------
private :
// Incoming healing. This is mapped directly to +Health
UPROPERTY ( BlueprintReadOnly , Category = " Lyra|Health " , Meta = ( AllowPrivateAccess = true ) )
FGameplayAttributeData Healing ;
// Incoming damage. This is mapped directly to -Health
UPROPERTY ( BlueprintReadOnly , Category = " Lyra|Health " , Meta = ( HideFromModifiers , AllowPrivateAccess = true ) )
FGameplayAttributeData Damage ;
} ;