Scripting API

Scripting API

Chunk

Struct in Abyss.Core, from Abyss.Core.

One contiguous block of entities, exposing each queried component as a span over Bevy's own storage.

public readonly ref struct Chunk

Remarks

Spans obtained here point into native memory. Writing to one writes to the world; no copy is made in either direction.

Properties

Count

public int Count { get; }

Number of entities in this chunk.

Entities

public ReadOnlySpan<ulong> Entities { get; }

The entity ids of this chunk's rows, in the same order as every component column.

Each value is a Bevy Entity in its packed 64-bit form: index in the low 32 bits, generation in the high 32.

Methods

GetSpan<T>

public Span<T> GetSpan<T>(int column) where T : unmanaged

Gets a writable span over one component column.

Type parameters

  • T: The component struct. Must be the same size as the registered component; a mismatch is rejected rather than reinterpreted, because reinterpreting native storage as the wrong type is unrecoverable.

Parameters

  • column: Index of the column, matching the order the query's terms were given.

Exceptions

  • InvalidOperationException: The column was declared read-only, holds a component whose values are not plain data — Bevy's or a plugin's, which Chunk.GetFieldView writes a field at a time — or the chunk's pointers have gone stale.

GetLists<T>

public ListColumn<T> GetLists<T>(int column) where T : unmanaged

Gets the lists of one column, one for each row: a list component's, each to read and write in place. See DynamicList<T>.

Type parameters

  • T: The plain-data struct one item is; must be the size the list says.

Parameters

  • column: Index of the column, matching the order the query's terms were given.

Exceptions

  • InvalidOperationException: The column was declared read-only, holds no lists, or the chunk's pointers have gone stale.

GetReadOnlyLists<T>

public ReadOnlyListColumn<T> GetReadOnlyLists<T>(int column) where T : unmanaged

Gets the lists of one column, one for each row, to read.

Type parameters

  • T: The plain-data struct one item is; must be the size the list says.

Parameters

  • column: Index of the column, matching the order the query's terms were given.

Exceptions

  • InvalidOperationException: The column holds no lists, or the chunk's pointers have gone stale.

GetChildren

public ChildrenColumn GetChildren(int column)

Gets the children of each row of one column, Bevy's Children, to read.

Parameters

  • column: Index of the column, matching the order the query's terms were given.

Exceptions

  • InvalidOperationException: The column holds no Children, its term not World.Children's, or the chunk's pointers have gone stale.

GetNames

public NameColumn GetNames(int column)

Gets the name of each row of one column, Bevy's Name, to read.

Parameters

  • column: Index of the column, matching the order the query's terms were given.

Exceptions

  • InvalidOperationException: The column holds no Name, its term not World.Name's, or the chunk's pointers have gone stale.

GetReadOnlySpan<T>

public ReadOnlySpan<T> GetReadOnlySpan<T>(int column) where T : unmanaged

Gets a read-only span over one component column.

Type parameters

  • T: The component struct; must match the registered element size.

Parameters

  • column: Index of the column, matching the order the query's terms were given.

GetFieldView<T>

public FieldView<T> GetFieldView<T>(int column, ComponentField field) where T : unmanaged

Gets a view over one field of a column, at the offset the engine reported.

Type parameters

Parameters

  • column: Index of the column the field belongs to.
  • field: The field, from the component's layout.

For components whose layout C# cannot safely mirror — anything Bevy or a plugin declares, which is #[repr(Rust)] and may be reordered by the compiler. The offset comes from ComponentLayout, which got it from the compiler rather than from a guess.

Prefer Chunk.GetSpan where the layout is known: this walks with a stride of one whole component rather than reading contiguous memory, which is slower and is the price of not owning the layout.