Init Ability Actor Info

This commit is contained in:
2024-11-19 18:41:15 -04:00
parent 9f72e0891f
commit 3ec76f0841
4 changed files with 43 additions and 0 deletions

View File

@ -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()
{ {
@ -28,3 +30,28 @@ AAuraCharacter::AAuraCharacter()
Camera->SetupAttachment(CameraBoom); Camera->SetupAttachment(CameraBoom);
} }
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 Client
InitAbilityActorInfo();
}
void AAuraCharacter::InitAbilityActorInfo()
{
AAuraPlayerState* AuraPlayerState = GetPlayerState<AAuraPlayerState>();
check(AuraPlayerState);
AuraPlayerState->GetAbilitySystemComponent()->InitAbilityActorInfo(AuraPlayerState, this);
AbilitySystemComponent = AuraPlayerState->GetAbilitySystemComponent();
AttributeSet = AuraPlayerState->GetAttributeSet();
}

View File

@ -35,3 +35,9 @@ void AAuraEnemy::UnHighlightActor()
GetMesh()->SetRenderCustomDepth(false); GetMesh()->SetRenderCustomDepth(false);
Weapon->SetRenderCustomDepth(false); Weapon->SetRenderCustomDepth(false);
} }
void AAuraEnemy::BeginPlay()
{
Super::BeginPlay();
AbilitySystemComponent->InitAbilityActorInfo(this, this);
}

View File

@ -26,4 +26,9 @@ private:
public: public:
AAuraCharacter(); AAuraCharacter();
virtual void PossessedBy(AController* NewController) override;
virtual void OnRep_PlayerState() override;
private:
void InitAbilityActorInfo();
}; };

View File

@ -17,6 +17,11 @@ class AURA_API AAuraEnemy : public AAuraCharacterBase, public IEnemyInterface
public: public:
AAuraEnemy(); AAuraEnemy();
/** Enemy Interface */
virtual void HighlightActor() override; virtual void HighlightActor() override;
virtual void UnHighlightActor() override; virtual void UnHighlightActor() override;
/** End Enemy Interface */
protected:
virtual void BeginPlay() override;
}; };