void UUpdateManager::StartPlatformEnvironmentCheck() { IOnlineSubsystem* OnlineSubConsole = IOnlineSubsystem::GetByPlatform(); if (!bPlatformEnvironmentDetected && OnlineSubConsole != nullptr && OnlineSubConsole->GetIdentityInterface().IsValid()) { SetUpdateState(EUpdateState::DetectingPlatformEnvironment); ULocalPlayer* LP = GetGameInstance()->GetFirstGamePlayer(); if (LP != nullptr) { const int32 ControllerId = LP->GetControllerId(); OnLoginConsoleCompleteHandle = OnlineSubConsole->GetIdentityInterface()->AddOnLoginCompleteDelegate_Handle( ControllerId, FOnLoginCompleteDelegate::CreateUObject(this, &ThisClass::PlatformEnvironmentCheck_OnLoginConsoleComplete) ); OnlineSubConsole->GetIdentityInterface()->Login(ControllerId, FOnlineAccountCredentials()); } } else { StartHotfixCheck(); } }
void AShooterGameState::RequestFinishAndExitToMainMenu() { if (AuthorityGameMode) { // we are server, tell the gamemode AShooterGameMode* const GameMode = Cast<AShooterGameMode>(AuthorityGameMode); if (GameMode) { GameMode->RequestFinishAndExitToMainMenu(); } } else { // we are client, handle our own business UShooterGameInstance* GI = Cast<UShooterGameInstance>(GetGameInstance()); if (GI) { GI->RemoveSplitScreenPlayers(); } APlayerController* const PrimaryPC = GetGameInstance()->GetFirstLocalPlayerController(); if (PrimaryPC) { check(PrimaryPC->GetNetMode() == ENetMode::NM_Client); PrimaryPC->ClientReturnToMainMenu(TEXT("Return to Main Menu requested by game state")); } } }
void ABrainCharacter::Load() { if (!GetName().IsEmpty()) { if (UBrainGameInstance* gameInstance = Cast<UBrainGameInstance>(GetGameInstance())) { if (UBrainSaveManager* saveManager = gameInstance->GetSaveManager()) { FBrainCharacterSaveData savedData = saveManager->GetDataFromSave<FBrainCharacterSaveData>(GetName()); if (savedData._loadFromfile) { SetActorLocation(savedData._location); SetActorRotation(savedData._rotation); _energy = savedData._energy; } else { SetActorRotation(FRotator(0)); _energy = _maxEnergy; } } } } }
void ARoguelikeChar::DiePainfully() { bIsDead = true; PlayerAnimationInstance->bIsDead = true; bIsSprinting = false; bIsAiming = false; PlayerAnimationInstance->bIsSprinting = false; PlayerAnimationInstance->bIsAiming = false; PlayerAnimationInstance->MovementSpeedX = 0; PlayerAnimationInstance->MovementSpeedY = 0; PlayerAnimationInstance->bHasJumped = false; PlayerAnimationInstance->bIsReloading = false; PlayerCamera->Deactivate(); DeathCamera->Activate(); URoguelikeGameInstance* GameInstance = Cast<URoguelikeGameInstance>(GetGameInstance()); if (GameInstance) { GameInstance->StopGame(); } }
void ARoguelikeChar::BeginPlay() { Super::BeginPlay(); PlayerController = Cast<ADokController>(Controller); SpawnCharInRandomTile(); SpawnZombiesSpawnPoints(); SpawnPowerUps(); SpawnHealthKits(); SpawnDDs(); GameplayComponentReferencing(); PlayerMachineGun->StaticMesh = MachineGunMesh; PlayerMachineGun->AttachTo(CharacterMesh, "GunSocket", EAttachLocation::SnapToTarget, false); PlayerAnimationInstance = Cast<UHeroAnimInstance>(CharacterMesh->GetAnimInstance()); URoguelikeGameInstance* GameInstance = Cast<URoguelikeGameInstance>(GetGameInstance()); GameInstance->Character = this; GameInstance->StartGameInstance(); GNearClippingPlane = 0.1f; InitializeGameplayStats(); }
void ANimModGameState::OnRestartTimerExpired() { GetWorld()->GetTimerManager().ClearTimer(restartHandle); if (ISSERVER) { UNimModGameInstance *gameInstance = Cast<UNimModGameInstance>(GetGameInstance()); if (gameInstance) { gameInstance->SaveTeamsForRoundRestart(this->Teams); } } UWorld *world = GetWorld(); if (world != nullptr) { for (FConstControllerIterator Iterator = world->GetControllerIterator(); Iterator; ++Iterator) { AController* Controller = *Iterator; ANimModPlayerController* PlayerController = Cast<ANimModPlayerController>(Controller); if (PlayerController) PlayerController->ClientRestartRound(); } } RestartRound(); UnfreezePlayers(); }
void AZombieCharacter::Die() { //Disables the logic of the zombie and gradually destroys this Actor AZombieController* ZCon = Cast<AZombieController>(GetController()); if (ZCon) { //Increasing the kills and wave count if necessary OurCharacter->Kills++; URoguelikeGameInstance* GameInstance = Cast<URoguelikeGameInstance>(GetGameInstance()); GameInstance->IncreaseWaveCountIfNeeded(); OurCharacter->PlayerController->UpdateUI(); //Stopping the AI logic ZCon->UnPossess(); AlphaChannelReduction(); //AlphaReductionTimeline.PlayFromStart(); //Handling the last animations ZAnimInstance->bIsDead = true; ZAnimInstance->Speed = 0; AudioComponent->Stop(); //Disabling the collision to avoid false kill count! UCapsuleComponent* RootComp = Cast<UCapsuleComponent>(GetRootComponent()); RootComp->SetCollisionEnabled(ECollisionEnabled::NoCollision); } }
void UOnlineSessionClient::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result) { UE_LOG(LogOnline, Verbose, TEXT("OnJoinSessionComplete %s bSuccess: %d"), *SessionName.ToString(), static_cast<int32>(Result)); IOnlineSessionPtr SessionInt = GetSessionInt(); if (SessionInt.IsValid()) { SessionInt->ClearOnJoinSessionCompleteDelegate_Handle(OnJoinSessionCompleteDelegateHandle); if (Result == EOnJoinSessionCompleteResult::Success) { FString URL; if (SessionInt->GetResolvedConnectString(SessionName, URL)) { APlayerController* PC = GetGameInstance()->GetFirstLocalPlayerController(GetWorld()); if (PC) { if (bIsFromInvite) { URL += TEXT("?bIsFromInvite"); bIsFromInvite = false; } PC->ClientTravel(URL, TRAVEL_Absolute); } } else { UE_LOG(LogOnline, Warning, TEXT("Failed to join session %s"), *SessionName.ToString()); } } } }
void ANinjaGameModeBase::BeginPlay() { UNinjaGameInstance* GameInst = (UNinjaGameInstance*)GetGameInstance(); if (GameInst && !Debug) { RoundLimit = GameInst->GetNumRounds(); } }
void UOnlineSessionClient::JoinSession(FName SessionName, const FOnlineSessionSearchResult& SearchResult) { // Clean up existing sessions if applicable IOnlineSessionPtr SessionInt = GetSessionInt(); if (SessionInt.IsValid()) { EOnlineSessionState::Type SessionState = SessionInt->GetSessionState(SessionName); if (SessionState != EOnlineSessionState::NoSession) { CachedSessionResult = SearchResult; OnEndForJoinSessionCompleteDelegateHandle = EndExistingSession_Impl(SessionName, OnEndForJoinSessionCompleteDelegate); } else { GetGameInstance()->JoinSession(GetGameInstance()->GetFirstGamePlayer(), SearchResult); } } }
void AShooterGameMode::InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage) { const int32 BotsCountOptionValue = GetIntOption(Options, GetBotsCountOptionName(), 0); SetAllowBots(BotsCountOptionValue > 0 ? true : false, BotsCountOptionValue); Super::InitGame(MapName, Options, ErrorMessage); const UGameInstance* GameInstance = GetGameInstance(); if (GameInstance && Cast<UShooterGameInstance>(GameInstance)->GetIsOnline()) { bPauseable = false; } }
void ASDBXGameMode::SetSongLoop() { //Set the song loop to play USDBXGameInstance* GInstance = Cast<USDBXGameInstance>(GetGameInstance()); FString name = GInstance->GetSongName(); name = name.Replace(TEXT(" "), TEXT("")); name = name.Replace(TEXT("("), TEXT("")); name = name.Replace(TEXT(")"), TEXT("")); FString SoundCuePath = "/Game/Audio/" + name + "." + name; songLoop = Cast<USoundCue>(StaticLoadObject(USoundCue::StaticClass(), NULL, *SoundCuePath)); UE_LOG(LogTemp, Warning, TEXT("%s"), *SoundCuePath); }
void UUpdateManager::CheckComplete(EUpdateCompletionStatus Result, bool bUpdateTimestamp) { UE_LOG(LogHotfixManager, Display, TEXT("CheckComplete %s"), UpdateCompletionEnum ? *UpdateCompletionEnum->GetEnumName((int32)Result) : TEXT("Invalid")); UGameInstance* GameInstance = GetGameInstance(); bool bIsServer = GameInstance->IsDedicatedServerInstance(); #if !UE_BUILD_SHIPPING int32 DbgVal = CVarDebugUpdateManager.GetValueOnGameThread(); if (DbgVal >= 0 && DbgVal <= (int32)EUpdateCompletionStatus::UpdateFailure_NotLoggedIn) { Result = (EUpdateCompletionStatus)DbgVal; UE_LOG(LogHotfixManager, Display, TEXT("CheckComplete OVERRIDE! %s"), UpdateCompletionEnum ? *UpdateCompletionEnum->GetEnumName((int32)Result) : TEXT("Invalid")); } #endif LastCompletionResult[bCheckHotfixAvailabilityOnly] = Result; const bool bSuccessResult = (Result == EUpdateCompletionStatus::UpdateSuccess || Result == EUpdateCompletionStatus::UpdateSuccess_NoChange || Result == EUpdateCompletionStatus::UpdateSuccess_NeedsReload || Result == EUpdateCompletionStatus::UpdateSuccess_NeedsRelaunch); if (bUpdateTimestamp && bSuccessResult) { LastUpdateCheck[bCheckHotfixAvailabilityOnly] = FDateTime::UtcNow(); } auto CompletionDelegate = [this, Result]() { UE_LOG(LogHotfixManager, Display, TEXT("External CheckComplete %s"), UpdateCompletionEnum ? *UpdateCompletionEnum->GetEnumName((int32)Result) : TEXT("Invalid")); if (!bInitialUpdateFinished) { // Prime the state so that the first "after login" check will occur bInitialUpdateFinished = true; SetUpdateState(EUpdateState::UpdatePending); } else { SetUpdateState(EUpdateState::UpdateComplete); } bCheckHotfixAvailabilityOnly = false; OnUpdateCheckComplete().Broadcast(Result); }; // Delay completion delegate to give UI a chance to show the screen for a reasonable amount of time DelayResponse(CompletionDelegate, bCheckHotfixAvailabilityOnly ? UpdateCheckAvailabilityCompleteDelay : UpdateCheckCompleteDelay); }
void ASDBXGameMode::InitializeSpawners() { //Parse the beatmap FString GameDir = FPaths::GameDir(); USDBXGameInstance* GInstance = Cast<USDBXGameInstance>(GetGameInstance()); FString CompleteFilePath = GameDir + "Content/BeatMaps/" + GInstance->GetSongName() + ".txt"; TArray<FString> songData; FFileHelper::LoadANSITextFileToStrings(*CompleteFilePath, NULL, songData); songLength = FCString::Atof(*songData[0]); bpm = FCString::Atof(*songData[1]); startOffset = FCString::Atof(*songData[2]); FTimerHandle handle1; GetWorldTimerManager().SetTimer(handle1, this, &ASDBXGameMode::StartSong, startOffset, false); ParseString(songData[3]); }
void AThe_Time_Of_EndingGameMode::BeginPlay() { Super::BeginPlay(); DefaultPawnClass = MhambiPawnClass; APlayerController* player1 = UGameplayStatics::GetPlayerController(this, 0); //player1->SetPawn(Cast<APawn>(MhambiPawnClass->GetArchetype())); DefaultPawnClass = ReyPawnClass; FString error; ULocalPlayer* player2 = GetGameInstance()->CreateLocalPlayer(1, error, true); GEngine->AddOnScreenDebugMessage(-1, 3.0f, FColor::Blue, "Begin Play"); DefaultPawnClass = MhambiPawnClass; }
bool AGameModeBase::SpawnPlayerFromSimulate(const FVector& NewLocation, const FRotator& NewRotation) { #if WITH_EDITOR APlayerController* PC = GetGameInstance()->GetFirstLocalPlayerController(); if (PC != nullptr) { PC->PlayerState->bOnlySpectator = false; bool bNeedsRestart = true; if (PC->GetPawn() == nullptr) { // Use the "auto-possess" pawn in the world, if there is one. for (FConstPawnIterator Iterator = GetWorld()->GetPawnIterator(); Iterator; ++Iterator) { APawn* Pawn = *Iterator; if (Pawn && Pawn->AutoPossessPlayer == EAutoReceiveInput::Player0) { if (Pawn->Controller == nullptr) { PC->Possess(Pawn); bNeedsRestart = false; } break; } } } if (bNeedsRestart) { RestartPlayer(PC); if (PC->GetPawn()) { // If there was no player start, then try to place the pawn where the camera was. if (PC->StartSpot == nullptr || Cast<AWorldSettings>(PC->StartSpot.Get())) { const FVector Location = NewLocation; const FRotator Rotation = NewRotation; PC->SetControlRotation(Rotation); PC->GetPawn()->TeleportTo(Location, Rotation); } } } } #endif return true; }
// Called when the game starts or when spawned void APlayerCharacter::BeginPlay() { Super::BeginPlay(); //UInventoryComponent UOncomingGameInstance* inst = Cast<UOncomingGameInstance>(GetGameInstance()); if(inst) { registry = inst->ItemRegistry; } UWorld* world = GetWorld(); if (world) { //AItem* item = Cast<AItem>(world->SpawnActor(AItem::StaticClass())); //item->Name = "Used 0 times!"; //Cast<UInventoryComponent>(GetComponentsByClass(UInventoryComponent::StaticClass())[0])->PrimarySlot = item; } }
//~~ Called when the game starts or when spawned ~~// void APOTLStructure::BeginPlay() { Super::BeginPlay(); // Bind to time update APOTLGameMode* GameMode = Cast<APOTLGameMode>(GetWorld()->GetAuthGameMode()); if (GameMode) { GameMode->OnTimeUpdated.AddDynamic(this, &APOTLStructure::OnTimeUpdate); } GameInstance = Cast<UPOTLGameInstance>(GetGameInstance()); if (GameInstance) { //IncludeStorage // Add test resources //FreeResources.Add(TEXT("Wood"), 9.f); //FreeResources.Add(TEXT("Stone"), 15.f); // Add test factory for resource process //FST_Factory Factory; //Factory.Invoice.Add(FName(TEXT("Plank"), 1)); //Factory.Invoice.Add(TEXT("Plank"), 1); //Factories.Add(Factory); //GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, Factory.Invoice[FName(TEXT("Plank")]); } if (IsValid(AttachedTo)) { // Bind to labor } //GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, FName(TEXT("Plank")).ToString()); /*********** BINDINGS **************/ //UPOTLGameInstance::OnTurnSwitched.AddDynamic(this, &APOTLStructure::RequestResources); //UPOTLGameInstance::OnTurnSwitched.Add(this, &APOTLStructure::RequestResources); //UPOTLGameInstance::OnNewTurn.Add(this, &APOTLStructure::BindToDelegate); }
void ARoguelikeChar::SpawnHealthKits() { if(PlayerController) { FVector SpawnPosition; TArray<AActor*> AllStaticMeshes; UGameplayStatics::GetAllActorsOfClass(GetWorld(), AStaticMeshActor::StaticClass(), AllStaticMeshes); URoguelikeGameInstance* GameInstance = Cast<URoguelikeGameInstance>(GetGameInstance()); int32 SpawnedFirstAidKits = 0; do { int32 RandomTileIndex = FMath::RandRange(0, AllStaticMeshes.Num() - 1); AStaticMeshActor* StaticMesh = Cast<AStaticMeshActor>(AllStaticMeshes[RandomTileIndex]); if ( (StaticMesh->ActorHasTag(FName("PowerUpTile"))) && !(StaticMesh->Tags.Contains(FName("HasPowerup"))) ) { SpawnPosition = AllStaticMeshes[RandomTileIndex]->GetActorLocation(); SpawnPosition.Z += 50; SpawnedFirstAidKits++; //Declaring spawning parameters FActorSpawnParameters SpawnParams; SpawnParams.Owner = this; SpawnParams.Instigator = Instigator; AFirstAidKit* Kit = GetWorld()->SpawnActor<AFirstAidKit>(GameInstance->FirstAidKitBP, SpawnPosition, FRotator(), SpawnParams); //If the kit is for overtime heal mark it as such and update its material /*if(FMath::RandBool()) { Kit->bIsOvertimeHeal = true; Kit->UpdateMaterial(); }*/ } } while (SpawnedFirstAidKits<GameInstance->MaxFirstAidKits); } }
void AFireball::BeginPlay() { Super::BeginPlay(); MovementComponent->SetActive(false); MousePressedTime = 0; FireScale = 1; ParticleSystemComponent->SetIsReplicated(true); if (GetGameInstance()->GetFirstLocalPlayerController() != NULL) { //auto inputManager = UInputEventManager::Get(); auto pc = Cast<AThirdPersonProjectCharacter>(GetOwner()); if (pc && pc->IsLocallyControlled()) { pc->OnMouseEvent.AddDynamic(this, &AFireball::OnMouseEvent); } } }
void ADonkeyKongCharacter::BeginPlay() { Super::BeginPlay(); for (auto It = TActorIterator<ADKLevelMaster>(GetWorld()); It; ++It) { MasterLevel = *It; break; } for (auto Iter = LadderToTrace.CreateConstIterator(); Iter; ++Iter) { const ECollisionChannel & Channel = (*Iter); if (FCollisionObjectQueryParams::IsValidObjectQuery(Channel)) { LadderPrams.AddObjectTypesToQuery(Channel); } } GameMode = Cast<ADonkeyKongGameMode>(GetWorld()->GetAuthGameMode()); GameInstance = Cast<UDKGameInstance>(GetGameInstance()); }
void ARoguelikeChar::SpawnDDs() { if (PlayerController) { FVector SpawnPosition; TArray<AActor*> AllStaticMeshes; UGameplayStatics::GetAllActorsOfClass(GetWorld(), AStaticMeshActor::StaticClass(), AllStaticMeshes); URoguelikeGameInstance* GameInstance = Cast<URoguelikeGameInstance>(GetGameInstance()); int32 SpawnedDoubleDamagePowerups = 0; //Spawning Double Damage... do { //Selecting a random valid tile int32 RandomTileIndex = FMath::RandRange(0, AllStaticMeshes.Num() - 1); if (AllStaticMeshes[RandomTileIndex]->ActorHasTag(FName("PowerUpTile")) && !AllStaticMeshes[RandomTileIndex]->Tags.Contains(FName("HasPowerup"))) { SpawnPosition = AllStaticMeshes[RandomTileIndex]->GetActorLocation(); SpawnPosition.Z += 100; SpawnedDoubleDamagePowerups++; //Declaring spawning parameters FActorSpawnParameters SpawnParams; SpawnParams.Owner = this; SpawnParams.Instigator = Instigator; ADoubleDamagePowerup* DD = GetWorld()->SpawnActor<ADoubleDamagePowerup>(GameInstance->DoubleDamageBP, SpawnPosition, FRotator(), SpawnParams); AllStaticMeshes[RandomTileIndex]->Tags.Add(FName("HasPowerup")); } } while (SpawnedDoubleDamagePowerups < GameInstance->MaxDDPowerups); } }
FString UShooterLocalPlayer::GetNickname() const { auto Nickname = Super::GetNickname(); auto bReplace = (Nickname.Len() == 0); static bool bReentry = false; if (!bReentry) { bReentry = true; const auto World = GetWorld(); if (nullptr != World) { const auto GameInstance = World->GetGameInstance(); if (nullptr != GameInstance) { const auto LocalPlayers = GameInstance->GetLocalPlayers(); for (auto i : LocalPlayers) { if (this == i) { break; } if (i->GetNickname() == Nickname) { bReplace = true; break; } } } } bReentry = false; } if (bReplace) { Nickname = FString::Printf(TEXT("Player%i"), GetControllerId() + 1); } return Nickname; }
void ALabyrinthGameMode::RequestFinishAndExitToMainMenu() { FinishMatch(); // TO-DO: Change this to ULGameInstance UGameInstance* const GI = GetGameInstance(); if (GI) { //GI->RemoveSplitScreenPlayers; } ALPlayerController* LocalPrimaryController = nullptr; for (FConstPlayerControllerIterator It = GetWorld()->GetPlayerControllerIterator(); It; It++) { ALPlayerController* Controller = Cast<ALPlayerController>(*It); if (Controller == NULL) { continue; } if (!Controller->IsLocalController()) { const FString RemoteReturnReason = NSLOCTEXT("Network Errors", "HostHasLeft", "Host has left the game.").ToString(); Controller->ClientReturnToMainMenu(RemoteReturnReason); } else { LocalPrimaryController = Controller; } } // GameInstance should call this from an EndState. So call the PC function that performs cleanup // not the one that sets GI state if (LocalPrimaryController != NULL) { // TO-DO: Add this to the player Controller. //LocalPrimaryController->HandleReturnToMainMenu(); } }
void AHeliGameModeLobby::InitGameState() { Super::InitGameState(); AHeliLobbyGameState* const MyGameState = Cast<AHeliLobbyGameState>(GameState); if (MyGameState) { MyGameState->NumTeams = NumTeams; // setting custom player configuration in the game state when hosting a match like custom server name, selected game mode, selected map, etc. UHeliGameInstance* MyGameInstance = Cast<UHeliGameInstance>(GetGameInstance()); if (MyGameInstance) { MyGameState->ServerName = MyGameInstance->CustomServerName; MyGameState->GameModeName = MyGameInstance->SelectedGameMode; MyGameState->MapName = MyGameInstance->SelectedMapName; MyGameState->MaxNumberOfPlayers = MyGameInstance->MaxNumberOfPlayers; MyGameState->MaxRoundTime = MyGameInstance->RoundTime; MyGameState->MaxWarmupTime = MyGameInstance->WarmupTime; } } }
void ABrainNormalInteractiveObject::Load() { FString name = GetName(); FBrainNIOSaveData savedData = Cast<UBrainGameInstance>(GetGameInstance())->GetSaveManager()->GetDataFromSave<FBrainNIOSaveData>(name); if (savedData._loadFromfile) { // Load Translation SetActorLocation(savedData._location); _currentTranslation = savedData._location; _targetTranslation = savedData._location; SetActorRotation(savedData._rotation); _currentRotation = savedData._rotation; _targetRotation = savedData._rotation; SetActorScale3D(savedData._scale); _currentScale = savedData._scale; _targetScale = savedData._scale; _cachedTransform = GetTransform(); SetActorTransform(FTransform(Shear(savedData._shearFirstAxis, savedData._shearSecondAxis))*_cachedTransform); } }
void AGameModeBase::PostLogin(APlayerController* NewPlayer) { // Runs shared initialization that can happen during seamless travel as well GenericPlayerInitialization(NewPlayer); // Perform initialization that only happens on initially joining a server UWorld* World = GetWorld(); NewPlayer->ClientCapBandwidth(NewPlayer->Player->CurrentNetSpeed); if (MustSpectate(NewPlayer)) { NewPlayer->ClientGotoState(NAME_Spectating); } else { // If NewPlayer is not only a spectator and has a valid ID, add him as a user to the replay. if (NewPlayer->PlayerState->UniqueId.IsValid()) { GetGameInstance()->AddUserToReplay(NewPlayer->PlayerState->UniqueId.ToString()); } } if (GameSession) { GameSession->PostLogin(NewPlayer); } // Notify Blueprints that a new player has logged in. Calling it here, because this is the first time that the PlayerController can take RPCs K2_PostLogin(NewPlayer); FGameModeEvents::GameModePostLoginEvent.Broadcast(this, NewPlayer); // Now that initialization is done, try to spawn the player's pawn and start match HandleStartingNewPlayer(NewPlayer); }
void ARoguelikeChar::SpawnZombiesSpawnPoints() { if (PlayerController) { FVector SpawnPosition; TArray<AActor*> AllStaticMeshes; UGameplayStatics::GetAllActorsOfClass(GetWorld(), AStaticMeshActor::StaticClass(), AllStaticMeshes); URoguelikeGameInstance* GameInstance = Cast<URoguelikeGameInstance>(GetGameInstance()); int32 SpawnedPoints = 0; for (int32 i = 0; i < AllStaticMeshes.Num() && (SpawnedPoints < GameInstance->MaxZombiesSpawnPoints); i++) { if (AllStaticMeshes[i]->ActorHasTag(FName("Spike"))) { SpawnPosition = AllStaticMeshes[i]->GetActorLocation(); SpawnPosition.Z += 270; SpawnedPoints++; FActorSpawnParameters SpawnParams; //SpawnParams.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod; SpawnParams.Owner = this; SpawnParams.Instigator = Instigator; GLog->Log("Found a spike"); AZombieSpawnPoint* SpawnPoint = GetWorld()->SpawnActor<AZombieSpawnPoint>(GameInstance->SpawnPointBP, SpawnPosition, FRotator(0, 0, 0), SpawnParams); } } } }
void ABrainNormalInteractiveObject::Load() { if (!GetName().IsEmpty()) { if (UBrainGameInstance* gameInstance = Cast<UBrainGameInstance>(GetGameInstance())) { if (UBrainSaveManager* saveManager = gameInstance->GetSaveManager()) { FBrainNIOSaveData savedData = saveManager->GetDataFromSave<FBrainNIOSaveData>(GetName()); if (savedData._loadFromfile) { // Movement Counters and Energy _countRotation = savedData._countRotation; _countTranslation = savedData._countTranslation; _countScale = savedData._countScale; _countShear = savedData._countShear; // Load Translation SetActorLocation(savedData._location); _currentTranslation = savedData._location; _targetTranslation = savedData._location; SetActorRotation(savedData._rotation); _currentRotation = savedData._rotation; _targetRotation = savedData._rotation; SetActorScale3D(savedData._scale); _currentScale = savedData._scale; _targetScale = savedData._scale; _cachedTransform = GetTransform(); SetActorTransform(FTransform(Shear(savedData._shearFirstAxis, savedData._shearSecondAxis)) * _cachedTransform); } } } } }
void AShooterGameMode::RequestFinishAndExitToMainMenu() { FinishMatch(); UShooterGameInstance* const GameInstance = Cast<UShooterGameInstance>(GetGameInstance()); if (GameInstance) { GameInstance->RemoveSplitScreenPlayers(); } AShooterPlayerController* LocalPrimaryController = nullptr; for (FConstPlayerControllerIterator Iterator = GetWorld()->GetPlayerControllerIterator(); Iterator; ++Iterator) { AShooterPlayerController* Controller = Cast<AShooterPlayerController>(*Iterator); if (Controller == NULL) { continue; } if (!Controller->IsLocalController()) { const FString RemoteReturnReason = NSLOCTEXT("NetworkErrors", "HostHasLeft", "Host has left the game.").ToString(); Controller->ClientReturnToMainMenu(RemoteReturnReason); } else { LocalPrimaryController = Controller; } } // GameInstance should be calling this from an EndState. So call the PC function that performs cleanup, not the one that sets GI state. if (LocalPrimaryController != NULL) { LocalPrimaryController->HandleReturnToMainMenu(); } }