Scripting API

Scripting API

PackAccess

Struct in Abyss.Core, from Abyss.Core.

A game's packs as its own code reaches them: an add-on its build made apart, a pack it was given after it shipped, attached over the others and taken away again. Reached from a flow or a plugin's hooks, GameCode.Packs, between frames.

public readonly struct PackAccess

Remarks

Every pack beside a built game is mounted as it starts, the main one first, and every add-on it lists that is on the computer — in addons beside it, where a store installs what the player has, or in the player's own folder — so a game only attaches what it is given after. Attached, a pack's addresses and identities are found as the others' are, and its catalog read.

An add-on is a group built apart (PackAccess.AddOns): its pack does not ship with the game, and the main pack lists it, with its length and SHA-256, which a file is checked against (PackAccess.Check). Loading what only an add-on not attached holds says which in the log.

A game with a content address downloads its add-ons (AddOnSettings): it reads the list there as it starts (PackAccess.Checked), which may name an add-on made after it shipped or a newer build of one (PackAccess.Updates); PackAccess.Download fetches one into the player's folder, going on from where a download stopped, checks it and attaches it, an older build let go of; and PackAccess.Remove takes one away. What it downloaded that no list names any more is taken away once the list there has been read.

Detached, what was loaded from it stays loaded; what is loaded after is looked for in the packs left, and the folders.

Properties

Attached

public IReadOnlyList<string> Attached { get; }

The packs attached, the first attached first, by their whole paths.

AddOns

public IReadOnlyList<AddOn> AddOns { get; }

The add-ons the game's build made, in the order its groups are listed: packs that do not ship with it, which it attaches once it has them.

Folder

public string Folder { get; }

The folder a pack named by a relative path is looked for in: the main pack's, or the game's beside its assets.

Checked

public Task<bool> Checked { get; }

The list at the content address, read in the background as the game starts, or by the last PackAccess.CheckList: true once the game goes by it, false where it could not be read — offline, another game's — or the game has no content address, and goes by the list it has.

Updates

public IReadOnlyList<AddOn> Updates { get; }

The add-ons attached as another build than the list names: a newer one is there to PackAccess.Download.

Methods

IsAttached

public bool IsAttached(AddOn addOn)

Whether a build of an add-on is attached, as the game started or since.

Parameters

  • addOn

Check

public bool Check(AddOn addOn, string path)

Whether a file is the add-on its build made — as long, and of the same SHA-256 — read whole to say it: what a file downloaded or given is checked by before it is attached.

Parameters

Exceptions

  • IOException: The file cannot be read.

CheckList

public Task<bool> CheckList()

Reads the list at the content address again, as PackAccess.Checked says; what a game's "look for new content" does.

Download

public AddOnDownload Download(AddOn addOn)

Downloads an add-on from the game's content address into the player's folder, or gives its download under way: going on from where an earlier one stopped, checked by its length and SHA-256, and attached in place of an older build of it. One attached as its list names it ends at once, and one in the player's folder as it names it is attached from there.

Parameters

Remove

public bool Remove(AddOn addOn)

Takes an add-on away: detached, and what the game downloaded of it deleted; one a store put beside the game is only detached. Says whether there was anything to take away.

Parameters

  • addOn

SizeToDownload

public long SizeToDownload(IEnumerable<AddOn> addOns)

The bytes still to download of some add-ons, for "Download 34 MB?": none of one on the computer as its list names it, and less what an earlier download left of one.

Parameters

  • addOns

AddOnOf

public AddOn? AddOnOf(string address)

The add-on not attached that holds what an address names, which loading it needs attached; null for none.

Parameters

  • address

Attach

public PackId Attach(string path)

Attaches a pack over those attached, and gives what takes it away again: an add-on, or any pack of the game's.

Parameters

Exceptions

  • AbyssException: It is not a pack this build reads.
  • InvalidOperationException: It is another game's pack, or no build of this game's made it.

Detach

public bool Detach(PackId pack)

Takes away a pack PackAccess.Attach attached, and says whether it was attached still.

Parameters

  • pack