UNPKG

phaser4-rex-plugins

Version:
2 lines (1 loc) 1.04 kB
var e,t;e=void 0,t=function(){class e{constructor(e,t){this.setCompleteCallback(e,t),this.events=new Set}shutdown(){return this.setCompleteCallback(void 0,void 0),this.events.clear(),this.event=void 0,this}destroy(){return this.shutdown(),this}setCompleteCallback(e,t){return this.completeCallback=e,this.scope=t,this}waitCallback(){var e=this,t=function(){e.remove(t)};return this.events.add(t),t}waitEvent(e,t){return e.once(t,this.waitCallback()),this}remove(e){return this.events.delete(e),this.noWaitEvent&&(this.scope?this.completeCallback.call(this.scope):this.completeCallback()),this}clear(){return this.events.clear(),this}get noWaitEvent(){return 0===this.events.size}}class t extends Phaser.Plugins.BasePlugin{constructor(e){super(e)}start(){this.game.events.on("destroy",this.destroy,this)}add(t,s){return new e(t,s)}}return t},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).rexwaiteventsplugin=t();