SystemRegistry
Namespace Mc.Scripting · Kind class (sealed)
public sealed class SystemRegistryRegisters ECS systems in the engine’s tick pipeline, scoped to a plugin (released on unload).
Examples
Section titled “Examples”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:aih.Dispose(); // restores itMethods
Section titled “Methods”| 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
Before
Section titled “Before”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
Register
Section titled “Register”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
Replace
Section titled “Replace”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
SetEnabled
Section titled “SetEnabled”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