Files
Aura-TopDownRPG-GAS/Source/Aura/Private/Character/AuraCharacter.cpp
2025-10-14 22:20:59 -04:00

71 lines
2.4 KiB
C++

// Copyright Echo Devgroup
#include "Character/AuraCharacter.h"
#include "AbilitySystem/AuraAbilitySystemComponent.h"
#include "GameFramework/CharacterMovementComponent.h"
#include "Player/AuraPlayerController.h"
#include "Player/AuraPlayerState.h"
#include "UI/HUD/AuraHUD.h"
AAuraCharacter::AAuraCharacter()
{
GetCharacterMovement()->bOrientRotationToMovement = true;
GetCharacterMovement()->RotationRate = FRotator(0.f, 400.f, 0.f);
GetCharacterMovement()->bConstrainToPlane = true;
GetCharacterMovement()->bSnapToPlaneAtStart = true;
//Don't use controller rotation
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;
}
void AAuraCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
//UE_LOG(LogTemp, Warning, TEXT("AuraCharacter.cpp - PossessedBy"));
InitAbilityActorInfo(); //Init Ability Actor Info for the Server
}
void AAuraCharacter::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
//UE_LOG(LogTemp, Warning, TEXT("AuraCharacter.cpp - OnRep_PlayerState"));
InitAbilityActorInfo(); //Init Ability Actor Info for the Client
}
int32 AAuraCharacter::GetPlayerLevel()
{
const AAuraPlayerState* AuraPlayerState = GetPlayerState<AAuraPlayerState>();
check(AuraPlayerState)
{
return AuraPlayerState->GetPlayerLevel();
}
}
void AAuraCharacter::InitAbilityActorInfo() //Function to Init Ability Actor Info for the server
{
AAuraPlayerState* AuraPlayerState = GetPlayerState<AAuraPlayerState>();
check(AuraPlayerState);
AuraPlayerState->GetAbilitySystemComponent()->InitAbilityActorInfo(AuraPlayerState,this);
Cast<UAuraAbilitySystemComponent>(AuraPlayerState->GetAbilitySystemComponent())->AbilityActorInfoSet();
AbilitySystemComponent = AuraPlayerState->GetAbilitySystemComponent();
AttributeSet = AuraPlayerState->GetAttributeSet();
//UE_LOG(LogTemp, Warning, TEXT("AuraCharacter.cpp - InitAbilityActorInfo - AttributeSet"));
if (AAuraPlayerController* AuraPlayerController = Cast<AAuraPlayerController>(GetController()))
{
//UE_LOG(LogTemp, Warning, TEXT("AuraCharacter.cpp - InitAbilityActorInfo - Cast "));
if (AAuraHUD* AuraHUD = Cast<AAuraHUD>(AuraPlayerController->GetHUD()))
{
//UE_LOG(LogTemp, Warning, TEXT("AuraCharacter.cpp - InitAbilityActorInfo - InitOverlay"));
AuraHUD->InitOverlay(AuraPlayerController, AuraPlayerState, AbilitySystemComponent, AttributeSet);
}
}
InitializeDefaultAttributes();
}