Scripting API

Scripting API

FieldView<T>

Struct in Abyss.Core, from Abyss.Core.

One field of every row in a chunk, reached at the offset the engine reported.

public readonly ref struct FieldView<T> where T : unmanaged

Remarks

A ref struct for the same reason Chunk is: the pointer inside is valid only until the next resolve or the next structural change, and the compiler is the cheapest place to stop it outliving that.

Access is strided. A column holds whole components back to back, so consecutive values of one field are Stride bytes apart rather than adjacent, and this cannot be handed out as a Span<T> — a span is by definition contiguous. That is the cost of reading a layout the engine described rather than one C# owns, and it is why Chunk.GetSpan stays the right call for components C# declared itself.

An array field ([f32; 3]) is addressed as view[row, element]; a scalar as view[row].

Type parameters

  • T: The field's element type.

Properties

Length

public int Length { get; }

Number of rows, matching the chunk's entity count.

Elements

public int Elements { get; }

Values per row: 1 for a scalar field, N for an array field.

Stride

public int Stride { get; }

Bytes between one row's value and the next. One whole component.

IsWritable

public bool IsWritable { get; }

Whether writes are permitted, following the column's declared access.

Indexers

this[]

public ref T this[int row] { get; }

The field's value in one row, for a scalar field.

Parameters

  • row

this[]

public ref T this[int row, int element] { get; }

One element of the field's value in one row.

Parameters

  • row
  • element

Methods

CopyRowTo

public void CopyRowTo(int row, Span<T> destination)

Copies one row's values into destination.

Parameters

  • row
  • destination

For array fields, where the values within a row are contiguous even though rows are not — so a whole vector comes out in one copy rather than element by element.

CopyRowFrom

public void CopyRowFrom(int row, ReadOnlySpan<T> source)

Copies source into one row's values.

Parameters

  • row
  • source

Exceptions

  • InvalidOperationException: The column was declared read-only.