GameObjectSystem: Scene-Level Batch Processing Systems in s&box
A GameObjectSystem in s&box is a scene-level system that performs work at specific points during the frame. Automatically instantiated when a scene is created — no manual setup needed.
Implementation
public class MyGameSystem : GameObjectSystem
{
public MyGameSystem( Scene scene ) : base( scene )
{
Listen( Stage.PhysicsStep, 10, DoSomething, "DoingSomething" );
}
void DoSomething()
{
var allThings = Scene.GetAllComponents<MyThing>();
// process all things in one batch
}
}Why Use GameObjectSystems
Faster than per-component OnUpdate() — process all instances in one batch, avoid out-of-order problems, and guarantee timing (e.g., all bone positions updated before anything reads them).
Access
Access via Scene.Get<MyGameSystem>() or inherit from GameObjectSystem<T> for a static Current property:
public class MyGameSystem : GameObjectSystem<MyGameSystem>
{
public MyGameSystem( Scene scene ) : base( scene ) { }
public void MyMethod() { Log.Info( "Hello" ); }
}
// Usage:
MyGameSystem.Current.MyMethod();Stages and Order
Stages correspond to frame events (e.g., Stage.PhysicsStep runs during FixedUpdate). The order parameter (-1 = before, +1 = after) controls execution sequence within a stage.
Configuration
Properties marked with [Property] are configurable in Project Settings under Systems, and saved per-project.