UNPKG

phaser4-rex-plugins

Version:
2 lines (1 loc) 1.23 kB
var e,t;e=void 0,t=function(){const e=Phaser.Loader.FILE_POPULATED,t=Phaser.Utils.String.UUID;class o extends Phaser.Loader.File{constructor(e,o){o.hasOwnProperty("type")||(o.type="await"),o.hasOwnProperty("url")||(o.url=""),o.hasOwnProperty("key")||(o.key=t()),super(e,o)}load(){if(this.state===e)this.loader.nextFile(this,!0);else{var t=this.config,o=t.callback,i=t.scope;if(o){var n=this,s=!1,r=function(){s||(setTimeout((function(){n.onLoad()}),0),s=!0)},a=function(){s||(setTimeout((function(){n.onError()}),0),s=!0)};i?o.call(i,r,a):o(r,a)}else this.onLoad()}}onLoad(){this.loader.nextFile(this,!0)}onError(){this.loader.nextFile(this,!1)}}const i=Phaser.Utils.Objects.IsPlainObject,n=function(e,t){var n;return(n=e)&&"function"==typeof n?t={config:{callback:e,scope:t}}:i(e)?(t=e).hasOwnProperty("config")||(t={config:t}):t={key:e,config:t},this.addFile(new o(this,t)),this};class s extends Phaser.Plugins.BasePlugin{constructor(e){super(e),e.registerFileType("rexAwait",n)}addToScene(e){e.sys.load.rexAwait=n}}return s},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).rexawaitloaderplugin=t();