void APlayerStart::PostUnregisterAllComponents() { Super::PostUnregisterAllComponents(); UWorld* ActorWorld = GetWorld(); if ( ActorWorld && ActorWorld->GetAuthGameMode() ) { ActorWorld->GetAuthGameMode()->RemovePlayerStart(this); } }
bool UPlayer::Exec( UWorld* InWorld, const TCHAR* Cmd,FOutputDevice& Ar) { if(PlayerController) { // Since UGameViewportClient calls Exec on UWorld, we only need to explicitly // call UWorld::Exec if we either have a null GEngine or a null ViewportClient UWorld* World = PlayerController->GetWorld(); check(World); check(InWorld == NULL || InWorld == World); const bool bWorldNeedsExec = GEngine == NULL || Cast<ULocalPlayer>(this) == NULL || static_cast<ULocalPlayer*>(this)->ViewportClient == NULL; APawn* PCPawn = PlayerController->GetPawnOrSpectator(); if( bWorldNeedsExec && World->Exec(World, Cmd,Ar) ) { return true; } else if( PlayerController->PlayerInput && PlayerController->PlayerInput->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if( PlayerController->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if( PCPawn && PCPawn->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if( PlayerController->MyHUD && PlayerController->MyHUD->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if( World->GetGameInstance() && World->GetGameInstance()->ProcessConsoleExec(Cmd, Ar, PCPawn) ) { return true; } else if( World->GetAuthGameMode() && World->GetAuthGameMode()->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if( PlayerController->CheatManager && PlayerController->CheatManager->ProcessConsoleExec(Cmd,Ar,PCPawn) ) { return true; } else if (World->GameState && World->GameState->ProcessConsoleExec(Cmd, Ar, PCPawn)) { return true; } else if (PlayerController->PlayerCameraManager && PlayerController->PlayerCameraManager->ProcessConsoleExec(Cmd, Ar, PCPawn)) { return true; } } return false; }
void ABaseLevelScriptActor::ReceiveBeginPlay() { Super::ReceiveBeginPlay(); UWorld* World = GetWorld(); if (World) { ASaveManager* SaveManager = UHelpers::GetSaveManager(World); if (SaveManager->GetData()->Checkpoint.StreamingLevels.Num() <= 0) { // no chekpoint so first time playing /* Because the player isn't probaply initialized here yet we create out save game custom This is currently a work around and all default values set must be hardcoded here */ ASaveManager* SaveManager = UHelpers::GetSaveManager(GetWorld()); APlayerStart* PlayerStart = World->GetAuthGameMode()->PlayerStarts[0]; SaveManager->GetData()->Checkpoint = { PlayerStart->GetTransform().GetLocation(), PlayerStart->GetTransform().Rotator(), UHelpers::GetActiveLevelsFrom(GetWorld()) }; TArray<FName> Weapons; TArray<int32> AmmoCounters; AmmoCounters.Add(6); AmmoCounters.Add(6); AmmoCounters.Add(2); SaveManager->GetData()->Player = { PlayerStart->GetTransform().GetLocation(), PlayerStart->GetTransform().Rotator(), Weapons, AmmoCounters }; SaveManager->Save(); UGameplayStatics::GetPlayerPawn(World, 0)->SetActorTransform(GetWorld()->GetAuthGameMode()->PlayerStarts[0]->GetTransform()); } else{ ((AMOOnshineWorksGameMode*)World->GetAuthGameMode())->RestoreCheckpoint(); } } }
PyObject *py_ue_get_num_spectators(ue_PyUObject *self, PyObject * args) { ue_py_check(self); UWorld *world = ue_get_uworld(self); if (!world) return PyErr_Format(PyExc_Exception, "unable to retrieve UWorld from uobject"); #if ENGINE_MINOR_VERSION < 14 AGameMode *game_mode = world->GetAuthGameMode(); #else AGameModeBase *game_mode = world->GetAuthGameMode(); #endif if (!game_mode) return PyErr_Format(PyExc_Exception, "unable to retrieve GameMode from world"); #if ENGINE_MINOR_VERSION < 14 return PyLong_FromLong(game_mode->NumSpectators); #else return PyLong_FromLong(game_mode->GetNumSpectators()); #endif }
void ABrainPlayerController::ShowPauseMenu() { UWorld* world = GetWorld(); if (world) { ABrainGameMode* gameMode = Cast<ABrainGameMode>(world->GetAuthGameMode()); if (gameMode) { UGameplayStatics::SetGamePaused(world,true); GiveControlsToUI(true); gameMode->CreatePauseMenu(); } } }
void UCustomBPLibrary::RemovePlayerController(APlayerController* pc) { if (pc == NULL) { return; } UWorld* world = pc->GetWorld(); if (world != NULL && pc != NULL) { world->GetAuthGameMode()->RemovePlayerControllerFromPlayerCount(pc); } }
AFPSGGameSession* AFPSGPlayerController::getGameSession() const { AFPSGGameSession* myGameSession = NULL; UWorld* world = GetWorld(); if (world != NULL) { AGameMode* gameMode = world->GetAuthGameMode(); if (gameMode != NULL) { myGameSession = Cast<AFPSGGameSession>(gameMode->GameSession); } } return myGameSession; }