classdesc

  Class representing a system.

### Hierarchy

- System

## Index

### Constructors

- constructor

### Properties

- _accumulator
- _componentTypes
- _engine
- _entityUUIDs
- _fixed
- _frozen
- _methods
- _name
- _onAddEntity
- _onInit
- _onRemoveEntity
- _onUpdate
- _step

### Accessors

- accumulator
- fixed
- name
- step
- watchedComponentTypes
- watchedEntityUUIDs

### Methods

- addMethod
- canWatch
- dispatch
- init
- isWatchingComponentType
- isWatchingEntity
- removeMethod
- unwatchComponentType
- unwatchEntity
- update
- watchComponentType
- watchEntity

## Constructors

### constructor

- new System(config: SystemConfig): System

- - Defined in core/System.ts:25
  description

    Create a System.

  #### Parameters

  - ##### config: SystemConfig

    Configuration object

  #### Returns System

## Properties

### Private _accumulator

_accumulator: number

- Defined in core/System.ts:13

### Private _componentTypes

_componentTypes: string[]

- Defined in core/System.ts:14

### Private _engine

_engine: Engine

- Defined in core/System.ts:15

### Private _entityUUIDs

_entityUUIDs: string[]

- Defined in core/System.ts:16

### Private _fixed

_fixed: boolean

- Defined in core/System.ts:17

### Private _frozen

_frozen: boolean

- Defined in core/System.ts:18

### Private _methods

_methods: __type

- Defined in core/System.ts:19

### Private _name

_name: string

- Defined in core/System.ts:20

### Private _onAddEntity

_onAddEntity: function

- Defined in core/System.ts:21

#### Type declaration

- - (entity: Entity): void

  - #### Parameters

    - ##### entity: Entity

    #### Returns void

### Private _onInit

_onInit: function

- Defined in core/System.ts:22

#### Type declaration

- - (): void

  - #### Returns void

### Private _onRemoveEntity

_onRemoveEntity: function

- Defined in core/System.ts:23

#### Type declaration

- - (entity: Entity): void

  - #### Parameters

    - ##### entity: Entity

    #### Returns void

### Private _onUpdate

_onUpdate: function

- Defined in core/System.ts:24

#### Type declaration

- - (delta: number): void

  - #### Parameters

    - ##### delta: number

    #### Returns void

### Private _step

_step: number

- Defined in core/System.ts:25

## Accessors

### accumulator

- get accumulator(): number

- - Defined in core/System.ts:87
  description

    Get the accumulated time of the system.

  readonly

  #### Returns number

  - Time in milliseconds

### fixed

- get fixed(): boolean

- - Defined in core/System.ts:96
  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

- - Defined in core/System.ts:114
  description

    Get the entity's name.

  readonly

  #### Returns string

  - Name string

### step

- get step(): number

- - Defined in core/System.ts:105
  description

    Get the step size of the system in milliseconds.

  readonly

  #### Returns number

  - Time in milliseconds

### watchedComponentTypes

- get watchedComponentTypes(): string[]

- - Defined in core/System.ts:123
  description

    Get all of the component types the system is watching.

  readonly

  #### Returns string[]

  - Array of component types

### watchedEntityUUIDs

- get watchedEntityUUIDs(): string[]

- - Defined in core/System.ts:132
  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

- - Defined in core/System.ts:141
  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

- - Defined in core/System.ts:152
  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

- - Defined in core/System.ts:172
  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

- init(engine: Engine): void

- - Defined in core/System.ts:184
  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

- - Defined in core/System.ts:203
  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

- - Defined in core/System.ts:216
  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

- - Defined in core/System.ts:228
  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[]

- - Defined in core/System.ts:241
  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[]

- - Defined in core/System.ts:258
  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

- - Defined in core/System.ts:273
  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[]

- - Defined in core/System.ts:292
  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[]

- - Defined in core/System.ts:316
  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