Skip to main content

GameMode

An abstract class in Root.Township, the global namespace.

Base for how the game runs (for example as a server or a client): starting up, loading the game scene and stopping.

Constructors​

MemberWhat it is
protected GameMode()Creates a GameMode with default values.

Fields​

MemberWhat it is
protected static Logger loggerShared logger.

Properties​

MemberWhat it is
abstract bool IsClient { get; }Whether this mode runs a client.
abstract bool IsServer { get; }Whether this mode runs a server.

Methods​

MemberWhat it is
abstract Task<bool> ActivateAsync()Subclass: starts the mode. True on success.
virtual void OnStartFailed()Called after a failed start. Empty by default.
virtual void OnStartSucceeded()Called after a successful start. Empty by default.
virtual Task StopModeAsync(string reason)Stops the mode. The base clears every timeline entry.
protected virtual async Task LoadAndSwapToGameSceneAsync(int sceneIndex)Fades the local player to black, waits half a second and loads the game scene by index.

Used in​

Members of other types that take, return or hold a GameMode: