Table of Contents

Class SystemDefinition

Namespace
Typhon.Engine
Assembly
Typhon.Engine.dll

Immutable definition of a system node in the system DAG. Created by DagBuilder and consumed by DagScheduler.

public sealed class SystemDefinition
Inheritance
SystemDefinition
Inherited Members

Constructors

SystemDefinition()

public SystemDefinition()

Properties

Access

Declared read/write access for this system (RFC 07 — Unit 2). Populated from SystemBuilder declaration methods. Storage only at the Unit 2 stage — Unit 3 consumes this for conflict detection and DAG-edge derivation. Public read so tooling (Workbench RFC 07 Unit 6 surfacing) can project declarations into wire records; only the engine sets it.

public SystemAccessDescriptor Access { get; }

Property Value

SystemAccessDescriptor

CallbackAction

Delegate for CallbackSystem and QuerySystem systems. Invoked once per tick on a single worker. Receives TickContext with tick-level information.

public Action<TickContext> CallbackAction { get; init; }

Property Value

Action<TickContext>

CanShed

Whether this system can be shed (dropped entirely) under severe overload.

public bool CanShed { get; set; }

Property Value

bool

CellAmortize

Cell-level amortization denominator (issue #231). When greater than 0, this system processes only 1/N of the tier's clusters per tick, rotating through buckets as tickNumber % N. The callback's AmortizedDeltaTime is set to DeltaTime × CellAmortize so integrations over the full elapsed time happen in one step. Must be paired with a non-All TierFilter; amortizing the full cluster set without tier scoping is rejected at RuntimeSchedule.Build.

public int CellAmortize { get; }

Property Value

int

ChangeFilterTypes

Component types for change-filtered reactive input. Null/empty means no filter (process all). OR logic: entity included if any filtered component was written.

public Type[] ChangeFilterTypes { get; set; }

Property Value

Type[]

ChunksPerWorker

Oversubscription factor for parallel chunk dispatch. The effective worker-cap on chunk count becomes round(WorkerCount × ChunksPerWorker) instead of WorkerCount. Default 1.0f preserves the pre-knob behaviour (one chunk per worker).

Use values above 1.0 (e.g. 1.5, 2.0) on parallel systems where worker efficiency suffers because a single slow chunk holds back the critical path — extra chunks let fast workers steal more work via the existing dynamic _nextChunk loop in DagScheduler. Values must be in the range [1.0, 64.0]; Build(IResource, ILogger) rejects values outside that band. The upper bound also guards against the (int)MathF.Round overflow that would silently collapse the chunk cap to 1 for absurd factors.

The final chunk count is still capped by ceil(entityCount / ParallelQueryMinChunkSize), so small populations won't proliferate trivial chunks. Cost trade-off: every extra chunk pays its own prepare/dispatch overhead — Versioned path also creates an extra Transaction per chunk.

Set by RuntimeSchedule from ChunksPerWorker(float).
public float ChunksPerWorker { get; }

Property Value

float

ConsumesQueueIndices

Indices of event queues this system consumes (reads from).

public int[] ConsumesQueueIndices { get; }

Property Value

int[]

DagId

Flat global id of the Dag this system belongs to. Set by Build(IResource, ILogger). The DAG's Track determines whether the system is engine-internal (track carries EngineTag).

public int DagId { get; }

Property Value

int

ExplicitChunkCount

Explicit chunk count for chunked-parallel CallbackSystems (set via ChunkedParallel(int)). Zero means "derive from entity count" (the QuerySystem path); positive means "this is a chunked callback — dispatch this many chunks regardless of any entity input, and skip entity-prep infrastructure". The runtime fast-path in TyphonRuntime reads this and routes accordingly.

public int ExplicitChunkCount { get; }

Property Value

int

Index

Position in the systems array. Set by Build().

public int Index { get; }

Property Value

int

InputFactory

Factory returning the View that provides this system's entity input. Null for CallbackSystems.

public Func<ViewBase> InputFactory { get; set; }

Property Value

Func<ViewBase>

Instance

Back-pointer to the system instance backing this definition (class-based systems only — null for lambda-style registrations). Used by the scheduler to invoke Typhon.Engine.ChunkedCallbackSystem.OnShouldRun() and Typhon.Engine.ChunkedCallbackSystem.OnPrepare() polymorphically on typed systems.

public ISystem Instance { get; init; }

Property Value

ISystem

IsCheckerboard

When true, this parallel QuerySystem uses two-phase checkerboard dispatch (issue #234). Clusters are split into Red ((cellX + cellY) % 2 == 0) and Black sets, dispatched as two sequential parallel phases within one DAG node. No two adjacent cells are processed simultaneously, enabling conflict-free cross-cell reads/writes (e.g. pheromone diffusion).

public bool IsCheckerboard { get; }

Property Value

bool

IsParallelQuery

True if this QuerySystem uses parallel chunk dispatch across workers. When true, Execute is called once per chunk with a per-chunk Transaction and entity slice. Set by RuntimeSchedule from Parallel().

public bool IsParallelQuery { get; }

Property Value

bool

Name

Unique name identifying this system in the DAG.

public string Name { get; init; }

Property Value

string

Phase

The DAG-local phase this system belongs to (RFC 07 / Q3). Set by Build(IResource, ILogger) from Phase(Phase), or the owning DAG's default phase when no phase was declared.

public Phase Phase { get; }

Property Value

Phase

PhaseIndex

Index into the owning ResolvedPhases for the resolved phase. DAG-local — every system has a valid phase.

public int PhaseIndex { get; }

Property Value

int

PipelineChunkAction

Delegate for Pipeline systems. Called per chunk with (chunkIndex, totalChunks). Multiple workers call this concurrently with distinct chunk indices. No TickContext — Pipeline's entity access goes through Gather/Scatter pipelines.

public Action<int, int> PipelineChunkAction { get; init; }

Property Value

Action<int, int>

PredecessorCount

Number of predecessor systems that must complete before this system can execute.

public int PredecessorCount { get; }

Property Value

int

Priority

Priority for overload management. Defined but not enforced until #201.

public SystemPriority Priority { get; init; }

Property Value

SystemPriority

ProducesQueueIndices

Indices of event queues this system produces (writes to).

public int[] ProducesQueueIndices { get; }

Property Value

int[]

ReactiveSkip

Reactive skip predicate evaluated after ShouldRun passes. Returns true if the system should be skipped because its change-filtered input is empty (no dirty entities and no newly added entities). Set by TyphonRuntime at init — not configured by game code.

public Func<bool> ReactiveSkip { get; set; }

Property Value

Func<bool>

RuntimeChunkCount

Per-dispatch chunk-count override for chunked-callback systems. When non-zero, the runtime dispatches this many chunks for the next invocation instead of the static ExplicitChunkCount from ChunkedParallel(int). Used by the fence work-planner to size FenceExec based on per-tick work volume. Resets are caller-managed; zero means "use ExplicitChunkCount as before".

public int RuntimeChunkCount { get; set; }

Property Value

int

ShouldRun

Optional predicate evaluated before dispatch. If it returns false, the system is skipped and its successors are dispatched immediately. Null means always run. Evaluated before input query to avoid View refresh cost on false predicate.

public Func<bool> ShouldRun { get; init; }

Property Value

Func<bool>

SourceFilePath

Repo-relative or absolute path to the source file declaring this system's entry method. Resolved from the delegate's PDB at DagBuilder registration. Empty/null when no PDB was available — the Workbench falls back to "no Source row" for the chunk.

public string SourceFilePath { get; init; }

Property Value

string

SourceLine

1-based line number of the entry method's first sequence point. 0 when not resolved.

public int SourceLine { get; init; }

Property Value

int

SourceMethod

Containing-method short name (e.g. MoveAllAnts) for display in the Source row.

public string SourceMethod { get; init; }

Property Value

string

Successors

Indices of successor systems in the DAG.

public int[] Successors { get; }

Property Value

int[]

ThrottledTickDivisor

System runs every M ticks under overload. Default: 1 (every tick).

public int ThrottledTickDivisor { get; set; }

Property Value

int

TickDivisor

System runs every N ticks under normal load. Default: 1 (every tick).

public int TickDivisor { get; set; }

Property Value

int

TierFilter

Simulation-tier dispatch filter (issue #231). When set to anything other than All, the parallel cluster partition is computed over the per-tier cluster list instead of Typhon.Engine.Internals.ArchetypeClusterState.ActiveClusterIds, and this system only processes entities whose cluster lives in a cell with a matching tier. The default All preserves the pre-#231 fast path.

public SimTier TierFilter { get; }

Property Value

SimTier

TotalChunks

Number of work chunks for Pipeline systems. Determines parallelism granularity. For CallbackSystem/QuerySystem systems this is always 1. Mutable because Pipeline chunk count may change per tick based on query result set size.

public int TotalChunks { get; set; }

Property Value

int

Type

Execution model: PipelineSystem (multi-worker chunks), QuerySystem (single-worker entities), or CallbackSystem (inline).

public SystemType Type { get; init; }

Property Value

SystemType

WritesVersioned

True if this parallel QuerySystem writes Versioned components (copy-on-write MVCC). When true, per-chunk Transactions are used instead of the optimized PointInTimeAccessor path. Set by RuntimeSchedule from WritesVersioned().

public bool WritesVersioned { get; }

Property Value

bool