Game Type API

The Game Type system allows the friend system to adapt to different game architectures. The IGameTypeHandler interface defines how invitations and room joining work for each game type.

IGameTypeHandler Interface

Scripts/Abstractions/IGameTypeHandler.cs

Implement this interface to create custom game type handlers.

Methods

MethodDescription
Initialize(userId, backend)Set up handler with user ID and backend
CreateSession(roomName, maxPlayers, customProperties, callback)Create a new game session
JoinSession(roomInfo, callback)Join an existing session
PrepareInvitation(targetUserId, message, customData)Create invitation data

Properties

PropertyTypeDescription
SupportsRoomCreationboolCan this type create rooms?
SupportsDirectJoinboolCan players directly join friends?
SupportsCustomInvitationDataboolCan invitations have extra data?

BaseGameTypeHandler

Scripts/Abstractions/BaseGameTypeHandler.cs

Abstract base class providing common functionality. Extend this for custom handlers.

Built-in Implementations

RoomBasedGameTypeHandler

For room/lobby-based games. Supports room creation, direct joining, and room-code invitations.

OpenWorldGameTypeHandler

For seamless world games. Uses location data in invitations instead of room codes.

GameTypeFactory

Scripts/GameTypes/GameTypeFactory.cs

Factory for creating and registering game type handlers.

// Register a custom handler
GameTypeFactory.RegisterHandler<MyCustomGameType>();

// Use a string-based ID (advanced)
GameTypeFactory.RegisterCustomFactory(createHandlerFunc);