Skip to content

PlatformAPI reference

Class ProfileSelection

Namespace: MicroEngine.Hosting
Assembly: MicroEngine.Hosting.dll
Guide: Composing a game for every platform

How every host chooses a platform from its catalog (an ordered list of profiles, the most preferred first). The rules are the launcher’s, written once: a named platform (Platform, else the developer variable MICROENGINE_PLATFORM) is the only candidate; Headless names the headless platform; otherwise the game’s preferred backend comes first, then every other platform that can run here except the headless one (a player who sees no window would not know why), or the catalog’s default when that leaves none.

C#
public static class ProfileSelection

Inheritance

object ← ProfileSelection

Fields

PlatformVariable

The developer variable that names the platform when the launch names none.

C#
public const string PlatformVariable = "MICROENGINE_PLATFORM"

Field Value

string

Methods

Choose<TProfile>(IReadOnlyList<TProfile>, LaunchRequest, HostEnvironment, string?, TProfile?)

The profiles a launch tries, in order (see the class remarks). headless stands in for –headless when the catalog has no headless profile; backend is the game’s preferred one.

C#
public static ProfileChoice<TProfile> Choose<TProfile>(IReadOnlyList<TProfile> catalog, LaunchRequest request, HostEnvironment environment, string? backend, TProfile? headless = null) where TProfile : class, IHostProfile

Parameters

catalog IReadOnlyList<TProfile>

request LaunchRequest

environment HostEnvironment

backend string?

headless TProfile?

Returns

ProfileChoice<TProfile>

Type Parameters

TProfile

Default<TProfile>(IReadOnlyList<TProfile>)

The first profile that can run here, or why there is none.

C#
public static (TProfile? Profile, string? Error) Default<TProfile>(IReadOnlyList<TProfile> catalog) where TProfile : class, IHostProfile

Parameters

catalog IReadOnlyList<TProfile>

Returns

(TProfile? Profile, string? Error)

Type Parameters

TProfile

Fallbacks<TProfile>(IReadOnlyList<TProfile>)

The profiles tried when nobody named one: every profile that can run here except the headless one, or the catalog’s default when that leaves none.

C#
public static (IReadOnlyList<TProfile> Profiles, string? Error) Fallbacks<TProfile>(IReadOnlyList<TProfile> catalog) where TProfile : class, IHostProfile

Parameters

catalog IReadOnlyList<TProfile>

Returns

(IReadOnlyList<TProfile> Profiles, string? Error)

Type Parameters

TProfile

Find<TProfile>(IReadOnlyList<TProfile>, string)

The profile named name (ignoring case), or null.

C#
public static TProfile? Find<TProfile>(IReadOnlyList<TProfile> catalog, string name) where TProfile : class, IHostProfile

Parameters

catalog IReadOnlyList<TProfile>

name string

Returns

TProfile?

Type Parameters

TProfile

Preferred<TProfile>(IReadOnlyList<TProfile>, string?)

The profiles tried when the game prefers backend and nobody named one: that profile first, then the Fallbacks``1. A preference the catalog lacks or that cannot run here becomes a note and is skipped.

C#
public static ProfileChoice<TProfile> Preferred<TProfile>(IReadOnlyList<TProfile> catalog, string? backend) where TProfile : class, IHostProfile

Parameters

catalog IReadOnlyList<TProfile>

backend string?

Returns

ProfileChoice<TProfile>

Type Parameters

TProfile

Resolve<TProfile>(IReadOnlyList<TProfile>, string?)

The named profile, or Default``1 for null or empty; otherwise why it cannot be used.

C#
public static (TProfile? Profile, string? Error) Resolve<TProfile>(IReadOnlyList<TProfile> catalog, string? name) where TProfile : class, IHostProfile

Parameters

catalog IReadOnlyList<TProfile>

name string?

Returns

(TProfile? Profile, string? Error)

Type Parameters

TProfile