Options
All
  • Public
  • Public/Protected
  • All
Menu

Class System

classdesc

Class representing a system.

Hierarchy

  • System

Index

Constructors

constructor

Accessors

accumulator

  • get accumulator(): number
  • description

    Get the accumulated time of the system.

    readonly

    Returns number

    • Time in milliseconds

fixed

  • get fixed(): boolean
  • description

    Get whether or not the system uses a fixed step.

    readonly

    Returns boolean

    • True if the system uses a fixed step

name

  • get name(): string
  • description

    Get the entity's name.

    readonly

    Returns string

    • Name string

step

  • get step(): number
  • description

    Get the step size of the system in milliseconds.

    readonly

    Returns number

    • Time in milliseconds

watchedComponentTypes

  • get watchedComponentTypes(): string[]
  • description

    Get all of the component types the system is watching.

    readonly

    Returns string[]

    • Array of component types

watchedEntityUUIDs

  • get watchedEntityUUIDs(): string[]
  • description

    Get all of the entity UUIDs the system is watching.

    readonly

    Returns string[]

    • Array of UUID strings

Methods

addMethod

  • addMethod(key: string, fn: Function): void
  • description

    Add an extra method to the system. Cannot be modified after the system is registered with the engine.

    Parameters

    • key: string

      Method identifier

    • fn: Function

      Method to be called by user in the future

    Returns void

canWatch

  • canWatch(entity: Entity): boolean
  • description

    Check if the system can watch a given entity.

    readonly

    Parameters

    • entity: Entity

      Entity to check

    Returns boolean

    • True if the given entity is watchable

dispatch

  • dispatch(key: string, payload?: any): any
  • description

    Call a user-added method from outside the system. Cannot be modified after the system is registered with the engine.

    Parameters

    • key: string

      Method identifier

    • Optional payload: any

      Any data which should be passed to the method

    Returns any

    • Any data which the method returns

init

  • description

    Initialize the system (as a part of linking to the engine). After linking the engine, the system will run its stored init hook method. Cannot be modified after the system is registered with the engine.

    Parameters

    • engine: Engine

      Engine instance to link to

    Returns void

isWatchingComponentType

  • isWatchingComponentType(componentType: string): boolean
  • description

    Check if the system is watching a given component type.

    readonly

    Parameters

    • componentType: string

    Returns boolean

    • True if the given component type is being watched

isWatchingEntity

  • isWatchingEntity(entity: Entity): boolean
  • description

    Check if the system is watching a given entity.

    readonly

    Parameters

    • entity: Entity

      Entity instance to check

    Returns boolean

    • True if the given entity instance is being watched

removeMethod

  • removeMethod(key: string): void
  • description

    Remove a user-added method from the system. Cannot be modified after the system is registered with the engine.

    Parameters

    • key: string

      Method identifier

    Returns void

unwatchComponentType

  • unwatchComponentType(componentType: string): string[]
  • description

    Remove a component type to the system's watch list. Cannot be modified after the system is registered with the engine.

    Parameters

    • componentType: string

      Component type to stop watching

    Returns string[]

    • Array of watched component types

unwatchEntity

  • unwatchEntity(entity: Entity): string[]
  • description

    Remove an entity UUID to the system's watch list.

    Parameters

    • entity: Entity

      Entity instance to stop watching

    Returns string[]

    • Array of watched entity UUIDs

update

  • update(delta: number): void
  • description

    Update the system with a given amount of time to simulate. The system will run its stored update function using either a fixed step or variable step (specified at creation) and the supplied delta time. Cannot be modified after the system is registered with the engine.

    Parameters

    • delta: number

      Time in milliseconds to simulate

    Returns void

watchComponentType

  • watchComponentType(componentType: string): string[]
  • description

    Add a single component type to the system's watch list. Cannot be modified after the system is registered with the engine.

    Parameters

    • componentType: string

      Component type to watch

    Returns string[]

    • Array of watched component types

watchEntity

  • watchEntity(entity: Entity): string[]
  • description

    Watch an entity by adding its UUID to to the system. After adding, the system will run the entity through the internal add function to do any additional processing.

    Parameters

    • entity: Entity

      Entity instance to watch

    Returns string[]

    • Array of watched entity UUIDs

Generated using TypeDoc