54 lines
1.0 KiB
C++
54 lines
1.0 KiB
C++
|
// 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;
|
||
|
}
|
||
|
|