text: !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).rexbulletplugin=e()}(this,function(){"use strict";function r(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 t(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t}function o(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 c(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 h(n){var s=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 t,e=u(n);if(s){var i=u(this).constructor;t=Reflect.construct(e,arguments,i)}else t=e.apply(this,arguments);return c(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):[]}},s=Phaser.Utils.Objects.GetValue,f=function(){function i(t,e){r(this,i),this.parent=t,this._isRunning=!1,this.isPaused=!1,this.tickingState=!1,this.setEventEmitter(s(e,"eventEmitter",void 0)),this.setTickingMode(s(e,"tickingMode",1))}return t(i,[{key:"boot",value:function(){2!==this.tickingMode||this.tickingState||this.startTicking()}},{key:"shutdown",value:function(){this.destroyEventEmitter(),this.tickingState&&this.stopTicking()}},{key:"destroy",value:function(){this.shutdown()}},{key:"setTickingMode",value:function(t){"string"==typeof t&&(t=v[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)}}]),i}();Object.assign(f.prototype,e);function l(t,e,i,n){var s=t.body,r=s.velocity.x,o=s.velocity.y;e===r&&i===o||(s.setVelocity(e,i),n&&n(e,i,r,o))}var v={no:0,lazy:1,always:2},p=Phaser.Utils.Objects.GetValue,y=function(){o(s,f);var n=h(s);function s(t,e){var i;return r(this,s),(i=n.call(this,t,e)).gameObject=t,i.scene=t.scene,i.resetFromJSON(e),i.boot(),i}return t(s,[{key:"resetFromJSON",value:function(t){return this.gameObject.body||this.scene.physics.add.existing(this.gameObject,!1),this.setEnable(p(t,"enable",!0)),this.setSpeed(p(t,"speed",200)),this}},{key:"toJSON",value:function(){return{tickingMode:this.tickingMode}}},{key:"boot",value:function(){a(u(s.prototype),"boot",this).call(this),this.gameObject.once&&this.gameObject.on("destroy",this.destroy,this)}},{key:"shutdown",value:function(){a(u(s.prototype),"shutdown",this).call(this),this.gameObject=void 0,this.scene=void 0}},{key:"startTicking",value:function(){a(u(s.prototype),"startTicking",this).call(this),this.scene.events.on("update",this.update,this)}},{key:"stopTicking",value:function(){a(u(s.prototype),"stopTicking",this).call(this),this.scene&&this.scene.events.off("update",this.update,this)}},{key:"enable",get:function(){return this.isRunning},set:function(t){(this.isRunning=t)||l(this.gameObject,0,0)}},{key:"setEnable",value:function(t){return null==t&&(t=!0),this.enable=t,this}},{key:"setSpeed",value:function(t){return this.speed=t,this}},{key:"update",value:function(){if(!this.enable)return l(this.gameObject,0,0),this;var t=this.gameObject.rotation,e=this.speed*Math.cos(t),i=this.speed*Math.sin(t);return l(this.gameObject,e,i),this}}]),s}();return function(){o(i,Phaser.Plugins.BasePlugin);var e=h(i);function i(t){return r(this,i),e.call(this,t)}return t(i,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this)}},{key:"add",value:function(t,e){return new y(t,e)}}]),i}()});
  