gale.ecs.system module

This file contains the implementation of the class System, the base for any piece of per-frame logic that operates on a gale.ecs.World’s entities, and SystemScheduler, a small orchestrator that runs an ordered list of systems every frame.

Author: Alejandro Mujica (aledrums@gmail.com)

class gale.ecs.system.System[source]

Bases: object

Base class for any system: a piece of logic that queries a World for entities with a given combination of components and does something with them every frame, such as integrating physics, decaying fatigue, or checking collisions. Subclasses should override update.

update(world, dt)[source]

Run this system’s logic once over world.

Parameters:
  • world (World) – The world to query and mutate.

  • dt (float) – Time elapsed, in seconds, since the last call.

Return type:

None

class gale.ecs.system.SystemScheduler(systems)[source]

Bases: object

Runs an ordered list of systems against a World every frame, mirroring how gale.state.StateMachine is a separate small orchestrator instead of baking dispatch into BaseState: SystemScheduler only knows how to run systems in order, it does not own or know anything about the World’s storage.

Usage example:

scheduler = SystemScheduler([MovementSystem(), FatigueSystem()])

# Every frame: scheduler.update(world, dt)

Parameters:

systems (List[System])

add_system(system)[source]

Append a system to run after every system already scheduled.

Parameters:

system (System) – The system to add.

Return type:

None

update(world, dt)[source]

Run every scheduled system, in order, against world.

Parameters:
  • world (World) – The world to pass to each system’s update.

  • dt (float) – Time elapsed, in seconds, since the last call.

Return type:

None