Skip to content

PlatformAPI reference

Class HostEnvironment

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

What a host knows about the process it runs in, handed to the composition instead of being read from process-wide state: its kind, its developer variables (environment variables on desktop; the page’s or the launch’s variables elsewhere), where it reports and where its files are. Tests build one with their own variables and writers.

C#
public sealed class HostEnvironment

Inheritance

object ← HostEnvironment

Constructors

HostEnvironment(HostKind)

An environment of kind over this process: its environment variables, the console and its base directory.

C#
public HostEnvironment(HostKind kind)

Parameters

kind HostKind

Properties

BaseDirectory

The folder the host’s program runs from (BaseDirectory by default).

C#
public string BaseDirectory { get; init; }

Property Value

string

ClockSeed

A seed for runs that ask for none, from the clock by default (ResolveSeed).

C#
public Func<int> ClockSeed { get; init; }

Property Value

Func<int>

CrashDirectory

Where the desktop launcher writes the crash report of a run that fails (Core.CrashReport), or null for the game’s save folder (SaveStore.DefaultDirectory).

C#
public string? CrashDirectory { get; init; }

Property Value

string?

Error

Where the host prints errors (the console’s standard error by default, as it was when this was created).

C#
public TextWriter Error { get; init; }

Property Value

TextWriter

Kind

The kind of host.

C#
public HostKind Kind { get; }

Property Value

HostKind

Out

Where the host prints results (the console’s standard output by default, as it was when this was created).

C#
public TextWriter Out { get; init; }

Property Value

TextWriter

Variables

Reads a developer variable by name, or null; the process’s environment variables by default.

C#
public Func<string, string?> Variables { get; init; }

Property Value

Func<string, string?>

Methods

Variable(string)

The developer variable name, or null when it is unset or blank.

C#
public string? Variable(string name)

Parameters

name string

Returns

string?