Entity
An entity.
Table of Contents
- Methods
- Properties
Constructor
Entity
-
idOrUidGenerator=null
-
components=[]
Parameters:
-
[idOrUidGenerator=null]
Number | UIDGenerator optionalThe entity id if a Number is passed. If an UIDGenerator is passed, the entity will use it to generate a new id. If nothing is passed, the entity will use the default UIDGenerator.
-
[components=[]]
ArrayComponent optionalAn array of initial components.
Methods
updateComponent
-
name
-
data
Update a component field by field, NOT recursively. If the component does not exists, this method create it silently.
Parameters:
-
name
StringName of the component
-
data
ObjectDict of attributes to update
Example:
entity.addComponent('kite', {vel: 0, pos: {x: 1}}); // entity.component.pos is '{vel: 0, pos: {x: 1}}' entity.updateComponent('kite', {angle: 90, pos: {y: 1}}); // entity.component.pos is '{vel: 0, angle: 90, pos: {y: 1}}'
Properties
components
Object
Components of the entity stored as key-value pairs.
id
Number
Unique identifier of the entity.
systems
ArraySystem
Systems applied to the entity.
systemsDirty
Boolean
Indiquate a change in components (a component was removed or added) which require to re-compute entity eligibility to all systems.