Scripting API
Scripting API
ComponentChoice
Record in Abyss.Core, from Abyss.Core.
One enum a component holds, which no layout can describe: where it is, and what it can be.
public record ComponentChoiceRemarks
An enum is read and written whole, by name, never at an offset. Where a Rust enum keeps its discriminant is the compiler's business, and a variant's fields sit wherever that variant puts them, so an offset measured from one value is wrong for the next. The engine reads and writes an enum through reflection instead, and its value crosses as JSON as Bevy's reflection writes it: "Hidden" for a Visibility, or {"Srgba":{"red":1.0,"green":0.5,"blue":0.2,"alpha":1.0}} for a color.
Found through the component's type: the component itself if it is an enum, at the empty path, and every enum inside its structs, at the dotted path a layout would give it — color. Not one that can hold an entity, whose id means nothing once written down.
Constructors
ComponentChoice
public ComponentChoice(string Path, IReadOnlyList<ChoiceVariant> Variants)One enum a component holds, which no layout can describe: where it is, and what it can be.
Parameters
Path: Where it is: a dotted path, or empty for a component that is an enum.Variants: What it can be, in the order the enum declares them.
An enum is read and written whole, by name, never at an offset. Where a Rust enum keeps its discriminant is the compiler's business, and a variant's fields sit wherever that variant puts them, so an offset measured from one value is wrong for the next. The engine reads and writes an enum through reflection instead, and its value crosses as JSON as Bevy's reflection writes it: "Hidden" for a Visibility, or {"Srgba":{"red":1.0,"green":0.5,"blue":0.2,"alpha":1.0}} for a color.
Found through the component's type: the component itself if it is an enum, at the empty path, and every enum inside its structs, at the dotted path a layout would give it — color. Not one that can hold an entity, whose id means nothing once written down.
Properties
Path
public string Path { get; init; }Where it is: a dotted path, or empty for a component that is an enum.
Variants
public IReadOnlyList<ChoiceVariant> Variants { get; init; }What it can be, in the order the enum declares them.
Methods
VariantOf
public static string? VariantOf(string value)The variant a value holds: its only key, or itself for a variant with nothing in it.
Parameters
value: A value, as JSON.
Returns The variant's name, or null for text that is neither.
Bevy's reflection writes a variant with nothing in it as its name, "Hidden", and one holding values as an object with the name as its one key, {"Srgba":{...}}.
