Constructor
new EntityCollection(sharedAI)
A sequence of entities with filtering and tasking capabilities.
Parameters:
| Name | Type | Description |
|---|---|---|
sharedAI |
API3.SharedScript | The shared data container which holds all of the entities. |
- Source:
Methods
filter(filter) → {API3.EntityCollection}
Derives a new collection which contains only selected entities.
The current collection is not affected by the
filtering.
Parameters:
| Name | Type | Description |
|---|---|---|
filter |
API3.Filter | A filter object which chooses the entities to go into the derived collection. Only entities found in the current collection will be filtered into the derived one. It is possible to supply a "naked" decision function as well (see API3.Filter.func). |
- Source:
- To Do:
-
- Describe the thisp parameter.
Returns:
A new collection which contains
only those entities of the current
collection which match the filter
criterion. The new collection is
updated as the current collection
changes.
Example
var wonders = gameState.getEnemyStructures().filter(
API3.Filters.byClass("Wonder"));
filterNearest(targetPos, n) → {API3.EntityCollection}
Returns the (at most) n entities nearest to targetPos.
Entities are selected by their euclidian distance to
the target pos.
Warning: As the function considers the euclidian distance only, it is dangerous to use it for selection of unit around a target spot, as it toes not take into account obstructions on the path between unit and target.
Warning: As the function considers the euclidian distance only, it is dangerous to use it for selection of unit around a target spot, as it toes not take into account obstructions on the path between unit and target.
Parameters:
| Name | Type | Description |
|---|---|---|
targetPos |
Array.<Number> | Describes the position to start
searching for entities, where
targetPos[0] gives
the x-position and
targetPos[1] gives
the z-position. |
n |
Number | Maximum number of entities to return. |
- Source:
Returns:
A new collection which holds only
the nearest entities to the target
spot. The collection will
not auto-update
when entities change position.