gameinstancemanager - TogetherGames/Public-Unity-CSharp GitHub Wiki

GameInstanceManager

together.GameInstanceManager

Overview

The GameInstanceManager is used for fetching and finding matches that exist for the current game.


Members

List<GameInstance> GameInstances

Stores all the GameInstances contained in the Manager.


Methods


Add()

Adds a GameInstance to the manager internally without persistence.

Note
This method is deprecated

Returns void
Syntax
GameInstanceManager.Add( gameInstance )
Parameters

GameInstance gameInstance

Instance of a GameInstance to add internally

--------------------------------------------------------------------------------

FindByGameInstanceID()

Finds the GameInstance with the specified GameInstanceID if it exists, otherwise returns null

Returns GameInstance
Syntax
GameInstanceManager.FindByGameInstanceID( gameInstanceID )
Parameters

long gameInstanceID

The ID of the GameInstance to find

--------------------------------------------------------------------------------

GetCount()

Gets the number of GameInstances currently managed internally.

Returns int
Syntax
GameInstanceManager.GetCount(  )

Get()

Gets the GameInstance at the specified index if it exists, otherwise return null.

Returns GameInstance
Syntax
GameInstanceManager.Get( index )
Parameters

int index

The index of the GameInstance to find

--------------------------------------------------------------------------------

IndexOf()

Returns the index of the specified GameInstance if it exists, otherwise returns -1.

Returns int
Syntax
GameInstanceManager.IndexOf( gameInstance )
Parameters

GameInstance gameInstance

Instance of the GameInstance to find the index of

--------------------------------------------------------------------------------

IndexOfByGameInstanceID()

Returns the index of the GameInstance with the specified GameInstanceID if it exists, otherwise returns -1

Returns int
Syntax
GameInstanceManager.IndexOfByGameInstanceID( gameInstanceID )
Parameters

long gameInstanceID

The ID of the GameInstance to find the index of

--------------------------------------------------------------------------------

Remove()

Removes a GameInstance from the internally managed list. This does not delete the GameInstance from the Game persistently.

Note
This method is deprecated

Returns void
Syntax
GameInstanceManager.Remove( index )
Parameters

int index

The index of the GameInstance to be removed internally

--------------------------------------------------------------------------------

PostProcessUsernames()

Post processes the GameInstanceUser's usernames. If a GameInstanceUser's User is registered, its Name member will be assigned the name from their social network account. Otherwise, the Name member will be set to the User's Username.

Returns void
Syntax
GameInstanceManager.PostProcessUsernames(  )

Create()

Creates a new GameInstance. Upon success, this will automatically update the internal list.

Returns void
Syntax
GameInstanceManager.Create( gameInstanceType, gameInstanceSubType, roomID, maxUsers, passTurn, gameInstanceProperties, gameInstanceUserProperties, callbackFunc )
Parameters

string gameInstanceType

The type of GameInstance to create. Potentially, a Game could have several types of GameInstance types within it. Type is limited to 16 characters.

[string](#) gameInstanceSubType

The subtype of the GameInstance that will be created. Potentially, a Game could have several sub types within it. SubType is limited to 16 characters.

[long](#) roomID

The ID of the room the rematch GameInstance is created in. Pass 0 to bypass room creation.

[int](#) maxUsers

The max number of users the GameInstance supports. Pass in 2 for a two player game.

[bool](#) passTurn

A boolean indicating whether the turn should be passed immediately onto the next User. When true, the TurnUserID will actually be set to null. When the next User joins the GameInstance, the TurnUserID will be set to them.

[PropertyCollection](./propertycollection) gameInstanceProperties

The properties to assign to the GameInstance. Pass null to assign no properties to the GameInstance.

[PropertyCollection](./propertycollection) gameInstanceUserProperties

The properties to assign to your GameInstanceUser. Pass null to assign no properties to the GameInstanceUser.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

CreateRematch()

Creates a rematch of a GameInstance. Upon success, this will automatically update the internal list. If the GameInstance is not already finished, it will be finished and a leaderboard will be generated.

Returns void
Syntax
GameInstanceManager.CreateRematch( originalGameInstanceID, gameInstanceType, gameInstanceSubType, roomID, maxUsers, winningUserID, turnUserID, includeLeftGameUsers, rematchMessage, originalGameProps, origianlGameWinningUserProps, rematchGameProps, callbackFunc )
Parameters

long originalGameInstanceID

The ID of the original GameInstance we're creating a rematch from.

[string](#) gameInstanceType

The type of GameInstance to create. Potentially, a Game could have several types of GameInstance types within it. Type is limited to 16 characters.

[string](#) gameInstanceSubType

The subtype of the GameInstance that will be created. Potentially, a Game could have several subtypes within it. SubType is limited to 16 characters.

[long](#) roomID

The ID of the room the rematch GameInstance is created in. Pass in 0 for no room.

[int](#) maxUsers

The max number of users the GameInstance supports. Pass in 2 for a two player game.

[long](#) winningUserID

The ID of the User that has won the GameInstance.

[long](#) turnUserID

The ID of the User whose initial turn it is.

[bool](#) includeLeftGameUsers

A boolean dictating whether users that have left the original game should be included in the rematched GameInstance.

[string](#) rematchMessage

The notification message to send to all other users that are a member of the rematched GameInstance. Pass "" to have no notification message sent.

[PropertyCollection](./propertycollection) originalGameProps

The final properties of the original GameInstance.

[PropertyCollection](./propertycollection) origianlGameWinningUserProps

The properties of the winning User of the original GameInstance.

[PropertyCollection](./propertycollection) rematchGameProps

The properties of the rematch GameInstance. Pass in null to assign no properties to the rematched GameInstance.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

Delete()

Deletes a GameInstance. Upon success, this will automatically update the internal list.

Returns void
Syntax
GameInstanceManager.Delete( gameInstanceID, callbackFunc )
Parameters

long gameInstanceID

The ID of the GameInstance to delete.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

GetAll()

Gets all GameInstances. Upon success, this will automatically update the internal list.

Returns void
Syntax
GameInstanceManager.GetAll( userID, stateMask, maxCount, getGameInstanceProperties, friendsOnly, gameInstanceType, gameInstanceSubtype, callbackFunc )
Parameters

long userID

The ID of the User who must be a member of a GameInstance retrieved. Pass 0 to fetch all games regardless of membership within them.

[int](#) stateMask

A table containing the GameInstance States to retrieve. The following stateMask table members are examined:

waitingForPlayers Waiting for players to join the game.
inProgress Players are currently playing the game.
finished Game has been finished and a leaderboard was generated.
possibleRematch A rematched Game waiting for enough players to join.
forfeit Game was forfeited by a User.
Examples:
// To get all GameInstances that are playable.
local stateMasks = { waitingForPlayers=true, inProgress=true };
// To get all GameInstances regardless of State.
local stateMasks = { waitingForPlayers=true, inProgress=true, finished=true, possibleRematch=true, forfeit=true };
[int](#) maxCount

The maximum number of GameInstance to retrieve.

[bool](#) getGameInstanceProperties

Set TRUE to retrieve the property collections of each game instance, FALSE to retrieve the instances without properties.

[bool](#) friendsOnly

Set TRUE to retrieve only gamesin which you and your friends are joined in

[string](#) gameInstanceType

Set to retrieve only games with this type, pass null to ignore.

[string](#) gameInstanceSubtype

Set to retrieve only games with this subtype, pass null to ignore.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

GetAllInDuel()

Gets all the GameInstances in a duel. Upon success, this will automatically update the internal list.

Returns void
Syntax
GameInstanceManager.GetAllInDuel( gameInstanceDuelID, callbackFunc )
Parameters

long gameInstanceDuelID

The ID of the duel to retrieve all GameInstances for.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

Join()

Joins an existing GameInstance. Upon success, this will automatically update the internal list.

Returns void
Syntax
GameInstanceManager.Join( gameInstanceID, gameInstanceUserProperties, callbackFunc )
Parameters

long gameInstanceID

The ID of the specific GameInstance to join.

[PropertyCollection](./propertycollection) gameInstanceUserProperties

The properties to assign the User joining the GameInstance.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------

JoinRandom()

Joins a random existing GameInstance. Upon success, this will automatically update the internal list.

Returns void
Syntax
GameInstanceManager.JoinRandom( gameInstanceType, gameInstanceUserProperties, callbackFunc )
Parameters

string gameInstanceType

The type of GameInstance to join.

[PropertyCollection](./propertycollection) gameInstanceUserProperties

The properties to assign the User joining the GameInstance.

[OnCompleteHandler](./oncompletehandler) callbackFunc

The function to call upon completion.

--------------------------------------------------------------------------------
⚠️ **GitHub.com Fallback** ⚠️