Files
esengine/source/bin/framework.min.js
2020-08-15 18:16:59 +08:00

1 line
204 KiB
JavaScript

window.es={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}();var transform,__awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(s,a)}c((n=n.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var i,n,r,o,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,n=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(r=(r=s.trys).length>0&&r[r.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){s.label=o[1];break}if(6===o[0]&&s.label<r[1]){s.label=r[1],r=o;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(o);break}r[2]&&s.ops.pop(),s.trys.pop();continue}o=e.call(t,s)}catch(t){o=[6,t],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};Array.prototype.findIndex=function(t){return function(t,e){for(var i=0,n=t.length;i<n;i++)if(e.call(arguments[2],t[i],i,t))return i;return-1}(this,t)},Array.prototype.any=function(t){return function(t,e){return t.findIndex(e)>-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,e){var i=t.findIndex(e);return-1==i?null:t[i]}(this,t)},Array.prototype.find=function(t){return function(t,e){return t.firstOrDefault(e)}(this,t)},Array.prototype.where=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return e.call(arguments[2],n,r,t)&&i.push(n),i},[]);for(var i=[],n=0,r=t.length;n<r;n++){var o=t[n];e.call(arguments[2],o,n,t)&&i.push(o)}return i}(this,t)},Array.prototype.count=function(t){return function(t,e){return t.where(e).length}(this,t)},Array.prototype.findAll=function(t){return function(t,e){return t.where(e)}(this,t)},Array.prototype.contains=function(t){return function(t,e){for(var i=0,n=t.length;i<n;i++){if(t[i]instanceof egret.HashObject&&e instanceof egret.HashObject&&t[i].hashCode==e.hashCode)return!0;if(t[i]==e)return!0}return!1}(this,t)},Array.prototype.removeAll=function(t){!function(t,e){var i;do{(i=t.findIndex(e))>=0&&t.splice(i,1)}while(i>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var i=t.findIndex(function(t){return t===e});return i>=0&&(t.splice(i,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,e){t.splice(e,1)}(this,t)},Array.prototype.removeRange=function(t,e){return function(t,e,i){t.splice(e,i)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return i.push(e.call(arguments[2],n,r,t)),i},[]);for(var i=[],n=0,r=t.length;n<r;n++)i.push(e.call(arguments[2],t[n],n,t));return i}(this,t)},Array.prototype.orderBy=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?i(r,o):r>o?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?-i(r,o):r<o?1:-1}),t}(this,t,e)},Array.prototype.groupBy=function(t){return function(t,e){if("function"==typeof t.reduce){var i=[];return t.reduce(function(n,r,o){var s=JSON.stringify(e.call(arguments[1],r,o,t)),a=i.findIndex(function(t){return t===s});return a<0&&(a=i.push(s)-1),n[a]||(n[a]=[]),n[a].push(r),n},[])}for(var n=[],r=[],o=function(i,o){var a=JSON.stringify(e.call(s[1],t[i],i,t)),c=r.findIndex(function(t){return t===a});c<0&&(c=r.push(a)-1),n[c]||(n[c]=[]),n[c].push(t[i])},s=arguments,a=0,c=t.length;a<c;a++)o(a);return n}(this,t)},Array.prototype.sum=function(t){return function(t,e){for(var i,n=0,r=t.length;n<r;n++)0==n?i=e?e.call(arguments[2],t[n],n,t):t[n]:i+=e?e.call(arguments[2],t[n],n,t):t[n];return i}(this,t)},function(t){var e=function(){return function(){this.priority=0,this.insertionIndex=0,this.queueIndex=0}}();t.PriorityQueueNode=e}(es||(es={})),function(t){var e=function(){function e(){}return e.search=function(e,n,r){var o=this,s=!1,a=new Map;a.set(n,n);var c=new Map,h=new t.PriorityQueue(1e3);h.enqueue(new i(n),0),c.set(n,0);for(var u=function(){var t=h.dequeue();if(JSON.stringify(t.data)==JSON.stringify(r))return s=!0,"break";e.getNeighbors(t.data).forEach(function(n){var s=c.get(t.data)+e.cost(t.data,n);if(!o.hasKey(c,n)||s<c.get(n)){c.set(n,s);var u=s+e.heuristic(n,r);h.enqueue(new i(n),u),a.set(n,t.data)}})};h.count>0;){if("break"===u())break}return s?this.recontructPath(a,n,r):null},e.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},e.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},e}();t.AStarPathfinder=e;var i=function(t){function e(e){var i=t.call(this)||this;return i.data=e,i}return __extends(e,t),e}(t.PriorityQueueNode);t.AStarNode=i}(es||(es={})),function(t){var e=function(){function e(e,i){this.dirs=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,1)],this.walls=[],this.weightedNodes=[],this.defaultWeight=1,this.weightedNodeWeight=5,this._neighbors=new Array(4),this._width=e,this._height=i}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x<this._width&&0<=t.y&&t.y<this._height},e.prototype.isNodePassable=function(t){return!this.walls.firstOrDefault(function(e){return JSON.stringify(e)==JSON.stringify(t)})},e.prototype.search=function(e,i){return t.AStarPathfinder.search(this,e,i)},e.prototype.getNeighbors=function(e){var i=this;return this._neighbors.length=0,this.dirs.forEach(function(n){var r=new t.Vector2(e.x+n.x,e.y+n.y);i.isNodeInBounds(r)&&i.isNodePassable(r)&&i._neighbors.push(r)}),this._neighbors},e.prototype.cost=function(t,e){return this.weightedNodes.find(function(t){return JSON.stringify(t)==JSON.stringify(e)})?this.weightedNodeWeight:this.defaultWeight},e.prototype.heuristic=function(t,e){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)},e}();t.AstarGridGraph=e}(es||(es={})),function(t){var e=function(){function t(t){this._numNodes=0,this._nodes=new Array(t+1),this._numNodesEverEnqueued=0}return Object.defineProperty(t.prototype,"count",{get:function(){return this._numNodes},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxSize",{get:function(){return this._nodes.length-1},enumerable:!0,configurable:!0}),t.prototype.clear=function(){this._nodes.splice(1,this._numNodes),this._numNodes=0},t.prototype.contains=function(t){return t?t.queueIndex<0||t.queueIndex>=this._nodes.length?(console.error("node.QueueIndex has been corrupted. Did you change it manually? Or add this node to another queue?"),!1):this._nodes[t.queueIndex]==t:(console.error("node cannot be null"),!1)},t.prototype.enqueue=function(t,e){t.priority=e,this._numNodes++,this._nodes[this._numNodes]=t,t.queueIndex=this._numNodes,t.insertionIndex=this._numNodesEverEnqueued++,this.cascadeUp(this._nodes[this._numNodes])},t.prototype.dequeue=function(){var t=this._nodes[1];return this.remove(t),t},t.prototype.remove=function(t){if(t.queueIndex==this._numNodes)return this._nodes[this._numNodes]=null,void this._numNodes--;var e=this._nodes[this._numNodes];this.swap(t,e),delete this._nodes[this._numNodes],this._numNodes--,this.onNodeUpdated(e)},t.prototype.isValidQueue=function(){for(var t=1;t<this._nodes.length;t++)if(this._nodes[t]){var e=2*t;if(e<this._nodes.length&&this._nodes[e]&&this.hasHigherPriority(this._nodes[e],this._nodes[t]))return!1;var i=e+1;if(i<this._nodes.length&&this._nodes[i]&&this.hasHigherPriority(this._nodes[i],this._nodes[t]))return!1}return!0},t.prototype.onNodeUpdated=function(t){var e=Math.floor(t.queueIndex/2),i=this._nodes[e];e>0&&this.hasHigherPriority(t,i)?this.cascadeUp(t):this.cascadeDown(t)},t.prototype.cascadeDown=function(t){for(var e,i=t.queueIndex;;){e=t;var n=2*i;if(n>this._numNodes){t.queueIndex=i,this._nodes[i]=t;break}var r=this._nodes[n];this.hasHigherPriority(r,e)&&(e=r);var o=n+1;if(o<=this._numNodes){var s=this._nodes[o];this.hasHigherPriority(s,e)&&(e=s)}if(e==t){t.queueIndex=i,this._nodes[i]=t;break}this._nodes[i]=e;var a=e.queueIndex;e.queueIndex=i,i=a}},t.prototype.cascadeUp=function(t){for(var e=Math.floor(t.queueIndex/2);e>=1;){var i=this._nodes[e];if(this.hasHigherPriority(i,t))break;this.swap(t,i),e=Math.floor(t.queueIndex/2)}},t.prototype.swap=function(t,e){this._nodes[t.queueIndex]=e,this._nodes[e.queueIndex]=t;var i=t.queueIndex;t.queueIndex=e.queueIndex,e.queueIndex=i},t.prototype.hasHigherPriority=function(t,e){return t.priority<e.priority||t.priority==e.priority&&t.insertionIndex<e.insertionIndex},t}();t.PriorityQueue=e}(es||(es={})),function(t){var e=function(){function e(){}return e.search=function(e,i,n){var r=this,o=!1,s=[];s.unshift(i);var a=new Map;a.set(i,i);for(var c=function(){var t=s.shift();if(JSON.stringify(t)==JSON.stringify(n))return o=!0,"break";e.getNeighbors(t).forEach(function(e){r.hasKey(a,e)||(s.unshift(e),a.set(e,t))})};s.length>0;){if("break"===c())break}return o?t.AStarPathfinder.recontructPath(a,i,n):null},e.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},e}();t.BreadthFirstPathfinder=e}(es||(es={})),function(t){var e=function(){function t(){this.edges=new Map}return t.prototype.addEdgesForNode=function(t,e){return this.edges.set(t,e),this},t.prototype.getNeighbors=function(t){return this.edges.get(t)},t}();t.UnweightedGraph=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.x=0,this.y=0,this.x=t||0,this.y=null!=e?e:this.x}return Object.defineProperty(e,"zero",{get:function(){return e.zeroVector2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return e.unitVector2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return e.unitXVector},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return e.unitYVector},enumerable:!0,configurable:!0}),e.add=function(t,i){var n=new e(0,0);return n.x=t.x+i.x,n.y=t.y+i.y,n},e.divide=function(t,i){var n=new e(0,0);return n.x=t.x/i.x,n.y=t.y/i.y,n},e.multiply=function(t,i){var n=new e(0,0);return n.x=t.x*i.x,n.y=t.y*i.y,n},e.subtract=function(t,i){var n=new e(0,0);return n.x=t.x-i.x,n.y=t.y-i.y,n},e.normalize=function(t){var e=1/Math.sqrt(t.x*t.x+t.y*t.y);return t.x*=e,t.y*=e,t},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var i=t.x-e.x,n=t.y-e.y;return i*i+n*n},e.clamp=function(i,n,r){return new e(t.MathHelper.clamp(i.x,n.x,r.x),t.MathHelper.clamp(i.y,n.y,r.y))},e.lerp=function(i,n,r){return new e(t.MathHelper.lerp(i.x,n.x,r),t.MathHelper.lerp(i.y,n.y,r))},e.transform=function(t,i){return new e(t.x*i.m11+t.y*i.m21+i.m31,t.x*i.m12+t.y*i.m22+i.m32)},e.distance=function(t,e){var i=t.x-e.x,n=t.y-e.y;return Math.sqrt(i*i+n*n)},e.angle=function(i,n){return i=e.normalize(i),n=e.normalize(n),Math.acos(t.MathHelper.clamp(e.dot(i,n),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){var i=new e;return i.x=-t.x,i.y=-t.y,i},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.prototype.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);return this.x*=t,this.y*=t,this},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.round=function(){return new e(Math.round(this.x),Math.round(this.y))},e.prototype.equals=function(t){return t.x==this.x&&t.y==this.y},e.unitYVector=new e(0,1),e.unitXVector=new e(1,0),e.unitVector2=new e(1,1),e.zeroVector2=new e(0,0),e}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(t,i,n){void 0===n&&(n=!1),this.walls=[],this._neighbors=new Array(4),this._width=t,this._hegiht=i,this._dirs=n?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x<this._width&&0<=t.y&&t.y<this._hegiht},e.prototype.isNodePassable=function(t){return!this.walls.firstOrDefault(function(e){return JSON.stringify(e)==JSON.stringify(t)})},e.prototype.getNeighbors=function(e){var i=this;return this._neighbors.length=0,this._dirs.forEach(function(n){var r=new t.Vector2(e.x+n.x,e.y+n.y);i.isNodeInBounds(r)&&i.isNodePassable(r)&&i._neighbors.push(r)}),this._neighbors},e.prototype.search=function(e,i){return t.BreadthFirstPathfinder.search(this,e,i)},e.CARDINAL_DIRS=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,-1)],e.COMPASS_DIRS=[new t.Vector2(1,0),new t.Vector2(1,-1),new t.Vector2(0,-1),new t.Vector2(-1,-1),new t.Vector2(-1,0),new t.Vector2(-1,1),new t.Vector2(0,1),new t.Vector2(1,1)],e}();t.UnweightedGridGraph=e}(es||(es={})),function(t){var e=function(){function e(t,i,n){void 0===n&&(n=!1),this.walls=[],this.weightedNodes=[],this.defaultWeight=1,this.weightedNodeWeight=5,this._neighbors=new Array(4),this._width=t,this._height=i,this._dirs=n?e.COMPASS_DIRS:e.CARDINAL_DIRS}return e.prototype.isNodeInBounds=function(t){return 0<=t.x&&t.x<this._width&&0<=t.y&&t.y<this._height},e.prototype.isNodePassable=function(t){return!this.walls.firstOrDefault(function(e){return JSON.stringify(e)==JSON.stringify(t)})},e.prototype.search=function(e,i){return t.WeightedPathfinder.search(this,e,i)},e.prototype.getNeighbors=function(e){var i=this;return this._neighbors.length=0,this._dirs.forEach(function(n){var r=new t.Vector2(e.x+n.x,e.y+n.y);i.isNodeInBounds(r)&&i.isNodePassable(r)&&i._neighbors.push(r)}),this._neighbors},e.prototype.cost=function(t,e){return this.weightedNodes.find(function(t){return JSON.stringify(t)==JSON.stringify(e)})?this.weightedNodeWeight:this.defaultWeight},e.CARDINAL_DIRS=[new t.Vector2(1,0),new t.Vector2(0,-1),new t.Vector2(-1,0),new t.Vector2(0,1)],e.COMPASS_DIRS=[new t.Vector2(1,0),new t.Vector2(1,-1),new t.Vector2(0,-1),new t.Vector2(-1,-1),new t.Vector2(-1,0),new t.Vector2(-1,1),new t.Vector2(0,1),new t.Vector2(1,1)],e}();t.WeightedGridGraph=e}(es||(es={})),function(t){var e=function(t){function e(e){var i=t.call(this)||this;return i.data=e,i}return __extends(e,t),e}(t.PriorityQueueNode);t.WeightedNode=e;var i=function(){function i(){}return i.search=function(i,n,r){var o=this,s=!1,a=new Map;a.set(n,n);var c=new Map,h=new t.PriorityQueue(1e3);h.enqueue(new e(n),0),c.set(n,0);for(var u=function(){var t=h.dequeue();if(JSON.stringify(t.data)==JSON.stringify(r))return s=!0,"break";i.getNeighbors(t.data).forEach(function(n){var r=c.get(t.data)+i.cost(t.data,n);if(!o.hasKey(c,n)||r<c.get(n)){c.set(n,r);var s=r;h.enqueue(new e(n),s),a.set(n,t.data)}})};h.count>0;){if("break"===u())break}return s?this.recontructPath(a,n,r):null},i.recontructPath=function(t,e,i){var n=[],r=i;for(n.push(i);r!=e;)r=this.getKey(t,r),n.push(r);return n.reverse(),n},i.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},i.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},i}();t.WeightedPathfinder=i}(es||(es={})),function(t){var e=function(){function e(){}return e.drawHollowRect=function(e,i,n){void 0===n&&(n=0),this._debugDrawItems.push(new t.DebugDrawItem(e,i,n))},e.render=function(){if(this._debugDrawItems.length>0){var e=new egret.Shape;t.Core.scene&&t.Core.scene.addChild(e);for(var i=this._debugDrawItems.length-1;i>=0;i--){this._debugDrawItems[i].draw(e)&&this._debugDrawItems.removeAt(i)}}},e._debugDrawItems=[],e}();t.Debug=e}(es||(es={})),function(t){var e=function(){function t(){}return t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefaults=e}(es||(es={})),function(t){var e;!function(t){t[t.line=0]="line",t[t.hollowRectangle=1]="hollowRectangle",t[t.pixel=2]="pixel",t[t.text=3]="text"}(e=t.DebugDrawType||(t.DebugDrawType={}));var i=function(){function i(t,i,n){this.rectangle=t,this.color=i,this.duration=n,this.drawType=e.hollowRectangle}return i.prototype.draw=function(i){switch(this.drawType){case e.line:t.DrawUtils.drawLine(i,this.start,this.end,this.color);break;case e.hollowRectangle:t.DrawUtils.drawHollowRect(i,this.rectangle,this.color);break;case e.pixel:t.DrawUtils.drawPixel(i,new t.Vector2(this.x,this.y),this.color,this.size);break;case e.text:}return this.duration-=t.Time.deltaTime,this.duration<0},i}();t.DebugDrawItem=i}(es||(es={})),function(t){var e=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.updateInterval=1,e._enabled=!0,e._updateOrder=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"transform",{get:function(){return this.entity.transform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this.entity?this.entity.enabled&&this._enabled:this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onAddedToEntity=function(){},e.prototype.onRemovedFromEntity=function(){},e.prototype.onEntityTransformChanged=function(t){},e.prototype.debugRender=function(){},e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},e.prototype.setUpdateOrder=function(t){return this._updateOrder!=t&&(this._updateOrder=t),this},e.prototype.clone=function(){var t=ObjectUtils.clone(this);return t.entity=null,t},e}(egret.HashObject);t.Component=e}(es||(es={})),function(t){var e=function(e){function i(){var n=e.call(this)||this;return n._globalManagers=[],i._instance=n,i.emitter=new t.Emitter,i.content=new t.ContentManager,n.addEventListener(egret.Event.ADDED_TO_STAGE,n.onAddToStage,n),n}return __extends(i,e),Object.defineProperty(i,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(i,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(t){t?null==this._instance._scene?(this._instance._scene=t,this._instance.addChild(t),this._instance._scene.begin(),i.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),i.startSceneTransition=function(t){if(!this._instance._sceneTransition)return this._instance._sceneTransition=t,t;console.warn("在前一个场景完成之前,不能开始一个新的场景转换。")},i.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},i.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},i.getGlobalManager=function(t){for(var e=0;e<this._instance._globalManagers.length;e++)if(this._instance._globalManagers[e]instanceof t)return this._instance._globalManagers[e];return null},i.prototype.onOrientationChanged=function(){i.emitter.emit(t.CoreEvents.OrientationChanged)},i.prototype.draw=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return this._sceneTransition?(this._sceneTransition.preRender(),!this._scene||this._sceneTransition.hasPreviousSceneRender?[3,2]:(this._scene.render(),this._scene.postRender(),[4,this._sceneTransition.onBeginTransition()])):[3,4];case 1:return e.sent(),[3,3];case 2:this._sceneTransition&&(this._scene&&this._sceneTransition.isNewSceneLoaded&&(this._scene.render(),this._scene.postRender()),this._sceneTransition.render()),e.label=3;case 3:return[3,5];case 4:this._scene&&(this._scene.render(),t.Debug.render(),this._scene.postRender()),e.label=5;case 5:return[2]}})})},i.prototype.startDebugUpdate=function(){t.TimeRuler.Instance.startFrame(),t.TimeRuler.Instance.beginMark("update",65280)},i.prototype.endDebugUpdate=function(){t.TimeRuler.Instance.endMark("update")},i.prototype.onSceneChanged=function(){i.emitter.emit(t.CoreEvents.SceneChanged),t.Time.sceneChanged()},i.prototype.onGraphicsDeviceReset=function(){i.emitter.emit(t.CoreEvents.GraphicsDeviceReset)},i.prototype.initialize=function(){},i.prototype.update=function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(i){switch(i.label){case 0:if(t.Time.update(egret.getTimer()),!this._scene)return[3,2];for(e=this._globalManagers.length-1;e>=0;e--)this._globalManagers[e].enabled&&this._globalManagers[e].update();return this._sceneTransition&&(!this._sceneTransition||this._sceneTransition.loadsNewScene&&!this._sceneTransition.isNewSceneLoaded)||this._scene.update(),this._nextScene?(this.removeChild(this._scene),this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),this.addChild(this._scene),[4,this._scene.begin()]):[3,2];case 1:i.sent(),i.label=2;case 2:return[4,this.draw()];case 3:return i.sent(),[2]}})})},i.prototype.onAddToStage=function(){i.graphicsDevice=new t.GraphicsDevice,this.addEventListener(egret.Event.RESIZE,this.onGraphicsDeviceReset,this),this.addEventListener(egret.StageOrientationEvent.ORIENTATION_CHANGE,this.onOrientationChanged,this),this.addEventListener(egret.Event.ENTER_FRAME,this.update,this),t.Input.initialize(),this.initialize()},i.debugRenderEndabled=!1,i}(egret.DisplayObjectContainer);t.Core=e}(es||(es={})),function(t){!function(t){t[t.GraphicsDeviceReset=0]="GraphicsDeviceReset",t[t.SceneChanged=1]="SceneChanged",t[t.OrientationChanged=2]="OrientationChanged"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function e(i){this.updateInterval=1,this._tag=0,this._enabled=!0,this._updateOrder=0,this.components=new t.ComponentList(this),this.transform=new t.Transform(this),this.name=i,this.id=e._idGenerator++,this.componentBits=new t.BitSet}return Object.defineProperty(e.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),e.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},e.prototype.setTag=function(t){return this._tag!=t&&(this.scene&&this.scene.entities.removeFromTagList(this),this._tag=t,this.scene&&this.scene.entities.addToTagList(this)),this},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},e.prototype.setUpdateOrder=function(t){if(this._updateOrder!=t)return this._updateOrder=t,this.scene&&(this.scene.entities.markEntityListUnsorted(),this.scene.entities.markTagUnsorted(this.tag)),this},e.prototype.destroy=function(){this._isDestroyed=!0,this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destroy()}},e.prototype.detachFromScene=function(){this.scene.entities.remove(this),this.components.deregisterAllComponents();for(var t=0;t<this.transform.childCount;t++)this.transform.getChild(t).entity.detachFromScene()},e.prototype.attachToScene=function(t){this.scene=t,t.entities.add(this),this.components.registerAllComponents();for(var e=0;e<this.transform.childCount;e++)this.transform.getChild(e).entity.attachToScene(t)},e.prototype.clone=function(i){void 0===i&&(i=new t.Vector2);var n=new e(this.name+"(clone)");return n.copyFrom(this),n.transform.position=i,n},e.prototype.onAddedToScene=function(){},e.prototype.onRemovedFromScene=function(){this._isDestroyed&&this.components.removeAllComponents()},e.prototype.update=function(){this.components.update()},e.prototype.addComponent=function(t){return t.entity=this,this.components.add(t),t.initialize(),t},e.prototype.getComponent=function(t){return this.components.getComponent(t,!1)},e.prototype.hasComponent=function(t){return null!=this.components.getComponent(t,!1)},e.prototype.getOrCreateComponent=function(t){var e=this.components.getComponent(t,!0);return e||(e=this.addComponent(t)),e},e.prototype.getComponents=function(t,e){return this.components.getComponents(t,e)},e.prototype.removeComponent=function(t){this.components.remove(t)},e.prototype.removeComponentForType=function(t){var e=this.getComponent(t);return!!e&&(this.removeComponent(e),!0)},e.prototype.removeAllComponents=function(){for(var t=0;t<this.components.count;t++)this.removeComponent(this.components.buffer[t])},e.prototype.compareTo=function(t){var e=this._updateOrder-t._updateOrder;return 0==e&&(e=this.id-t.id),e},e.prototype.toString=function(){return"[Entity: name: "+this.name+", tag: "+this.tag+", enabled: "+this.enabled+", depth: "+this.updateOrder+"]"},e.prototype.copyFrom=function(t){this.tag=t.tag,this.updateInterval=t.updateInterval,this.updateOrder=t.updateOrder,this.enabled=t.enabled,this.transform.scale=t.transform.scale,this.transform.rotation=t.transform.rotation;for(var e=0;e<t.components.count;e++)this.addComponent(t.components.buffer[e].clone());for(e=0;e<t.components._componentsToAdd.length;e++)this.addComponent(t.components._componentsToAdd[e].clone());for(e=0;e<t.transform.childCount;e++){var i=t.transform.getChild(e).entity,n=i.clone();n.transform.copyFrom(i.transform),n.transform.parent=this.transform}},e._idGenerator=0,e}();t.Entity=e}(es||(es={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.enablePostProcessing=!0,i._sceneComponents=[],i._renderers=[],i._postProcessors=[],i.entities=new t.EntityList(i),i.renderableComponents=new t.RenderableComponentList,i.content=new t.ContentManager,i.entityProcessors=new t.EntityProcessorList,i.initialize(),i}return __extends(i,e),i.createWithDefaultRenderer=function(){var e=new i;return e.addRenderer(new t.DefaultRenderer),e},i.prototype.initialize=function(){},i.prototype.onStart=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){return[2]})})},i.prototype.unload=function(){},i.prototype.onActive=function(){},i.prototype.onDeactive=function(){},i.prototype.begin=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){return 0==this._renderers.length&&(this.addRenderer(new t.DefaultRenderer),console.warn("场景开始时没有渲染器 自动添加DefaultRenderer以保证能够正常渲染")),this.camera=this.createEntity("camera").getOrCreateComponent(new t.Camera),t.Physics.reset(),this.entityProcessors&&this.entityProcessors.begin(),this.addEventListener(egret.Event.ACTIVATE,this.onActive,this),this.addEventListener(egret.Event.DEACTIVATE,this.onDeactive,this),this.camera.onSceneSizeChanged(this.stage.stageWidth,this.stage.stageHeight),this._didSceneBegin=!0,this.onStart(),[2]})})},i.prototype.end=function(){this._didSceneBegin=!1,this.removeEventListener(egret.Event.DEACTIVATE,this.onDeactive,this),this.removeEventListener(egret.Event.ACTIVATE,this.onActive,this);for(var t=0;t<this._renderers.length;t++)this._renderers[t].unload();for(t=0;t<this._postProcessors.length;t++)this._postProcessors[t].unload();this.entities.removeAllEntities(),this.removeChildren();for(t=0;t<this._sceneComponents.length;t++)this._sceneComponents[t].onRemovedFromScene();this._sceneComponents.length=0,this.camera=null,this.content.dispose(),this.entityProcessors&&this.entityProcessors.end(),this.parent&&this.parent.removeChild(this),this.unload()},i.prototype.update=function(){this.entities.updateLists();for(var t=this._sceneComponents.length-1;t>=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),this.entityProcessors&&this.entityProcessors.lateUpdate(),this.renderableComponents.updateList()},i.prototype.render=function(){if(0!=this._renderers.length)for(var t=0;t<this._renderers.length;t++)this._renderers[t].render(this);else console.error("场景中没有渲染器!")},i.prototype.postRender=function(){if(this.enablePostProcessing)for(var t=0;t<this._postProcessors.length;t++)this._postProcessors[t].enabled&&this._postProcessors[t].process()},i.prototype.addSceneComponent=function(t){return t.scene=this,t.onEnabled(),this._sceneComponents.push(t),this._sceneComponents.sort(t.compareTo),t},i.prototype.getSceneComponent=function(t){for(var e=0;e<this._sceneComponents.length;e++){var i=this._sceneComponents[e];if(i instanceof t)return i}return null},i.prototype.getOrCreateSceneComponent=function(t){var e=this.getSceneComponent(t);return null==e&&(e=this.addSceneComponent(new t)),e},i.prototype.removeSceneComponent=function(t){this._sceneComponents.contains(t)?(this._sceneComponents.remove(t),t.onRemovedFromScene()):console.warn("SceneComponent"+t+"不在SceneComponents列表中!")},i.prototype.addRenderer=function(t){return this._renderers.push(t),this._renderers.sort(),t.onAddedToScene(this),t},i.prototype.getRenderer=function(t){for(var e=0;e<this._renderers.length;e++)if(this._renderers[e]instanceof t)return this._renderers[e];return null},i.prototype.removeRenderer=function(t){this._renderers.contains(t)&&(this._renderers.remove(t),t.unload())},i.prototype.addPostProcessor=function(t){return this._postProcessors.push(t),this._postProcessors.sort(),t.onAddedToScene(this),this._didSceneBegin&&t.onSceneBackBufferSizeChanged(this.stage.stageWidth,this.stage.stageHeight),t},i.prototype.getPostProcessor=function(t){for(var e=0;e<this._postProcessors.length;e++)if(this._postProcessors[e]instanceof t)return this._postProcessors[e];return null},i.prototype.removePostProcessor=function(t){this._postProcessors.contains(t)&&(this._postProcessors.remove(t),t.unload())},i.prototype.createEntity=function(e){var i=new t.Entity(e);return this.addEntity(i)},i.prototype.createEntityAsync=function(t){var e=this;return new Promise(function(i){i(e.createEntity(t))})},i.prototype.addEntity=function(t){this.entities.buffer.contains(t)&&console.warn("您试图将同一实体添加到场景两次: "+t),this.entities.add(t),t.scene=this;for(var e=0;e<t.transform.childCount;e++)this.addEntity(t.transform.getChild(e).entity);return t},i.prototype.destroyAllEntities=function(){for(var t=0;t<this.entities.count;t++)this.entities.buffer[t].destroy()},i.prototype.findEntity=function(t){return this.entities.findEntity(t)},i.prototype.findEntitiesWithTag=function(t){return this.entities.entitiesWithTag(t)},i.prototype.entitiesOfType=function(t){return this.entities.entitiesOfType(t)},i.prototype.findComponentOfType=function(t){return this.entities.findComponentOfType(t)},i.prototype.findComponentsOfType=function(t){return this.entities.findComponentsOfType(t)},i.prototype.addEntityProcessor=function(t){return t.scene=this,this.entityProcessors.add(t),t},i.prototype.removeEntityProcessor=function(t){this.entityProcessors.remove(t)},i.prototype.getEntityProcessor=function(){return this.entityProcessors.getProcessor()},i}(egret.DisplayObjectContainer);t.Scene=e}(es||(es={})),function(t){!function(t){t[t.position=0]="position",t[t.scale=1]="scale",t[t.rotation=2]="rotation"}(t.Component||(t.Component={}))}(transform||(transform={})),function(t){var e,i=egret.HashObject;!function(t){t[t.clean=0]="clean",t[t.positionDirty=1]="positionDirty",t[t.scaleDirty=2]="scaleDirty",t[t.rotationDirty=3]="rotationDirty"}(e=t.DirtyType||(t.DirtyType={}));var n=function(i){function n(e){var n=i.call(this)||this;return n._localTransform=t.Matrix2D.create(),n._worldTransform=t.Matrix2D.create().identity(),n._rotationMatrix=t.Matrix2D.create(),n._translationMatrix=t.Matrix2D.create(),n._scaleMatrix=t.Matrix2D.create(),n._worldToLocalTransform=t.Matrix2D.create().identity(),n._worldInverseTransform=t.Matrix2D.create().identity(),n._position=t.Vector2.zero,n._scale=t.Vector2.one,n._rotation=0,n._localPosition=t.Vector2.zero,n._localScale=t.Vector2.one,n._localRotation=0,n.entity=e,n.scale=t.Vector2.one,n._children=[],n}return __extends(n,i),Object.defineProperty(n.prototype,"childCount",{get:function(){return this._children.length},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"rotationDegrees",{get:function(){return t.MathHelper.toDegrees(this._rotation)},set:function(e){this.setRotation(t.MathHelper.toRadians(e))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localRotationDegrees",{get:function(){return t.MathHelper.toDegrees(this._localRotation)},set:function(e){this.localRotation=t.MathHelper.toRadians(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localToWorldTransform",{get:function(){return this.updateTransform(),this._worldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},set:function(t){this.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"worldToLocalTransform",{get:function(){return this._worldToLocalDirty&&(this.parent?(this.parent.updateTransform(),this._worldToLocalTransform=this.parent._worldTransform.invert()):this._worldToLocalTransform=t.Matrix2D.create().identity(),this._worldToLocalDirty=!1),this._worldToLocalTransform},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"worldInverseTransform",{get:function(){return this.updateTransform(),this._worldInverseDirty&&(this._worldInverseTransform=this._worldTransform.invert(),this._worldInverseDirty=!1),this._worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"position",{get:function(){return this.updateTransform(),this._positionDirty&&(this.parent?(this.parent.updateTransform(),this._position=t.Vector2Ext.transformR(this._localPosition,this.parent._worldTransform)):this._position=this._localPosition,this._positionDirty=!1),this._position},set:function(t){this.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scale",{get:function(){return this.updateTransform(),this._scale},set:function(t){this.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"rotation",{get:function(){return this.updateTransform(),this._rotation},set:function(t){this.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localPosition",{get:function(){return this.updateTransform(),this._localPosition},set:function(t){this.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localScale",{get:function(){return this.updateTransform(),this._localScale},set:function(t){this.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localRotation",{get:function(){return this.updateTransform(),this._localRotation},set:function(t){this.setLocalRotation(t)},enumerable:!0,configurable:!0}),n.prototype.getChild=function(t){return this._children[t]},n.prototype.setParent=function(t){return this._parent.equals(t)?this:(this._parent||(this._parent._children.remove(this),this._parent._children.push(this)),this._parent=t,this.setDirty(e.positionDirty),this)},n.prototype.setPosition=function(e,i){var n=new t.Vector2(e,i);return n.equals(this._position)?this:(this._position=n,this.parent?this.localPosition=t.Vector2Ext.transformR(this._position,this._worldToLocalTransform):this.localPosition=n,this._positionDirty=!1,this)},n.prototype.setLocalPosition=function(t){return t.equals(this._localPosition)?this:(this._localPosition=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.positionDirty),this)},n.prototype.setRotation=function(t){return this._rotation=t,this.parent?this.localRotation=this.parent.rotation+t:this.localRotation=t,this},n.prototype.setRotationDegrees=function(e){return this.setRotation(t.MathHelper.toRadians(e))},n.prototype.lookAt=function(e){var i=this.position.x>e.x?-1:1,n=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=i*Math.acos(t.Vector2.dot(n,t.Vector2.unitY))},n.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},n.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},n.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},n.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},n.prototype.roundPosition=function(){this.position=this._position.round()},n.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(this._translationMatrix=t.Matrix2D.create().translate(this._localPosition.x,this._localPosition.y),this._localPositionDirty=!1),this._localRotationDirty&&(this._rotationMatrix=t.Matrix2D.create().rotate(this._localRotation),this._localRotationDirty=!1),this._localScaleDirty&&(this._scaleMatrix=t.Matrix2D.create().scale(this._localScale.x,this._localScale.y),this._localScaleDirty=!1),this._localTransform=this._scaleMatrix.multiply(this._rotationMatrix),this._localTransform=this._localTransform.multiply(this._translationMatrix),this.parent||(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),this.parent&&(this._worldTransform=this._localTransform.multiply(this.parent._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=t.Vector2.multiply(this.parent._scale,this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},n.prototype.setDirty=function(e){if(0==(this.hierarchyDirty&e)){switch(this.hierarchyDirty|=e,e){case t.DirtyType.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case t.DirtyType.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case t.DirtyType.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}this._children||(this._children=[]);for(var i=0;i<this._children.length;i++)this._children[i].setDirty(e)}},n.prototype.copyFrom=function(t){this._position=t.position,this._localPosition=t._localPosition,this._rotation=t._rotation,this._localRotation=t._localRotation,this._scale=t._scale,this._localScale=t._localScale,this.setDirty(e.positionDirty),this.setDirty(e.rotationDirty),this.setDirty(e.scaleDirty)},n.prototype.toString=function(){return"[Transform: parent: "+this.parent+", position: "+this.position+", rotation: "+this.rotation+",\n scale: "+this.scale+", localPosition: "+this._localPosition+", localRotation: "+this._localRotation+",\n localScale: "+this._localScale+"]"},n.prototype.equals=function(t){return t.hashCode==this.hashCode},n}(i);t.Transform=n}(es||(es={})),function(t){var e;!function(t){t[t.lockOn=0]="lockOn",t[t.cameraWindow=1]="cameraWindow"}(e=t.CameraStyle||(t.CameraStyle={}));var i=function(){return function(){this.left=0,this.right=0,this.top=0,this.bottom=0}}();t.CameraInset=i;var n=function(n){function r(r,o){void 0===r&&(r=null),void 0===o&&(o=e.lockOn);var s=n.call(this)||this;return s._inset=new i,s._areMatrixedDirty=!0,s._areBoundsDirty=!0,s._isProjectionMatrixDirty=!0,s.followLerp=.1,s.deadzone=new t.Rectangle,s.focusOffset=t.Vector2.zero,s.mapLockEnabled=!1,s.mapSize=new t.Rectangle,s._desiredPositionDelta=new t.Vector2,s._worldSpaceDeadZone=new t.Rectangle,s._minimumZoom=.3,s._maximumZoom=3,s._bounds=new t.Rectangle,s._transformMatrix=(new t.Matrix2D).identity(),s._inverseTransformMatrix=(new t.Matrix2D).identity(),s._origin=t.Vector2.zero,s._targetEntity=r,s._cameraStyle=o,s.setZoom(0),s}return __extends(r,n),Object.defineProperty(r.prototype,"position",{get:function(){return this.entity.transform.position},set:function(t){this.entity.transform.position=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"rotation",{get:function(){return this.entity.transform.rotation},set:function(t){this.entity.transform.rotation=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"zoom",{get:function(){return 0==this._zoom?1:this._zoom<1?t.MathHelper.map(this._zoom,this._minimumZoom,1,-1,0):t.MathHelper.map(this._zoom,1,this._maximumZoom,0,1)},set:function(t){this.setZoom(t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"minimumZoom",{get:function(){return this._minimumZoom},set:function(t){this.setMinimumZoom(t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"maximumZoom",{get:function(){return this._maximumZoom},set:function(t){this.setMaximumZoom(t)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bounds",{get:function(){if(this._areMatrixedDirty&&this.updateMatrixes(),this._areBoundsDirty){var e=this.screenToWorldPoint(new t.Vector2(this._inset.left,this._inset.top)),i=this.screenToWorldPoint(new t.Vector2(t.Core.graphicsDevice.viewport.width-this._inset.right,t.Core.graphicsDevice.viewport.height-this._inset.bottom));if(0!=this.entity.transform.rotation){var n=this.screenToWorldPoint(new t.Vector2(t.Core.graphicsDevice.viewport.width-this._inset.right,this._inset.top)),r=this.screenToWorldPoint(new t.Vector2(this._inset.left,t.Core.graphicsDevice.viewport.height-this._inset.bottom)),o=Math.min(e.x,i.x,n.x,r.x),s=Math.max(e.x,i.x,n.x,r.x),a=Math.min(e.y,i.y,n.y,r.y),c=Math.max(e.y,i.y,n.y,r.y);this._bounds.location=new t.Vector2(o,a),this._bounds.width=s-o,this._bounds.height=c-a}else this._bounds.location=e,this._bounds.width=i.x-e.x,this._bounds.height=i.y-e.y;this._areBoundsDirty=!1}return this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"transformMatrix",{get:function(){return this._areMatrixedDirty&&this.updateMatrixes(),this._transformMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"inverseTransformMatrix",{get:function(){return this._areMatrixedDirty&&this.updateMatrixes(),this._inverseTransformMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"origin",{get:function(){return this._origin},set:function(t){this._origin!=t&&(this._origin=t,this._areMatrixedDirty=!0)},enumerable:!0,configurable:!0}),r.prototype.onSceneSizeChanged=function(e,i){var n=this._origin;this.origin=new t.Vector2(e/2,i/2),this.entity.transform.position=t.Vector2.add(this.entity.transform.position,t.Vector2.subtract(this._origin,n))},r.prototype.setInset=function(t,e,n,r){return this._inset=new i,this._inset.left=t,this._inset.right=e,this._inset.top=n,this._inset.bottom=r,this._areBoundsDirty=!0,this},r.prototype.setPosition=function(t){return this.entity.transform.setPosition(t.x,t.y),this},r.prototype.setRotation=function(t){return this.entity.transform.setRotation(t),this},r.prototype.setZoom=function(e){var i=t.MathHelper.clamp(e,-1,1);return this._zoom=0==i?1:i<0?t.MathHelper.map(i,-1,0,this._minimumZoom,1):t.MathHelper.map(i,0,1,1,this._maximumZoom),this._areMatrixedDirty=!0,this},r.prototype.setMinimumZoom=function(t){if(!(t<=0))return this._zoom<t&&(this._zoom=this.minimumZoom),this._minimumZoom=t,this;console.error("minimumZoom must be greater than zero")},r.prototype.setMaximumZoom=function(t){if(!(t<=0))return this._zoom>t&&(this._zoom=t),this._maximumZoom=t,this;console.error("maximumZoom must be greater than zero")},r.prototype.onEntityTransformChanged=function(t){this._areMatrixedDirty=!0},r.prototype.zoomIn=function(t){this.zoom+=t},r.prototype.zoomOut=function(t){this.zoom-=t},r.prototype.worldToScreenPoint=function(e){return this.updateMatrixes(),e=t.Vector2.transform(e,this._transformMatrix)},r.prototype.screenToWorldPoint=function(e){return this.updateMatrixes(),e=t.Vector2.transform(e,this._inverseTransformMatrix)},r.prototype.mouseToWorldPoint=function(){return this.screenToWorldPoint(t.Input.touchPosition)},r.prototype.onAddedToEntity=function(){this.follow(this._targetEntity,this._cameraStyle)},r.prototype.update=function(){var e=t.Vector2.multiply(new t.Vector2(this.bounds.width,this.bounds.height),new t.Vector2(.5));this._worldSpaceDeadZone.x=this.position.x-e.x*t.Core.scene.scaleX+this.deadzone.x+this.focusOffset.x,this._worldSpaceDeadZone.y=this.position.y-e.y*t.Core.scene.scaleY+this.deadzone.y+this.focusOffset.y,this._worldSpaceDeadZone.width=this.deadzone.width,this._worldSpaceDeadZone.height=this.deadzone.height,this._targetEntity&&this.updateFollow(),this.position=t.Vector2.lerp(this.position,t.Vector2.add(this.position,this._desiredPositionDelta),this.followLerp),this.entity.transform.roundPosition(),this.mapLockEnabled&&(this.position=this.clampToMapSize(this.position),this.entity.transform.roundPosition())},r.prototype.clampToMapSize=function(e){var i=t.Vector2.multiply(new t.Vector2(this.bounds.width,this.bounds.height),new t.Vector2(.5)).add(new t.Vector2(this.mapSize.x,this.mapSize.y)),n=new t.Vector2(this.mapSize.width-i.x,this.mapSize.height-i.y);return t.Vector2.clamp(e,i,n)},r.prototype.updateFollow=function(){if(this._desiredPositionDelta.x=this._desiredPositionDelta.y=0,this._cameraStyle==e.lockOn){var i=this._targetEntity.transform.position.x,n=this._targetEntity.transform.position.y;this._worldSpaceDeadZone.x>i?this._desiredPositionDelta.x=i-this._worldSpaceDeadZone.x:this._worldSpaceDeadZone.x<i&&(this._desiredPositionDelta.x=i-this._worldSpaceDeadZone.x),this._worldSpaceDeadZone.y<n?this._desiredPositionDelta.y=n-this._worldSpaceDeadZone.y:this._worldSpaceDeadZone.y>n&&(this._desiredPositionDelta.y=n-this._worldSpaceDeadZone.y)}else{if(!this._targetCollider&&(this._targetCollider=this._targetEntity.getComponent(t.Collider),!this._targetCollider))return;var r=this._targetEntity.getComponent(t.Collider).bounds;this._worldSpaceDeadZone.containsRect(r)||(this._worldSpaceDeadZone.left>r.left?this._desiredPositionDelta.x=r.left-this._worldSpaceDeadZone.left:this._worldSpaceDeadZone.right<r.right&&(this._desiredPositionDelta.x=r.right-this._worldSpaceDeadZone.right),this._worldSpaceDeadZone.bottom<r.bottom?this._desiredPositionDelta.y=r.bottom-this._worldSpaceDeadZone.bottom:this._worldSpaceDeadZone.top>r.top&&(this._desiredPositionDelta.y=r.top-this._worldSpaceDeadZone.top))}},r.prototype.follow=function(i,n){switch(void 0===n&&(n=e.cameraWindow),this._targetEntity=i,this._cameraStyle=n,this._cameraStyle){case e.cameraWindow:var r=this.bounds.width/6,o=this.bounds.height/3;this.deadzone=new t.Rectangle((this.bounds.width-r)/2,(this.bounds.height-o)/2,r,o);break;case e.lockOn:this.deadzone=new t.Rectangle(this.bounds.width/2,this.bounds.height/2,10,10)}},r.prototype.setCenteredDeadzone=function(e,i){this.deadzone=new t.Rectangle((this.bounds.width-e)/2,(this.bounds.height-i)/2,e,i)},r.prototype.updateMatrixes=function(){var e;this._areMatrixedDirty&&(this._transformMatrix=t.Matrix2D.create().translate(-this.entity.transform.position.x,-this.entity.transform.position.y),1!=this._zoom&&(e=t.Matrix2D.create().scale(this._zoom,this._zoom),this._transformMatrix=this._transformMatrix.multiply(e)),0!=this.entity.transform.rotation&&(e=t.Matrix2D.create().rotate(this.entity.transform.rotation),this._transformMatrix=this._transformMatrix.multiply(e)),e=t.Matrix2D.create().translate(this._origin.x,this._origin.y),this._transformMatrix=this._transformMatrix.multiply(e),this._inverseTransformMatrix=this._transformMatrix.invert(),this._areBoundsDirty=!0,this._areMatrixedDirty=!1)},r}(t.Component);t.Camera=n}(es||(es={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._shakeDirection=t.Vector2.zero,i._shakeOffset=t.Vector2.zero,i._shakeIntensity=0,i._shakeDegredation=.95,i}return __extends(i,e),i.prototype.shake=function(e,i,n){void 0===e&&(e=15),void 0===i&&(i=.9),void 0===n&&(n=t.Vector2.zero),this.enabled=!0,this._shakeIntensity<e&&(this._shakeDirection=n,this._shakeIntensity=e,(i<0||i>=1)&&(i=.95),this._shakeDegredation=i)},i.prototype.update=function(){Math.abs(this._shakeIntensity)>0&&(this._shakeOffset=this._shakeDirection,0!=this._shakeOffset.x||0!=this._shakeOffset.y?this._shakeOffset.normalize():(this._shakeOffset.x=this._shakeOffset.x+Math.random()-.5,this._shakeOffset.y=this._shakeOffset.y+Math.random()-.5),this._shakeOffset.multiply(new t.Vector2(this._shakeIntensity)),this._shakeIntensity*=-this._shakeDegredation,Math.abs(this._shakeIntensity)<=.01&&(this._shakeIntensity=0,this.enabled=!1)),this.entity.scene.camera.position.add(this._shakeOffset)},i}(t.Component);t.CameraShake=e}(es||(es={})),function(t){var e=function(){function t(t){this._type=t,this._cache=[]}return t.prototype.obtain=function(){try{return this._cache.length>0?this._cache.shift():new this._type}catch(t){throw new Error(this._type+t)}},t.prototype.free=function(t){t.reset(),this._cache.push(t)},t}();t.ComponentPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Component);t.PooledComponent=e}(es||(es={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.displayObject=new egret.DisplayObject,i.color=0,i._areBoundsDirty=!0,i._localOffset=t.Vector2.zero,i._renderLayer=0,i._bounds=new t.Rectangle,i}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.bounds.width},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.bounds.height},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderLayer",{get:function(){return this._renderLayer},set:function(t){this.setRenderLayer(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bounds",{get:function(){return this._areBoundsDirty&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,t.Vector2.zero,this.entity.transform.scale,this.entity.transform.rotation,this.width,this.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isVisible",{get:function(){return this._isVisible},set:function(t){this._isVisible!=t&&(this._isVisible=t,this._isVisible?this.onBecameVisible():this.onBecameInvisible())},enumerable:!0,configurable:!0}),i.prototype.onEntityTransformChanged=function(t){this._areBoundsDirty=!0},i.prototype.isVisibleFromCamera=function(t){return this.isVisible=t.bounds.intersects(this.bounds),this.isVisible},i.prototype.setRenderLayer=function(t){if(t!=this._renderLayer){var e=this._renderLayer;this._renderLayer=t,this.entity&&this.entity.scene&&this.entity.scene.renderableComponents.updateRenderableRenderLayer(this,e,this._renderLayer)}return this},i.prototype.setColor=function(t){return this.color=t,this},i.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this._localOffset=t),this},i.prototype.sync=function(t){this.displayObject.x=this.entity.position.x+this.localOffset.x-t.position.x+t.origin.x,this.displayObject.y=this.entity.position.y+this.localOffset.y-t.position.y+t.origin.y,this.displayObject.scaleX=this.entity.scale.x,this.displayObject.scaleY=this.entity.scale.y,this.displayObject.rotation=this.entity.rotation},i.prototype.toString=function(){return"[RenderableComponent] renderLayer: "+this.renderLayer},i.prototype.onBecameVisible=function(){this.displayObject.visible=this.isVisible},i.prototype.onBecameInvisible=function(){this.displayObject.visible=this.isVisible},i}(t.Component);t.RenderableComponent=e}(es||(es={})),function(t){var e=function(){function e(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.onRemovedFromScene=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled),this},e.prototype.setUpdateOrder=function(e){return this.updateOrder!=e&&(this.updateOrder=e,t.Core.scene._sceneComponents.sort(this.compareTo)),this},e.prototype.compareTo=function(t){return this.updateOrder-t.updateOrder},e}();t.SceneComponent=e}(es||(es={})),function(t){var e=egret.Bitmap,i=function(i){function n(e){void 0===e&&(e=null);var n=i.call(this)||this;return e instanceof t.Sprite?n.setSprite(e):e instanceof egret.Texture&&n.setSprite(new t.Sprite(e)),n}return __extends(n,i),Object.defineProperty(n.prototype,"bounds",{get:function(){return this._areBoundsDirty&&this._sprite&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,this._origin,this.entity.transform.scale,this.entity.transform.rotation,this._sprite.sourceRect.width,this._sprite.sourceRect.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"originNormalized",{get:function(){return new t.Vector2(this._origin.x/this.width*this.entity.transform.scale.x,this._origin.y/this.height*this.entity.transform.scale.y)},set:function(e){this.setOrigin(new t.Vector2(e.x*this.width/this.entity.transform.scale.x,e.y*this.height/this.entity.transform.scale.y))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"origin",{get:function(){return this._origin},set:function(t){this.setOrigin(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"sprite",{get:function(){return this._sprite},set:function(t){this.setSprite(t)},enumerable:!0,configurable:!0}),n.prototype.setSprite=function(t){return this._sprite=t,this._sprite&&(this._origin=this._sprite.origin,this.displayObject.anchorOffsetX=this._origin.x,this.displayObject.anchorOffsetY=this._origin.y),this.displayObject=new e(t.texture2D),this},n.prototype.setOrigin=function(t){return this._origin!=t&&(this._origin=t,this.displayObject.anchorOffsetX=this._origin.x,this.displayObject.anchorOffsetY=this._origin.y,this._areBoundsDirty=!0),this},n.prototype.setOriginNormalized=function(e){return this.setOrigin(new t.Vector2(e.x*this.width/this.entity.transform.scale.x,e.y*this.height/this.entity.transform.scale.y)),this},n.prototype.render=function(t){this.sync(t),this.displayObject.x=this.entity.position.x+this.localOffset.x-t.position.x+t.origin.x,this.displayObject.y=this.entity.position.y+this.localOffset.y-t.position.y+t.origin.y},n}(t.RenderableComponent);t.SpriteRenderer=i}(es||(es={})),function(t){var e=egret.Bitmap,i=egret.RenderTexture,n=function(n){function r(e){var i=n.call(this,e)||this;return i._textureScale=t.Vector2.one,i._inverseTexScale=t.Vector2.one,i._gapX=0,i._gapY=0,i._sourceRect=e.sourceRect,i.displayObject.$fillMode=egret.BitmapFillMode.REPEAT,i}return __extends(r,n),Object.defineProperty(r.prototype,"bounds",{get:function(){return this._areBoundsDirty&&this._sprite&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,this._origin,this.entity.transform.scale,this.entity.transform.rotation,this.width,this.height),this._areBoundsDirty=!1),this._bounds},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollX",{get:function(){return this._sourceRect.x},set:function(t){this._sourceRect.x=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scrollY",{get:function(){return this._sourceRect.y},set:function(t){this._sourceRect.y=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"textureScale",{get:function(){return this._textureScale},set:function(e){this._textureScale=e,this._inverseTexScale=new t.Vector2(1/this._textureScale.x,1/this._textureScale.y),this._sourceRect.width=this._sprite.sourceRect.width*this._inverseTexScale.x,this._sourceRect.height=this._sprite.sourceRect.height*this._inverseTexScale.y},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"width",{get:function(){return this._sourceRect.width},set:function(t){this._areBoundsDirty=!0,this._sourceRect.width=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"height",{get:function(){return this._sourceRect.height},set:function(t){this._areBoundsDirty=!0,this._sourceRect.height=t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"gapXY",{get:function(){return new t.Vector2(this._gapX,this._gapY)},set:function(t){this._gapX=t.x,this._gapY=t.y;var n=new i,r=this.sprite.sourceRect;r.x=0,r.y=0,r.width+=this._gapX,r.height+=this._gapY,n.drawToTexture(this.displayObject,r),this.displayObject?this.displayObject.texture=n:this.displayObject=new e(n)},enumerable:!0,configurable:!0}),r.prototype.setGapXY=function(t){return this.gapXY=t,this},r.prototype.render=function(t){n.prototype.render.call(this,t);var e=this.displayObject;e.width=this.width,e.height=this.height,e.scrollRect=this._sourceRect},r}(t.SpriteRenderer);t.TiledSpriteRenderer=n}(es||(es={})),function(t){var e=function(e){function i(t){var i=e.call(this,t)||this;return i.scrollSpeedX=15,i.scroolSpeedY=0,i._scrollX=0,i._scrollY=0,i._scrollWidth=0,i._scrollHeight=0,i._scrollWidth=i.width,i._scrollHeight=i.height,i}return __extends(i,e),Object.defineProperty(i.prototype,"textureScale",{get:function(){return this._textureScale},set:function(e){this._textureScale=e,this._inverseTexScale=new t.Vector2(1/this._textureScale.x,1/this._textureScale.y)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scrollWidth",{get:function(){return this._scrollWidth},set:function(t){this._scrollWidth=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scrollHeight",{get:function(){return this._scrollHeight},set:function(t){this._scrollHeight=t},enumerable:!0,configurable:!0}),i.prototype.update=function(){this.sprite&&(this._scrollX+=this.scrollSpeedX*t.Time.deltaTime,this._scrollY+=this.scroolSpeedY*t.Time.deltaTime,this._sourceRect.x=this._scrollX,this._sourceRect.y=this._scrollY,this._sourceRect.width=this._scrollWidth+Math.abs(this._scrollX),this._sourceRect.height=this._scrollHeight+Math.abs(this._scrollY))},i}(t.TiledSpriteRenderer);t.ScrollingSpriteRenderer=e}(es||(es={})),function(t){var e=function(){return function(e,i,n){void 0===i&&(i=new t.Rectangle(0,0,e.textureWidth,e.textureHeight)),void 0===n&&(n=i.getHalfSize()),this.uvs=new t.Rectangle,this.texture2D=e,this.sourceRect=i,this.center=new t.Vector2(.5*i.width,.5*i.height),this.origin=n;var r=1/e.textureWidth,o=1/e.textureHeight;this.uvs.x=i.x*r,this.uvs.y=i.y*o,this.uvs.width=i.width*r,this.uvs.height=i.height*o}}();t.Sprite=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.sprites=t,this.frameRate=e}}();t.SpriteAnimation=e}(es||(es={})),function(t){var e,i;!function(t){t[t.loop=0]="loop",t[t.once=1]="once",t[t.clampForever=2]="clampForever",t[t.pingPong=3]="pingPong",t[t.pingPongOnce=4]="pingPongOnce"}(e=t.LoopMode||(t.LoopMode={})),function(t){t[t.none=0]="none",t[t.running=1]="running",t[t.paused=2]="paused",t[t.completed=3]="completed"}(i=t.State||(t.State={}));var n=function(n){function r(t){var e=n.call(this,t)||this;return e.speed=1,e.animationState=i.none,e._elapsedTime=0,e._animations=new Map,e}return __extends(r,n),Object.defineProperty(r.prototype,"isRunning",{get:function(){return this.animationState==i.running},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"animations",{get:function(){return this._animations},enumerable:!0,configurable:!0}),r.prototype.update=function(){if(this.animationState==i.running&&this.currentAnimation){var n=this.currentAnimation,r=1/(n.frameRate*this.speed),o=r*n.sprites.length;this._elapsedTime+=t.Time.deltaTime;var s=Math.abs(this._elapsedTime);if(this._loopMode==e.once&&s>o||this._loopMode==e.pingPongOnce&&s>2*o)return this.animationState=i.completed,this._elapsedTime=0,this.currentFrame=0,void(this.sprite=n.sprites[this.currentFrame]);var a=Math.floor(s/r),c=n.sprites.length;if(c>2&&(this._loopMode==e.pingPong||this._loopMode==e.pingPongOnce)){var h=c-1;this.currentFrame=h-Math.abs(h-a%(2*h))}else this.currentFrame=a%c;this.sprite=n.sprites[this.currentFrame]}},r.prototype.addAnimation=function(t,e){return!this.sprite&&e.sprites.length>0&&this.setSprite(e.sprites[0]),this._animations[t]=e,this},r.prototype.play=function(t,n){void 0===n&&(n=null),this.currentAnimation=this._animations[t],this.currentAnimationName=t,this.currentFrame=0,this.animationState=i.running,this.sprite=this.currentAnimation.sprites[0],this._elapsedTime=0,this._loopMode=n||e.loop},r.prototype.isAnimationActive=function(t){return this.currentAnimation&&this.currentAnimationName==t},r.prototype.pause=function(){this.animationState=i.paused},r.prototype.unPause=function(){this.animationState=i.running},r.prototype.stop=function(){this.currentAnimation=null,this.currentAnimationName=null,this.currentFrame=0,this.animationState=i.none},r}(t.SpriteRenderer);t.SpriteAnimator=n}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"hasCollision",{get:function(){return this.below||this.right||this.left||this.above},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this.becameGroundedThisFrame=this.isGroundedOnOnewayPlatform=this.right=this.left=this.above=this.below=!1,this.slopAngle=0},t.prototype.toString=function(){return"[CollisionState] r: "+this.right+", l: "+this.left+", a: "+this.above+", b: "+this.below+", angle: "+this.slopAngle+", wasGroundedLastFrame: "+this.wasGroundedLastFrame+", becameGroundedThisFrame: "+this.becameGroundedThisFrame},t}();t.CollisionState=e;var i=function(e){function i(){var t=e.call(this)||this;return t.colliderHorizontalInset=2,t.colliderVerticalInset=6,t}return __extends(i,e),i.prototype.testCollisions=function(e,i,n){this._boxColliderBounds=i,n.wasGroundedLastFrame=n.below,n.reset();var r=e.x;e.y;if(0!=r){var o=r>0?t.Edge.right:t.Edge.left,s=this.collisionRectForSide(o,r);this.testMapCollision(s,o,n,0)?(e.x=0-t.RectangleExt.getSide(i,o),n.left=o==t.Edge.left,n.right=o==t.Edge.right,n._movementRemainderX.reset()):(n.left=!1,n.right=!1)}},i.prototype.testMapCollision=function(e,i,n,r){var o=t.EdgeExt.oppositeEdge(i);t.EdgeExt.isVertical(o)?e.center.x:e.center.y,t.RectangleExt.getSide(e,i),t.EdgeExt.isVertical(o)},i.prototype.collisionRectForSide=function(e,i){var n;return n=t.EdgeExt.isHorizontal(e)?t.RectangleExt.getRectEdgePortion(this._boxColliderBounds,e):t.RectangleExt.getHalfRect(this._boxColliderBounds,e),t.EdgeExt.isVertical(e)?t.RectangleExt.contract(n,this.colliderHorizontalInset,0):t.RectangleExt.contract(n,0,this.colliderVerticalInset),t.RectangleExt.expandSide(n,e,i),n},i}(t.Component);t.TiledMapMover=i}(es||(es={})),function(t){var e=function(e){function i(t,i,n){void 0===i&&(i=null),void 0===n&&(n=!0);var r=e.call(this)||this;return r.physicsLayer=1,r.toContainer=!1,r.tiledMap=t,r._shouldCreateColliders=n,r.displayObject=new egret.DisplayObjectContainer,i&&(r.collisionLayer=t.tileLayers[i]),r}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.tiledMap.width*this.tiledMap.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.tiledMap.height*this.tiledMap.tileHeight},enumerable:!0,configurable:!0}),i.prototype.setLayerToRender=function(t){this.layerIndicesToRender=[],this.layerIndicesToRender[0]=this.getLayerIndex(t)},i.prototype.setLayersToRender=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.layerIndicesToRender=[];for(var i=0;i<t.length;i++)this.layerIndicesToRender[i]=this.getLayerIndex(t[i])},i.prototype.getLayerIndex=function(t){var e=this.tiledMap.getLayer(t);for(var i in this.tiledMap.layers)if(this.tiledMap.layers.hasOwnProperty(i)&&this.tiledMap.layers[i]==e)return 0;return-1},i.prototype.getRowAtWorldPosition=function(t){return t-=this.entity.transform.position.y+this._localOffset.y,this.tiledMap.worldToTilePositionY(t)},i.prototype.getColumnAtWorldPosition=function(t){return t-=this.entity.transform.position.x+this._localOffset.x,this.tiledMap.worldToTilePositionX(t)},i.prototype.onEntityTransformChanged=function(t){this._shouldCreateColliders&&t==transform.Component.position&&(this.removeColliders(),this.addColliders())},i.prototype.onAddedToEntity=function(){this.addColliders()},i.prototype.onRemovedFromEntity=function(){this.removeColliders()},i.prototype.update=function(){this.tiledMap.update()},i.prototype.render=function(e){if(this.sync(e),this.layerIndicesToRender)for(var i=0;i<this.tiledMap.layers.length;i++)this.tiledMap.layers[i].visible&&this.layerIndicesToRender.contains(i)&&t.TiledRendering.renderLayerRenderCamera(this.tiledMap.layers[i],this.toContainer?null:this.displayObject,t.Vector2.add(this.entity.transform.position,this._localOffset),this.transform.scale,this.renderLayer,e.bounds);else t.TiledRendering.renderMap(this.tiledMap,this.toContainer?null:this.displayObject,t.Vector2.add(this.entity.transform.position,this._localOffset),this.transform.scale,this.renderLayer);this.toContainer||(this.displayObject.cacheAsBitmap=!0,this.toContainer=!0)},i.prototype.addColliders=function(){if(this.collisionLayer&&this._shouldCreateColliders){var e=this.collisionLayer.getCollisionRectangles();this._colliders=[];for(var i=0;i<e.length;i++){var n=(new t.BoxCollider).createBoxRect(e[i].x+this._localOffset.x,e[i].y+this._localOffset.y,e[i].width,e[i].height);n.physicsLayer=this.physicsLayer,n.entity=this.entity,this._colliders[i]=n,t.Physics.addCollider(n)}}},i.prototype.removeColliders=function(){if(null!=this._colliders){for(var e=0,i=this._colliders;e<i.length;e++){var n=i[e];t.Physics.removeCollider(n)}this._colliders=null}},i}(t.RenderableComponent);t.TiledMapRenderer=e}(es||(es={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToEntity=function(){this._triggerHelper=new t.ColliderTriggerHelper(this.entity)},i.prototype.calculateMovement=function(e,i){if(!this.entity.getComponent(t.Collider)||!this._triggerHelper)return!1;for(var n=this.entity.getComponents(t.Collider),r=0;r<n.length;r++){var o=n[r];if(!o.isTrigger){var s=o.bounds;s.x+=e.x,s.y+=e.y;for(var a=t.Physics.boxcastBroadphaseExcludingSelf(o,s,o.collidesWithLayers),c=0;c<a.length;c++){var h=a[c];if(!h.isTrigger){var u=new t.CollisionResult;o.collidesWith(h,e,u)&&(e=e.subtract(u.minimumTranslationVector),null!=u.collider&&(i=u))}}}}return t.ListPool.free(n),null!=i.collider},i.prototype.applyMovement=function(e){this.entity.position=t.Vector2.add(this.entity.position,e),this._triggerHelper&&this._triggerHelper.update()},i.prototype.move=function(t,e){return this.calculateMovement(t,e),this.applyMovement(t),null!=e.collider},i}(t.Component);t.Mover=e}(es||(es={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._tempTriggerList=[],t}return __extends(i,e),i.prototype.onAddedToEntity=function(){this._collider=this.entity.getComponent(t.Collider),this._collider||console.warn("ProjectileMover has no Collider. ProjectilMover requires a Collider!")},i.prototype.move=function(e){if(!this._collider)return!1;var i=!1;this.entity.position=t.Vector2.add(this.entity.position,e);for(var n=t.Physics.boxcastBroadphase(this._collider.bounds,this._collider.collidesWithLayers),r=0;r<n.length;r++){var o=n[r];this._collider.overlaps(o)&&o.enabled&&(i=!0,this.notifyTriggerListeners(this._collider,o))}return i},i.prototype.notifyTriggerListeners=function(t,e){e.entity.getComponents("ITriggerListener",this._tempTriggerList);for(var i=0;i<this._tempTriggerList.length;i++)this._tempTriggerList[i].onTriggerEnter(t,e);this._tempTriggerList.length=0,this.entity.getComponents("ITriggerListener",this._tempTriggerList);for(i=0;i<this._tempTriggerList.length;i++)this._tempTriggerList[i].onTriggerEnter(e,t);this._tempTriggerList.length=0},i}(t.Component);t.ProjectileMover=e}(es||(es={})),function(t){var e=function(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i.physicsLayer=1,i.collidesWithLayers=t.Physics.allLayers,i.shouldColliderScaleAndRotateWithTransform=!0,i.registeredPhysicsBounds=new t.Rectangle,i._isPositionDirty=!0,i._isRotationDirty=!0,i._localOffset=t.Vector2.zero,i}return __extends(i,e),Object.defineProperty(i.prototype,"absolutePosition",{get:function(){return t.Vector2.add(this.entity.transform.position,this._localOffset)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this.shouldColliderScaleAndRotateWithTransform&&this.entity?this.entity.transform.rotation:0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bounds",{get:function(){return(this._isPositionDirty||this._isRotationDirty)&&(this.shape.recalculateBounds(this),this._isPositionDirty=this._isRotationDirty=!1),this.shape.bounds},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),i.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this.unregisterColliderWithPhysicsSystem(),this._localOffset=t,this._localOffsetLength=this._localOffset.length(),this._isPositionDirty=!0,this.registerColliderWithPhysicsSystem()),this},i.prototype.setShouldColliderScaleAndRotateWithTransform=function(t){return this.shouldColliderScaleAndRotateWithTransform=t,this._isPositionDirty=this._isRotationDirty=!0,this},i.prototype.onAddedToEntity=function(){if(this._colliderRequiresAutoSizing){if(!(this instanceof t.BoxCollider||this instanceof t.CircleCollider))return void console.error("Only box and circle colliders can be created automatically");var e=this.entity.getComponent(t.RenderableComponent);if(e){var i=e.bounds,n=i.width/this.entity.scale.x,r=i.height/this.entity.scale.y;this instanceof t.CircleCollider?this.radius=.5*Math.max(n,r):(this.width=n,this.height=r),this.localOffset=t.Vector2.subtract(i.center,this.entity.transform.position)}else console.warn("Collider has no shape and no RenderableComponent. Can't figure out how to size it.")}this._isParentEntityAddedToScene=!0,this.registerColliderWithPhysicsSystem()},i.prototype.onRemovedFromEntity=function(){this.unregisterColliderWithPhysicsSystem(),this._isParentEntityAddedToScene=!1},i.prototype.onEntityTransformChanged=function(e){switch(e){case transform.Component.position:case transform.Component.scale:this._isPositionDirty=!0;break;case transform.Component.rotation:this._isRotationDirty=!0}this._isColliderRegistered&&t.Physics.updateCollider(this)},i.prototype.onEnabled=function(){this.registerColliderWithPhysicsSystem(),this._isPositionDirty=this._isRotationDirty=!0},i.prototype.onDisabled=function(){this.unregisterColliderWithPhysicsSystem()},i.prototype.registerColliderWithPhysicsSystem=function(){this._isParentEntityAddedToScene&&!this._isColliderRegistered&&(t.Physics.addCollider(this),this._isColliderRegistered=!0)},i.prototype.unregisterColliderWithPhysicsSystem=function(){this._isParentEntityAddedToScene&&this._isColliderRegistered&&t.Physics.removeCollider(this),this._isColliderRegistered=!1},i.prototype.overlaps=function(t){return this.shape.overlaps(t.shape)},i.prototype.collidesWith=function(t,e,i){var n=this.entity.position;this.entity.position=this.entity.position.add(e);var r=this.shape.collidesWithShape(t.shape,i);return r&&(i.collider=t),this.entity.position=n,r},i.prototype.clone=function(){var t=ObjectUtils.clone(this);return t.entity=null,this.shape&&(t.shape=this.shape.clone()),t},i}(t.Component);t.Collider=e}(es||(es={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.shape=new t.Box(1,1),i._colliderRequiresAutoSizing=!0,i}return __extends(i,e),Object.defineProperty(i.prototype,"width",{get:function(){return this.shape.width},set:function(t){this.setWidth(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.shape.height},set:function(t){this.setHeight(t)},enumerable:!0,configurable:!0}),i.prototype.createBoxRect=function(e,i,n,r){return this._localOffset=new t.Vector2(e+n/2,i+n/2),this.shape=new t.Box(n,r),this._colliderRequiresAutoSizing=!1,this},i.prototype.setSize=function(e,i){this._colliderRequiresAutoSizing=!1;var n=this.shape;return e==n.width&&i==n.height||(n.updateBox(e,i),this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},i.prototype.setWidth=function(e){this._colliderRequiresAutoSizing=!1;var i=this.shape;return e!=i.width&&(i.updateBox(e,i.height),this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},i.prototype.setHeight=function(e){this._colliderRequiresAutoSizing=!1;var i=this.shape;e!=i.height&&(i.updateBox(i.width,e),this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this))},i.prototype.toString=function(){return"[BoxCollider: bounds: "+this.bounds+"]"},i}(t.Collider);t.BoxCollider=e}(es||(es={})),function(t){var e=function(e){function i(i){var n=e.call(this)||this;return i&&(n._colliderRequiresAutoSizing=!0),n.shape=new t.Circle(i||1),n}return __extends(i,e),Object.defineProperty(i.prototype,"radius",{get:function(){return this.shape.radius},set:function(t){this.setRadius(t)},enumerable:!0,configurable:!0}),i.prototype.setRadius=function(e){this._colliderRequiresAutoSizing=!1;var i=this.shape;return e!=i.radius&&(i.radius=e,i._originalRadius=e,this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},i.prototype.toString=function(){return"[CircleCollider: bounds: "+this.bounds+", radius: "+this.shape.radius+"]"},i}(t.Collider);t.CircleCollider=e}(es||(es={})),function(t){var e=function(e){function i(i){var n=e.call(this)||this;i[0]==i[i.length-1]&&i.splice(i.length-1,1);var r=t.Polygon.findPolygonCenter(i);return n.setLocalOffset(r),t.Polygon.recenterPolygonVerts(i),n.shape=new t.Polygon(i),n}return __extends(i,e),i}(t.Collider);t.PolygonCollider=e}(es||(es={})),function(t){var e=function(){function e(e){this._entities=[],this._matcher=e||t.Matcher.empty()}return Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(t){this._scene=t,this._entities=[]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"matcher",{get:function(){return this._matcher},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onChanged=function(t){var e=this._entities.contains(t),i=this._matcher.IsIntersted(t);i&&!e?this.add(t):!i&&e&&this.remove(t)},e.prototype.add=function(t){this._entities.push(t),this.onAdded(t)},e.prototype.onAdded=function(t){},e.prototype.remove=function(t){this._entities.remove(t),this.onRemoved(t)},e.prototype.onRemoved=function(t){},e.prototype.update=function(){this.begin(),this.process(this._entities)},e.prototype.lateUpdate=function(){this.lateProcess(this._entities),this.end()},e.prototype.begin=function(){},e.prototype.process=function(t){},e.prototype.lateProcess=function(t){},e.prototype.end=function(){},e}();t.EntitySystem=e}(es||(es={})),function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.lateProcessEntity=function(t){},e.prototype.process=function(t){var e=this;t.forEach(function(t){return e.processEntity(t)})},e.prototype.lateProcess=function(t){var e=this;t.forEach(function(t){return e.lateProcessEntity(t)})},e}(t.EntitySystem);t.EntityProcessingSystem=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.onChanged=function(t){},e.prototype.process=function(t){this.begin(),this.end()},e}(t.EntitySystem);t.PassiveSystem=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.onChanged=function(t){},e.prototype.process=function(t){this.begin(),this.processSystem(),this.end()},e}(t.EntitySystem);t.ProcessingSystem=e}(es||(es={})),function(t){var e=function(){function t(e){void 0===e&&(e=64);var i=e>>6;0!=(e&t.LONG_MASK)&&i++,this._bits=new Array(i)}return t.prototype.and=function(t){for(var e,i=Math.min(this._bits.length,t._bits.length),n=0;n<i;++n)this._bits[n]&=t._bits[n];for(;e<this._bits.length;)this._bits[e++]=0},t.prototype.andNot=function(t){for(var e=Math.min(this._bits.length,t._bits.length);--e>=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var i=this._bits[e];if(0!=i)if(-1!=i){var n=((i=((i=(i>>1&0x5555555555555400)+(0x5555555555555400&i))>>2&0x3333333333333400)+(0x3333333333333400&i))>>32)+i;t+=((n=((n=(n>>4&252645135)+(252645135&n))>>8&16711935)+(16711935&n))>>16&65535)+(65535&n)}else t+=64}return t},t.prototype.clear=function(t){if(null!=t){var e=t>>6;this.ensure(e),this._bits[e]&=~(1<<t)}else for(var i=0;i<this._bits.length;i++)this._bits[i]=0},t.prototype.get=function(t){var e=t>>6;return!(e>=this._bits.length)&&0!=(this._bits[e]&1<<t)},t.prototype.intersects=function(t){for(var e=Math.min(this._bits.length,t._bits.length);--e>=0;)if(0!=(this._bits[e]&t._bits[e]))return!0;return!1},t.prototype.isEmpty=function(){for(var t=this._bits.length-1;t>=0;t--)if(this._bits[t])return!1;return!0},t.prototype.nextSetBit=function(t){for(var e=t>>6,i=1<<t;e<this._bits.length;){var n=this._bits[e];do{if(0!=(n&i))return t;i<<=1,t++}while(0!=i);i=1,e++}return-1},t.prototype.set=function(t,e){if(void 0===e&&(e=!0),e){var i=t>>6;this.ensure(i),this._bits[i]|=1<<t}else this.clear(t)},t.prototype.ensure=function(t){if(t>=this._bits.length){var e=new Number[t+1];e=this._bits.copyWithin(0,0,this._bits.length),this._bits=e}},t.LONG_MASK=63,t}();t.BitSet=e}(es||(es={})),function(t){var e=function(){function e(t){this._components=[],this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=t}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(t){this._componentsToRemove.contains(t)&&console.warn("You are trying to remove a Component ("+t+") that you already removed"),this._componentsToAdd.contains(t)?this._componentsToAdd.remove(t):this._componentsToRemove.push(t)},e.prototype.removeAllComponents=function(){for(var t=0;t<this._components.length;t++)this.handleRemove(this._components[t]);this._components.length=0,this._componentsToAdd.length=0,this._componentsToRemove.length=0},e.prototype.deregisterAllComponents=function(){for(var e=0;e<this._components.length;e++){var i=this._components[e];i instanceof t.RenderableComponent&&(this._entity.scene.removeChild(i.displayObject),this._entity.scene.renderableComponents.remove(i)),this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(i),!1),this._entity.scene.entityProcessors.onComponentRemoved(this._entity)}},e.prototype.registerAllComponents=function(){for(var e=0;e<this._components.length;e++){var i=this._components[e];i instanceof t.RenderableComponent&&(this._entity.scene.addChild(i.displayObject),this._entity.scene.renderableComponents.add(i)),this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(i)),this._entity.scene.entityProcessors.onComponentAdded(this._entity)}},e.prototype.updateLists=function(){if(this._componentsToRemove.length>0){for(var i=0;i<this._componentsToRemove.length;i++)this.handleRemove(this._componentsToRemove[i]),this._components.remove(this._componentsToRemove[i]);this._componentsToRemove.length=0}if(this._componentsToAdd.length>0){i=0;for(var n=this._componentsToAdd.length;i<n;i++){(r=this._componentsToAdd[i])instanceof t.RenderableComponent&&(this._entity.scene.addChild(r.displayObject),this._entity.scene.renderableComponents.add(r)),this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(r)),this._entity.scene.entityProcessors.onComponentAdded(this._entity),this._components.push(r),this._tempBufferList.push(r)}this._componentsToAdd.length=0,this._isComponentListUnsorted=!0;for(i=0;i<this._tempBufferList.length;i++){var r;(r=this._tempBufferList[i]).onAddedToEntity(),r.enabled&&r.onEnabled()}this._tempBufferList.length=0}this._isComponentListUnsorted&&(this._components.sort(e.compareUpdatableOrder.compare),this._isComponentListUnsorted=!1)},e.prototype.handleRemove=function(e){e instanceof t.RenderableComponent&&(this._entity.scene.removeChild(e.displayObject),this._entity.scene.renderableComponents.remove(e)),this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(e),!1),this._entity.scene.entityProcessors.onComponentRemoved(this._entity),e.onRemovedFromEntity(),e.entity=null},e.prototype.getComponent=function(t,e){for(var i=0;i<this._components.length;i++){if((n=this._components[i])instanceof t)return n}if(!e)for(i=0;i<this._componentsToAdd.length;i++){var n;if((n=this._componentsToAdd[i])instanceof t)return n}return null},e.prototype.getComponents=function(t,e){e||(e=[]);for(var i=0;i<this._components.length;i++){var n=this._components[i];"string"==typeof t?egret.is(n,t)&&e.push(n):n instanceof t&&e.push(n)}for(i=0;i<this._componentsToAdd.length;i++){n=this._componentsToAdd[i];"string"==typeof t?egret.is(n,t)&&e.push(n):n instanceof t&&e.push(n)}return e},e.prototype.update=function(){this.updateLists();for(var e=0;e<this._components.length;e++){var i=this._components[e];!i.enabled||1!=i.updateInterval&&t.Time.frameCount%i.updateInterval!=0||i.update()}},e.prototype.onEntityTransformChanged=function(t){for(var e=0;e<this._components.length;e++)this._components[e].enabled&&this._components[e].onEntityTransformChanged(t);for(e=0;e<this._componentsToAdd.length;e++)this._componentsToAdd[e].enabled&&this._componentsToAdd[e].onEntityTransformChanged(t)},e.prototype.onEntityEnabled=function(){for(var t=0;t<this._components.length;t++)this._components[t].onEnabled()},e.prototype.onEntityDisabled=function(){for(var t=0;t<this._components.length;t++)this._components[t].onDisabled()},e.compareUpdatableOrder=new t.IUpdatableComparer,e}();t.ComponentList=e}(es||(es={})),function(t){var e=function(){function t(){}return t.add=function(t){this._componentTypesMask.has(t)||(this._componentTypesMask[t]=this._componentTypesMask.size)},t.getIndexFor=function(t){var e=-1;return this._componentTypesMask.has(t)||(this.add(t),e=this._componentTypesMask.get(t)),e},t._componentTypesMask=new Map,t}();t.ComponentTypeManager=e}(es||(es={})),function(t){var e=function(){function e(t){this._entities=[],this._entitiesToAdded=[],this._entitiesToRemove=[],this._entityDict=new Map,this._unsortedTags=[],this._tempEntityList=[],this.scene=t}return Object.defineProperty(e.prototype,"count",{get:function(){return this._entities.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._entities},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isEntityListUnsorted=!0},e.prototype.markTagUnsorted=function(t){this._unsortedTags.push(t)},e.prototype.add=function(t){-1==this._entitiesToAdded.indexOf(t)&&this._entitiesToAdded.push(t)},e.prototype.remove=function(t){this._entitiesToRemove.contains(t)?this._entitiesToAdded.contains(t)?this._entitiesToAdded.remove(t):this._entitiesToRemove.contains(t)||this._entitiesToRemove.push(t):console.warn("You are trying to remove an entity ("+t.name+") that you already removed")},e.prototype.removeAllEntities=function(){this._unsortedTags.length=0,this._entitiesToAdded.length=0,this._isEntityListUnsorted=!1,this.updateLists();for(var t=0;t<this._entities.length;t++)this._entities[t]._isDestroyed=!0,this._entities[t].onRemovedFromScene(),this._entities[t].scene=null;this._entities.length=0,this._entityDict.clear()},e.prototype.contains=function(t){return this._entities.contains(t)||this._entitiesToAdded.contains(t)},e.prototype.getTagList=function(t){var e=this._entityDict.get(t);return e||(e=[],this._entityDict.set(t,e)),this._entityDict.get(t)},e.prototype.addToTagList=function(t){var e=this.getTagList(t.tag);e.contains(t)||(e.push(t),this._unsortedTags.push(t.tag))},e.prototype.removeFromTagList=function(t){var e=this._entityDict.get(t.tag);e&&e.remove(t)},e.prototype.update=function(){for(var e=0;e<this._entities.length;e++){var i=this._entities[e];!i.enabled||1!=i.updateInterval&&t.Time.frameCount%i.updateInterval!=0||i.update()}},e.prototype.updateLists=function(){var t=this;if(this._entitiesToRemove.length>0){var e=this._entitiesToRemove;this._entitiesToRemove=this._tempEntityList,this._tempEntityList=e,this._tempEntityList.forEach(function(e){t.removeFromTagList(e),t._entities.remove(e),e.onRemovedFromScene(),e.scene=null,t.scene.entityProcessors.onEntityRemoved(e)}),this._tempEntityList.length=0}if(this._entitiesToAdded.length>0){e=this._entitiesToAdded;this._entitiesToAdded=this._tempEntityList,this._tempEntityList=e,this._tempEntityList.forEach(function(e){t._entities.contains(e)||(t._entities.push(e),e.scene=t.scene,t.addToTagList(e),t.scene.entityProcessors.onEntityAdded(e))}),this._tempEntityList.forEach(function(t){return t.onAddedToScene()}),this._tempEntityList.length=0,this._isEntityListUnsorted=!0}this._isEntityListUnsorted&&(this._entities.sort(),this._isEntityListUnsorted=!1),this._unsortedTags.length>0&&(this._unsortedTags.forEach(function(e){t._entityDict.get(e).sort()}),this._unsortedTags.length=0)},e.prototype.findEntity=function(t){for(var e=0;e<this._entities.length;e++)if(this._entities[e].name==t)return this._entities[e];return this._entitiesToAdded.firstOrDefault(function(e){return e.name==t})},e.prototype.entitiesWithTag=function(e){for(var i=this.getTagList(e),n=t.ListPool.obtain(),r=0;r<i.length;r++)n.push(i[r]);return n},e.prototype.entitiesOfType=function(e){for(var i=t.ListPool.obtain(),n=0;n<this._entities.length;n++)this._entities[n]instanceof e&&i.push(this._entities[n]);return this._entitiesToAdded.forEach(function(t){t instanceof e&&i.push(t)}),i},e.prototype.findComponentOfType=function(t){for(var e=0;e<this._entities.length;e++){if(this._entities[e].enabled)if(i=this._entities[e].getComponent(t))return i}for(e=0;e<this._entitiesToAdded.length;e++){var i,n=this._entitiesToAdded[e];if(n.enabled)if(i=n.getComponent(t))return i}return null},e.prototype.findComponentsOfType=function(e){for(var i=t.ListPool.obtain(),n=0;n<this._entities.length;n++)this._entities[n].enabled&&this._entities[n].getComponents(e,i);for(n=0;n<this._entitiesToAdded.length;n++){var r=this._entitiesToAdded[n];r.enabled&&r.getComponents(e,i)}return i},e}();t.EntityList=e}(es||(es={})),function(t){var e=function(){function e(){this._processors=[]}return e.prototype.add=function(t){this._processors.push(t)},e.prototype.remove=function(t){this._processors.remove(t)},e.prototype.onComponentAdded=function(t){this.notifyEntityChanged(t)},e.prototype.onComponentRemoved=function(t){this.notifyEntityChanged(t)},e.prototype.onEntityAdded=function(t){this.notifyEntityChanged(t)},e.prototype.onEntityRemoved=function(t){this.removeFromProcessors(t)},e.prototype.begin=function(){},e.prototype.update=function(){for(var t=0;t<this._processors.length;t++)this._processors[t].update()},e.prototype.lateUpdate=function(){for(var t=0;t<this._processors.length;t++)this._processors[t].lateUpdate()},e.prototype.end=function(){},e.prototype.getProcessor=function(){for(var e=0;e<this._processors.length;e++){var i=this._processors[e];if(i instanceof t.EntitySystem)return i}return null},e.prototype.notifyEntityChanged=function(t){for(var e=0;e<this._processors.length;e++)this._processors[e].onChanged(t)},e.prototype.removeFromProcessors=function(t){for(var e=0;e<this._processors.length;e++)this._processors[e].remove(t)},e}();t.EntityProcessorList=e}(es||(es={})),function(t){var e=function(){function e(){this.allSet=new t.BitSet,this.exclusionSet=new t.BitSet,this.oneSet=new t.BitSet}return e.empty=function(){return new e},e.prototype.getAllSet=function(){return this.allSet},e.prototype.getExclusionSet=function(){return this.exclusionSet},e.prototype.getOneSet=function(){return this.oneSet},e.prototype.IsIntersted=function(t){if(!this.allSet.isEmpty())for(var e=this.allSet.nextSetBit(0);e>=0;e=this.allSet.nextSetBit(e+1))if(!t.componentBits.get(e))return!1;return!(!this.exclusionSet.isEmpty()&&this.exclusionSet.intersects(t.componentBits))&&!(!this.oneSet.isEmpty()&&!this.oneSet.intersects(t.componentBits))},e.prototype.all=function(){for(var e=this,i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];return i.forEach(function(i){e.allSet.set(t.ComponentTypeManager.getIndexFor(i))}),this},e.prototype.exclude=function(){for(var e=this,i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];return i.forEach(function(i){e.exclusionSet.set(t.ComponentTypeManager.getIndexFor(i))}),this},e.prototype.one=function(){for(var e=this,i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];return i.forEach(function(i){e.oneSet.set(t.ComponentTypeManager.getIndexFor(i))}),this},e}();t.Matcher=e}(es||(es={}));var ObjectUtils=function(){function t(){}return t.clone=function(t,e){void 0===e&&(e=null);e=e||{};for(var i in t)"object"==typeof t[i]?(e[i]=t[i]instanceof Array?[]:{},this.clone(t[i],e[i])):e[i]=t[i];return e},t.elements=function(t){var e=[];for(var i in t)if(Array.isArray(t[i]))for(var n=0,r=t[i];n<r.length;n++){var o=r[n];e.push(o)}else e.push(t[i]);return e},t}();!function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return e.renderLayer-t.renderLayer},t}();t.RenderableComparer=e}(es||(es={})),function(t){var e=function(){function e(){this._components=[],this._componentsByRenderLayer=new Map,this._unsortedRenderLayers=[],this._componentsNeedSort=!0}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components},enumerable:!0,configurable:!0}),e.prototype.add=function(t){this._components.push(t),this.addToRenderLayerList(t,t.renderLayer)},e.prototype.remove=function(t){this._components.remove(t),this._componentsByRenderLayer.get(t.renderLayer).remove(t)},e.prototype.updateRenderableRenderLayer=function(t,e,i){this._componentsByRenderLayer.has(e)&&this._componentsByRenderLayer.get(e).contains(t)&&(this._componentsByRenderLayer.get(e).remove(t),this.addToRenderLayerList(t,i))},e.prototype.setRenderLayerNeedsComponentSort=function(t){this._unsortedRenderLayers.contains(t)||this._unsortedRenderLayers.push(t),this._componentsNeedSort=!0},e.prototype.setNeedsComponentSort=function(){this._componentsNeedSort=!0},e.prototype.addToRenderLayerList=function(t,e){var i=this.componentsWithRenderLayer(e);i.contains(t)?console.warn("组件呈现层列表已经包含此组件"):(i.push(t),this._unsortedRenderLayers.contains(e)||this._unsortedRenderLayers.push(e),this._componentsNeedSort=!0)},e.prototype.componentsWithRenderLayer=function(t){return this._componentsByRenderLayer.get(t)||this._componentsByRenderLayer.set(t,[]),this._componentsByRenderLayer.get(t)},e.prototype.updateList=function(){if(this._componentsNeedSort&&(this._components.sort(e.compareUpdatableOrder.compare),this._componentsNeedSort=!1,this.updateEgretList()),this._unsortedRenderLayers.length>0){for(var t=0,i=this._unsortedRenderLayers.length;t<i;t++){var n=this._componentsByRenderLayer.get(this._unsortedRenderLayers[t]);n&&n.sort(e.compareUpdatableOrder.compare)}this._unsortedRenderLayers.length=0,this.updateEgretList()}},e.prototype.updateEgretList=function(){var e=t.Core._instance._scene;if(e)for(var i=function(t){var i=n._components[t],r=e.$children.find(function(t){return t.hashCode==i.displayObject.hashCode}),o=e.getChildIndex(r);o!=t&&e.swapChildrenAt(o,t)},n=this,r=0;r<this._components.length;r++)i(r)},e.compareUpdatableOrder=new t.RenderableComparer,e}();t.RenderableComponentList=e}(es||(es={}));var StringUtils=function(){function t(){}return t.matchChineseWord=function(t){return t.match(/[\u4E00-\u9FA5]+/gim)},t.lTrim=function(t){for(var e=0;this.isWhiteSpace(t.charAt(e));)e++;return t.slice(e,t.length)},t.rTrim=function(t){for(var e=t.length-1;this.isWhiteSpace(t.charAt(e));)e--;return t.slice(0,e+1)},t.trim=function(t){return null==t?null:this.rTrim(this.lTrim(t))},t.isWhiteSpace=function(t){return" "==t||"\t"==t||"\r"==t||"\n"==t},t.replaceMatch=function(t,e,i,n){void 0===n&&(n=!1);for(var r=t.length,o="",s=!1,a=1==n?e.toLowerCase():e,c=0;c<r;c++)s=!1,t.charAt(c)==a.charAt(0)&&t.substr(c,a.length)==a&&(s=!0),s?(o+=i,c=c+a.length-1):o+=t.charAt(c);return o},t.htmlSpecialChars=function(t,e){void 0===e&&(e=!1);for(var i=this.specialSigns.length,n=0;n<i;n+=2){var r=void 0,o=void 0;if(r=this.specialSigns[n],o=this.specialSigns[n+1],e){var s=r;r=o,o=s}t=this.replaceMatch(t,r,o)}return t},t.zfill=function(t,e){if(void 0===e&&(e=2),!t)return t;e=Math.floor(e);var i=t.length;if(i>=e)return t;var n=!1;"-"==t.substr(0,1)&&(n=!0,t=t.substr(1));for(var r=e-i,o=0;o<r;o++)t="0"+t;return n&&(t="-"+t),t},t.reverse=function(t){return t.length>1?this.reverse(t.substring(1))+t.substring(0,1):t},t.cutOff=function(t,e,i,n){void 0===n&&(n=!0),e=Math.floor(e),i=Math.floor(i);var r=t.length;e>r&&(e=r);var o,s=e,a=e+i;return n?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-i)+i,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var i=0,n=e.length;i<n;i++)null!=e[i]&&""!=e[i]||(e[i]="无"),t=t.replace("{"+i+"}",e[i]);return t},t.specialSigns=["&","&amp;","<","&lt;",">","&gt;",'"',"&quot;","'","&apos;","®","&reg;","©","&copy;","™","&trade;"],t}();!function(t){var e=function(){function e(){}return e.convertImageToCanvas=function(e,i){this.sharedCanvas||(this.sharedCanvas=egret.sys.createCanvas(),this.sharedContext=this.sharedCanvas.getContext("2d"));var n=e.$getTextureWidth(),r=e.$getTextureHeight();i||((i=egret.$TempRectangle).x=0,i.y=0,i.width=n,i.height=r),i.x=Math.min(i.x,n-1),i.y=Math.min(i.y,r-1),i.width=Math.min(i.width,n-i.x),i.height=Math.min(i.height,r-i.y);var o=Math.floor(i.width),s=Math.floor(i.height),a=this.sharedCanvas;if(a.style.width=o+"px",a.style.height=s+"px",this.sharedCanvas.width=o,this.sharedCanvas.height=s,"webgl"==egret.Capabilities.renderMode){var c=void 0;e.$renderBuffer?c=e:(egret.sys.systemRenderer.renderClear&&egret.sys.systemRenderer.renderClear(),(c=new egret.RenderTexture).drawToTexture(new egret.Bitmap(e)));for(var h=c.$renderBuffer.getPixels(i.x,i.y,o,s),u=0,l=0,p=0;p<h.length;p+=4)this.sharedContext.fillStyle="rgba("+h[p]+","+h[p+1]+","+h[p+2]+","+h[p+3]/255+")",this.sharedContext.fillRect(u,l,1,1),++u==o&&(u=0,l++);return e.$renderBuffer||c.dispose(),a}var d=e,f=Math.round(d.$offsetX),m=Math.round(d.$offsetY),g=d.$bitmapWidth,y=d.$bitmapHeight,_=t.Core._instance.stage.textureScaleFactor;return this.sharedContext.drawImage(d.$bitmapData.source,d.$bitmapX+i.x/_,d.$bitmapY+i.y/_,g*i.width/n,y*i.height/r,f,m,i.width,i.height),a},e.toDataURL=function(t,e,i,n){try{return this.convertImageToCanvas(e,i).toDataURL(t,n)}catch(t){egret.$error(1033)}return null},e.eliFoTevas=function(t,e,i,n,r){var o=this.convertImageToCanvas(e,n).toTempFilePathSync({fileType:t.indexOf("png")>=0?"png":"jpg"});return wx.getFileSystemManager().saveFile({tempFilePath:o,filePath:wx.env.USER_DATA_PATH+"/"+i,success:function(t){}}),o},e.getPixel32=function(t,e,i){return egret.$warn(1041,"getPixel32","getPixels"),t.getPixels(e,i)},e.getPixels=function(t,e,i,n,r){if(void 0===n&&(n=1),void 0===r&&(r=1),"webgl"==egret.Capabilities.renderMode){var o=void 0;return t.$renderBuffer?o=t:(o=new egret.RenderTexture).drawToTexture(new egret.Bitmap(t)),o.$renderBuffer.getPixels(e,i,n,r)}try{this.convertImageToCanvas(t);return this.sharedContext.getImageData(e,i,n,r).data}catch(t){egret.$error(1039)}},e}();t.TextureUtils=e}(es||(es={})),function(t){var e=function(){function t(){}return t.update=function(t){var e=(t-this._lastTime)/1e3;this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this._timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this._timeSinceSceneLoad=0},t.checkEvery=function(t){return this._timeSinceSceneLoad/t>(this._timeSinceSceneLoad-this.deltaTime)/t},t.deltaTime=0,t.timeScale=1,t.frameCount=0,t._lastTime=0,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),i=t.getMonth()+1;return parseInt(e+(i<10?"0":"")+i)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,i=e<10?"0":"",n=t.getDate(),r=n<10?"0":"";return parseInt(t.getFullYear()+i+e+r+n)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var i=new Date;i.setTime(t.getTime()),i.setDate(1),i.setMonth(0);var n=i.getFullYear(),r=i.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,i.setDate(i.getDate()-(r-1))):i.setDate(i.getDate()+7-r+1);var s=this.diffDay(t,i,!1);if(s<0)return i.setDate(1),i.setMonth(0),i.setDate(i.getDate()-1),this.weekId(i,!1);var a=s/7,c=Math.floor(a)+1;if(53==c){i.setTime(t.getTime()),i.setDate(i.getDate()-1);var h=i.getDay();if(0==h&&(h=7),e&&(!o||h<4))return i.setFullYear(i.getFullYear()+1),i.setDate(1),i.setMonth(0),this.weekId(i,!1)}return parseInt(n+"00"+(c>9?"":"0")+c)},t.diffDay=function(t,e,i){void 0===i&&(i=!1);var n=(t.getTime()-e.getTime())/864e5;return i?Math.ceil(n):Math.floor(n)},t.getFirstDayOfWeek=function(t){var e=(t=t||new Date).getDay()||7;return new Date(t.getFullYear(),t.getMonth(),t.getDate()+1-e,0,0,0,0)},t.getFirstOfDay=function(t){return(t=t||new Date).setHours(0,0,0,0),t},t.getNextFirstOfDay=function(t){return new Date(this.getFirstOfDay(t).getTime()+864e5)},t.formatDate=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();return e+"-"+i+"-"+(n=n<10?"0"+n:n)},t.formatDateTime=function(t){var e=t.getFullYear(),i=t.getMonth()+1;i=i<10?"0"+i:i;var n=t.getDate();n=n<10?"0"+n:n;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+i+"-"+n+" "+r+":"+o+":"+(s=s<10?"0"+s:s)},t.parseDate=function(t){var e=Date.parse(t);return isNaN(e)?new Date:new Date(Date.parse(t.replace(/-/g,"/")))},t.secondToTime=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===i&&(i=!0);var n=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=n.toString(),a=r.toString(),c=o.toString();return n<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(c="0"+c),i?s+e+a+e+c:a+e+c},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var i=t.split(e),n=0,r=i.length,o=0;o<r;o++){n+=i[o]*Math.pow(60,r-1-o)}return(n*=1e3).toString()},t}();!function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.initialize=function(t){this.platformInitialize(t)},e.prototype.platformInitialize=function(t){if(e.runtimeType==egret.RuntimeType.WXGAME){this.isMobile=!0;var i=wx.getSystemInfoSync(),n=i.system.toLowerCase();n.indexOf("ios")>-1?this.os="iOS":n.indexOf("android")>-1&&(this.os="Android");var r=i.language;r=r.indexOf("zh")>-1?"zh-CN":"en-US",this.language=r}},e}(egret.Capabilities);t.GraphicsCapabilities=e}(es||(es={})),function(t){var e=function(){function e(){this.setup(),this.graphicsCapabilities=new t.GraphicsCapabilities,this.graphicsCapabilities.initialize(this)}return Object.defineProperty(e.prototype,"viewport",{get:function(){return this._viewport},enumerable:!0,configurable:!0}),e.prototype.setup=function(){this._viewport=new t.Viewport(0,0,t.Core._instance.stage.stageWidth,t.Core._instance.stage.stageHeight)},e}();t.GraphicsDevice=e}(es||(es={})),function(t){var e=function(){function e(t,e,i,n){this._x=t,this._y=e,this._width=i,this._height=n,this._minDepth=0,this._maxDepth=1}return Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(t){this._width=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(t){this._height=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return 0!=this._height&&0!=this._width?this._width/this._height:0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bounds",{get:function(){return new t.Rectangle(this._x,this._y,this._width,this._height)},set:function(t){this._x=t.x,this._y=t.y,this._width=t.width,this._height=t.height},enumerable:!0,configurable:!0}),e}();t.Viewport=e}(es||(es={})),function(t){var e=function(e){function i(){return e.call(this,t.PostProcessor.default_vert,i.blur_frag,{screenWidth:t.Core.graphicsDevice.viewport.width,screenHeight:t.Core.graphicsDevice.viewport.height})||this}return __extends(i,e),i.blur_frag="precision mediump float;\nuniform sampler2D uSampler;\nuniform float screenWidth;\nuniform float screenHeight;\nfloat normpdf(in float x, in float sigma)\n{\nreturn 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\n}\nvoid main()\n{\nvec3 c = texture2D(uSampler, gl_FragCoord.xy / vec2(screenWidth, screenHeight).xy).rgb;\nconst int mSize = 11;\nconst int kSize = (mSize - 1)/2;\nfloat kernel[mSize];\nvec3 final_colour = vec3(0.0);\nfloat sigma = 7.0;\nfloat z = 0.0;\nfor (int j = 0; j <= kSize; ++j)\n{\nkernel[kSize+j] = kernel[kSize-j] = normpdf(float(j),sigma);\n}\nfor (int j = 0; j < mSize; ++j)\n{\nz += kernel[j];\n}\nfor (int i = -kSize; i <= kSize; ++i)\n{\nfor (int j = -kSize; j <= kSize; ++j)\n{\nfinal_colour += kernel[kSize+j]*kernel[kSize+i]*texture2D(uSampler, (gl_FragCoord.xy+vec2(float(i),float(j))) / vec2(screenWidth, screenHeight).xy).rgb;\n}\n}\ngl_FragColor = vec4(final_colour/(z*z), 1.0);\n}",i}(egret.CustomFilter);t.GaussianBlurEffect=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,e.vertSrc,e.fragmentSrc)||this}return __extends(e,t),e.vertSrc="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e.fragmentSrc="precision lowp float;\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\n#define SAMPLE_COUNT 15\nuniform vec2 _sampleOffsets[SAMPLE_COUNT];\nuniform float _sampleWeights[SAMPLE_COUNT];\nvoid main(void) {\nvec4 c = vec4(0, 0, 0, 0);\nfor( int i = 0; i < SAMPLE_COUNT; i++ )\n c += texture2D( uSampler, vTextureCoord + _sampleOffsets[i] ) * _sampleWeights[i];\ngl_FragColor = c;\n}",e}(egret.CustomFilter);t.PolygonLightEffect=e}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=null),this.enabled=!0,this.effect=t}return e.prototype.onAddedToScene=function(e){this.scene=e,this.shape=new egret.Shape,this.shape.graphics.beginFill(16777215,1),this.shape.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this.shape.graphics.endFill(),e.addChild(this.shape)},e.prototype.process=function(){this.drawFullscreenQuad()},e.prototype.onSceneBackBufferSizeChanged=function(t,e){},e.prototype.unload=function(){this.effect&&(this.effect=null),this.scene.removeChild(this.shape),this.scene=null},e.prototype.drawFullscreenQuad=function(){this.scene.filters=[this.effect]},e.default_vert="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nattribute vec2 aColor;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nvarying vec4 vColor;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\ngl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\nvTextureCoord = aTextureCoord;\nvColor = vec4(aColor.x, aColor.x, aColor.x, aColor.x);\n}",e}();t.PostProcessor=e}(es||(es={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),i.prototype.onAddedToScene=function(i){e.prototype.onAddedToScene.call(this,i),this.effect=new t.GaussianBlurEffect},i}(t.PostProcessor);t.GaussianBlurPostProcessor=e}(es||(es={})),function(t){var e=function(){function t(t,e){void 0===e&&(e=null),this.renderOrder=0,this.camera=e,this.renderOrder=t}return t.prototype.onAddedToScene=function(t){},t.prototype.unload=function(){},t.prototype.onSceneBackBufferSizeChanged=function(t,e){},t.prototype.compareTo=function(t){return this.renderOrder-t.renderOrder},t.prototype.beginRender=function(t){},t.prototype.renderAfterStateCheck=function(t,e){t.render(e)},t}();t.Renderer=e}(es||(es={})),function(t){var e=function(t){function e(){return t.call(this,0,null)||this}return __extends(e,t),e.prototype.render=function(t){var e=this.camera?this.camera:t.camera;this.beginRender(e);for(var i=0;i<t.renderableComponents.count;i++){var n=t.renderableComponents.buffer[i];n.enabled&&n.isVisibleFromCamera(e)&&this.renderAfterStateCheck(n,e)}},e}(t.Renderer);t.DefaultRenderer=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.render=function(t){},e}(t.Renderer);t.ScreenSpaceRenderer=e}(es||(es={})),function(t){var e=function(t){function e(e,i,n){var r=t.call(this)||this;return r._indices=[],r.radius=e,r.power=n,r.color=i,r.computeTriangleIndices(),r}return __extends(e,t),Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(t){this.setRadius(t)},enumerable:!0,configurable:!0}),e.prototype.setRadius=function(t){t!=this._radius&&(this._radius=t,this._areBoundsDirty=!0)},e.prototype.render=function(t){},e.prototype.reset=function(){},e.prototype.computeTriangleIndices=function(t){void 0===t&&(t=20),this._indices.length=0;for(var e=0;e<t;e+=2)this._indices.push(0),this._indices.push(e+2),this._indices.push(e+1)},e}(t.RenderableComponent);t.PolyLight=e}(es||(es={})),function(t){var e=function(){function e(t){this.sceneLoadAction=t,this.loadsNewScene=null!=t}return Object.defineProperty(e.prototype,"hasPreviousSceneRender",{get:function(){return!!this._hasPreviousSceneRender||(this._hasPreviousSceneRender=!0,!1)},enumerable:!0,configurable:!0}),e.prototype.preRender=function(){},e.prototype.render=function(){},e.prototype.onBeginTransition=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.loadNextScene()];case 1:return t.sent(),this.transitionComplete(),[2]}})})},e.prototype.tickEffectProgressProperty=function(t,e,i,n){return void 0===n&&(n=!1),new Promise(function(r){var o=n?1:0,s=n?0:1;egret.Tween.get(t.uniforms).set({_progress:o}).to({_progress:s},1e3*e,i).call(function(){r()})})},e.prototype.transitionComplete=function(){t.Core._instance._sceneTransition=null,this.onTransitionCompleted&&this.onTransitionCompleted()},e.prototype.loadNextScene=function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(i){switch(i.label){case 0:return this.onScreenObscured&&this.onScreenObscured(),this.loadsNewScene||(this.isNewSceneLoaded=!0),e=t.Core,[4,this.sceneLoadAction()];case 1:return e.scene=i.sent(),this.isNewSceneLoaded=!0,[2]}})})},e}();t.SceneTransition=e}(es||(es={})),function(t){var e=function(e){function i(t){var i=e.call(this,t)||this;return i.fadeToColor=0,i.fadeOutDuration=.4,i.fadeEaseType=egret.Ease.quadInOut,i.delayBeforeFadeInDuration=.1,i._alpha=0,i._mask=new egret.Shape,i}return __extends(i,e),i.prototype.onBeginTransition=function(){return __awaiter(this,void 0,void 0,function(){var e=this;return __generator(this,function(i){return this._mask.graphics.beginFill(this.fadeToColor,1),this._mask.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this._mask.graphics.endFill(),egret.Tween.get(this).to({_alpha:1},1e3*this.fadeOutDuration,this.fadeEaseType).call(function(){return __awaiter(e,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return[4,this.loadNextScene()];case 1:return t.sent(),[2]}})})}).wait(this.delayBeforeFadeInDuration).call(function(){egret.Tween.get(e).to({_alpha:0},1e3*e.fadeOutDuration,e.fadeEaseType).call(function(){e.transitionComplete()})}),[2]})})},i.prototype.render=function(){this._mask.graphics.clear(),this._mask.graphics.beginFill(this.fadeToColor,this._alpha),this._mask.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this._mask.graphics.endFill()},i}(t.SceneTransition);t.FadeTransition=e}(es||(es={})),function(t){var e=function(e){function i(i){var n=e.call(this,i)||this;n.duration=1,n.easeType=egret.Ease.quadOut;return n._windEffect=new egret.CustomFilter("attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\nuniform vec2 projectionVector;\nvarying vec2 vTextureCoord;\nconst vec2 center = vec2(-1.0, 1.0);\nvoid main(void) {\n gl_Position = vec4( (aVertexPosition / projectionVector) + center , 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}","precision lowp float;\nvarying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform float _progress;\nuniform float _size;\nuniform float _windSegments;\nvoid main(void) {\nvec2 co = floor(vec2(0.0, vTextureCoord.y * _windSegments));\nfloat x = sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453;\nfloat r = x - floor(x);\nfloat m = smoothstep(0.0, -_size, vTextureCoord.x * (1.0 - _size) + _size * r - (_progress * (1.0 + _size)));\nvec4 fg = texture2D(uSampler, vTextureCoord);\ngl_FragColor = mix(fg, vec4(0, 0, 0, 0), m);\n}",{_progress:0,_size:.3,_windSegments:100}),n._mask=new egret.Shape,n._mask.graphics.beginFill(16777215,1),n._mask.graphics.drawRect(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),n._mask.graphics.endFill(),n._mask.filters=[n._windEffect],n}return __extends(i,e),Object.defineProperty(i.prototype,"windSegments",{set:function(t){this._windEffect.uniforms._windSegments=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"size",{set:function(t){this._windEffect.uniforms._size=t},enumerable:!0,configurable:!0}),i.prototype.onBeginTransition=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(t){switch(t.label){case 0:return this.loadNextScene(),[4,this.tickEffectProgressProperty(this._windEffect,this.duration,this.easeType)];case 1:return t.sent(),this.transitionComplete(),[2]}})})},i}(t.SceneTransition);t.WindTransition=e}(es||(es={})),function(t){var e=function(){function e(){}return e.getPoint=function(e,i,n,r){var o=1-(r=t.MathHelper.clamp01(r));return t.Vector2.add(t.Vector2.add(t.Vector2.multiply(new t.Vector2(o*o),e),t.Vector2.multiply(new t.Vector2(2*o*r),i)),t.Vector2.multiply(new t.Vector2(r*r),n))},e.getFirstDerivative=function(e,i,n,r){return t.Vector2.add(t.Vector2.multiply(new t.Vector2(2*(1-r)),t.Vector2.subtract(i,e)),t.Vector2.multiply(new t.Vector2(2*r),t.Vector2.subtract(n,i)))},e.getFirstDerivativeThree=function(e,i,n,r,o){var s=1-(o=t.MathHelper.clamp01(o));return t.Vector2.add(t.Vector2.add(t.Vector2.multiply(new t.Vector2(3*s*s),t.Vector2.subtract(i,e)),t.Vector2.multiply(new t.Vector2(6*s*o),t.Vector2.subtract(n,i))),t.Vector2.multiply(new t.Vector2(3*o*o),t.Vector2.subtract(r,n)))},e.getPointThree=function(e,i,n,r,o){var s=1-(o=t.MathHelper.clamp01(o));return t.Vector2.add(t.Vector2.add(t.Vector2.add(t.Vector2.multiply(new t.Vector2(s*s*s),e),t.Vector2.multiply(new t.Vector2(3*s*s*o),i)),t.Vector2.multiply(new t.Vector2(3*s*o*o),n)),t.Vector2.multiply(new t.Vector2(o*o*o),r))},e.getOptimizedDrawingPoints=function(e,i,n,r,o){void 0===o&&(o=1);var s=t.ListPool.obtain();return s.push(e),this.recursiveGetOptimizedDrawingPoints(e,i,n,r,s,o),s.push(r),s},e.recursiveGetOptimizedDrawingPoints=function(e,i,n,r,o,s){var a=t.Vector2.divide(t.Vector2.add(e,i),new t.Vector2(2)),c=t.Vector2.divide(t.Vector2.add(i,n),new t.Vector2(2)),h=t.Vector2.divide(t.Vector2.add(n,r),new t.Vector2(2)),u=t.Vector2.divide(t.Vector2.add(a,c),new t.Vector2(2)),l=t.Vector2.divide(t.Vector2.add(c,h),new t.Vector2(2)),p=t.Vector2.divide(t.Vector2.add(u,l),new t.Vector2(2)),d=t.Vector2.subtract(r,e),f=Math.abs((i.x,r.x*d.y-(i.y-r.y)*d.x)),m=Math.abs((n.x-r.x)*d.y-(n.y-r.y)*d.x);(f+m)*(f+m)<s*(d.x*d.x+d.y*d.y)?o.push(p):(this.recursiveGetOptimizedDrawingPoints(e,a,u,p,o,s),this.recursiveGetOptimizedDrawingPoints(p,l,h,r,o,s))},e}();t.Bezier=e}(es||(es={})),function(t){var e=function(){function t(){}return t.isFlagSet=function(t,e){return 0!=(t&e)},t.isUnshiftedFlagSet=function(t,e){return 0!=(t&(e=1<<e))},t.setFlagExclusive=function(t,e){return 1<<e},t.setFlag=function(t,e){return t|1<<e},t.unsetFlag=function(t,e){return t&~(e=1<<e)},t.invertFlags=function(t){return~t},t}();t.Flags=e}(es||(es={})),function(t){var e=function(){function e(){}return e.toDegrees=function(t){return 57.29577951308232*t},e.toRadians=function(t){return.017453292519943295*t},e.map=function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},e.lerp=function(t,e,i){return t+(e-t)*i},e.clamp=function(t,e,i){return t<e?e:t>i?i:t},e.pointOnCirlce=function(i,n,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+i.x,Math.sin(o)*o+i.y)},e.isEven=function(t){return t%2==0},e.clamp01=function(t){return t<0?0:t>1?1:t},e.angleBetweenVectors=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.Epsilon=1e-5,e.Rad2Deg=57.29578,e.Deg2Rad=.0174532924,e.PiOver2=Math.PI/2,e}();t.MathHelper=e}(es||(es={})),function(t){t.matrixPool=[];var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),Object.defineProperty(i.prototype,"m11",{get:function(){return this.a},set:function(t){this.a=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"m12",{get:function(){return this.b},set:function(t){this.b=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"m21",{get:function(){return this.c},set:function(t){this.c=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"m22",{get:function(){return this.d},set:function(t){this.d=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"m31",{get:function(){return this.tx},set:function(t){this.tx=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"m32",{get:function(){return this.ty},set:function(t){this.ty=t},enumerable:!0,configurable:!0}),i.create=function(){var e=t.matrixPool.pop();return e||(e=new i),e},i.prototype.identity=function(){return this.a=this.d=1,this.b=this.c=this.tx=this.ty=0,this},i.prototype.translate=function(t,e){return this.tx+=t,this.ty+=e,this},i.prototype.scale=function(t,e){return 1!==t&&(this.a*=t,this.c*=t,this.tx*=t),1!==e&&(this.b*=e,this.d*=e,this.ty*=e),this},i.prototype.rotate=function(t){if(0!==(t=+t)){t/=DEG_TO_RAD;var e=Math.cos(t),i=Math.sin(t),n=this.a,r=this.b,o=this.c,s=this.d,a=this.tx,c=this.ty;this.a=n*e-r*i,this.b=n*i+r*e,this.c=o*e-s*i,this.d=o*i+s*e,this.tx=a*e-c*i,this.ty=a*i+c*e}return this},i.prototype.invert=function(){return this.$invertInto(this),this},i.prototype.add=function(t){return this.m11+=t.m11,this.m12+=t.m12,this.m21+=t.m21,this.m22+=t.m22,this.m31+=t.m31,this.m32+=t.m32,this},i.prototype.substract=function(t){return this.m11-=t.m11,this.m12-=t.m12,this.m21-=t.m21,this.m22-=t.m22,this.m31-=t.m31,this.m32-=t.m32,this},i.prototype.divide=function(t){return this.m11/=t.m11,this.m12/=t.m12,this.m21/=t.m21,this.m22/=t.m22,this.m31/=t.m31,this.m32/=t.m32,this},i.prototype.multiply=function(t){var e=this.m11*t.m11+this.m12*t.m21,i=this.m11*t.m12+this.m12*t.m22,n=this.m21*t.m11+this.m22*t.m21,r=this.m21*t.m12+this.m22*t.m22,o=this.m31*t.m11+this.m32*t.m21+t.m31,s=this.m31*t.m12+this.m32*t.m22+t.m32;return this.m11=e,this.m12=i,this.m21=n,this.m22=r,this.m31=o,this.m32=s,this},i.prototype.determinant=function(){return this.m11*this.m22-this.m12*this.m21},i.prototype.release=function(e){e&&t.matrixPool.push(e)},i}(egret.Matrix);t.Matrix2D=e}(es||(es={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),Object.defineProperty(i.prototype,"max",{get:function(){return new t.Vector2(this.right,this.bottom)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"center",{get:function(){return new t.Vector2(this.x+this.width/2,this.y+this.height/2)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"location",{get:function(){return new t.Vector2(this.x,this.y)},set:function(t){this.x=t.x,this.y=t.y},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"size",{get:function(){return new t.Vector2(this.width,this.height)},set:function(t){this.width=t.x,this.height=t.y},enumerable:!0,configurable:!0}),i.fromMinMax=function(t,e,n,r){return new i(t,e,n-t,r-e)},i.rectEncompassingPoints=function(t){for(var e=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=0;o<t.length;o++){var s=t[o];s.x<e&&(e=s.x),s.x>n&&(n=s.x),s.y<i&&(i=s.y),s.y>r&&(r=s.y)}return this.fromMinMax(e,i,n,r)},i.prototype.intersects=function(t){return t.left<this.right&&this.left<t.right&&t.top<this.bottom&&this.top<t.bottom},i.prototype.rayIntersects=function(t){var e=0,i=Number.MAX_VALUE;if(Math.abs(t.direction.x)<1e-6){if(t.start.x<this.x||t.start.x>this.x+this.width)return e}else{var n=1/t.direction.x,r=(this.x-t.start.x)*n,o=(this.x+this.width-t.start.x)*n;if(r>o){var s=r;r=o,o=s}if((e=Math.max(r,e))>(i=Math.min(o,i)))return e}if(Math.abs(t.direction.y)<1e-6){if(t.start.y<this.y||t.start.y>this.y+this.height)return e}else{var a=1/t.direction.y,c=(this.y-t.start.y)*a,h=(this.y+this.height-t.start.y)*a;if(c>h){var u=c;c=h,h=u}if((e=Math.max(c,e))>(i=Math.max(h,i)))return e}return e},i.prototype.containsRect=function(t){return this.x<=t.x&&t.x<this.x+this.width&&this.y<=t.y&&t.y<this.y+this.height},i.prototype.contains=function(t,e){return this.x<=t&&t<this.x+this.width&&this.y<=e&&e<this.y+this.height},i.prototype.getHalfSize=function(){return new t.Vector2(.5*this.width,.5*this.height)},i.prototype.getClosestPointOnRectangleBorderToPoint=function(e,i){i=t.Vector2.zero;var n=new t.Vector2;if(n.x=t.MathHelper.clamp(e.x,this.left,this.right),n.y=t.MathHelper.clamp(e.y,this.top,this.bottom),this.contains(n.x,n.y)){var r=n.x-this.left,o=this.right-n.x,s=n.y-this.top,a=this.bottom-n.y,c=Math.min(r,o,s,a);c==s?(n.y=this.top,i.y=-1):c==a?(n.y=this.bottom,i.y=1):c==r?(n.x=this.left,i.x=-1):(n.x=this.right,i.x=1)}else n.x==this.left&&(i.x=-1),n.x==this.right&&(i.x=1),n.y==this.top&&(i.y=-1),n.y==this.bottom&&(i.y=1);return n},i.prototype.getClosestPointOnBoundsToOrigin=function(){var e=this.max,i=Math.abs(this.location.x),n=new t.Vector2(this.location.x,0);return Math.abs(e.x)<i&&(i=Math.abs(e.x),n.x=e.x,n.y=0),Math.abs(e.y)<i&&(i=Math.abs(e.y),n.x=0,n.y=e.y),Math.abs(this.location.y)<i&&(i=Math.abs(this.location.y),n.x=0,n.y=this.location.y),n},i.prototype.calculateBounds=function(e,i,n,r,o,s,a){if(0==o)this.x=e.x+i.x-n.x*r.x,this.y=e.y+i.y-n.y*r.y,this.width=s*r.x,this.height=a*r.y;else{var c=e.x+i.x,h=e.y+i.y;this._transformMat=t.Matrix2D.create().translate(-c-n.x,-h-n.y),this._tempMat=t.Matrix2D.create().scale(r.x,r.y),this._transformMat=this._transformMat.multiply(this._tempMat),this._tempMat=t.Matrix2D.create().rotate(o),this._transformMat=this._transformMat.multiply(this._tempMat),this._tempMat=t.Matrix2D.create().translate(c,h),this._transformMat=this._transformMat.multiply(this._tempMat);var u=new t.Vector2(c,h),l=new t.Vector2(c+s,h),p=new t.Vector2(c,h+a),d=new t.Vector2(c+s,h+a);u=t.Vector2Ext.transformR(u,this._transformMat),l=t.Vector2Ext.transformR(l,this._transformMat),p=t.Vector2Ext.transformR(p,this._transformMat),d=t.Vector2Ext.transformR(d,this._transformMat);var f=Math.min(u.x,d.x,l.x,p.x),m=Math.max(u.x,d.x,l.x,p.x),g=Math.min(u.y,d.y,l.y,p.y),y=Math.max(u.y,d.y,l.y,p.y);this.location=new t.Vector2(f,g),this.width=m-f,this.height=y-g}},i}(egret.Rectangle);t.Rectangle=e}(es||(es={})),function(t){var e=function(){return function(t,e,i){this.x=t,this.y=e,this.z=i}}();t.Vector3=e}(es||(es={})),function(t){var e=function(){function e(t){this._activeTriggerIntersections=[],this._previousTriggerIntersections=[],this._tempTriggerList=[],this._entity=t}return e.prototype.update=function(){for(var e=this._entity.getComponents(t.Collider),i=0;i<e.length;i++)for(var n=e[i],r=t.Physics.boxcastBroadphase(n.bounds,n.collidesWithLayers),o=function(e){var i=r[e];if(!n.isTrigger&&!i.isTrigger)return"continue";if(n.overlaps(i)){var o=new t.Pair(n,i);-1==s._activeTriggerIntersections.findIndex(function(t){return t.first==o.first&&t.second==o.second})&&-1==s._previousTriggerIntersections.findIndex(function(t){return t.first==o.first&&t.second==o.second})&&s.notifyTriggerListeners(o,!0),s._activeTriggerIntersections.contains(o)||s._activeTriggerIntersections.push(o)}},s=this,a=0;a<r.length;a++)o(a);t.ListPool.free(e),this.checkForExitedColliders()},e.prototype.checkForExitedColliders=function(){for(var t=this,e=function(e){var n=i._previousTriggerIntersections.findIndex(function(i){return i.first==t._activeTriggerIntersections[e].first&&i.second==t._activeTriggerIntersections[e].second});-1!=n&&i._previousTriggerIntersections.removeAt(n)},i=this,n=0;n<this._activeTriggerIntersections.length;n++)e(n);for(n=0;n<this._previousTriggerIntersections.length;n++)this.notifyTriggerListeners(this._previousTriggerIntersections[n],!1);this._previousTriggerIntersections.length=0;for(n=0;n<this._activeTriggerIntersections.length;n++)this._previousTriggerIntersections.contains(this._activeTriggerIntersections[n])||this._previousTriggerIntersections.push(this._activeTriggerIntersections[n]);this._activeTriggerIntersections.length=0},e.prototype.notifyTriggerListeners=function(t,e){t.first.entity.getComponents("ITriggerListener",this._tempTriggerList);for(var i=0;i<this._tempTriggerList.length;i++)if(e?this._tempTriggerList[i].onTriggerEnter(t.second,t.first):this._tempTriggerList[i].onTriggerExit(t.second,t.first),this._tempTriggerList.length=0,t.second.entity){t.second.entity.getComponents("ITriggerListener",this._tempTriggerList);for(var n=0;n<this._tempTriggerList.length;n++)e?this._tempTriggerList[n].onTriggerEnter(t.first,t.second):this._tempTriggerList[n].onTriggerExit(t.first,t.second);this._tempTriggerList.length=0}},e}();t.ColliderTriggerHelper=e}(es||(es={})),function(t){var e;!function(t){t[t.center=0]="center",t[t.top=1]="top",t[t.bottom=2]="bottom",t[t.topLeft=9]="topLeft",t[t.topRight=5]="topRight",t[t.left=8]="left",t[t.right=4]="right",t[t.bottomLeft=10]="bottomLeft",t[t.bottomRight=6]="bottomRight"}(e=t.PointSectors||(t.PointSectors={}));var i=function(){function i(){}return i.isLineToLine=function(e,i,n,r){var o=t.Vector2.subtract(i,e),s=t.Vector2.subtract(r,n),a=o.x*s.y-o.y*s.x;if(0==a)return!1;var c=t.Vector2.subtract(n,e),h=(c.x*s.y-c.y*s.x)/a;if(h<0||h>1)return!1;var u=(c.x*o.y-c.y*o.x)/a;return!(u<0||u>1)},i.lineToLineIntersection=function(e,i,n,r){var o=new t.Vector2(0,0),s=t.Vector2.subtract(i,e),a=t.Vector2.subtract(r,n),c=s.x*a.y-s.y*a.x;if(0==c)return o;var h=t.Vector2.subtract(n,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return o;var l=(h.x*s.y-h.y*s.x)/c;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y))},i.closestPointOnLine=function(e,i,n){var r=t.Vector2.subtract(i,e),o=t.Vector2.subtract(n,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,new t.Vector2(r.x*s,r.y*s))},i.isCircleToCircle=function(e,i,n,r){return t.Vector2.distanceSquared(e,n)<(i+r)*(i+r)},i.isCircleToLine=function(e,i,n,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(n,r,e))<i*i},i.isCircleToPoint=function(e,i,n){return t.Vector2.distanceSquared(e,n)<i*i},i.isRectToCircle=function(t,e,i){var n=.5*t.width,r=.5*t.height,o=Math.max(0,Math.max(e.x-t.x)-n),s=Math.max(0,Math.max(e.y-t.y)-r);return o*o+s*s<i*i},i.isRectToLine=function(i,n,r){var o=this.getSector(i.x,i.y,i.width,i.height,n),s=this.getSector(i.x,i.y,i.width,i.height,r);if(o==e.center||s==e.center)return!0;if(0!=(o&s))return!1;var a=o|s,c=void 0,h=void 0;return!(0==(a&e.top)||(c=new t.Vector2(i.x,i.y),h=new t.Vector2(i.x+i.width,i.y),!this.isLineToLine(c,h,n,r)))||(!(0==(a&e.bottom)||(c=new t.Vector2(i.x,i.y+i.height),h=new t.Vector2(i.x+i.width,i.y+i.height),!this.isLineToLine(c,h,n,r)))||(!(0==(a&e.left)||(c=new t.Vector2(i.x,i.y),h=new t.Vector2(i.x,i.y+i.height),!this.isLineToLine(c,h,n,r)))||!(0==(a&e.right)||(c=new t.Vector2(i.x+i.width,i.y),h=new t.Vector2(i.x+i.width,i.y+i.height),!this.isLineToLine(c,h,n,r)))))},i.isRectToPoint=function(t,e,i,n,r){return r.x>=t&&r.y>=e&&r.x<t+i&&r.y<e+n},i.getSector=function(t,i,n,r,o){var s=e.center;return o.x<t?s|=e.left:o.x>=t+n&&(s|=e.right),o.y<i?s|=e.top:o.y>=i+r&&(s|=e.bottom),s},i}();t.Collisions=i}(es||(es={})),function(t){var e=function(){function e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize)},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,i,n){if(void 0===n&&(n=-1),0!=i.length)return this._spatialHash.overlapCircle(t,e,i,n);console.error("An empty results array was passed in. No results will ever be returned.")},e.boxcastBroadphase=function(t,e){return void 0===e&&(e=this.allLayers),this._spatialHash.aabbBroadphase(t,null,e)},e.boxcastBroadphaseExcludingSelf=function(t,e,i){return void 0===i&&(i=this.allLayers),this._spatialHash.aabbBroadphase(e,t,i)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.debugDraw=function(t){this._spatialHash.debugDraw(t,2)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,i){this.start=e,this.end=i,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e,i,n,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=i,this.distance=n,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,i,n){this.collider=t,this.fraction=e,this.distance=i,this.point=n},e.prototype.setValuesNonCollider=function(t,e,i,n){this.fraction=t,this.distance=e,this.point=i,this.normal=n},e.prototype.reset=function(){this.collider=null,this.fraction=this.distance=0},e.prototype.toString=function(){return"[RaycastHit] fraction: "+this.fraction+", distance: "+this.distance+", normal: "+this.normal+", centroid: "+this.centroid+", point: "+this.point},e}();t.RaycastHit=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.clone=function(){return ObjectUtils.clone(this)},t}();t.Shape=e}(es||(es={})),function(t){var e=function(e){function i(t,i){var n=e.call(this)||this;return n._areEdgeNormalsDirty=!0,n.isUnrotated=!0,n.setPoints(t),n.isBox=i,n}return __extends(i,e),Object.defineProperty(i.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),i.prototype.setPoints=function(t){this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=[];for(var e=0;e<this.points.length;e++)this._originalPoints.push(this.points[e])},i.prototype.recalculateCenterAndEdgeNormals=function(){this._polygonCenter=i.findPolygonCenter(this.points),this._areEdgeNormalsDirty=!0},i.prototype.buildEdgeNormals=function(){var e,i=this.isBox?2:this.points.length;null!=this._edgeNormals&&this._edgeNormals.length==i||(this._edgeNormals=new Array(i));for(var n=0;n<i;n++){var r=this.points[n];e=n+1>=this.points.length?this.points[0]:this.points[n+1];var o=t.Vector2Ext.perpendicular(r,e);o=t.Vector2.normalize(o),this._edgeNormals[n]=o}},i.buildSymmetricalPolygon=function(e,i){for(var n=new Array(e),r=0;r<e;r++){var o=2*Math.PI*(r/e);n[r]=t.Vector2.multiply(new t.Vector2(Math.cos(o),Math.sin(o)),new t.Vector2(i))}return n},i.recenterPolygonVerts=function(e){for(var i=this.findPolygonCenter(e),n=0;n<e.length;n++)e[n]=t.Vector2.subtract(e[n],i)},i.findPolygonCenter=function(e){for(var i=0,n=0,r=0;r<e.length;r++)i+=e[r].x,n+=e[r].y;return new t.Vector2(i/e.length,n/e.length)},i.getFarthestPointInDirection=function(e,i){for(var n=0,r=t.Vector2.dot(e[n],i),o=1;o<e.length;o++){var s=t.Vector2.dot(e[o],i);s>r&&(r=s,n=o)}return e[n]},i.getClosestPointOnPolygonToPoint=function(e,i,n,r){n=Number.MAX_VALUE,r=new t.Vector2(0,0);for(var o,s=new t.Vector2(0,0),a=0;a<e.length;a++){var c=a+1;c==e.length&&(c=0);var h=t.ShapeCollisions.closestPointOnLine(e[a],e[c],i);if((o=t.Vector2.distanceSquared(i,h))<n){n=o,s=h;var u=t.Vector2.subtract(e[c],e[a]);r=new t.Vector2(-u.y,u.x)}}return t.Vector2Ext.normalize(r),s},i.rotatePolygonVerts=function(e,i,n){for(var r=Math.cos(e),o=Math.sign(e),s=0;s<i.length;s++){var a=i[s];n[s]=new t.Vector2(a.x*r+a.y*-o,a.x*o+a.y*r)}},i.prototype.recalculateBounds=function(e){if(this.center=e.localOffset,e.shouldColliderScaleAndRotateWithTransform){var i=!0,n=void 0,r=t.Matrix2D.create().translate(-this._polygonCenter.x,-this._polygonCenter.y);if(e.entity.transform.scale!=t.Vector2.zero&&(n=t.Matrix2D.create().scale(e.entity.transform.scale.x,e.entity.transform.scale.y),r=r.multiply(n),i=!1,this.center=t.Vector2.multiply(e.localOffset,e.entity.transform.scale)),0!=e.entity.transform.rotation){n=t.Matrix2D.create().rotate(e.entity.transform.rotation),r=r.multiply(n);var o=Math.atan2(e.localOffset.y,e.localOffset.x)*t.MathHelper.Rad2Deg,s=i?e._localOffsetLength:t.Vector2.multiply(e.localOffset,e.entity.transform.scale).length();this.center=t.MathHelper.pointOnCirlce(t.Vector2.zero,s,e.entity.transform.rotation+o)}n=t.Matrix2D.create().translate(this._polygonCenter.x,this._polygonCenter.y),r=r.multiply(n),t.Vector2Ext.transform(this._originalPoints,r,this.points),this.isUnrotated=0==e.entity.transform.rotation,e._isRotationDirty&&(this._areEdgeNormalsDirty=!0)}this.position=t.Vector2.add(e.entity.transform.position,this.center),this.bounds=t.Rectangle.rectEncompassingPoints(this.points),this.bounds.location=this.bounds.location.add(this.position)},i.prototype.overlaps=function(e){var n=new t.CollisionResult;if(e instanceof i)return t.ShapeCollisions.polygonToPolygon(this,e,n);if(e instanceof t.Circle)return!!t.ShapeCollisions.circleToPolygon(e,this,n)&&(n.invertResult(),!0);throw new Error("overlaps of Pologon to "+e+" are not supported")},i.prototype.collidesWithShape=function(e,n){if(e instanceof i)return t.ShapeCollisions.polygonToPolygon(this,e,n);if(e instanceof t.Circle)return!!t.ShapeCollisions.circleToPolygon(e,this,n)&&(n.invertResult(),!0);throw new Error("overlaps of Polygon to "+e+" are not supported")},i.prototype.collidesWithLine=function(e,i,n){return t.ShapeCollisions.lineToPoly(e,i,this,n)},i.prototype.containsPoint=function(e){e=t.Vector2.subtract(e,this.position);for(var i=!1,n=0,r=this.points.length-1;n<this.points.length;r=n++)this.points[n].y>e.y!=this.points[r].y>e.y&&e.x<(this.points[r].x-this.points[n].x)*(e.y-this.points[n].y)/(this.points[r].y-this.points[n].y)+this.points[n].x&&(i=!i);return i},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisions.pointToPoly(e,this,i)},i}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function i(t,n){var r=e.call(this,i.buildBox(t,n),!0)||this;return r.width=t,r.height=n,r}return __extends(i,e),i.buildBox=function(e,i){var n=e/2,r=i/2,o=new Array(4);return o[0]=new t.Vector2(-n,-r),o[1]=new t.Vector2(n,-r),o[2]=new t.Vector2(n,r),o[3]=new t.Vector2(-n,r),o},i.prototype.updateBox=function(e,i){this.width=e,this.height=i;var n=e/2,r=i/2;this.points[0]=new t.Vector2(-n,-r),this.points[1]=new t.Vector2(n,-r),this.points[2]=new t.Vector2(n,r),this.points[3]=new t.Vector2(-n,r);for(var o=0;o<this.points.length;o++)this._originalPoints[o]=this.points[o]},i.prototype.overlaps=function(n){if(this.isUnrotated){if(n instanceof i&&n.isUnrotated)return this.bounds.intersects(n.bounds);if(n instanceof t.Circle)return t.Collisions.isRectToCircle(this.bounds,n.position,n.radius)}return e.prototype.overlaps.call(this,n)},i.prototype.collidesWithShape=function(n,r){return n instanceof i&&n.isUnrotated?t.ShapeCollisions.boxToBox(this,n,r):e.prototype.collidesWithShape.call(this,n,r)},i.prototype.containsPoint=function(t){return this.isUnrotated?this.bounds.contains(t.x,t.y):e.prototype.containsPoint.call(this,t)},i.prototype.pointCollidesWithShape=function(i,n){return this.isUnrotated?t.ShapeCollisions.pointToBox(i,this,n):e.prototype.pointCollidesWithShape.call(this,i,n)},i}(t.Polygon);t.Box=e}(es||(es={})),function(t){var e=function(e){function i(t){var i=e.call(this)||this;return i.radius=t,i._originalRadius=t,i}return __extends(i,e),i.prototype.recalculateBounds=function(e){if(this.center=e.localOffset,e.shouldColliderScaleAndRotateWithTransform){var i=e.entity.transform.scale,n=1==i.x&&1==i.y,r=Math.max(i.x,i.y);if(this.radius=this._originalRadius*r,0!=e.entity.transform.rotation){var o=Math.atan2(e.localOffset.y,e.localOffset.x)*t.MathHelper.Rad2Deg,s=n?e._localOffsetLength:t.Vector2.multiply(e.localOffset,e.entity.transform.scale).length();this.center=t.MathHelper.pointOnCirlce(t.Vector2.zero,s,e.entity.transform.rotation+o)}}this.position=t.Vector2.add(e.transform.position,this.center),this.bounds=new t.Rectangle(this.position.x-this.radius,this.position.y-this.radius,2*this.radius,2*this.radius)},i.prototype.overlaps=function(e){var n=new t.CollisionResult;if(e instanceof t.Box&&e.isUnrotated)return t.Collisions.isRectToCircle(e.bounds,this.position,this.radius);if(e instanceof i)return t.Collisions.isCircleToCircle(this.position,this.radius,e.position,e.radius);if(e instanceof t.Polygon)return t.ShapeCollisions.circleToPolygon(this,e,n);throw new Error("overlaps of circle to "+e+" are not supported")},i.prototype.collidesWithShape=function(e,n){if(e instanceof t.Box&&e.isUnrotated)return t.ShapeCollisions.circleToBox(this,e,n);if(e instanceof i)return t.ShapeCollisions.circleToCircle(this,e,n);if(e instanceof t.Polygon)return t.ShapeCollisions.circleToPolygon(this,e,n);throw new Error("Collisions of Circle to "+e+" are not supported")},i.prototype.collidesWithLine=function(e,i,n){return t.ShapeCollisions.lineToCircle(e,i,this,n)},i.prototype.containsPoint=function(e){return t.Vector2.subtract(e,this.position).lengthSquared()<=this.radius*this.radius},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisions.pointToCircle(e,this,i)},i}(t.Shape);t.Circle=e}(es||(es={})),function(t){var e=function(){function e(){this.normal=t.Vector2.zero,this.minimumTranslationVector=t.Vector2.zero,this.point=t.Vector2.zero}return e.prototype.removeHorizontal=function(e){if(Math.sign(this.normal.x)!=Math.sign(e.x)||0==e.x&&0!=this.normal.x){var i=this.minimumTranslationVector.length()/this.normal.y;1!=Math.abs(this.normal.x)&&Math.abs(i)<Math.abs(3*e.y)&&(this.minimumTranslationVector=new t.Vector2(0,-i))}},e.prototype.invertResult=function(){return this.minimumTranslationVector=t.Vector2.negate(this.minimumTranslationVector),this.normal=t.Vector2.negate(this.normal),this},e.prototype.toString=function(){return"[CollisionResult] normal: "+this.normal+", minimumTranslationVector: "+this.minimumTranslationVector},e}();t.CollisionResult=e}(es||(es={})),function(t){var e=function(){function e(){}return e.intersectMovingCircleToBox=function(e,i,n){var r=i.bounds;r.inflate(e.radius,e.radius);var o=new t.Ray2D(t.Vector2.subtract(e.position,n),e.position),s=r.rayIntersects(o);if(s>1)return s;var a,c=t.Vector2.add(o.start,t.Vector2.add(o.direction,new t.Vector2(s))),h=0;c.x<i.bounds.left&&(a|=1),c.x>i.bounds.right&&(h|=1),c.y<i.bounds.top&&(a|=2),c.y>i.bounds.bottom&&(h|=2);var u=a+h;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),s},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,i,n){for(var r,o=!0,s=e.edgeNormals,a=i.edgeNormals,c=Number.POSITIVE_INFINITY,h=new t.Vector2,u=t.Vector2.subtract(e.position,i.position),l=0;l<s.length+a.length;l++){r=l<s.length?s[l]:a[l-s.length];var p=0,d=0,f=0,m=0,g=0,y=this.getInterval(r,e,p,f);p=y.min,d=y.max;var _=this.getInterval(r,i,d,m);d=_.min,m=_.max;var v=t.Vector2.dot(u,r);if(p+=v,f+=v,(g=this.intervalDistance(p,f,d,m))>0&&(o=!1),!o)return!1;(g=Math.abs(g))<c&&(c=g,h=r,t.Vector2.dot(h,u)<0&&(h=new t.Vector2(-h)))}return n.normal=h,n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(-h.x,-h.y),new t.Vector2(c)),!0},e.intervalDistance=function(t,e,i,n){return t<i?i-e:t-i},e.getInterval=function(e,i,n,r){var o=t.Vector2.dot(i.points[0],e);n=r=o;for(var s=1;s<i.points.length;s++)(o=t.Vector2.dot(i.points[s],e))<n?n=o:o>r&&(r=o);return{min:n,max:r}},e.circleToPolygon=function(e,i,n){var r,o=t.Vector2.subtract(e.position,i.position),s=t.Polygon.getClosestPointOnPolygonToPoint(i.points,o,0,n.normal),a=i.containsPoint(e.position);if(0>e.radius*e.radius&&!a)return!1;a?r=t.Vector2.multiply(n.normal,new t.Vector2(Math.sqrt(0)-e.radius)):r=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));return n.minimumTranslationVector=r,n.point=t.Vector2.add(s,i.position),!0},e.circleToBox=function(e,i,n){var r=i.bounds.getClosestPointOnRectangleBorderToPoint(e.position,n.normal);if(i.containsPoint(e.position)){n.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(n.normal,new t.Vector2(e.radius)));return n.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)n.minimumTranslationVector=t.Vector2.multiply(n.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){n.normal=t.Vector2.subtract(e.position,r);var a=n.normal.length()-e.radius;return n.point=r,n.normal=t.Vector2Ext.normalize(n.normal),n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),n.normal),!0}return!1},e.pointToCircle=function(e,i,n){var r=t.Vector2.distanceSquared(e,i.position),o=1+i.radius;if(r<o*o){n.normal=t.Vector2.normalize(t.Vector2.subtract(e,i.position));var s=o-Math.sqrt(r);return n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(-s,-s),n.normal),n.point=t.Vector2.add(i.position,t.Vector2.multiply(n.normal,new t.Vector2(i.radius,i.radius))),!0}return!1},e.pointToBox=function(e,i,n){return!!i.containsPoint(e)&&(n.point=i.bounds.getClosestPointOnRectangleBorderToPoint(e,n.normal),n.minimumTranslationVector=t.Vector2.subtract(e,n.point),!0)},e.closestPointOnLine=function(e,i,n){var r=t.Vector2.subtract(i,e),o=t.Vector2.subtract(n,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,t.Vector2.multiply(r,new t.Vector2(s,s)))},e.pointToPoly=function(e,i,n){if(i.containsPoint(e)){var r=t.Polygon.getClosestPointOnPolygonToPoint(i.points,t.Vector2.subtract(e,i.position),0,n.normal);return n.minimumTranslationVector=t.Vector2.multiply(n.normal,new t.Vector2(Math.sqrt(0),Math.sqrt(0))),n.point=t.Vector2.add(r,i.position),!0}return!1},e.circleToCircle=function(e,i,n){var r=t.Vector2.distanceSquared(e.position,i.position),o=e.radius+i.radius;if(r<o*o){n.normal=t.Vector2.normalize(t.Vector2.subtract(e.position,i.position));var s=o-Math.sqrt(r);return n.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(-s),n.normal),n.point=t.Vector2.add(i.position,t.Vector2.multiply(n.normal,new t.Vector2(i.radius))),!0}return!1},e.boxToBox=function(e,i,n){var r=this.minkowskiDifference(e,i);return!!r.contains(0,0)&&(n.minimumTranslationVector=r.getClosestPointOnBoundsToOrigin(),!n.minimumTranslationVector.equals(t.Vector2.zero)&&(n.normal=new t.Vector2(-n.minimumTranslationVector.x,-n.minimumTranslationVector.y),n.normal=n.normal.normalize(),!0))},e.minkowskiDifference=function(e,i){var n=t.Vector2.subtract(e.position,t.Vector2.add(e.bounds.location,t.Vector2.divide(e.bounds.size,new t.Vector2(2)))),r=t.Vector2.subtract(t.Vector2.add(e.bounds.location,n),i.bounds.max),o=t.Vector2.add(e.bounds.size,i.bounds.size);return new t.Rectangle(r.x,r.y,o.x,o.y)},e.lineToPoly=function(e,i,n,r){for(var o=t.Vector2.zero,s=t.Vector2.zero,a=Number.MAX_VALUE,c=!1,h=n.points.length-1,u=0;u<n.points.length;h=u,u++){var l=t.Vector2.add(n.position,n.points[h]),p=t.Vector2.add(n.position,n.points[u]),d=t.Vector2.zero;if(this.lineToLine(l,p,e,i,d)){c=!0;var f=(d.x-e.x)/(i.x-e.x);if((Number.isNaN(f)||Number.isFinite(f))&&(f=(d.y-e.y)/(i.y-e.y)),f<a){var m=t.Vector2.subtract(p,l);o=new t.Vector2(m.y,-m.x),a=f,s=d}}}if(c){o=o.normalize();var g=t.Vector2.distance(e,s);return r.setValuesNonCollider(a,g,s,o),!0}return!1},e.lineToLine=function(e,i,n,r,o){var s=t.Vector2.subtract(i,e),a=t.Vector2.subtract(r,n),c=s.x*a.y-s.y*a.x;if(0==c)return!1;var h=t.Vector2.subtract(n,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return!1;var l=(h.x*s.y-h.y*s.x)/c;return!(l<0||l>1)&&(o=o.add(e).add(t.Vector2.multiply(new t.Vector2(u),s)),!0)},e.lineToCircle=function(e,i,n,r){var o=t.Vector2.distance(e,i),s=t.Vector2.divide(t.Vector2.subtract(i,e),new t.Vector2(o)),a=t.Vector2.subtract(e,n.position),c=t.Vector2.dot(a,s),h=t.Vector2.dot(a,a)-n.radius*n.radius;if(h>0&&c>0)return!1;var u=c*c-h;return!(u<0)&&(r.fraction=-c-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,n.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,i,n,r){var o=this.minkowskiDifference(e,i);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal=r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-n.x)),c=o.rayIntersects(a);return c<=1&&(r.fraction=c,r.distance=n.length()*c,r.normal=new t.Vector2(-n.x),r.normal=r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(n,new t.Vector2(c))),!0)},e}();t.ShapeCollisions=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestCircle=new t.Circle(0),this._cellDict=new i,this._tempHashSet=[],this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new n}return e.prototype.register=function(e){var i=e.bounds;e.registeredPhysicsBounds=i;var n=this.cellCoords(i.x,i.y),r=this.cellCoords(i.right,i.bottom);this.gridBounds.contains(n.x,n.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,n)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=n.x;o<=r.x;o++)for(var s=n.y;s<=r.y;s++){var a=this.cellAtPosition(o,s,!0);a.firstOrDefault(function(t){return t.hashCode==e.hashCode})||a.push(e)}},e.prototype.remove=function(t){for(var e=t.registeredPhysicsBounds,i=this.cellCoords(e.x,e.y),n=this.cellCoords(e.right,e.bottom),r=i.x;r<=n.x;r++)for(var o=i.y;o<=n.y;o++){var s=this.cellAtPosition(r,o);s?s.remove(t):console.log("从不存在碰撞器的单元格中移除碰撞器: ["+t+"]")}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.debugDraw=function(t,e){void 0===e&&(e=1);for(var i=this.gridBounds.x;i<=this.gridBounds.right;i++)for(var n=this.gridBounds.y;n<=this.gridBounds.bottom;n++){var r=this.cellAtPosition(i,n);r&&r.length>0&&this.debugDrawCellDetails(i,n,r.length,t,e)}},e.prototype.aabbBroadphase=function(e,i,n){this._tempHashSet.length=0;for(var r=this.cellCoords(e.x,e.y),o=this.cellCoords(e.right,e.bottom),s=r.x;s<=o.x;s++)for(var a=r.y;a<=o.y;a++){var c=this.cellAtPosition(s,a);if(c)for(var h=function(r){var o=c[r];if(o==i||!t.Flags.isFlagSet(n,o.physicsLayer))return"continue";e.intersects(o.bounds)&&(u._tempHashSet.firstOrDefault(function(t){return t.hashCode==o.hashCode})||u._tempHashSet.push(o))},u=this,l=0;l<c.length;l++)h(l)}return this._tempHashSet},e.prototype.overlapCircle=function(e,i,n,r){var o=new t.Rectangle(e.x-i,e.y-i,2*i,2*i);this._overlapTestCircle.radius=i,this._overlapTestCircle.position=e;for(var s=0,a=this.aabbBroadphase(o,null,r),c=0;c<a.length;c++){var h=a[c];if(h instanceof t.BoxCollider)n[s]=h,s++;else if(h instanceof t.CircleCollider)h.shape.overlaps(this._overlapTestCircle)&&(n[s]=h,s++);else{if(!(h instanceof t.PolygonCollider))throw new Error("overlapCircle against this collider type is not implemented!");h.shape.overlaps(this._overlapTestCircle)&&(n[s]=h,s++)}if(s==n.length)return s}return s},e.prototype.cellCoords=function(e,i){return new t.Vector2(Math.floor(e*this._inverseCellSize),Math.floor(i*this._inverseCellSize))},e.prototype.cellAtPosition=function(t,e,i){void 0===i&&(i=!1);var n=this._cellDict.tryGetValue(t,e);return n||i&&(n=[],this._cellDict.add(t,e,n)),n},e.prototype.debugDrawCellDetails=function(t,e,i,n,r){void 0===n&&(n=.5),void 0===r&&(r=1)},e}();t.SpatialHash=e;var i=function(){function t(){this._store=new Map}return t.prototype.add=function(t,e,i){this._store.set(this.getKey(t,e),i)},t.prototype.remove=function(t){this._store.forEach(function(e){e.contains(t)&&e.remove(t)})},t.prototype.tryGetValue=function(t,e){return this._store.get(this.getKey(t,e))},t.prototype.clear=function(){this._store.clear()},t.prototype.getKey=function(t,e){return Long.fromNumber(t).shiftLeft(32).or(Long.fromNumber(e,!0)).toString()},t}();t.NumberDictionary=i;var n=function(){function e(){this._checkedColliders=[],this._cellHits=[]}return e.prototype.start=function(t,e,i){this._ray=t,this._hits=e,this._layerMask=i,this.hitCounter=0},e.prototype.checkRayIntersection=function(i,n,r){for(var o=0;o<r.length;o++){var s=r[o];if(!this._checkedColliders.contains(s))if(this._checkedColliders.push(s),!s.isTrigger||t.Physics.raycastsHitTriggers)if(t.Flags.isFlagSet(this._layerMask,s.physicsLayer))if(s.bounds.rayIntersects(this._ray)<=1&&s.shape.collidesWithLine(this._ray.start,this._ray.end,this._tempHit)){if(!t.Physics.raycastsStartInColliders&&s.shape.containsPoint(this._ray.start))continue;this._tempHit.collider=s,this._cellHits.push(this._tempHit)}}if(0==this._cellHits.length)return!1;this._cellHits.sort(e.compareRaycastHits);for(o=0;o<this._cellHits.length;o++)if(this._hits[this.hitCounter]=this._cellHits[o],this.hitCounter++,this.hitCounter==this._hits.length)return!0;return!1},e.prototype.reset=function(){this._hits=null,this._checkedColliders.length=0,this._cellHits.length=0},e.compareRaycastHits=function(t,e){return t.distance-e.distance},e}();t.RaycastResultParser=n}(es||(es={})),function(t){var e=function(){return function(){}}();t.TmxGroup=e}(es||(es={})),function(t){var e=function(){return function(){}}();t.TmxImageLayer=e}(es||(es={})),function(t){var e=function(){function e(){}return Object.defineProperty(e.prototype,"offset",{get:function(){return new t.Vector2(this.offsetX,this.offsetY)},enumerable:!0,configurable:!0}),e.prototype.getTileWithGid=function(t){for(var e=0;e<this.tiles.length;e++)if(this.tiles[e]&&this.tiles[e].gid==t)return this.tiles[e];return null},e.prototype.getTile=function(t,e){return this.tiles[t+e*this.width]},e.prototype.getCollisionRectangles=function(){for(var t=[],e=[],i=-1,n=-1,r=0;r<this.map.height;r++){for(var o=0;o<this.map.width;o++){n=r*this.map.width+o;var s=this.getTile(o,r);s&&!t[n]?(i<0&&(i=o),t[n]=!0):(s||t[n])&&i>=0&&(e.push(this.findBoundsRect(i,o,r,t)),i=-1)}i>=0&&(e.push(this.findBoundsRect(i,this.map.width,r,t)),i=-1)}return e},e.prototype.findBoundsRect=function(e,i,n,r){for(var o=-1,s=n+1;s<this.map.height;s++)for(var a=e;a<i;a++){if(o=s*this.map.width+a,this.getTile(a,s)||r[o]){for(var c=e;c<a;c++)r[o=s*this.map.width+c]=!1;return new t.Rectangle(e*this.map.tileWidth,n*this.map.tileHeight,(i-e)*this.map.tileWidth,(s-n)*this.map.tileHeight)}r[o]=!0}return new t.Rectangle(e*this.map.tileWidth,n*this.map.tileHeight,(i-e)*this.map.tileWidth,(this.map.height-n)*this.map.tileHeight)},e}();t.TmxLayer=e;var i=function(){function e(t,i,n,r){this.x=n,this.y=r;var o,s=i;o=0!=(s&e.FLIPPED_HORIZONTALLY_FLAG),this.horizontalFlip=o,o=0!=(s&e.FLIPPED_VERTICALLY_FLAG),this.verticalFlip=o,s&=~(e.FLIPPED_HORIZONTALLY_FLAG|e.FLIPPED_VERTICALLY_FLAG),this.gid=s,this.tileset=t.getTilesetForTileGid(this.gid)}return Object.defineProperty(e.prototype,"position",{get:function(){return new t.Vector2(this.x,this.y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"tilesetTile",{get:function(){null==this._tilesetTileIndex&&(this._tilesetTileIndex=-1,this.tileset.firstGid<=this.gid&&this.tileset.tiles.get(this.gid-this.tileset.firstGid)&&(this._tilesetTileIndex=this.gid-this.tileset.firstGid));return this._tilesetTileIndex<0?null:this.tileset.tiles.get(this._tilesetTileIndex)},enumerable:!0,configurable:!0}),e.FLIPPED_HORIZONTALLY_FLAG=2147483648,e.FLIPPED_VERTICALLY_FLAG=1073741824,e}();t.TmxLayerTile=i}(es||(es={})),function(t){var e=function(){return function(){this.tmxDirectory=""}}();t.TmxDocument=e;var i=function(){function t(){}return t.prototype.dispose=function(){this.bitmap&&(this.bitmap.dispose(),this.bitmap=null)},t}();t.TmxImage=i}(es||(es={})),function(t){var e=function(e){function i(){return null!==e&&e.apply(this,arguments)||this}return __extends(i,e),Object.defineProperty(i.prototype,"worldWidth",{get:function(){return this.width*this.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"worldHeight",{get:function(){return this.height*this.tileHeight},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"requiresLargeTileCulling",{get:function(){return this.maxTileHeight>this.tileHeight||this.maxTileWidth>this.tileWidth},enumerable:!0,configurable:!0}),i.prototype.getTilesetForTileGid=function(t){if(0==t)return null;for(var e=this.tilesets.length-1;e>=0;e--)if(this.tilesets[e].firstGid<=t)return this.tilesets[e];console.error("tile gid"+t+"未在任何tileset中找到")},i.prototype.worldToTilePositionX=function(e,i){void 0===i&&(i=!0);var n=Math.floor(e/this.tileWidth);return i?t.MathHelper.clamp(n,0,this.width-1):n},i.prototype.worldToTilePositionY=function(e,i){void 0===i&&(i=!0);var n=Math.floor(e/this.tileHeight);return i?t.MathHelper.clamp(n,0,this.height-1):n},i.prototype.getLayer=function(t){return this.layers[t]},i.prototype.update=function(){this.tilesets.forEach(function(t){t.update()})},i.prototype.dispose=function(t){void 0===t&&(t=!0),this._isDisposed||(t&&(this.tilesets.forEach(function(t){t.image&&t.image.dispose()}),this.imageLayers.forEach(function(t){t.image&&t.image.dispose()})),this._isDisposed=!0)},i}(t.TmxDocument);t.TmxMap=e,function(t){t[t.unknown=0]="unknown",t[t.orthogonal=1]="orthogonal",t[t.isometric=2]="isometric",t[t.staggered=3]="staggered",t[t.hexagonal=4]="hexagonal"}(t.OrientationType||(t.OrientationType={})),function(t){t[t.x=0]="x",t[t.y=1]="y"}(t.StaggerAxisType||(t.StaggerAxisType={})),function(t){t[t.odd=0]="odd",t[t.even=1]="even"}(t.StaggerIndexType||(t.StaggerIndexType={})),function(t){t[t.rightDown=0]="rightDown",t[t.rightUp=1]="rightUp",t[t.leftDown=2]="leftDown",t[t.leftUp=3]="leftUp"}(t.RenderOrderType||(t.RenderOrderType={}))}(es||(es={})),function(t){var e=function(){return function(){}}();t.TmxObjectGroup=e;var i=function(){return function(){this.shape=new egret.Shape,this.textField=new egret.TextField}}();t.TmxObject=i;var n=function(){return function(){}}();t.TmxText=n;var r=function(){return function(){}}();t.TmxAlignment=r,function(t){t[t.basic=0]="basic",t[t.point=1]="point",t[t.tile=2]="tile",t[t.ellipse=3]="ellipse",t[t.polygon=4]="polygon",t[t.polyline=5]="polyline",t[t.text=6]="text"}(t.TmxObjectType||(t.TmxObjectType={})),function(t){t[t.unkownOrder=-1]="unkownOrder",t[t.TopDown=0]="TopDown",t[t.IndexOrder=1]="IndexOrder"}(t.DrawOrderType||(t.DrawOrderType={})),function(t){t[t.left=0]="left",t[t.center=1]="center",t[t.right=2]="right",t[t.justify=3]="justify"}(t.TmxHorizontalAlignment||(t.TmxHorizontalAlignment={})),function(t){t[t.top=0]="top",t[t.center=1]="center",t[t.bottom=2]="bottom"}(t.TmxVerticalAlignment||(t.TmxVerticalAlignment={}))}(es||(es={})),function(t){var e=function(){function e(){}return e.loadTmxMap=function(t,e){var i=RES.getRes(e);return this.loadTmxMapData(t,i)},e.loadTmxMapData=function(e,i){return __awaiter(this,void 0,void 0,function(){var n,r,o,s;return __generator(this,function(a){switch(a.label){case 0:e.version=i.version,e.tiledVersion=i.tiledversion,e.width=i.width,e.height=i.height,e.tileWidth=i.tilewidth,e.tileHeight=i.tileheight,e.hexSideLength=i.hexsidelength,e.orientation=this.parseOrientationType(i.orientation),e.staggerAxis=this.parseStaggerAxisType(i.staggeraxis),e.staggerIndex=this.parseStaggerIndexType(i.staggerindex),e.renderOrder=this.parseRenderOrderType(i.renderorder),e.nextObjectID=i.nextobjectid,e.backgroundColor=t.TmxUtils.color16ToUnit(i.color),e.properties=this.parsePropertyDict(i.properties),e.maxTileWidth=e.tileWidth,e.maxTileHeight=e.tileHeight,e.tilesets=[],n=0,r=i.tilesets,a.label=1;case 1:return n<r.length?(o=r[n],[4,this.parseTmxTileset(e,o)]):[3,4];case 2:s=a.sent(),e.tilesets.push(s),this.updateMaxTileSizes(s),a.label=3;case 3:return n++,[3,1];case 4:return e.layers=[],e.tileLayers=[],e.objectGroups=[],e.imageLayers=[],e.groups=[],this.parseLayers(e,i,e,e.width,e.height),[2,e]}})})},e.parseLayers=function(e,i,n,r,o){return __awaiter(this,void 0,void 0,function(){var s,a,c,h,u,l,p,d;return __generator(this,function(f){switch(f.label){case 0:s=0,a=ObjectUtils.elements(i).where(function(t){return"tilelayer"==t.type||"objectgroup"==t.type||"imagelayer"==t.type||"group"==t.type}),f.label=1;case 1:if(!(s<a.length))return[3,10];switch(c=a[s],h=void 0,c.type){case"tilelayer":return[3,2];case"objectgroup":return[3,3];case"imagelayer":return[3,4];case"group":return[3,6]}return[3,7];case 2:return u=this.loadTmxLayer(new t.TmxLayer,n,c,r,o),h=u,(e instanceof t.TmxMap||e instanceof t.TmxGroup)&&e.tileLayers.push(u),[3,8];case 3:return l=this.loadTmxObjectGroup(new t.TmxObjectGroup,n,c),h=l,(e instanceof t.TmxMap||e instanceof t.TmxGroup)&&e.objectGroups.push(l),[3,8];case 4:return[4,this.loadTmxImageLayer(new t.TmxImageLayer,n,c)];case 5:return p=f.sent(),h=p,(e instanceof t.TmxMap||e instanceof t.TmxGroup)&&e.imageLayers.push(p),[3,8];case 6:return d=this.loadTmxGroup(new t.TmxGroup,n,c,r,o),h=d,(e instanceof t.TmxMap||e instanceof t.TmxGroup)&&e.groups.push(d),[3,8];case 7:throw new Error("无效的操作");case 8:(e instanceof t.TmxMap||e instanceof t.TmxGroup)&&e.layers.push(h),f.label=9;case 9:return s++,[3,1];case 10:return[2]}})})},e.loadTmxGroup=function(t,e,i,n,r){return t.map=e,t.name=null!=i.name?i.name:"",t.opacity=null!=i.opacity?i.opacity:1,t.visible=null==i.visible||i.visible,t.offsetX=null!=i.offsetx?i.offsetx:0,t.offsetY=null!=i.offsety?i.offsety:0,t.properties=this.parsePropertyDict(i.properties),t.layers=[],t.tileLayers=[],t.objectGroups=[],t.imageLayers=[],t.groups=[],this.parseLayers(t,i,e,n,r),t},e.loadTmxImageLayer=function(e,i,n){return __awaiter(this,void 0,void 0,function(){var r,o;return __generator(this,function(s){switch(s.label){case 0:return e.map=i,e.name=n.name,e.width=n.width,e.height=n.height,e.visible=null==n.visible||n.visible,e.opacity=null!=n.opacity?n.opacity:1,e.offsetX=null!=n.offsetx?n.offsetx:0,e.offsetY=null!=n.offsety?n.offsety:0,(r=n.image)?(o=e,[4,this.loadTmxImage(new t.TmxImage,r)]):[3,2];case 1:o.image=s.sent(),s.label=2;case 2:return e.properties=this.parsePropertyDict(n.properties),[2,e]}})})},e.loadTmxLayer=function(i,n,r,o,s){i.map=n,i.name=r.name,i.opacity=null!=r.opacity?r.opacity:1,i.visible=null==r.visible||r.visible,i.offsetX=null!=r.offsetx?r.offsetx:0,i.offsetY=null!=r.offsety?r.offsety:0,i.width=r.width,i.height=r.height;var a=r.data,c=null!=a.encoding?a.encoding:"csv";if(i.tiles=new Array(o*s),"base64"==c)for(var h=t.TmxUtils.decode(a.toString(),c,a.compression),u=0,l=0;l<s;l++)for(var p=0;p<o;p++){var d=h[u];i.tiles[u++]=0!=d?new t.TmxLayerTile(n,d,p,l):null}else if("csv"==c)for(var f=0,m=0,g=a;m<g.length;m++){d=g[m];var y=f%o,_=f/o;i.tiles[f++]=0!=d?new t.TmxLayerTile(n,d,y,_):null}else{if(c)throw new Error("TmxLayer:未知编码");f=0;for(var v=0,b=a.tile;v<b.length;v++){var x=b[v];d=null!=x.gid?x.gid:0,y=f%o,_=f/o;i.tiles[f++]=0!=d?new t.TmxLayerTile(n,d,y,_):null}}return i.properties=e.parsePropertyDict(r.properties),i},e.updateMaxTileSizes=function(t){t.tiles.forEach(function(e){e.image&&(e.image.width>t.map.maxTileWidth&&(t.map.maxTileWidth=e.image.width),e.image.height>t.map.maxTileHeight&&(t.map.maxTileHeight=e.image.height))}),t.tileRegions.forEach(function(e){var i=e.width,n=e.height;i>t.map.maxTileWidth&&(t.map.maxTileWidth=i),i>t.map.maxTileHeight&&(t.map.maxTileHeight=n)})},e.parseOrientationType=function(e){return"unknown"==e?t.OrientationType.unknown:"orthogonal"==e?t.OrientationType.orthogonal:"isometric"==e?t.OrientationType.isometric:"staggered"==e?t.OrientationType.staggered:"hexagonal"==e?t.OrientationType.hexagonal:t.OrientationType.unknown},e.parseStaggerAxisType=function(e){return"y"==e?t.StaggerAxisType.y:t.StaggerAxisType.x},e.parseStaggerIndexType=function(e){return"even"==e?t.StaggerIndexType.even:t.StaggerIndexType.odd},e.parseRenderOrderType=function(e){return"right-up"==e?t.RenderOrderType.rightUp:"left-down"==e?t.RenderOrderType.leftDown:"left-up"==e?t.RenderOrderType.leftUp:t.RenderOrderType.rightDown},e.parsePropertyDict=function(e){if(!e)return null;for(var i=new Map,n=0,r=e;n<r.length;n++){var o=r[n],s=o.name,a=o.value;"color"==o.type?i.set(s,t.TmxUtils.color16ToUnit(a).toString()):i.set(s,a)}return i},e.parseTmxTileset=function(e,i){return __awaiter(this,void 0,void 0,function(){var n,r,o,s;return __generator(this,function(a){switch(a.label){case 0:return n=i.firstgid,r=n,(o=i.image)?[3,2]:(o="resource/assets/"+o,[4,RES.getResByUrl(o,null,this,RES.ResourceItem.TYPE_IMAGE)]);case 1:return s=a.sent(),[2,this.loadTmxTileset(new t.TmxTileset,e,s.tileset,r)];case 2:return[2,this.loadTmxTileset(new t.TmxTileset,e,i,r)]}})})},e.loadTmxTileset=function(e,i,n,r){return __awaiter(this,void 0,void 0,function(){var o,s,a,c,h,u,l,p,d,f,m,g;return __generator(this,function(y){switch(y.label){case 0:return e.map=i,e.firstGid=r,e.name=n.name,e.tileWidth=n.tilewidth,e.tileHeight=n.tileheight,e.spacing=null!=n.spacing?n.spacing:0,e.margin=null!=n.margin?n.margin:0,e.columns=n.columns,e.tileCount=n.tilecount,e.tileOffset=this.parseTmxTileOffset(n.tileoffset),n.image?(o=e,[4,this.loadTmxImage(new t.TmxImage,n)]):[3,2];case 1:o.image=y.sent(),y.label=2;case 2:if(e.terrains=[],n.terrains)for(s=0,a=n.terrains;s<a.length;s++)c=a[s],e.terrains.push(this.parseTmxTerrain(c));e.tiles=new Map,h=0,u=n.tiles,y.label=3;case 3:return h<u.length?(l=u[h],[4,this.loadTmxTilesetTile(new t.TmxTilesetTile,e,l,e.terrains)]):[3,6];case 4:p=y.sent(),e.tiles.set(p.id,p),y.label=5;case 5:return h++,[3,3];case 6:if(e.properties=this.parsePropertyDict(n.properties),e.tileRegions=new Map,e.image&&e.image.bitmap)for(d=r,f=e.margin;f<e.image.height-e.margin;f+=e.tileHeight+e.spacing)for(m=0,g=e.margin;g<e.image.width-e.margin&&(e.tileRegions.set(d++,new t.Rectangle(g,f,e.tileWidth,e.tileHeight)),!(++m>=e.columns));g+=e.tileWidth+e.spacing);else e.tiles.forEach(function(i){e.tileRegions.set(r+i.id,new t.Rectangle(0,0,i.image.width,i.image.height))});return[2,e]}})})},e.loadTmxTilesetTile=function(e,i,n,r){return __awaiter(this,void 0,void 0,function(){var o,s,a,c,h,u,l,p,d,f,m,g,y;return __generator(this,function(_){switch(_.label){case 0:if(e.tileset=i,e.id=n.id,o=n.terrain)for(e.terrainEdges=new Array(4),s=0,a=0,c=o;a<c.length;a++)h=c[a],u=r[h],e.terrainEdges[s++]=u;return e.probability=null!=n.probability?n.probability:1,e.type=n.type,(l=n.image)?(p=e,[4,this.loadTmxImage(new t.TmxImage,l)]):[3,2];case 1:p.image=_.sent(),_.label=2;case 2:if(e.objectGroups=[],n.objectgroup)for(d=0,f=n.objectgroup;d<f.length;d++)y=f[d],e.objectGroups.push(this.loadTmxObjectGroup(new t.TmxObjectGroup,i.map,y));if(e.animationFrames=[],n.animation)for(m=0,g=n.animation.frame;m<g.length;m++)y=g[m],e.animationFrames.push(this.loadTmxAnimationFrame(new t.TmxAnimationFrame,y));return e.properties=this.parsePropertyDict(n.properties),e.properties&&e.processProperties(),[2,e]}})})},e.loadTmxAnimationFrame=function(t,e){return t.gid=e.tileid,t.duration=e.duration/1e3,t},e.loadTmxObjectGroup=function(e,i,n){e.map=i,e.name=null!=n.name?n.name:"",e.color=t.TmxUtils.color16ToUnit(n.color),e.opacity=null!=n.opacity?n.opacity:1,e.visible=null==n.visible||n.visible,e.offsetX=null!=n.offsetx?n.offsetx:0,e.offsetY=null!=n.offsety?n.offsety:0;var r=new Map;r.set("unknown",t.DrawOrderType.unkownOrder),r.set("topdown",t.DrawOrderType.IndexOrder),r.set("index",t.DrawOrderType.TopDown);var o=n.draworder;o&&(e.drawOrder=r.get(o)),e.objects=[];for(var s=0,a=n.objects;s<a.length;s++){var c=a[s];e.objects.push(this.loadTmxObject(new t.TmxObject,i,c))}return e.properties=this.parsePropertyDict(n.properties),e},e.loadTmxObject=function(e,i,n){e.id=null!=n.id?n.id:0,e.name=null!=n.name?n.name:"",e.x=n.x,e.y=n.y,e.width=null!=n.width?n.width:0,e.height=null!=n.height?n.height:0,e.type=null!=n.type?n.type:"",e.visible=null==n.visible||n.visible,e.rotation=null!=n.rotation?n.rotation:0;var r=n.gid,o=n.ellipse,s=n.polygon,a=n.polyline,c=n.text,h=n.point;return r?(e.tile=new t.TmxLayerTile(i,r,Math.round(e.x),Math.round(e.y)),e.objectType=t.TmxObjectType.tile):o?e.objectType=t.TmxObjectType.ellipse:s?(e.points=this.parsePoints(s),e.objectType=t.TmxObjectType.polygon):a?(e.points=this.parsePoints(a),e.objectType=t.TmxObjectType.polyline):c?(e.text=this.loadTmxText(new t.TmxText,c),e.objectType=t.TmxObjectType.text):e.objectType=h?t.TmxObjectType.point:t.TmxObjectType.basic,e.properties=this.parsePropertyDict(n.properties),e},e.loadTmxText=function(e,i){return e.fontFamily=null!=i.fontfamily?i.fontfamily:"sans-serif",e.pixelSize=null!=i.pixelsize?i.pixelsize:16,e.wrap=null!=i.wrap&&i.wrap,e.color=t.TmxUtils.color16ToUnit(i.color),e.bold=!!i.bold&&i.bold,e.italic=!!i.italic&&i.italic,e.underline=!!i.underline&&i.underline,e.strikeout=!!i.strikeout&&i.strikeout,e.kerning=!i.kerning||i.kerning,e.alignment=this.loadTmxAlignment(new t.TmxAlignment,i),e.value=i,e},e.loadTmxAlignment=function(e,i){function n(t){return t&&""!=t?t[0].toString().toUpperCase()+t.substr(1):t}var r=null!=i.halign?i.halign:"left";e.horizontal=t.TmxHorizontalAlignment[n(r)];var o=null!=i.valign?i.valign:"top";return e.vertical=t.TmxVerticalAlignment[n(o)],e},e.parsePoints=function(t){for(var e=[],i=0,n=0,r=t;n<r.length;n++){var o=r[n];e[i++]=this.parsePoint(o)}return e},e.parsePoint=function(e){return new t.Vector2(e.x,e.y)},e.parseTmxTerrain=function(e){var i=new t.TmxTerrain;return i.name=e.name,i.tile=e.tile,i.properties=this.parsePropertyDict(e.properties),i},e.parseTmxTileOffset=function(e){var i=new t.TmxTileOffset;return e?(i.x=e.x,i.y=e.y,i):(i.x=0,i.y=0,i)},e.loadTmxImage=function(e,i){return __awaiter(this,void 0,void 0,function(){var n,r,o,s,a;return __generator(this,function(c){switch(c.label){case 0:return(n=i.image)?(e.source="resource/assets/"+n,r=e,s=(o=egret.SpriteSheet).bind,[4,RES.getResByUrl(e.source,null,this,RES.ResourceItem.TYPE_IMAGE)]):[3,2];case 1:return r.bitmap=new(s.apply(o,[void 0,c.sent()])),[3,3];case 2:e.format=i.format,a=i.data,e.data=t.TmxUtils.decode(a,a.encoding,a.compression),c.label=3;case 3:return e.trans=t.TmxUtils.color16ToUnit(i.trans),e.width=null!=i.imagewidth?i.imagewidth:0,e.height=null!=i.imageheight?i.imageheight:0,[2,e]}})})},e}();t.TiledMapLoader=e}(es||(es={})),function(t){var e=egret.Bitmap,i=function(){function i(){}return i.renderMap=function(e,i,n,r,o){var s=this;e.layers.forEach(function(e){e instanceof t.TmxLayer&&e.visible?s.renderLayer(e,i,n,r,o):e instanceof t.TmxImageLayer&&e.visible?s.renderImageLayer(e,i,n,r,o):e instanceof t.TmxGroup&&e.visible?s.renderGroup(e,i,n,r,o):e instanceof t.TmxObjectGroup&&e.visible&&s.renderObjectGroup(e,i,n,r,o)})},i.renderLayer=function(e,i,n,r,o){if(e.visible)for(var s=e.map.tileWidth*r.x,a=e.map.tileHeight*r.y,c=t.DrawUtils.getColorMatrix(16777215),h=0;h<e.tiles.length;h++){var u=e.tiles[h];u&&this.renderTile(u,i,n,r,s,a,c,o)}},i.renderLayerRenderCamera=function(e,i,n,r,o,s){e instanceof t.TmxLayer&&e.visible?this.renderLayerCamera(e,i,n,r,o,s):e instanceof t.TmxImageLayer&&e.visible?this.renderImageLayer(e,i,n,r,o):e instanceof t.TmxGroup&&e.visible?this.renderGroup(e,i,n,r,o):e instanceof t.TmxObjectGroup&&e.visible&&this.renderObjectGroup(e,i,n,r,o)},i.renderLayerCamera=function(e,i,n,r,o,s){if(e.visible){n=n.add(e.offset),s.location=s.location.subtract(n);var a,c,h,u=e.map.tileWidth*r.x,l=e.map.tileHeight*r.y,p=0;e.map.requiresLargeTileCulling?(a=e.map.worldToTilePositionX(s.left-(e.map.maxTileWidth*r.x-u)),c=e.map.worldToTilePositionY(s.top-(e.map.maxTileHeight*r.y-l)),h=e.map.worldToTilePositionX(s.right+(e.map.maxTileWidth*r.x-u)),p=e.map.worldToTilePositionY(s.bottom+(e.map.maxTileHeight*r.y-l))):(a=e.map.worldToTilePositionX(s.left),c=e.map.worldToTilePositionY(s.top),h=e.map.worldToTilePositionX(s.right),p=e.map.worldToTilePositionY(s.bottom));for(var d=t.DrawUtils.getColorMatrix(16777215),f=c;f<=p;f++)for(var m=a;m<=h;m++){var g=e.getTile(m,f);g&&this.renderTile(g,i,n,r,u,l,d,o)}}},i.renderImageLayer=function(e,i,n,r,o){if(e.visible){var s=t.DrawUtils.getColorMatrix(16777215),a=t.Vector2.add(n,new t.Vector2(e.offsetX,e.offsetY).multiply(r));e.image.texture.parent||i.addChild(e.image.texture),e.image.texture.x=a.x,e.image.texture.y=a.y,e.image.texture.scaleX=r.x,e.image.texture.scaleY=r.y,e.image.texture.filters=[s]}},i.renderObjectGroup=function(i,n,r,o,s){if(i.visible)for(var a in i.objects){var c=i.objects[a];if(c.visible&&(t.Core.debugRenderEndabled||c.objectType==t.TmxObjectType.tile||c.objectType==t.TmxObjectType.text)){var h=t.Vector2.add(r,new t.Vector2(c.x,c.y).multiply(o));switch(c.objectType){case t.TmxObjectType.basic:c.shape.parent||n.addChild(c.shape);var u=new t.Rectangle(h.x,h.y,c.width*o.x,c.height*o.y);t.DrawUtils.drawHollowRect(c.shape,u,i.color);break;case t.TmxObjectType.point:var l=.5*i.map.tileWidth;h.x-=.5*l,h.y-=.5*l,c.shape.parent||n.addChild(c.shape),t.DrawUtils.drawPixel(c.shape,h,i.color,l);break;case t.TmxObjectType.tile:var p=i.map.getTilesetForTileGid(c.tile.gid),d=p.tileRegions.get(c.tile.gid);if(c.tile.horizontalFlip&&c.tile.verticalFlip?(h.x+=p.tileHeight+(d.height*o.y-p.tileHeight),h.y-=d.width*o.x-p.tileWidth):c.tile.horizontalFlip?h.x+=p.tileWidth+(d.height*o.y-p.tileHeight):c.tile.verticalFlip?h.y+=p.tileWidth-d.width*o.x:h.y+=p.tileHeight-d.height*o.y,n){var f=p.image.bitmap.getTexture(""+c.tile.gid);f||(f=p.image.bitmap.createTexture(""+c.tile.gid,d.x,d.y,d.width,d.height)),p.image.texture=new e(f),n.addChild(p.image.texture),p.image.texture.x!=h.x&&(p.image.texture.x=h.x),p.image.texture.y!=h.y&&(p.image.texture.y=h.y),c.tile.verticalFlip&&c.tile.horizontalFlip?(p.image.texture.scaleX=-1,p.image.texture.scaleY=-1):c.tile.verticalFlip?(p.image.texture.scaleX=o.x,p.image.texture.scaleY=-1):c.tile.horizontalFlip?(p.image.texture.scaleX=-1,p.image.texture.scaleY=o.y):(p.image.texture.scaleX=o.x,p.image.texture.scaleY=o.y),0!=p.image.texture.anchorOffsetX&&(p.image.texture.anchorOffsetX=0),0!=p.image.texture.anchorOffsetY&&(p.image.texture.anchorOffsetY=0)}break;case t.TmxObjectType.ellipse:h=new t.Vector2(c.x+.5*c.width,c.y+.5*c.height).multiply(o),c.shape.parent||n.addChild(c.shape),t.DrawUtils.drawCircle(c.shape,h,.5*c.width,i.color);break;case t.TmxObjectType.polygon:case t.TmxObjectType.polyline:for(var m=[],g=0;g<c.points.length;g++)m[g]=t.Vector2.multiply(c.points[g],o);t.DrawUtils.drawPoints(c.shape,h,m,i.color,c.objectType==t.TmxObjectType.polygon);break;case t.TmxObjectType.text:c.textField.parent||n.addChild(c.textField),t.DrawUtils.drawString(c.textField,c.text.value,h,c.text.color,t.MathHelper.toRadians(c.rotation),t.Vector2.zero,1);break;default:t.Core.debugRenderEndabled&&(c.textField.parent||n.addChild(c.textField),t.DrawUtils.drawString(c.textField,c.name+"("+c.type+")",t.Vector2.subtract(h,new t.Vector2(0,15)),16777215,0,t.Vector2.zero,1))}}}},i.renderGroup=function(e,i,n,r,o){var s=this;e.visible&&e.layers.forEach(function(e){e instanceof t.TmxGroup&&s.renderGroup(e,i,n,r,o),e instanceof t.TmxObjectGroup&&s.renderObjectGroup(e,i,n,r,o),e instanceof t.TmxLayer&&s.renderLayer(e,i,n,r,o),e instanceof t.TmxImageLayer&&s.renderImageLayer(e,i,n,r,o)})},i.renderTile=function(i,n,r,o,s,a,c,h){var u=i.gid,l=i.tilesetTile;l&&l.animationFrames.length>0&&(u=l.currentAnimationFrameGid);var p=i.tileset.tileRegions.get(u),d=Math.floor(i.x)*s,f=Math.floor(i.y)*a;i.horizontalFlip&&i.verticalFlip?(d+=a+(p.height*o.y-a),f-=p.width*o.x-s):i.horizontalFlip?(d+=s+(p.height*o.y-a),f+=a):i.verticalFlip?f+=s-p.width*o.x:f+=a;var m=new t.Vector2(d,f).add(r);if(i.tileset.image){if(n){var g=i.tileset.image.bitmap.getTexture(""+u);g||(g=i.tileset.image.bitmap.createTexture(""+u,p.x,p.y,p.width,p.height)),i.tileset.image.texture=new e(g),n.addChild(i.tileset.image.texture),i.tileset.image.texture.x!=m.x&&(i.tileset.image.texture.x=m.x),i.tileset.image.texture.y!=m.y&&(i.tileset.image.texture.y=m.y),i.verticalFlip&&i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=-1):i.verticalFlip?(i.tileset.image.texture.scaleX=o.x,i.tileset.image.texture.scaleY=-1):i.horizontalFlip?(i.tileset.image.texture.scaleX=-1,i.tileset.image.texture.scaleY=o.y):(i.tileset.image.texture.scaleX=o.x,i.tileset.image.texture.scaleY=o.y),0!=i.tileset.image.texture.rotation&&(i.tileset.image.texture.rotation=0),0!=i.tileset.image.texture.anchorOffsetX&&(i.tileset.image.texture.anchorOffsetX=0),0!=i.tileset.image.texture.anchorOffsetY&&(i.tileset.image.texture.anchorOffsetY=0)}}else l.image.texture&&(l.image.bitmap.getTexture(u.toString())||(l.image.texture=new e(l.image.bitmap.createTexture(u.toString(),p.x,p.y,p.width,p.height)),n.addChild(l.image.texture)),l.image.texture.x=m.x,l.image.texture.y=m.y,l.image.texture.scaleX=o.x,l.image.texture.scaleY=o.y,l.image.texture.rotation=0,l.image.texture.anchorOffsetX=0,l.image.texture.anchorOffsetY=0,l.image.texture.filters=[c])},i}();t.TiledRendering=i}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.update=function(){this.tiles.forEach(function(t){t.updateAnimatedTiles()})},e}(t.TmxDocument);t.TmxTileset=e;var i=function(){return function(){}}();t.TmxTileOffset=i;var n=function(){return function(){}}();t.TmxTerrain=n}(es||(es={})),function(t){var e=function(){function e(){}return Object.defineProperty(e.prototype,"currentAnimationFrameGid",{get:function(){return this.animationFrames[this._animationCurrentFrame].gid+this.tileset.firstGid},enumerable:!0,configurable:!0}),e.prototype.processProperties=function(){var t;(t=this.properties.get("engine.isDestructable"))&&(this.isDestructable=Boolean(t)),(t=this.properties.get("engine:isSlope"))&&(this.isSlope=Boolean(t)),(t=this.properties.get("engine:isOneWayPlatform"))&&(this.isOneWayPlatform=Boolean(t)),(t=this.properties.get("engine:slopeTopLeft"))&&(this.slopeTopLeft=Number(t)),(t=this.properties.get("engine:slopeTopRight"))&&(this.slopeTopRight=Number(t))},e.prototype.updateAnimatedTiles=function(){0!=this.animationFrames.length&&(this._animationElapsedTime+=t.Time.deltaTime,this._animationElapsedTime>this.animationFrames[this._animationCurrentFrame].duration&&(this._animationCurrentFrame=t.MathHelper.incrementWithWrap(this._animationCurrentFrame,this.animationFrames.length),this._animationElapsedTime=0))},e}();t.TmxTilesetTile=e;var i=function(){return function(){}}();t.TmxAnimationFrame=i}(es||(es={})),function(t){var e=function(){function e(){}return e.decode=function(e,i,n){switch(n=n||"none",i=i||"none"){case"base64":var r=t.Base64Utils.decodeBase64AsArray(e,4);return"none"===n?r:t.Base64Utils.decompress(e,r,n);case"csv":return t.Base64Utils.decodeCSV(e);case"none":for(var o=[],s=0;s<e.length;s++)o[s]=+e[s].gid;return o;default:throw new Error("未定义的编码:"+i)}},e.color16ToUnit=function(t){if(!t)return 16777215;var e="0x"+t.slice(1);return parseInt(e,16)},e}();t.TmxUtils=e}(es||(es={}));var ArrayUtils=function(){function t(){}return t.bubbleSort=function(t){for(var e=!1,i=0;i<t.length;i++){e=!1;for(var n=t.length-1;n>i;n--)if(t[n]<t[n-1]){var r=t[n];t[n]=t[n-1],t[n-1]=r,e=!0}if(!e)break}},t.insertionSort=function(t){for(var e=t.length,i=1;i<e;i++){for(var n=t[i],r=i;r>0&&t[r-1]>n;r--)t[r]=t[r-1];t[r]=n}},t.binarySearch=function(t,e){for(var i=0,n=t.length,r=i+n>>1;i<n;)e<=t[r]?n=r:e>=t[r]&&(i=r+1),r=i+n>>1;return t[i]==e?i:-1},t.findElementIndex=function(t,e){for(var i=t.length,n=0;n<i;++n)if(t[n]==e)return n;return null},t.getMaxElementIndex=function(t){for(var e=0,i=t.length,n=1;n<i;n++)t[n]>t[e]&&(e=n);return e},t.getMinElementIndex=function(t){for(var e=0,i=t.length,n=1;n<i;n++)t[n]<t[e]&&(e=n);return e},t.getUniqueAry=function(t){for(var e=[],i=[],n=t.length,r=0;r<n;++r){var o=t[r];-1==e.indexOf(o)&&e.push(o)}for(r=(n=e.length)-1;r>=0;--r)i.unshift(e[r]);return i},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var i=t.concat(e),n={},r=[],o=i.length,s=0;s<o;++s)n[i[s]]?n[i[s]]instanceof Object&&n[i[s]].count++:(n[i[s]]={},n[i[s]].count=0,n[i[s]].key=i[s],n[i[s]].count++);for(var a in n)2!=n[a].count&&r.unshift(n[a].key);return r},t.swap=function(t,e,i){var n=t[e];t[e]=t[i],t[i]=n},t.clearList=function(t){if(t)for(var e=t.length-1;e>=0;e-=1)t.splice(e,1)},t.cloneList=function(t){return t?t.slice(0,t.length):null},t.equals=function(t,e){if(t==e)return!0;var i=t.length;if(i!=e.length)return!1;for(;i--;)if(t[i]!=e[i])return!1;return!0},t.insert=function(t,e,i){if(!t)return null;var n=t.length;if(e>n&&(e=n),e<0&&(e=0),e==n)t.push(i);else if(0==e)t.unshift(i);else{for(var r=n-1;r>=e;r-=1)t[r+1]=t[r];t[e]=i}return i},t}();!function(t){var e=function(){function t(){}return Object.defineProperty(t,"nativeBase64",{get:function(){return"function"==typeof window.atob},enumerable:!0,configurable:!0}),t.decode=function(t){if(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),this.nativeBase64)return window.atob(t);for(var e,i,n,r,o,s,a=[],c=0;c<t.length;)e=this._keyStr.indexOf(t.charAt(c++))<<2|(r=this._keyStr.indexOf(t.charAt(c++)))>>4,i=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(c++)))>>2,n=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(c++))),a.push(String.fromCharCode(e)),64!==o&&a.push(String.fromCharCode(i)),64!==s&&a.push(String.fromCharCode(n));return a=a.join("")},t.encode=function(t){if(t=t.replace(/\r\n/g,"\n"),!this.nativeBase64){for(var e,i,n,r,o,s,a,c=[],h=0;h<t.length;)r=(e=t.charCodeAt(h++))>>2,o=(3&e)<<4|(i=t.charCodeAt(h++))>>4,s=(15&i)<<2|(n=t.charCodeAt(h++))>>6,a=63&n,isNaN(i)?s=a=64:isNaN(n)&&(a=64),c.push(this._keyStr.charAt(r)),c.push(this._keyStr.charAt(o)),c.push(this._keyStr.charAt(s)),c.push(this._keyStr.charAt(a));return c=c.join("")}window.btoa(t)},t.decodeBase64AsArray=function(e,i){i=i||1;var n,r,o,s=t.decode(e),a=new Uint32Array(s.length/i);for(n=0,o=s.length/i;n<o;n++)for(a[n]=0,r=i-1;r>=0;--r)a[n]+=s.charCodeAt(n*i+r)<<(r<<3);return a},t.decompress=function(t,e,i){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},t.decodeCSV=function(t){for(var e=t.replace("\n","").trim().split(","),i=[],n=0;n<e.length;n++)i.push(+e[n]);return i},t._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t}();t.Base64Utils=e}(es||(es={})),function(t){var e=function(){function e(e,i,n,r){if(0!=(4294967040&(e|i|n|r))){var o=t.MathHelper.clamp(e,0,255),s=t.MathHelper.clamp(i,0,255),a=t.MathHelper.clamp(n,0,255),c=t.MathHelper.clamp(r,0,255);this._packedValue=c<<24|a<<16|s<<8|o}else this._packedValue=r<<24|n<<16|i<<8|e}return Object.defineProperty(e.prototype,"b",{get:function(){return this._packedValue>>16},set:function(t){this._packedValue=4278255615&this._packedValue|t<<16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this._packedValue>>8},set:function(t){this._packedValue=4294902015&this._packedValue|t<<8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"r",{get:function(){return this._packedValue},set:function(t){this._packedValue=4294967040&this._packedValue|t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a",{get:function(){return this._packedValue>>24},set:function(t){this._packedValue=16777215&this._packedValue|t<<24},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"packedValue",{get:function(){return this._packedValue},set:function(t){this._packedValue=t},enumerable:!0,configurable:!0}),e.prototype.equals=function(t){return this._packedValue==t._packedValue},e}();t.Color=e}(es||(es={})),function(t){var e=function(){function t(){this.loadedAssets=new Map}return t.prototype.loadRes=function(t,e){var i=this;return void 0===e&&(e=!0),new Promise(function(n,r){var o=i.loadedAssets.get(t);o?n(o):e?RES.getResAsync(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)}):RES.getResByUrl(t).then(function(e){i.loadedAssets.set(t,e),n(e)}).catch(function(e){console.error("资源加载错误:",t,e),r(e)})})},t.prototype.dispose=function(){this.loadedAssets.forEach(function(t){t.dispose()}),this.loadedAssets.clear()},t}();t.ContentManager=e}(es||(es={})),function(t){var e=function(){function e(){}return e.drawLine=function(e,i,n,r,o){void 0===o&&(o=1),this.drawLineAngle(e,i,t.MathHelper.angleBetweenVectors(i,n),t.Vector2.distance(i,n),r,o)},e.drawCircle=function(t,e,i,n){t.graphics.beginFill(n),t.graphics.drawCircle(e.x,e.y,i),t.graphics.endFill()},e.drawPoints=function(e,i,n,r,o,s){if(void 0===o&&(o=!0),void 0===s&&(s=1),!(n.length<2)){for(var a=1;a<n.length;a++)this.drawLine(e,t.Vector2.add(i,n[a-1]),t.Vector2.add(i,n[a]),r,s);o&&this.drawLine(e,t.Vector2.add(i,n[n.length-1]),t.Vector2.add(i,n[0]),r,s)}},e.drawString=function(t,e,i,n,r,o,s){},e.drawLineAngle=function(t,e,i,n,r,o){void 0===o&&(o=1),t.graphics.beginFill(r),t.graphics.drawRect(e.x,e.y,1,1),t.graphics.endFill(),t.scaleX=n,t.scaleY=o,t.$anchorOffsetX=0,t.$anchorOffsetY=0,t.rotation=i},e.drawHollowRect=function(t,e,i,n){void 0===n&&(n=1),this.drawHollowRectR(t,e.x,e.y,e.width,e.height,i,n)},e.drawHollowRectR=function(e,i,n,r,o,s,a){void 0===a&&(a=1);var c=new t.Vector2(i,n).round(),h=new t.Vector2(i+r,n).round(),u=new t.Vector2(i+r,n+o).round(),l=new t.Vector2(i,n+o).round();this.drawLine(e,c,h,s,a),this.drawLine(e,h,u,s,a),this.drawLine(e,u,l,s,a),this.drawLine(e,l,c,s,a)},e.drawPixel=function(e,i,n,r){void 0===r&&(r=1);var o=new t.Rectangle(i.x,i.y,r,r);1!=r&&(o.x-=.5*r,o.y-=.5*r),e.graphics.beginFill(n),e.graphics.drawRect(o.x,o.y,o.width,o.height),e.graphics.endFill()},e.getColorMatrix=function(t){var e=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0];return e[0]=Math.floor(t/256/256)/255,e[6]=Math.floor(t/256%256)/255,e[12]=t%256/255,new egret.ColorMatrixFilter(e)},e}();t.DrawUtils=e}(es||(es={})),function(t){var e=function(){function e(){}return e.oppositeEdge=function(e){switch(e){case t.Edge.bottom:return t.Edge.top;case t.Edge.top:return t.Edge.bottom;case t.Edge.left:return t.Edge.right;case t.Edge.right:return t.Edge.left}},e.isHorizontal=function(e){return e==t.Edge.right||e==t.Edge.left},e.isVertical=function(e){return e==t.Edge.top||e==t.Edge.bottom},e}();t.EdgeExt=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var i=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,i,n){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==i})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(i,n))},t.prototype.removeObserver=function(t,e){var i=this._messageTable.get(t),n=i.findIndex(function(t){return t.func==e});-1!=n&&i.removeAt(n)},t.prototype.emit=function(t,e){var i=this._messageTable.get(t);if(i)for(var n=i.length-1;n>=0;n--)i[n].func.call(i[n].context,e)},t}();t.Emitter=i}(es||(es={})),function(t){!function(t){t[t.top=0]="top",t[t.bottom=1]="bottom",t[t.left=2]="left",t[t.right=3]="right"}(t.Edge||(t.Edge={}))}(es||(es={})),function(t){var e=function(){function t(){}return t.repeat=function(t,e){for(var i=[];e--;)i.push(t);return i},t}();t.Enumerable=e}(es||(es={})),function(t){var e=function(){function t(){}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.setEnabled=function(t){this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled())},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.update=function(){},t}();t.GlobalManager=e}(es||(es={})),function(t){var e=function(){function e(){this.x=0,this.y=0,this.touchPoint=-1,this.touchDown=!1}return Object.defineProperty(e.prototype,"position",{get:function(){return new t.Vector2(this.x,this.y)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this.x=0,this.y=0,this.touchDown=!1,this.touchPoint=-1},e}();t.TouchState=e;var i=function(){function i(){}return Object.defineProperty(i,"gameTouchs",{get:function(){return this._gameTouchs},enumerable:!0,configurable:!0}),Object.defineProperty(i,"resolutionScale",{get:function(){return this._resolutionScale},enumerable:!0,configurable:!0}),Object.defineProperty(i,"totalTouchCount",{get:function(){return this._totalTouchCount},enumerable:!0,configurable:!0}),Object.defineProperty(i,"touchPosition",{get:function(){return this._gameTouchs[0]?this._gameTouchs[0].position:t.Vector2.zero},enumerable:!0,configurable:!0}),Object.defineProperty(i,"maxSupportedTouch",{get:function(){return t.Core._instance.stage.maxTouches},set:function(e){t.Core._instance.stage.maxTouches=e,this.initTouchCache()},enumerable:!0,configurable:!0}),Object.defineProperty(i,"touchPositionDelta",{get:function(){var e=t.Vector2.subtract(this.touchPosition,this._previousTouchState.position);return e.length()>0&&this.setpreviousTouchState(this._gameTouchs[0]),e},enumerable:!0,configurable:!0}),i.initialize=function(){this._init||(this._init=!0,t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.touchBegin,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.touchMove,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_END,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.touchEnd,this),t.Core._instance.stage.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.touchEnd,this),this.initTouchCache())},i.scaledPosition=function(e){var i=new t.Vector2(e.x-this._resolutionOffset.x,e.y-this._resolutionOffset.y);return t.Vector2.multiply(i,this.resolutionScale)},i.initTouchCache=function(){this._totalTouchCount=0,this._touchIndex=0,this._gameTouchs.length=0;for(var t=0;t<this.maxSupportedTouch;t++)this._gameTouchs.push(new e)},i.touchBegin=function(t){this._touchIndex<this.maxSupportedTouch&&(this._gameTouchs[this._touchIndex].touchPoint=t.touchPointID,this._gameTouchs[this._touchIndex].touchDown=t.touchDown,this._gameTouchs[this._touchIndex].x=t.stageX,this._gameTouchs[this._touchIndex].y=t.stageY,0==this._touchIndex&&this.setpreviousTouchState(this._gameTouchs[0]),this._touchIndex++,this._totalTouchCount++)},i.touchMove=function(t){t.touchPointID==this._gameTouchs[0].touchPoint&&this.setpreviousTouchState(this._gameTouchs[0]);var e=this._gameTouchs.findIndex(function(e){return e.touchPoint==t.touchPointID});if(-1!=e){var i=this._gameTouchs[e];i.x=t.stageX,i.y=t.stageY}},i.touchEnd=function(t){var e=this._gameTouchs.findIndex(function(e){return e.touchPoint==t.touchPointID});-1!=e&&(this._gameTouchs[e].reset(),0==e&&this._previousTouchState.reset(),this._totalTouchCount--,0==this.totalTouchCount&&(this._touchIndex=0))},i.setpreviousTouchState=function(t){this._previousTouchState=new e,this._previousTouchState.x=t.position.x,this._previousTouchState.y=t.position.y,this._previousTouchState.touchPoint=t.touchPoint,this._previousTouchState.touchDown=t.touchDown},i._init=!1,i._previousTouchState=new e,i._resolutionOffset=new t.Vector2,i._touchIndex=0,i._gameTouchs=[],i._resolutionScale=t.Vector2.one,i._totalTouchCount=0,i}();t.Input=i}(es||(es={}));var KeyboardUtils=function(){function t(){}return t.init=function(){this.keyDownDict={},this.keyUpDict={},document.addEventListener("keydown",this.onKeyDonwHander),document.addEventListener("keyup",this.onKeyUpHander)},t.registerKey=function(t,e,i,n){void 0===n&&(n=0);for(var r=[],o=4;o<arguments.length;o++)r[o-4]=arguments[o];(n?this.keyUpDict:this.keyDownDict)[t]={fun:e,args:r,thisObj:i}},t.unregisterKey=function(t,e){void 0===e&&(e=0),delete(e?this.keyUpDict:this.keyDownDict)[t]},t.destroy=function(){this.keyDownDict=null,this.keyUpDict=null,document.removeEventListener("keydown",this.onKeyDonwHander),document.removeEventListener("keyup",this.onKeyUpHander)},t.onKeyDonwHander=function(t){if(this.keyDownDict){var e=this.keyCodeToString(t.keyCode),i=this.keyDownDict[e];if(i){var n=i.fun,r=i.thisObj,o=i.args;n.apply(r,o)}}},t.onKeyUpHander=function(t){if(this.keyUpDict){var e=this.keyCodeToString(t.keyCode),i=this.keyUpDict[e];if(i){var n=i.fun,r=i.thisObj,o=i.args;n.apply(r,o)}}},t.keyCodeToString=function(t){switch(t){case 8:return this.BACK_SPACE;case 9:return this.TAB;case 13:return this.ENTER;case 16:return this.SHIFT;case 17:return this.CTRL;case 19:return this.PAUSE_BREAK;case 20:return this.CAPS_LOCK;case 27:return this.ESC;case 32:return this.SPACE;case 33:return this.PAGE_UP;case 34:return this.PAGE_DOWN;case 35:return this.END;case 36:return this.HOME;case 37:return this.LEFT;case 38:return this.UP;case 39:return this.RIGHT;case 40:return this.DOWN;case 45:return this.INSERT;case 46:return this.DELETE;case 91:return this.WINDOWS;case 112:return this.F1;case 113:return this.F2;case 114:return this.F3;case 115:return this.F4;case 116:return this.F5;case 117:return this.F6;case 118:return this.F7;case 119:return this.F8;case 120:return this.F9;case 122:return this.F11;case 123:return this.F12;case 144:return this.NUM_LOCK;case 145:return this.SCROLL_LOCK;default:return String.fromCharCode(t)}},t.TYPE_KEY_DOWN=0,t.TYPE_KEY_UP=1,t.A="A",t.B="B",t.C="C",t.D="D",t.E="E",t.F="F",t.G="G",t.H="H",t.I="I",t.J="J",t.K="K",t.L="L",t.M="M",t.N="N",t.O="O",t.P="P",t.Q="Q",t.R="R",t.S="S",t.T="T",t.U="U",t.V="V",t.W="W",t.X="X",t.Y="Y",t.Z="Z",t.ESC="Esc",t.F1="F1",t.F2="F2",t.F3="F3",t.F4="F4",t.F5="F5",t.F6="F6",t.F7="F7",t.F8="F8",t.F9="F9",t.F10="F10",t.F11="F11",t.F12="F12",t.NUM_1="1",t.NUM_2="2",t.NUM_3="3",t.NUM_4="4",t.NUM_5="5",t.NUM_6="6",t.NUM_7="7",t.NUM_8="8",t.NUM_9="9",t.NUM_0="0",t.TAB="Tab",t.CTRL="Ctrl",t.ALT="Alt",t.SHIFT="Shift",t.CAPS_LOCK="Caps Lock",t.ENTER="Enter",t.SPACE="Space",t.BACK_SPACE="Back Space",t.INSERT="Insert",t.DELETE="Page Down",t.HOME="Home",t.END="Page Down",t.PAGE_UP="Page Up",t.PAGE_DOWN="Page Down",t.LEFT="Left",t.RIGHT="Right",t.UP="Up",t.DOWN="Down",t.PAUSE_BREAK="Pause Break",t.NUM_LOCK="Num Lock",t.SCROLL_LOCK="Scroll Lock",t.WINDOWS="Windows",t}();!function(t){var e=function(){function t(){}return t.warmCache=function(t){if((t-=this._objectQueue.length)>0)for(var e=0;e<t;e++)this._objectQueue.unshift([])},t.trimCache=function(t){for(;t>this._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={}));var THREAD_ID=Math.floor(1e3*Math.random())+"-"+Date.now(),nextTick=function(t){setTimeout(t,0)},LockUtils=function(){function t(t){this._keyX="mutex_key_"+t+"_X",this._keyY="mutex_key_"+t+"_Y",this.setItem=egret.localStorage.setItem.bind(localStorage),this.getItem=egret.localStorage.getItem.bind(localStorage),this.removeItem=egret.localStorage.removeItem.bind(localStorage)}return t.prototype.lock=function(){var t=this;return new Promise(function(e,i){var n=function(){t.setItem(t._keyX,THREAD_ID),null===!t.getItem(t._keyY)&&nextTick(n),t.setItem(t._keyY,THREAD_ID),t.getItem(t._keyX)!==THREAD_ID?setTimeout(function(){t.getItem(t._keyY)===THREAD_ID?(e(),t.removeItem(t._keyY)):nextTick(n)},10):(e(),t.removeItem(t._keyY))};n()})},t}();!function(t){var e=function(){function t(t,e){this.first=t,this.second=e}return t.prototype.clear=function(){this.first=this.second=null},t.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},t}();t.Pair=e}(es||(es={}));var RandomUtils=function(){function t(){}return t.randrange=function(t,e,i){if(void 0===i&&(i=1),0==i)throw new Error("step 不能为 0");var n=e-t;if(0==n)throw new Error("没有可用的范围("+t+","+e+")");n<0&&(n=t-e);var r=Math.floor((n+i-1)/i);return Math.floor(this.random()*r)*i+Math.min(t,e)},t.randint=function(t,e){return(t=Math.floor(t))>(e=Math.floor(e))?t++:e++,this.randrange(t,e)},t.randnum=function(t,e){return this.random()*(e-t)+t},t.shuffle=function(t){return t.sort(this._randomCompare),t},t.choice=function(t){if(!t.hasOwnProperty("length"))throw new Error("无法对此对象执行此操作");var e=Math.floor(this.random()*t.length);return t instanceof String?String(t).charAt(e):t[e]},t.sample=function(t,e){var i=t.length;if(e<=0||i<e)throw new Error("采样数量不够");for(var n=[],r=[],o=0;o<e;o++){for(var s=Math.floor(this.random()*i);r.indexOf(s)>=0;)s=Math.floor(this.random()*i);n.push(t[s]),r.push(s)}return n},t.random=function(){return Math.random()},t.boolean=function(t){return void 0===t&&(t=.5),this.random()<t},t._randomCompare=function(t,e){return this.random()>.5?1:-1},t}();!function(t){var e=function(){function e(){}return e.getSide=function(e,i){switch(i){case t.Edge.top:return e.top;case t.Edge.bottom:return e.bottom;case t.Edge.left:return e.left;case t.Edge.right:return e.right}},e.union=function(e,i){var n=new t.Rectangle(i.x,i.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,n.x),r.y=Math.min(e.y,n.y),r.width=Math.max(e.right,n.right)-r.x,r.height=Math.max(e.bottom,r.bottom)-r.y,r},e.getHalfRect=function(e,i){switch(i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,e.height/2);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height/2,e.width,e.height/2);case t.Edge.left:return new t.Rectangle(e.x,e.y,e.width/2,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width/2,e.y,e.width/2,e.height)}},e.getRectEdgePortion=function(e,i,n){switch(void 0===n&&(n=1),i){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,n);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-n,e.width,n);case t.Edge.left:return new t.Rectangle(e.x,e.y,n,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-n,e.y,n,e.height)}},e.expandSide=function(e,i,n){switch(n=Math.abs(n),i){case t.Edge.top:e.y-=n,e.height+=n;break;case t.Edge.bottom:e.height+=n;break;case t.Edge.left:e.x-=n,e.width+=n;break;case t.Edge.right:e.width+=n}},e.contract=function(t,e,i){t.x+=e,t.y+=i,t.width-=2*e,t.height-=2*i},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.update=function(t){this.remainder+=t;var e=Math.trunc(this.remainder);return this.remainder-=e,e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelNumber=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,i,n,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(n,i))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(r,n))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(i,r))<0))},e.prototype.triangulate=function(i,n){void 0===n&&(n=!0);var r=i.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,c=i[this._triPrev[s]],h=i[s],u=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(c,h,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[l],c,h,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),n||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.length<t&&(this._triNext.reverse(),this._triNext=new Array(Math.max(2*this._triNext.length,t))),this._triPrev.length<t&&(this._triPrev.reverse(),this._triPrev=new Array(Math.max(2*this._triPrev.length,t)));for(var e=0;e<t;e++)this._triPrev[e]=e-1,this._triNext[e]=e+1;this._triPrev[0]=t-1,this._triNext[t-1]=0},e}();t.Triangulator=e}(es||(es={})),function(t){var e=function(){function e(){}return e.isTriangleCCW=function(e,i,n){return this.cross(t.Vector2.subtract(i,e),t.Vector2.subtract(n,i))<0},e.cross=function(t,e){return t.y*e.x-t.x*e.y},e.perpendicular=function(e,i){return new t.Vector2(-1*(i.y-e.y),i.x-e.x)},e.normalize=function(e){var i=Math.sqrt(e.x*e.x+e.y*e.y);return i>t.MathHelper.Epsilon?e=t.Vector2.divide(e,new t.Vector2(i)):e.x=e.y=0,e},e.transformA=function(t,e,i,n,r,o){for(var s=0;s<o;s++){var a=t[e+s],c=n[r+s];c.x=a.x*i.m11+a.y*i.m21+i.m31,c.y=a.x*i.m12+a.y*i.m22+i.m32,n[r+s]=c}},e.transformR=function(e,i){var n=e.x*i.m11+e.y*i.m21+i.m31,r=e.x*i.m12+e.y*i.m22+i.m32;return new t.Vector2(n,r)},e.transform=function(t,e,i){this.transformA(t,0,e,i,0,t.length)},e.round=function(e){return new t.Vector2(Math.round(e.x),Math.round(e.y))},e}();t.Vector2Ext=e}(es||(es={}));var stopwatch,WebGLUtils=function(){function t(){}return t.getContext=function(){return document.getElementsByTagName("canvas")[0].getContext("2d")},t}();!function(t){var e,i=function(){function i(){this.clientArea=new t.Rectangle(0,0,t.Core.graphicsDevice.viewport.width,t.Core.graphicsDevice.viewport.height),this.safeArea=this.clientArea}return i.prototype.place=function(i,n,r,o){var s=new t.Rectangle(0,0,i.x,i.y);return 0!=(o&e.left)?s.x=this.clientArea.x+this.clientArea.width*n:0!=(o&e.right)?s.x=this.clientArea.x+this.clientArea.width*(1-n)-s.width:0!=(o&e.horizontalCenter)&&(s.x=this.clientArea.x+(this.clientArea.width-s.width)/2+n*this.clientArea.width),0!=(o&e.top)?s.y=this.clientArea.y+this.clientArea.height*r:0!=(o&e.bottom)?s.y=this.clientArea.y+this.clientArea.height*(1-r)-s.height:0!=(o&e.verticalCenter)&&(s.y=this.clientArea.y+(this.clientArea.height-s.height)/2+r*this.clientArea.height),s.left<this.safeArea.left&&(s.x=this.safeArea.left),s.right>this.safeArea.right&&(s.x=this.safeArea.right-s.width),s.top<this.safeArea.top&&(s.y=this.safeArea.top),s.bottom>this.safeArea.bottom&&(s.y=this.safeArea.bottom-s.height),s},i}();t.Layout=i,function(t){t[t.none=0]="none",t[t.left=1]="left",t[t.right=2]="right",t[t.horizontalCenter=4]="horizontalCenter",t[t.top=8]="top",t[t.bottom=16]="bottom",t[t.verticalCenter=32]="verticalCenter",t[t.topLeft=9]="topLeft",t[t.topRight=10]="topRight",t[t.topCenter=12]="topCenter",t[t.bottomLeft=17]="bottomLeft",t[t.bottomRight=18]="bottomRight",t[t.bottomCenter=20]="bottomCenter",t[t.centerLeft=33]="centerLeft",t[t.centerRight=34]="centerRight",t[t.center=36]="center"}(e=t.Alignment||(t.Alignment={}))}(es||(es={})),function(t){var e,i=function(){function t(t){void 0===t&&(t=n),this.getSystemTime=t,this._stopDuration=0,this._completeSlices=[]}return t.prototype.getState=function(){return void 0===this._startSystemTime?e.IDLE:void 0===this._stopSystemTime?e.RUNNING:e.STOPPED},t.prototype.isIdle=function(){return this.getState()===e.IDLE},t.prototype.isRunning=function(){return this.getState()===e.RUNNING},t.prototype.isStopped=function(){return this.getState()===e.STOPPED},t.prototype.slice=function(){return this.recordPendingSlice()},t.prototype.getCompletedSlices=function(){return Array.from(this._completeSlices)},t.prototype.getCompletedAndPendingSlices=function(){return this._completeSlices.concat([this.getPendingSlice()])},t.prototype.getPendingSlice=function(){return this.calculatePendingSlice()},t.prototype.getTime=function(){return this.caculateStopwatchTime()},t.prototype.reset=function(){this._startSystemTime=this._pendingSliceStartStopwatchTime=this._stopSystemTime=void 0,this._stopDuration=0,this._completeSlices=[]},t.prototype.start=function(t){if(void 0===t&&(t=!1),t&&this.reset(),void 0!==this._stopSystemTime){var e=(i=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var i=this.getSystemTime();this._startSystemTime=i,this._pendingSliceStartStopwatchTime=0}},t.prototype.stop=function(t){if(void 0===t&&(t=!1),void 0===this._startSystemTime)return 0;var e=this.getSystemTimeOfCurrentStopwatchTime();return t&&this.recordPendingSlice(this.caculateStopwatchTime(e)),this._stopSystemTime=e,this.getTime()},t.prototype.calculatePendingSlice=function(t){return void 0===this._pendingSliceStartStopwatchTime?Object.freeze({startTime:0,endTime:0,duration:0}):(void 0===t&&(t=this.getTime()),Object.freeze({startTime:this._pendingSliceStartStopwatchTime,endTime:t,duration:t-this._pendingSliceStartStopwatchTime}))},t.prototype.caculateStopwatchTime=function(t){return void 0===this._startSystemTime?0:(void 0===t&&(t=this.getSystemTimeOfCurrentStopwatchTime()),t-this._startSystemTime-this._stopDuration)},t.prototype.getSystemTimeOfCurrentStopwatchTime=function(){return void 0===this._stopSystemTime?this.getSystemTime():this._stopSystemTime},t.prototype.recordPendingSlice=function(t){if(void 0!==this._pendingSliceStartStopwatchTime){void 0===t&&(t=this.getTime());var e=this.calculatePendingSlice(t);return this._pendingSliceStartStopwatchTime=e.endTime,this._completeSlices.push(e),e}return this.calculatePendingSlice()},t}();t.Stopwatch=i,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),n=t};var n=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){this.showLog=!1,this._frameKey="frame",this._logKey="log",this.markers=[],this.stopwacth=new stopwatch.Stopwatch,this._markerNameToIdMap=new Map,this._logs=new Array(2);for(var e=0;e<this._logs.length;++e)this._logs[e]=new i;this.sampleFrames=this.targetSampleFrames=1,this.width=.8*t.Core.graphicsDevice.viewport.width,t.Core.emitter.addObserver(t.CoreEvents.GraphicsDeviceReset,this.onGraphicsDeviceReset,this),this.onGraphicsDeviceReset()}return Object.defineProperty(e,"Instance",{get:function(){return this._instance||(this._instance=new e),this._instance},enumerable:!0,configurable:!0}),e.prototype.startFrame=function(){var t=this;new LockUtils(this._frameKey).lock().then(function(){t._updateCount=parseInt(egret.localStorage.getItem(t._frameKey),10),isNaN(t._updateCount)&&(t._updateCount=0);var i=t._updateCount;if(i+=1,egret.localStorage.setItem(t._frameKey,i.toString()),!(t.enabled&&1<i&&i<e.maxSampleFrames)){t._prevLog=t._logs[1&t.frameCount++],t._curLog=t._logs[1&t.frameCount];for(var n=t.stopwacth.getTime(),r=0;r<t._prevLog.bars.length;++r){for(var o=t._prevLog.bars[r],s=t._curLog.bars[r],a=0;a<o.nestCount;++a){var c=o.markerNests[a];o.markers[c].endTime=n,s.markerNests[a]=a,s.markers[a].markerId=o.markers[c].markerId,s.markers[a].beginTime=0,s.markers[a].endTime=-1,s.markers[a].color=o.markers[c].color}for(c=0;c<o.markCount;++c){var h=o.markers[c].endTime-o.markers[c].beginTime,u=o.markers[c].markerId,l=t.markers[u];l.logs[r].color=o.markers[c].color,l.logs[r].initialized?(l.logs[r].min=Math.min(l.logs[r].min,h),l.logs[r].max=Math.min(l.logs[r].max,h),l.logs[r].avg+=h,l.logs[r].avg*=.5,l.logs[r].samples++>=e.logSnapDuration&&(l.logs[r].snapMin=l.logs[r].min,l.logs[r].snapMax=l.logs[r].max,l.logs[r].snapAvg=l.logs[r].avg,l.logs[r].samples=0)):(l.logs[r].min=h,l.logs[r].max=h,l.logs[r].avg=h,l.logs[r].initialized=!0)}s.markCount=o.nestCount,s.nestCount=o.nestCount}t.stopwacth.reset(),t.stopwacth.start()}})},e.prototype.beginMark=function(t,i,n){var r=this;void 0===n&&(n=0),new LockUtils(this._frameKey).lock().then(function(){if(n<0||n>=e.maxBars)throw new Error("barIndex argument out of range");var o=r._curLog.bars[n];if(o.markCount>=e.maxSamples)throw new Error("exceeded sample count. either set larger number to timeruler.maxsaple or lower sample count");if(o.nestCount>=e.maxNestCall)throw new Error("exceeded nest count. either set larger number to timeruler.maxnestcall or lower nest calls");var s=r._markerNameToIdMap.get(t);isNaN(s)&&(s=r.markers.length,r._markerNameToIdMap.set(t,s)),o.markerNests[o.nestCount++]=o.markCount,o.markers[o.markCount].markerId=s,o.markers[o.markCount].color=i,o.markers[o.markCount].beginTime=r.stopwacth.getTime(),o.markers[o.markCount].endTime=-1})},e.prototype.endMark=function(t,i){var n=this;void 0===i&&(i=0),new LockUtils(this._frameKey).lock().then(function(){if(i<0||i>=e.maxBars)throw new Error("barIndex argument out of range");var r=n._curLog.bars[i];if(r.nestCount<=0)throw new Error("call beginMark method before calling endMark method");var o=n._markerNameToIdMap.get(t);if(isNaN(o))throw new Error("Marker "+t+" is not registered. Make sure you specifed same name as you used for beginMark method");var s=r.markerNests[--r.nestCount];if(r.markers[s].markerId!=o)throw new Error("Incorrect call order of beginMark/endMark method. beginMark(A), beginMark(B), endMark(B), endMark(A) But you can't called it like beginMark(A), beginMark(B), endMark(A), endMark(B).");r.markers[s].endTime=n.stopwacth.getTime()})},e.prototype.getAverageTime=function(t,i){if(t<0||t>=e.maxBars)throw new Error("barIndex argument out of range");var n=0,r=this._markerNameToIdMap.get(i);return r&&(n=this.markers[r].logs[t].avg),n},e.prototype.resetLog=function(){var t=this;new LockUtils(this._logKey).lock().then(function(){var e=parseInt(egret.localStorage.getItem(t._logKey),10);e+=1,egret.localStorage.setItem(t._logKey,e.toString()),t.markers.forEach(function(t){for(var e=0;e<t.logs.length;++e)t.logs[e].initialized=!1,t.logs[e].snapMin=0,t.logs[e].snapMax=0,t.logs[e].snapAvg=0,t.logs[e].min=0,t.logs[e].max=0,t.logs[e].avg=0,t.logs[e].samples=0})})},e.prototype.render=function(t,i){if(void 0===t&&(t=this._position),void 0===i&&(i=this.width),egret.localStorage.setItem(this._frameKey,"0"),this.showLog){var n=0,r=0;this._prevLog.bars.forEach(function(t){t.markCount>0&&(n+=e.barHeight+2*e.barPadding,r=Math.max(r,t.markers[t.markCount-1].endTime))});var o=this.sampleFrames*(1/60*1e3);this._frameAdjust=r>o?Math.max(0,this._frameAdjust)+1:Math.min(0,this._frameAdjust)-1,Math.max(this._frameAdjust)>e.autoAdjustDelay&&(this.sampleFrames=Math.min(e.maxSampleFrames,this.sampleFrames),this.sampleFrames=Math.max(this.targetSampleFrames,r/(1/60*1e3)+1),this._frameAdjust=0);t.y,e.barHeight}},e.prototype.onGraphicsDeviceReset=function(){var i=new t.Layout;this._position=i.place(new t.Vector2(this.width,e.barHeight),0,.01,t.Alignment.bottomCenter).location},e.maxBars=8,e.maxSamples=256,e.maxNestCall=32,e.barHeight=8,e.maxSampleFrames=4,e.logSnapDuration=120,e.barPadding=2,e.autoAdjustDelay=30,e}();t.TimeRuler=e;var i=function(){return function(){this.bars=new Array(e.maxBars),this.bars.fill(new n,0,e.maxBars)}}();t.FrameLog=i;var n=function(){return function(){this.markers=new Array(e.maxSamples),this.markCount=0,this.markerNests=new Array(e.maxNestCall),this.nestCount=0,this.markers.fill(new r,0,e.maxSamples),this.markerNests.fill(0,0,e.maxNestCall)}}();t.MarkerCollection=n;var r=function(){return function(){this.markerId=0,this.beginTime=0,this.endTime=0,this.color=0}}();t.Marker=r;var o=function(){return function(t){this.logs=new Array(e.maxBars),this.name=t,this.logs.fill(new s,0,e.maxBars)}}();t.MarkerInfo=o;var s=function(){return function(){this.snapMin=0,this.snapMax=0,this.snapAvg=0,this.min=0,this.max=0,this.avg=0,this.samples=0,this.color=0,this.initialized=!1}}();t.MarkerLog=s}(es||(es={}));