Show:
Module: ecs

A system update all eligible entities at a given frequency. This class is not meant to be used directly and should be sub-classed to define specific logic.

Constructor

System
(
  • frequency=1
)

Parameters:

  • [frequency=1] Number optional

    Frequency of execution.

Methods

dispose ()

dispose the system by exiting all the entities

enter
(
  • entity
)

Abstract method to subclass. Called when an entity is added to the system.

Parameters:

  • entity Entity

    The added entity.

exit
(
  • entity
)

Abstract method to subclass. Called when an entity is removed from the system.

Parameters:

  • entity Entity

    The removed entity.

postUpdate ()

Abstract method to subclass. Called once per update, after entities iteration.

preUpdate ()

Abstract method to subclass. Called once per update, before entities iteration.

test
(
  • entity
)

Abstract method to subclass. Should return true if the entity is eligible to the system, false otherwise.

Parameters:

  • entity Entity

    The entity to test.

update
(
  • entity
)

Abstract method to subclass. Called for each entity to update. This is the only method that should actual mutate entity state.

Parameters:

  • entity Entity

    The entity to update.

updateAll ()

Apply update to each entity of this system.

Properties

entities

ArrayEntity

Entities of the system.

frequency

Number

Frequency of update execution, a frequency of 1 run the system every update, 2 will run the system every 2 updates, ect.