// Fill out your copyright notice in the Description page of Project Settings. #include "BlasterGameMode.h" #include "Blaster/Character/BlasterCharacter.h" #include "Blaster/PlayerController/BlasterPlayerController.h" #include "Blaster/PlayerState/BlasterPlayerState.h" #include "GameFramework/PlayerStart.h" #include "Kismet/GameplayStatics.h" void ABlasterGameMode::PlayerEliminated(ABlasterCharacter* EliminatedCharacter, ABlasterPlayerController* VictimController, ABlasterPlayerController* AttackerController) { ABlasterPlayerState* AttackerPlayerState = AttackerController ? Cast(AttackerController->PlayerState) : nullptr; ABlasterPlayerState* VictimPlayerState = VictimController ? Cast(VictimController->PlayerState) : nullptr; if (AttackerPlayerState && AttackerPlayerState != VictimPlayerState) { AttackerPlayerState->IncreaseScore(1.f); } if (EliminatedCharacter) { EliminatedCharacter->Eliminated(); } } void ABlasterGameMode::RequestRespawn(ACharacter* EliminatedCharacter, AController* EliminatedController) { if (EliminatedCharacter) { EliminatedCharacter->Reset(); EliminatedCharacter->Destroy(); } if (EliminatedController) { TArray PlayerStarts; UGameplayStatics::GetAllActorsOfClass(this, APlayerStart::StaticClass(), PlayerStarts); const int32 Selection = FMath::RandRange(0, PlayerStarts.Num() - 1); RestartPlayerAtPlayerStart(EliminatedController, PlayerStarts[Selection]); } }