Interface System

This interface defines the core structure for system classes in the ECS architecture.
Systems contain the game logic that operates on entities and their components.
Dependencies like EntityManager can be injected using dependency injection decorators.
Systems must implement onUpdate() and can optionally implement lifecycle hooks like onCreate(), onDestroy(), onEnabled() and onDisabled().

class PlayerSystem implements System {
@inject(Symbols.EntityManager) private readonly entityManager: EntityManager;

public onUpdate() {
this.entityManager.search(Player).forEach(({component, entity}) => {
// do somethng
});
}
}
interface System {
    onCreate?(): void;
    onDestroy?(): void;
    onDisabled?(): void;
    onEnabled?(): void;
    onUpdate(): void;
}

Implemented by

Methods

  • This method is called the first time the system is enabled

    Returns void

  • This method is called when the system is destroyed

    Returns void

  • This method is called when the system is disabled

    Returns void

  • This method is called when the system is enabled

    Returns void