Scripting API

Scripting API

IPlugin

Interface in Abyss.Core, from Abyss.Core.

A part of a game: what it adds to a schedule when the game plays.

public interface IPlugin

Remarks

Bevy's shape, for the C# half of a game. A Rust plugin is a Bevy Plugin whose build adds systems to an app; this is the same for the game's C# systems, which run in a Schedule. A plugin is built once each time the game starts playing — in the game's own Program, and in the editor at every Play — so whatever it keeps between its IPlugin.Build and its systems starts fresh each time. One marked ExecuteAlwaysAttribute runs while the game is edited too, and one marked EditorOnlyAttribute runs only in the editor; the editor builds either as it opens the game, and again at every Play from the game's C# loaded afresh.

The components it uses are registered already: a game registers its own before it opens a scene, and the editor does before anything. Reach them with World.Component on schedule.World, rather than registering them again, which declares a second component nothing carries.

[assembly: AbyssPlugin<OrbitGame>]
internal sealed class OrbitGame : IPlugin{    public void Build(Schedule schedule) =>        Wobbling.Add(schedule, schedule.World.Transform(), schedule.World.Component<Wobble>());}

Code that is no system's has three places of its own, each optional, each run between frames on the engine thread and never in the schedule: IPlugin.BeforeFirstScene, which may await and choose the scene the game opens; IPlugin.Started, once it is open; and IPlugin.Stopping, as the game stops. A plugin that has none costs nothing for them. What it keeps that is no data of the ECS's goes in World.Services, and what goes on over frames in a flow, AddFlow.

Methods

Build

void Build(Schedule schedule)

Adds the plugin's systems to a schedule the game is about to play.

Parameters

  • schedule

BeforeFirstScene

Task BeforeFirstScene(GameStart start)

Runs before the game's first scene is read, every plugin's in turn, the scene waiting until each is over: to read a save, sign in, fetch what the game is set up with, and say which scene it opens (GameStart.FirstScene). It may await; what follows an await comes back to the engine thread. In the editor it runs at Play, the open scene playing.

Parameters

  • start: The game starting: the world, the scene it opens, and what to wait with.

Started

void Started(World world)

Runs once the game has started, its first scene active, before its flows start.

Parameters

  • world: The world, the plugin's own until it returns.

Stopping

void Stopping(World world)

Runs as the game stops — Stop in the editor, quitting, the game's scripts built again — before its async code is stopped: to save, to sign out, to close what it opened.

Parameters

  • world: The world, as the game left it.