BaseComponent

BaseComponent

Class to represent a component that data should be extracted from

This is intended to be a base class for other classes to extend, so shouldn't be used directly.

To extend it the static Types() method needs to be implemented in the child class as well as the type constants.

Constructor

new BaseComponent(component_type, entities)

Source:
Parameters:
Name Type Description
component_type string Component type constant
entities Array.<BaseEntity> Array of BaseEntity instances

Members

component_type :string

Description:
  • Component constant
Source:
Component constant
Type:
  • string

entities :Array.<BaseEntity>

Description:
  • Array of BaseEntity instances
Source:
Array of BaseEntity instances
Type:

Methods

(static) Types() → {Array.<string>}

Description:
  • Returns an array of all the available component type strings This needs to be overridden by child classes
Source:
Returns:
Type
Array.<string>

GetEntityByTag(tag) → (nullable) {BaseEntity}

Description:
  • Get an BaseEntity by tag
Source:
Example
let entity = component.GetEntityByTag(OccupantEntity.HEAD_NODE);
Parameters:
Name Type Description
tag string Entity tag
Returns:
Type
BaseEntity

toJSON() → {object}

Description:
  • JSON representation
Source:
Example
let json = component.toJSON();
Returns:
Type
object