GASATHON/Project/Source/Gasa/Characters/PlayerCharacter.cpp

55 lines
1.4 KiB
C++
Raw Normal View History

2024-04-12 19:05:09 -07:00
#include "PlayerCharacter.h"
2024-04-13 08:56:19 -07:00
#include "AbilitySystemComponent.h"
2024-04-21 15:56:57 -07:00
#include "Game/GasaPlayerController.h"
#include "UI/GasaHUD.h"
#include "UI/WidgetController.h"
2024-04-13 08:56:19 -07:00
2024-04-12 19:05:09 -07:00
APlayerCharacter::APlayerCharacter()
{
PrimaryActorTick.bCanEverTick = true;
2024-04-13 08:09:22 -07:00
bAutoAbilitySystem = false;
2024-04-12 19:05:09 -07:00
}
2024-04-13 08:56:19 -07:00
2024-04-21 15:56:57 -07:00
// TODO(Ed): We need to setup Net Slime...
void APlayerCharacter::PossessedBy(AController* NewController)
{
Super::PossessedBy(NewController);
AGasaPlayerState* PS = GetGasaPlayerState();
// Server setup ability system (character side)
{
AbilitySystem = PS->AbilitySystem;
Attributes = PS->Attributes;
AbilitySystem->InitAbilityActorInfo(PS, this);
}
2024-04-21 15:56:57 -07:00
AGasaPlayerController* PC = GetController<AGasaPlayerController>();
AGasaHUD* HUD = PC->GetHUD<AGasaHUD>();
FWidgetControllerData Data = { PC, PS, AbilitySystem, Attributes };
2024-04-21 21:30:29 -07:00
HUD->InitHostWidget(& Data);
}
2024-04-21 15:56:57 -07:00
// TODO(Ed): We need to setup Net Slime...
2024-04-13 08:56:19 -07:00
void APlayerCharacter::OnRep_PlayerState()
{
Super::OnRep_PlayerState();
AGasaPlayerState* PS = GetGasaPlayerState();
// Client setup ability system
{
AbilitySystem = PS->AbilitySystem;
Attributes = PS->Attributes;
AbilitySystem->InitAbilityActorInfo(PS, this);
}
2024-04-21 15:56:57 -07:00
if (IsLocallyControlled())
{
AGasaPlayerController* PC = GetController<AGasaPlayerController>();
AGasaHUD* HUD = PC->GetHUD<AGasaHUD>();
FWidgetControllerData Data = { PC, PS, AbilitySystem, Attributes };
2024-04-21 21:30:29 -07:00
HUD->InitHostWidget(& Data);
2024-04-21 15:56:57 -07:00
}
2024-04-13 08:56:19 -07:00
}