Skip to content

LaunchContext

public sealed class LaunchContext

Namespace SideHustle

Passed to a gamemode’s launch callback. Carries who is launching (host / client / singleplayer) and, for multiplayer, the lobby id. The gamemode calls ReturnToHub when it is finished so Side Hustle can restore the menu.

Example

One callback for every role, reading a host setting:

static void Start(LaunchContext ctx)
{
int seconds = ctx.Multiplayer?.GetInt("len", 30) ?? 30; // null in singleplayer
if (ctx.Role == SessionRole.Host) { /* start the round */ }
// later, when the gamemode is done:
ctx.ReturnToHub();
}
public GamemodeDescriptor Descriptor { get; internal set; }

Type: GamemodeDescriptor

The descriptor being launched.

public bool? IsHost { get; internal set; }

true = host, false = client, null = singleplayer.

public ulong LobbyId { get; internal set; }

Steam lobby id for multiplayer; 0 for singleplayer.

public bool IsSingleplayer { get; }

True when this is a singleplayer launch.

public SessionRole Role { get; }

Type: SessionRole

Added in 3.0.0

Who the local player is in this session; the same information as IsHost as an enum. Since 3.0.0.

public int PlayerCount { get; internal set; }

Added in 1.1.0

Players currently in the lobby (1 for singleplayer).

public string HostName { get; internal set; }

Added in 1.1.0

The host’s display name: their session alias when they set one on the Host form, else their Steam persona. On a client it is read from the lobby (sh_host_name), which the host writes the same way. Null for singleplayer.

public bool HasPassword { get; internal set; }

Added in 1.1.0

True if the lobby was created with a password.

public Multiplayer.MultiplayerInfo Multiplayer { get; internal set; }

Type: MultiplayerInfo

Added in 1.1.0

The full multiplayer payload (max players, gamemode name, the host’s free-form config blob, …). Null for singleplayer. Use this to pass gamemode-specific settings from host to clients.

public void ReturnToHub()

Call this from your gamemode when it is done (e.g. the player clicks “Back”). Side Hustle restores the main menu and re-shows the hub. Only the first call counts: once the session was ended - by this call or by Side Hustle aborting it - later calls are ignored and logged.