RealtimeStyleTransferRuntime/Plugins/CommonGame/Source/Public/CommonGameInstance.h

74 lines
3.1 KiB
C
Raw Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
2022-09-13 07:18:28 +00:00
#include "CommonUserTypes.h"
#include "CoreTypes.h"
2022-05-23 18:41:30 +00:00
#include "Engine/GameInstance.h"
2022-09-13 07:18:28 +00:00
#include "GameplayTagContainer.h"
#include "UObject/UObjectGlobals.h"
#include "UObject/WeakObjectPtrTemplates.h"
2022-05-23 18:41:30 +00:00
#include "CommonGameInstance.generated.h"
2022-09-13 07:18:28 +00:00
class FText;
class UCommonUserInfo;
class UCommonSession_SearchResult;
struct FOnlineResultInformation;
2022-05-23 18:41:30 +00:00
class ULocalPlayer;
class USocialManager;
2022-09-13 07:18:28 +00:00
class UObject;
struct FFrame;
struct FGameplayTag;
2022-05-23 18:41:30 +00:00
UCLASS(Abstract, Config = Game)
class COMMONGAME_API UCommonGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
UCommonGameInstance(const FObjectInitializer& ObjectInitializer);
/** Handles errors/warnings from CommonUser, can be overridden per game */
UFUNCTION()
virtual void HandleSystemMessage(FGameplayTag MessageType, FText Title, FText Message);
UFUNCTION()
virtual void HandlePrivilegeChanged(const UCommonUserInfo* UserInfo, ECommonUserPrivilege Privilege, ECommonUserAvailability OldAvailability, ECommonUserAvailability NewAvailability);
/** Call to reset user and session state, usually because a player has been disconnected */
virtual void ResetUserAndSessionState();
2022-09-13 07:18:28 +00:00
/**
* Requested Session Flow
* Something requests the user to join a specific session (for example, a platform overlay via OnUserRequestedSession).
* This request is handled in SetRequestedSession.
* Check if we can join the requested session immediately (CanJoinRequestedSession). If we can, join the requested session (JoinRequestedSession)
* If not, cache the requested session and instruct the game to get into a state where the session can be joined (ResetGameAndJoinRequestedSession)
*/
/** Handles user accepting a session invite from an external source (for example, a platform overlay). Intended to be overridden per game. */
virtual void OnUserRequestedSession(const FPlatformUserId& PlatformUserId, UCommonSession_SearchResult* InRequestedSession, const FOnlineResultInformation& RequestedSessionResult);
/** Get the requested session */
UCommonSession_SearchResult* GetRequestedSession() const { return RequestedSession; }
/** Set (or clear) the requested session. When this is set, the requested session flow begins. */
virtual void SetRequestedSession(UCommonSession_SearchResult* InRequestedSession);
/** Checks if the requested session can be joined. Can be overridden per game. */
virtual bool CanJoinRequestedSession() const;
/** Join the requested session */
virtual void JoinRequestedSession();
/** Get the game into a state to join the requested session */
virtual void ResetGameAndJoinRequestedSession();
virtual int32 AddLocalPlayer(ULocalPlayer* NewPlayer, FPlatformUserId UserId) override;
2022-05-23 18:41:30 +00:00
virtual bool RemoveLocalPlayer(ULocalPlayer* ExistingPlayer) override;
virtual void Init() override;
virtual void ReturnToMainMenu() override;
private:
/** This is the primary player*/
TWeakObjectPtr<ULocalPlayer> PrimaryPlayer;
2022-09-13 07:18:28 +00:00
/** Session the player has requested to join */
UPROPERTY()
TObjectPtr<UCommonSession_SearchResult> RequestedSession;
2022-05-23 18:41:30 +00:00
};