Class: CollisionSystem
CollisionSystem watches for collisions between entities with Colliders and Transforms. It uses a number of algorithms to first do a broad sweep of possible collisions, then do a narrow sweep of the possible collisions to determine actual collisions and info around them. Once it has determined all collisions, it broadcasts them as messages.
Hierarchy
-
↳ CollisionSystem
Table of contents
Constructors
Properties
- entities
- messageBus
- scene
- subscriberID
- DESCRIPTOR_COLLISION_ENTER
- DESCRIPTOR_COLLISION_EXIT
- MESSAGE_COLLISION_ENTER
- MESSAGE_COLLISION_EXIT
- MESSAGE_DEREGISTER
- MESSAGE_REGISTER
- MESSAGE_UPDATE
Methods
Constructors
constructor
+ new CollisionSystem(messageBus
: IMessageBus, layerPairs?
: [string, string][], scene?
: IScene, narrowAlgorithm?
: ICollisionAlgorithm, broadAlgorithm?
: ICollisionAlgorithm, colliding?
: Collision[], entities?
: SystemEntity[], subscriberID?
: number): CollisionSystem
Parameters:
Name | Type |
---|---|
messageBus |
IMessageBus |
layerPairs |
[string, string][] |
scene? |
IScene |
narrowAlgorithm |
ICollisionAlgorithm |
broadAlgorithm |
ICollisionAlgorithm |
colliding |
Collision[] |
entities? |
SystemEntity[] |
subscriberID? |
number |
Returns: CollisionSystem
Inherited from: ArraySystem
Properties
entities
• Protected
entities: SystemEntity[]
The list of entities the system is tracking.
Inherited from: ArraySystem.entities
messageBus
• Protected
messageBus: IMessageBus
Reference to the message bus, the fundamental piece of JamJar for communicating with other parts of the engine.
Inherited from: ArraySystem.messageBus
scene
• Protected
Optional
scene: undefined | IScene
Any scene this system is part of, will change the lifecycle of the system to be part of the scene's lifecycle - it will be destroyed when the scene is destroyed.
Inherited from: ArraySystem.scene
subscriberID
• subscriberID: number
Inherited from: ArraySystem.subscriberID
DESCRIPTOR_COLLISION_ENTER
▪ Readonly
Static
DESCRIPTOR_COLLISION_ENTER: collision_enter= "collision_enter"
Descriptor of a script triggered when a collision enter occurs.
DESCRIPTOR_COLLISION_EXIT
▪ Readonly
Static
DESCRIPTOR_COLLISION_EXIT: collision_exit= "collision_exit"
Descriptor of a script triggered when a collision exit occurs.
MESSAGE_COLLISION_ENTER
▪ Readonly
Static
MESSAGE_COLLISION_ENTER: collision_enter= "collision_enter"
Message published when a collision enter occurs.
MESSAGE_COLLISION_EXIT
▪ Readonly
Static
MESSAGE_COLLISION_EXIT: collision_exit= "collision_exit"
Message published when a collision exit occurs.
MESSAGE_DEREGISTER
▪ Readonly
Static
MESSAGE_DEREGISTER: stateful_system_deregister= "stateful_system_deregister"
Message to deregister an entity + components with a system so it is no longer tracked.
Inherited from: ArraySystem.MESSAGE_DEREGISTER
MESSAGE_REGISTER
▪ Readonly
Static
MESSAGE_REGISTER: stateful_system_register= "stateful_system_register"
Message to register an entity + components with a system so it can be tracked.
Inherited from: ArraySystem.MESSAGE_REGISTER
MESSAGE_UPDATE
▪ Readonly
Static
MESSAGE_UPDATE: system_update= "system_update"
Inherited from: ArraySystem.MESSAGE_UPDATE
Methods
Destroy
▸ Destroy(): void
Destroy destroys the System and unsubscribes it from all messages. The System should be garbage collected after this, unless a direct reference to it exists somewhere. Therefore direct references to systems are discouraged; communication should all be through the message bus.
Returns: void
Inherited from: ArraySystem
OnDestroy
▸ Protected
OnDestroy(): void
Custom Destroy logic should go here to facilitate garbage collection, for example removing listeners.
Returns: void
Inherited from: ArraySystem
OnMessage
▸ OnMessage(message
: IMessage): void
Parameters:
Name | Type |
---|---|
message |
IMessage |
Returns: void
Inherited from: ArraySystem
Update
▸ Update(): void
Returns: void
Overrides: ArraySystem
register
▸ Protected
register(entity
: IEntity, components
: Component[]): void
Parameters:
Name | Type |
---|---|
entity |
IEntity |
components |
Component[] |
Returns: void
Inherited from: ArraySystem
remove
▸ Protected
remove(entity
: IEntity): void
Parameters:
Name | Type |
---|---|
entity |
IEntity |
Returns: void
Inherited from: ArraySystem