PresenceKeyGameMode

PresenceKeyGameMode

#Overview

name: PresenceKeyGameMode

The value of this variable can be defined or overridden in .ini config files. 3 .ini config files referencing this setting variable.

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of PresenceKeyGameMode is to serve as a configuration variable that maps the “Game Mode” rich presence entry to a backend key in the Unreal Engine’s online presence system. This variable is primarily used for player presence and session information management.

PresenceKeyGameMode is utilized by the CommonUser plugin, specifically within the CommonUserBasicPresence subsystem. This subsystem is responsible for managing and updating user presence information in online multiplayer scenarios.

The value of this variable is set through configuration, as indicated by the UPROPERTY(Config) decorator in the class definition. This means it can be modified in the project’s configuration files without changing the source code.

PresenceKeyGameMode interacts closely with other presence-related variables, such as PresenceKeyMapName. Both are used together to update a player’s online presence status with information about the current game mode and map.

Developers must be aware that this variable is crucial for accurately representing the player’s current game state in online services. It should be properly configured to match the backend expectations for presence information.

Best practices when using this variable include:

  1. Ensuring the configuration value matches the backend’s expected key for game mode information.
  2. Consistently updating the presence information when the game mode changes.
  3. Coordinating with backend services to ensure proper interpretation of the presence data.
  4. Considering localization aspects if the game mode names are displayed to users in different regions.

#Setting Variables

#References In INI files

Location: <Workspace>/Projects/Lyra/Config/Custom/Steam/DefaultEngine.ini:45, section: [/Script/CommonUser.CommonUserBasicPresence]

Location: <Workspace>/Projects/Lyra/Config/Custom/SteamEOS/DefaultEngine.ini:101, section: [/Script/CommonUser.CommonUserBasicPresence]

Location: <Workspace>/Projects/Lyra/Config/Custom/SteamEOS/DefaultGame.ini:10, section: [CommonSessionSubsystem]

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Projects/Lyra/Plugins/CommonUser/Source/CommonUser/Private/CommonUserBasicPresence.cpp:79

Scope (from outer to inner):

file
function     void UCommonUserBasicPresence::OnNotifySessionInformationChanged

Source code excerpt:

				FOnlineUserPresenceStatus UpdatedPresence;
				UpdatedPresence.StatusStr = *SessionStateToBackendKey(SessionStatus);
				UpdatedPresence.Properties.Emplace(PresenceKeyGameMode, GameMode);
				UpdatedPresence.Properties.Emplace(PresenceKeyMapName, MapNameTruncated);

				for (const ULocalPlayer* LocalPlayer : GetGameInstance()->GetLocalPlayers())
				{
					if (LocalPlayer && LocalPlayer->GetPreferredUniqueNetId().GetUniqueNetId() != nullptr)
					{

#Loc: <Workspace>/Projects/Lyra/Plugins/CommonUser/Source/CommonUser/Private/CommonUserBasicPresence.cpp:106

Scope (from outer to inner):

file
function     void UCommonUserBasicPresence::OnNotifySessionInformationChanged

Source code excerpt:

					UpdateParams.LocalAccountId = LocalPlayer->GetPreferredUniqueNetId().GetV2();
					UpdateParams.Mutations.StatusString.Emplace(*SessionStateToBackendKey(SessionStatus));
					UpdateParams.Mutations.UpdatedProperties.Emplace(PresenceKeyGameMode, GameMode);
					UpdateParams.Mutations.UpdatedProperties.Emplace(PresenceKeyMapName, MapNameTruncated);

					Presence->PartialUpdatePresence(MoveTemp(UpdateParams));
				}
			}

#Loc: <Workspace>/Projects/Lyra/Plugins/CommonUser/Source/CommonUser/Public/CommonUserBasicPresence.h:48

Scope (from outer to inner):

file
class        class UCommonUserBasicPresence : public UGameInstanceSubsystem

Source code excerpt:

	/** Maps the "Game Mode" rich presence entry to a backend key*/
	UPROPERTY(Config)
	FString PresenceKeyGameMode;

	/** Maps the "Map Name" rich presence entry to a backend key*/
	UPROPERTY(Config)
	FString PresenceKeyMapName;

	void OnNotifySessionInformationChanged(ECommonSessionInformationState SessionStatus, const FString& GameMode, const FString& MapName);