Options
All
  • Public
  • Public/Protected
  • All
Menu

Class System<ComponentTypeUnion, ContextType> Abstract

An Excalibur System that updates entities of certain types. Systems are scene specific

Excalibur Systems currently require at least 1 Component type to operated

Multiple types are declared as a type union For example:

class MySystem extends System<ComponentA | ComponentB> {
public readonly types = ['a', 'b'] as const;
public readonly systemType = SystemType.Update;
public update(entities: Entity<ComponentA | ComponentB>) {
...
}
}

Type Parameters

Hierarchy

Implements

Index

Constructors

  • new System<ComponentTypeUnion, ContextType>(): System<ComponentTypeUnion, ContextType>
  • Type Parameters

    Returns System<ComponentTypeUnion, ContextType>

Properties

priority: number = 0

System can execute in priority order, by default all systems are priority 0. Lower values indicated higher priority. For a system to execute before all other a lower priority value (-1 for example) must be set. For a system to execute after all other a higher priority value (10 for example) must be set.

systemType: SystemType

Determine whether the system is called in the SystemType.Update or the SystemType.Draw phase. Update is first, then Draw.

types: readonly SystemTypes<ComponentTypeUnion>[]

The types of entities that this system operates on For example ['transform', 'motion']

Methods

  • initialize(engine: ContextType): void
  • postupdate(engine: ContextType, elapsedMs: number): void
  • Optionally run a postupdate after the system processes matching entities

    Parameters

    • engine: ContextType
    • elapsedMs: number

      Time in milliseconds since the last frame

    Returns void

  • preupdate(engine: ContextType, elapsedMs: number): void
  • Optionally run a preupdate before the system processes matching entities

    Parameters

    • engine: ContextType
    • elapsedMs: number

      Time in milliseconds since the last frame

    Returns void

  • update(entities: Entity[], delta: number): void
  • Update all entities that match this system's types

    Parameters

    • entities: Entity[]

      Entities to update that match this system's types

    • delta: number

      Time in milliseconds

    Returns void