Scripting API

Scripting API

ResourceBorrow<T>

Struct in Abyss.Core, from Abyss.Core.

An exclusive borrow of a resource, held for as long as the borrow is alive.

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

Remarks

The resource counterpart of ChunkCollection: a ref struct whose ResourceBorrow<T>.Dispose gives the borrow back, so using is the documented pattern. The compiler forbids storing it in a field or capturing it in a closure, which is what stops the reference inside outliving the scope that holds the borrow.

Always exclusive. The ad-hoc path hands out a writable ref, so there is no shared form to offer — a system declaring Res<T> is how you get a shared borrow, and the schedule scopes it for you.

Type parameters

  • T: The resource's struct type.

Properties

Value

public ref T Value { get; }

The resource's value. Writing to it writes to the world.

Methods

Dispose

public void Dispose()

Gives the borrow back.