import { BaseCollider } from "./BaseCollider" ; /**
 * 碰撞的组
 * 用来分组的
 */ export class ColliderGroup { private mColliderList : Array < BaseCollider > = new Array ( ) ; /**
     * 是否开启碰撞
     */ public active = true ; /**
     * 组名
     */ public name : string = "" ; param collider public addCollider ( collider ) { if ( ! this . mColliderList . includes ( collider ) ) { this . mColliderList . push ( collider ) ; } } param collider public remove ( collider ) { this . mColliderList . remove ( collider ) ; } /**
     * 获取当前组里的碰撞
     */ public getColliders ( ) { let arr = new Array ( ) ; this . mColliderList . forEach ( ( v ) => { arr . push ( v ) ; } ) ; return arr ; } param deltaMS public update ( deltaMS ) { if ( ! this . active ) { return ; } for ( let i = 0 ; i < this . mColliderList . length ; i ++ ) { for ( let j = i ; j < this . mColliderList . length ; j ++ ) { let source = this . mColliderList [ i ] ; let target = this . mColliderList [ j ] ; if ( source == target ) { continue ; } let isContact = source . detection ( target ) ; target . sendEvent ( isContact , source ) ; } } } }