22. Init ability actor info

This commit is contained in:
2024-04-13 11:56:19 -04:00
parent 931edffc7c
commit 5a4fc6381b
15 changed files with 130 additions and 34 deletions

View File

@ -43,11 +43,31 @@ AGasaCharacter::AGasaCharacter()
{
AbilitySystem = CreateDefaultSubobject<UGasaAbilitySystemComp>("Ability System");
AbilitySystem->SetIsReplicated(true);
AbilitySystem->SetReplicationMode(EGameplayEffectReplicationMode::Minimal);
Attributes = CreateDefaultSubobject<UAttributeSet>("Attributes");
}
}
#pragma region Pawn
void AGasaCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
if (bAutoAbilitySystem)
{
// TODO(Ed): Do we need to do this for enemies?
AbilitySystem->InitAbilityActorInfo(this, this);
}
}
void AGasaCharacter::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
}
#pragma endregion Pawn
#pragma region Actor
void AGasaCharacter::BeginPlay()
{
Super::BeginPlay();
@ -96,3 +116,4 @@ void AGasaCharacter::Tick(float DeltaSeconds)
break;
}
}
#pragma endregion Actor

View File

@ -4,6 +4,7 @@
#include "GameFramework/Character.h"
#include "GasaCommon.h"
#include "Game/GasaPlayerState.h"
#include "GasaCharacter.generated.h"
@ -57,10 +58,18 @@ public:
AGasaCharacter();
FORCEINLINE AGasaPlayerState* GetGasaPlayerState() { return GetPlayerState<AGasaPlayerState>(); }
#pragma region IAbilitySystem
FORCEINLINE UAttributeSet* GetAttributes() { return Attributes; }
FORCEINLINE UAbilitySystemComponent* GetAbilitySystemComponent() const override { return AbilitySystem; }
#pragma endregion IAbilitySystem
#pragma region Pawn
void PossessedBy(AController* NewController) override;
void OnRep_PlayerState() override;
#pragma endregion Pawn
#pragma region Actor
void BeginPlay() override;

View File

@ -1,8 +1,23 @@
#include "PlayerCharacter.h"
#include "AbilitySystemComponent.h"
APlayerCharacter::APlayerCharacter()
{
PrimaryActorTick.bCanEverTick = true;
bAutoAbilitySystem = false;
}
void APlayerCharacter::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
AGasaPlayerState* PS = GetGasaPlayerState();
// Client setup ability system
{
AbilitySystem = PS->AbilitySystem;
Attributes = PS->Attributes;
AbilitySystem->InitAbilityActorInfo(PS, this);
}
}

View File

@ -10,5 +10,9 @@ class GASA_API APlayerCharacter : public AGasaCharacter
GENERATED_BODY()
public:
APlayerCharacter();
APlayerCharacter();
#pragma region Pawn
void OnRep_PlayerState() override;
#pragma endregion Pawn
};