Class: Module

Module

Abstract Module. Use for holding some (for one propose) components and systems
in one bag and easy plug-n-play to the World.

For example here is some system engine modules, like ngPhysics - that holds components
that describe physics properties of the entity or like ngPixijsAdapter - that holds
system of integration with Pixi.js library.

new Module()

Source:
  • core/module.js, line 20

Members

$c

Describe Component

Source:
  • core/module.js, line 56
Example
 module.$c('Goblin', {
    gold: 100,
    health: 50,
    wisdom: 10
 });

$name :string

Name of the Module

Source:
  • core/module.js, line 29

$s

Describe System. Like a filter in AngularJS

Source:
  • core/module.js, line 119
See:
Example
 module.$s('theSystem', {
    //define array of requiested component
    $require: ['theComponent1', 'theComponent2']

    //(optional) execute on adding system
    $added: function() {

    },

    //(optional) execute on removing system
    $removed: function() {

    },

    //(optional) execute on adding entity to system
    $addEntity: function($entity) {

    },

    //(optional) execute on removing entity from system
    $removeEntity: function($entity) {

    },

    //(optional) beforeUpdate
    //before function define all injections (angularjs style)
    $beforeUpdate: ['$entities', function($entities) {

    }],

    //(optional) handle each entity in the system.
    //before function define all injections (angularjs style)
    $update: ['#entity', '$world', function($entity, $world) {

    }],

    //(optional) afterUpdate
    //before function define all injections (angularjs style)
    $afterUpdate: ['$entities', function($entities) {

    }]
 });

Methods

$has(name) → {boolean}

Define is module has component or system.

Parameters:
Name Type Description
name string

of component or system

Source:
  • core/module.js, line 37
Returns:
Type
boolean

comments powered by Disqus