zooMgr.ts 522 B

12345678910111213141516171819202122232425
  1. import { ZooId } from "./zooId";
  2. export class ZooMgr {
  3. private static _inst: ZooMgr;
  4. public static get inst(): ZooMgr {
  5. if (this._inst == null) {
  6. this._inst = new ZooMgr();
  7. }
  8. return this._inst;
  9. }
  10. zooMap: Map<number, ZooId> = new Map();
  11. add(zooId: ZooId){
  12. this.zooMap.set(zooId.id, zooId);
  13. }
  14. remove(zooId: ZooId){
  15. this.zooMap.delete(zooId.id);
  16. }
  17. get(id: number){
  18. return this.zooMap.get(id);
  19. }
  20. }