import { BaseCollider } from "./BaseCollider" ; import { ColliderGroup } from "./ColliderGroup" ; /**
 * 碰撞的组的Manager
 */ export class ColliderGroupManager { private static mGroupMap : Map < string , ColliderGroup > = new Map ( ) ; param groupName public static getGroup ( groupName ) { let group = this . mGroupMap . get ( groupName ) ; if ( ! group ) { group = new ColliderGroup ( ) ; group . name = groupName ; this . mGroupMap . set ( groupName , group ) ; } return group ; } param collider public static addCollider ( collider ) { this . getGroup ( collider . group ) . addCollider ( collider ) ; } param collider public static remove ( collider ) { if ( collider . group == undefined ) { return ; } this . getGroup ( collider . group ) . remove ( collider ) ; } param groupName public static getColliders ( groupName ? ) { if ( groupName ) { return this . getGroup ( groupName ) . getColliders ( ) ; } let arr = new Array ( ) ; this . mGroupMap . forEach ( ( g ) => { g . getColliders ( ) . forEach ( ( a ) => { if ( ! arr . includes ( a ) ) { arr . push ( a ) ; } } ) ; } ) ; return arr ; } param deltaMS public static update ( deltaMS ) { ColliderGroupManager . mGroupMap . forEach ( c => { c . update ( deltaMS ) ; } ) ; } }