Health and Mana Attributes
This commit is contained in:
@ -2,3 +2,46 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "AbilitySystem/AuraAttributeSet.h"
|
#include "AbilitySystem/AuraAttributeSet.h"
|
||||||
|
#include "Net/UnrealNetwork.h"
|
||||||
|
|
||||||
|
UAuraAttributeSet::UAuraAttributeSet()
|
||||||
|
{
|
||||||
|
InitHealth(100.f);
|
||||||
|
InitMaxHealth(100.f);
|
||||||
|
InitMana(50.f);
|
||||||
|
InitMaxMana(50.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAuraAttributeSet::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
|
||||||
|
{
|
||||||
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||||
|
|
||||||
|
#define CON_NOTIFY(Attribute) \
|
||||||
|
DOREPLIFETIME_CONDITION_NOTIFY(UAuraAttributeSet, Attribute, COND_None, REPNOTIFY_Always)
|
||||||
|
|
||||||
|
CON_NOTIFY(MaxHealth);
|
||||||
|
CON_NOTIFY(MaxMana);
|
||||||
|
|
||||||
|
CON_NOTIFY(Health)
|
||||||
|
CON_NOTIFY(Mana);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAuraAttributeSet::OnRep_Health(const FGameplayAttributeData& OldHealth) const
|
||||||
|
{
|
||||||
|
GAMEPLAYATTRIBUTE_REPNOTIFY(UAuraAttributeSet, Health, OldHealth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAuraAttributeSet::OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth) const
|
||||||
|
{
|
||||||
|
GAMEPLAYATTRIBUTE_REPNOTIFY(UAuraAttributeSet, MaxHealth, OldMaxHealth);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAuraAttributeSet::OnRep_Mana(const FGameplayAttributeData& OldMana) const
|
||||||
|
{
|
||||||
|
GAMEPLAYATTRIBUTE_REPNOTIFY(UAuraAttributeSet, Mana, OldMana);
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAuraAttributeSet::OnRep_MaxMana(const FGameplayAttributeData& OldMaxMana) const
|
||||||
|
{
|
||||||
|
GAMEPLAYATTRIBUTE_REPNOTIFY(UAuraAttributeSet, MaxMana, OldMaxMana);
|
||||||
|
}
|
@ -3,8 +3,16 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
|
#include "AbilitySystemComponent.h"
|
||||||
#include "AttributeSet.h"
|
#include "AttributeSet.h"
|
||||||
#include "AuraAttributeSet.generated.h"
|
#include "AuraAttributeSet.generated.h"
|
||||||
|
|
||||||
|
#define ATTRIBUTE_ACCESSORS(ClassName, PropertyName) \
|
||||||
|
GAMEPLAYATTRIBUTE_PROPERTY_GETTER(ClassName, PropertyName) \
|
||||||
|
GAMEPLAYATTRIBUTE_VALUE_GETTER(PropertyName) \
|
||||||
|
GAMEPLAYATTRIBUTE_VALUE_SETTER(PropertyName) \
|
||||||
|
GAMEPLAYATTRIBUTE_VALUE_INITTER(PropertyName)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -13,4 +21,42 @@ class AURA_API UAuraAttributeSet : public UAttributeSet
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UAuraAttributeSet();
|
||||||
|
virtual void GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Vital attributes
|
||||||
|
*/
|
||||||
|
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Health, Category="Vital Attributes")
|
||||||
|
FGameplayAttributeData Health;
|
||||||
|
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, Health);
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_Mana, Category="Vital Attributes")
|
||||||
|
FGameplayAttributeData Mana;
|
||||||
|
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, Mana);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Secondary Attributes
|
||||||
|
*/
|
||||||
|
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_MaxHealth, Category="Secondary Attributes")
|
||||||
|
FGameplayAttributeData MaxHealth;
|
||||||
|
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, MaxHealth);
|
||||||
|
|
||||||
|
UPROPERTY(BlueprintReadOnly, ReplicatedUsing = OnRep_MaxMana, Category="Secondary Attributes")
|
||||||
|
FGameplayAttributeData MaxMana;
|
||||||
|
ATTRIBUTE_ACCESSORS(UAuraAttributeSet, MaxMana);
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnRep_Health(const FGameplayAttributeData& OldHealth) const;
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnRep_Mana(const FGameplayAttributeData& OldMana) const;
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth) const;
|
||||||
|
|
||||||
|
UFUNCTION()
|
||||||
|
void OnRep_MaxMana(const FGameplayAttributeData& OldMaxMana) const;
|
||||||
|
|
||||||
};
|
};
|
Reference in New Issue
Block a user