Skip to content

SystemRegistry

Namespace Mc.Scripting · Kind class (sealed)

public sealed class SystemRegistry

Registers ECS systems in the engine’s tick pipeline, scoped to a plugin (released on unload).

Systems and ordering

Systems.Add("regen", Phase.Tick, dt => { /* runs every tick */ });
Systems.After("vanilla:physics", "after_physics", dt => { });
var h = Systems.Replace("vanilla:ai", "my_ai", dt => { }); // disables vanilla:ai
h.Dispose(); // restores it
Member Description
SystemHandle Add(string name, Phase phase, SystemCallback callback) Adds a system that runs once per tick at the end of phase on the tick thread.
SystemHandle After(string anchor, string name, SystemCallback callback) Registers name to run right after the system anchor.
SystemHandle Before(string anchor, string name, SystemCallback callback) Registers name to run right before the system anchor.
Register Registers a system in the engine’s registry.
SystemHandle Replace(string target, string name, SystemCallback callback) Replaces the (native or scripted) system target: it is disabled and name runs in its place.
bool SetEnabled(string name, bool enabled) Enables or disables a registered system by name (native or scripted).
public SystemHandle Add(string name, Phase phase, SystemCallback callback)

Adds a system that runs once per tick at the end of phase on the tick thread.

Parameters

Name Type Description
name string
phase Phase
callback SystemCallback

Returns SystemHandle

public SystemHandle After(string anchor, string name, SystemCallback callback)

Registers name to run right after the system anchor.

Parameters

Name Type Description
anchor string
name string
callback SystemCallback

Returns SystemHandle

public SystemHandle Before(string anchor, string name, SystemCallback callback)

Registers name to run right before the system anchor.

Parameters

Name Type Description
anchor string
name string
callback SystemCallback

Returns SystemHandle

public SystemHandle Register(Phase phase, string name, SystemCallback callback, SystemPlacement placement = SystemPlacement.Append, string? anchor = null)

Registers a system in the engine’s registry. The registry name is namespaced by the plugin: "{plugin name}:{name}" (left as is when name already starts with that prefix), so plugins cannot collide; a collision with a native system or with another plugin’s system throws. anchor is the full registry name of an existing (native or scripted) system for After/Before/Replace (the phase is then the anchor’s and phase is ignored). Called from inside a system, the registration takes effect when the tick ends.

Parameters

Name Type Description
phase Phase
name string
callback SystemCallback
placement SystemPlacement = SystemPlacement.Append
anchor string? = null

Returns SystemHandle

public SystemHandle Replace(string target, string name, SystemCallback callback)

Replaces the (native or scripted) system target: it is disabled and name runs in its place. Dispose the handle (or unload the plugin) to restore it.

Parameters

Name Type Description
target string
name string
callback SystemCallback

Returns SystemHandle

public bool SetEnabled(string name, bool enabled)

Enables or disables a registered system by name (native or scripted). A system this plugin disabled is re-enabled when the plugin unloads. Returns false if no such system exists.

Parameters

Name Type Description
name string
enabled bool

Returns bool

Phase · SystemCallback · SystemHandle · SystemPlacement