blaster/Source/Blaster/PlayerState/BlasterPlayerState.cpp

54 lines
1.0 KiB
C++
Raw Normal View History

2022-05-09 14:33:48 +00:00
// Fill out your copyright notice in the Description page of Project Settings.
#include "BlasterPlayerState.h"
#include "Blaster/Character/BlasterCharacter.h"
#include "Blaster/PlayerController/BlasterPlayerController.h"
void ABlasterPlayerState::IncreaseScore(float ScoreAmount)
{
SetScore(GetScore() + ScoreAmount);
Character = GetCharacter();
if (Character)
{
Controller = GetController();
if (Controller)
{
Controller->SetHUDScore(GetScore());
}
}
}
void ABlasterPlayerState::OnRep_Score()
{
Super::OnRep_Score();
Character = GetCharacter();
if (Character)
{
Controller = GetController();
if (Controller)
{
Controller->SetHUDScore(GetScore());
}
}
}
ABlasterCharacter* ABlasterPlayerState::GetCharacter() const
{
return Character == nullptr ? Cast<ABlasterCharacter>(GetPawn()) : Character;
}
ABlasterPlayerController* ABlasterPlayerState::GetController() const
{
if (Character)
{
return Controller == nullptr ? Cast<ABlasterPlayerController>(Character->Controller) : Controller;
}
return nullptr;
}