text: !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).rexinterceptionplugin=e()}(this,function(){"use strict";function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(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,n.key,n)}}function h(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function t(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}}),e&&i(t,e)}function u(t){return(u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function i(t,e){return(i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function s(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function c(n){return function(){var t,e=u(n);if(function(){if("undefined"!=typeof Reflect&&Reflect.construct&&!Reflect.construct.sham){if("function"==typeof Proxy)return 1;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),1}catch(t){return}}}()){var i=u(this).constructor;t=Reflect.construct(e,arguments,i)}else t=e.apply(this,arguments);return s(this,t)}}function a(t,e,i){return(a="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,i){var n=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}(t,e);if(n){var s=Object.getOwnPropertyDescriptor(n,e);return s.get?s.get.call(i):s.value}})(t,e,i||t)}var e={setEventEmitter:function(t,e){return void 0===e&&(e=Phaser.Events.EventEmitter),this._privateEE=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):[]}},r=Phaser.Utils.Objects.GetValue,l=function(){function i(t,e){o(this,i),this.parent=t,this._isRunning=!1,this.tickingState=!1,this.setEventEmitter(r(e,"eventEmitter",void 0)),this.setTickingMode(r(e,"tickingMode",1))}return h(i,[{key:"boot",value:function(){2!==this.tickingMode||this.tickingState||this.startTicking()}},{key:"shutdown",value:function(){this.destroyEventEmitter(),this.tickingState&&this.stopTicking()}},{key:"setTickingMode",value:function(t){"string"==typeof t&&(t=p[t]),this.tickingMode=t}},{key:"startTicking",value:function(){this.tickingState=!0}},{key:"stopTicking",value:function(){this.tickingState=!1}},{key:"start",value:function(){return this.isRunning=!0,this}},{key:"pause",value:function(){return this.isRunning=!1,this}},{key:"resume",value:function(){return this.isRunning=!0,this}},{key:"stop",value:function(){return this.isRunning=!1,this}},{key:"complete",value:function(){this.isRunning=!1,this.emit("complete",this.parent,this)}},{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()))}}]),i}();Object.assign(l.prototype,e);function f(t){return t instanceof v}var p={no:0,lazy:1,always:2},v=Phaser.Scene,y=Phaser.Math.Vector2,g=function(){function t(){o(this,t),this.position=new y,this.velocity=new y}return h(t,[{key:"init",value:function(t,e){return this.velocity.reset(),this.position.set(t,e),this}},{key:"update",value:function(t,e,i){return this.velocity.set(t-this.position.x,e-this.position.y),0===this.velocity.x&&0===this.velocity.y||this.velocity.setToPolar(this.velocity.angle(),this.velocity.length()/i),this.position.set(t,e),this}}]),t}(),d=Phaser.Utils.Objects.GetValue,m=Phaser.Math.Vector2,E=Phaser.Math.Distance.Between,k=Phaser.Math.Angle.BetweenPoints,_=function(){t(r,l);var s=c(r);function r(t,e){var i,n;return o(this,r),(i=s.call(this,t,e)).gameObject=t,i.scene=f(n=t)?n:n.scene&&f(n.scene)?n.scene:n.parent&&n.parent.scene&&f(n.parent.scene)?n.parent.scene:void 0,i._target=void 0,i.mySpeedMonitor=new g,i.targetSpeedMonitor=new g,i.predictedPosition=new m,i.resetFromJSON(e),i.boot(),i}return h(r,[{key:"resetFromJSON",value:function(t){return this.isRunning=d(t,"isRunning",!1),this.setEnable(d(t,"enable",!0)),this.setTarget(d(t,"target",void 0)),this}},{key:"toJSON",value:function(){return{isRunning:this.isRunning,duration:this.duration,tickingMode:this.tickingMode}}},{key:"boot",value:function(){a(u(r.prototype),"boot",this).call(this),this.gameObject.once&&this.gameObject.on("destroy",this.destroy,this)}},{key:"shutdown",value:function(){a(u(r.prototype),"shutdown",this).call(this),this.gameObject=void 0,this.scene=void 0}},{key:"destroy",value:function(){this.shutdown()}},{key:"startTicking",value:function(){a(u(r.prototype),"startTicking",this).call(this),this.scene.events.on("update",this.update,this)}},{key:"stopTicking",value:function(){a(u(r.prototype),"stopTicking",this).call(this),this.scene&&this.scene.events.off("update",this.update,this)}},{key:"setEnable",value:function(t){return null==t&&(t=!0),this.enable=t,this}},{key:"setTarget",value:function(t){return this.target=t,this}},{key:"update",value:function(t,e){if(!this.isRunning)return this;if(void 0===this.target)return this;if(!this.enable)return this.predictedPosition.copy(this.target),this;e/=1e3,this.mySpeedMonitor.update(this.gameObject.x,this.gameObject.y,e),this.targetSpeedMonitor.update(this.target.x,this.target.y,e);var i=this.targetSpeedMonitor.velocity.x-this.mySpeedMonitor.velocity.x,n=this.targetSpeedMonitor.velocity.y-this.mySpeedMonitor.velocity.y;if(0==i&&0==n)this.predictedPosition.copy(this.target);else{var s=E(0,0,i,n);t=E(this.target.x,this.target.y,this.gameObject.x,this.gameObject.y)/s;this.predictedPosition.set(this.target.x+this.targetSpeedMonitor.velocity.x*t,this.target.y+this.targetSpeedMonitor.velocity.y*t)}return this}},{key:"target",get:function(){return this._target},set:function(t){return null==t&&(t=void 0),this.target===t||(this.target&&this.target.off("destroy",this.setTarget,this),t&&t.on("destroy",this.setTarget,this),this._target=t),this.isRunning?void 0===this.target&&a(u(r.prototype),"stop",this).call(this):void 0!==this.target&&(this.mySpeedMonitor.init(this.gameObject.x,this.gameObject.y),this.targetSpeedMonitor.init(this.target.x,this.target.y),a(u(r.prototype),"start",this).call(this)),this}},{key:"predictedAngle",get:function(){return k(this.gameObject,this.predictedPosition)}}]),r}();return function(){t(i,Phaser.Plugins.BasePlugin);var e=c(i);function i(t){return o(this,i),e.call(this,t)}return h(i,[{key:"add",value:function(t,e){return new _(t,e)}}]),i}()});
  