UNPKG

phaser3-rex-plugins

Version:
2 lines (1 loc) 30.3 kB
var t,e;t=void 0,e=function(){var t=!1,e={renderWebGL:function(t,e,i){if(i.addToRenderList(e),e.layerRendererEnable){var r=e.rendererLayer;if(r){var s=r.list,a=s.length;if(0!==a){r.depthSort(),t.pipelines.preBatch(e);var n=-1!==e.blendMode;n||t.setBlendMode(0);for(var l=0;l<a;l++){var h=s[l];if(h.willRender(i)){n||h.blendMode===t.currentBlendMode||t.setBlendMode(h.blendMode);var o=h.mask;o&&o.preRenderWebGL(t,h,i);var d=h.type;d!==t.currentType&&(t.newType=!0,t.currentType=d),t.nextTypeMatch=l<a-1&&s[l+1].type===t.currentType,h.renderWebGL(t,h,i),o&&o.postRenderWebGL(t,i),t.newType=!1}}t.pipelines.postBatch(e)}}}},renderCanvas:function(t,e,i){if(i.addToRenderList(e),e.layerRendererEnable){var r=e.rendererLayer;if(r){var s=r.list;if(0!==s.length){r.depthSort();var a=-1!==e.blendMode;a||t.setBlendMode(0),e.mask&&e.mask.preRenderCanvas(t,null,i);for(var n=0;n<s.length;n++){var l=s[n];l.willRender(i)&&(a||l.blendMode===t.currentBlendMode||t.setBlendMode(l.blendMode),l.renderCanvas(t,l,i))}e.mask&&e.mask.postRenderCanvas(t)}}}}};const i=Phaser.Structs.List,r=Phaser.Utils.Array.StableSort,s=Phaser.GameObjects.Events,a=Phaser.Scenes.Events;class n extends i{constructor(t){super(t.scene),this.parent=t,this.scene=t.scene,this.events=this.scene.sys.events,this.active=!1,this.sortChildrenFlag=!1,this.addCallback=this.addChildCallback,this.removeCallback=this.removeChildCallback}addChildCallback(t){var e=t.displayList;e&&e!==this&&t.removeFromDisplayList(),t.parentContainer&&t.parentContainer.remove(t),t.displayList||(this.queueDepthSort(),t.displayList=this,t.emit(s.ADDED_TO_SCENE,t,this.scene),this.events.emit(a.ADDED_TO_SCENE,t,this.scene))}removeChildCallback(t){this.queueDepthSort(),t.displayList===this&&(t.displayList=null),t.emit(s.REMOVED_FROM_SCENE,t,this.scene),this.events.emit(a.REMOVED_FROM_SCENE,t,this.scene)}queueDepthSort(){return this.sortChildrenFlag=!0,this}depthSort(){return!this.sortChildrenFlag||this.list.length<2?(this.sortChildrenFlag=!1,this):(r(this.list,this.sortByDepth),this.sortChildrenFlag=!1,this)}sortByDepth(t,e){return t._depth-e._depth}}!function(e){if(!t){void 0===e&&(e=60);var i=Phaser.VERSION.split("."),r=parseInt(i[0]);if(3===r){var s=parseInt(i[1]);s<e&&console.error(`Minimum supported version : ${r}.${s}`)}else console.error(`Can't supported version : ${r}`);t=!0}}();const l=Phaser.GameObjects.Zone,h=Phaser.Utils.Array.Add,o=Phaser.Utils.Array.Remove;class d extends l{constructor(t,e,i,r,s){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===s&&(s=1),super(t,e,i,r,s),this.children=[],this.layerRendererEnable=!1,this.rendererLayer=void 0}destroy(t){if(this.scene&&!this.ignoreDestroy){if(t)for(var e,i=this.children.length-1;i>=0;i--)(e=this.children[i]).parentContainer||e.displayList&&e.displayList!==this.rendererLayer||e.destroy(t);this.clear(!t),super.destroy(t),this.rendererLayer=void 0}}contains(t){return-1!==this.children.indexOf(t)}add(t){return h(this.children,t,0,(function(t){t.once("destroy",this.onChildDestroy,this),this.addChildCallback(t)}),this),this}remove(t,e){return o(this.children,t,(function(t){t.off("destroy",this.onChildDestroy,this),this.removeChildCallback(t,e),e&&t.destroy()}),this),this}addChildCallback(t){var e=this.rendererLayer;e&&e.add(t)}removeChildCallback(t,e){var i=this.rendererLayer;i&&i.remove(t)}onChildDestroy(t,e){this.remove(t,!1)}clear(t){for(var e,i=this.children.slice(),r=0,s=i.length;r<s;r++)(e=i[r])&&(e.off("destroy",this.onChildDestroy,this),this.removeChildCallback(e,t),t&&e.destroy());return this.children.length=0,this}enableLayerRenderer(){if(this.layerRendererEnable)return this;this.layerRendererEnable=!0;var t=new n(this);this.rendererLayer=t;for(var e=0,i=this.children.length;e<i;e++)this.addChildCallback(this.children[e]);return t.queueDepthSort(),this}}const c=Phaser.GameObjects.Components;Phaser.Class.mixin(d,[c.Alpha,c.Flip]),Object.assign(d.prototype,e);var u=function(t,e){var i;if(void 0===e)t.hasOwnProperty("rexContainer")&&(i=t.rexContainer.parent);else for(i=u(t);i&&i.name!==e;)i=u(i);return i};const y=Phaser.Math.DegToRad,p=Phaser.Math.RadToDeg;var v=function(t){if(!t.hasOwnProperty("rexContainer")){var e={parent:null,self:null,layer:null,x:0,y:0,syncPosition:!0,rotation:0,syncRotation:!0,scaleX:0,scaleY:0,syncScale:!0,alpha:0,syncAlpha:!0,syncScrollFactor:!0,syncCameraFilter:!0,syncDisplayList:!0,visible:!0,active:!0};Object.defineProperty(e,"angle",{get:function(){return p(this.rotation)},set:function(t){this.rotation=y(t)}}),Object.defineProperty(e,"displayWidth",{get:function(){return t.width*this.scaleX},set:function(e){this.scaleX=e/t.width}}),Object.defineProperty(e,"displayHeight",{get:function(){return t.height*this.scaleY},set:function(e){this.scaleY=e/t.height}}),t.rexContainer=e}return t.rexContainer},C={setParent(t,e){void 0===e&&(e=this);var i=v(t);return e?(i.parent=e,i.self=t):(i.parent=null,i.self=null),this},getParent(t,e){return"string"==typeof t&&(e=t,t=void 0),void 0===t&&(t=this),u(t,e)},getTopmostParent(t){return void 0===t&&(t=this),function(t){for(var e=u(t);e;)t=e,e=u(e);return t}(t)}};const f=Phaser.Utils.Objects.GetValue,g=d.prototype.add;var b=function(t,e){this.setParent(t);var i=v(t);return x(i,e),this.resetChildState(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t).updateCameraFilter(t),g.call(this,t),L.call(this,t,i),this},m=function(t,e){this.setParent(t);var i=v(t);return x(i,e),i.x=t.x,i.y=t.y,i.rotation=t.rotation,i.scaleX=t.scaleX,i.scaleY=t.scaleY,i.alpha=t.alpha,i.visible=t.visible,i.active=t.active,this.updateChildPosition(t).updateChildAlpha(t).updateChildVisible(t).updateChildActive(t).updateChildScrollFactor(t).updateChildMask(t),g.call(this,t),L.call(this,t,i),this},x=function(t,e){void 0===e&&(e=!0),"boolean"==typeof e?(t.syncPosition=e,t.syncRotation=e,t.syncScale=e,t.syncAlpha=e,t.syncScrollFactor=e,t.syncCameraFilter=e,t.syncDisplayList=e):(t.syncPosition=f(e,"syncPosition",!0),t.syncRotation=f(e,"syncRotation",!0),t.syncScale=f(e,"syncScale",!0),t.syncAlpha=f(e,"syncAlpha",!0),t.syncScrollFactor=f(e,"syncScrollFactor",!0),t.syncCameraFilter=f(e,"syncCameraFilter",!0),t.syncDisplayList=f(e,"syncDisplayList",!0))},L=function(t,e){this.addToParentContainer(t),e.syncDisplayList&&this.addToPatentLayer(t)},P={add(t){return Array.isArray(t)?this.addMultiple(t):b.call(this,t),this},pin(t,e){return Array.isArray(t)?this.addMultiple(t,e):b.call(this,t,e),this},addMultiple(t){for(var e=Array.from(arguments),i=0,r=t.length;i<r;i++)e[0]=t[i],this.add.apply(this,e);return this},addLocal(t){return Array.isArray(t)?this.addMultiple(t):m.call(this,t),this},pinLocal(t,e){return Array.isArray(t)?this.addMultiple(t,e):m.call(this,t,e),this},addLocalMultiple(t){for(var e=0,i=t.length;e<i;e++)m.call(this,t[e]);return this}};const S=d.prototype.remove,A=d.prototype.clear;var R={remove(t,e){return u(t)!==this||(this.setParent(t,null),S.call(this,t,e)),this},unpin(t,e){return u(t)!==this||(this.setParent(t,null),S.call(this,t,e)),this},clear(t){for(var e=this.children,i=0,r=e.length;i<r;i++){var s=e[i];this.setParent(s,null)}return A.call(this,t),this}},k={getLocalState:t=>v(t),resetChildState(t){return this.resetChildPositionState(t).resetChildVisibleState(t).resetChildAlphaState(t).resetChildActiveState(t),this},resetChildrenState(t){for(var e=0,i=t.length;e<i;e++)this.resetChildState(t[e]);return this},syncProperties(){return this.syncPosition().syncVisible().syncAlpha().syncActive().syncScrollFactor().syncMask(),this}},F={worldToLocal(t){t.x-=this.x,t.y-=this.y;var e=Math.cos(-this.rotation),i=Math.sin(-this.rotation),r=t.x,s=t.y;return t.x=r*e-s*i,t.y=r*i+s*e,t.x/=this.scaleX,t.y/=this.scaleY,t},localToWorld(t){t.x*=this.scaleX,t.y*=this.scaleY;var e=Math.cos(this.rotation),i=Math.sin(this.rotation),r=t.x,s=t.y;return t.x=r*e-s*i,t.y=r*i+s*e,t.x+=this.x,t.y+=this.y,t}},M=function(t,e){return t===e?1:t/e},E={updateChildPosition(t){t.isRexContainerLite&&(t.syncChildrenEnable=!1);var e=v(t),i=e.parent;return e.syncPosition&&(t.x=e.x,t.y=e.y,i.localToWorld(t)),e.syncRotation&&(t.rotation=e.rotation+i.rotation),e.syncScale&&(t.scaleX=e.scaleX*i.scaleX,t.scaleY=e.scaleY*i.scaleY),t.isRexContainerLite&&(t.syncChildrenEnable=!0,t.syncPosition()),this},syncPosition(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildPosition,this),this},resetChildPositionState(t){var e=v(t),i=e.parent;return e.x=t.x,e.y=t.y,i.worldToLocal(e),e.scaleX=M(t.scaleX,i.scaleX),e.scaleY=M(t.scaleY,i.scaleY),e.rotation=t.rotation-i.rotation,this},setChildPosition(t,e,i){return t.x=e,t.y=i,this.resetChildPositionState(t),this},setChildLocalPosition(t,e,i){var r=v(t);return r.x=e,r.y=i,this.updateChildPosition(t),this},resetLocalPositionState(){var t=v(this).parent;return t&&t.resetChildPositionState(this),this},getChildLocalX:t=>v(t).x,getChildLocalY:t=>v(t).y};const T=Phaser.Math.DegToRad;var w={updateChildRotation(t){var e=v(t),i=e.parent;return e.syncRotation&&(t.rotation=i.rotation+e.rotation),this},syncRotation(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildRotation,this),this},resetChildRotationState(t){var e=v(t),i=e.parent;return e.rotation=t.rotation-i.rotation,this},setChildRotation(t,e){return t.rotation=e,this.resetChildRotationState(t),this},setChildAngle(t,e){return t.angle=e,this.resetChildRotationState(t),this},setChildLocalRotation(t,e){return v(t).rotation=e,this.updateChildRotation(t),this},setChildLocalAngle(t,e){return v(t).rotation=T(e),this.updateChildRotation(t),this},resetLocalRotationState(){var t=v(this).parent;return t&&t.resetChildRotationState(this),this},getChildLocalRotation:t=>v(t).rotation},X={updateChildScale(t){var e=v(t),i=e.parent;return e.syncScale&&(t.scaleX=i.scaleX*e.scaleX,t.scaleY=i.scaleY*e.scaleY),this},syncScale(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScale,this),this},resetChildScaleState(t){var e=v(t),i=e.parent;return e.scaleX=M(t.scaleX,i.scaleX),e.scaleY=M(t.scaleY,i.scaleY),this},setChildScale(t,e,i){return void 0===i&&(i=e),t.scaleX=e,t.scaleY=i,this.resetChildScaleState(t),this},setChildScaleX(t,e){return t.scaleX=e,this.resetChildScaleState(t),this},setChildScaleY(t,e){return t.scaleY=e,this.resetChildScaleState(t),this},setChildLocalScale(t,e,i){void 0===i&&(i=e);var r=v(t);return r.scaleX=e,r.scaleY=i,this.updateChildScale(t),this},setChildLocalScaleX(t,e){return v(t).scaleX=e,this.updateChildScale(t),this},setChildLocalScaleY(t,e){return v(t).scaleY=e,this.updateChildScale(t),this},setChildDisplaySize(t,e,i){return t.setDisplaySize(e,i),this.resetChildScaleState(t),this},resetLocalScaleState(){var t=v(this).parent;return t&&t.resetChildScaleState(this),this},getChildLocalScaleX:t=>v(t).scaleX,getChildLocalScaleY:t=>v(t).scaleY},Y={updateChildVisible(t){var e=v(t),i=e.parent,r=!e.hasOwnProperty("maskVisible")||e.maskVisible,s=!i||i.visible;return t.visible=s&&e.visible&&r,this},syncVisible(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildVisible,this),this},resetChildVisibleState(t){var e=v(t);return e.hasOwnProperty("maskVisible")&&delete e.maskVisible,e.visible=t.visible,this},setChildVisible(t,e){return this.setChildLocalVisible(t,e),this},setChildLocalVisible(t,e){return void 0===e&&(e=!0),v(t).visible=e,this.updateChildVisible(t),this},setChildMaskVisible(t,e){return void 0===e&&(e=!0),v(t).maskVisible=e,this.updateChildVisible(t),this},resetLocalVisibleState(){var t=v(this).parent;return t&&t.resetChildVisibleState(this),this},getChildLocalVisible:t=>v(t).visible},O={updateChildAlpha(t){var e=v(t),i=e.parent;return e.syncAlpha&&(t.alpha=i.alpha*e.alpha),this},syncAlpha(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildAlpha,this),this},resetChildAlphaState(t){var e=v(t),i=e.parent;return e.alpha=M(t.alpha,i.alpha),this},setChildAlpha(t,e){return t.alpha=e,this.resetChildAlphaState(t),this},setChildLocalAlpha(t,e){return v(t).alpha=e,this.updateChildAlpha(t),this},resetLocalAlphaState(){var t=v(this).parent;return t&&t.resetChildAlphaState(this),this},getChildLocalAlpha:t=>v(t).alpha},_={updateChildActive(t){var e=v(t),i=e.parent;return t.active=i.active&&e.active,this},syncActive(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildActive,this),this},resetChildActiveState(t){return v(t).active=t.active,this},setChildActive(t,e){return t.active=e,this.resetChildActiveState(t),this},setChildLocalActive(t,e){return void 0===e&&(e=!0),v(t).active=e,this.updateChildActive(t),this},resetLocalActiveState(){var t=v(this).parent;return t&&t.resetChildActiveState(this),this},getChildLocalActive:t=>v(t).active},D={updateChildScrollFactor(t){var e=v(t),i=e.parent;return e.syncScrollFactor&&(t.scrollFactorX=i.scrollFactorX,t.scrollFactorY=i.scrollFactorY),this},syncScrollFactor(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildScrollFactor,this),this}},V={updateCameraFilter(t){var e=v(t),i=e.parent;return e.syncCameraFilter&&(t.cameraFilter=i.cameraFilter),this},syncCameraFilter(){return this.syncChildrenEnable&&this.children.forEach(this.updateCameraFilter,this),this}},B={updateChildMask(t){return null==this.mask||(this.mask.hasOwnProperty("geometryMask")?this.mask.geometryMask:this.mask.bitmapMask)!==t&&(t.mask=this.mask),this},syncMask(){return this.syncChildrenEnable&&this.children.forEach(this.updateChildMask,this),this},setMask(t){return this.mask=t,this},clearChildrenMask(){for(var t=this.children,e=0,i=t.length;e<i;e++){var r=t[e];r.clearMask&&r.clearMask(!1),r.hasOwnProperty("isRexContainerLite")||this.setChildMaskVisible(r)}return this},clearMask(t){return void 0===t&&(t=!1),t&&this.mask&&mask.destroy(),this._mask=null,this.setChildMaskVisible(this),this.clearChildrenMask(),this}},G=function(t,e){if(t.length<=1)return t;var i;void 0===e&&(e=!1);for(var r=0,s=t.length;r<s;r++){var a=t[r];if(a.displayList?i=a.displayList:a.parentContainer&&(i=a.parentContainer.list),i)break}return i||(i=a.scene.sys.displayList),i.depthSort&&(i.depthSort(),i=i.list),e?t.sort((function(t,e){return i.indexOf(e)-i.indexOf(t)})):t.sort((function(t,e){return i.indexOf(t)-i.indexOf(e)})),t},j=function(t,e){var i=e?e.displayList:void 0,r=e?e.parentContainer:void 0;return t.filter((function(t){var s=t.displayList,a=t.parentContainer;return!(!s&&!a||e&&(s?s!==i:!a||a!==r))}))},U={setDepth(t,e){if(this.depth=t,!this.layerRendererEnable&&!e&&this.children)for(var i=this.getAllChildren(),r=0,s=i.length;r<s;r++)i[r].depth=t;return this},swapDepth(t){var e=this.depth,i=t.depth;return this.setDepth(i),t.setDepth(e),this},incDepth(t){if(this.depth+=t,!this.layerRendererEnable&&this.children)for(var e=this.getAllChildren(),i=0,r=e.length;i<r;i++)e[i].depth+=t;return this},bringToTop(){var t=this.displayList;if(!t)return this;if(this.layerRendererEnable)t.exists(this)&&t.bringToTop(this);else{var e=this.getAllChildren([this]);G(e,!1);for(var i=0,r=e.length;i<r;i++){var s=e[i];t.exists(s)&&t.bringToTop(s)}}return this},bringMeToTop(){return this.bringToTop()},sendToBack(){var t=this.displayList;if(!t)return this;if(this.layerRendererEnable)t.exists(this)&&t.sendToBack(this);else{var e=this.getAllChildren([this]);G(e,!0);for(var i=0,r=e.length;i<r;i++){var s=e[i];t.exists(s)&&t.sendToBack(s)}}return this},sendMeToBack(){return this.sendToBack()},moveDepthBelow(t){var e=this.displayList;if(!e)return this;if(t.displayList!==e)return this;if(this.layerRendererEnable)e.exists(this)&&e.moveBelow(t,this);else{var i=this.getAllChildren([this]);G(i,!1);for(var r=0,s=i.length;r<s;r++){var a=i[r];if(e.exists(a)){e.moveBelow(t,a);break}}}return this},moveMyDepthBelow(t){return this.moveDepthBelow(t)},moveDepthAbove(t){var e=this.displayList;if(!e)return this;if(t.displayList!==e)return this;if(this.layerRendererEnable)e.exists(this)&&e.moveAbove(t,this);else{var i=this.getAllChildren([this]);G(i,!0);for(var r=0,s=i.length;r<s;r++){var a=i[r];if(e.exists(a)){e.moveAbove(t,a);break}}}return this},moveMyDepthAbove(t){return this.moveDepthAbove(t)},bringChildToTop(t){if(t===this&&this.layerRendererEnable)return this;var e,i;if(t!==this&&t.isRexContainerLite&&!t.layerRendererEnable?(e=t.getAllChildren([t]),e=j(e,t),e=G(e,!1)):e=[t],this.layerRendererEnable)i=this;else{var r=this.getAllChildren([this]);r=j(r,t),i=(r=G(r,!1))[r.length-1]}for(var s=0,a=e.length;s<a;s++){var n=e[s];i!==n&&(n!==this&&i.displayList!==n.displayList||(i.displayList.moveAbove(n,i),i=n))}return this},sendChildToBack(t){if(t===this&&this.layerRendererEnable)return this;var e,i;if(t!==this&&t.isRexContainerLite&&!t.layerRendererEnable?(e=t.getAllChildren([t]),e=j(e,t),e=G(e,!1)):e=[t],this.layerRendererEnable)i=this;else{var r=this.getAllChildren([this]);r=j(r,t),i=(r=G(r,!1))[0]}for(var s=e.length-1;s>=0;s--){var a=e[s];i!==a&&(a!==this&&i.displayList!==a.displayList||(i.displayList.moveBelow(a,i),i=a))}return this}},W=function(t,e){if(!e(t)&&t.isRexContainerLite)for(var i=t.children,r=0,s=i.length;r<s;r++)W(i[r],e)},N=function(t,e){for(var i=[t];i.length>0;){var r=i.shift();!e(r)&&r.isRexContainerLite&&i.push(...r.children)}};const z=Phaser.Utils.Array;var H={getChildren(t){if(t)for(var e=0,i=this.children.length;e<i;e++)t.push(this.children[e]);else t=this.children;return t},getAllChildren(t){void 0===t&&(t=[]);var e=this;return N(e,(function(i){i!==e&&t.push(i)})),t},getAllVisibleChildren(t){void 0===t&&(t=[]);var e=this;return N(e,(function(i){if(i!==e)return!i.visible||void t.push(i)})),t},bfs(t,e){return void 0===e&&(e=this),N(e,t),this},dfs(t,e){return void 0===e&&(e=this),W(e,t),this},contains(t){var e=u(t);return!!e&&(e===this||this.contains(e))},getByName(t,e){if(e){for(var i,r,s=[this];s.length;)for(var a=0,n=(i=s.shift()).children.length;a<n;a++){if((r=i.children[a]).name===t)return r;r.isRexContainerLite&&s.push(r)}return null}return z.GetFirst(this.children,"name",t)},getRandom(t,e){return z.GetRandom(this.children,t,e)},getFirst(t,e,i,r){return z.GetFirstElement(this.children,t,e,i,r)},getAll(t,e,i,r){return z.GetAll(this.children,t,e,i,r)},count(t,e,i,r){return z.CountAllMatching(this.children,t,e,i,r)},swap(t,e){return z.Swap(this.children,t,e),this},setAll(t,e,i,r){return z.SetAll(this.children,t,e,i,r),this}},q=function(t){for(var e=[],i=0,r=t.length;i<r;i++){var s=t[i];s.hasOwnProperty("rexContainer")&&e.push(s.rexContainer)}return e},I=function(t,e,i){if(i.parent){var r=i.parent,s=i.self;switch(e){case"x":case"y":r.updateChildPosition(s);break;case"angle":case"rotation":r.updateChildRotation(s);break;case"scaleX":case"scaleY":case"displayWidth":case"displayHeight":r.updateChildScale(s);break;case"alpha":r.updateChildAlpha(s);break;default:r.updateChildPosition(s),r.updateChildRotation(s),r.updateChildScale(s),r.updateChildAlpha(s)}}else t.remove()},$={tweenChild(t){var e=t.targets;Array.isArray(e)||(e=[e]);var i=this.scene||function(t){for(var e=0,i=t.length;e<i;e++){var r=t[e].scene;if(r)return r}return null}(e);if(i){t.targets=q(e);var r=i.tweens.add(t);return r.on("update",I),r}},tweenSelf(t){return t.targets=[this],this.tweenChild(t)},createTweenChildConfig(t){var e=t.targets;e&&(Array.isArray(e)||(e=[e]),t.targets=q(e));var i=t.onUpdate;return t.onUpdate=function(t,e){i&&i(t,e),I(t,void 0,e)},t},tween(t){var e=this.scene;return t.targets||(t.targets=this),e.tweens.add(t)}};Phaser.GameObjects.Container;const Z=Phaser.GameObjects.Layer;var J=function(t){return t instanceof Z},K=function(t){var e=t.getAllChildren([t]);return e=e.filter((function(t){return!!t.displayList||!!t.parentContainer}))},Q=function(t){var e=K(this);-1===e.indexOf(this)&&e.push(this),G(e),t.add(e)},tt=function(t,e,i){if(this.scene){var r=K(this);G(r,e),t.remove(r),i&&r.forEach((function(t){t.addToDisplayList()}))}},et={addToContainer(t){return this._setParentContainerFlag=!0,Q.call(this,t),this._setParentContainerFlag=!1,this},addToLayer(t){return Q.call(this,t),this},removeFromContainer(){return this.parentContainer?(this._setParentContainerFlag=!0,tt.call(this,this.parentContainer,!0,!1),this._setParentContainerFlag=!1,this):this},removeFromLayer(t){return void 0===t&&(t=!0),J(this.displayList)?(tt.call(this,this.displayList,!1,t),this):this},getParentContainer(){if(this.parentContainer)return this.parentContainer;for(var t=this.getParent();t;){var e=t.parentContainer;if(e)return e;t=t.getParent()}return null},addToParentContainer(t){if(!t.displayList)return this;var e=this.getParentContainer();return e?(t.isRexContainerLite?t.addToContainer(e):e.add(t),this):this},addToPatentLayer(t){if(!t.displayList)return this;var e=this.displayList;return e===t.displayList||J(e)&&(t.isRexContainerLite?t.addToLayer(e):e.add(t)),this}},it=function(){if(this.rendererLayer)return this.rendererLayer;for(var t=this.getParent();t;){if(t.rendererLayer)return t.rendererLayer;t=t.getParent()}return null},rt={hasLayer(){return this.layerRendererEnable},enableLayer(){return this.enableLayerRenderer(),this},getLayer(){return this.enableLayerRenderer(),this},addChildCallback(t){if(t.displayList){var e=it.call(this);e&&e!==t.displayList&&(t.isRexContainerLite?t.addToLayer(e):e.add(t),v(t).layer=e)}},removeChildCallback(t,e){var i=v(t),r=i.layer;r&&(t.isRexContainerLite?t.removeFromLayer(!0):r.remove(t),i.layer=null)}},st=function(t){return void 0!==t.displayWidth?t.displayWidth:t.width},at=function(t){return void 0!==t.displayHeight?t.displayHeight:t.height};const nt=Phaser.Geom.Rectangle,lt=Phaser.Math.Vector2,ht=Phaser.Math.RotateAround,ot=Phaser.GameObjects.Container;var dt=function(t,e){if(void 0===e?e=new nt:!0===e&&(void 0===ct&&(ct=new nt),e=ct),t.getBounds&&!(t instanceof ot))return t.getBounds(e);var i,r,s,a,n,l,h,o;if(t.parentContainer){var d=t.parentContainer.getBoundsTransformMatrix();ut(t,e),d.transformPoint(e.x,e.y,e),i=e.x,r=e.y,yt(t,e),d.transformPoint(e.x,e.y,e),s=e.x,a=e.y,pt(t,e),d.transformPoint(e.x,e.y,e),n=e.x,l=e.y,vt(t,e),d.transformPoint(e.x,e.y,e),h=e.x,o=e.y}else ut(t,e),i=e.x,r=e.y,yt(t,e),s=e.x,a=e.y,pt(t,e),n=e.x,l=e.y,vt(t,e),h=e.x,o=e.y;return e.x=Math.min(i,s,n,h),e.y=Math.min(r,a,l,o),e.width=Math.max(i,s,n,h)-e.x,e.height=Math.max(r,a,l,o)-e.y,e},ct=void 0,ut=function(t,e,i){return void 0===e?e=new lt:!0===e&&(void 0===Ct&&(Ct=new lt),e=Ct),t.getTopLeft?t.getTopLeft(e,i):(e.x=t.x-st(t)*t.originX,e.y=t.y-at(t)*t.originY,ft(t,e,i))},yt=function(t,e,i){return void 0===e?e=new lt:!0===e&&(void 0===Ct&&(Ct=new lt),e=Ct),t.getTopRight?t.getTopRight(e,i):(e.x=t.x-st(t)*t.originX+st(t),e.y=t.y-at(t)*t.originY,ft(t,e,i))},pt=function(t,e,i){return void 0===e?e=new lt:!0===e&&(void 0===Ct&&(Ct=new lt),e=Ct),t.getBottomLeft?t.getBottomLeft(e,i):(e.x=t.x-st(t)*t.originX,e.y=t.y-at(t)*t.originY+at(t),ft(t,e,i))},vt=function(t,e,i){return void 0===e?e=new lt:!0===e&&(void 0===Ct&&(Ct=new lt),e=Ct),t.getBottomRight?t.getBottomRight(e,i):(e.x=t.x-st(t)*t.originX+st(t),e.y=t.y-at(t)*t.originY+at(t),ft(t,e,i))},Ct=void 0,ft=function(t,e,i){return void 0===i&&(i=!1),0!==t.rotation&&ht(e,t.x,t.y,t.rotation),i&&t.parentContainer&&t.parentContainer.getBoundsTransformMatrix().transformPoint(e.x,e.y,e),e};const gt=Phaser.Geom.Rectangle,bt=Phaser.Geom.Rectangle.Union;var mt,xt=function(t,e){var i=Array.isArray(t);if(void 0===e?e=i?[]:{}:function(t){if("object"!=typeof t||null===t)return t;if(Array.isArray(t))t.length=0;else for(var e in t)delete t[e]}(e),i){e.length=t.length;for(var r=0,s=t.length;r<s;r++)e[r]=t[r]}else for(var a in t)e[a]=t[a];return e};const Lt=Phaser.GameObjects.GameObject,Pt=Phaser.GameObjects.Layer;var St=Phaser.Utils.Objects.GetValue,At=function(t){if(t){var e,i,r=t.gameObjects,s=t.renderTexture,a=t.saveTexture,n=St(t,"x",void 0),l=St(t,"y",void 0),h=St(t,"width",void 0),o=St(t,"height",void 0),d=St(t,"originX",0),c=St(t,"originY",0),u=St(t,"padding",0);if(void 0===h||void 0===o||void 0===n||void 0===l){var y=function(t,e){var i;void 0===e?e=new gt:!0===e&&(void 0===mt&&(mt=new gt),e=mt),e.setTo(0,0,0,0);for(var r=!0,s=0,a=t.length;s<a;s++)if((i=t[s]).getBounds){var n=dt(i,!0);r?(e.setTo(n.x,n.y,n.width,n.height),r=!1):bt(n,e,e)}return e}(r,!0);void 0!==n&&void 0!==l?(h=2*Math.max(n-y.left,y.right-n),o=2*Math.max(l-y.top,y.bottom-l),d=.5,c=.5):(n=y.x,l=y.y,h=y.width,o=y.height,d=0,c=0),e=y.x,i=y.y}else e=n+(0-d)*h,i=l+(0-c)*o;e-=u,i-=u,h+=2*u,o+=2*u;var p,v=r[0].scene,C=v.sys.textures;return a&&!s&&(s=C.addDynamicTexture(a,h,o)),s||(s=v.add.renderTexture(0,0,h,o)),s.setPosition&&s.setPosition(n,l),s.width===h&&s.height===o||s.setSize(h,o),s.setOrigin&&s.setOrigin(d,c),s.camera.setScroll(e,i),r=G(xt(r)),s.draw(r),a&&((p=s)instanceof Lt||p instanceof Pt?s.saveTexture(a):s.key!==a&&C.renameTexture(s.key,key)),s}},Rt={snapshot(t){var e=this.scaleX,i=this.scaleY,r=1===e&&1===i;r||this.setScale(1),void 0===t&&(t={}),t.gameObjects=this.getAllVisibleChildren(),t.x=this.x,t.y=this.y,t.originX=this.originX,t.originY=this.originY;var s=At(t),a=!!s.scene;return r||(this.setScale(e,i),a&&s.setScale(e,i)),a?s:this}};const kt=Phaser.Utils.Objects.GetValue;var Ft=function(t,e,i,r,s,a,n,l){if(t.getBounds||void 0!==t.width&&void 0!==t.height){var h=ut(t,Mt[0],l);h.x-=n,h.y-=n;var o=yt(t,Mt[1],l);o.x+=n,o.y-=n;var d=vt(t,Mt[2],l);d.x+=n,d.y+=n;var c=pt(t,Mt[3],l);c.x-=n,c.y+=n,null!==s&&e.fillStyle(s,a).fillPoints(Mt,!0,!0),null!==i&&e.lineStyle(r,i).strokePoints(Mt,!0,!0)}},Mt=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];const Et=Phaser.Utils.Objects.GetValue,Tt=Phaser.Math.RotateAround;var wt={changeOrigin:function(t,e){this.syncChildrenEnable=!1,function(t,e,i){void 0===i&&(i=e);var r={x:(e-t.originX)*t.displayWidth,y:(i-t.originY)*t.displayHeight};Tt(r,0,0,t.rotation),t.originX=e,t.originY=i,t.x=t.x+r.x,t.y=t.y+r.y}(this,t,e),this.syncChildrenEnable=!0;for(var i=this.getAllChildren(),r=0,s=i.length;r<s;r++)this.resetChildPositionState(i[r]);return this},drawBounds:function(t,e){var i=Et(e,"drawContainer",!0),r=Et(e,"children");return void 0===r&&(r=this.getAllVisibleChildren([this])),i||(r=r.filter((function(t){return!t.isRexContainerLite}))),function(t,e,i){var r,s,a,n,l,h;if("number"==typeof i?r=i:(r=kt(i,"color"),s=kt(i,"lineWidth"),a=kt(i,"fillColor"),n=kt(i,"fillAlpha"),l=kt(i,"padding"),h=kt(i,"includeParent")),void 0===r&&(r=16777215),void 0===s&&(s=1),void 0===a&&(a=null),void 0===n&&(n=1),void 0===l&&(l=0),void 0===h&&(h=!0),Array.isArray(t))for(var o=0,d=t.length;o<d;o++)Ft(t[o],e,r,s,a,n,l,h);else Ft(t,e,r,s,a,n,l,h)}(r,t,e),this}};Object.assign(wt,C,P,R,k,F,E,w,X,Y,O,_,D,V,B,U,H,$,et,rt,Rt);class Xt extends d{constructor(t,e,i,r,s,a){Array.isArray(r)&&(a=r,r=void 0,s=void 0),super(t,e,i,r,s),this.type="rexContainerLite",this.isRexContainerLite=!0,this.syncChildrenEnable=!0,this._active=!0,this._mask=null,this._scrollFactorX=1,this._scrollFactorY=1,this._cameraFilter=0,a&&this.add(a)}destroy(t){this.scene&&!this.ignoreDestroy&&(this.syncChildrenEnable=!1,super.destroy(t))}resize(t,e){return this.setSize(t,e),this}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.syncPosition())}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.syncPosition())}get rotation(){return super.rotation}set rotation(t){this.rotation!==t&&(super.rotation=t,this.syncPosition())}get scaleX(){return super.scaleX}set scaleX(t){this.scaleX!==t&&(super.scaleX=t,this.syncPosition())}get scaleY(){return super.scaleY}set scaleY(t){this.scaleY!==t&&(super.scaleY=t,this.syncPosition())}get scale(){return super.scale}set scale(t){this.scale!==t&&(super.scale=t,this.syncPosition())}get visible(){return super.visible}set visible(t){super.visible!==t&&(super.visible=t,this.syncVisible())}get alpha(){return super.alpha}set alpha(t){super.alpha!==t&&(super.alpha=t,this.syncAlpha())}get active(){return this._active}set active(t){this._active!==t&&(this._active=t,this.syncActive())}get mask(){return this._mask}set mask(t){this._mask!==t&&(this._mask=t,this.layerRendererEnable||this.syncMask())}get scrollFactorX(){return this._scrollFactorX}set scrollFactorX(t){this._scrollFactorX!==t&&(this._scrollFactorX=t,this.syncScrollFactor())}get scrollFactorY(){return this._scrollFactorY}set scrollFactorY(t){this._scrollFactorY!==t&&(this._scrollFactorY=t,this.syncScrollFactor())}get cameraFilter(){return this._cameraFilter}set cameraFilter(t){this._cameraFilter!==t&&(this._cameraFilter=t,this.syncCameraFilter())}get list(){return this.children}static GetParent(t){return u(t)}get parentContainer(){return this._parentContainer}set parentContainer(t){this._parentContainer||t?this.setParentContainerFlag?this._parentContainer=t:this._parentContainer&&!t?(this.removeFromContainer(),this._parentContainer=t):t?(this._parentContainer=t,this.addToContainer(t)):this._parentContainer=t:this._parentContainer=t}get setParentContainerFlag(){if(this._setParentContainerFlag)return!0;var t=u(this);return!!t&&t.setParentContainerFlag}}function Yt(t,e,i,r,s){var a=new Xt(this.scene,t,e,i,r,s);return this.scene.add.existing(a),a}Object.assign(Xt.prototype,wt);const Ot=Phaser.Utils.Objects.GetAdvancedValue,_t=Phaser.Utils.Objects.GetValue,Dt=Phaser.GameObjects.BuildGameObject;function Vt(t,e){void 0===t&&(t={}),void 0!==e&&(t.add=e);var i=Ot(t,"width",1),r=Ot(t,"height",i),s=_t(t,"children",void 0),a=new Xt(this.scene,0,0,i,r);return a.syncChildrenEnable=!1,Dt(this.scene,a,t),a.syncChildrenEnable=!0,a.add(s),a}var Bt=function(t){return null!==t&&"object"==typeof t};class Gt extends Phaser.Plugins.BasePlugin{constructor(t){super(t),t.registerGameObject("rexContainerLite",Yt,Vt)}start(){this.game.events.on("destroy",this.destroy,this)}getParent(t){return Xt.GetParent(t)}}return function(t,e,i,r="."){if(!Bt(t))return t;if(function(t){return null==t}(e)||""===e||Array.isArray(e)&&0===e.length)return t;if("string"==typeof e&&-1===e.indexOf(r)||"number"==typeof e)return t[e]=i,t;var s=function(t,e){return Array.isArray(t)||(t="string"!=typeof t||""===t.trim()?[]:t.split(e).filter(Boolean)),t}(e,r);if(0===s.length)return t;for(var a=t,n=s.length,l=0;l<n-1;l++){var h=s[l],o=a[h];Bt(o)||(a[h]={}),a=a[h]}a[s[n-1]]=i}(window,"RexPlugins.GameObjects.ContainerLite",Xt),Gt},"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).rexcontainerliteplugin=e();