Scripting API

Scripting API

AbyssSystemAttribute

Class in Abyss.Core, from Abyss.Core.

Marks a static method as a system, so its access can be derived from its signature instead of declared a second time by hand.

public sealed class AbyssSystemAttribute : Attribute

Remarks

Without this, a system's access is written twice — once in the query terms and once in the body that reads and writes the spans — and nothing checks that the two agree. Declaring position.Read() and then writing to the column is exactly the mistake the engine cannot catch, because the declaration is what it trusts. Deriving the terms from the parameters removes the opportunity.

The generator recognizes parameters by ref kind and type:

ParameterMeaning
ref TWrite access to component T, one entity at a time
in TRead access to component T, one entity at a time
Span<T>Write access to component T, a whole chunk at a time
ReadOnlySpan<T>Read access to component T, a whole chunk at a time
in SystemContextDelta time, frame number, and the raw chunks

The per-entity and per-chunk forms cannot be mixed in one signature: the first is a loop body and the second is the loop itself.

For each marked method the generator emits an Add<Name> helper on the containing type, which registers the system with a Schedule using the derived terms. The containing type — and every type enclosing it — must be declared partial.

public static partial class MovementSystems{    [AbyssSystem]    private static void Integrate(ref Position position, in Velocity velocity, in SystemContext context)    {        position.X += velocity.X * context.DeltaTime;    }}
// elsewhere:MovementSystems.AddIntegrate(schedule, position, velocity);

Properties

Name

public string? Name { get; set; }

Display name for the system. Defaults to ContainingType.MethodName.

Parallel

public bool Parallel { get; set; }

Whether the system's chunks are run a slice at a time across the machine's cores, through SystemContext.ForEachChunkParallel, rather than one after another on one thread.

For a system over many entities, each standing alone: what one entity's row says is all it reads, and that row is all it writes. A hundred thousand entities moved that way take a few cores' time instead of one's. With a few hundred, handing slices out costs more than it saves, and the system is better left as it is.

A parallel system may read resources (Res<T>) but not write them, and its body cannot use context.Commands, Gizmos, Assets, Scenes, Services, Events or ResourceMut: each slice would write them at once from another thread. The generator refuses them where it can see them, and the context does where it cannot. Record, draw and write in a system of its own that runs after it.

[AbyssSystem(Parallel = true)][MethodImpl(MethodImplOptions.AggressiveInlining)]private static void Integrate(ref Position position, in Velocity velocity, in SystemContext context){    position.X += velocity.X * context.DeltaTime;}

Fixed

public bool Fixed { get; set; }

Whether the system runs at the game's fixed rate rather than once a frame: its generated Add puts it in the schedule's Schedule.Fixed systems, run once for each step of the game's fixed clock, with the step — a sixtieth of a second unless the project's Time settings say otherwise — as its SystemContext.DeltaTime.

For what must move the same however fast the game draws: forces, velocities, and anything a physics step reads or writes.

[AbyssSystem(Fixed = true)][MethodImpl(MethodImplOptions.AggressiveInlining)]private static void Fall(ref Velocity velocity, in SystemContext context){    velocity.Y -= 9.81f * context.DeltaTime;}