void ANimModGameState::RestartRound_Implementation() { if (ISSERVER && RoundManager != nullptr) { RoundManager->RestartRound(); //return; } ALevelScriptActor* LevelScript = GetWorld()->GetLevelScriptActor(); if (LevelScript) { LevelScript->LevelReset(); } if (ISSERVER) { //Reset the level for (FConstControllerIterator Iterator = GetWorld()->GetControllerIterator(); Iterator; ++Iterator) { AController* Controller = *Iterator; ANimModPlayerController* PlayerController = Cast<ANimModPlayerController>(Controller); if (PlayerController) { ANimModGameMode *gameMode = Cast<ANimModGameMode>(GetWorld()->GetAuthGameMode()); gameMode->RestartPlayer(PlayerController); //PlayerController->ClientRestartRound(); //PlayerController->ServerRestartPlayer(); } else Controller->Reset(); } } }
void AGameModeBase::ResetLevel() { UE_LOG(LogGameMode, Log, TEXT("Reset %s"), *GetName()); // Reset ALL controllers first for (FConstControllerIterator Iterator = GetWorld()->GetControllerIterator(); Iterator; ++Iterator) { AController* Controller = *Iterator; APlayerController* PlayerController = Cast<APlayerController>(Controller); if (PlayerController) { PlayerController->ClientReset(); } Controller->Reset(); } // Reset all actors (except controllers, the GameMode, and any other actors specified by ShouldReset()) for (FActorIterator It(GetWorld()); It; ++It) { AActor* A = *It; if (A && !A->IsPendingKill() && A != this && !A->IsA<AController>() && ShouldReset(A)) { A->Reset(); } } // Reset the GameMode Reset(); // Notify the level script that the level has been reset ALevelScriptActor* LevelScript = GetWorld()->GetLevelScriptActor(); if (LevelScript) { LevelScript->LevelReset(); } }