Scripting API

Scripting API

SceneField

Record in Abyss.Core.Scenes, from Abyss.Core.

One field of one component, with as many values as the field holds.

public record SceneField

Constructors

SceneField

public SceneField(string Name, FieldValue[] Values, string? Choice = null)

One field of one component, with as many values as the field holds.

Parameters

  • Name: The field's name as the engine describes it, which for a flattened vector is dotted — translation.x.
  • Values: One value for a scalar, N for an array: a whole number exactly, every bit of a 64-bit one, and a fraction as a double; see FieldValue. Empty for an enum.
  • Choice: For an enum the component holds, its value as JSON as Bevy's reflection writes it — "Hidden", or {"Srgba":{"red":1.0,...}} — with SceneField.Name its path, which is empty for a component that is an enum itself. Null for a number. A scene may leave fields of its variant out, as it leaves out a field a load gives as it is: {"Perspective":{"fov":0.5}}; see World.SetChoice. See ComponentChoice.

Properties

Name

public string Name { get; init; }

The field's name as the engine describes it, which for a flattened vector is dotted — translation.x.

Values

public FieldValue[] Values { get; init; }

One value for a scalar, N for an array: a whole number exactly, every bit of a 64-bit one, and a fraction as a double; see FieldValue. Empty for an enum.

Choice

public string? Choice { get; init; }

For an enum the component holds, its value as JSON as Bevy's reflection writes it — "Hidden", or {"Srgba":{"red":1.0,...}} — with SceneField.Name its path, which is empty for a component that is an enum itself. Null for a number. A scene may leave fields of its variant out, as it leaves out a field a load gives as it is: {"Perspective":{"fov":0.5}}; see World.SetChoice. See ComponentChoice.

Reference

public SceneReference? Reference { get; init; }

For a field that names an asset — a PrefabRef, an Audio Source's clip — the file it names, which a scene writes in place of the two numbers the field holds; null for any other field.

SceneField.Values are the identity's halves all the same, so what builds, compares and merges fields by their numbers does so unchanged; this is what the file says, and what finds the file by its path when its identity is not known (SceneDocument.ResolveReferences).

Text

public string? Text { get; init; }

For a field that is a text — a FixedText64 or a SharedText — the text it holds, written as its string, "Sword", rather than as its bytes or its handle; null for any other field. A fixed text's values are its bytes: all of its room where it was read from an entity, and the text's own where read from a file, the rest of the room zero as it is built.

A file read gives no field a text: a string there is kept as an enum's value is, as SceneField.Choice, and a load makes it the text of a field that is a text in its world.

Entity

public bool Entity { get; init; }

For a field that names an entity — an EntityRef — true: written as {"entity": 4128}, the id the document gives the entity it names, which is its one value, and {"entity": null} for none; false for any other field.

The id rather than the entity's number, which names it only in the world it was read from: a load gives the field the entity of that id, looked for in the prefab instance the field's own entity is in first, then in each around it, then in the whole scene, so each instance of a prefab names its own parts; see Capture.

Localized

public SceneLocalized? Localized { get; init; }

For a field that names a string of the game's — a LocalizedString — the string, written as {"string": "Menu.Play", "table": "…", "entry": 3}, and {"string": null} for none; null for any other field.

SceneField.Values are its three numbers all the same, its table's identity's halves and its entry's, so what builds, compares and merges fields by their numbers does so unchanged; the name is for whoever reads the file, and a load goes by the identities.

Methods

Prefab

public static SceneField Prefab(string name, AssetGuid id, string? path)

A field naming the prefab or model of id, at path as far as is known.

Parameters

  • name: The field's name.
  • id: The file's identity, which the field holds.
  • path: Where the file is, or null where nothing says.

Referring

public static SceneField Referring(string name, FieldAsset kind, AssetGuid id, string? path)

A field naming the file of id, an asset of kind, at path as far as is known: its identity's two halves, as a PrefabRef holds them, whatever it names.

Parameters

  • name: The field's name.
  • kind: What kind of asset it names.
  • id: The file's identity, which the field holds.
  • path: Where the file is, or null where nothing says.

Localizing

public static SceneField Localizing(string name, AssetGuid table, uint entry, string? said)

A field naming the entry entry of the string table table, called said as far as is known; none for AssetGuid.None.

Parameters

  • name
  • table
  • entry
  • said

Naming

public static SceneField Naming(string name, ulong id)

A field naming the entity the document calls id, or none for 0.

Parameters

  • name
  • id

Texted

public static SceneField Texted(string name, string text)

A field that is a text holding text, its values the text's bytes.

Parameters

  • name
  • text

Texted

public static SceneField Texted(string name, FieldValue[] room)

A field that is fixed text, as an entity holds it: room, every byte of it, the text up to the first zero.

Parameters

  • name
  • room