Engine

engine~ Engine

The Engine class

Constructor

new Engine()

Source:

Extends

  • EventEmitter

Members

(private) entities :Object

Source:

Declared entities

Type:
  • Object

(private) systems :Array.<System>

Source:

Declared systems

Type:
  • Array.<System>

(private) systemVsEntities :Object

Source:

Entities associated to systems

Type:
  • Object

Methods

entity(name) → {Entity}

Source:

Declare a new entity

Parameters:
Name Type Description
name String

Name of the new entity

Returns:

The newly created entity object

Type
Entity

getEntity(name) → {Entity}

Source:

Returns existing entity

Parameters:
Name Type Description
name String

Name of the entity

Returns:

The entity object or undefined if not found

Type
Entity

getSystem(name) → {System}

Source:

Returns existing system

Parameters:
Name Type Description
name String

Name of the system

Returns:

The system object or undefined if not found

Type
System

removeEntity(name)

Source:

Remove a entity from the engine instance

Parameters:
Name Type Description
name String

The name of the entity to be removed

removeSystem(name)

Source:

Remove a system from the engine instance

Parameters:
Name Type Description
name String

The name of the system to be removed

system(name, components, handler) → {System}

Source:

Declare a new system.
The handler function receives two arguments, the name of the entity and a object of components.

Parameters:
Name Type Description
name String

Name of the new system

components Array.<string>

Names of the components the new system will operate on

handler function

System function

Returns:

The newly created system object

Type
System

tick() → {Number}

Source:

Run a single execution step.
Emit a TICK_BEFORE event before running the systems and a TICK_AFTER event after running them.

Returns:

Current simulation time

Type
Number

(private) updateSystemsVsEntities()

Source:

Scan systems and search for suitable entities to be associated.