UNPKG

phaser3-rex-plugins

Version:
2 lines (1 loc) 3.36 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexwaiteventsplugin=e();}(undefined,(function(){function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(o=r.key,i=void 0,"symbol"==typeof(i=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,e||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(o,"string"))?i:String(i)),r);}var o,i;}function n(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function o(t,e){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},o(t,e)}function i(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function u(t){var e=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return !1}}();return function(){var n,o=r(t);if(e){var u=r(this).constructor;n=Reflect.construct(o,arguments,u);}else n=o.apply(this,arguments);return i(this,n)}}var c=Phaser.Structs.Set,s=function(){function e(n,r){t(this,e),this.setCompleteCallback(n,r),this.events=new c;}return n(e,[{key:"shutdown",value:function(){return this.setCompleteCallback(void 0,void 0),this.events.clear(),this.event=void 0,this}},{key:"destroy",value:function(){return this.shutdown(),this}},{key:"setCompleteCallback",value:function(t,e){return this.completeCallback=t,this.scope=e,this}},{key:"waitCallback",value:function(){var t=this,e=function e(){t.remove(e);};return this.events.set(e),e}},{key:"waitEvent",value:function(t,e){return t.once(e,this.waitCallback()),this}},{key:"remove",value:function(t){return this.events.delete(t),this.noWaitEvent&&(this.scope?this.completeCallback.call(this.scope):this.completeCallback()),this}},{key:"clear",value:function(){return this.events.clear(),this}},{key:"noWaitEvent",get:function(){return 0===this.events.size}}]),e}();return function(e){!function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&o(t,e);}(i,Phaser.Plugins.BasePlugin);var r=u(i);function i(e){return t(this,i),r.call(this,e)}return n(i,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this);}},{key:"add",value:function(t,e){return new s(t,e)}}]),i}()}));