// 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" #include "Net/UnrealNetwork.h" void ABlasterPlayerState::GetLifetimeReplicatedProps(TArray& OutLifetimeProps) const { Super::GetLifetimeReplicatedProps(OutLifetimeProps); DOREPLIFETIME(ABlasterPlayerState, Defeats); } void ABlasterPlayerState::IncreaseScore(float ScoreAmount) { SetScore(GetScore() + ScoreAmount); Character = Character == nullptr ? Cast(GetPawn()) : Character; if (Character) { Controller = Controller == nullptr ? Cast(Character->Controller) : Controller; if (Controller) { Controller->SetHUDScore(GetScore()); } } } void ABlasterPlayerState::OnRep_Score() { Super::OnRep_Score(); Character = Character == nullptr ? Cast(GetPawn()) : Character; if (Character) { Controller = Controller == nullptr ? Cast(Character->Controller) : Controller; if (Controller) { Controller->SetHUDScore(GetScore()); } } } void ABlasterPlayerState::IncreaseDefeats(int32 DefeatsAmount) { Defeats += DefeatsAmount; Character = Character == nullptr ? Cast(GetPawn()) : Character; if (Character) { Controller = Controller == nullptr ? Cast(Character->Controller) : Controller; if (Controller) { Controller->SetHUDDefeats(Defeats); } } } void ABlasterPlayerState::OnRep_Defeats() { Character = Character == nullptr ? Cast(GetPawn()) : Character; if (Character) { Controller = Controller == nullptr ? Cast(Character->Controller) : Controller; if (Controller) { Controller->SetHUDDefeats(Defeats); } } }