Scripting API

Scripting API

DynamicList<T>

Struct in Abyss.Core, from Abyss.Core.

One entity's list, read and written where the engine keeps it: a view, which code holds while it works on the list and cannot keep.

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

Remarks

Valid until the world's next structural change — an entity spawned or despawned, a component added or taken away — as a Chunk is; used after one, it throws rather than reading memory the change may have moved. A span from DynamicList<T>.AsSpan is valid until the list next needs more room, as one from CollectionsMarshal.AsSpan over a List<T> is.

Growing asks the engine for room and touches only this list, so a system running over its chunks on several threads can grow the lists of its own rows on each of them.

Type parameters

  • T: The plain-data struct one item is.

Properties

Count

public int Count { get; }

How many items it holds.

Capacity

public int Capacity { get; }

How many it has room for before it needs more.

Indexers

this[]

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

The item at index, to read or write in place.

Parameters

  • index

Exceptions

  • ArgumentOutOfRangeException: No item is there.

Methods

AsSpan

public Span<T> AsSpan()

The items it holds, as a span: valid until it next needs more room.

Add

public void Add(in T item)

Adds item at the end.

Parameters

  • item

AddRange

public void AddRange(ReadOnlySpan<T> items)

Adds every one of items at the end, in order.

Parameters

  • items

Insert

public void Insert(int index, in T item)

Puts item at index, moving those from there on one along.

Parameters

  • index
  • item

Exceptions

  • ArgumentOutOfRangeException: The index is past the end.

RemoveAt

public void RemoveAt(int index)

Takes out the item at index, moving those after it one back.

Parameters

  • index

Exceptions

  • ArgumentOutOfRangeException: No item is there.

RemoveAtSwapBack

public void RemoveAtSwapBack(int index)

Takes out the item at index and puts the last in its place: what DynamicList<T>.RemoveAt does without moving the rest, for a list whose order does not matter.

Parameters

  • index

Exceptions

  • ArgumentOutOfRangeException: No item is there.

Clear

public void Clear()

Lets go of every item; the room stays, for the next ones.

EnsureCapacity

public void EnsureCapacity(int capacity)

Makes room for at least capacity items without asking again.

Parameters

  • capacity

ToArray

public T[] ToArray()

A copy of the items it holds.

GetEnumerator

public Span<T>.Enumerator GetEnumerator()

Walks the items in order, each to read or write in place.