Scripting API
Scripting API
PackWriter
Class in Abyss.Core, from Abyss.Core.
Writes a pack an entry at a time; nothing is a pack until PackWriter.Finish.
public sealed class PackWriter : IDisposableRemarks
What goes in is the engine's own forms: an image's KTX2 import (AddImage), a model's .abymesh, a material's .abymat (World.PackMaterial), a shader's layout (World.PackedShaderLayout) and its compiled variants (AddVariant), a scene's column image. Each entry is an asset's identity and a part.
Methods
Create
public static PackWriter Create(string path, AssetGuid id)Starts a pack at path, which it replaces, with id as its identity.
Parameters
pathid
Exceptions
AbyssException: The file cannot be made.
Add
public void Add(AssetGuid id, uint part, PackEntryKind kind, string name, ReadOnlySpan<byte> bytes, IReadOnlyList<AssetGuid>? needs = null)Adds an entry: bytes under id and part, at the path name.
Parameters
id: The asset's identity.part: Which of its entries: 0 for its only one.kind: What it holds.name: Its path, as a game asks for it.bytes: What it holds.needs: The identities of what loading it loads first.
Exceptions
AbyssException: An identity and part added already, or the bytes cannot be written.
AddImage
public void AddImage(AssetGuid id, uint part, string name, ImportSettings settings, ReadOnlySpan<byte> ktx2)Adds an image: its KTX2 import, with the settings it was imported with, which say how it is read and sampled.
Parameters
idpartnamesettingsktx2
Exceptions
AbyssException: An identity and part added already, or the bytes cannot be written.
AddAudio
public void AddAudio(AssetGuid id, string name, AudioSettings settings, ReadOnlySpan<byte> sound)Adds a sound clip: its file's own bytes, with the settings it is played with, never compressed, so a clip streamed is read from where it is in the pack.
Parameters
idnamesettingssound
Exceptions
AbyssException: An identity added already, settings the engine does not have, or the bytes cannot be written.
AddVariant
public void AddVariant(AssetGuid id, uint part, string name, string switches, ReadOnlySpan<byte> spirv)Adds a compiled variant of a game's shader, as a part after the shader's layout: its switches and its SPIR-V.
Parameters
idpartnameswitchesspirv
Exceptions
AbyssException: An identity and part added already, or the bytes cannot be written.
Finish
public PackWritten Finish()Writes the table, the dependencies, the names and the header: the pack is whole.
Exceptions
AbyssException: It cannot be written, or it is whole already.
Dispose
public void Dispose()Lets go of the writer; a pack not made whole is left as far as it got.
