Compare commits
2 Commits
ac3ec88290
...
4610a9f55f
Author | SHA1 | Date | |
---|---|---|---|
4610a9f55f | |||
6b399f2c91 |
@ -2,4 +2,40 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "AbilitySystem/AuraAttributeSet.h"
|
#include "AbilitySystem/AuraAttributeSet.h"
|
||||||
|
#include "AbilitySystemComponent.h"
|
||||||
|
#include "Net/UnrealNetwork.h"
|
||||||
|
|
||||||
|
UAuraAttributeSet::UAuraAttributeSet()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void UAuraAttributeSet::GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const
|
||||||
|
{
|
||||||
|
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
|
||||||
|
|
||||||
|
DOREPLIFETIME_CONDITION_NOTIFY(UAuraAttributeSet, Health, COND_None, REPNOTIFY_Always)
|
||||||
|
DOREPLIFETIME_CONDITION_NOTIFY(UAuraAttributeSet, MaxHealth, COND_None, REPNOTIFY_Always)
|
||||||
|
|
||||||
|
DOREPLIFETIME_CONDITION_NOTIFY(UAuraAttributeSet, Mana, COND_None, REPNOTIFY_Always)
|
||||||
|
DOREPLIFETIME_CONDITION_NOTIFY(UAuraAttributeSet, MaxMana, COND_None, REPNOTIFY_Always)
|
||||||
|
}
|
||||||
|
|
||||||
|
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,9 +3,11 @@
|
|||||||
|
|
||||||
#include "Character/AuraCharacter.h"
|
#include "Character/AuraCharacter.h"
|
||||||
|
|
||||||
|
#include "AbilitySystemComponent.h"
|
||||||
#include "Camera/CameraComponent.h"
|
#include "Camera/CameraComponent.h"
|
||||||
#include "GameFramework/CharacterMovementComponent.h"
|
#include "GameFramework/CharacterMovementComponent.h"
|
||||||
#include "GameFramework/SpringArmComponent.h"
|
#include "GameFramework/SpringArmComponent.h"
|
||||||
|
#include "Player/AuraPlayerState.h"
|
||||||
|
|
||||||
AAuraCharacter::AAuraCharacter()
|
AAuraCharacter::AAuraCharacter()
|
||||||
{
|
{
|
||||||
@ -35,3 +37,29 @@ AAuraCharacter::AAuraCharacter()
|
|||||||
bUseControllerRotationYaw = false;
|
bUseControllerRotationYaw = false;
|
||||||
bUseControllerRotationRoll = false;
|
bUseControllerRotationRoll = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AAuraCharacter::PossessedBy(AController* NewController)
|
||||||
|
{
|
||||||
|
Super::PossessedBy(NewController);
|
||||||
|
|
||||||
|
// Init ability actor info for the server
|
||||||
|
InitAbilityActorInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AAuraCharacter::OnRep_PlayerState()
|
||||||
|
{
|
||||||
|
Super::OnRep_PlayerState();
|
||||||
|
|
||||||
|
// Init ability actor info for the server
|
||||||
|
InitAbilityActorInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AAuraCharacter::InitAbilityActorInfo()
|
||||||
|
{
|
||||||
|
AAuraPlayerState *AuraPlayerState = GetPlayerState<AAuraPlayerState>();
|
||||||
|
check(AuraPlayerState);
|
||||||
|
AuraPlayerState->GetAbilitySystemComponent()->InitAbilityActorInfo(AuraPlayerState, this);
|
||||||
|
|
||||||
|
AbilitySystemComponent = AuraPlayerState->GetAbilitySystemComponent();
|
||||||
|
AttributeSet = AuraPlayerState->GetAttributeSet();
|
||||||
|
}
|
||||||
|
@ -31,3 +31,10 @@ void AAuraEnemy::UnHighlightActor()
|
|||||||
GetMesh()->SetRenderCustomDepth(false);
|
GetMesh()->SetRenderCustomDepth(false);
|
||||||
Weapon->SetRenderCustomDepth(false);
|
Weapon->SetRenderCustomDepth(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AAuraEnemy::BeginPlay()
|
||||||
|
{
|
||||||
|
Super::BeginPlay();
|
||||||
|
|
||||||
|
AbilitySystemComponent->InitAbilityActorInfo(this, this);
|
||||||
|
}
|
||||||
|
@ -14,4 +14,31 @@ class AURA_API UAuraAttributeSet : public UAttributeSet
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
UAuraAttributeSet ();
|
||||||
|
virtual void GetLifetimeReplicatedProps(TArray<class FLifetimeProperty>& OutLifetimeProps) const override;
|
||||||
|
|
||||||
|
UPROPERTY (BlueprintReadOnly, ReplicatedUsing = OnRep_Health, Category = "Vital Attributes")
|
||||||
|
FGameplayAttributeData Health;
|
||||||
|
|
||||||
|
UPROPERTY (BlueprintReadOnly, ReplicatedUsing = OnRep_MaxHealth, Category = "Vital Attributes")
|
||||||
|
FGameplayAttributeData MaxHealth;
|
||||||
|
|
||||||
|
UPROPERTY (BlueprintReadOnly, ReplicatedUsing = OnRep_Mana, Category = "Vital Attributes")
|
||||||
|
FGameplayAttributeData Mana;
|
||||||
|
|
||||||
|
UPROPERTY (BlueprintReadOnly, ReplicatedUsing = OnRep_MaxMana, Category = "Vital Attributes")
|
||||||
|
FGameplayAttributeData MaxMana;
|
||||||
|
|
||||||
|
UFUNCTION ()
|
||||||
|
void OnRep_Health(const FGameplayAttributeData& OldHealth) const;
|
||||||
|
|
||||||
|
UFUNCTION ()
|
||||||
|
void OnRep_MaxHealth(const FGameplayAttributeData& OldMaxHealth) const;
|
||||||
|
|
||||||
|
UFUNCTION ()
|
||||||
|
void OnRep_Mana(const FGameplayAttributeData& OldMana) const;
|
||||||
|
|
||||||
|
UFUNCTION ()
|
||||||
|
void OnRep_MaxMana(const FGameplayAttributeData& OldMaxMana) const;
|
||||||
};
|
};
|
||||||
|
@ -16,6 +16,8 @@ class AURA_API AAuraCharacter : public AAuraCharacterBase
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
AAuraCharacter ();
|
AAuraCharacter ();
|
||||||
|
virtual void PossessedBy(AController* NewController) override;
|
||||||
|
virtual void OnRep_PlayerState() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPROPERTY (EditAnywhere)
|
UPROPERTY (EditAnywhere)
|
||||||
@ -23,4 +25,6 @@ private:
|
|||||||
|
|
||||||
UPROPERTY (EditAnywhere)
|
UPROPERTY (EditAnywhere)
|
||||||
TObjectPtr<UCameraComponent> Camera;
|
TObjectPtr<UCameraComponent> Camera;
|
||||||
|
|
||||||
|
void InitAbilityActorInfo ();
|
||||||
};
|
};
|
||||||
|
@ -19,4 +19,7 @@ public:
|
|||||||
AAuraEnemy ();
|
AAuraEnemy ();
|
||||||
virtual void HighlightActor() override;
|
virtual void HighlightActor() override;
|
||||||
virtual void UnHighlightActor() override;
|
virtual void UnHighlightActor() override;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void BeginPlay() override;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user