Class SystemBuilder<TContext>
Typed fluent builder for systems deriving from ChunkedCallbackSystem<TContext>. Wraps a non-generic SystemBuilder and exposes typed ShouldRun(Func<TContext, bool>) / Prepare(Func<TContext, int>) overloads that receive the ambient TContext. All other methods forward to the inner builder unchanged.
public sealed class SystemBuilder<TContext> where TContext : class
Type Parameters
TContext
- Inheritance
-
SystemBuilder<TContext>
- Inherited Members
Methods
AdditionalReads<T>()
Declares a read of T beyond the system's primary View input (cross-entity read).
public SystemBuilder<TContext> AdditionalReads<T>() where T : unmanaged
Returns
- SystemBuilder<TContext>
Type Parameters
T
After(string)
Declares a dependency on another system (this system runs after it).
public SystemBuilder<TContext> After(string dependency)
Parameters
dependencystring
Returns
- SystemBuilder<TContext>
AfterAll(params string[])
Declares dependencies on multiple systems (this system runs after all of them).
public SystemBuilder<TContext> AfterAll(params string[] dependencies)
Parameters
dependenciesstring[]
Returns
- SystemBuilder<TContext>
Before(string)
Declares that this system must run before another (mirror of After(string)).
public SystemBuilder<TContext> Before(string dependent)
Parameters
dependentstring
Returns
- SystemBuilder<TContext>
CanShed(bool)
Sets whether this system can be shed entirely under severe overload.
public SystemBuilder<TContext> CanShed(bool value)
Parameters
valuebool
Returns
- SystemBuilder<TContext>
CellAmortize(int)
Sets the cell-level amortization denominator — the system processes 1/N of the tier's clusters per tick. Requires a non-All tier.
public SystemBuilder<TContext> CellAmortize(int denominator)
Parameters
denominatorint
Returns
- SystemBuilder<TContext>
ChangeFilter(params Type[])
Sets the component types for change-filtered reactive input. OR logic: entity included if any filtered component was written.
public SystemBuilder<TContext> ChangeFilter(params Type[] componentTypes)
Parameters
componentTypesType[]
Returns
- SystemBuilder<TContext>
Checkerboard()
Enables two-phase checkerboard dispatch — no two adjacent cells are processed simultaneously. Requires Parallel().
public SystemBuilder<TContext> Checkerboard()
Returns
- SystemBuilder<TContext>
ChunkedParallel(int)
Enables chunk-parallel execution for a chunked callback with an explicit chunk count, independent of any entity input.
public SystemBuilder<TContext> ChunkedParallel(int chunkCount)
Parameters
chunkCountint
Returns
- SystemBuilder<TContext>
ChunksPerWorker(float)
Sets the oversubscription factor for parallel chunk dispatch (worker cap becomes round(WorkerCount × factor)). Must be in [1.0, 64.0].
public SystemBuilder<TContext> ChunksPerWorker(float factor)
Parameters
factorfloat
Returns
- SystemBuilder<TContext>
ExclusivePhase()
Marks this system as having exclusive control of its phase — no other system in the same phase may run concurrently.
public SystemBuilder<TContext> ExclusivePhase()
Returns
- SystemBuilder<TContext>
InRealm(RealmId)
Narrows this QuerySystem to realm realm (Realms): it is dispatched that realm's clusters only — read from the realm's own cluster
list, not filtered out of every realm's — and a change filter sees that realm's changes only. A realm not runnable this tick (dormant) gives it
nothing, like any other system. See InRealms(params RealmId[]).
public SystemBuilder<TContext> InRealm(RealmId realm)
Parameters
realmRealmId
Returns
- SystemBuilder<TContext>
InRealms(params RealmId[])
Narrows this QuerySystem to the realms realms: their clusters only, and a change filter sees their changes only. A realm may be
registered after the runtime is built (it is dispatched from the tick it is registered); it must be below the engine's realm count.
public SystemBuilder<TContext> InRealms(params RealmId[] realms)
Parameters
realmsRealmId[]
Returns
- SystemBuilder<TContext>
Exceptions
- ArgumentException
No realm, or None.
Input(Func<ViewBase>)
Sets the View factory providing the system's entity input.
public SystemBuilder<TContext> Input(Func<ViewBase> viewFactory)
Parameters
Returns
- SystemBuilder<TContext>
MinChunkSize(int)
Override ParallelQueryMinChunkSize for this system only — the smallest entity count
it will accept in a parallel chunk. Default 0 inherits the global value.
public SystemBuilder<TContext> MinChunkSize(int entities)
Parameters
entitiesint
Returns
- SystemBuilder<TContext>
Remarks
Set this when the system's cost PER ENTITY is far above the schedule's average, so that a chunk of the
global size is much more work than the dispatch it is sized against. The symptom is a system consuming a large
share of the tick while SystemTelemetry.WorkersTouched shows it running on a handful of workers, and
ChunksPerWorker(float) having no effect — because the entity-count cap, not the worker cap, is binding.
Validated at Build(IResource, ILogger): must be at least 1, and rejected on non-parallel systems where it has no effect.
Name(string)
Sets the system's unique name in the DAG.
public SystemBuilder<TContext> Name(string name)
Parameters
namestring
Returns
- SystemBuilder<TContext>
Parallel()
Enables automatic chunk-parallel execution across workers. QuerySystem only.
public SystemBuilder<TContext> Parallel()
Returns
- SystemBuilder<TContext>
Phase(Phase)
Assigns this system to a phase. The phase must be one declared on the owning DAG.
public SystemBuilder<TContext> Phase(Phase phase)
Parameters
phasePhase
Returns
- SystemBuilder<TContext>
Prepare(Func<TContext, int>)
Set a typed plan builder evaluated before dispatch. Returns the dynamic chunk count (0 = skip, >0 = dispatch, -1 = no opinion).
public SystemBuilder<TContext> Prepare(Func<TContext, int> planBuilder)
Parameters
Returns
- SystemBuilder<TContext>
Priority(SystemPriority)
Sets the system's overload priority.
public SystemBuilder<TContext> Priority(SystemPriority priority)
Parameters
prioritySystemPriority
Returns
- SystemBuilder<TContext>
ReadsEvents(EventQueueBase)
Declares that this system consumes from the given event queue.
public SystemBuilder<TContext> ReadsEvents(EventQueueBase queue)
Parameters
queueEventQueueBase
Returns
- SystemBuilder<TContext>
ReadsFresh<T>()
Declares a read of T ordered after any same-phase writer of it. See ReadsFresh<T>().
public SystemBuilder<TContext> ReadsFresh<T>() where T : unmanaged
Returns
- SystemBuilder<TContext>
Type Parameters
T
ReadsResource(string)
Declares that this system reads a named resource.
public SystemBuilder<TContext> ReadsResource(string name)
Parameters
namestring
Returns
- SystemBuilder<TContext>
ReadsSnapshot<T>()
Declares a read of T ordered before any same-phase writer of it. See ReadsSnapshot<T>().
public SystemBuilder<TContext> ReadsSnapshot<T>() where T : unmanaged
Returns
- SystemBuilder<TContext>
Type Parameters
T
Reads<T>()
Declares that this system reads component T. See Reads<T>().
public SystemBuilder<TContext> Reads<T>() where T : unmanaged
Returns
- SystemBuilder<TContext>
Type Parameters
T
RealmRate(RealmRate)
How this QuerySystem runs over realms simulated at a divisor (Realms D4): Divided (the default) visits each cluster of an N-divided realm once every N runs; Full visits every runnable cluster every run.
public SystemBuilder<TContext> RealmRate(RealmRate rate)
Parameters
rateRealmRate
Returns
- SystemBuilder<TContext>
ShouldRun(Func<TContext, bool>)
Set a typed predicate evaluated before dispatch. Stored on the system instance; read by Typhon.Engine.ChunkedCallbackSystem<TContext>.OnShouldRun().
public SystemBuilder<TContext> ShouldRun(Func<TContext, bool> predicate)
Parameters
Returns
- SystemBuilder<TContext>
SideWrites<T>()
Declares that this system writes T via a side-transaction. Surfaced in tooling but does NOT affect scheduler ordering.
public SystemBuilder<TContext> SideWrites<T>() where T : unmanaged
Returns
- SystemBuilder<TContext>
Type Parameters
T
ThrottledTickDivisor(int)
Sets the throttled tick divisor (system runs every Nth tick under overload).
public SystemBuilder<TContext> ThrottledTickDivisor(int divisor)
Parameters
divisorint
Returns
- SystemBuilder<TContext>
TickDivisor(int)
Sets the tick divisor (system runs every Nth tick at normal load).
public SystemBuilder<TContext> TickDivisor(int divisor)
Parameters
divisorint
Returns
- SystemBuilder<TContext>
TickOffset(int)
Pins which of its divisor's ticks this system runs on, instead of letting the schedule stagger it.
public SystemBuilder<TContext> TickOffset(int offset)
Parameters
offsetintA tick phase below the tightest of this system's rate gates — its
TickDivisorand itsThrottledTickDivisor.
Returns
- SystemBuilder<TContext>
This builder.
Remarks
Normally you do not set this. RuntimeSchedule.Build assigns an offset to every divided system so that the slow work in a schedule does
not all land on the same tick, and declaring a system should not require knowing what else is in the schedule.
The reason to set it is two INDEPENDENT systems that want the same tick because they share a cache-hot working set — the automatic assignment would spread them, having no way to know they are related. Systems the DAG already joins need no help: DSEL-04 gives a whole dependency closure one offset.
Refused at build when it is out of range for the system's gates, when its closure cannot all reach it, or when it disagrees with another explicit offset in the same closure.
Tier(SimTier)
Sets the simulation-tier dispatch filter (this system only processes clusters whose cell matches the tier).
public SystemBuilder<TContext> Tier(SimTier tier)
Parameters
tierSimTier
Returns
- SystemBuilder<TContext>
WritesEvents(EventQueueBase)
Declares that this system publishes to the given event queue.
public SystemBuilder<TContext> WritesEvents(EventQueueBase queue)
Parameters
queueEventQueueBase
Returns
- SystemBuilder<TContext>
WritesResource(string)
Declares that this system mutates a named resource (e.g., a shared physics-world handle that isn't a component).
public SystemBuilder<TContext> WritesResource(string name)
Parameters
namestring
Returns
- SystemBuilder<TContext>
WritesVersioned()
Declares that this parallel QuerySystem writes Versioned components. Forces per-chunk Transaction fallback instead of the PointInTimeAccessor path.
public SystemBuilder<TContext> WritesVersioned()
Returns
- SystemBuilder<TContext>
Writes<T>()
Declares that this system mutates component T. See Writes<T>().
public SystemBuilder<TContext> Writes<T>() where T : unmanaged
Returns
- SystemBuilder<TContext>
Type Parameters
T