System Management
Scene manages system registration, execution order, and lifecycle.
Adding Systems
Section titled “Adding Systems”class SystemScene extends Scene { protected initialize(): void { // Add system const movementSystem = new MovementSystem(); this.addSystem(movementSystem);
// Set system update order (lower runs first) movementSystem.updateOrder = 1;
// Add more systems this.addSystem(new PhysicsSystem()); this.addSystem(new RenderSystem()); }}Getting Systems
Section titled “Getting Systems”// Get system of specific typeconst physicsSystem = this.getEntityProcessor(PhysicsSystem);
if (physicsSystem) { console.log("Found physics system");}Removing Systems
Section titled “Removing Systems”public removeUnnecessarySystems(): void { const physicsSystem = this.getEntityProcessor(PhysicsSystem);
if (physicsSystem) { this.removeSystem(physicsSystem); }}Controlling Systems
Section titled “Controlling Systems”Enable/Disable Systems
Section titled “Enable/Disable Systems”public pausePhysics(): void { const physicsSystem = this.getEntityProcessor(PhysicsSystem); if (physicsSystem) { physicsSystem.enabled = false; // Disable system }}
public resumePhysics(): void { const physicsSystem = this.getEntityProcessor(PhysicsSystem); if (physicsSystem) { physicsSystem.enabled = true; // Enable system }}Get All Systems
Section titled “Get All Systems”public getAllSystems(): EntitySystem[] { return this.systems; // Get all registered systems}System Organization Best Practice
Section titled “System Organization Best Practice”Group systems by function:
class OrganizedScene extends Scene { protected initialize(): void { // Add systems by function and dependencies this.addInputSystems(); this.addLogicSystems(); this.addRenderSystems(); }
private addInputSystems(): void { this.addSystem(new InputSystem()); }
private addLogicSystems(): void { this.addSystem(new MovementSystem()); this.addSystem(new PhysicsSystem()); this.addSystem(new CollisionSystem()); }
private addRenderSystems(): void { this.addSystem(new RenderSystem()); this.addSystem(new UISystem()); }}API Reference
Section titled “API Reference”| Method | Returns | Description |
|---|---|---|
addSystem(system) | void | Add system to scene |
removeSystem(system) | void | Remove system from scene |
getEntityProcessor(Type) | T | undefined | Get system by type |
systems | EntitySystem[] | Get all systems |