Scripting API

Scripting API

Query

Class in Abyss.Core, from Abyss.Core.

A prepared query over a fixed set of components.

public sealed class Query : IDisposable

Remarks

Resolving a query is the only boundary crossing a system performs per frame. It yields the set of contiguous blocks matching the query — one per Bevy table — after which all iteration happens in managed code over spans that point straight at native storage.

Create a query once and reuse it. The native side keeps its scratch buffers alive between resolves, so a steady-state frame allocates nothing on either side of the boundary.

Properties

ColumnCount

public int ColumnCount { get; }

Number of components this query touches, and so of columns per chunk.

World

public World World { get; }

The world this query belongs to.

Methods

Resolve

public ChunkCollection Resolve()

Recomputes the set of matching chunks and returns a view over them.

Call this every frame. Holding chunks across a structural change is exactly the mistake the version stamp exists to catch, and caching the returned view would invite it.

Release

public void Release()

Releases the borrows this query holds in the world's ledger.

A no-op unless World.BorrowChecking is on. Disposing the ChunkCollection that Query.Resolve returned calls this for you, which is why the using form is the documented pattern.

MarkChanged

public void MarkChanged()

Marks every write column in the resolved chunks as changed, so Bevy-side change detection sees what C# wrote.

Writing through a span bypasses Bevy's change ticks entirely. Systems whose results other Bevy systems observe through Changed<T> must call this after running. It costs one pass over the change-tick arrays, so call it once per frame, not once per chunk.

Dispose

public void Dispose()

Releases the native query.