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
| Method | Description |
|---|---|
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
| Property | Type | Description |
|---|---|---|
SupportsRoomCreation | bool | Can this type create rooms? |
SupportsDirectJoin | bool | Can players directly join friends? |
SupportsCustomInvitationData | bool | Can 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);