Scripting API
Scripting API
SortingLayers
Class in Abyss.Core, from Abyss.Core.
A game's sorting layers, in the order they are drawn, and what decides between two sprites of one layer and one order: settings/sorting.json beside the game's assets, which Project Settings' Sorting Layers lays out.
public sealed class SortingLayersRemarks
Default first, always there and always called Default. Every sprite on a layer further down the list is drawn over every sprite on one above it, and on one layer, a sprite of a higher Order in Layer over one of a lower. A sprite keeps its layer by an identity this gives it, which stays with the layer as it is renamed and moved; a game's code finds a layer by its name (World.SortingLayerNamed).
A game with no sorting.json has Default alone, sorted on Z. The engine checks a list as this does, so one this reads is one it sorts by (abyss_core::sprite::SortingLayers).
An identity is never given twice: the file keeps the next one to give, so a layer added after one was taken away is not the layer a sprite that was on the old one names. That sprite is drawn on Default, and the log says so.
Constructors
SortingLayers
public SortingLayers()Default alone, sorted on Z: the layers of a game that has said nothing of them.
Properties
Layers
public IReadOnlyList<SortingLayer> Layers { get; }Its layers, in the order they are drawn, Default first.
Axis
public SortAxis Axis { get; set; }What decides between two sprites of one layer and one order.
Methods
FileIn
public static string FileIn(string game)Where a game keeps it: settings/sorting.json in its folder.
Parameters
game
Read
public static SortingLayers Read(string game)A game's sorting layers; Default alone for one with no sorting.json.
Parameters
game
Exceptions
FormatException: The file is not a list this build reads, saying why.IOException: The file is there and cannot be read.
Parse
public static SortingLayers Parse(string json)A list from its text.
Parameters
json
Exceptions
FormatException: It is not a list this build reads, saying why.
ToJson
public string ToJson()The list as its file holds it, which the engine reads as it is.
Write
public void Write(string game)Writes the list into a game's folder.
Parameters
game
Copy
public SortingLayers Copy()A copy, to change without changing this.
Find
public SortingLayer? Find(uint id)The layer of identity id, or null.
Parameters
id
Named
public SortingLayer? Named(string name)The layer called name, or null; names are matched as they are written.
Parameters
name
Add
public SortingLayer Add()Adds a layer after the others, drawn over them: SortingLayers.NewLayerName, or that and the first number after it no layer is called, under an identity no layer of the list has had.
Returns The layer added.
Remove
public bool Remove(uint id)Takes a layer away — never Default; a sprite on it is drawn on Default.
Parameters
id
Returns Whether there was such a layer to take away.
Rename
public string? Rename(uint id, string name)Calls a layer name, trimmed, and the first number after it no other layer is called where one is called that; a name of nothing but spaces leaves it as it was, and so does Default's, which is always Default.
Parameters
idname
Returns What it is called now, or null for a layer there is not.
Move
public bool Move(uint id, int to)Moves a layer to to in the list, drawn over those before it there; never Default, and never above it, which stays first.
Parameters
idto
Returns Whether it moved.
Constants
FileName
public const string FileName = "sorting.json"The file, under the game's settings folder.
PathName
public const string PathName = "settings/sorting.json"What it is called in a game's folder and in its pack: settings/sorting.json.
CurrentVersion
public const int CurrentVersion = 1The version of the file this build writes, and the newest it reads.
Default
public const uint Default = 0Default's identity.
DefaultName
public const string DefaultName = "Default"Default's name.
NewLayerName
public const string NewLayerName = "New Layer"What a layer added is called, a number after it where that is taken.
