OLS/Source/ols/Public/GameModes/OLSGameMode.h

78 lines
3.4 KiB
C++

// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action.
#pragma once
#include "CoreMinimal.h"
#include "CommonSessionSubsystem.h"
#include "ModularGameplayActors/OLSModularGameMode.h"
#include "OLSGameMode.generated.h"
/**
* Post login event, triggered when a player or bot joins the game as well as after seamless and non seamless travel
*
* This is called after the player has finished initialization
*/
DECLARE_MULTICAST_DELEGATE_TwoParams(FOLSGameModePlayerInitializeNativeDelegate, class AGameModeBase* /*GameMode*/,
class AController* /*NewPlayer*/);
/**
* AOLSGameMode
*
* The base game mode class used by this project.
*/
UCLASS(Config = Game, Meta = (ShortTooltip = "The base game mode class used by this project."))
class OLS_API AOLSGameMode : public AOLSModularGameModeBase
{
GENERATED_BODY()
public:
AOLSGameMode(const FObjectInitializer& objectInitializer);
UFUNCTION(BlueprintCallable, Category = "OLS|Pawn")
const class UOLSPawnDataAsset* GetPawnDataForController(const class AController* controller) const;
//~ Begin AGameModeBase interface
virtual void InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage) override;
virtual UClass* GetDefaultPawnClassForController_Implementation(AController* controller) override;
virtual APawn* SpawnDefaultPawnAtTransform_Implementation(AController* newPlayer, const FTransform& spawnTransform) override;
virtual bool ShouldSpawnAtStartSpot(AController* Player) override;
virtual void HandleStartingNewPlayer_Implementation(APlayerController* newPlayer) override;
virtual AActor* ChoosePlayerStart_Implementation(AController* player) override;
virtual void FinishRestartPlayer(AController* newPlayer, const FRotator& startRotation) override;
virtual bool PlayerCanRestart_Implementation(APlayerController* player) override;
virtual void InitGameState() override;
virtual bool UpdatePlayerStartSpot(AController* player, const FString& portal, FString& outErrorMessage) override;
virtual void GenericPlayerInitialization(AController* newPlayer) override;
virtual void FailedToRestartPlayer(AController* newPlayer) override;
//~ End AGameModeBase interface
// Restart (respawn) the specified player or bot next frame
// - If bForceReset is true, the controller will be reset this frame (abandoning the currently possessed pawn, if any)
UFUNCTION(BlueprintCallable)
void RequestPlayerRestartNextFrame(AController* controller, bool shouldForceReset = false);
// Agnostic version of PlayerCanRestart that can be used for both player bots and players
virtual bool ControllerCanRestart(AController* controller);
// Delegate called on player initialization, described above
FOLSGameModePlayerInitializeNativeDelegate OnGameModePlayerInitialized;
protected:
void OnExperienceLoaded(const class UOLSExperienceDefinitionDataAsset* currentExperience);
bool IsExperienceLoaded() const;
void OnMatchAssignmentGiven(FPrimaryAssetId experienceId, const FString& experienceIdSource);
void HandleMatchAssignmentIfNotExpectingOne();
bool TryDedicatedServerLogin();
void HostDedicatedServerMatch(ECommonSessionOnlineMode onlineMode);
UFUNCTION()
void OnUserInitializedForDedicatedServer(const UCommonUserInfo* userInfo, bool isSuccess, FText error, ECommonUserPrivilege requestedPrivilege, ECommonUserOnlineContext onlineContext);
};