Skip to main content

Class: MapColliderCollection

Defined in: src/sdk/components/map/colliders/MapColliderCollection.ts:14

A collection of MapCollider objects. This collection supports collision (intersection) testing against simple shapes on all members of the collection at once, allowing you to enumerate all members that collide with a given shape.

Members are stored using a regular hash set, allowing for fast, constant-time addition and removal of colliders to and from the collection. This also means that collision tests on the collection have linear time complexity with respect to the size of the collection. Therefore, it is recommended to use this collection with colliders that implement relatively fast intersection tests and/or restrict the size of the collection to a reasonable limit.

Constructors​

Constructor​

new MapColliderCollection(): MapColliderCollection

Returns​

MapColliderCollection

Methods​

deregister()​

deregister(collider): void

Defined in: src/sdk/components/map/colliders/MapColliderCollection.ts:37

Deregisters a collider with this collection.

Parameters​

ParameterTypeDescription
colliderMapColliderThe collider to deregister.

Returns​

void

Throws​

Error if this collection has been destroyed.


destroy()​

destroy(): void

Defined in: src/sdk/components/map/colliders/MapColliderCollection.ts:127

Destroys this collection.

Returns​

void


intersectBox()​

intersectBox(cx, cy, axisX, axisY, halfWidth, halfHeight, mapProjection, out): MapCollider[]

Defined in: src/sdk/components/map/colliders/MapColliderCollection.ts:59

Finds all colliders in this collection that intersect an oriented rectangular box.

Parameters​

ParameterTypeDescription
cxnumberThe x coordinate of the center of the box.
cynumberThe y coordinate of the center of the box.
axisXnumberThe x component of the unit vector parallel to the axis that defines the box's width.
axisYnumberThe y component of the unit vector parallel to the axis that defines the box's width.
halfWidthnumberThe half width of the box.
halfHeightnumberThe half height of the box.
mapProjectionMapProjectionThe map projection.
outunknown[]The array to which to write the results.

Returns​

MapCollider[]

All colliders in this collection that intersect the specified oriented rectangular box, in order of decreasing priority.

Throws​

Error if this collection has been destroyed.


intersectCircle()​

intersectCircle(cx, cy, radius, mapProjection, out): MapCollider[]

Defined in: src/sdk/components/map/colliders/MapColliderCollection.ts:98

Finds all colliders in this collection that intersect a circle.

Parameters​

ParameterTypeDescription
cxnumberThe x coordinate of the center of the circle.
cynumberThe y coordinate of the center of the circle.
radiusnumberThe radius of the circle.
mapProjectionMapProjectionThe map projection.
outunknown[]The array to which to write the results.

Returns​

MapCollider[]

All colliders in this collection that intersect the specified circle, in order of decreasing priority.

Throws​

Error if this collection has been destroyed.


register()​

register(collider): void

Defined in: src/sdk/components/map/colliders/MapColliderCollection.ts:24

Registers a collider with this collection.

Parameters​

ParameterTypeDescription
colliderMapColliderThe collider to register.

Returns​

void

Throws​

Error if this collection has been destroyed.