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
| Parameter | Type | Description |
|---|---|---|
collider | MapCollider | The 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
| Parameter | Type | Description |
|---|---|---|
cx | number | The x coordinate of the center of the box. |
cy | number | The y coordinate of the center of the box. |
axisX | number | The x component of the unit vector parallel to the axis that defines the box's width. |
axisY | number | The y component of the unit vector parallel to the axis that defines the box's width. |
halfWidth | number | The half width of the box. |
halfHeight | number | The half height of the box. |
mapProjection | MapProjection | The map projection. |
out | unknown[] | The array to which to write the results. |
Returns
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
| Parameter | Type | Description |
|---|---|---|
cx | number | The x coordinate of the center of the circle. |
cy | number | The y coordinate of the center of the circle. |
radius | number | The radius of the circle. |
mapProjection | MapProjection | The map projection. |
out | unknown[] | The array to which to write the results. |
Returns
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
| Parameter | Type | Description |
|---|---|---|
collider | MapCollider | The collider to register. |
Returns
void
Throws
Error if this collection has been destroyed.