UNPKG

phaser3-rex-plugins

Version:
2 lines (1 loc) 30.2 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).rexloadingprogressplugin=e();}(undefined,(function(){function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,(s=n.key,r=void 0,"symbol"==typeof(r=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===e?String:Number)(t)}(s,"string"))?r:String(r)),n);}var s,r;}function n(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function s(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&&a(t,e);}function r(t){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},r(t)}function a(t,e){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},a(t,e)}function o(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function h(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 i,n=r(t);if(e){var s=r(this).constructor;i=Reflect.construct(n,arguments,s);}else i=n.apply(this,arguments);return function(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 o(t)}(this,i)}}function u(){return u="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=r(t)););return t}(t,e);if(n){var s=Object.getOwnPropertyDescriptor(n,e);return s.get?s.get.call(arguments.length<3?t:i):s.value}},u.apply(this,arguments)}var c={setEventEmitter:function(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames:function(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}},l=Phaser.Scene,v=function(t){return t instanceof l},p=function(e){return null==e||"object"!==t(e)?null:v(e)?e:e.scene&&v(e.scene)?e.scene:e.parent&&e.parent.scene&&v(e.parent.scene)?e.parent.scene:null},f=Phaser.Game,y=function(t){return t instanceof f},d=Phaser.Utils.Objects.GetValue,m=function(){function i(t,n){e(this,i),this.setParent(t),this.isShutdown=!1,this.setEventEmitter(d(n,"eventEmitter",!0)),this.parent&&(this.parent===this.scene?this.scene.sys.events.once("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.once("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.once("destroy",this.onParentDestroy,this));}return n(i,[{key:"shutdown",value:function(t){this.isShutdown||(this.parent&&(this.parent===this.scene?this.scene.sys.events.off("shutdown",this.onEnvDestroy,this):this.parent===this.game?this.game.events.off("shutdown",this.onEnvDestroy,this):this.parent.once&&this.parent.off("destroy",this.onParentDestroy,this)),this.destroyEventEmitter(),this.parent=void 0,this.scene=void 0,this.game=void 0,this.isShutdown=!0);}},{key:"destroy",value:function(t){this.shutdown(t);}},{key:"onEnvDestroy",value:function(){this.destroy(!0);}},{key:"onParentDestroy",value:function(t,e){this.destroy(e);}},{key:"setParent",value:function(e){var i;return this.parent=e,this.scene=p(e),this.game=null==(i=e)||"object"!==t(i)?null:y(i)?i:y(i.game)?i.game:v(i)?i.sys.game:v(i.scene)?i.scene.sys.game:void 0,this}}]),i}();function k(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}Object.assign(m.prototype,c);var _={exports:{}};!function(t){var e=Object.prototype.hasOwnProperty,i="~";function n(){}function s(t,e,i){this.fn=t,this.context=e,this.once=i||!1;}function r(t,e,n,r,a){if("function"!=typeof n)throw new TypeError("The listener must be a function");var o=new s(n,r||t,a),h=i?i+e:e;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function a(t,e){0==--t._eventsCount?t._events=new n:delete t._events[e];}function o(){this._events=new n,this._eventsCount=0;}Object.create&&(n.prototype=Object.create(null),(new n).__proto__||(i=!1)),o.prototype.eventNames=function(){var t,n,s=[];if(0===this._eventsCount)return s;for(n in t=this._events)e.call(t,n)&&s.push(i?n.slice(1):n);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(t)):s},o.prototype.listeners=function(t){var e=i?i+t:t,n=this._events[e];if(!n)return [];if(n.fn)return [n.fn];for(var s=0,r=n.length,a=new Array(r);s<r;s++)a[s]=n[s].fn;return a},o.prototype.listenerCount=function(t){var e=i?i+t:t,n=this._events[e];return n?n.fn?1:n.length:0},o.prototype.emit=function(t,e,n,s,r,a){var o=i?i+t:t;if(!this._events[o])return !1;var h,u,c=this._events[o],l=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,e),!0;case 3:return c.fn.call(c.context,e,n),!0;case 4:return c.fn.call(c.context,e,n,s),!0;case 5:return c.fn.call(c.context,e,n,s,r),!0;case 6:return c.fn.call(c.context,e,n,s,r,a),!0}for(u=1,h=new Array(l-1);u<l;u++)h[u-1]=arguments[u];c.fn.apply(c.context,h);}else {var v,p=c.length;for(u=0;u<p;u++)switch(c[u].once&&this.removeListener(t,c[u].fn,void 0,!0),l){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,e);break;case 3:c[u].fn.call(c[u].context,e,n);break;case 4:c[u].fn.call(c[u].context,e,n,s);break;default:if(!h)for(v=1,h=new Array(l-1);v<l;v++)h[v-1]=arguments[v];c[u].fn.apply(c[u].context,h);}}return !0},o.prototype.on=function(t,e,i){return r(this,t,e,i,!1)},o.prototype.once=function(t,e,i){return r(this,t,e,i,!0)},o.prototype.removeListener=function(t,e,n,s){var r=i?i+t:t;if(!this._events[r])return this;if(!e)return a(this,r),this;var o=this._events[r];if(o.fn)o.fn!==e||s&&!o.once||n&&o.context!==n||a(this,r);else {for(var h=0,u=[],c=o.length;h<c;h++)(o[h].fn!==e||s&&!o[h].once||n&&o[h].context!==n)&&u.push(o[h]);u.length?this._events[r]=1===u.length?u[0]:u:a(this,r);}return this},o.prototype.removeAllListeners=function(t){var e;return t?(e=i?i+t:t,this._events[e]&&a(this,e)):(this._events=new n,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=i,o.EventEmitter=o,t.exports=o;}(_);var E=function(t){s(r,t);var i=h(r);function r(){return e(this,r),i.apply(this,arguments)}return n(r,[{key:"shutdown",value:function(){this.removeAllListeners();}},{key:"destroy",value:function(){this.removeAllListeners();}}]),r}(k(_.exports)),g={setEventEmitter:function(t,e){return void 0===e&&(e=E),this._privateEE=!0===t||void 0===t,this._eventEmitter=this._privateEE?new e:t,this},destroyEventEmitter:function(){return this._eventEmitter&&this._privateEE&&this._eventEmitter.shutdown(),this},getEventEmitter:function(){return this._eventEmitter},on:function(){return this._eventEmitter&&this._eventEmitter.on.apply(this._eventEmitter,arguments),this},once:function(){return this._eventEmitter&&this._eventEmitter.once.apply(this._eventEmitter,arguments),this},off:function(){return this._eventEmitter&&this._eventEmitter.off.apply(this._eventEmitter,arguments),this},emit:function(t){return this._eventEmitter&&t&&this._eventEmitter.emit.apply(this._eventEmitter,arguments),this},addListener:function(){return this._eventEmitter&&this._eventEmitter.addListener.apply(this._eventEmitter,arguments),this},removeListener:function(){return this._eventEmitter&&this._eventEmitter.removeListener.apply(this._eventEmitter,arguments),this},removeAllListeners:function(){return this._eventEmitter&&this._eventEmitter.removeAllListeners.apply(this._eventEmitter,arguments),this},listenerCount:function(){return this._eventEmitter?this._eventEmitter.listenerCount.apply(this._eventEmitter,arguments):0},listeners:function(){return this._eventEmitter?this._eventEmitter.listeners.apply(this._eventEmitter,arguments):[]},eventNames:function(){return this._eventEmitter?this._eventEmitter.eventNames.apply(this._eventEmitter,arguments):[]}},b=function(t,e,i){if(t&&"number"!=typeof t){if(t.hasOwnProperty(e))return t[e];if(-1!==e.indexOf(".")){for(var n=e.split("."),s=t,r=i,a=0;a<n.length;a++){if(!s.hasOwnProperty(n[a])){r=i;break}r=s[n[a]],s=s[n[a]];}return r}return i}return i},O=["next","exit","enter"],S=function(){function t(i){e(this,t);var n=b(i,"states",void 0);n&&this.addStates(n);var s=b(i,"extend",void 0);if(s)for(var r in s)this.hasOwnProperty(r)&&void 0!==this[r]||(this[r]=s[r]);var a=b(i,"eventEmitter",void 0),o=b(i,"EventEmitterClass",void 0);this.setEventEmitter(a,o),this._stateLock=!1,this.resetFromJSON(i);}return n(t,[{key:"shutdown",value:function(){this.destroyEventEmitter();}},{key:"destroy",value:function(){this.shutdown();}},{key:"resetFromJSON",value:function(t){this.setEnable(b(t,"enable",!0)),this.start(b(t,"start",void 0));var e=b(t,"init",void 0);return e&&e.call(this),this}},{key:"toJSON",value:function(){return {curState:this.state,prevState:this.prevState,enable:this.enable,start:this._start}}},{key:"setEnable",value:function(t){return void 0===t&&(t=!0),this.enable=t,this}},{key:"toggleEnable",value:function(){return this.setEnable(!this.enable),this}},{key:"state",get:function(){return this._state},set:function(t){if(this.enable&&!this._stateLock&&this._state!==t){if(this._prevState=this._state,this._state=t,this._stateLock=!0,this.emit("statechange",this),null!=this._prevState){var e="exit_"+this._prevState,i=this[e];i&&i.call(this),this.emit(e,this);}if(this._stateLock=!1,null!=this._state){var n="enter_"+this._state,s=this[n];s&&s.call(this),this.emit(n,this);}}}},{key:"prevState",get:function(){return this._prevState}},{key:"start",value:function(t){return this._start=t,this._prevState=void 0,this._state=t,this}},{key:"goto",value:function(t){return null!=t&&(this.state=t),this}},{key:"next",value:function(){var t,e=this["next_"+this.state];return e&&(t="string"==typeof e?e:e.call(this)),this.goto(t),this}},{key:"stateProperties",get:function(){return O}},{key:"addState",value:function(t,e){"string"!=typeof t&&(t=(e=t).name);for(var i=this.stateProperties,n=0,s=i.length;n<s;n++){var r=i[n],a=e[r];a&&(this["".concat(r,"_").concat(t)]=a);}return this}},{key:"addStates",value:function(t){if(Array.isArray(t))for(var e=0,i=t.length;e<i;e++)this.addState(t[e]);else for(var n in t)this.addState(n,t[n]);return this}},{key:"runMethod",value:function(t,e,i,n,s,r){var a=this[t+"_"+this.state];if(a){var o=arguments.length;switch(o){case 1:return a.call(this);case 2:return a.call(this,e);case 3:return a.call(this,e,i);case 4:return a.call(this,e,i,n);case 5:return a.call(this,e,i,n,s);case 6:return a.call(this,e,i,n,s,r)}for(var h=new Array(o-1),u=1;u<o;u++)h[u-1]=arguments[u];return a.apply(this,h)}}}]),t}();Object.assign(S.prototype,g);var w=function(t,e,i,n,s){void 0===s&&(s=!1);var r=t._events[e];if(!r)return !1;for(var a=0,o=r.length;a<o;a++){var h=r[a];if(h.fn===i&&h.context===n&&h.once===s)return !0}return !1},T=["next","exit","enter","update","preupdate","postupdate"],P=function(t){s(a,t);var i=h(a);function a(){return e(this,a),i.apply(this,arguments)}return n(a,[{key:"shutdown",value:function(){this.stopUpdate(),this.stopPreUpdate(),this.stopPostUpdate(),this._scene=void 0,u(r(a.prototype),"shutdown",this).call(this);}},{key:"resetFromJSON",value:function(t){return u(r(a.prototype),"resetFromJSON",this).call(this,t),this._scene=b(t,"scene",void 0),this}},{key:"stateProperties",get:function(){return T}},{key:"update",value:function(t,e){this.runMethod("update",t,e);}},{key:"preupdate",value:function(t,e){this.runMethod("preupdate",t,e);}},{key:"postupdate",value:function(t,e){this.runMethod("postupdate",t,e);}},{key:"startUpdate",value:function(t){t||(t=this._scene);var e=t.sys.events;return w(e,"update",this.update,this)||(this._scene=t,e.on("update",this.update,this)),this}},{key:"stopUpdate",value:function(){return this._scene?(this._scene.sys.events.off("update",this.update,this),this):this}},{key:"startPreUpdate",value:function(t){t||(t=this._scene);var e=t.sys.events;return w(e,"preupdate",this.preupdate,this)||(this._scene=t,e.on("preupdate",this.preupdate,this)),this}},{key:"stopPreUpdate",value:function(){return this._scene?(this._scene.sys.events.off("preupdate",this.preupdate,this),this):this}},{key:"startPostUpdate",value:function(t){t||(t=this._scene);var e=t.sys.events;return w(e,"postupdate",this.postupdate,this)||(this._scene=t,e.on("postupdate",this.postupdate,this)),this}},{key:"stopPostUpdate",value:function(){return this._scene?(this._scene.sys.events.off("postupdate",this.postupdate,this),this):this}}]),a}(S),C=function(t){s(r,t);var i=h(r);function r(t,n){var s;e(this,r),(s=i.call(this,n)).parent=t;var a=n.initState||"IDLE";return s.start(a),s}return n(r,[{key:"init",value:function(){this.start("IDLE");}},{key:"next_IDLE",value:function(){return "TRANS_OPNE"}},{key:"next_TRANS_OPNE",value:function(){return "OPEN"}},{key:"enter_TRANS_OPNE",value:function(){var t=this.parent;if(t.transitInTime>0){var e=t.runTransitionInCallback();t.delayCall(e,this.next,this);}else this.next();}},{key:"exit_TRANS_OPNE",value:function(){this.parent.removeDelayCall();}},{key:"next_OPEN",value:function(){return "TRANS_CLOSE"}},{key:"enter_OPEN",value:function(){this.parent.onOpen();}},{key:"exit_OPEN",value:function(){this.parent.removeDelayCall();}},{key:"next_TRANS_CLOSE",value:function(){return "CLOSE"}},{key:"enter_TRANS_CLOSE",value:function(){var t=this.parent;if(t.transitOutTime>0){var e=t.runTransitionOutCallback();t.delayCall(e,this.next,this);}else this.next();}},{key:"exit_TRANS_CLOSE",value:function(){this.parent.removeDelayCall();}},{key:"next_CLOSE",value:function(){return "TRANS_OPNE"}},{key:"enter_CLOSE",value:function(){this.parent.onClose();}},{key:"exit_CLOSE",value:function(){}},{key:"canOpen",value:function(){return "IDLE"===this.state||"CLOSE"===this.state}},{key:"canClose",value:function(){return "IDLE"===this.state||"OPEN"===this.state}}]),r}(P),x={delayCall:function(t,e,i){return this.delayCallTimer=function(t,e,i,n,s){var r=p(t);return r.time.delayedCall(e,(function(){r.game.events.once("poststep",(function(){i.call(n,s);}));}))}(this,t,e,i),this},removeDelayCall:function(){return this.delayCallTimer&&(this.delayCallTimer.remove(!1),this.delayCallTimer=void 0),this}},D=function(){},L={setTransitInTime:function(t){return this.transitInTime=t,this},setTransitOutTime:function(t){return this.transitOutTime=t,this},setTransitInCallback:function(t){return t||(t=D),this.transitInCallback=t,this},setTransitOutCallback:function(t){return t||(t=D),this.transitOutCallback=t,this}},j={runTransitionInCallback:function(){return this.transitInCallback(this.parent,this.transitInTime),this.transitInTime},onOpen:function(){},requestOpen:function(t,e){if(!this._state.canOpen())return this;this.openEventData=arguments.length>0?t:this.parent;var i=this.transitInTime;return void 0!==e&&(this.transitInTime=e),this._state.goto("TRANS_OPNE"),this.transitInTime=i,this}},N={runTransitionOutCallback:function(){return this.transitOutCallback(this.parent,this.transitOutTime),this.transitOutTime},onClose:function(){this.oneShotMode&&this.parent.destroy();},requestClose:function(t,e){if(!this._state.canClose)return this;this.closeEventData=arguments.length>0?t:this.parent;var i=this.transitOutTime;return void 0!==e&&(this.transitOutTime=e),this._state.goto("TRANS_CLOSE"),this.transitOutTime=i,this}},R={};Object.assign(R,x,L,j,N);var I=Phaser.Utils.Objects.GetValue,A=function(t){s(a,t);var i=h(a);function a(t,n){var s;return e(this,a),(s=i.call(this,t,n)).setTransitInTime(I(n,"duration.in",200)),s.setTransitOutTime(I(n,"duration.out",200)),s.setTransitInCallback(I(n,"transitIn")),s.setTransitOutCallback(I(n,"transitOut")),s.oneShotMode=I(n,"destroy",!1),s.delayCallTimer=void 0,s._state=new C(o(s),{eventEmitter:!1,initState:I(n,"initState","IDLE")}),s.openEventData=void 0,s.closeEventData=void 0,s}return n(a,[{key:"state",get:function(){return this._state.state}},{key:"shutdown",value:function(t){this.isShutdown||(this.transitInCallback=void 0,this.transitOutCallback=void 0,this.openEventData=void 0,this.closeEventData=void 0,this.removeDelayCall(),u(r(a.prototype),"shutdown",this).call(this,t));}}]),a}(m);Object.assign(A.prototype,R);var U=Phaser.Utils.Objects.GetValue,F=function(t){s(a,t);var i=h(a);function a(t,n){var s;return e(this,a),(s=i.call(this,t,n))._isRunning=!1,s.isPaused=!1,s.tickingState=!1,s.setTickingMode(U(n,"tickingMode",1)),s}return n(a,[{key:"boot",value:function(){2!==this.tickingMode||this.tickingState||this.startTicking();}},{key:"shutdown",value:function(t){this.isShutdown||(this.stop(),this.tickingState&&this.stopTicking(),u(r(a.prototype),"shutdown",this).call(this,t));}},{key:"setTickingMode",value:function(t){"string"==typeof t&&(t=M[t]),this.tickingMode=t;}},{key:"startTicking",value:function(){this.tickingState=!0;}},{key:"stopTicking",value:function(){this.tickingState=!1;}},{key:"isRunning",get:function(){return this._isRunning},set:function(t){this._isRunning!==t&&(this._isRunning=t,1===this.tickingMode&&t!=this.tickingState&&(t?this.startTicking():this.stopTicking()));}},{key:"start",value:function(){return this.isPaused=!1,this.isRunning=!0,this}},{key:"pause",value:function(){return this.isRunning&&(this.isPaused=!0,this.isRunning=!1),this}},{key:"resume",value:function(){return this.isPaused&&(this.isRunning=!0),this}},{key:"stop",value:function(){return this.isPaused=!1,this.isRunning=!1,this}},{key:"complete",value:function(){this.isPaused=!1,this.isRunning=!1,this.emit("complete",this.parent,this);}}]),a}(m),M={no:0,lazy:1,always:2},G=Phaser.Utils.Objects.GetValue,X=function(t){s(a,t);var i=h(a);function a(t,n){var s;e(this,a);var r=(s=i.call(this,t,n)).scene?"update":"step";return s.tickEventName=G(n,"tickEventName",r),s.isSceneTicker=!Y(s.tickEventName),s}return n(a,[{key:"startTicking",value:function(){u(r(a.prototype),"startTicking",this).call(this),this.isSceneTicker?this.scene.sys.events.on(this.tickEventName,this.update,this):this.game.events.on(this.tickEventName,this.update,this);}},{key:"stopTicking",value:function(){u(r(a.prototype),"stopTicking",this).call(this),this.isSceneTicker&&this.scene?this.scene.sys.events.off(this.tickEventName,this.update,this):this.game&&this.game.events.off(this.tickEventName,this.update,this);}}]),a}(F),Y=function(t){return "step"===t||"poststep"===t},J=Phaser.Utils.Objects.GetValue,V=Phaser.Math.Clamp,q=function(){function t(i){e(this,t),this.resetFromJSON(i);}return n(t,[{key:"resetFromJSON",value:function(t){this.state=J(t,"state",B),this.timeScale=J(t,"timeScale",1),this.delay=J(t,"delay",0),this.repeat=J(t,"repeat",0),this.repeatCounter=J(t,"repeatCounter",0),this.repeatDelay=J(t,"repeatDelay",0),this.duration=J(t,"duration",0),this.nowTime=J(t,"nowTime",0),this.justRestart=J(t,"justRestart",!1);}},{key:"toJSON",value:function(){return {state:this.state,timeScale:this.timeScale,delay:this.delay,repeat:this.repeat,repeatCounter:this.repeatCounter,repeatDelay:this.repeatDelay,duration:this.duration,nowTime:this.nowTime,justRestart:this.justRestart}}},{key:"destroy",value:function(){}},{key:"setTimeScale",value:function(t){return this.timeScale=t,this}},{key:"setDelay",value:function(t){return void 0===t&&(t=0),this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setRepeat",value:function(t){return this.repeat=t,this}},{key:"setRepeatInfinity",value:function(){return this.repeat=-1,this}},{key:"setRepeatDelay",value:function(t){return this.repeatDelay=t,this}},{key:"start",value:function(){return this.nowTime=this.delay>0?-this.delay:0,this.state=this.nowTime>=0?H:z,this.repeatCounter=0,this}},{key:"stop",value:function(){return this.state=B,this}},{key:"update",value:function(t,e){this.state!==B&&this.state!==Q&&0!==e&&0!==this.timeScale&&(this.nowTime+=e*this.timeScale,this.justRestart=!1,this.nowTime>=this.duration?-1===this.repeat||this.repeatCounter<this.repeat?(this.repeatCounter++,this.justRestart=!0,this.nowTime-=this.duration,this.repeatDelay>0&&(this.nowTime-=this.repeatDelay,this.state=K)):(this.nowTime=this.duration,this.state=Q):this.nowTime>=0&&(this.state=H));}},{key:"t",get:function(){var t;switch(this.state){case B:case z:case K:t=0;break;case H:t=this.nowTime/this.duration;break;case Q:t=1;}return V(t,0,1)},set:function(t){(t=V(t,-1,1))<0?(this.state=z,this.nowTime=-this.delay*t):(this.state=H,this.nowTime=this.duration*t,1===t&&0!==this.repeat&&this.repeatCounter++);}},{key:"setT",value:function(t){return this.t=t,this}},{key:"isIdle",get:function(){return this.state===B}},{key:"isDelay",get:function(){return this.state===z}},{key:"isCountDown",get:function(){return this.state===H}},{key:"isRunning",get:function(){return this.state===z||this.state===H}},{key:"isDone",get:function(){return this.state===Q}},{key:"isOddIteration",get:function(){return 1==(1&this.repeatCounter)}},{key:"isEvenIteration",get:function(){return 0==(1&this.repeatCounter)}}]),t}(),B=0,z=1,H=2,K=3,Q=-1,W=function(t){s(a,t);var i=h(a);function a(t,n){var s;return e(this,a),(s=i.call(this,t,n)).timer=new q,s}return n(a,[{key:"shutdown",value:function(t){this.isShutdown||(u(r(a.prototype),"shutdown",this).call(this,t),this.timer.destroy(),this.timer=void 0);}},{key:"start",value:function(){return this.timer.start(),u(r(a.prototype),"start",this).call(this),this}},{key:"stop",value:function(){return this.timer.stop(),u(r(a.prototype),"stop",this).call(this),this}},{key:"complete",value:function(){return this.timer.stop(),u(r(a.prototype),"complete",this).call(this),this}}]),a}(X),Z=Phaser.Utils.Objects.GetValue,$=Phaser.Utils.Objects.GetAdvancedValue,tt=Phaser.Tweens.Builders.GetEaseFunction,et=function(t){s(a,t);var i=h(a);function a(){return e(this,a),i.apply(this,arguments)}return n(a,[{key:"resetFromJSON",value:function(t){return this.timer.resetFromJSON(Z(t,"timer")),this.setEnable(Z(t,"enable",!0)),this.setTarget(Z(t,"target",this.parent)),this.setDelay($(t,"delay",0)),this.setDuration($(t,"duration",1e3)),this.setEase(Z(t,"ease","Linear")),this.setRepeat(Z(t,"repeat",0)),this}},{key:"setEnable",value:function(t){return null==t&&(t=!0),this.enable=t,this}},{key:"setTarget",value:function(t){return void 0===t&&(t=this.parent),this.target=t,this}},{key:"setDelay",value:function(t){return this.delay=t,this}},{key:"setDuration",value:function(t){return this.duration=t,this}},{key:"setRepeat",value:function(t){return this.repeat=t,this}},{key:"setRepeatDelay",value:function(t){return this.repeatDelay=t,this}},{key:"setEase",value:function(t){return void 0===t&&(t="Linear"),this.ease=t,this.easeFn=tt(t),this}},{key:"start",value:function(){return this.timer.isRunning||u(r(a.prototype),"start",this).call(this),this}},{key:"restart",value:function(){return this.timer.stop(),this.start.apply(this,arguments),this}},{key:"stop",value:function(t){return void 0===t&&(t=!1),u(r(a.prototype),"stop",this).call(this),t&&(this.timer.setT(1),this.updateGameObject(this.target,this.timer),this.complete()),this}},{key:"update",value:function(t,e){if(!this.isRunning||!this.enable||!this.parent.active)return this;var i=this.target,n=this.timer;return n.update(t,e),n.isDelay||this.updateGameObject(i,n),this.emit("update",i,this),n.isDone&&this.complete(),this}},{key:"updateGameObject",value:function(t,e){}}]),a}(W),it=Phaser.Utils.Objects.GetValue,nt=Phaser.Utils.Objects.GetAdvancedValue,st=Phaser.Math.Linear,rt=function(t){s(a,t);var i=h(a);function a(t,n){var s;return e(this,a),(s=i.call(this,t,n)).scaleStart={},s.scaleEnd={},s.resetFromJSON(n),s.boot(),s}return n(a,[{key:"resetFromJSON",value:function(t){return u(r(a.prototype),"resetFromJSON",this).call(this,t),this.setMode(it(t,"mode",0)),this.setScaleRange(nt(t,"start",void 0),nt(t,"end",0)),this}},{key:"setMode",value:function(t){return "string"==typeof t&&(t=at[t]),this.mode=t,this}},{key:"setScaleRange",value:function(t,e){return "number"==typeof t?(this.startX=t,this.startY=t):(this.startX=nt(t,"x",this.parent.scaleX),this.startY=nt(t,"y",this.parent.scaleY)),"number"==typeof e?(this.endX=e,this.endY=e):(this.endX=nt(e,"x",void 0),this.endY=nt(e,"y",void 0)),this.hasScaleX=void 0!==this.startX&&void 0!==this.endX,this.hasScaleY=void 0!==this.startY&&void 0!==this.endY,this}},{key:"start",value:function(){if(this.timer.isRunning)return this;var t=this.parent;this.hasScaleX&&(t.scaleX=this.startX),this.hasScaleY&&(t.scaleY=this.startY);var e=this.repeat;return 2===this.mode&&-1!==e&&(e=2*(e+1)-1),this.timer.setDelay(this.delay).setDuration(this.duration).setRepeat(e),u(r(a.prototype),"start",this).call(this),this}},{key:"updateGameObject",value:function(t,e){var i=e.t;e.isOddIteration&&(i=1-i),i=this.easeFn(i),this.hasScaleX&&(t.scaleX=st(this.startX,this.endX,i)),this.hasScaleY&&(t.scaleY=st(this.startY,this.endY,i));}},{key:"complete",value:function(){return u(r(a.prototype),"complete",this).call(this),1===this.mode&&this.parent.destroy(),this}}]),a}(et),at={stop:0,destroy:1,yoyo:2},ot=function(t,e,i,n,s){var r,a;switch(void 0===n&&(n="Cubic"),i){case 0:case"x":r={x:0},a={x:t.scaleX};break;case 1:case"y":r={y:0},a={y:t.scaleY};break;default:r=0,a=t.scale;}var o={mode:0,start:r,end:a,duration:e,ease:n};return void 0===s?s=new rt(t,o):s.resetFromJSON(o),s.restart(),s},ht=function(t,e,i,n,s){void 0===n&&(n="Linear");var r={mode:0};switch(i){case 0:case"x":r.end={x:0};break;case 1:case"y":r.end={y:0};break;default:r.end=0;}return r.duration=e,r.ease=n,void 0===s?s=new rt(t,r):s.resetFromJSON(r),s.restart(),s},ut=Phaser.Loader.FILE_POPULATED,ct=Phaser.Utils.String.UUID,lt=function(t){s(r,Phaser.Loader.File);var i=h(r);function r(t,n){return e(this,r),n.hasOwnProperty("type")||(n.type="await"),n.hasOwnProperty("url")||(n.url=""),n.hasOwnProperty("key")||(n.key=ct()),i.call(this,t,n)}return n(r,[{key:"load",value:function(){if(this.state===ut)this.loader.nextFile(this,!0);else {var t=this.config,e=t.callback,i=t.scope,n=this.onLoad.bind(this),s=this.onError.bind(this);e?i?e.call(i,n,s):e(n,s):this.onLoad();}}},{key:"onLoad",value:function(){this.loader.nextFile(this,!0);}},{key:"onError",value:function(){this.loader.nextFile(this,!1);}}]),r}(),vt=Phaser.Utils.Objects.IsPlainObject,pt=function(t,e){var i;(i=t)&&"function"==typeof i?e={config:{callback:t,scope:e}}:vt(t)?(e=t).hasOwnProperty("config")||(e={config:e}):e={key:t,config:e};return this.addFile(new lt(this,e)),this};Phaser.Loader.FileTypesManager.register("rexAwait",pt);var ft=Phaser.Utils.Objects.GetValue,yt=function(t){s(a,t);var i=h(a);function a(t,n){var s;return e(this,a),void 0===n&&(n={}),n.hasOwnProperty("transitIn")||(n.transitIn=ot),n.hasOwnProperty("transitOut")||(n.transitOut=ht),n.destroy=!0,(s=i.call(this,t,n)).setProgressCallback(ft(n,"progress")),s.start(),s}return n(a,[{key:"setProgressCallback",value:function(t){return t||(t=D),this.progressCallback=t,this}},{key:"start",value:function(){var t=this;pt.call(this.scene.load,(function(e,i){t.once("close",e);})),this.requestOpen();}},{key:"onOpen",value:function(){this.scene.load.on("progress",this.onProgress,this),this.emit("open",this.parent,this),u(r(a.prototype),"onOpen",this).call(this),this.onProgress();}},{key:"onClose",value:function(){this.scene.load.off("progress",this.onProgress,this),this.emit("close",this.closeEventData),u(r(a.prototype),"onClose",this).call(this);}},{key:"onProgress",value:function(){var t,e,i,n=(t=this.scene,e=t.load,i=e.totalToLoad-1,1-(e.list.size+e.inflight.size-1)/i);this.progressCallback(this.parent,n),this.emit("progress",n),1===n&&this.requestClose();}}]),a}(A);return function(t){s(r,Phaser.Plugins.BasePlugin);var i=h(r);function r(t){return e(this,r),i.call(this,t)}return n(r,[{key:"add",value:function(t,e){return new yt(t,e)}}]),r}()}));