Scripting API
Scripting API
ComponentLayout
Class in Abyss.Core, from Abyss.Core.
Where every field of a component actually sits.
public sealed class ComponentLayoutRemarks
The answer to a problem that would otherwise stop scripts reading anything Bevy or its plugins declare. Those components are #[repr(Rust)]: the compiler may reorder fields and insert padding as it likes, so a C# struct that looks like the Rust one is relying on an accident that a Bevy upgrade, a Rust upgrade or a different optimization level can change — and the failure would be a silent misread of every entity, not an error.
So the engine reports where the fields are, every offset taken from the compiler rather than written down, and C# reads them there. Nothing is mirrored and nothing is copied: the access is still straight into Bevy's storage.
It is not free. Reading one field is a strided walk — rows are whole components, so consecutive values of a field sit size bytes apart rather than adjacent. For a component the engine declares #[repr(C)], mirroring it in C# and using Chunk.GetSpan is still faster and still correct. This is for the components where that is not an option.
Properties
Component
public string Component { get; }The name the component is bound by.
Id
public ComponentId Id { get; }The component's id, so a query can select it without a mirror type.
Size
public int Size { get; }Size of one value, which is also the stride between rows in a column.
Fields
public IReadOnlyList<ComponentField> Fields { get; }The fields, in the order the engine reported them.
Indexers
this[]
public ComponentField this[string name] { get; }Finds a field by name.
Parameters
name
Exceptions
ArgumentException: No field of that name is described.
Methods
Read
public QueryTerm Read()A term selecting this component for reading.
Write
public QueryTerm Write()A term selecting this component for writing.
Exceptions
InvalidOperationException: It holds an entity, which is read, never written: a parent is changed through commands, which keep the hierarchy whole (FieldKind.Entity).
Has
public bool Has(string name)Whether a field of that name is described.
Parameters
name
