Scripting API

Scripting API

SpriteSheet

Record in Abyss.Core, from Abyss.Core.

An image's Sprite Mode and its slices, as its sidecar keeps them: what the Sprite Editor cuts it into, what the editor tells the world (World.UseSpriteSheet), and what a build packs beside the image.

public record SpriteSheet

Remarks

Kept in the image's import block — "spriteMode": "multiple", the source's size as it was cut, "spriteSize": [w, h], and "slices", each its identity, name, rectangle, pivot and border — and only where it says something, so an image nobody cut has the sidecar it always had.

Constructors

SpriteSheet

public SpriteSheet(SpriteMode Mode, int Width, int Height, IReadOnlyList<SpriteSlice> Slices)

An image's Sprite Mode and its slices, as its sidecar keeps them: what the Sprite Editor cuts it into, what the editor tells the world (World.UseSpriteSheet), and what a build packs beside the image.

Parameters

  • Mode: Whole, or cut.
  • Width: How wide the source was as it was cut.
  • Height: How tall.
  • Slices: The slices, in the order sprites find them in.

Kept in the image's import block — "spriteMode": "multiple", the source's size as it was cut, "spriteSize": [w, h], and "slices", each its identity, name, rectangle, pivot and border — and only where it says something, so an image nobody cut has the sidecar it always had.

Properties

Mode

public SpriteMode Mode { get; init; }

Whole, or cut.

Width

public int Width { get; init; }

How wide the source was as it was cut.

Height

public int Height { get; init; }

How tall.

Slices

public IReadOnlyList<SpriteSlice> Slices { get; init; }

The slices, in the order sprites find them in.

None

public static SpriteSheet None { get; }

Whole, and no slices: what an image nobody cut has.

PixelsPerUnit

public float PixelsPerUnit { get; init; }

How many of the source image's pixels make one world unit as a sprite draws it — its Pixels Per Unit: at 100, a 64-pixel sprite is 0.64 units across, and a unit is a meter to Physics 2D.

SaysNothing

public bool SaysNothing { get; }

Whether it says nothing an image nobody cut does not.

Cut

public bool Cut { get; }

Whether it is cut into slices a sprite can draw: Multiple, with at least one.

Methods

Slice

public SpriteSlice? Slice(ulong id)

The slice of identity id, or null.

Parameters

  • id

Equals

public bool Equals(SpriteSheet? other)

Parameters

  • other

GetHashCode

public override int GetHashCode()

EngineJson

public string EngineJson(int width, int height)

What the world is told of an image of the Sprite type, for a source now width by height — or of a size not known, at zero, which the engine takes as the size it loads — as the engine reads it (abyss_core::sprite::sheet::Sheet::parse): its Pixels Per Unit, and where it is cut the slices that still fit in it.

Parameters

  • width
  • height

UseAll

public static IReadOnlyList<string> UseAll(World world, AssetDatabase database)

Tells world the Pixels Per Unit of every image of the Sprite type, and the slices of each its project's sidecars say is cut, at the size it was cut from: what a game played from its folders does, reading its images from their sources. What could not be used is said, one line each, its sprites drawing the image whole.

Parameters

  • world: The game's world.
  • database: The game's files and what each sidecar says.

Trace

public static IReadOnlyList<IReadOnlyList<Vector2>> Trace(SourcePicture picture, SpriteSlice slice, float smoothing)

The loops round what shows of slice of picture — its pixels whose alpha is above a tenth — as a tile of it Traced is met, straightened by smoothing pixels: each loop's corners in the slice's pixels from its top left corner down, anticlockwise round what shows as the picture is seen and clockwise round a hole. Takes no world.

Parameters

  • picture
  • slice
  • smoothing

Exceptions

  • AbyssException: The slice reaches past the picture's source, or the smoothing is not a number at or above zero.
  • AbyssException: In a game's executable, which is built without what only the editor does (AbyssStatus.NotInBuiltGame).

Islands

public static (IReadOnlyList<(int X, int Y, int Width, int Height)> Islands, int Width, int Height) Islands(string source, int least)

The rectangles round each island of the image file source that is not clear, none narrower and shorter than least pixels, in rows from the top, each from the left — what Automatic cuts an image into — and the image's size. Takes no world.

Parameters

  • source
  • least

Exceptions

  • AbyssException: The file cannot be read or decoded.
  • AbyssException: In a game's executable, which is built without what only the editor does (AbyssStatus.NotInBuiltGame).

Constants

DefaultPixelsPerUnit

public const float DefaultPixelsPerUnit = 100

How many of an image's pixels make a world unit where its sidecar says nothing.