Methods
addEntities(…entities) → {EntityManager}
Adds all specified entities to the entity manager.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
entities |
Entity |
<repeatable> |
The entities. |
Fires:
- EntityManager#manager:add
- module:transvolve#event:error
Throws
- TypeError
- Will throw this error if any argument is not an Entity.
- ReferenceError
- Will throw this error if invoked after the entity manager has been disposed.
clear() → {EntityManager}
Removes all entities from the manager.
Throws
- ReferenceError
- Will throw this error if invoked after the entity manager has been disposed.
contains(entity) → {boolean}
Returns truthy is the entity manager contains a specified entity.
Parameters
Name | Type | Description |
---|---|---|
entity |
Entity | The entity. |
Throws
- TypeError
- Will throw this error if entity is not an Entity.
- ReferenceError
- Will throw this error if invoked after the entity manager has been disposed.
Returns
If the entity manager contains the entity.
- Type
- boolean
findEntities(predicate) → {Array.<Entity>}
Finds all entities in the entity manager that return truthy for the predicate.
Parameters
Name | Type | Description |
---|---|---|
predicate |
function | The predicate function. |
Throws
- TypeError
- Will throw this error if the predicate is not a function.
- ReferenceError
- Will throw this error if invoked after the entity manager has been disposed.
forEach(iteratee)
Iterates over elements of collection and invokes iteratee for each element.
Parameters
Name | Type | Description |
---|---|---|
iteratee |
function | The iteratee function. |
Throws
- TypeError
- Will throw this error if the iteratee is not a function.
- ReferenceError
- Will throw this error if invoked after the entity manager has been disposed.
getEntities(…ids) → {Entity|Array.<Entity>}
Gets all entities in the entity manager for specified ids. Returns only a single entity if
only one id is specified, but returns all entities if no ids are specified.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
ids |
number |
<repeatable> |
The entity ids. |
Fires:
- module:transvolve#event:error
Throws
- TypeError
- Will throw this error if an argument other than a number is passed.
- ReferenceError
- Will throw this error if invoked after the entity manager has been disposed.
length() → {number}
Gets the length of the entity list.
Throws
- ReferenceError
- Will throw this error if invoked after the entity manager has been disposed.
Returns
The length of the entity list.
- Type
- number
removeEntities(…entitiesOrIds) → {EntityManager}
Removes all specified entities from the entity manager.
Parameters
Name | Type | Attributes | Description |
---|---|---|---|
entitiesOrIds |
Entity | number |
<repeatable> |
The entities or entity ids. |
Fires:
- EntityManager#manager:remove
- module:transvolve#event:error
Throws
- TypeError
- Will throw this error if any argument is not an Entity or a number.
- ReferenceError
- Will throw this error if invoked after the entity manager has been disposed.
toArray() → {Array.<Entity>}
Turns the doubly linked list to an array.
Throws
- ReferenceError
- Will throw this error if invoked after the entity manager has been disposed.
Type Definitions
EntityNode
A single entity reference within an entity manager.
Properties:
Name | Type | Description |
---|---|---|
entity |
Entity | The entity. |
previous |
EntityNode | The previous node. |
next |
EntityNode | The next node. |