Skip to content

Class ScriptSession

Namespace: Apogee.Host
Assembly: Apogee.Host.dll

A script running in a world: the entry script has been executed and its callbacks are registered; the loops step it frame by frame.

public sealed class ScriptSession : IDisposable

Inheritance

object ← ScriptSession

Implements

IDisposable

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Properties

Assets

Asset paths and UIDs, the scripts' assets global.

public AssetLibrary Assets { get; }

Property Value

AssetLibrary

Audio

The game's sound, the scripts' audio global; inactive when OpenAL Soft is not installed.

public AudioSystem Audio { get; }

Property Value

AudioSystem

DebugDraw

The debug lines and shapes of this frame: scripts add to it (debug_draw), and so does the physics world when its is on. The loops draw it with the world and clears it.

public DebugDraw DebugDraw { get; }

Property Value

DebugDraw

Files

The game's files (res://, mod://, the engine's shaders as shaders://), or null for a single script.

public VirtualFileSystem? Files { get; }

Property Value

VirtualFileSystem?

Importers

Everything a session can import: models, images and shaders.

public static IReadOnlyList<IAssetImporter> Importers { get; }

Property Value

IReadOnlyList<IAssetImporter>

Input

The router behind the scripts' input global: feeds it, the scripts define the actions on its map.

public InputActionRouter Input { get; }

Property Value

InputActionRouter

Models

The models entities draw, the scripts' models global. The loops attach a renderer to it when there is a GPU.

public ModelLibrary Models { get; }

Property Value

ModelLibrary

Net

The game's network, the scripts' net global; inactive when GameNetworkingSockets is not installed.

public NetSystem Net { get; }

Property Value

NetSystem

Physics

The physics of , the scripts' physics global.

public PhysicsWorld Physics { get; }

Property Value

PhysicsWorld

Reloader

Reloads what changed on disk (a game started with watching), or null.

public HotReloader? Reloader { get; }

Property Value

HotReloader?

Settings

The player's settings, the scripts' settings global: user://settings.xml of a game, in memory for a single script. The engine's keys (window, graphics, audio) are defined, and the volumes and the input bindings follow them. It is saved a second after a change, and when the session ends.

public SettingsStore Settings { get; }

Property Value

SettingsStore

Steam

The game's Steam connection, the scripts' steam global; inactive when Steam is not running or this run does not use it.

public SteamSystem Steam { get; }

Property Value

SteamSystem

Tasks

The tasks scripts started with task, for tests and tools to look at.

public ScriptScheduler Tasks { get; }

Property Value

ScriptScheduler

Ui

The game's user interface, the scripts' ui global. The loops size it to the screen, feed it input, step it with the world and draw it over the picture.

public UiSystem Ui { get; }

Property Value

UiSystem

World

public World World { get; }

Property Value

World

Methods

CreateShaderLibrary(string)

The shaders for this session's renderers. A game's come from its own file system, so that its mods' compiled shaders are found, and when it is watched a change to a shader file rebuilds the pipelines made from it; a single script gets the engine's shaders next to the program.

public ShaderLibrary CreateShaderLibrary(string cacheDirectory)

Parameters

cacheDirectory string

Returns

ShaderLibrary

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

EndFrame()

Runs what scripts deferred until the end of the frame.

public void EndFrame()

Progress(float)

Runs the world's systems for deltaSeconds of real time (the game's time scale applies to the systems, the physics and the tasks).

public void Progress(float deltaSeconds)

Parameters

deltaSeconds float

RegisterLibraries()

Makes sure the libraries scripts see are registered: they register from their assemblies' module initializers, at startup under NativeAOT and on first use otherwise.

public static void RegisterLibraries()

Reload()

Applies the changes to files since the last frame, if the game is being watched.

public void Reload()

Start(string, bool)

Runs the script at path (a full path with forward slashes) in a new world, which it sees as the world global.

public static ScriptSession Start(string path, bool realAudio = false)

Parameters

path string

realAudio bool

Returns

ScriptSession

StartGame(string, string?, bool, bool, bool, bool, string?)

Starts a game: folder is res://, userFolder (or the platform's folder for the game's name) is user://. The packages of the game and the player's mods are found and solved, their definitions loaded, and their scripts run in a world, as describes. A mod that fails is logged and left out; a base package that fails is an error of the game ().

public static ScriptSession StartGame(string folder, string? userFolder, bool watch = false, bool realAudio = false, bool realSteam = false, bool runScripts = true, string? scene = null)

Parameters

folder string

userFolder string?

watch bool

realAudio bool

realSteam bool

runScripts bool

False makes everything a game has (the world, the file system, the models, physics, audio, the UI) without running the packages' scripts: what an editor edits before Play.

scene string?

Scene text () loaded into the world before the scripts run: what Play starts from.

Returns

ScriptSession

StartGame(GameStart)

Starts a game as does, and reads its game.xml if it has one: the user folder (unless one is given), the Steam app id and the version that the packages' gameVersion are checked against come from it, and so does the entry scene.

public static ScriptSession StartGame(GameStart start)

Parameters

start GameStart

Returns

ScriptSession

Exceptions

ContentException

The game's game.xml is wrong, or its entry scene is missing.

SteamAppIdFor(GameManifest?, string, out string?)

The game's Steam app id: the one in its game.xml (when it names one); else the number in steam_appid.txt in the game's folder, with a warning that the file is deprecated; else 0.

public static uint SteamAppIdFor(GameManifest? manifest, string folder, out string? warning)

Parameters

manifest GameManifest?

The game's game.xml, or null.

folder string

The game's folder.

warning string?

What to tell the developer, or null.

Returns

uint

UserDirectoryFor(string, string?, GameManifest?)

The folder of the player's files (user://) of the game in folder: userFolder when one is given, else the one manifest names (), else one named after the game folder.

public static string UserDirectoryFor(string folder, string? userFolder, GameManifest? manifest)

Parameters

folder string

userFolder string?

manifest GameManifest?

The game's game.xml; null when it has none.

Returns

string