Scripting API

Scripting API

Player

Class in Abyss.Core, from Abyss.Core.

The engine's start for a game: the window, the game's pack, its components and plugins, and the first scene of its build — what a built game runs, and what dotnet run runs from a game's folders.

public static class Player

Remarks

A game has no Main of its own to write. The engine's source generator writes AbyssGame into a game — its components' registration, and the two ways in: Run, which a game's Program calls in one line, and the abyss_game_main a built game's executable starts it through (see abyss-player). Both come here.

Played from the pack beside it, as a built game always is — Pack.Main beside the executable, or one named with --pack — and from its project's folders otherwise, where they are, as the editor reads them (HomeOf): the assets, the shaders, the build's settings, the packages, and its models from the imports the editor made in the project's cache (Player.CacheOf). Nothing of them is copied beside the game as it builds.

Methods

Run

public static int Run(Assembly game, Action<World> register, IReadOnlyList<string> args)

Plays a game from where it is, and returns what it exits with.

Parameters

  • game: The game's assembly, whose plugins it plays.
  • register: Registers every component the game declares, before anything names one.
  • args: The command line, without the program: --pack and a pack's path, to play from that pack; --no-vsync, to draw as fast as it can, as a game's speed is measured.

Run

public static int Run(Assembly game, IReadOnlyList<Assembly> packages, Action<World> register, IReadOnlyList<string> args)

Plays a game with packages from where it is, and returns what it exits with.

Parameters

  • game: The game's assembly, whose plugins it plays.
  • packages: Its packages' assemblies, whose plugins it plays before the game's, each after the packages it needs.
  • register: Registers every component the game and its packages declare, before anything names one.
  • args: The command line, without the program: --pack and a pack's path, to play from that pack; --no-vsync, to draw as fast as it can, as a game's speed is measured.

CacheOf

public static string CacheOf(Assembly game, string home)

Where a game played from its folders finds its models' imports: the project's cache, which the editor imports into, where the game's build says its project is (Player.ProjectKey, which a built game is not given); or a cache beside its folders.

Parameters

  • game: The game's assembly.
  • home: The folder beside the game.

HomeOf

public static string HomeOf(Assembly game, string beside, IReadOnlyList<string> args)

Where a game plays from: the folder beside it where it has a pack there to play — the one --pack names, or Pack.Main — or, in a Mac app, its Contents/Resources where the pack is there; and otherwise the folder of the project its build names (Player.ProjectKey, which a built game is not given), its files read where they are, as the editor reads them, so a build copies none of them beside it; and the folder beside it where the build names none that is there.

Parameters

  • game: The game's assembly.
  • beside: The folder beside the game.
  • args: The command line, without the program.

WindowFor

public static WindowSetup WindowFor(string title, PlayerSettings player, IReadOnlyList<string> args)

The window a game opens: its title, and its Player's size, mode and whether it is resized; waiting for the display unless the command line says --no-vsync, as a game's speed is measured.

Parameters

  • title
  • player
  • args

RunNative

public static int RunNative(Assembly game, Action<World> register, int argc, nint argv)

Plays a game from a built game's executable, which hands over its command line as C strings, and returns what it exits with; what it throws is said in the log and ends it.

Parameters

  • game: The game's assembly, whose plugins it plays.
  • register: Registers every component the game declares.
  • argc: How many arguments there are, the program's own path first.
  • argv: The arguments: that many pointers to null-terminated UTF-8.

RunNative

public static int RunNative(Assembly game, IReadOnlyList<Assembly> packages, Action<World> register, int argc, nint argv)

Plays a game with packages from a built game's executable; see RunNative.

Parameters

  • game: The game's assembly, whose plugins it plays.
  • packages: Its packages' assemblies, whose plugins it plays before the game's.
  • register: Registers every component the game and its packages declare.
  • argc: How many arguments there are, the program's own path first.
  • argv: The arguments: that many pointers to null-terminated UTF-8.

Plan

public static PlayerStart Plan(string home, IReadOnlyList<string> args)

Where a game plays from, and its build's settings: the pack --pack names, or Pack.Main beside it, with the settings it holds; or, with neither, the folders beside it, with settings/build.json there.

Parameters

  • home: The folder beside the game.
  • args: The command line, without the program.

Exceptions

  • FormatException: The settings are not a build's this engine reads.

InputIn

public static (InputActions Actions, string? Problem) InputIn(string home)

The input actions of the game at home: its settings/input.json, the default ones where it has none, and the default ones and why where it cannot be read.

Parameters

  • home

UiIn

public static (UiSettings Settings, string? Problem) UiIn(string home)

The interface's settings of the game at home: its settings/ui.json, the defaults where it has none, and the defaults and why where it cannot be read.

Parameters

  • home

TimeIn

public static (TimeSettings Settings, string? Problem) TimeIn(string home)

The Time settings of the game at home: its settings/time.json, the defaults where it has none, and the defaults and why where it cannot be read.

Parameters

  • home

LayersIn

public static (LayerSettings Settings, string? Problem) LayersIn(string home)

The layers of the game at home: its settings/layers.json, Default alone where it has none, and Default alone and why where it cannot be read.

Parameters

  • home

Constants

ProjectKey

public const string ProjectKey = "AbyssProject"

What a game's build calls the folder of its project, which a game played from its folders plays from, and finds its cache by.