// 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(); check(AuraPlayerState) { return AuraPlayerState->GetPlayerLevel(); } } void AAuraCharacter::InitAbilityActorInfo() //Function to Init Ability Actor Info for the server { AAuraPlayerState* AuraPlayerState = GetPlayerState(); check(AuraPlayerState); AuraPlayerState->GetAbilitySystemComponent()->InitAbilityActorInfo(AuraPlayerState,this); Cast(AuraPlayerState->GetAbilitySystemComponent())->AbilityActorInfoSet(); AbilitySystemComponent = AuraPlayerState->GetAbilitySystemComponent(); AttributeSet = AuraPlayerState->GetAttributeSet(); //UE_LOG(LogTemp, Warning, TEXT("AuraCharacter.cpp - InitAbilityActorInfo - AttributeSet")); if (AAuraPlayerController* AuraPlayerController = Cast(GetController())) { //UE_LOG(LogTemp, Warning, TEXT("AuraCharacter.cpp - InitAbilityActorInfo - Cast ")); if (AAuraHUD* AuraHUD = Cast(AuraPlayerController->GetHUD())) { //UE_LOG(LogTemp, Warning, TEXT("AuraCharacter.cpp - InitAbilityActorInfo - InitOverlay")); AuraHUD->InitOverlay(AuraPlayerController, AuraPlayerState, AbilitySystemComponent, AttributeSet); } } InitializeDefaultAttributes(); }