Scripting API

Scripting API

Services

Class in Abyss.Core, from Abyss.Core.

The objects a game keeps that are no data of the ECS's — a web client, a save system, a store's SDK — one of each type, found by the type: World.Services.

public sealed class Services

Remarks

Beside the ECS, not in it. A component or a resource is plain data the engine keeps in its own memory; an HttpClient is an object .NET keeps, with a lifetime and threads of its own. A plugin adds what it makes as it is built, and any code finds it after — another plugin's, a flow, a system through SystemContext.Services.

A system may run beside others, so what systems use from here has to be safe to use from several threads at once, as an HttpClient is. Adding and finding are.

What a game adds goes when it stops in the editor: Stop takes away what was added since Play, disposing what is disposable, as it puts the world back.

Properties

Count

public int Count { get; }

How many there are.

Methods

Add<T>

public void Add<T>(T service) where T : class

Adds a service, found from now on by T.

Type parameters

  • T

Parameters

  • service

Exceptions

  • InvalidOperationException: There is one of that type already.

Get<T>

public T Get<T>() where T : class

The service of a type.

Type parameters

  • T

Exceptions

  • InvalidOperationException: There is none of that type.

TryGet<T>

public bool TryGet<T>(out T? service) where T : class

The service of a type, if there is one.

Type parameters

  • T

Parameters

  • service

Remove<T>

public bool Remove<T>() where T : class

Takes away the service of a type, if there is one; disposing it is the caller's.

Type parameters

  • T

Returns Whether there was one.

Mark

public long Mark()

Where the list is now, to go back to: what Play keeps for Stop, and what runs a game calls.

RollBack

public void RollBack(long mark)

Takes away what was added since mark, the last first, disposing what is disposable: what Stop does.

Parameters

  • mark