Files
esengine/source/bin/framework.min.js
2021-07-02 18:25:30 +08:00

1 line
216 KiB
JavaScript

window.es={};var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))(function(r,o){function s(t){try{h(n.next(t))}catch(t){o(t)}}function a(t){try{h(n.throw(t))}catch(t){o(t)}}function h(t){t.done?r(t.value):new i(function(e){e(t.value)}).then(s,a)}h((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])}}},__read=this&&this.__read||function(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var n,r,o=i.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(n=o.next()).done;)s.push(n.value)}catch(t){r={error:t}}finally{try{n&&!n.done&&(i=o.return)&&i.call(o)}finally{if(r)throw r.error}}return s},__spread=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(__read(arguments[e]));return t};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 __values=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],i=0;return e?e.call(t):{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}}},transform;!function(t){var e=function(){function e(i,n){void 0===i&&(i=!0),void 0===n&&(n=!0),this._globalManagers=[],this._coroutineManager=new t.CoroutineManager,this._timerManager=new t.TimerManager,this._frameCounterElapsedTime=0,this._frameCounter=0,this._totalMemory=0,e._instance=this,e.emitter=new t.Emitter,e.emitter.addObserver(t.CoreEvents.frameUpdated,this.update,this),e.registerGlobalManager(this._coroutineManager),e.registerGlobalManager(this._timerManager),e.entitySystemsEnabled=n,this.debug=i,this.initialize()}return Object.defineProperty(e,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(e,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(e){t.Insist.isNotNull(e,"场景不能为空"),null==this._instance._scene?(this._instance._scene=e,this._instance.onSceneChanged(),this._instance._scene.begin()):this._instance._nextScene=e},enumerable:!0,configurable:!0}),e.create=function(e){return void 0===e&&(e=!0),null==this._instance&&(this._instance=new t.Core(e)),this._instance},e.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},e.unregisterGlobalManager=function(e){new t.List(this._instance._globalManagers).remove(e),e.enabled=!1},e.getGlobalManager=function(t){for(var i=0,n=e._instance._globalManagers.length;i<n;++i){var r=e._instance._globalManagers[i];if(r instanceof t)return r}return null},e.startCoroutine=function(t){return this._instance._coroutineManager.startCoroutine(t)},e.schedule=function(t,e,i,n){return void 0===e&&(e=!1),void 0===i&&(i=null),this._instance._timerManager.schedule(t,e,i,n)},e.prototype.startDebugDraw=function(){if(this.debug&&(this._frameCounter++,this._frameCounterElapsedTime+=t.Time.deltaTime,this._frameCounterElapsedTime>=1)){var e=window.performance.memory;null!=e&&(this._totalMemory=Number((e.totalJSHeapSize/1048576).toFixed(2))),this._titleMemory&&this._titleMemory(this._totalMemory,this._frameCounter),this._frameCounter=0,this._frameCounterElapsedTime-=1}},e.prototype.onSceneChanged=function(){t.Time.sceneChanged()},e.prototype.initialize=function(){},e.prototype.update=function(i){return void 0===i&&(i=-1),__awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(r){if(e.paused)return[2];if(t.Time.update(i),null!=this._scene){for(n=this._globalManagers.length-1;n>=0;n--)this._globalManagers[n].enabled&&this._globalManagers[n].update();this._scene.update(),null!=this._nextScene&&(this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),this._scene.begin())}return this.startDebugDraw(),[2]})})},e.paused=!1,e.debugRenderEndabled=!1,e}();t.Core=e}(es||(es={})),function(t){var e;!function(t){t[t.error=0]="error",t[t.warn=1]="warn",t[t.log=2]="log",t[t.info=3]="info",t[t.trace=4]="trace"}(e=t.LogType||(t.LogType={}));var i=function(){function t(){}return t.warnIf=function(t,i){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];t&&this.log(e.warn,i,n)},t.warn=function(t){for(var i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];this.log(e.warn,t,i)},t.error=function(t){for(var i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];this.log(e.error,t,i)},t.log=function(t,i){for(var n=[],r=2;r<arguments.length;r++)n[r-2]=arguments[r];switch(t){case e.error:console.error(t+": "+StringUtils.format(i,n));break;case e.warn:console.warn(t+": "+StringUtils.format(i,n));break;case e.log:console.log(t+": "+StringUtils.format(i,n));break;case e.info:console.info(t+": "+StringUtils.format(i,n));break;case e.trace:console.trace(t+": "+StringUtils.format(i,n));break;default:throw new Error("argument out of range")}},t}();t.Debug=i}(es||(es={})),function(t){var e=function(){function t(){}return t.debugText=16777215,t.colliderBounds=5033164.5,t.colliderEdge=9109504,t.colliderPosition=16776960,t.colliderCenter=16711680,t.renderableBounds=16776960,t.renderableCenter=10040012,t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefault=e}(es||(es={})),function(t){var e=function(){function t(){}return t.fail=function(t){void 0===t&&(t=null);for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];null==t?console.assert(!1):console.assert(!1,StringUtils.format(t,e))},t.isTrue=function(t,e){void 0===e&&(e=null);for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n];t||(null==e?this.fail():this.fail(e,i))},t.isFalse=function(t,e){void 0===e&&(e=null);for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n];null==e?this.isTrue(!t):this.isTrue(!t,e,i)},t.isNull=function(t,e){void 0===e&&(e=null);for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n];null==e?this.isTrue(null==t):this.isTrue(null==t,e,i)},t.isNotNull=function(t,e){void 0===e&&(e=null);for(var i=[],n=2;n<arguments.length;n++)i[n-2]=arguments[n];null==e?this.isTrue(null!=t):this.isTrue(null!=t,e,i)},t.areEqual=function(t,e,i){for(var n=[],r=3;r<arguments.length;r++)n[r-3]=arguments[r];t!=e&&this.fail(i,n)},t.areNotEqual=function(t,e,i){for(var n=[],r=3;r<arguments.length;r++)n[r-3]=arguments[r];t==e&&this.fail(i,n)},t}();t.Insist=e}(es||(es={})),function(t){var e=function(){function t(){this._enabled=!0,this._updateOrder=0,this.id=t._idGenerator++}return Object.defineProperty(t.prototype,"transform",{get:function(){return this.entity.transform},enumerable:!0,configurable:!0}),Object.defineProperty(t.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(t.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),t.prototype.initialize=function(){},t.prototype.onAddedToEntity=function(){},t.prototype.onRemovedFromEntity=function(){},t.prototype.onEntityTransformChanged=function(t){},t.prototype.debugRender=function(t){},t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},t.prototype.setUpdateOrder=function(t){return this._updateOrder!=t&&(this._updateOrder=t),this},t._idGenerator=0,t}();t.Component=e}(es||(es={})),function(t){var e=function(){function e(t,i){this.index_=0,this.index_=void 0!==i?e.INDEX++:i,this.type_=t}return e.prototype.getName=function(){return t.getClassName(this.type_)},e.prototype.getIndex=function(){return this.index_},e.prototype.toString=function(){return"ComponentType["+t.getClassName(e)+"] ("+this.index_+")"},e.INDEX=0,e}();t.ComponentType=e}(es||(es={})),function(t){!function(t){t[t.sceneChanged=0]="sceneChanged",t[t.frameUpdated=1]="frameUpdated",t[t.renderChanged=2]="renderChanged"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){var i=t.updateOrder-e.updateOrder;return 0==i&&(i=t.id-e.id),i},t}();t.EntityComparer=e;var i=function(){function i(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.componentBits=new t.Bits,this.name=e,this.id=i}return Object.defineProperty(i.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),i.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},i.prototype.setParent=function(e){return e instanceof t.Transform?this.transform.setParent(e):e instanceof i&&this.transform.setParent(e.transform),this},i.prototype.setPosition=function(t,e){return this.transform.setPosition(t,e),this},i.prototype.setLocalPosition=function(t){return this.transform.setLocalPosition(t),this},i.prototype.setRotation=function(t){return this.transform.setRotation(t),this},i.prototype.setRotationDegrees=function(t){return this.transform.setRotationDegrees(t),this},i.prototype.setLocalRotation=function(t){return this.transform.setLocalRotation(t),this},i.prototype.setLocalRotationDegrees=function(t){return this.transform.setLocalRotationDegrees(t),this},i.prototype.setScale=function(e){return e instanceof t.Vector2?this.transform.setScale(e):this.transform.setScale(new t.Vector2(e,e)),this},i.prototype.setLocalScale=function(e){return e instanceof t.Vector2?this.transform.setLocalScale(e):this.transform.setLocalScale(new t.Vector2(e,e)),this},i.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},i.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},i.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},i.prototype.destroy=function(){this._isDestroyed=!0,this.scene.identifierPool.checkIn(this.id),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()}},i.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()},i.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)},i.prototype.onAddedToScene=function(){},i.prototype.onRemovedFromScene=function(){this._isDestroyed&&this.components.removeAllComponents()},i.prototype.update=function(){this.components.update()},i.prototype.debugRender=function(t){t&&this.components.debugRender(t)},i.prototype.createComponent=function(t){var e=new t;return this.addComponent(e),e},i.prototype.addComponent=function(t){return t.entity=this,this.components.add(t),t.initialize(),t},i.prototype.getComponent=function(t){return this.components.getComponent(t,!1)},i.prototype.getComponentInScene=function(t){return this.components.getComponent(t,!0)},i.prototype.tryGetComponent=function(t,e){return e.value=this.components.getComponent(t,!1),null!=e.value},i.prototype.hasComponent=function(t){return null!=this.components.getComponent(t,!1)},i.prototype.getOrCreateComponent=function(t){var e=this.components.getComponent(t,!0);return e||(e=this.addComponent(new t)),e},i.prototype.getComponents=function(t,e){return this.components.getComponents(t,e)},i.prototype.removeComponent=function(t){this.components.remove(t)},i.prototype.removeComponentForType=function(t){var e=this.getComponent(t);return!!e&&(this.removeComponent(e),!0)},i.prototype.removeAllComponents=function(){for(var t=0;t<this.components.count;t++)this.removeComponent(this.components.buffer[t])},i.prototype.compareTo=function(t){var e=this._updateOrder-t._updateOrder;return 0==e&&(e=this.id-t.id),e},i.prototype.equals=function(t){return 0==this.compareTo(t)},i.prototype.getHashCode=function(){return this.id},i.prototype.toString=function(){return"[Entity: name: "+this.name+", tag: "+this.tag+", enabled: "+this.enabled+", depth: "+this.updateOrder+"]"},i.entityComparer=new e,i}();t.Entity=i}(es||(es={})),function(t){var e=function(){function e(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=0,this.y=0,this.x=t,this.y=e}return Object.defineProperty(e,"zero",{get:function(){return new e(0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"one",{get:function(){return new e(1,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitX",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"unitY",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"up",{get:function(){return new e(0,-1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"down",{get:function(){return new e(0,1)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"left",{get:function(){return new e(-1,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"right",{get:function(){return new e(1,0)},enumerable:!0,configurable:!0}),e.add=function(t,i){var n=e.zero;return n.x=t.x+i.x,n.y=t.y+i.y,n},e.divide=function(t,i){var n=e.zero;return n.x=t.x/i.x,n.y=t.y/i.y,n},e.divideScaler=function(t,i){var n=e.zero;return n.x=t.x/i,n.y=t.y/i,n},e.sqrDistance=function(t,e){return Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)},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.lerpPrecise=function(i,n,r){return new e(t.MathHelper.lerpPrecise(i.x,n.x,r),t.MathHelper.lerpPrecise(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.transformNormal=function(t,i){return new e(t.x*i.m11+t.y*i.m21,t.x*i.m12+t.y*i.m22)},e.distance=function(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))},e.angle=function(e,i){return e=e.normalize(),i=i.normalize(),Math.acos(t.MathHelper.clamp(e.dot(i),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){return t.x=-t.x,t.y=-t.y,t},e.reflect=function(e,i){var n=t.Vector2.zero,r=2*(e.x*i.x+e.y*i.y);return n.x=e.x-i.x*r,n.y=e.y-i.y*r,n},e.smoothStep=function(i,n,r){return new e(t.MathHelper.smoothStep(i.x,n.x,r),t.MathHelper.smoothStep(i.y,n.y,r))},e.prototype.setTo=function(t,e){this.x=t,this.y=e},e.prototype.negate=function(){return this.scale(-1)},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.addEqual=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return new e(this.x/t.x,this.y/t.y)},e.prototype.divideScaler=function(t){return new e(this.x/t,this.y/t)},e.prototype.multiply=function(t){return new e(t.x*this.x,t.y*this.y)},e.prototype.multiplyScaler=function(t){return this.x*=t,this.y*=t,this},e.prototype.sub=function(t){return new e(this.x-t.x,this.y-t.y)},e.prototype.subEqual=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.dot=function(t){return this.x*t.x+this.y*t.y},e.prototype.scale=function(t){return new e(this.x*t,this.y*t)},e.prototype.scaleEqual=function(t){return this.x*=t,this.y*=t,this},e.prototype.transform=function(t){return new e(this.x*t.m11+this.y*t.m21+t.m31,this.x*t.m12+this.y*t.m22+t.m32)},e.prototype.normalize=function(){var t=this.distance();return t>0?new e(this.x/t,this.y/t):new e(0,1)},e.prototype.normalizeEqual=function(){var t=this.distance();return t>0?(this.setTo(this.x/t,this.y/t),this):(this.setTo(0,1),this)},e.prototype.magnitude=function(){return this.distance()},e.prototype.distance=function(t){return t||(t=e.zero),Math.sqrt(Math.pow(this.x-t.x,2)+Math.pow(this.y-t.y,2))},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.angleBetween=function(e,i){var n=e.sub(this),r=i.sub(this);return t.Vector2Ext.angle(n,r)},e.prototype.equals=function(t,e){return void 0===e&&(e=.001),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e},e.prototype.isValid=function(){return t.MathHelper.isValid(this.x)&&t.MathHelper.isValid(this.y)},e.min=function(t,i){return new e(t.x<i.x?t.x:i.x,t.y<i.y?t.y:i.y)},e.max=function(t,i){return new e(t.x>i.x?t.x:i.x,t.y>i.y?t.y:i.y)},e.hermite=function(i,n,r,o,s){return new e(t.MathHelper.hermite(i.x,n.x,r.x,o.x,s),t.MathHelper.hermite(i.y,n.y,r.y,o.y,s))},e.unsignedAngle=function(e,i,n){void 0===n&&(n=!0),e.normalizeEqual(),i.normalizeEqual();var r=Math.acos(t.MathHelper.clamp(e.dot(i),-1,1))*t.MathHelper.Rad2Deg;return n?Math.round(r):r},e.prototype.clone=function(){return new e(this.x,this.y)},e}();t.Vector2=e}(es||(es={})),function(t){var e=function(){function e(){this._sceneComponents=[],this._renderers=[],this.entities=new t.EntityList(this),this.renderableComponents=new t.RenderableComponentList,this.entityProcessors=new t.EntityProcessorList,this.identifierPool=new t.IdentifierPool,this.initialize()}return e.prototype.initialize=function(){},e.prototype.onStart=function(){},e.prototype.unload=function(){},e.prototype.begin=function(){0==this._renderers.length&&this.addRenderer(new t.DefaultRenderer),t.Physics.reset(),null!=this.entityProcessors&&this.entityProcessors.begin(),this._didSceneBegin=!0,this.onStart()},e.prototype.end=function(){this._didSceneBegin=!1;for(var e=0;e<this._renderers.length;e++)this._renderers[e].unload();this.entities.removeAllEntities();for(e=0;e<this._sceneComponents.length;e++)this._sceneComponents[e].onRemovedFromScene();this._sceneComponents.length=0,this.camera=null,t.Physics.clear(),this.entityProcessors&&this.entityProcessors.end(),this.unload()},e.prototype.update=function(){this.entities.updateLists();for(var t=this._sceneComponents.length-1;t>=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();null!=this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),null!=this.entityProcessors&&this.entityProcessors.lateUpdate(),this.renderableComponents.updateLists(),this.render()},e.prototype.render=function(){for(var t=0;t<this._renderers.length;t++)this._renderers[t].render(this)},e.prototype.addRenderer=function(t){return this._renderers.push(t),this._renderers.sort(function(t,e){return t.renderOrder-e.renderOrder}),t.onAddedToScene(this),t},e.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},e.prototype.removeRenderer=function(e){new t.List(this._renderers).remove(e),e.unload()},e.prototype.addSceneComponent=function(t){return t.scene=this,t.onEnabled(),this._sceneComponents.push(t),this._sceneComponents.sort(t.compare),t},e.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},e.prototype.getOrCreateSceneComponent=function(t){var e=this.getSceneComponent(t);return null==e&&(e=this.addSceneComponent(new t)),e},e.prototype.removeSceneComponent=function(e){var i=new t.List(this._sceneComponents);t.Insist.isTrue(i.contains(e),"SceneComponent"+e+"不在SceneComponents列表中!"),i.remove(e),e.onRemovedFromScene()},e.prototype.createEntity=function(e){var i=new t.Entity(e,this.identifierPool.checkOut());return this.addEntity(i)},e.prototype.addEntity=function(e){t.Insist.isFalse(new t.List(this.entities.buffer).contains(e),"您试图将同一实体添加到场景两次: "+e),this.entities.add(e),e.scene=this;for(var i=0;i<e.transform.childCount;i++)this.addEntity(e.transform.getChild(i).entity);return e},e.prototype.destroyAllEntities=function(){for(var t=0;t<this.entities.count;t++)this.entities.buffer[t].destroy()},e.prototype.findEntity=function(t){return this.entities.findEntity(t)},e.prototype.findEntityById=function(t){return this.entities.findEntityById(t)},e.prototype.findEntitiesWithTag=function(t){return this.entities.entitiesWithTag(t)},e.prototype.findEntityWithTag=function(t){return this.entities.entityWithTag(t)},e.prototype.findComponentOfType=function(t){return this.entities.findComponentOfType(t)},e.prototype.findComponentsOfType=function(t){return this.entities.findComponentsOfType(t)},e.prototype.findEntitiesOfComponent=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return(t=this.entities).findEntitesOfComponent.apply(t,__spread(e))},e.prototype.addEntityProcessor=function(t){return t.scene=this,this.entityProcessors.add(t),t},e.prototype.removeEntityProcessor=function(t){this.entityProcessors.remove(t)},e.prototype.getEntityProcessor=function(t){return this.entityProcessors.getProcessor(t)},e}();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;!function(t){t[t.clean=0]="clean",t[t.positionDirty=1]="positionDirty",t[t.scaleDirty=2]="scaleDirty",t[t.rotationDirty=4]="rotationDirty"}(e=t.DirtyType||(t.DirtyType={}));var i=function(){function i(e){this._localTransform=t.Matrix2D.identity,this._worldTransform=t.Matrix2D.identity,this._rotationMatrix=t.Matrix2D.identity,this._translationMatrix=t.Matrix2D.identity,this._children=[],this._worldToLocalTransform=t.Matrix2D.identity,this._worldInverseTransform=t.Matrix2D.identity,this._position=t.Vector2.zero,this._scale=t.Vector2.one,this._rotation=0,this._localPosition=t.Vector2.zero,this._localScale=t.Vector2.one,this._localRotation=0,this.entity=e,this.scale=this._localScale=t.Vector2.one}return Object.defineProperty(i.prototype,"childCount",{get:function(){return this._children.length},enumerable:!0,configurable:!0}),Object.defineProperty(i.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(i.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(i.prototype,"localToWorldTransform",{get:function(){return this.updateTransform(),this._worldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},set:function(t){this.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"worldToLocalTransform",{get:function(){return this._worldToLocalDirty&&(null==this.parent?this._worldToLocalTransform=t.Matrix2D.identity:(this.parent.updateTransform(),this._worldToLocalTransform=t.Matrix2D.invert(this.parent._worldTransform)),this._worldToLocalDirty=!1),this._worldToLocalTransform},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"worldInverseTransform",{get:function(){return this.updateTransform(),this._worldInverseDirty&&(this._worldInverseTransform=t.Matrix2D.invert(this._worldTransform),this._worldInverseDirty=!1),this._worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this.updateTransform(),this._positionDirty&&(null==this.parent?this._position=this._localPosition:(this.parent.updateTransform(),t.Vector2Ext.transformR(this._localPosition,this.parent._worldTransform,this._position)),this._positionDirty=!1),this._position},set:function(t){this.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scale",{get:function(){return this.updateTransform(),this._scale},set:function(t){this.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this.updateTransform(),this._rotation},set:function(t){this.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localPosition",{get:function(){return this.updateTransform(),this._localPosition},set:function(t){this.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localScale",{get:function(){return this.updateTransform(),this._localScale},set:function(t){this.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localRotation",{get:function(){return this.updateTransform(),this._localRotation},set:function(t){this.setLocalRotation(t)},enumerable:!0,configurable:!0}),i.prototype.getChild=function(t){return this._children[t]},i.prototype.setParent=function(t){var i=this;if(this._parent==t)return this;if(null!=this._parent){var n=this._parent._children.findIndex(function(t){return t==i});-1!=n&&this._parent._children.splice(n,1)}return null!=t&&t._children.push(this),this._parent=t,this.setDirty(e.positionDirty),this},i.prototype.setPosition=function(e,i){var n=new t.Vector2(e,i);return n.equals(this._position)?this:(this._position=n,null!=this.parent?this.localPosition=t.Vector2.transform(this._position,this.worldToLocalTransform):this.localPosition=n,this._positionDirty=!1,this)},i.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)},i.prototype.setRotation=function(t){return this._rotation=t,null!=this.parent?this.localRotation=this.parent.rotation+t:this.localRotation=t,this},i.prototype.setRotationDegrees=function(e){return this.setRotation(t.MathHelper.toRadians(e))},i.prototype.lookAt=function(e){var i=this.position.x>e.x?-1:1,n=this.position.sub(e).normalize();this.rotation=i*Math.acos(n.dot(t.Vector2.unitY))},i.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},i.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},i.prototype.setScale=function(e){return this._scale=e,null!=this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},i.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},i.prototype.roundPosition=function(){this.position=t.Vector2Ext.round(this._position)},i.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(null!=this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(t.Matrix2D.createTranslation(this._localPosition.x,this._localPosition.y,this._translationMatrix),this._localPositionDirty=!1),this._localRotationDirty&&(t.Matrix2D.createRotation(this._localRotation,this._rotationMatrix),this._localRotationDirty=!1),this._localScaleDirty&&(t.Matrix2D.createScale(this._localScale.x,this._localScale.y,this._scaleMatrix),this._localScaleDirty=!1),t.Matrix2D.multiply(this._scaleMatrix,this._rotationMatrix,this._localTransform),t.Matrix2D.multiply(this._localTransform,this._translationMatrix,this._localTransform),null==this.parent&&(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),null!=this.parent&&(t.Matrix2D.multiply(this._localTransform,this.parent._worldTransform,this._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=this.parent._scale.multiply(this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},i.prototype.setDirty=function(t){if(0==(this.hierarchyDirty&t)){switch(this.hierarchyDirty|=t,t){case e.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case e.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case e.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}for(var i=0;i<this._children.length;i++)this._children[i].setDirty(t)}},i.prototype.copyFrom=function(t){this._position=t.position.clone(),this._localPosition=t._localPosition.clone(),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)},i.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+"]"},i}();t.Transform=i}(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,t.isIUpdatable=function(t){return void 0!==t.update}}(es||(es={})),function(t){var e=function(){function t(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.onRemovedFromScene=function(){},t.prototype.update=function(){},t.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},t.prototype.setUpdateOrder=function(t){return this.updateOrder!=t&&(this.updateOrder=t),this},t.prototype.compare=function(t){return this.updateOrder-t.updateOrder},t}();t.SceneComponent=e}(es||(es={})),function(t){var e=function(e){function i(){var i=e.call(this)||this;return i.shouldUseGravity=!0,i.velocity=t.Vector2.zero,i._mass=10,i._elasticity=.5,i._friction=.5,i._glue=.01,i._inverseMass=0,i._inverseMass=1/i._mass,i}return __extends(i,e),Object.defineProperty(i.prototype,"mass",{get:function(){return this._mass},set:function(t){this.setMass(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"elasticity",{get:function(){return this._elasticity},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"elasticiy",{set:function(t){this.setElasticity(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"friction",{get:function(){return this._friction},set:function(t){this.setFriction(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"glue",{get:function(){return this._glue},set:function(t){this.setGlue(t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isImmovable",{get:function(){return this._mass<1e-4},enumerable:!0,configurable:!0}),i.prototype.setMass=function(e){return this._mass=t.MathHelper.clamp(e,0,Number.MAX_VALUE),this._mass>1e-4?this._inverseMass=1/this._mass:this._inverseMass=0,this},i.prototype.setElasticity=function(e){return this._elasticity=t.MathHelper.clamp01(e),this},i.prototype.setFriction=function(e){return this._friction=t.MathHelper.clamp01(e),this},i.prototype.setGlue=function(e){return this._glue=t.MathHelper.clamp(e,0,10),this},i.prototype.setVelocity=function(t){return this.velocity=t,this},i.prototype.addImpulse=function(e){this.isImmovable||this.velocity.addEqual(e.scale(this._inverseMass*(t.Time.deltaTime*t.Time.deltaTime)*1e5))},i.prototype.onAddedToEntity=function(){this._collider=null;for(var e=0;e<this.entity.components.buffer.length;e++){var i=this.entity.components.buffer[e];if(i instanceof t.Collider){this._collider=i;break}}t.Debug.warnIf(null==this._collider,"ArcadeRigidbody 没有 Collider。ArcadeRigidbody需要一个Collider!")},i.prototype.update=function(){var e,n;if(this.isImmovable||null==this._collider)this.velocity=t.Vector2.zero;else{this.shouldUseGravity&&this.velocity.addEqual(t.Physics.gravity.scale(t.Time.deltaTime)),this.entity.position=this.entity.position.add(this.velocity.scale(t.Time.deltaTime));var r=new t.CollisionResult,o=t.Physics.boxcastBroadphaseExcludingSelf(this._collider,this._collider.bounds,this._collider.collidesWithLayers.value);try{for(var s=__values(o),a=s.next();!a.done;a=s.next()){var h=a.value;if(h&&(!h.entity.equals(this.entity)&&this._collider.collidesWithNonMotion(h,r))){var c=h.entity.getComponent(i);if(null!=c)this.processOverlap(c,r.minimumTranslationVector),this.processCollision(c,r.minimumTranslationVector);else{this.entity.position=this.entity.position.sub(r.minimumTranslationVector);var l=this.calculateResponseVelocity(this.velocity,r.minimumTranslationVector);this.velocity.addEqual(l)}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(e)throw e.error}}}},i.prototype.processOverlap=function(t,e){this.isImmovable?t.entity.position=t.entity.position.add(e):t.isImmovable?this.entity.position=this.entity.position.sub(e):(this.entity.position=this.entity.position.sub(e.scale(.5)),t.entity.position=t.entity.position.add(e.scale(.5)))},i.prototype.processCollision=function(t,e){var i=this.velocity.sub(t.velocity);i=this.calculateResponseVelocity(i,e);var n=this._inverseMass+t._inverseMass,r=this._inverseMass/n,o=t._inverseMass/n;this.velocity=this.velocity.add(i.scale(r)),t.velocity=t.velocity.sub(i.scale(o))},i.prototype.calculateResponseVelocity=function(e,i){var n=i.scale(-1).normalize(),r=e.dot(n),o=n.scale(r),s=e.sub(o);r>0&&(o=t.Vector2.zero);var a=this._friction;return s.lengthSquared()<this._glue&&(a=1.01),o.scale(1+this._elasticity).sub(s.scale(a)).scale(-1)},i}(t.Component);t.ArcadeRigidbody=e}(es||(es={})),function(t){var e=function(){return function(){this.topLeft=t.Vector2.zero,this.bottomRight=t.Vector2.zero,this.bottomLeft=t.Vector2.zero}}(),i=function(){function t(){this.right=!1,this.left=!1,this.above=!1,this.below=!1,this.becameGroundedThisFrame=!1,this.wasGroundedLastFrame=!1,this.movingDownSlope=!1,this.slopeAngle=0}return t.prototype.hasCollision=function(){return this.below||this.right||this.left||this.above},t.prototype.reset=function(){this.right=this.left=!1,this.above=this.below=!1,this.becameGroundedThisFrame=this.movingDownSlope=!1,this.slopeAngle=0},t.prototype.toString=function(){return"[CharacterCollisionState2D] r: "+this.right+", l: "+this.left+", a: "+this.above+", b: "+this.below+", movingDownSlope: "+this.movingDownSlope+", angle: "+this.slopeAngle+", wasGroundedLastFrame: "+this.wasGroundedLastFrame+", becameGroundedThisFrame: "+this.becameGroundedThisFrame},t}(),n=function(){function n(n,r,o,s,a){void 0===o&&(o=-1),void 0===s&&(s=-1),void 0===a&&(a=-1),this.ignoredColliders=new Set,this.slopeLimit=30,this.jumpingThreshold=-7,this.totalHorizontalRays=5,this.totalVerticalRays=3,this.collisionState=new i,this.velocity=new t.Vector2(0,0),this._skinWidth=.02,this.kSkinWidthFloatFudgeFactor=.001,this._raycastOrigins=new e,this._raycastHit=new t.RaycastHit,this._isGoingUpSlope=!1,this._isWarpingToGround=!0,this.platformMask=-1,this.triggerMask=-1,this.oneWayPlatformMask=-1,this.rayOriginSkinMutiplier=4,this.onTriggerEnterEvent=new t.ObservableT,this.onTriggerExitEvent=new t.ObservableT,this.onControllerCollidedEvent=new t.ObservableT,this.platformMask=o,this.oneWayPlatformMask=s,this.triggerMask=a,this.platformMask|=this.oneWayPlatformMask,this._player=n;for(var h=null,c=0;c<this._player.components.buffer.length;c++){var l=this._player.components.buffer[c];if(l instanceof t.Collider){h=l;break}}if(h.isTrigger=!1,!(h instanceof t.BoxCollider))throw new Error("player collider must be box");this._collider=h,this.skinWidth=r||.05*h.width,this._slopeLimitTangent=Math.tan(75*t.MathHelper.Deg2Rad),this._triggerHelper=new t.ColliderTriggerHelper(this._player);for(c=0;c<32;c++)0==(this.triggerMask&1<<c)&&t.Flags.unsetFlag(this._collider.collidesWithLayers,c)}return Object.defineProperty(n.prototype,"skinWidth",{get:function(){return this._skinWidth},set:function(t){this._skinWidth=t,this.recalculateDistanceBetweenRays()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isGrounded",{get:function(){return this.collisionState.below},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"raycastHitsThisFrame",{get:function(){return this._raycastHitsThisFrame},enumerable:!0,configurable:!0}),n.prototype.onTriggerEnter=function(t,e){this.onTriggerEnterEvent.notify(t)},n.prototype.onTriggerExit=function(t,e){this.onTriggerExitEvent.notify(t)},n.prototype.move=function(t,e){this.collisionState.wasGroundedLastFrame=this.collisionState.below,this.collisionState.reset(),this._raycastHitsThisFrame=[],this._isGoingUpSlope=!1,this.primeRaycastOrigins(),t.y>0&&this.collisionState.wasGroundedLastFrame&&(t=this.handleVerticalSlope(t)),0!==t.x&&(t=this.moveHorizontally(t)),0!==t.y&&(t=this.moveVertically(t)),this._player.setPosition(this._player.position.x+t.x,this._player.position.y+t.y),e>0&&(this.velocity.x=t.x/e,this.velocity.y=t.y/e),!this.collisionState.wasGroundedLastFrame&&this.collisionState.below&&(this.collisionState.becameGroundedThisFrame=!0),this._isGoingUpSlope&&(this.velocity.y=0),this._isWarpingToGround||this._triggerHelper.update();for(var i=0;i<this._raycastHitsThisFrame.length;i++)this.onControllerCollidedEvent.notify(this._raycastHitsThisFrame[i]);this.ignoreOneWayPlatformsTime>0&&(this.ignoreOneWayPlatformsTime-=e)},n.prototype.warpToGrounded=function(e){void 0===e&&(e=1e3),this.ignoreOneWayPlatformsTime=0,this._isWarpingToGround=!0;var i=0;do{if(i+=1,this.move(new t.Vector2(0,1),.02),i>e)break}while(!this.isGrounded);this._isWarpingToGround=!1},n.prototype.recalculateDistanceBetweenRays=function(){var t=this._collider.height*Math.abs(this._player.scale.y)-2*this._skinWidth;this._verticalDistanceBetweenRays=t/(this.totalHorizontalRays-1);var e=this._collider.width*Math.abs(this._player.scale.x)-2*this._skinWidth;this._horizontalDistanceBetweenRays=e/(this.totalVerticalRays-1)},n.prototype.primeRaycastOrigins=function(){var e=this._collider.bounds;this._raycastOrigins.topLeft=new t.Vector2(e.x+this._skinWidth,e.y+this._skinWidth),this._raycastOrigins.bottomRight=new t.Vector2(e.right-this._skinWidth,e.bottom-this._skinWidth),this._raycastOrigins.bottomLeft=new t.Vector2(e.x+this._skinWidth,e.bottom-this._skinWidth)},n.prototype.moveHorizontally=function(e){for(var i=e.x>0,n=Math.abs(e.x)+this._skinWidth*this.rayOriginSkinMutiplier,r=i?t.Vector2.right:t.Vector2.left,o=this._raycastOrigins.bottomLeft.y,s=i?this._raycastOrigins.bottomRight.x-this._skinWidth*(this.rayOriginSkinMutiplier-1):this._raycastOrigins.bottomLeft.x+this._skinWidth*(this.rayOriginSkinMutiplier-1),a=0;a<this.totalHorizontalRays;a++){var h=new t.Vector2(s,o-a*this._verticalDistanceBetweenRays);if(0===a&&this.supportSlopedOneWayPlatforms&&this.collisionState.wasGroundedLastFrame?this._raycastHit=t.Physics.linecast(h,h.add(r.scaleEqual(n)),this.platformMask,this.ignoredColliders):this._raycastHit=t.Physics.linecast(h,h.add(r.scaleEqual(n)),this.platformMask&~this.oneWayPlatformMask,this.ignoredColliders),this._raycastHit.collider){if(0===a&&this.handleHorizontalSlope(e,t.Vector2.unsignedAngle(this._raycastHit.normal,t.Vector2.up))){this._raycastHitsThisFrame.push(this._raycastHit);break}if(e.x=this._raycastHit.point.x-h.x,n=Math.abs(e.x),i?(e.x-=this._skinWidth*this.rayOriginSkinMutiplier,this.collisionState.right=!0):(e.x+=this._skinWidth*this.rayOriginSkinMutiplier,this.collisionState.left=!0),this._raycastHitsThisFrame.push(this._raycastHit),n<this._skinWidth*this.rayOriginSkinMutiplier+this.kSkinWidthFloatFudgeFactor)break}}return e},n.prototype.moveVertically=function(e){var i=e.y<0,n=Math.abs(e.y)+this._skinWidth*this.rayOriginSkinMutiplier,r=i?t.Vector2.up:t.Vector2.down,o=this._raycastOrigins.topLeft.x,s=i?this._raycastOrigins.topLeft.y+this._skinWidth*(this.rayOriginSkinMutiplier-1):this._raycastOrigins.bottomLeft.y-this._skinWidth*(this.rayOriginSkinMutiplier-1);o+=e.x;var a=this.platformMask;(i||this.ignoreOneWayPlatformsTime>0)&&(a&=~this.oneWayPlatformMask);for(var h=0;h<this.totalVerticalRays;h++){var c=new t.Vector2(o+h*this._horizontalDistanceBetweenRays,s);if(this._raycastHit=t.Physics.linecast(c,c.add(r.scaleEqual(n)),a,this.ignoredColliders),this._raycastHit.collider&&(e.y=this._raycastHit.point.y-c.y,n=Math.abs(e.y),i?(e.y+=this._skinWidth*this.rayOriginSkinMutiplier,this.collisionState.above=!0):(e.y-=this._skinWidth*this.rayOriginSkinMutiplier,this.collisionState.below=!0),this._raycastHitsThisFrame.push(this._raycastHit),!i&&e.y<-1e-5&&(this._isGoingUpSlope=!0),n<this._skinWidth*this.rayOriginSkinMutiplier+this.kSkinWidthFloatFudgeFactor))break}return e},n.prototype.handleVerticalSlope=function(e){var i=.5*(this._raycastOrigins.bottomLeft.x+this._raycastOrigins.bottomRight.x),n=t.Vector2.down,r=this._slopeLimitTangent*(this._raycastOrigins.bottomRight.x-i),o=new t.Vector2(i,this._raycastOrigins.bottomLeft.y);if(this._raycastHit=t.Physics.linecast(o,o.add(n.scaleEqual(r)),this.platformMask,this.ignoredColliders),this._raycastHit.collider){var s=t.Vector2.unsignedAngle(this._raycastHit.normal,t.Vector2.up);if(0===s)return e;if(Math.sign(this._raycastHit.normal.x)===Math.sign(e.x)){var a=this.slopeSpeedMultiplier?this.slopeSpeedMultiplier.lerp(-s):1;e.y+=this._raycastHit.point.y-o.y-this.skinWidth,e.x*=a,this.collisionState.movingDownSlope=!0,this.collisionState.slopeAngle=s}}return e},n.prototype.handleHorizontalSlope=function(e,i){if(90===Math.round(i))return!1;if(i<this.slopeLimit){if(e.y>this.jumpingThreshold){var n=this.slopeSpeedMultiplier?this.slopeSpeedMultiplier.lerp(i):1;e.x*=n,e.y=Math.abs(Math.tan(i*t.MathHelper.Deg2Rad)*e.x);var r=e.x>0,o=r?this._raycastOrigins.bottomRight:this._raycastOrigins.bottomLeft,s=null;(s=this.supportSlopedOneWayPlatforms&&this.collisionState.wasGroundedLastFrame?t.Physics.linecast(o,o.add(e),this.platformMask,this.ignoredColliders):t.Physics.linecast(o,o.add(e),this.platformMask&~this.oneWayPlatformMask,this.ignoredColliders)).collider&&(e.x=s.point.x-o.x,e.y=s.point.y-o.y,r?e.x-=this._skinWidth:e.x+=this._skinWidth),this._isGoingUpSlope=!0,this.collisionState.below=!0}}else e.x=0;return!0},n}();t.CharacterController=n}(es||(es={})),function(t){var e=function(){function e(){}return e.getITriggerListener=function(e,i){var n,r;try{for(var o=__values(e.components._components),s=o.next();!s.done;s=o.next()){var a=s.value;t.isITriggerListener(a)&&i.push(a)}}catch(t){n={error:t}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}for(var h in e.components._componentsToAdd){a=e.components._componentsToAdd[h];t.isITriggerListener(a)&&i.push(a)}return i},e}();t.TriggerListenerHelper=e,t.isITriggerListener=function(t){return void 0!==t.onTriggerEnter}}(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){for(var n,r,o=null,s=0;s<this.entity.components.buffer.length;s++){if((h=this.entity.components.buffer[s])instanceof t.Collider){o=h;break}}if(null==o||null==this._triggerHelper)return!1;var a=[];for(s=0;s<this.entity.components.buffer.length;s++){var h;(h=this.entity.components.buffer[s])instanceof t.Collider&&a.push(h)}for(s=0;s<a.length;s++){var c=a[s];if(!c.isTrigger){var l=c.bounds.clone();l.x+=e.x,l.y+=e.y;var u=t.Physics.boxcastBroadphaseExcludingSelf(c,l,c.collidesWithLayers.value);try{for(var p=__values(u),f=p.next();!f.done;f=p.next()){var d=f.value;if(d.isTrigger)return;var m=new t.CollisionResult;c.collidesWith(d,e,m)&&(e.sub(m.minimumTranslationVector),null!=m.collider&&(i.collider=m.collider,i.minimumTranslationVector=m.minimumTranslationVector,i.normal=m.normal,i.point=m.point))}}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=p.return)&&r.call(p)}finally{if(n)throw n.error}}}}return t.ListPool.free(a),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(){for(var e=null,i=0;i<this.entity.components.buffer.length;i++){var n=this.entity.components.buffer[i];if(n instanceof t.Collider){e=n;break}}this._collider=e,t.Debug.warnIf(null==this._collider,"ProjectileMover没有Collider。ProjectilMover需要一个Collider!")},i.prototype.move=function(e){var i,n;if(null==this._collider)return!1;var r=!1;this.entity.position=t.Vector2.add(this.entity.position,e);var o=t.Physics.boxcastBroadphase(this._collider.bounds,this._collider.collidesWithLayers.value);try{for(var s=__values(o),a=s.next();!a.done;a=s.next()){var h=a.value;this._collider.overlaps(h)&&h.enabled&&(r=!0,this.notifyTriggerListeners(this._collider,h))}}catch(t){i={error:t}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return r},i.prototype.notifyTriggerListeners=function(e,i){t.TriggerListenerHelper.getITriggerListener(i.entity,this._tempTriggerList);for(var n=0;n<this._tempTriggerList.length;n++)this._tempTriggerList[n].onTriggerEnter(e,i);this._tempTriggerList.length=0,t.TriggerListenerHelper.getITriggerListener(this.entity,this._tempTriggerList);for(n=0;n<this._tempTriggerList.length;n++)this._tempTriggerList[n].onTriggerEnter(i,e);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.castSortOrder=0,i.isTrigger=!1,i.physicsLayer=new t.Ref(1),i.collidesWithLayers=new t.Ref(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&&null!=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.equals(t)||(this.unregisterColliderWithPhysicsSystem(),this._localOffset.setTo(t.x,t.y),this._localOffsetLength=this._localOffset.magnitude(),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){for(var e=null,i=0;i<this.entity.components.buffer.length;i++){var n=this.entity.components.buffer[i];if(n instanceof t.RenderableComponent){e=n;break}}if(null!=e){var r=e.bounds.clone(),o=r.width/this.entity.transform.scale.x,s=r.height/this.entity.transform.scale.y;this instanceof t.CircleCollider?(this.radius=.5*Math.max(o,s),this.localOffset=r.center.sub(this.entity.transform.position)):this instanceof t.BoxCollider&&(this.width=o,this.height=s,this.localOffset=r.center.sub(this.entity.transform.position))}}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(e,i,n){void 0===n&&(n=new t.CollisionResult);var r=this.entity.position;this.entity.position=this.entity.position.add(i);var o=this.shape.collidesWithShape(e.shape,n);return o&&(n.collider=e),this.entity.position=r,o},i.prototype.collidesWithNonMotion=function(e,i){return void 0===i&&(i=new t.CollisionResult),this.shape.collidesWithShape(e.shape,i)?(i.collider=e,!0):(i.collider=null,!1)},i.prototype.collidesWithAny=function(e,i){var n,r,o=this.bounds.clone();o.x+=e.x,o.y+=e.y;var s=t.Physics.boxcastBroadphaseExcludingSelf(this,o,this.collidesWithLayers.value),a=this.shape.position.clone();this.shape.position=t.Vector2.add(this.shape.position,e);var h=!1;try{for(var c=__values(s),l=c.next();!l.done;l=c.next()){var u=l.value;u.isTrigger||this.collidesWithNonMotion(u,i)&&(e=e.sub(i.minimumTranslationVector),this.shape.position=this.shape.position.sub(i.minimumTranslationVector),h=!0)}}catch(t){n={error:t}}finally{try{l&&!l.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}return this.shape.position=a.clone(),h},i.prototype.collidesWithAnyNonMotion=function(e){var i,n;void 0===e&&(e=new t.CollisionResult);var r=t.Physics.boxcastBroadphaseExcludingSelfNonRect(this,this.collidesWithLayers.value);try{for(var o=__values(r),s=o.next();!s.done;s=o.next()){var a=s.value;if(!a.isTrigger&&this.collidesWithNonMotion(a,e))return!0}}catch(t){i={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return!1},i.lateSortOrder=999,i}(t.Component);t.Collider=e}(es||(es={})),function(t){var e=function(e){function i(i,n,r,o){void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1),void 0===o&&(o=1);var s=e.call(this)||this;return 1==r&&1==o?s._colliderRequiresAutoSizing=!0:s._localOffset=new t.Vector2(i+r/2,n+o/2),s.shape=new t.Box(r,o),s}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.setSize=function(e,i){this._colliderRequiresAutoSizing=!1;var n=this.shape;return e==n.width&&i==n.height||(n.updateBox(e,i),this._isPositionDirty=!0,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._isPositionDirty=!0,null!=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._isPositionDirty=!0,this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this))},i.prototype.debugRender=function(e){var i=this.shape;e.drawHollowRect(this.bounds.x,this.bounds.y,this.bounds.width,this.bounds.height,new t.Color(76,76,76,76),2),e.end(),e.drawPolygon(this.shape.position,i.points,new t.Color(139,0,0,255),!0,2),e.end(),e.drawPixel(this.entity.position,new t.Color(255,255,0),4),e.end(),e.drawPixel(t.Vector2.add(this.transform.position,this.shape.center),new t.Color(255,0,0),2),e.end()},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){void 0===i&&(i=1);var n=e.call(this)||this;return n.shape=new t.Circle(i),1==i&&(n._colliderRequiresAutoSizing=!0),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._isPositionDirty=!0,null!=this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},i.prototype.debugRender=function(e){e.drawHollowRect(this.bounds.x,this.bounds.y,this.bounds.width,this.bounds.height,new t.Color(76,76,76,76),2),e.end(),e.drawCircle(this.shape.position,this.radius,new t.Color(139,0,0),2),e.end(),e.drawPixel(this.entity.transform.position,new t.Color(255,255,0),4),e.end(),e.drawPixel(this.shape.position,new t.Color(255,0,0),2),e.end()},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=i.slice(0,i.length-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(e){function i(){var i=null!==e&&e.apply(this,arguments)||this;return i._bounds=new t.Rectangle,i._areBoundsDirty=!0,i._renderLayer=0,i.debugRenderEnabled=!0,i._isVisible=!1,i._localOffset=new t.Vector2,i}return __extends(i,e),i.prototype.getwidth=function(){return this.bounds.width},i.prototype.getheight=function(){return this.bounds.height},i.prototype.getbounds=function(){return this._areBoundsDirty&&(this._bounds.calculateBounds(this.entity.transform.position,this._localOffset,new t.Vector2(this.getwidth()/2,this.getheight()/2),this.entity.transform.scale,this.entity.transform.rotation,this.getwidth(),this.getheight()),this._areBoundsDirty=!1),this._bounds},Object.defineProperty(i.prototype,"bounds",{get:function(){return this.getbounds()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderLayer",{get:function(){return this._renderLayer},set:function(t){this.setRenderLayer(t)},enumerable:!0,configurable:!0}),i.prototype.onEntityTransformChanged=function(t){this._areBoundsDirty=!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.equals(t)||(this._localOffset=t,this._areBoundsDirty=!0),this},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.onBecameVisible=function(){},i.prototype.onBecameInvisible=function(){},i.prototype.setRenderLayer=function(e){if(e!=this._renderLayer){var i=this._renderLayer;this._renderLayer=e,null!=this.entity&&null!=this.entity.scene&&t.Core.scene.renderableComponents.updateRenderableRenderLayer(this,i,this._renderLayer)}return this},i.prototype.isVisibleFromCamera=function(t){return this.isVisible=t.bounds.intersects(this.bounds),this.isVisible},i.prototype.debugRender=function(e){if(this.debugRenderEnabled){for(var i=null,n=0;n<this.entity.components.buffer.length;n++){var r=this.entity.components.buffer[n];if(r instanceof t.Collider){i=r;break}}null==i&&(e.drawHollowRect(this.bounds.x,this.bounds.y,this.bounds.width,this.bounds.height,new t.Color(255,255,0)),e.end()),e.drawPixel(t.Vector2.add(this.entity.transform.position,this._localOffset),new t.Color(153,50,204),4),e.end()}},i}(t.Component);t.RenderableComponent=e}(es||(es={})),function(t){function e(e){switch(typeof e){case"boolean":case"number":case"string":return""+e;case"function":return t.getClassName(e);default:return e.uuid=e.uuid?e.uuid:t.UUID.randomUUID(),e.uuid}}var i=function(){function t(){this.clear()}return t.prototype.clear=function(){this.map_={},this.keys_={}},t.prototype.values=function(){var t=[],e=this.map_;for(var i in e)t.push(e[i]);return t},t.prototype.contains=function(t){var e=this.map_;for(var i in e)if(t===e[i])return!0;return!1},t.prototype.containsKey=function(t){return e(t)in this.map_},t.prototype.containsValue=function(t){var e=this.map_;for(var i in e)if(t===e[i])return!0;return!1},t.prototype.get=function(t){return this.map_[e(t)]},t.prototype.isEmpty=function(){return 0===Object.keys(this.map_).length},t.prototype.keys=function(){var t=this.map_,e=[];for(var i in t)e.push(t[i]);return e},t.prototype.put=function(t,i){var n=e(t);this.map_[n]=i,this.keys_[n]=t},t.prototype.remove=function(t){var i=this.map_,n=e(t),r=i[n];return delete i[n],delete this.keys_[n],r},t.prototype.size=function(){return Object.keys(this.map_).length},t}();t.HashMap=i}(es||(es={})),function(t){var e=function(){function e(e){this._entities=[],this._startTime=0,this._endTime=0,this._useTime=0,this._matcher=e||t.Matcher.empty(),this.initialize()}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}),Object.defineProperty(e.prototype,"useTime",{get:function(){return this._useTime},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onChanged=function(t){var e=!!this._entities.find(function(e){return e.id==t.id}),i=this._matcher.isInterestedEntity(t);i&&!e?this.add(t):!i&&e&&this.remove(t)},e.prototype.add=function(t){this._entities.find(function(e){return e.id==t.id})||this._entities.push(t),this.onAdded(t)},e.prototype.onAdded=function(t){},e.prototype.remove=function(e){new t.List(this._entities).remove(e),this.onRemoved(e)},e.prototype.onRemoved=function(t){},e.prototype.update=function(){this.checkProcessing()&&(this.begin(),this.process(this._entities))},e.prototype.lateUpdate=function(){this.checkProcessing()&&(this.lateProcess(this._entities),this.end())},e.prototype.begin=function(){t.Core.Instance.debug&&(this._startTime=Date.now())},e.prototype.process=function(t){},e.prototype.lateProcess=function(t){},e.prototype.end=function(){t.Core.Instance.debug&&(this._endTime=Date.now(),this._useTime=this._endTime-this._startTime)},e.prototype.checkProcessing=function(){return!0},e}();t.EntitySystem=e}(es||(es={})),function(t){var e=function(e){function i(t){var i=e.call(this,t)||this;return i.delay=0,i.running=!1,i.acc=0,i}return __extends(i,e),i.prototype.process=function(t){var e=t.length;if(0!=e){this.delay=Number.MAX_VALUE;for(var i=0;e>i;i++){var n=t[i];this.processDelta(n,this.acc);var r=this.getRemainingDelay(n);r<=0?this.processExpired(n):this.offerDelay(r)}this.acc=0}else this.stop()},i.prototype.checkProcessing=function(){return!!this.running&&(this.acc+=t.Time.deltaTime,this.acc>=this.delay)},i.prototype.offerDelay=function(t){this.running?this.delay=Math.min(this.delay,t):(this.running=!0,this.delay=t)},i.prototype.getInitialTimeDelay=function(){return this.delay},i.prototype.getRemainingTimeUntilProcessing=function(){return this.running?this.delay-this.acc:0},i.prototype.isRunning=function(){return this.running},i.prototype.stop=function(){this.running=!1,this.acc=0},i}(t.EntitySystem);t.DelayedIteratingSystem=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){if(0!=t.length)for(var e=0,i=t.length;e<i;++e){var n=t[e];this.processEntity(n)}},e.prototype.lateProcess=function(t){if(0!=t.length)for(var e=0,i=t.length;e<i;++e){var n=t[e];this.lateProcessEntity(n)}},e}(t.EntitySystem);t.EntityProcessingSystem=e}(es||(es={})),function(t){var e=function(e){function i(t,i){var n=e.call(this,t)||this;return n.acc=0,n.interval=0,n.intervalDelta=0,n.interval=i,n}return __extends(i,e),i.prototype.checkProcessing=function(){return this.acc+=t.Time.deltaTime,this.acc>=this.interval&&(this.acc-=this.interval,this.intervalDelta=this.acc-this.intervalDelta,!0)},i.prototype.getIntervalDelta=function(){return this.interval+this.intervalDelta},i}(t.EntitySystem);t.IntervalSystem=e}(es||(es={})),function(t){var e=function(t){function e(e,i){return t.call(this,e,i)||this}return __extends(e,t),e.prototype.process=function(t){var e=this;t.forEach(function(t){return e.processEntity(t)})},e}(t.IntervalSystem);t.IntervalIteratingSystem=e}(es||(es={})),function(es){var JobSystem=function(_super){function JobSystem(t,e){var i=_super.call(this,t)||this;i._threads=e,i._jobs=new Array(e);for(var n=0;n<i._jobs.length;n++)i._jobs[n]=new Job;return i._executeStr=JSON.stringify(i.execute,function(t,e){return"function"==typeof e?e+"":e}),i}return __extends(JobSystem,_super),JobSystem.prototype.process=function(t){for(var e=this,i=t.length&this._threads,n=t.length/this._threads+(0==i?0:1),r=function(i){var r=i*n,s=r+n;s>t.length&&(s=t.length);var a=o._jobs[i];if(a.set(t,r,s,o._executeStr,o),r!=s){var h=es.WorkerUtils.makeWorker(o.queueOnThread);es.WorkerUtils.workerMessage(h)(a).then(function(t){var i=t;e.resetJob(i),h.terminate()}).catch(function(t){a.err=t,h.terminate()})}},o=this,s=0;s<this._threads;s++)r(s)},JobSystem.prototype.queueOnThread=function(){onmessage=function(_a){for(var _b=_a.data,jobId=_b.jobId,message=_b.message,job=message[0],executeFunc=JSON.parse(job.execute,function(k,v){return v.indexOf&&v.indexOf("function")>-1?eval("(function(){return "+v+" })()"):v}),i=job.from;i<job.to;i++)executeFunc.call(job.context,job.entities[i]);postMessage({jobId:jobId,result:message},null)}},JobSystem}(es.EntitySystem);es.JobSystem=JobSystem;var Job=function(){function t(){}return t.prototype.set=function(t,e,i,n,r){this.entities=t,this.from=e,this.to=i,this.execute=n,this.context=r},t}()}(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(){this._bit={}}return t.prototype.set=function(t,e){this._bit[t]=e},t.prototype.get=function(t){var e=this._bit[t];return null==e?0:e},t}();t.Bits=e}(es||(es={})),function(t){var e=function(){function e(t){this._components=[],this._updatableComponents=[],this._componentsToAdd={},this._componentsToRemove={},this._componentsToAddList=[],this._componentsToRemoveList=[],this._tempBufferList=[],this.componentsByType=new Map,this.componentsToAddByType=new Map,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[t.id]=t,this._componentsToAddList.push(t),this.addComponentsToAddByType(t)},e.prototype.remove=function(t){if(this._componentsToAdd[t.id]){var e=this._componentsToAddList.findIndex(function(e){return e.id==t.id});return-1!=e&&this._componentsToAddList.splice(e,1),delete this._componentsToAdd[t.id],void this.removeComponentsToAddByType(t)}this._componentsToRemove[t.id]=t,this._componentsToRemoveList.push(t)},e.prototype.removeAllComponents=function(){if(this._components.length>0)for(var t=0,e=this._components.length;t<e;++t)this.handleRemove(this._components[t]);this.componentsByType.clear(),this.componentsToAddByType.clear(),this._components.length=0,this._updatableComponents.length=0,this._componentsToAdd={},this._componentsToRemove={},this._componentsToAddList.length=0,this._componentsToRemoveList.length=0},e.prototype.deregisterAllComponents=function(){if(this._components.length>0)for(var e=0,i=this._components.length;e<i;++e){var n=this._components[e];n&&(n instanceof t.RenderableComponent&&this._entity.scene.renderableComponents.remove(n),t.isIUpdatable(n)&&new t.List(this._updatableComponents).remove(n),this.decreaseBits(n),this._entity.scene.entityProcessors.onComponentRemoved(this._entity))}},e.prototype.registerAllComponents=function(){if(this._components.length>0)for(var e=0,i=this._components.length;e<i;++e){var n=this._components[e];n instanceof t.RenderableComponent&&this._entity.scene.renderableComponents.remove(n),t.isIUpdatable(n)&&this._updatableComponents.push(n),this.addBits(n),this._entity.scene.entityProcessors.onComponentAdded(this._entity)}},e.prototype.decreaseBits=function(e){var i=this._entity.componentBits,n=t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(e));i.set(n,i.get(n)-1)},e.prototype.addBits=function(e){var i=this._entity.componentBits,n=t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(e));i.set(n,i.get(n)+1)},e.prototype.updateLists=function(){if(this._componentsToRemoveList.length>0){for(var e=function(t,e){var n=i._componentsToRemoveList[t];i.handleRemove(n);var r=i._components.findIndex(function(t){return t.id==n.id});-1!=r&&i._components.splice(r,1),i.removeComponentsByType(n)},i=this,n=0,r=this._componentsToRemoveList.length;n<r;++n)e(n);this._componentsToRemove={},this._componentsToRemoveList.length=0}if(this._componentsToAddList.length>0){for(n=0,r=this._componentsToAddList.length;n<r;++n){(o=this._componentsToAddList[n])instanceof t.RenderableComponent&&this._entity.scene.renderableComponents.add(o),t.isIUpdatable(o)&&this._updatableComponents.push(o),this.addBits(o),this._entity.scene.entityProcessors.onComponentAdded(this._entity),this.addComponentsByType(o),this._components.push(o),this._tempBufferList.push(o)}this._componentsToAdd={},this._componentsToAddList.length=0,this.componentsToAddByType.clear(),this._isComponentListUnsorted=!0}if(this._tempBufferList.length>0){for(n=0,r=this._tempBufferList.length;n<r;++n){var o;(o=this._tempBufferList[n]).onAddedToEntity(),o.enabled&&o.onEnabled()}this._tempBufferList.length=0}},e.prototype.handleRemove=function(e){if(e instanceof t.RenderableComponent&&this._entity.scene.renderableComponents.remove(e),t.isIUpdatable(e)&&this._updatableComponents.length>0){var i=this._updatableComponents.findIndex(function(t){return t.id==e.id});-1!=i&&this._updatableComponents.splice(i,1)}this.decreaseBits(e),this._entity.scene.entityProcessors.onComponentRemoved(this._entity),e.onRemovedFromEntity(),e.entity=null},e.prototype.removeComponentsByType=function(e){var i=this.componentsByType.get(t.TypeUtils.getType(e)),n=i.findIndex(function(t){return t.id==e.id});-1!=n&&i.splice(n,1)},e.prototype.addComponentsByType=function(e){var i=this.componentsByType.get(t.TypeUtils.getType(e));i||(i=[]),i.push(e),this.componentsByType.set(t.TypeUtils.getType(e),i)},e.prototype.removeComponentsToAddByType=function(e){var i=this.componentsToAddByType.get(t.TypeUtils.getType(e)),n=i.findIndex(function(t){return t.id==e.id});-1!=n&&i.splice(n,1)},e.prototype.addComponentsToAddByType=function(e){var i=this.componentsToAddByType.get(t.TypeUtils.getType(e));i||(i=[]),i.push(e),this.componentsToAddByType.set(t.TypeUtils.getType(e),i)},e.prototype.getComponent=function(t,e){var i=this.componentsByType.get(t);if(i&&i.length>0)return i[0];if(!e){var n=this.componentsToAddByType.get(t);if(n&&n.length>0)return n[0]}return null},e.prototype.getComponents=function(t,e){e||(e=[]);var i=this.componentsByType.get(t);i&&(e=e.concat(i));var n=this.componentsToAddByType.get(t);return n&&(e=e.concat(n)),e},e.prototype.update=function(){if(this.updateLists(),this._updatableComponents.length>0)for(var t=0,e=this._updatableComponents.length;t<e;++t){var i=this._updatableComponents[t];i.enabled&&i.update()}},e.prototype.onEntityTransformChanged=function(t){if(this._components.length>0)for(var e=0,i=this._components.length;e<i;++e){(n=this._components[e]).enabled&&n.onEntityTransformChanged(t)}if(this._componentsToAddList.length>0)for(e=0,i=this._componentsToAddList.length;e<i;++e){var n;(n=this._componentsToAddList[e]).enabled&&n.onEntityTransformChanged(t)}},e.prototype.onEntityEnabled=function(){if(this._components.length>0)for(var t=0,e=this._components.length;t<e;t++)this._components[t].onEnabled()},e.prototype.onEntityDisabled=function(){if(this._components.length>0)for(var t=0,e=this._components.length;t<e;t++)this._components[t].onDisabled()},e.prototype.debugRender=function(t){if(t)for(var e=0;e<this._components.length;e++)this._components[e].enabled&&this._components[e].debugRender(t)},e.compareUpdatableOrder=new t.IUpdatableComparer,e}();t.ComponentList=e}(es||(es={})),function(t){var e=function(){function e(){this.componentTypeCount_=0,this.componentTypes_={},this.types=new t.Bag}return e.prototype.getTypeFor=function(e){if("number"==typeof e)return this.types.get(e);var i=this.componentTypes_[t.getClassName(e)];if(null==i){var n=this.componentTypeCount_++;i=new t.ComponentType(e,n),this.componentTypes_[t.getClassName(e)]=i,this.types.set(n,i)}return i},e.prototype.getIndexFor=function(t){return this.getTypeFor(t).getIndex()},e}();t.ComponentTypeFactory=e}(es||(es={})),function(t){var e=function(){function t(){}return t.add=function(t){this._componentTypesMask.has(t)||this._componentTypesMask.set(t,this._componentTypesMask.size)},t.getIndexFor=function(t){var e=-1;return this._componentTypesMask.has(t)?e=this._componentTypesMask.get(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._entitiesToAddedList=[],this._entitiesToRemoveList=[],this._entityDict=new Map,this._unsortedTags=new Set,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.add(t)},e.prototype.add=function(t){this._entitiesToAdded[t.id]=t,this._entitiesToAddedList.push(t)},e.prototype.remove=function(t){if(this._entitiesToAdded[t.id]){var e=this._entitiesToAddedList.findIndex(function(e){return e.id==t.id});return-1!=e&&this._entitiesToAddedList.splice(e,1),void delete this._entitiesToAdded[t.id]}this._entitiesToRemoveList.push(t),this._entitiesToRemove[t.id]||(this._entitiesToRemove[t.id]=t)},e.prototype.removeAllEntities=function(){this._unsortedTags.clear(),this._entitiesToAdded={},this._entitiesToAddedList.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._entitiesToAdded[t.id]},e.prototype.getTagList=function(t){var e=this._entityDict.get(t);return e||(e=new Set,this._entityDict.set(t,e)),e},e.prototype.addToTagList=function(t){this.getTagList(t.tag).add(t),this._unsortedTags.add(t.tag)},e.prototype.removeFromTagList=function(t){var e=this._entityDict.get(t.tag);e&&e.delete(t)},e.prototype.update=function(){for(var e=0,i=this._entities.length;e<i;++e){var n=this._entities[e];!n.enabled||1!=n.updateInterval&&t.Time.frameCount%n.updateInterval!=0||n.update()}},e.prototype.updateLists=function(){if(this._entitiesToRemoveList.length>0){for(var t=function(t,i){var n=e._entitiesToRemoveList[t];e.removeFromTagList(n);var r=e._entities.findIndex(function(t){return t.id==n.id});-1!=r&&e._entities.splice(r,1),n.onRemovedFromScene(),n.scene=null,e.scene.entityProcessors.onEntityRemoved(n)},e=this,i=0,n=this._entitiesToRemoveList.length;i<n;++i)t(i);this._entitiesToRemove={},this._entitiesToRemoveList.length=0}if(this._entitiesToAddedList.length>0){for(i=0,n=this._entitiesToAddedList.length;i<n;++i){var r=this._entitiesToAddedList[i];this._entities.push(r),r.scene=this.scene,this.addToTagList(r),this.scene.entityProcessors.onEntityAdded(r)}for(i=0,n=this._entitiesToAddedList.length;i<n;++i){(r=this._entitiesToAddedList[i]).onAddedToScene()}this._entitiesToAdded={},this._entitiesToAddedList.length=0}},e.prototype.findEntity=function(t){if(this._entities.length>0)for(var e=0,i=this._entities.length;e<i;++e){if((n=this._entities[e]).name==t)return n}if(this._entitiesToAddedList.length>0)for(e=0,i=this._entitiesToAddedList.length;e<i;++e){var n;if((n=this._entitiesToAddedList[e]).name==t)return n}return null},e.prototype.findEntityById=function(t){if(this._entities.length>0)for(var e=0,i=this._entities.length;e<i;++e){var n=this._entities[e];if(n.id==t)return n}return this._entitiesToAdded[t]},e.prototype.entitiesWithTag=function(e){var i,n,r=this.getTagList(e),o=t.ListPool.obtain();if(r.size>0)try{for(var s=__values(r),a=s.next();!a.done;a=s.next()){var h=a.value;o.push(h)}}catch(t){i={error:t}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o},e.prototype.entityWithTag=function(t){var e,i,n=this.getTagList(t);if(n.size>0)try{for(var r=__values(n),o=r.next();!o.done;o=r.next()){return o.value}}catch(t){e={error:t}}finally{try{o&&!o.done&&(i=r.return)&&i.call(r)}finally{if(e)throw e.error}}return null},e.prototype.findComponentOfType=function(t){if(this._entities.length>0)for(var e=0,i=this._entities.length;e<i;e++){if((n=this._entities[e]).enabled)if(r=n.getComponent(t))return r}if(this._entitiesToAddedList.length>0)for(e=0;e<this._entitiesToAddedList.length;e++){var n,r;if((n=this._entitiesToAddedList[e]).enabled)if(r=n.getComponent(t))return r}return null},e.prototype.findComponentsOfType=function(e){var i=t.ListPool.obtain();if(this._entities.length>0)for(var n=0,r=this._entities.length;n<r;n++){(o=this._entities[n]).enabled&&o.getComponents(e,i)}if(this._entitiesToAddedList.length>0)for(n=0,r=this._entitiesToAddedList.length;n<r;n++){var o;(o=this._entitiesToAddedList[n]).enabled&&o.getComponents(e,i)}return i},e.prototype.findEntitesOfComponent=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var i=[];if(this._entities.length>0)for(var n=0,r=this._entities.length;n<r;n++)if(this._entities[n].enabled){var o=!0;if(t.length>0)for(var s=0,a=t.length;s<a;s++){var h=t[s];if(!this._entities[n].hasComponent(h)){o=!1;break}}o&&i.push(this._entities[n])}if(this._entitiesToAddedList.length>0)for(n=0,r=this._entitiesToAddedList.length;n<r;n++){var c=this._entitiesToAddedList[n];if(c.enabled){o=!0;if(t.length>0)for(s=0,a=t.length;s<a;s++){h=t[s];if(!c.hasComponent(h)){o=!1;break}}o&&i.push(c)}}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(e){new t.List(this._processors).remove(e)},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(){if(0!=this._processors.length)for(var t=0,e=this._processors.length;t<e;++t)this._processors[t].update()},e.prototype.lateUpdate=function(){if(0!=this._processors.length)for(var t=0,e=this._processors.length;t<e;++t)this._processors[t].lateUpdate()},e.prototype.end=function(){},e.prototype.getProcessor=function(t){if(0==this._processors.length)return null;for(var e=0,i=this._processors.length;e<i;++e){var n=this._processors[e];if(n instanceof t)return n}return null},e.prototype.notifyEntityChanged=function(t){if(0!=this._processors.length)for(var e=0,i=this._processors.length;e<i;++e)this._processors[e].onChanged(t)},e.prototype.removeFromProcessors=function(t){if(0!=this._processors.length)for(var e=0,i=this._processors.length;e<i;++e)this._processors[e].remove(t)},e}();t.EntityProcessorList=e}(es||(es={})),function(t){var e=function(){function t(){}return t.isPrime=function(t){if(0!=(1&t)){for(var e=Math.sqrt(t),i=3;i<=e;i+=2)if(0==(t&i))return!1;return!0}return 2==t},t.getPrime=function(t){if(t<0)throw new Error("参数错误 min不能小于0");for(var e=0;e<this.primes.length;e++){var i=this.primes[e];if(i>=t)return i}for(e=1|t;e<Number.MAX_VALUE;e+=2)if(this.isPrime(e)&&(e-1)%this.hashPrime!=0)return e;return t},t.expandPrime=function(t){var e=2*t;return e>this.maxPrimeArrayLength&&this.maxPrimeArrayLength>t?this.maxPrimeArrayLength:this.getPrime(e)},t.getHashCode=function(t){var e,i=0;if(0==(e="object"==typeof t?JSON.stringify(t):t.toString()).length)return i;for(var n=0;n<e.length;n++){i=(i<<5)-i+e.charCodeAt(n),i&=i}return i},t.hashCollisionThreshold=100,t.hashPrime=101,t.primes=[3,7,11,17,23,29,37,47,59,71,89,107,131,163,197,239,293,353,431,521,631,761,919,1103,1327,1597,1931,2333,2801,3371,4049,4861,5839,7013,8419,10103,12143,14591,17519,21023,25229,30293,36353,43627,52361,62851,75431,90523,108631,130363,156437,187751,225307,270371,324449,389357,467237,560689,672827,807403,968897,1162687,1395263,1674319,2009191,2411033,2893249,3471899,4166287,4999559,5999471,7199369],t.maxPrimeArrayLength=2146435069,t}();t.HashHelpers=e}(es||(es={})),function(t){var e=function(){function e(){this.nextAvailableId_=0,this.ids=new t.Bag}return e.prototype.checkOut=function(){return this.ids.size()>0?this.ids.removeLast():this.nextAvailableId_++},e.prototype.checkIn=function(t){this.ids.add(t)},e}();t.IdentifierPool=e}(es||(es={})),function(t){var e=function(){function e(){this.allSet=[],this.exclusionSet=[],this.oneSet=[]}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.isInterestedEntity=function(t){return this.isInterested(t.componentBits)},e.prototype.isInterested=function(e){if(0!=this.allSet.length)for(var i=0,n=this.allSet.length;i<n;++i){var r=this.allSet[i];if(!e.get(t.ComponentTypeManager.getIndexFor(r)))return!1}if(0!=this.exclusionSet.length)for(i=0,n=this.exclusionSet.length;i<n;++i){r=this.exclusionSet[i];if(e.get(t.ComponentTypeManager.getIndexFor(r)))return!1}if(0!=this.oneSet.length)for(i=0,n=this.oneSet.length;i<n;++i){r=this.oneSet[i];if(e.get(t.ComponentTypeManager.getIndexFor(r)))return!0}return!0},e.prototype.all=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];for(var n=0,r=e.length;n<r;++n)t=e[n],this.allSet.push(t);return this},e.prototype.exclude=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];for(var n=0,r=e.length;n<r;++n)t=e[n],this.exclusionSet.push(t);return this},e.prototype.one=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var i=0,n=t.length;i<n;++i){var r=t[i];this.oneSet.push(r)}return this},e}();t.Matcher=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}),e.prototype.get=function(t){return this._components[t]},e.prototype.add=function(t){this._components.push(t),this.addToRenderLayerList(t,t.renderLayer)},e.prototype.remove=function(e){new t.List(this._components).remove(e),new t.List(this._componentsByRenderLayer.get(e.renderLayer)).remove(e)},e.prototype.updateRenderableRenderLayer=function(e,i,n){this._componentsByRenderLayer.has(i)&&new t.List(this._componentsByRenderLayer.get(i)).contains(e)&&(new t.List(this._componentsByRenderLayer.get(i)).remove(e),this.addToRenderLayerList(e,n))},e.prototype.setRenderLayerNeedsComponentSort=function(e){var i=new t.List(this._unsortedRenderLayers);i.contains(e)||i.add(e),this._componentsNeedSort=!0},e.prototype.setNeedsComponentSort=function(){this._componentsNeedSort=!0},e.prototype.addToRenderLayerList=function(e,i){var n=this.componentsWithRenderLayer(i);t.Insist.isFalse(!!n.find(function(t){return t==e}),"组件renderLayer列表已包含此组件"),n.push(e);var r=new t.List(this._unsortedRenderLayers);r.contains(i)||r.add(i),this._componentsNeedSort=!0},e.prototype.componentsWithRenderLayer=function(t){return this._componentsByRenderLayer.get(t)||this._componentsByRenderLayer.set(t,[]),this._componentsByRenderLayer.get(t)},e.prototype.updateLists=function(){if(this._componentsNeedSort&&(this._components.sort(function(t,e){return e.renderLayer-t.renderLayer}),this._componentsNeedSort=!1),this._unsortedRenderLayers.length>0)for(var t=0,e=this._unsortedRenderLayers.length;t<e;t++){var i=this._componentsByRenderLayer.get(this._unsortedRenderLayers[t]);i&&i.sort(function(t,e){return e.renderLayer-t.renderLayer}),this._unsortedRenderLayers.length=0}},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,h=0;h<r;h++)s=!1,t.charAt(h)==a.charAt(0)&&t.substr(h,a.length)==a&&(s=!0),s?(o+=i,h=h+a.length-1):o+=t.charAt(h);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.format=function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];for(var n=0;n<e.length-1;n++){var r=new RegExp("\\{"+n+"\\}","gm");t=t.replace(r,e[n+1])}return t},t.specialSigns=["&","&amp;","<","&lt;",">","&gt;",'"',"&quot;","'","&apos;","®","&reg;","©","&copy;","™","&trade;"],t}();!function(t){var e=function(){function t(){}return t.update=function(t){-1==t&&(t=Date.now()),-1==this._lastTime&&(this._lastTime=t);var e=0;(e=-1==t?(t-this._lastTime)/1e3:t)>this.maxDeltaTime&&(e=this.maxDeltaTime),this.totalTime+=e,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.totalTime=0,t.unscaledDeltaTime=0,t.deltaTime=0,t.timeScale=1,t.maxDeltaTime=Number.MAX_VALUE,t.frameCount=0,t.timeSinceSceneLoad=0,t._lastTime=-1,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,h=Math.floor(a)+1;if(53==h){i.setTime(t.getTime()),i.setDate(i.getDate()-1);var c=i.getDay();if(0==c&&(c=7),e&&(!o||c<4))return i.setFullYear(i.getFullYear()+1),i.setDate(1),i.setMonth(0),this.weekId(i,!1)}return parseInt(n+"00"+(h>9?"":"0")+h)},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(),h=o.toString();return n<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(h="0"+h),i?s+e+a+e+h:a+e+h},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(){function t(){}return t.makeWorker=function(t){return new Worker(URL.createObjectURL(new Blob(["("+t.toString()+")()"])))},t.workerMessage=function(t){var e=this;return t.onmessage=function(t){var i=t.data,n=i.result,r=i.jobId;"function"==typeof e.pendingJobs[r]&&e.pendingJobs[r](n),delete e.pendingJobs[r]},function(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];return new Promise(function(n){var r=e.jobIdGen++;e.pendingJobs[r]=n,t.postMessage({jobId:r,message:i})})}},t.pendingJobs={},t.jobIdGen=0,t}();t.WorkerUtils=e}(es||(es={})),function(t){var e=function(){return function(t){this.batcher=t}}();t.Graphics=e}(es||(es={})),function(t){var e=function(){function t(t,e,i,n){this.r=t,this.g=e,this.b=i,this.a=null!=n?n:1}return t.fromRGB=function(e,i,n,r){return new t(e,i,n,r)},t.createFromHex=function(e){var i=new t(1,1,1);return i.fromHex(e),i},t.fromHSL=function(t,e,n,r){return void 0===r&&(r=1),new i(t,e,n,r).toRGBA()},t.prototype.lighten=function(t){void 0===t&&(t=.1);var e=i.fromRGBA(this.r,this.g,this.b,this.a);return e.l+=e.l*t,e.toRGBA()},t.prototype.darken=function(t){void 0===t&&(t=.1);var e=i.fromRGBA(this.r,this.g,this.b,this.a);return e.l-=e.l*t,e.toRGBA()},t.prototype.saturate=function(t){void 0===t&&(t=.1);var e=i.fromRGBA(this.r,this.g,this.b,this.a);return e.s+=e.s*t,e.toRGBA()},t.prototype.desaturate=function(t){void 0===t&&(t=.1);var e=i.fromRGBA(this.r,this.g,this.b,this.a);return e.s-=e.s*t,e.toRGBA()},t.prototype.mulitiply=function(e){return new t(e.r/255*this.r/255*255,e.g/255*this.g/255*255,e.b/255*this.b/255*255,e.a*this.a)},t.prototype.screen=function(t){var e=t.invert(),i=t.invert();return e.mulitiply(i).invert()},t.prototype.invert=function(){return new t(255-this.r,255-this.g,255-this.b,1-this.a)},t.prototype.average=function(e){return new t((e.r+this.r)/2,(e.g+this.g)/2,(e.b+this.b)/2,(e.a+this.a)/2)},t.prototype.toString=function(t){switch(void 0===t&&(t="rgb"),t){case"rgb":return this.toRGBA();case"hsl":return this.toHSLA();case"hex":return this.toHex();default:throw new Error("Invalid Color format")}},t.prototype._componentToHex=function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},t.prototype.toHex=function(){return"#"+this._componentToHex(this.r)+this._componentToHex(this.g)+this._componentToHex(this.b)+this._componentToHex(this.a)},t.prototype.fromHex=function(t){var e=t.match(/^#?([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})?$/i);if(!e)throw new Error("Invalid hex string: "+t);var i=parseInt(e[1],16),n=parseInt(e[2],16),r=parseInt(e[3],16),o=1;e[4]&&(o=parseInt(e[4],16)/255),this.r=i,this.g=n,this.b=r,this.a=o},t.prototype.toRGBA=function(){var t=String(this.r.toFixed(0))+", "+String(this.g.toFixed(0))+", "+String(this.b.toFixed(0));return void 0!==this.a||null!=this.a?"rgba("+t+", "+String(this.a)+")":"rgb("+t+")"},t.prototype.toHSLA=function(){return i.fromRGBA(this.r,this.g,this.b,this.a).toString()},t.prototype.fillStyle=function(){return this.toString()},t.prototype.clone=function(){return new t(this.r,this.g,this.b,this.a)},t.Black=t.createFromHex("#000000"),t.White=t.createFromHex("#FFFFFF"),t.Gray=t.createFromHex("#808080"),t.LightGray=t.createFromHex("#D3D3D3"),t.DarkGray=t.createFromHex("#A9A9A9"),t.Yellow=t.createFromHex("#FFFF00"),t.Orange=t.createFromHex("#FFA500"),t.Red=t.createFromHex("#FF0000"),t.Vermillion=t.createFromHex("#FF5B31"),t.Rose=t.createFromHex("#FF007F"),t.Magenta=t.createFromHex("#FF00FF"),t.Violet=t.createFromHex("#7F00FF"),t.Blue=t.createFromHex("#0000FF"),t.Azure=t.createFromHex("#007FFF"),t.Cyan=t.createFromHex("#00FFFF"),t.Viridian=t.createFromHex("#59978F"),t.Green=t.createFromHex("#00FF00"),t.Chartreuse=t.createFromHex("#7FFF00"),t.Transparent=t.createFromHex("#FFFFFF00"),t}();t.Color=e;var i=function(){function t(t,e,i,n){this.h=t,this.s=e,this.l=i,this.a=n}return t.hue2rgb=function(t,e,i){return i<0&&(i+=1),i>1&&(i-=1),i<1/6?t+6*(e-t)*i:i<.5?e:i<2/3?t+(e-t)*(2/3-i)*6:t},t.fromRGBA=function(e,i,n,r){e/=255,i/=255,n/=255;var o=Math.max(e,i,n),s=Math.min(e,i,n),a=(o+s)/2,h=a,c=a;if(o===s)a=h=0;else{var l=o-s;switch(h=c>.5?l/(2-o-s):l/(o+s),o){case e:a=(i-n)/l+(i<n?6:0);break;case i:a=(n-e)/l+2;break;case n:a=(e-i)/l+4}a/=6}return new t(a,h,c,r)},t.prototype.toRGBA=function(){var i,n,r;if(0===this.s)i=n=r=this.l;else{var o=this.l<.5?this.l*(1+this.s):this.l+this.s-this.l*this.s,s=2*this.l-o;i=t.hue2rgb(s,o,this.h+1/3),n=t.hue2rgb(s,o,this.h),r=t.hue2rgb(s,o,this.h-1/3)}return new e(255*i,255*n,255*r,this.a)},t.prototype.toString=function(){return"hsla("+this.h.toFixed(0)+", "+this.s.toFixed(0)+", "+this.l.toFixed(0)+", "+this.a.toFixed(0)+")"},t}()}(es||(es={})),function(t){var e=function(){function e(e,i){this.renderOrder=0,this.shouldDebugRender=!0,this.renderDirty=!0,this.renderOrder=e,this.camera=i,t.Core.emitter.addObserver(t.CoreEvents.renderChanged,this.onRenderChanged,this)}return e.prototype.onAddedToScene=function(t){},e.prototype.unload=function(){},e.prototype.beginRender=function(e){t.Graphics.instance&&t.Graphics.instance.batcher.begin(e)},e.prototype.endRender=function(){t.Graphics.instance&&t.Graphics.instance.batcher.end()},e.prototype.onRenderChanged=function(){this.renderDirty=!0},e.prototype.renderAfterStateCheck=function(e,i){t.Graphics.instance&&e.render(t.Graphics.instance.batcher,i)},e.prototype.debugRender=function(e){if(t.Graphics.instance){t.Physics.debugDraw(2);for(var i=0;i<e.entities.count;i++){var n=e.entities.buffer[i];n.enabled&&n.debugRender(t.Graphics.instance.batcher)}}},e}();t.Renderer=e}(es||(es={})),function(t){var e=function(e){function i(t,i){return void 0===t&&(t=0),void 0===i&&(i=null),e.call(this,t,i)||this}return __extends(i,e),i.prototype.render=function(e){if(this.renderDirty){this.renderDirty=!1;var i=this.camera?this.camera:e.camera;this.beginRender(i);for(var n=0;n<e.renderableComponents.count;n++){var r=e.renderableComponents.get(n);r.enabled&&r.isVisibleFromCamera(e.camera)&&this.renderAfterStateCheck(r,i)}this.shouldDebugRender&&t.Core.debugRenderEndabled&&this.debugRender(e),this.endRender()}},i}(t.Renderer);t.DefaultRenderer=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 new t.Vector2(o*o).multiply(e).addEqual(new t.Vector2(2*o*r).multiply(i)).addEqual(new t.Vector2(r*r).multiply(n))},e.getPointThree=function(e,i,n,r,o){var s=1-(o=t.MathHelper.clamp01(o));return new t.Vector2(s*s*s).multiply(e).addEqual(new t.Vector2(3*s*s*o).multiply(i)).addEqual(new t.Vector2(3*s*o*o).multiply(n)).addEqual(new t.Vector2(o*o*o).multiply(r))},e.getFirstDerivative=function(t,e,i,n){return e.sub(t).scale(2*(1-n)).addEqual(i.sub(e).scale(2*n))},e.getFirstDerivativeThree=function(e,i,n,r,o){var s=1-(o=t.MathHelper.clamp01(o));return i.sub(e).scale(3*s*s).addEqual(n.sub(i).scale(6*s*o)).addEqual(r.sub(n).scale(3*o*o))},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.divideScaler(e.add(i),2),h=t.Vector2.divideScaler(i.add(n),2),c=t.Vector2.divideScaler(n.add(r),2),l=t.Vector2.divideScaler(a.add(h),2),u=t.Vector2.divideScaler(h.add(c),2),p=t.Vector2.divideScaler(l.add(u),2),f=r.sub(e),d=Math.abs((i.x,r.x*f.y-(i.y-r.y)*f.x)),m=Math.abs((n.x-r.x)*f.y-(n.y-r.y)*f.x);(d+m)*(d+m)<s*(f.x*f.x+f.y*f.y)?o.push(p):(this.recursiveGetOptimizedDrawingPoints(e,a,l,p,o,s),this.recursiveGetOptimizedDrawingPoints(p,u,c,r,o,s))},e}();t.Bezier=e}(es||(es={})),function(t){var e=function(){function e(){this._points=[],this._curveCount=0}return e.prototype.pointIndexAtTime=function(e){var i={time:0,range:0};return e>=1?(e=1,i.range=this._points.length-4):(e=t.MathHelper.clamp01(e)*this._curveCount,i.range=Math.floor(e),e-=i.range,i.range*=3),i.time=e,i},e.prototype.setControlPoint=function(t,e){if(t%3==0){var i=e.sub(this._points[t]);t>0&&this._points[t-1].addEqual(i),t+1<this._points.length&&this._points[t+1].addEqual(i)}this._points[t]=e},e.prototype.getPointAtTime=function(e){var i=this.pointIndexAtTime(e).range;return t.Bezier.getPointThree(this._points[i],this._points[i+1],this._points[i+2],this._points[i+3],e)},e.prototype.getVelocityAtTime=function(e){var i=this.pointIndexAtTime(e).range;return t.Bezier.getFirstDerivativeThree(this._points[i],this._points[i+1],this._points[i+2],this._points[i+3],e)},e.prototype.getDirectionAtTime=function(t){return this.getVelocityAtTime(t).normalize()},e.prototype.addCurve=function(t,e,i,n){0==this._points.length&&this._points.push(t),this._points.push(e),this._points.push(i),this._points.push(n),this._curveCount=(this._points.length-1)/3},e.prototype.reset=function(){this._points.length=0},e.prototype.getDrawingPoints=function(t){for(var e=[],i=0;i<t;i++){var n=i/t;e[i]=this.getPointAtTime(n)}return e},e}();t.BezierSpline=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){t.value=1<<e},t.setFlag=function(t,e){t.value=t.value|1<<e},t.unsetFlag=function(t,e){e=1<<e,t.value=t.value&~e},t.invertFlags=function(t){t.value=~t.value},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.barycentric=function(t,e,i,n,r){return t+(e-t)*n+(i-t)*r},e.catmullRom=function(t,e,i,n,r){var o=r*r;return.5*(2*e+(i-t)*r+(2*t-5*e+4*i-n)*o+(3*e-t-3*i+n)*(o*r))},e.map=function(t,e,i,n,r){return n+(t-e)*(r-n)/(i-e)},e.map01=function(t,e,i){return 1*(t-e)/(i-e)},e.map10=function(t,e,i){return 1-this.map01(t,e,i)},e.smoothStep=function(t,i,n){var r=this.clamp(n,0,1);return r=e.hermite(t,0,i,0,r)},e.wrapAngle=function(t){return t>-Math.PI&&t<=Math.PI?t:(t%=2*Math.PI)<=-Math.PI?t+2*Math.PI:t>Math.PI?t-2*Math.PI:t},e.isPowerOfTwo=function(t){return t>0&&t%(t-1)==0},e.lerp=function(t,e,i){return t+(e-t)*this.clamp01(i)},e.betterLerp=function(t,i,n,r){return Math.abs(t-i)<r?i:e.lerp(t,i,n)},e.lerpAngle=function(t,e,i){var n=this.repeat(e-t,360);return n>180&&(n-=360),t+n*this.clamp01(i)},e.lerpAngleRadians=function(t,e,i){var n=this.repeat(e-t,2*Math.PI);return n>Math.PI&&(n-=2*Math.PI),t+n*this.clamp01(i)},e.pingPong=function(t,e){return t=this.repeat(t,2*e),e-Math.abs(t-e)},e.signThreshold=function(t,e){return Math.abs(t)>=e?Math.sign(t):0},e.inverseLerp=function(t,e,i){if(t<e){if(i<t)return 0;if(i>e)return 1}else{if(i<e)return 1;if(i>t)return 0}return(i-t)/(e-t)},e.lerpPrecise=function(t,e,i){return(1-i)*t+e*i},e.clamp=function(t,e,i){return t<e?e:t>i?i:t},e.snap=function(t,e){return Math.round(t/e)*e},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.isOdd=function(t){return t%2!=0},e.roundWithRoundedAmount=function(t,e){var i=Math.round(t);return e.value=t-i*Math.round(t/i),i},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.angleToVector=function(e,i){return new t.Vector2(Math.cos(e)*i,Math.sin(e)*i)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.decrementWithWrap=function(t,e){return--t<0?e-1:t},e.hypotenuse=function(t,e){return Math.sqrt(t*t+e*e)},e.closestPowerOfTwoGreaterThan=function(t){return t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,(t|=t>>16)+1},e.roundToNearest=function(t,e){return Math.round(t/e)*e},e.withinEpsilon=function(t,e){return void 0===e&&(e=this.Epsilon),Math.abs(t)<e},e.approach=function(t,e,i){return t<e?Math.min(t+i,e):Math.max(t-i,e)},e.approachAngle=function(t,e,i){var n=this.deltaAngle(t,e);return-i<n&&n<i?e:this.repeat(this.approach(t,t+n,i),360)},e.project=function(t,e){var i=t.dot(e)/e.lengthSquared();return e.scale(i)},e.approachAngleRadians=function(t,e,i){var n=this.deltaAngleRadians(t,e);return-i<n&&n<i?e:this.repeat(this.approach(t,t+n,i),2*Math.PI)},e.approximately=function(t,e,i){return void 0===i&&(i=this.Epsilon),Math.abs(t-e)<=i},e.deltaAngle=function(t,e){var i=this.repeat(e-t,360);return i>180&&(i-=360),i},e.between=function(t,e,i){return t>=e&&t<=i},e.deltaAngleRadians=function(t,e){var i=this.repeat(e-t,2*Math.PI);return i>Math.PI&&(i-=2*Math.PI),i},e.repeat=function(t,e){return t-Math.floor(t/e)*e},e.floorToInt=function(t){return Math.trunc(Math.floor(t))},e.rotateAround=function(e,i){var n=t.Time.totalTime*i,r=Math.cos(n),o=Math.sin(n);return new t.Vector2(e.x+r,e.y+o)},e.rotateAround2=function(e,i,n){n=this.toRadians(n);var r=Math.cos(n),o=Math.sin(n),s=r*(e.x-i.x)-o*(e.y-i.y)+i.x,a=o*(e.x-i.x)+r*(e.y-i.y)+i.y;return new t.Vector2(s,a)},e.pointOnCircle=function(e,i,n){var r=this.toRadians(n);return new t.Vector2(Math.cos(r)*i+e.x,Math.sin(r)*i+e.y)},e.pointOnCircleRadians=function(e,i,n){return new t.Vector2(Math.cos(n)*i+e.x,Math.sin(n)*i+e.y)},e.lissajou=function(e,i,n,r,o){void 0===e&&(e=2),void 0===i&&(i=3),void 0===n&&(n=1),void 0===r&&(r=1),void 0===o&&(o=0);var s=Math.sin(t.Time.totalTime*e+o)*n,a=Math.cos(t.Time.totalTime*i)*r;return new t.Vector2(s,a)},e.lissajouDamped=function(e,i,n,r,o,s,a){void 0===e&&(e=2),void 0===i&&(i=3),void 0===n&&(n=1),void 0===r&&(r=1),void 0===o&&(o=.5),void 0===s&&(s=0),void 0===a&&(a=5);var h=this.pingPong(t.Time.totalTime,a),c=Math.pow(Math.E,-s*h),l=c*Math.sin(t.Time.totalTime*e+o)*n,u=c*Math.cos(t.Time.totalTime*i)*r;return new t.Vector2(l,u)},e.hermite=function(t,e,i,n,r){return 0==r?t:1==r?i:(2*t-2*i+n+e)*(r*r*r)+(3*i-3*t-2*e-n)*(r*r)+e*r+t},e.isValid=function(t){return!Number.isNaN(t)&&t!==1/0},e.smoothDamp=function(t,e,i,n,r,o){var s=2/(n=Math.max(1e-4,n)),a=s*o,h=1/(1+(a+(a*a*.48+a*(a*a)*.235))),c=t-e,l=e,u=r*n,p=(i+s*(c=this.clamp(c,-1*u,u)))*o;i=(i-s*p)*h;var f=(e=t-c)+(c+p)*h;return l-t>0==f>l&&(i=((f=l)-l)/o),{value:f,currentVelocity:i}},e.smoothDampVector=function(e,i,n,r,o,s){var a=t.Vector2.zero,h=this.smoothDamp(e.x,i.x,n.x,r,o,s);a.x=h.value,n.x=h.currentVelocity;var c=this.smoothDamp(e.y,i.y,n.y,r,o,s);return a.y=c.value,n.y=c.currentVelocity,a},e.mapMinMax=function(t,i,n,r,o){return r+(e.clamp(t,i,n)-i)*(o-r)/(n-i)},e.fromAngle=function(e){return new t.Vector2(Math.cos(e),Math.sin(e)).normalizeEqual()},e.Epsilon=1e-5,e.Rad2Deg=57.29578,e.Deg2Rad=.0174532924,e.PiOver2=Math.PI/2,e}();t.MathHelper=e}(es||(es={})),function(t){var e=function(){function t(t,e,i,n,r,o,s,a,h,c,l,u,p,f,d,m){this.m11=t,this.m12=e,this.m13=i,this.m14=n,this.m21=r,this.m22=o,this.m23=s,this.m24=a,this.m31=h,this.m32=c,this.m33=l,this.m34=u,this.m41=p,this.m42=f,this.m43=d,this.m44=m}return Object.defineProperty(t,"Identity",{get:function(){return this.identity},enumerable:!0,configurable:!0}),t.createOrthographicOffCenter=function(e,i,n,r,o,s,a){void 0===a&&(a=new t),a.m11=2/(i-e),a.m12=0,a.m13=0,a.m14=0,a.m21=0,a.m22=2/(r-n),a.m23=0,a.m24=0,a.m31=0,a.m32=0,a.m33=1/(o-s),a.m34=0,a.m41=(e+i)/(e-i),a.m42=(r+n)/(n-r),a.m43=o/(o-s),a.m44=1},t.createTranslation=function(t,e){e.m11=1,e.m12=0,e.m13=0,e.m14=0,e.m21=0,e.m22=1,e.m23=0,e.m24=0,e.m31=0,e.m32=0,e.m33=1,e.m34=0,e.m41=t.x,e.m42=t.y,e.m43=0,e.m44=1},t.createRotationZ=function(e,i){i=t.Identity;var n=Math.cos(e),r=Math.sin(e);i.m11=n,i.m12=r,i.m21=-r,i.m22=n},t.multiply=function(e,i,n){void 0===n&&(n=new t);var r=e.m11*i.m11+e.m12*i.m21+e.m13*i.m31+e.m14*i.m41,o=e.m11*i.m12+e.m12*i.m22+e.m13*i.m32+e.m14*i.m42,s=e.m11*i.m13+e.m12*i.m23+e.m13*i.m33+e.m14*i.m43,a=e.m11*i.m14+e.m12*i.m24+e.m13*i.m34+e.m14*i.m44,h=e.m21*i.m11+e.m22*i.m21+e.m23*i.m31+e.m24*i.m41,c=e.m21*i.m12+e.m22*i.m22+e.m23*i.m32+e.m24*i.m42,l=e.m21*i.m13+e.m22*i.m23+e.m23*i.m33+e.m24*i.m43,u=e.m21*i.m14+e.m22*i.m24+e.m23*i.m34+e.m24*i.m44,p=e.m31*i.m11+e.m32*i.m21+e.m33*i.m31+e.m34*i.m41,f=e.m31*i.m12+e.m32*i.m22+e.m33*i.m32+e.m34*i.m42,d=e.m31*i.m13+e.m32*i.m23+e.m33*i.m33+e.m34*i.m43,m=e.m31*i.m14+e.m32*i.m24+e.m33*i.m34+e.m34*i.m44,y=e.m41*i.m11+e.m42*i.m21+e.m43*i.m31+e.m44*i.m41,g=e.m41*i.m12+e.m42*i.m22+e.m43*i.m32+e.m44*i.m42,_=e.m41*i.m13+e.m42*i.m23+e.m43*i.m33+e.m44*i.m43,v=e.m41*i.m14+e.m42*i.m24+e.m43*i.m34+e.m44*i.m44;n.m11=r,n.m12=o,n.m13=s,n.m14=a,n.m21=h,n.m22=c,n.m23=l,n.m24=u,n.m31=p,n.m32=f,n.m33=d,n.m34=m,n.m41=y,n.m42=g,n.m43=_,n.m44=v},t.identity=new t(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),t}();t.Matrix=e}(es||(es={})),function(t){var e=function(){function e(){this.m11=0,this.m12=0,this.m21=0,this.m22=0,this.m31=0,this.m32=0}return Object.defineProperty(e,"identity",{get:function(){return(new e).setIdentity()},enumerable:!0,configurable:!0}),e.prototype.setIdentity=function(){return this.setValues(1,0,0,1,0,0)},e.prototype.setValues=function(t,e,i,n,r,o){return this.m11=t,this.m12=e,this.m21=i,this.m22=n,this.m31=r,this.m32=o,this},Object.defineProperty(e.prototype,"translation",{get:function(){return new t.Vector2(this.m31,this.m32)},set:function(t){this.m31=t.x,this.m32=t.y},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return Math.atan2(this.m21,this.m11)},set:function(t){var e=Math.cos(t),i=Math.sin(t);this.m11=e,this.m12=i,this.m21=-i,this.m22=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationDegrees",{get:function(){return t.MathHelper.toDegrees(this.rotation)},set:function(e){this.rotation=t.MathHelper.toRadians(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scale",{get:function(){return new t.Vector2(this.m11,this.m22)},set:function(t){this.m11=t.x,this.m22=t.y},enumerable:!0,configurable:!0}),e.createRotation=function(t,e){e.setIdentity();var i=Math.cos(t),n=Math.sin(t);e.m11=i,e.m12=n,e.m21=-1*n,e.m22=i},e.createRotationOut=function(t,e){var i=Math.cos(t),n=Math.sin(t);e.m11=i,e.m12=n,e.m21=-n,e.m22=i},e.createScale=function(t,e,i){i.m11=t,i.m12=0,i.m21=0,i.m22=e,i.m31=0,i.m32=0},e.createScaleOut=function(t,e,i){i.m11=t,i.m12=0,i.m21=0,i.m22=e,i.m31=0,i.m32=0},e.createTranslation=function(t,e,i){return i.m11=1,i.m12=0,i.m21=0,i.m22=1,i.m31=t,i.m32=e,i},e.createTranslationOut=function(t,e){e.m11=1,e.m12=0,e.m21=0,e.m22=1,e.m31=t.x,e.m32=t.y},e.invert=function(t){var e=1/t.determinant(),i=this.identity;return i.m11=t.m22*e,i.m12=-t.m12*e,i.m21=-t.m21*e,i.m22=t.m11*e,i.m31=(t.m32*t.m21-t.m31*t.m22)*e,i.m32=-(t.m32*t.m11-t.m31*t.m12)*e,i},e.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},e.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},e.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},e.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},e.multiply=function(t,e,i){var n=t.m11*e.m11+t.m12*e.m21,r=t.m11*e.m12+t.m12*e.m22,o=t.m21*e.m11+t.m22*e.m21,s=t.m21*e.m12+t.m22*e.m22,a=t.m31*e.m11+t.m32*e.m21+e.m31,h=t.m31*e.m12+t.m32*e.m22+e.m32;i.m11=n,i.m12=r,i.m21=o,i.m22=s,i.m31=a,i.m32=h},e.prototype.determinant=function(){return this.m11*this.m22-this.m12*this.m21},e.lerp=function(t,e,i){return t.m11=t.m11+(e.m11-t.m11)*i,t.m12=t.m12+(e.m12-t.m12)*i,t.m21=t.m21+(e.m21-t.m21)*i,t.m22=t.m22+(e.m22-t.m22)*i,t.m31=t.m31+(e.m31-t.m31)*i,t.m32=t.m32+(e.m32-t.m32)*i,t},e.transpose=function(t){var e=this.identity;return e.m11=t.m11,e.m12=t.m21,e.m21=t.m12,e.m22=t.m22,e.m31=0,e.m32=0,e},e.prototype.mutiplyTranslation=function(i,n){var r=new e;return e.createTranslation(i,n,r),t.MatrixHelper.mutiply(this,r)},e.prototype.equals=function(t){return this==t},e.toMatrix=function(e){var i=new t.Matrix;return i.m11=e.m11,i.m12=e.m12,i.m13=0,i.m14=0,i.m21=e.m21,i.m22=e.m22,i.m23=0,i.m24=0,i.m31=0,i.m32=0,i.m33=1,i.m34=0,i.m41=e.m31,i.m42=e.m32,i.m43=0,i.m44=1,i},e.prototype.toString=function(){return"{m11:"+this.m11+" m12:"+this.m12+" m21:"+this.m21+" m22:"+this.m22+" m31:"+this.m31+" m32:"+this.m32+"}"},e}();t.Matrix2D=e}(es||(es={})),function(t){var e=function(){function e(){}return e.add=function(e,i){var n=t.Matrix2D.identity;return n.m11=e.m11+i.m11,n.m12=e.m12+i.m12,n.m21=e.m21+i.m21,n.m22=e.m22+i.m22,n.m31=e.m31+i.m31,n.m32=e.m32+i.m32,n},e.divide=function(e,i){var n=t.Matrix2D.identity;return n.m11=e.m11/i.m11,n.m12=e.m12/i.m12,n.m21=e.m21/i.m21,n.m22=e.m22/i.m22,n.m31=e.m31/i.m31,n.m32=e.m32/i.m32,n},e.mutiply=function(e,i){var n=t.Matrix2D.identity;if(i instanceof t.Matrix2D){var r=e.m11*i.m11+e.m12*i.m21,o=i.m11*i.m12+e.m12*i.m22,s=e.m21*i.m11+e.m22*i.m21,a=e.m21*i.m12+e.m22*i.m22,h=e.m31*i.m11+e.m32*i.m21+i.m31,c=e.m31*i.m12+e.m32*i.m22+i.m32;n.m11=r,n.m12=o,n.m21=s,n.m22=a,n.m31=h,n.m32=c}else"number"==typeof i&&(n.m11=e.m11*i,n.m12=e.m12*i,n.m21=e.m21*i,n.m22=e.m22*i,n.m31=e.m31*i,n.m32=e.m32*i);return n},e.subtract=function(e,i){var n=t.Matrix2D.identity;return n.m11=e.m11-i.m11,n.m12=e.m12-i.m12,n.m21=e.m21-i.m21,n.m22=e.m22-i.m22,n.m31=e.m31-i.m31,n.m32=e.m32-i.m32,n},e}();t.MatrixHelper=e}(es||(es={})),function(t){var e=function(){function e(e,i,n,r){void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),this.x=0,this.y=0,this.width=0,this.height=0,this._tempMat=new t.Matrix2D,this._transformMat=new t.Matrix2D,this.x=e,this.y=i,this.width=n,this.height=r}return Object.defineProperty(e,"empty",{get:function(){return new e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"maxRect",{get:function(){return new e(Number.MIN_VALUE/2,Number.MIN_VALUE/2,Number.MAX_VALUE,Number.MAX_VALUE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"left",{get:function(){return this.x},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"right",{get:function(){return this.x+this.width},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"top",{get:function(){return this.y},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottom",{get:function(){return this.y+this.height},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return new t.Vector2(this.right,this.bottom)},enumerable:!0,configurable:!0}),e.prototype.isEmpty=function(){return 0==this.width&&0==this.height&&0==this.x&&0==this.y},Object.defineProperty(e.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(e.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}),Object.defineProperty(e.prototype,"center",{get:function(){return new t.Vector2(this.x+this.width/2,this.y+this.height/2)},enumerable:!0,configurable:!0}),e.fromMinMax=function(t,i,n,r){return new e(t,i,n-t,r-i)},e.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)},e.prototype.getSide=function(e){switch(e){case t.Edge.top:return this.top;case t.Edge.bottom:return this.bottom;case t.Edge.left:return this.left;case t.Edge.right:return this.right;default:throw new Error("Argument Out Of Range")}},e.prototype.contains=function(t,e){return this.x<=t&&t<this.x+this.width&&this.y<=e&&e<this.y+this.height},e.prototype.inflate=function(t,e){this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e},e.prototype.intersects=function(t){return t.left<this.right&&this.left<t.right&&t.top<this.bottom&&this.top<t.bottom},e.prototype.rayIntersects=function(t){var e={intersected:!1,distance: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.distance=Math.max(r,e.distance),i=Math.min(o,i),e.distance>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,h=(this.y-t.start.y)*a,c=(this.y+this.height-t.start.y)*a;if(h>c){var l=h;h=c,c=l}if(e.distance=Math.max(h,e.distance),i=Math.max(c,i),e.distance>i)return e}return e.intersected=!0,e},e.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},e.prototype.getHalfSize=function(){return new t.Vector2(.5*this.width,.5*this.height)},e.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},e.prototype.getClosestPointOnRectangleToPoint=function(e){var i=t.Vector2.zero;return i.x=t.MathHelper.clamp(e.x,this.left,this.right),i.y=t.MathHelper.clamp(e.y,this.top,this.bottom),i},e.prototype.getClosestPointOnRectangleBorderToPoint=function(e,i){var n=t.Vector2.zero;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,h=Math.min(r,o,s,a);h==s?(n.y=this.top,i.y=-1):h==a?(n.y=this.bottom,i.y=1):h==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},e.intersect=function(t,i){if(t.intersects(i)){var n=Math.min(t.x+t.width,i.x+i.width),r=Math.max(t.x,i.x),o=Math.max(t.y,i.y);return new e(r,o,n-r,Math.min(t.y+t.height,i.y+i.height)-o)}return new e(0,0,0,0)},e.prototype.offset=function(t,e){this.x+=t,this.y+=e},e.union=function(t,i){var n=Math.min(t.x,i.x),r=Math.min(t.y,i.y);return new e(n,r,Math.max(t.right,i.right)-n,Math.max(t.bottom,i.bottom)-r)},e.overlap=function(t,i){var n=Math.max(t.x,i.x,0),r=Math.max(t.y,i.y,0);return new e(n,r,Math.max(Math.min(t.right,i.right)-n,0),Math.max(Math.min(t.bottom,i.bottom)-r,0))},e.prototype.calculateBounds=function(e,i,n,r,o,s,a){if(0==o)this.x=Math.trunc(e.x+i.x-n.x*r.x),this.y=Math.trunc(e.y+i.y-n.y*r.y),this.width=Math.trunc(s*r.x),this.height=Math.trunc(a*r.y);else{var h=e.x+i.x,c=e.y+i.y;t.Matrix2D.createTranslation(-h-n.x,-c-n.y,this._transformMat),t.Matrix2D.createScale(r.x,r.y,this._tempMat),this._transformMat=this._transformMat.multiply(this._tempMat),t.Matrix2D.createRotation(o,this._tempMat),this._transformMat=this._transformMat.multiply(this._tempMat),t.Matrix2D.createTranslation(h,c,this._tempMat),this._transformMat=this._transformMat.multiply(this._tempMat);var l=new t.Vector2(h,c),u=new t.Vector2(h+s,c),p=new t.Vector2(h,c+a),f=new t.Vector2(h+s,c+a);t.Vector2Ext.transformR(l,this._transformMat,l),t.Vector2Ext.transformR(u,this._transformMat,u),t.Vector2Ext.transformR(p,this._transformMat,p),t.Vector2Ext.transformR(f,this._transformMat,f);var d=Math.trunc(Math.min(l.x,f.x,u.x,p.x)),m=Math.trunc(Math.max(l.x,f.x,u.x,p.x)),y=Math.trunc(Math.min(l.y,f.y,u.y,p.y)),g=Math.trunc(Math.max(l.y,f.y,u.y,p.y));this.location=new t.Vector2(d,y),this.width=Math.trunc(m-d),this.height=Math.trunc(g-y)}},e.prototype.getSweptBroadphaseBounds=function(t,i){var n=e.empty;return n.x=t>0?this.x:this.x+t,n.y=i>0?this.y:this.y+i,n.width=t>0?t+this.width:this.width-t,n.height=i>0?i+this.height:this.height-i,n},e.prototype.collisionCheck=function(t,e,i){e.value=i.value=0;var n=t.x-(this.x+this.width),r=t.x+t.width-this.x,o=t.y-(this.y+this.height),s=t.y+t.height-this.y;return!(n>0||r<0||o>0||s<0)&&(e.value=Math.abs(n)<r?n:r,i.value=Math.abs(o)<s?o:s,Math.abs(e.value)<Math.abs(i.value)?i.value=0:e.value=0,!0)},e.getIntersectionDepth=function(e,i){var n=e.width/2,r=e.height/2,o=i.width/2,s=i.height/2,a=new t.Vector2(e.left+n,e.top+r),h=new t.Vector2(i.left+o,i.top+s),c=a.x-h.x,l=a.y-h.y,u=n+o,p=r+s;if(Math.abs(c)>=u||Math.abs(l)>=p)return t.Vector2.zero;var f=c>0?u-c:-u-c,d=l>0?p-l:-p-l;return new t.Vector2(f,d)},e.prototype.equals=function(t){return this===t},e.prototype.getHashCode=function(){return Math.trunc(this.x)^Math.trunc(this.y)^Math.trunc(this.width)^Math.trunc(this.height)},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e}();t.Rectangle=e}(es||(es={})),function(t){var e=function(){function t(){this.remainder=0}return t.prototype.update=function(t){this.remainder+=t;var e=Math.trunc(this.remainder);return this.remainder-=e,t=e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelFloat=e}(es||(es={})),function(t){var e=function(){function e(){this._x=new t.SubpixelFloat,this._y=new t.SubpixelFloat}return e.prototype.update=function(t){t.x=this._x.update(t.x),t.y=this._y.update(t.y)},e.prototype.reset=function(){this._x.reset(),this._y.reset()},e}();t.SubpixelVector2=e}(es||(es={})),function(t){var e=function(){function e(e){this._activeTriggerIntersections=new t.HashSet,this._previousTriggerIntersections=new t.HashSet,this._tempTriggerList=[],this._entity=e}return e.prototype.update=function(){for(var e,i,n=[],r=this._entity.getComponents(t.Collider),o=0;o<r.length;o++)for(var s=r[o],a=t.Physics.boxcastBroadphaseExcludingSelf(s.bounds,s.collidesWithLayers),h=0;h<a.length;h++){var c=a[h];if((s.isTrigger||c.isTrigger)&&s.overlaps(c)){var l=new t.Pair(s,c);!this._activeTriggerIntersections.contains(l)&&!this._previousTriggerIntersections.contains(l)&&(c.castSortOrder>=t.Collider.lateSortOrder?n.push(l):this.notifyTriggerListeners(l,!0)),this._activeTriggerIntersections.add(l)}}try{for(var u=__values(n),p=u.next();!p.done;p=u.next()){l=p.value;this.notifyTriggerListeners(l,!0)}}catch(t){e={error:t}}finally{try{p&&!p.done&&(i=u.return)&&i.call(u)}finally{if(e)throw e.error}}this.checkForExitedColliders()},e.prototype.checkForExitedColliders=function(){this._previousTriggerIntersections.exceptWith(this._activeTriggerIntersections.toArray());for(var t=0;t<this._previousTriggerIntersections.getCount();t++)this.notifyTriggerListeners(this._previousTriggerIntersections[t],!1);this._previousTriggerIntersections.clear(),this._previousTriggerIntersections.unionWith(this._activeTriggerIntersections.toArray()),this._activeTriggerIntersections.clear()},e.prototype.notifyTriggerListeners=function(e,i){t.TriggerListenerHelper.getITriggerListener(e.first.entity,this._tempTriggerList);for(var n=0;n<this._tempTriggerList.length;n++)if(i?this._tempTriggerList[n].onTriggerEnter(e.second,e.first):this._tempTriggerList[n].onTriggerExit(e.second,e.first),this._tempTriggerList.length=0,e.second.entity){t.TriggerListenerHelper.getITriggerListener(e.second.entity,this._tempTriggerList);for(var r=0;r<this._tempTriggerList.length;r++)i?this._tempTriggerList[r].onTriggerEnter(e.first,e.second):this._tempTriggerList[r].onTriggerExit(e.first,e.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.lineToLine=function(t,e,i,n){var r=e.sub(t),o=n.sub(i),s=r.x*o.y-r.y*o.x;if(0==s)return!1;var a=i.sub(t),h=(a.x*o.y-a.y*o.x)/s;if(h<0||h>1)return!1;var c=(a.x*r.y-a.y*r.x)/s;return!(c<0||c>1)},i.lineToLineIntersection=function(e,i,n,r,o){void 0===o&&(o=t.Vector2.zero),o.x=0,o.y=0;var s=i.sub(e),a=r.sub(n),h=s.x*a.y-s.y*a.x;if(0==h)return!1;var c=n.sub(e),l=(c.x*a.y-c.y*a.x)/h;if(l<0||l>1)return!1;var u=(c.x*s.y-c.y*s.x)/h;if(u<0||u>1)return!1;var p=e.add(s.scale(l));return o.x=p.x,o.y=p.y,!0},i.closestPointOnLine=function(e,i,n){var r=i.sub(e),o=n.sub(e).dot(r)/r.dot(r);return o=t.MathHelper.clamp(o,0,1),e.add(r.scale(o))},i.circleToCircle=function(e,i,n,r){return t.Vector2.sqrDistance(e,n)<(i+r)*(i+r)},i.circleToLine=function(e,i,n,r){return t.Vector2.sqrDistance(e,this.closestPointOnLine(n,r,e))<i*i},i.circleToPoint=function(e,i,n){return t.Vector2.sqrDistance(e,n)<i*i},i.rectToCircle=function(i,n,r){if(this.rectToPoint(i.x,i.y,i.width,i.height,n))return!0;var o,s,a=this.getSector(i.x,i.y,i.width,i.height,n);return!(0==(a&e.top)||(o=new t.Vector2(i.x,i.y),s=new t.Vector2(i.x+i.width,i.y),!this.circleToLine(n,r,o,s)))||(!(0==(a&e.bottom)||(o=new t.Vector2(i.x,i.y+i.width),s=new t.Vector2(i.x+i.width,i.y+i.height),!this.circleToLine(n,r,o,s)))||(!(0==(a&e.left)||(o=new t.Vector2(i.x,i.y),s=new t.Vector2(i.x,i.y+i.height),!this.circleToLine(n,r,o,s)))||!(0==(a&e.right)||(o=new t.Vector2(i.x+i.width,i.y),s=new t.Vector2(i.x+i.width,i.y+i.height),!this.circleToLine(n,r,o,s)))))},i.rectToLine=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,h=void 0,c=void 0;return!(0==(a&e.top)||(h=new t.Vector2(i.x,i.y),c=new t.Vector2(i.x+i.width,i.y),!this.lineToLine(h,c,n,r)))||(!(0==(a&e.bottom)||(h=new t.Vector2(i.x,i.y+i.height),c=new t.Vector2(i.x+i.width,i.y+i.height),!this.lineToLine(h,c,n,r)))||(!(0==(a&e.left)||(h=new t.Vector2(i.x,i.y),c=new t.Vector2(i.x,i.y+i.height),!this.lineToLine(h,c,n,r)))||!(0==(a&e.right)||(h=new t.Vector2(i.x+i.width,i.y),c=new t.Vector2(i.x+i.width,i.y+i.height),!this.lineToLine(h,c,n,r)))))},i.rectToPoint=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(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.setAllValues=function(t,e,i,n,r){this.collider=t,this.fraction=e,this.distance=i,this.point=n,this.normal=r},e.prototype.setValues=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.clone=function(){var t=new e;return t.setAllValues(this.collider,this.fraction,this.distance,this.point,this.normal),t},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 e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize),this._hitArray[0].reset(),this._colliderArray[0]=null},e.clear=function(){this._spatialHash.clear()},e.debugDraw=function(t){this.debugRender&&this._spatialHash.debugDraw(t)},e.overlapCircle=function(t,i,n){return void 0===n&&(n=e.allLayers),this._colliderArray[0]=null,this._spatialHash.overlapCircle(t,i,this._colliderArray,n),this._colliderArray[0]},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.warn("传入了一个空的结果数组。不会返回任何结果")},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.boxcastBroadphaseExcludingSelfNonRect=function(t,e){void 0===e&&(e=this.allLayers);var i=t.bounds;return this._spatialHash.aabbBroadphase(i,t,e)},e.boxcastBroadphaseExcludingSelfDelta=function(t,i,n,r){void 0===r&&(r=e.allLayers);var o=t.bounds.getSweptBroadphaseBounds(i,n);return this._spatialHash.aabbBroadphase(o,t,r)},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.linecast=function(t,i,n,r){return void 0===n&&(n=this.allLayers),void 0===r&&(r=null),this._hitArray[0].reset(),this.linecastAll(t,i,this._hitArray,n),this._hitArray[0].reset(),e.linecastAll(t,i,this._hitArray,n,r),this._hitArray[0].clone()},e.linecastAll=function(t,e,i,n,r){return void 0===n&&(n=this.allLayers),void 0===r&&(r=null),this._spatialHash.linecast(t,e,i,n,r)},e.overlapRectangle=function(t,i){return void 0===i&&(i=e.allLayers),this._colliderArray[0]=null,this._spatialHash.overlapRectangle(t,this._colliderArray,i),this._colliderArray[0]},e.overlapRectangleAll=function(t,i,n){return void 0===n&&(n=e.allLayers),0==i.length?(console.warn("传入了一个空的结果数组。不会返回任何结果"),0):this._spatialHash.overlapRectangle(t,i,n)},e.gravity=new t.Vector2(0,-300),e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e.debugRender=!1,e._hitArray=[new t.RaycastHit],e._colliderArray=[null],e}();t.Physics=e}(es||(es={})),function(t){var e=function(){function t(t,e){this._start=t.clone(),this._end=e.clone(),this._direction=this._end.sub(this._start)}return Object.defineProperty(t.prototype,"start",{get:function(){return this._start},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"end",{get:function(){return this._end},enumerable:!0,configurable:!0}),t}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestBox=new t.Box(0,0),this._overlapTestCircle=new t.Circle(0),this._cellDict=new i,this._tempHashSet=new Set,this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new n}return e.prototype.register=function(e){var i=e.bounds.clone();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++){this.cellAtPosition(o,s,!0).push(e)}},e.prototype.remove=function(e){for(var i=e.registeredPhysicsBounds.clone(),n=this.cellCoords(i.x,i.y),r=this.cellCoords(i.right,i.bottom),o=n.x;o<=r.x;o++)for(var s=n.y;s<=r.y;s++){var a=this.cellAtPosition(o,s);t.Insist.isNotNull(a,"从不存在碰撞器的单元格中移除碰撞器: ["+e+"]"),null!=a&&new t.List(a).remove(e)}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.debugDraw=function(t){for(var e=this.gridBounds.x;e<=this.gridBounds.right;e++)for(var i=this.gridBounds.y;i<=this.gridBounds.bottom;i++){var n=this.cellAtPosition(e,i);null!=n&&n.length>0&&this.debugDrawCellDetails(e,i,t)}},e.prototype.debugDrawCellDetails=function(e,i,n){void 0===n&&(n=.5),t.Graphics.instance.batcher.drawHollowRect(e*this._cellSize,i*this._cellSize,this._cellSize,this._cellSize,new t.Color(255,0,0),n),t.Graphics.instance.batcher.end()},e.prototype.aabbBroadphase=function(e,i,n){this._tempHashSet.clear();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 h=this.cellAtPosition(s,a);if(h)for(var c=0;c<h.length;c++){var l=h[c];l!=i&&t.Flags.isFlagSet(n,l.physicsLayer.value)&&(e.intersects(l.bounds)&&this._tempHashSet.add(l))}}return Array.from(this._tempHashSet)},e.prototype.linecast=function(e,i,n,r,o){var s=new t.Ray2D(e,i);this._raycastParser.start(s,n,r,o);var a=this.cellCoords(e.x,e.y),h=this.cellCoords(i.x,i.y),c=Math.sign(s.direction.x),l=Math.sign(s.direction.y);a.x==h.x&&(c=0),a.y==h.y&&(l=0);var u=c<0?0:c,p=l<0?0:l,f=(a.x+u)*this._cellSize,d=(a.y+p)*this._cellSize,m=0!=s.direction.x?(f-s.start.x)/s.direction.x:Number.MAX_VALUE,y=0!=s.direction.y?(d-s.start.y)/s.direction.y:Number.MAX_VALUE,g=0!=s.direction.x?this._cellSize/(s.direction.x*c):Number.MAX_VALUE,_=0!=s.direction.y?this._cellSize/(s.direction.y*l):Number.MAX_VALUE,v=this.cellAtPosition(a.x,a.y);if(null!=v&&this._raycastParser.checkRayIntersection(a.x,a.y,v))return this._raycastParser.reset(),this._raycastParser.hitCounter;for(;a.x!=h.x||a.y!=h.y;)if(m<y?(a.x=t.MathHelper.approach(a.x,h.x,Math.abs(c)),m+=g):(a.y=t.MathHelper.approach(a.y,h.y,Math.abs(l)),y+=_),(v=this.cellAtPosition(a.x,a.y))&&this._raycastParser.checkRayIntersection(a.x,a.y,v))return this._raycastParser.reset(),this._raycastParser.hitCounter;return this._raycastParser.reset(),this._raycastParser.hitCounter},e.prototype.overlapRectangle=function(e,i,n){var r,o;this._overlapTestBox.updateBox(e.width,e.height),this._overlapTestBox.position=e.location.clone();var s=0,a=this.aabbBroadphase(e,null,n);try{for(var h=__values(a),c=h.next();!c.done;c=h.next()){var l=c.value;if(l instanceof t.BoxCollider)i[s]=l,s++;else if(l instanceof t.CircleCollider)t.Collisions.rectToCircle(e,l.bounds.center,.5*l.bounds.width)&&(i[s]=l,s++);else{if(!(l instanceof t.PolygonCollider))throw new Error("overlapRectangle对这个类型没有实现!");l.shape.overlaps(this._overlapTestBox)&&(i[s]=l,s++)}if(s==i.length)return s}}catch(t){r={error:t}}finally{try{c&&!c.done&&(o=h.return)&&o.call(h)}finally{if(r)throw r.error}}return s},e.prototype.overlapCircle=function(e,i,n,r){var o,s,a=new t.Rectangle(e.x-i,e.y-i,2*i,2*i);this._overlapTestCircle.radius=i,this._overlapTestCircle.position=e.clone();var h=0,c=this.aabbBroadphase(a,null,r);try{for(var l=__values(c),u=l.next();!u.done;u=l.next()){var p=u.value;if(p instanceof t.BoxCollider)p.shape.overlaps(this._overlapTestCircle)&&(n[h]=p,h++);else if(p instanceof t.CircleCollider)p.shape.overlaps(this._overlapTestCircle)&&(n[h]=p,h++);else{if(!(p instanceof t.PolygonCollider))throw new Error("对这个对撞机类型的overlapCircle没有实现!");p.shape.overlaps(this._overlapTestCircle)&&(n[h]=p,h++)}if(h==n.length)return h}}catch(t){o={error:t}}finally{try{u&&!u.done&&(s=l.return)&&s.call(l)}finally{if(o)throw o.error}}return h},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}();t.SpatialHash=e;var i=function(){function e(){this._store=new Map}return e.prototype.add=function(t,e,i){this._store.set(this.getKey(t,e),i)},e.prototype.remove=function(e){this._store.forEach(function(i){var n=new t.List(i);n.contains(e)&&n.remove(e)})},e.prototype.tryGetValue=function(t,e){return this._store.get(this.getKey(t,e))},e.prototype.getKey=function(t,e){return t+"_"+e},e.prototype.clear=function(){this._store.clear()},e}();t.NumberDictionary=i;var n=function(){function e(){this._tempHit=new t.RaycastHit,this._checkedColliders=[],this._cellHits=[]}return e.prototype.start=function(t,e,i,n){this._ray=t,this._hits=e,this._layerMask=i,this._ignoredColliders=n,this.hitCounter=0},e.prototype.checkRayIntersection=function(i,n,r){for(var o=0;o<r.length;o++){var s=r[o];if(!new t.List(this._checkedColliders).contains(s)&&(this._checkedColliders.push(s),(!s.isTrigger||t.Physics.raycastsHitTriggers)&&t.Flags.isFlagSet(this._layerMask,s.physicsLayer.value)&&(!this._ignoredColliders||!this._ignoredColliders.has(s)))){var a=s.bounds.rayIntersects(this._ray);if(a.intersected&&a.distance<=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,this._ignoredColliders=null},e.compareRaycastHits=function(t,e){return t.distance!==e.distance?t.distance-e.distance:t.collider.castSortOrder-e.collider.castSortOrder},e}();t.RaycastResultParser=n}(es||(es={})),function(t){var e=function(){return function(){}}();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),i.prototype.create=function(t,e){i.buildSymmetricalPolygon(t,e)},Object.defineProperty(i.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),i.prototype.setPoints=function(t){var e=this;this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=[],this.points.forEach(function(t){e._originalPoints.push(t.clone())})},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);t.Vector2Ext.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]=new t.Vector2(Math.cos(o)*i,Math.sin(o)*i)}return n},i.recenterPolygonVerts=function(t){for(var e=this.findPolygonCenter(t),i=0;i<t.length;i++)t[i]=t[i].sub(e)},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(t,e){for(var i=0,n=t[i].dot(e),r=1;r<t.length;r++){var o=t[r].dot(e);o>n&&(n=o,i=r)}return t[i]},i.getClosestPointOnPolygonToPoint=function(e,i){for(var n={distanceSquared:Number.MAX_VALUE,edgeNormal:t.Vector2.zero,closestPoint:t.Vector2.zero},r=0,o=0;o<e.length;o++){var s=o+1;s===e.length&&(s=0);var a=t.ShapeCollisionsCircle.closestPointOnLine(e[o],e[s],i);if((r=t.Vector2.sqrDistance(i,a))<n.distanceSquared){n.distanceSquared=r,n.closestPoint=a;var h=e[s].sub(e[o]);n.edgeNormal.x=h.y,n.edgeNormal.y=-h.x}}return n.edgeNormal=n.edgeNormal.normalize(),n},i.rotatePolygonVerts=function(e,i,n){for(var r=Math.cos(e),o=Math.sin(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){var i=this;if(this.center=e.localOffset,e.shouldColliderScaleAndRotateWithTransform){var n=!0,r=new t.Matrix2D,o=new t.Matrix2D;if(t.Matrix2D.createTranslation(-1*this._polygonCenter.x,-1*this._polygonCenter.y,o),!e.entity.transform.scale.equals(t.Vector2.one)){t.Matrix2D.createScale(e.entity.scale.x,e.entity.scale.y,r),t.Matrix2D.multiply(o,r,o),n=!1;var s=new t.Vector2(e.localOffset.x*e.entity.scale.x,e.localOffset.y*e.entity.scale.y);this.center=s}if(0!=e.entity.transform.rotation){t.Matrix2D.createRotation(t.MathHelper.Deg2Rad*e.entity.rotation,r),t.Matrix2D.multiply(o,r,o);var a=Math.atan2(e.localOffset.y*e.entity.transform.scale.y,e.localOffset.x*e.entity.transform.scale.x)*t.MathHelper.Rad2Deg,h=n?e._localOffsetLength:e.localOffset.multiply(e.entity.transform.scale).magnitude();this.center=t.MathHelper.pointOnCirlce(t.Vector2.zero,h,e.entity.transform.rotationDegrees+a)}t.Matrix2D.createTranslation(this._polygonCenter.x,this._polygonCenter.y,r),t.Matrix2D.multiply(o,r,o),this.points=[],this._originalPoints.forEach(function(t){i.points.push(t.transform(o))}),this.isUnrotated=0==e.entity.transform.rotation,e._isRotationDirty&&(this._areEdgeNormalsDirty=!0)}this.position=e.transform.position.add(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.ShapeCollisionsPolygon.polygonToPolygon(this,e,n);if(e instanceof t.Circle)return!!t.ShapeCollisionsCircle.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.ShapeCollisionsPolygon.polygonToPolygon(this,e,n);if(e instanceof t.Circle)return!!t.ShapeCollisionsCircle.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.ShapeCollisionsLine.lineToPoly(e,i,this,n)},i.prototype.containsPoint=function(t){t=t.sub(this.position);for(var e=!1,i=0,n=this.points.length-1;i<this.points.length;n=i++)this.points[i].y>t.y!=this.points[n].y>t.y&&t.x<(this.points[n].x-this.points[i].x)*(t.y-this.points[i].y)/(this.points[n].y-this.points[i].y)+this.points[i].x&&(e=!e);return e},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisionsPoint.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.rectToCircle(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.ShapeCollisionsBox.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.ShapeCollisionsPoint.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:e.localOffset.multiply(e.entity.transform.scale).magnitude();this.center=t.MathHelper.pointOnCirlce(t.Vector2.zero,s,e.entity.transform.rotation+o)}}this.position=e.transform.position.add(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.rectToCircle(e.bounds,this.position,this.radius);if(e instanceof i)return t.Collisions.circleToCircle(this.position,this.radius,e.position,e.radius);if(e instanceof t.Polygon)return t.ShapeCollisionsCircle.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.ShapeCollisionsCircle.circleToBox(this,e,n);if(e instanceof i)return t.ShapeCollisionsCircle.circleToCircle(this,e,n);if(e instanceof t.Polygon)return t.ShapeCollisionsCircle.circleToPolygon(this,e,n);throw new Error("Collisions of Circle to "+e+" are not supported")},i.prototype.collidesWithLine=function(e,i,n){return t.ShapeCollisionsLine.lineToCircle(e,i,this,n)},i.prototype.getPointAlongEdge=function(e){return new t.Vector2(this.position.x+this.radius*Math.cos(e),this.position.y+this.radius*Math.sin(e))},i.prototype.containsPoint=function(t){return t.sub(this.position).lengthSquared()<=this.radius*this.radius},i.prototype.pointCollidesWithShape=function(e,i){return t.ShapeCollisionsPoint.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.reset=function(){this.collider=null,this.normal.setTo(0,0),this.minimumTranslationVector.setTo(0,0),this.point&&this.point.setTo(0,0)},e.prototype.cloneTo=function(e){e.collider=this.collider,e.normal.setTo(this.normal.x,this.normal.y),e.minimumTranslationVector.setTo(this.minimumTranslationVector.x,this.minimumTranslationVector.y),this.point&&(e.point||(e.point=new t.Vector2(0,0)),e.point.setTo(this.point.x,this.point.y))},e.prototype.removeHorizontalTranslation=function(e){if(Math.sign(this.normal.x)!==Math.sign(e.x)||0===e.x&&0!==this.normal.x){var i=this.minimumTranslationVector.magnitude()/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(){this.minimumTranslationVector=this.minimumTranslationVector.negate(),this.normal=this.normal.negate()},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.intersectMovingCircleBox=function(e,i,n,r){var o=i.bounds;o.inflate(e.radius,e.radius);var s=new t.Ray2D(e.position.sub(n),e.position),a=o.rayIntersects(s);if(!a.intersected&&a.distance>1)return!1;var h,c=s.start.add(s.direction.scale(r)),l=0;c.x<i.bounds.left&&(h|=1),c.x>i.bounds.right&&(l|=1),c.y<i.bounds.top&&(h|=2),c.y>i.bounds.bottom&&(l|=2);var u=h+l;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),!0},e.corner=function(e,i){var n=t.Vector2.zero;return n.x=0==(1&i)?e.right:e.left,n.y=0==(1&i)?e.bottom:e.top,n},e.testCircleBox=function(t,e,i){var n=e.bounds.getClosestPointOnRectangleToPoint(t.position).sub(t.position);return n.dot(n)<=t.radius*t.radius},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return 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=n.minimumTranslationVector.scale(-1),n.normal=n.normal.normalize(),!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,-s.y),r.normal=r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,n.scale(-1)),h=o.rayIntersects(a);return!!(h.intersected&&h.distance<=1)&&(r.fraction=h.distance,r.distance=n.magnitude()*h.distance,r.normal=n.scale(-1),r.normal=r.normal.normalize(),r.centroid=e.bounds.center.add(n.scale(h.distance)),!0)},e.minkowskiDifference=function(e,i){var n=e.position.sub(e.bounds.center),r=e.bounds.location.add(n.sub(i.bounds.max)),o=e.bounds.size.add(i.bounds.size);return new t.Rectangle(r.x,r.y,o.x,o.y)},e}();t.ShapeCollisionsBox=e}(es||(es={})),function(t){var e=function(){function e(){}return e.circleToCircleCast=function(e,i,n,r){var o=e.position.add(n),s=this.closestPointOnLine(e.position,o,i.position),a=t.Vector2.sqrDistance(i.position,s),h=(e.radius+i.radius)*(e.radius+i.radius);if(a<=h){var c=n.normalize();s===o&&(o=e.position.add(n.add(c.scale(i.radius))),s=this.closestPointOnLine(e.position,o,i.position),a=t.Vector2.sqrDistance(i.position,s));var l=Math.sqrt(h-a);return r.centroid=s.sub(c.scale(l)),r.normal=r.centroid.sub(i.position).normalize(),r.fraction=(r.centroid.x-e.position.x)/n.x,r.distance=t.Vector2.distance(e.position,r.centroid),r.point=i.position.add(r.normal.scale(i.radius)),!0}return!1},e.circleToCircle=function(e,i,n){void 0===n&&(n=new t.CollisionResult);var r=t.Vector2.sqrDistance(e.position,i.position),o=e.radius+i.radius;if(r<o*o){n.normal=e.position.sub(i.position).normalize();var s=o-Math.sqrt(r);return n.minimumTranslationVector=n.normal.scale(-s),n.point=i.position.add(n.normal.scale(i.radius)),!0}return!1},e.circleToBox=function(e,i,n){void 0===n&&(n=new t.CollisionResult);var r=i.bounds.getClosestPointOnRectangleBorderToPoint(e.position,n.normal);if(i.containsPoint(e.position)){n.point=r;var o=r.add(n.normal.scale(e.radius));return n.minimumTranslationVector=e.position.sub(o),!0}var s=t.Vector2.sqrDistance(r,e.position);if(0==s)n.minimumTranslationVector=n.normal.scale(e.radius);else if(s<=e.radius*e.radius){n.normal=e.position.sub(r);var a=n.normal.magnitude()-e.radius;return n.point=r,n.normal=n.normal.normalize(),n.minimumTranslationVector=n.normal.scale(a),!0}return!1},e.circleToPolygon=function(e,i,n){void 0===n&&(n=new t.CollisionResult);var r=e.position.sub(i.position),o=t.Polygon.getClosestPointOnPolygonToPoint(i.points,r);n.normal=o.edgeNormal;var s,a=i.containsPoint(e.position);if(o.distanceSquared>e.radius*e.radius&&!a)return!1;if(a)s=n.normal.scale(Math.sqrt(o.distanceSquared)-e.radius);else if(0===o.distanceSquared)s=n.normal.scale(e.radius);else{var h=Math.sqrt(o.distanceSquared);s=r.sub(o.closestPoint).scale((e.radius-h)/h*-1)}return n.minimumTranslationVector=s,n.point=o.closestPoint.add(i.position),!0},e.closestPointOnLine=function(e,i,n){var r=i.sub(e),o=n.sub(e).dot(r)/r.dot(r);return o=t.MathHelper.clamp(o,0,1),e.add(r.scaleEqual(o))},e}();t.ShapeCollisionsCircle=e}(es||(es={})),function(t){var e=function(){function e(){}return e.lineToPoly=function(i,n,r,o){void 0===o&&(o=new t.RaycastHit);for(var s=t.Vector2.zero,a=t.Vector2.zero,h=Number.MAX_VALUE,c=!1,l=r.points.length-1,u=0;u<r.points.length;l=u,u++){var p=t.Vector2.add(r.position,r.points[l]),f=t.Vector2.add(r.position,r.points[u]),d=t.Vector2.zero;if(e.lineToLine(p,f,i,n,d)){c=!0;var m=(d.x-i.x)/(n.x-i.x);if((Number.isNaN(m)||Math.abs(m)==1/0)&&(m=(d.y-i.y)/(n.y-i.y)),m<h){var y=f.sub(p);s=new t.Vector2(y.y,-y.x),h=m,a=d}}}if(c){s=s.normalize();var g=t.Vector2.distance(i,a);return o.setValues(h,g,a,s),!0}return!1},e.lineToLine=function(t,e,i,n,r){var o=e.sub(t),s=n.sub(i),a=o.x*s.y-o.y*s.x;if(0==a)return!1;var h=i.sub(t),c=(h.x*s.y-h.y*s.x)/a;if(c<0||c>1)return!1;var l=(h.x*o.y-h.y*o.x)/a;if(l<0||l>1)return!1;var u=t.add(o.scale(c));return r.x=u.x,r.y=u.y,!0},e.lineToCircle=function(e,i,n,r){var o=t.Vector2.distance(e,i),s=t.Vector2.divideScaler(i.sub(e),o),a=e.sub(n.position),h=a.dot(s),c=a.dot(a)-n.radius*n.radius;if(c>0&&h>0)return!1;var l=h*h-c;return!(l<0)&&(r.fraction=-h-Math.sqrt(l),r.fraction<0&&(r.fraction=0),r.point=e.add(s.scale(r.fraction)),r.distance=t.Vector2.distance(e,r.point),r.normal=r.point.sub(n.position).normalize(),r.fraction=r.distance/o,!0)},e}();t.ShapeCollisionsLine=e}(es||(es={})),function(t){var e=function(){function e(){}return e.pointToCircle=function(e,i,n){var r=t.Vector2.sqrDistance(e,i.position),o=1+i.radius;if(r<o*o){n.normal=e.sub(i.position).normalize();var s=o-Math.sqrt(r);return n.minimumTranslationVector=n.normal.scale(-s),n.point=i.position.add(n.normal.scale(i.radius)),!0}return!1},e.pointToBox=function(e,i,n){return void 0===n&&(n=new t.CollisionResult),!!i.containsPoint(e)&&(n.point=i.bounds.getClosestPointOnRectangleBorderToPoint(e,n.normal),n.minimumTranslationVector=e.sub(n.point),!0)},e.pointToPoly=function(e,i,n){if(void 0===n&&(n=new t.CollisionResult),i.containsPoint(e)){var r=t.Polygon.getClosestPointOnPolygonToPoint(i.points,e.sub(i.position));return n.normal=r.edgeNormal,n.minimumTranslationVector=n.normal.scale(Math.sqrt(r.distanceSquared)),n.point=r.closestPoint.sub(i.position),!0}return!1},e}();t.ShapeCollisionsPoint=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,h=Number.POSITIVE_INFINITY,c=t.Vector2.zero,l=e.position.sub(i.position),u=0;u<s.length+a.length;u++){r=u<s.length?s[u]:a[u-s.length];var p=0,f=this.getInterval(r,e),d=f.min,m=f.max,y=this.getInterval(r,i),g=y.min,_=y.max,v=l.dot(r);if(d+=v,m+=v,(p=this.intervalDistance(d,m,g,_))>0&&(o=!1),!o)return!1;(p=Math.abs(p))<h&&(h=p,c.setTo(r.x,r.y),c.dot(l)<0&&(c=c.scale(-1)))}return n.normal=c,n.minimumTranslationVector=c.scale(-h),!0},e.getInterval=function(t,e){var i,n={min:0,max:0};i=e.points[0].dot(t),n.max=i,n.min=i;for(var r=1;r<e.points.length;r++)(i=e.points[r].dot(t))<n.min?n.min=i:i>n.max&&(n.max=i);return n},e.intervalDistance=function(t,e,i,n){return t<i?i-e:t-n},e}();t.ShapeCollisionsPolygon=e}(es||(es={})),function(t){var e=function(){function e(e){this.mass=1,this.collidesWithColliders=!0,this.position=new t.Vector2(e.x,e.y),this.lastPosition=new t.Vector2(e.x,e.y)}return e.prototype.applyForce=function(t){this.acceleration=this.acceleration.add(t.divideScaler(this.mass))},e.prototype.pin=function(){return this.isPinned=!0,this.pinnedPosition=this.position,this},e.prototype.pinTo=function(t){return this.isPinned=!0,this.pinnedPosition=t,this.position=this.pinnedPosition,this},e.prototype.unpin=function(){return this.isPinned=!1,this},e}();t.Particle=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=null),this.gravity=new t.Vector2(0,980),this.constraintIterations=3,this.maximumStepIterations=5,this.allowDragging=!0,this.selectionRadiusSquared=400,this._composites=[],this._tempCircle=new t.Circle(1),this._fixedDeltaTime=1/60,this.simulationBounds=e,this._fixedDeltaTime=Math.pow(this._fixedDeltaTime,2)}return e.prototype.update=function(){this.updateTiming(),this.allowDragging&&this.handleDragging();for(var t=1;t<=this._iterationSteps;t++)for(var e=this._composites.length-1;e>=0;e--){for(var i=this._composites[e],n=0;n<this.constraintIterations;n++)i.solveConstraints();i.updateParticles(this._fixedDeltaTimeSq,this.gravity),i.handleConstraintCollisions();for(var r=0;r<i.particles.length;r++){var o=i.particles[r];this.simulationBounds&&this.constrainParticleToBounds(o),o.collidesWithColliders&&this.handleCollisions(o,i.collidesWithLayers)}}},e.prototype.constrainParticleToBounds=function(t){var e=t.position,i=this.simulationBounds;0==t.radius?(e.y>i.height?e.y=i.height:e.y<i.y&&(e.y=i.y),e.x<i.x?e.x=i.x:e.x>i.width&&(e.x=i.width)):(e.y<i.y+t.radius&&(e.y=2*(i.y+t.radius)-e.y),e.y>i.height-t.radius&&(e.y=2*(i.height-t.radius)-e.y),e.x>i.width-t.radius&&(e.x=2*(i.width-t.radius)-e.x),e.x<i.x+t.radius&&(e.x=2*(i.x+t.radius)-e.x)),t.position=e},e.prototype.handleCollisions=function(i,n){for(var r=t.Physics.overlapCircleAll(i.position,i.radius,e._colliders,n),o=0;o<r;o++){var s=e._colliders[o];if(!s.isTrigger){var a=new t.CollisionResult;i.radius<2?s.shape.pointCollidesWithShape(i.position,a)&&(i.position=i.position.sub(a.minimumTranslationVector)):(this._tempCircle.radius=i.radius,this._tempCircle.position=i.position,this._tempCircle.collidesWithShape(s.shape,a)&&(i.position=i.position.sub(a.minimumTranslationVector)))}}},e.prototype.updateTiming=function(){this._leftOverTime+=t.Time.deltaTime,this._iterationSteps=Math.trunc(this._leftOverTime/this._fixedDeltaTime),this._leftOverTime-=this._iterationSteps*this._fixedDeltaTime,this._iterationSteps=Math.min(this._iterationSteps,this.maximumStepIterations)},e.prototype.addComposite=function(t){return this._composites.push(t),t},e.prototype.removeComposite=function(t){var e=this._composites.indexOf(t);this._composites.splice(e,1)},e.prototype.handleDragging=function(){},e.prototype.getNearestParticle=function(e){for(var i=this.selectionRadiusSquared,n=null,r=0;r<this._composites.length;r++)for(var o=this._composites[r].particles,s=0;s<o.length;s++){var a=o[s],h=t.Vector2.sqrDistance(a.position,e);h<=this.selectionRadiusSquared&&(null==n||h<i)&&(n=a,i=h)}return n},e.prototype.debugRender=function(e){for(var i=0;i<this._composites.length;i++)this._composites[i].debugRender(e);this.allowDragging&&null!=this._draggedParticle&&e.drawCircle(this._draggedParticle.position,8,t.Color.White)},e._colliders=[],e}();t.VerletWorld=e}(es||(es={})),function(t){var e=function(){function e(){this.friction=new t.Vector2(.98,1),this.drawParticles=!0,this.drawConstraints=!0,this.collidesWithLayers=t.Physics.allLayers,this.particles=[],this._constraints=[]}return e.prototype.addParticle=function(t){return this.particles.push(t),t},e.prototype.removeParticle=function(t){var e=this.particles.indexOf(t);this.particles.splice(e,1)},e.prototype.removeAll=function(){this.particles.length=0,this._constraints.length=0},e.prototype.addConstraint=function(t){return this._constraints.push(t),t.composite=this,t},e.prototype.removeConstraint=function(t){var e=this._constraints.indexOf(t);this._constraints.splice(e,1)},e.prototype.applyForce=function(t){for(var e=0;e<this.particles.length;e++)this.particles[e].applyForce(t)},e.prototype.solveConstraints=function(){for(var t=this._constraints.length-1;t>=0;t--)this._constraints[t].solve()},e.prototype.updateParticles=function(t,e){for(var i=0;i<this.particles.length;i++){var n=this.particles[i];if(n.isPinned)n.position=n.pinnedPosition;else{n.applyForce(e.scale(n.mass));var r=n.position.sub(n.lastPosition).multiply(this.friction),o=n.position.add(r).add(n.acceleration.scale(.5*t));n.lastPosition=n.position,n.position=o,n.acceleration.x=n.acceleration.y=0}}},e.prototype.handleConstraintCollisions=function(){for(var t=this._constraints.length-1;t>=0;t--)this._constraints[t].collidesWithColliders&&this._constraints[t].handleCollisions(this.collidesWithLayers)},e.prototype.debugRender=function(e){if(this.drawConstraints)for(var i=0;i<this._constraints.length;i++)this._constraints[i].debugRender(e);if(this.drawParticles)for(i=0;i<this.particles.length;i++)0==this.particles[i].radius?e.drawPixel(this.particles[i].position,new t.Color(220,52,94),4):e.drawCircleLow(this.particles[i].position,this.particles[i].radius,new t.Color(220,52,94),1,4)},e}();t.Composite=e}(es||(es={})),function(t){var e=function(e){function i(i,n){void 0===n&&(n=10);var r=e.call(this)||this;return r.addParticle(new t.Particle(i)).radius=n,r}return __extends(i,e),i}(t.Composite);t.Ball=e}(es||(es={})),function(t){var e=function(e){function i(i,n,r,o,s){void 0===o&&(o=.2),void 0===s&&(s=.5);var a=e.call(this)||this,h=a.addParticle(new t.Particle(i.add(new t.Vector2(-n/2,-r/2)))),c=a.addParticle(new t.Particle(i.add(new t.Vector2(n/2,-r/2)))),l=a.addParticle(new t.Particle(i.add(new t.Vector2(n/2,r/2)))),u=a.addParticle(new t.Particle(i.add(new t.Vector2(-n/2,r/2))));return a.addConstraint(new t.DistanceConstraint(h,c,o)),a.addConstraint(new t.DistanceConstraint(c,l,o)),a.addConstraint(new t.DistanceConstraint(l,u,o)),a.addConstraint(new t.DistanceConstraint(u,h,o)),a.addConstraint(new t.DistanceConstraint(h,l,s)).setCollidesWithColliders(!1),a.addConstraint(new t.DistanceConstraint(u,c,s)).setCollidesWithColliders(!1),a}return __extends(i,e),i}(t.Composite);t.VerletBox=e}(es||(es={})),function(t){var e=function(e){function i(i,n){for(var r=e.call(this)||this,o=0;o<i.length;o++){var s=new t.Particle(i[o]);r.addParticle(s),o>0&&r.addConstraint(new t.DistanceConstraint(r.particles[o],r.particles[o-1],n))}return r}return __extends(i,e),i.prototype.pinParticleAtIndex=function(t){return this.particles[t].pin(),this},i}(t.Composite);t.LineSegments=e}(es||(es={})),function(t){var e=function(){function t(){this.collidesWithColliders=!0}return t.prototype.handleCollisions=function(t){},t.prototype.debugRender=function(t){},t}();t.Constraint=e}(es||(es={})),function(t){var e=function(e){function i(t,i,n,r){var o=e.call(this)||this;return o._particleA=t,o._centerParticle=i,o._particleC=n,o.stiffness=r,o.collidesWithColliders=!1,o.angleInRadius=o.angleBetweenParticles(),o}return __extends(i,e),i.prototype.angleBetweenParticles=function(){var t=this._particleA.position.sub(this._centerParticle.position),e=this._particleC.position.sub(this._centerParticle.position);return Math.atan2(t.x*e.y-t.y*e.x,t.x*e.x+t.y*e.y)},i.prototype.solve=function(){var e=this.angleBetweenParticles()-this.angleInRadius;e<=-Math.PI?e+=2*Math.PI:e>=Math.PI&&(e-=2*Math.PI),e*=this.stiffness,this._particleA.position=t.MathHelper.rotateAround2(this._particleA.position,this._centerParticle.position,e),this._particleC.position=t.MathHelper.rotateAround2(this._particleC.position,this._centerParticle.position,-e),this._centerParticle.position=t.MathHelper.rotateAround2(this._centerParticle.position,this._particleA.position,e),this._centerParticle.position=t.MathHelper.rotateAround2(this._centerParticle.position,this._particleC.position,-e)},i}(t.Constraint);t.AngleConstraint=e}(es||(es={})),function(t){var e=function(e){function i(n,r,o,s){void 0===s&&(s=-1);var a=e.call(this)||this;return a.tearSensitivity=Number.POSITIVE_INFINITY,a.totalPointsToApproximateCollisionsWith=5,i._polygon.create(2,1),a._particleOne=n,a._particleTwo=r,a.stiffness=o,a.restingDistance=s>-1?s:t.Vector2.distance(n.position,r.position),a}return __extends(i,e),i.create=function(e,n,r,o,s){var a=t.Vector2.distance(e.position,n.position),h=t.Vector2.distance(r.position,n.position);return new i(e,r,o,Math.sqrt(a*a+h*h-2*a*h*Math.cos(s*t.MathHelper.Deg2Rad)))},i.prototype.setTearSensitivity=function(t){return this.tearSensitivity=t,this},i.prototype.setCollidesWithColliders=function(t){return this.collidesWithColliders=t,this},i.prototype.setShouldApproximateCollisionsWithPoints=function(t){return this.shouldApproximateCollisionsWithPoints=t,this},i.prototype.solve=function(){var t=this._particleOne.position.sub(this._particleTwo.position),e=t.magnitude(),i=(this.restingDistance-e)/e;if(e/this.restingDistance>this.tearSensitivity)this.composite.removeConstraint(this);else{var n=1/this._particleOne.mass,r=n/(n+1/this._particleTwo.mass)*this.stiffness,o=this.stiffness-r;this._particleOne.position=this._particleOne.position.add(t.scale(r*i)),this._particleTwo.position=this._particleTwo.position.sub(t.scale(o*i))}},i.prototype.handleCollisions=function(e){if(this.shouldApproximateCollisionsWithPoints)this.approximateCollisionsWithPoints(e);else{var n=Math.min(this._particleOne.position.x,this._particleTwo.position.x),r=Math.max(this._particleOne.position.x,this._particleTwo.position.x),o=Math.min(this._particleOne.position.y,this._particleTwo.position.y),s=Math.max(this._particleOne.position.y,this._particleTwo.position.y);i._polygon.bounds=t.Rectangle.fromMinMax(n,o,r,s),this.preparePolygonForCollisionChecks(void 0);for(var a=t.Physics.boxcastBroadphase(i._polygon.bounds,e),h=0;h<a.length;h++){var c=a[h],l=new t.CollisionResult;i._polygon.collidesWithShape(c.shape,l)&&(this._particleOne.position=this._particleOne.position.sub(l.minimumTranslationVector),this._particleTwo.position=this._particleTwo.position.sub(l.minimumTranslationVector))}}},i.prototype.approximateCollisionsWithPoints=function(e){for(var i,n=0;n<this.totalPointsToApproximateCollisionsWith-1;n++){i=t.Vector2.lerp(this._particleOne.position,this._particleTwo.position,(n+1)/this.totalPointsToApproximateCollisionsWith);for(var r=t.Physics.overlapCircleAll(i,3,t.VerletWorld._colliders,e),o=0;o<r;o++){var s=t.VerletWorld._colliders[o],a=new t.CollisionResult;s.shape.pointCollidesWithShape(i,a)&&(this._particleOne.position=this._particleOne.position.sub(a.minimumTranslationVector),this._particleTwo.position=this._particleTwo.position.sub(a.minimumTranslationVector))}}},i.prototype.preparePolygonForCollisionChecks=function(e){var n=t.Vector2.lerp(this._particleOne.position,this._particleTwo.position,.5);e.setTo(n.x,n.y),i._polygon.position=e,i._polygon.points[0]=this._particleOne.position.sub(i._polygon.position),i._polygon.points[1]=this._particleTwo.position.sub(i._polygon.position),i._polygon.recalculateCenterAndEdgeNormals()},i.prototype.debugRender=function(e){e.drawLine(this._particleOne.position,this._particleTwo.position,new t.Color(67,62,54),1)},i._polygon=new t.Polygon([]),i}(t.Constraint);t.DistanceConstraint=e}(es||(es={})),function(t){var e=function(){function e(t){if(t.length<2)throw new Error("curve length must be >= 2");if(t.sort(function(t,e){return t.t-e.t}),0!==t[0].t)throw new Error("curve must start with 0");if(1!==t[t.length-1].t)throw new Error("curve must end with 1");this._points=t}return Object.defineProperty(e.prototype,"points",{get:function(){return this._points},enumerable:!0,configurable:!0}),e.prototype.lerp=function(e){for(var i=1;i<this._points.length;i++)if(e<=this._points[i].t){var n=t.MathHelper.map01(e,this._points[i-1].t,this._points[i].t);return t.MathHelper.lerp(this._points[i-1].value,this._points[i].value,n)}throw new Error("should never be here")},e}();t.AnimCurve=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 i(){this._messageTable=new Map}return i.prototype.addObserver=function(i,n,r){var o=this._messageTable.get(i);o||(o=[],this._messageTable.set(i,o)),t.Insist.isFalse(-1!=o.findIndex(function(t){return t.func==n}),"您试图添加相同的观察者两次"),o.push(new e(n,r))},i.prototype.removeObserver=function(t,e){var i=this._messageTable.get(t),n=i.findIndex(function(t){return t.func==e});-1!=n&&i.splice(n,1)},i.prototype.emit=function(t){for(var e,i=[],n=1;n<arguments.length;n++)i[n-1]=arguments[n];var r=this._messageTable.get(t);if(r)for(var o=r.length-1;o>=0;o--)(e=r[o].func).call.apply(e,__spread([r[o].context],i))},i}();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.default=function(){return new t},t.prototype.equals=function(t,e){return"function"==typeof t.equals?t.equals(e):t===e},t.prototype.getHashCode=function(t){var e=this;if("number"==typeof t)return this._getHashCodeForNumber(t);if("string"==typeof t)return this._getHashCodeForString(t);var i=385229220;return this.forOwn(t,function(t){"number"==typeof t?i+=e._getHashCodeForNumber(t):"string"==typeof t?i+=e._getHashCodeForString(t):"object"==typeof t&&e.forOwn(t,function(){i+=e.getHashCode(t)})}),i},t.prototype._getHashCodeForNumber=function(t){return t},t.prototype._getHashCodeForString=function(t){for(var e=385229220,i=0;i<t.length;i++)e=-1521134295*e^t.charCodeAt(i);return e},t.prototype.forOwn=function(t,e){t=Object(t),Object.keys(t).forEach(function(i){return e(t[i],i,t)})},t}();t.EqualityComparer=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 t(){}return t.computeHash=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var i=2166136261,n=0;n<t.length;n++)i=16777619*(i^t[n]);return i+=i<<13,i^=i>>7,i+=i<<3,i^=i>>17,i+=i<<5},t}();t.Hash=e}(es||(es={})),function(t){var e=function(){function t(){this._listeners=[]}return t.prototype.addListener=function(t,e){-1===this._listeners.findIndex(function(i){return i.callback===e&&i.caller===t})&&this._listeners.push({caller:t,callback:e})},t.prototype.removeListener=function(t,e){var i=this._listeners.findIndex(function(i){return i.callback===e&&i.caller===t});i>=0&&this._listeners.splice(i,1)},t.prototype.clearListener=function(){this._listeners=[]},t.prototype.clearListenerWithCaller=function(t){for(var e=this._listeners.length-1;e>=0;e--){this._listeners[e].caller===t&&this._listeners.splice(e,1)}},t.prototype.notify=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];for(var n=this._listeners.length-1;n>=0;n--){var r=this._listeners[n];r.caller?(t=r.callback).call.apply(t,__spread([r.caller],e)):r.callback.apply(r,__spread(e))}},t}();t.Observable=e;var i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.addListener=function(e,i){t.prototype.addListener.call(this,e,i)},e.prototype.removeListener=function(e,i){t.prototype.removeListener.call(this,e,i)},e.prototype.notify=function(e){t.prototype.notify.call(this,e)},e}(e);t.ObservableT=i;var n=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.addListener=function(e,i){t.prototype.addListener.call(this,e,i)},e.prototype.removeListener=function(e,i){t.prototype.removeListener.call(this,e,i)},e.prototype.notify=function(e,i){t.prototype.notify.call(this,e,i)},e}(e);t.ObservableTT=n;var r=function(){function t(t,i){this.bindAction(t,i),this._onExec=new e}return t.prototype.bindAction=function(t,e){this._caller=t,this._action=e},t.prototype.dispatch=function(){for(var t,e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];this._action?(this._caller?(t=this._action).call.apply(t,__spread([this._caller],e)):this._action.apply(this,__spread(e)),this._onExec.notify()):console.warn("command not bind with an action")},t.prototype.addListener=function(t,e){this._onExec.addListener(t,e)},t.prototype.removeListener=function(t,e){this._onExec.removeListener(t,e)},t.prototype.clearListener=function(){this._onExec.clearListener()},t.prototype.clearListenerWithCaller=function(t){this._onExec.clearListenerWithCaller(t)},t}();t.Command=r;var o=function(){function t(t){this._onValueChange=new e,this._value=t}return Object.defineProperty(t.prototype,"onValueChange",{get:function(){return this._onValueChange},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(t){this._value=t},enumerable:!0,configurable:!0}),t.prototype.dispatch=function(t){if(t!==this._value){var e=this._value;this._value=t,this._onValueChange.notify(this._value,e)}},t.prototype.addListener=function(t,e){this._onValueChange.addListener(t,e)},t.prototype.removeListener=function(t,e){this._onValueChange.removeListener(t,e)},t.prototype.clearListener=function(){this._onValueChange.clearListener()},t.prototype.clearListenerWithCaller=function(t){this._onValueChange.clearListenerWithCaller(t)},t}();t.ValueChangeCommand=o}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=e}(es||(es={})),function(t){var e=function(){function e(){}return Object.defineProperty(e,"size",{get:function(){return new t.Vector2(this.width,this.height)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"center",{get:function(){return new t.Vector2(this.width/2,this.height/2)},enumerable:!0,configurable:!0}),e}();t.Screen=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(e.sub(i),n.sub(i))<0)&&(!(t.Vector2Ext.cross(e.sub(n),r.sub(n))<0)&&!(t.Vector2Ext.cross(e.sub(r),i.sub(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,h=i[this._triPrev[s]],c=i[s],l=i[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(h,c,l)){var u=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(i[u],h,c,l)){a=!1;break}u=this._triNext[u]}while(u!=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.length=Math.max(2*this._triNext.length,t)),this._triPrev.length<t&&(this._triPrev.reverse(),this._triPrev.length=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=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"],i=function(){function t(){}return t.randomUUID=function(){var t=4294967295*Math.random()|0,i=4294967295*Math.random()|0,n=4294967295*Math.random()|0,r=4294967295*Math.random()|0;return e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255]+"-"+e[255&i]+e[i>>8&255]+"-"+e[i>>16&15|64]+e[i>>24&255]+"-"+e[63&n|128]+e[n>>8&255]+"-"+e[n>>16&255]+e[n>>24&255]+e[255&r]+e[r>>8&255]+e[r>>16&255]+e[r>>24&255]},t}();t.UUID=i}(es||(es={})),function(t){t.getClassName=function(t){return t.className||t.name}}(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 __spread(this._completeSlices,[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}(es||(es={})),function(t){var e=function(){function t(t){void 0===t&&(t=64),this.size_=0,this.length=0,this.array=[],this.length=t}return t.prototype.removeAt=function(t){var e=this.array[t];return this.array[t]=this.array[--this.size_],this.array[this.size_]=null,e},t.prototype.remove=function(t){var e,i=this.size_;for(e=0;e<i;e++)if(t==this.array[e])return this.array[e]=this.array[--this.size_],this.array[this.size_]=null,!0;return!1},t.prototype.removeLast=function(){if(this.size_>0){var t=this.array[--this.size_];return this.array[this.size_]=null,t}return null},t.prototype.contains=function(t){var e,i;for(e=0,i=this.size_;i>e;e++)if(t===this.array[e])return!0;return!1},t.prototype.removeAll=function(t){var e,i,n,r,o=!1;for(e=0,n=t.size();e<n;e++)for(r=t[e],i=0;i<this.size_;i++)if(r===this.array[i]){this.removeAt(i),i--,o=!0;break}return o},t.prototype.get=function(t){if(t>=this.length)throw new Error("ArrayIndexOutOfBoundsException");return this.array[t]},t.prototype.safeGet=function(t){return t>=this.length&&this.grow(7*t/4+1),this.array[t]},t.prototype.size=function(){return this.size_},t.prototype.getCapacity=function(){return this.length},t.prototype.isIndexWithinBounds=function(t){return t<this.getCapacity()},t.prototype.isEmpty=function(){return 0==this.size_},t.prototype.add=function(t){this.size_===this.length&&this.grow(),this.array[this.size_++]=t},t.prototype.set=function(t,e){t>=this.length&&this.grow(2*t),this.size_=t+1,this.array[t]=e},t.prototype.grow=function(t){void 0===t&&(t=1+~~(3*this.length/2)),this.length=~~t},t.prototype.ensureCapacity=function(t){t>=this.length&&this.grow(2*t)},t.prototype.clear=function(){var t,e;for(t=0,e=this.size_;t<e;t++)this.array[t]=null;this.size_=0},t.prototype.addAll=function(t){var e;for(e=0;t.size()>e;e++)this.add(t.get(e))},t}();t.Bag=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=1),this._freeValueCellIndex=0,this._collisions=0,this._valuesInfo=new Array(e),this._values=new Array(e),this._buckets=new Array(t.HashHelpers.getPrime(e))}return e.prototype.getValuesArray=function(t){return t.value=this._freeValueCellIndex,this._values},Object.defineProperty(e.prototype,"valuesArray",{get:function(){return this._values},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this._freeValueCellIndex},enumerable:!0,configurable:!0}),e.prototype.add=function(t,e){if(!this.addValue(t,e,{value:0}))throw new Error("key 已经存在")},e.prototype.addValue=function(n,r,o){var s=t.HashHelpers.getHashCode(n),a=e.reduce(s,this._buckets.length);if(this._freeValueCellIndex==this._values.length){var h=t.HashHelpers.expandPrime(this._freeValueCellIndex);this._values.length=h,this._valuesInfo.length=h}var c=t.NumberExtension.toNumber(this._buckets[a])-1;if(-1==c)this._valuesInfo[this._freeValueCellIndex]=new i(n,s);else{var l=c;do{if(this._valuesInfo[l].hashcode==s&&this._valuesInfo[l].key==n)return this._values[l]=r,o.value=l,!1;l=this._valuesInfo[l].previous}while(-1!=l);this._collisions++,this._valuesInfo[this._freeValueCellIndex]=new i(n,s,c),this._valuesInfo[c].next=this._freeValueCellIndex}if(this._buckets[a]=this._freeValueCellIndex+1,this._values[this._freeValueCellIndex]=r,o.value=this._freeValueCellIndex,this._freeValueCellIndex++,this._collisions>this._buckets.length){this._buckets=new Array(t.HashHelpers.expandPrime(this._collisions)),this._collisions=0;for(var u=0;u<this._freeValueCellIndex;u++){a=e.reduce(this._valuesInfo[u].hashcode,this._buckets.length);var p=t.NumberExtension.toNumber(this._buckets[a])-1;this._buckets[a]=u+1,-1!=p?(this._collisions++,this._valuesInfo[u].previous=p,this._valuesInfo[u].next=-1,this._valuesInfo[p].next=u):(this._valuesInfo[u].next=-1,this._valuesInfo[u].previous=-1)}}return!0},e.prototype.remove=function(i){for(var n=e.hash(i),r=e.reduce(n,this._buckets.length),o=t.NumberExtension.toNumber(this._buckets[r])-1;-1!=o;){if(this._valuesInfo[o].hashcode==n&&this._valuesInfo[o].key==i){if(this._buckets[r]-1==o){if(-1!=this._valuesInfo[o].next)throw new Error("如果 bucket 指向单元格,那么 next 必须不存在。");var s=this._valuesInfo[o].previous;this._buckets[r]=s+1}else if(-1==this._valuesInfo[o].next)throw new Error("如果 bucket 指向另一个单元格,则 NEXT 必须存在");e.updateLinkedList(o,this._valuesInfo);break}o=this._valuesInfo[o].previous}if(-1==o)return!1;if(this._freeValueCellIndex--,o!=this._freeValueCellIndex){var a=e.reduce(this._valuesInfo[this._freeValueCellIndex].hashcode,this._buckets.length);this._buckets[a]-1==this._freeValueCellIndex&&(this._buckets[a]=o+1);var h=this._valuesInfo[this._freeValueCellIndex].next,c=this._valuesInfo[this._freeValueCellIndex].previous;-1!=h&&(this._valuesInfo[h].previous=o),-1!=c&&(this._valuesInfo[c].next=o),this._valuesInfo[o]=this._valuesInfo[this._freeValueCellIndex],this._values[o]=this._values[this._freeValueCellIndex]}return!0},e.prototype.trim=function(){var e=t.HashHelpers.expandPrime(this._freeValueCellIndex);e<this._valuesInfo.length&&(this._values.length=e,this._valuesInfo.length=e)},e.prototype.clear=function(){0!=this._freeValueCellIndex&&(this._freeValueCellIndex=0,this._buckets.length=0,this._values.length=0,this._valuesInfo.length=0)},e.prototype.fastClear=function(){0!=this._freeValueCellIndex&&(this._freeValueCellIndex=0,this._buckets.length=0,this._valuesInfo.length=0)},e.prototype.containsKey=function(t){return!!this.tryFindIndex(t,{value:0})},e.prototype.tryGetValue=function(t){var e={value:0};return this.tryFindIndex(t,e)?this._values[e.value]:null},e.prototype.tryFindIndex=function(i,n){for(var r=e.hash(i),o=e.reduce(r,this._buckets.length),s=t.NumberExtension.toNumber(this._buckets[o])-1;-1!=s;){if(this._valuesInfo[s].hashcode==r&&this._valuesInfo[s].key==i)return n.value=s,!0;s=this._valuesInfo[s].previous}return n.value=0,!1},e.prototype.getDirectValue=function(t){return this._values[t]},e.prototype.getIndex=function(t){var e={value:0};if(this.tryFindIndex(t,e))return e.value;throw new Error("未找到key")},e.updateLinkedList=function(t,e){var i=e[t].next,n=e[t].previous;-1!=i&&(e[i].previous=n),-1!=n&&(e[n].next=i)},e.hash=function(e){return t.HashHelpers.getHashCode(e)},e.reduce=function(t,e){return t>=e?t%e:t},e}();t.FasterDictionary=e;var i=function(){return function(t,e,i){void 0===i&&(i=-1),this.key=t,this.hashcode=e,this.previous=i,this.next=-1}}();t.FastNode=i}(es||(es={})),function(t){var e=function(){return function(t,e){this.element=t,this.next=e}}();function i(t,e){return t===e}t.Node=e,t.defaultEquals=i;var n=function(){function t(t){void 0===t&&(t=i),this.count=0,this.next=void 0,this.equalsFn=t,this.head=null}return t.prototype.push=function(t){var i,n=new e(t);if(null==this.head)this.head=n;else{for(i=this.head;null!=i.next;)i=i.next;i.next=n}this.count++},t.prototype.removeAt=function(t){if(t>=0&&t<this.count){var e=this.head;if(0===t)this.head=e.next;else{var i=this.getElementAt(t-1);e=i.next,i.next=e.next}return this.count--,e.element}},t.prototype.getElementAt=function(t){if(t>=0&&t<=this.count){for(var e=this.head,i=0;i<t&&null!=e;i++)e=e.next;return e}},t.prototype.insert=function(t,i){if(i>=0&&i<=this.count){var n=new e(t);if(0===i)n.next=this.head,this.head=n;else{var r=this.getElementAt(i-1);n.next=r.next,r.next=n}return this.count++,!0}return!1},t.prototype.indexOf=function(t){for(var e=this.head,i=0;i<this.count&&null!=e;i++){if(this.equalsFn(t,e.element))return i;e=e.next}return-1},t.prototype.remove=function(t){this.removeAt(this.indexOf(t))},t.prototype.clear=function(){this.head=void 0,this.count=0},t.prototype.size=function(){return this.count},t.prototype.isEmpty=function(){return 0===this.size()},t.prototype.getHead=function(){return this.head},t.prototype.toString=function(){if(null==this.head)return"";for(var t=""+this.head.element,e=this.head.next,i=1;i<this.size()&&null!=e;i++)t=t+", "+e.element,e=e.next;return t},t}();t.LinkedList=n}(es||(es={})),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={})),function(t){var e=function(){function e(t,e){this.first=t,this.second=e}return e.prototype.clear=function(){this.first=this.second=null},e.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},e.prototype.getHashCode=function(){return 37*t.EqualityComparer.default().getHashCode(this.first)+t.EqualityComparer.default().getHashCode(this.second)},e}();t.Pair=e}(es||(es={})),function(t){var e=function(){function e(){}return e.warmCache=function(t,e){if((e-=this._objectQueue.length)>0)for(var i=0;i<e;i++)this._objectQueue.unshift(new t)},e.trimCache=function(t){for(;t>this._objectQueue.length;)this._objectQueue.shift()},e.clearCache=function(){this._objectQueue.length=0},e.obtain=function(t){return this._objectQueue.length>0?this._objectQueue.shift():new t},e.free=function(e){this._objectQueue.unshift(e),t.isIPoolable(e)&&e.reset()},e._objectQueue=[],e}();t.Pool=e,t.isIPoolable=function(t){return void 0!==t.reset}}(es||(es={})),function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.getHashCode=function(t){return t.getHashCode()},e.prototype.areEqual=function(t,e){return t.equals(e)},e}(function(){function t(t){var e=this;this.clear(),t&&t.forEach(function(t){e.add(t)})}return t.prototype.add=function(t){var e=this,i=this.getHashCode(t),n=this.buckets[i];if(void 0===n){var r=new Array;return r.push(t),this.buckets[i]=r,this.count=this.count+1,!0}return!n.some(function(i){return e.areEqual(i,t)})&&(n.push(t),this.count=this.count+1,!0)},t.prototype.remove=function(t){var e=this,i=this.getHashCode(t),n=this.buckets[i];if(void 0===n)return!1;var r=!1,o=new Array;return n.forEach(function(i){e.areEqual(i,t)?r=!0:o.push(t)}),this.buckets[i]=o,r&&(this.count=this.count-1),r},t.prototype.contains=function(t){return this.bucketsContains(this.buckets,t)},t.prototype.getCount=function(){return this.count},t.prototype.clear=function(){this.buckets=new Array,this.count=0},t.prototype.toArray=function(){var t=new Array;return this.buckets.forEach(function(e){e.forEach(function(e){t.push(e)})}),t},t.prototype.exceptWith=function(t){var e=this;t&&t.forEach(function(t){e.remove(t)})},t.prototype.intersectWith=function(t){var e=this;if(t){var i=this.buildInternalBuckets(t);this.toArray().forEach(function(t){e.bucketsContains(i.Buckets,t)||e.remove(t)})}else this.clear()},t.prototype.unionWith=function(t){var e=this;t.forEach(function(t){e.add(t)})},t.prototype.isSubsetOf=function(t){var e=this,i=this.buildInternalBuckets(t);return this.toArray().every(function(t){return e.bucketsContains(i.Buckets,t)})},t.prototype.isSupersetOf=function(t){var e=this;return t.every(function(t){return e.contains(t)})},t.prototype.overlaps=function(t){var e=this;return t.some(function(t){return e.contains(t)})},t.prototype.setEquals=function(t){var e=this;return this.buildInternalBuckets(t).Count===this.count&&t.every(function(t){return e.contains(t)})},t.prototype.buildInternalBuckets=function(t){var e=this,i=new Array,n=0;return t.forEach(function(t){var r=e.getHashCode(t),o=i[r];if(void 0===o){var s=new Array;s.push(t),i[r]=s,n+=1}else o.some(function(i){return e.areEqual(i,t)})||(o.push(t),n+=1)}),{Buckets:i,Count:n}},t.prototype.bucketsContains=function(t,e){var i=this,n=t[this.getHashCode(e)];return void 0!==n&&n.some(function(t){return i.areEqual(t,e)})},t}());t.HashSet=e}(es||(es={})),function(t){var e=function(){function t(){}return t.waitForSeconds=function(t){return i.waiter.wait(t)},t}();t.Coroutine=e;var i=function(){function t(){this.waitTime=0}return t.prototype.wait=function(e){return t.waiter.waitTime=e,t.waiter},t.waiter=new t,t}();t.WaitForSeconds=i}(es||(es={})),function(t){var e=function(){function t(){this.waitTimer=0,this.useUnscaledDeltaTime=!1}return t.prototype.stop=function(){this.isDone=!0},t.prototype.setUseUnscaledDeltaTime=function(t){return this.useUnscaledDeltaTime=t,this},t.prototype.prepareForUse=function(){this.isDone=!1},t.prototype.reset=function(){this.isDone=!0,this.waitTimer=0,this.waitForCoroutine=null,this.enumerator=null,this.useUnscaledDeltaTime=!1},t}();t.CoroutineImpl=e;var i=function(i){function n(){var t=null!==i&&i.apply(this,arguments)||this;return t._unblockedCoroutines=[],t._shouldRunNextFrame=[],t}return __extends(n,i),n.prototype.startCoroutine=function(i){var n=t.Pool.obtain(e);return n.prepareForUse(),n.enumerator=i,this.tickCoroutine(n)?(this._isInUpdate?this._shouldRunNextFrame.push(n):this._unblockedCoroutines.push(n),n):null},n.prototype.update=function(){this._isInUpdate=!0;for(var e=0;e<this._unblockedCoroutines.length;e++){var i=this._unblockedCoroutines[e];if(i.isDone)t.Pool.free(i);else{if(null!=i.waitForCoroutine){if(!i.waitForCoroutine.isDone){this._shouldRunNextFrame.push(i);continue}i.waitForCoroutine=null}i.waitTimer>0?(i.waitTimer-=i.useUnscaledDeltaTime?t.Time.unscaledDeltaTime:t.Time.deltaTime,this._shouldRunNextFrame.push(i)):this.tickCoroutine(i)&&this._shouldRunNextFrame.push(i)}}var n=new t.List(this._unblockedCoroutines);n.clear(),n.addRange(this._shouldRunNextFrame),this._shouldRunNextFrame.length=0,this._isInUpdate=!1},n.prototype.tickCoroutine=function(i){var n=i.enumerator.next();return n.done||i.isDone?(t.Pool.free(i),!1):null==n.value||(n.value instanceof t.WaitForSeconds?(i.waitTimer=n.value.waitTime,!0):"number"==typeof n.value?(i.waitTimer=n.value,!0):"string"==typeof n.value?"break"!=n.value||(t.Pool.free(i),!1):!(n.value instanceof e)||(i.waitForCoroutine=n.value,!0))},n}(t.GlobalManager);t.CoroutineManager=i}(es||(es={})),function(t){var e=function(){function e(t,e,i){void 0===i&&(i=!0),this.binWidth=0,this.binHeight=0,this.usedRectangles=[],this.freeRectangles=[],this.init(t,e,i)}return e.prototype.init=function(e,i,n){void 0===n&&(n=!0),this.binWidth=e,this.binHeight=i,this.allowRotations=n;var r=new t.Rectangle;r.x=0,r.y=0,r.width=e,r.height=i,this.usedRectangles.length=0,this.freeRectangles.length=0,this.freeRectangles.push(r)},e.prototype.insert=function(e,i){var n=new t.Rectangle,r=new t.Ref(0),o=new t.Ref(0);if(0==(n=this.findPositionForNewNodeBestAreaFit(e,i,r,o)).height)return n;for(var s=this.freeRectangles.length,a=0;a<s;++a)this.splitFreeNode(this.freeRectangles[a],n)&&(new t.List(this.freeRectangles).removeAt(a),--a,--s);return this.pruneFreeList(),this.usedRectangles.push(n),n},e.prototype.findPositionForNewNodeBestAreaFit=function(e,i,n,r){var o=new t.Rectangle;n.value=Number.MAX_VALUE;for(var s=0;s<this.freeRectangles.length;++s){var a=this.freeRectangles[s].width*this.freeRectangles[s].height-e*i;if(this.freeRectangles[s].width>=e&&this.freeRectangles[s].height>=i){var h=Math.abs(this.freeRectangles[s].width-e),c=Math.abs(this.freeRectangles[s].height-i),l=Math.min(h,c);(a<n.value||a==n.value&&l<r.value)&&(o.x=this.freeRectangles[s].x,o.y=this.freeRectangles[s].y,o.width=e,o.height=i,r.value=l,n.value=a)}if(this.allowRotations&&this.freeRectangles[s].width>=i&&this.freeRectangles[s].height>=e){h=Math.abs(this.freeRectangles[s].width-i),c=Math.abs(this.freeRectangles[s].height-e),l=Math.min(h,c);(a<n.value||a==n.value&&l<r.value)&&(o.x=this.freeRectangles[s].x,o.y=this.freeRectangles[s].y,o.width=i,o.height=e,r.value=l,n.value=a)}return o}},e.prototype.splitFreeNode=function(t,e){if(e.x>=t.x+t.width||e.x+e.width<=t.x||e.y>=t.y+t.height||e.y+e.height<=t.y)return!1;if(e.x<t.x+t.width&&e.x+e.width>t.x){if(e.y>t.y&&e.y<t.y+t.height)(i=t).height=e.y-i.y,this.freeRectangles.push(i);if(e.y+e.height<t.y+t.height)(i=t).y=e.y+e.height,i.height=t.y+t.height-(e.y+e.height),this.freeRectangles.push(i)}if(e.y<t.y+t.height&&e.y+e.height>t.y){var i;if(e.x>t.x&&e.x<t.x+t.width)(i=t).width=e.x-i.x,this.freeRectangles.push(i);if(e.x+e.width<t.x+t.width)(i=t).x=e.x+e.width,i.width=t.x+t.width-(e.x+e.width),this.freeRectangles.push(i)}return!0},e.prototype.pruneFreeList=function(){for(var e=0;e<this.freeRectangles.length;++e)for(var i=e+1;i<this.freeRectangles.length;++i){if(this.isContainedIn(this.freeRectangles[e],this.freeRectangles[i])){new t.List(this.freeRectangles).removeAt(e),--e;break}this.isContainedIn(this.freeRectangles[i],this.freeRectangles[e])&&(new t.List(this.freeRectangles).removeAt(i),--i)}},e.prototype.isContainedIn=function(t,e){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height},e}();t.MaxRectsBinPack=e}(es||(es={})),function(t){var e=function(){function e(){}return e.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}},e.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}},e.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},e.findElementIndex=function(t,e){for(var i=t.length,n=0;n<i;++n)if(t[n]==e)return n;return null},e.getMaxElementIndex=function(t){for(var e=0,i=t.length,n=1;n<i;n++)t[n]>t[e]&&(e=n);return e},e.getMinElementIndex=function(t){for(var e=0,i=t.length,n=1;n<i;n++)t[n]<t[e]&&(e=n);return e},e.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},e.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},e.swap=function(t,e,i){var n=t[e];t[e]=t[i],t[i]=n},e.clearList=function(t){if(t)for(var e=t.length-1;e>=0;e-=1)t.splice(e,1)},e.cloneList=function(t){return t?t.slice(0,t.length):null},e.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},e.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},e.shuffle=function(e){for(var i=e.length;i>1;){i--;var n=t.RandomUtils.randint(0,i+1),r=e[n];e[n]=e[i],e[i]=r}},e.addIfNotPresent=function(e,i){return!new t.List(e).contains(i)&&(e.push(i),!0)},e.lastItem=function(t){return t[t.length-1]},e.randomItem=function(e){return e[t.RandomUtils.randint(0,e.length-1)]},e.randomItems=function(e,i){for(var n=new Set;n.size!=i;){var r=this.randomItem(e);n.has(r)||n.add(r)}var o=t.ListPool.obtain();return n.forEach(function(t){return o.push(t)}),o},e}();t.ArrayUtils=e}(es||(es={})),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=[],h=0;h<t.length;)e=this._keyStr.indexOf(t.charAt(h++))<<2|(r=this._keyStr.indexOf(t.charAt(h++)))>>4,i=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(h++)))>>2,n=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(h++))),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,h=[],c=0;c<t.length;)r=(e=t.charCodeAt(c++))>>2,o=(3&e)<<4|(i=t.charCodeAt(c++))>>4,s=(15&i)<<2|(n=t.charCodeAt(c++))>>6,a=63&n,isNaN(i)?s=a=64:isNaN(n)&&(a=64),h.push(this._keyStr.charAt(r)),h.push(this._keyStr.charAt(o)),h.push(this._keyStr.charAt(s)),h.push(this._keyStr.charAt(a));return h=h.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(){}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(){function t(){}return t.toNumber=function(t){return null==t?0:Number(t)},t}();t.NumberExtension=e}(es||(es={})),function(t){var e=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}();t.RandomUtils=e}(es||(es={})),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,n.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.boundsFromPolygonVector=function(e){for(var i=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,s=0;s<e.length;s++){var a=e[s];a.x<i&&(i=a.x),a.x>r&&(r=a.x),a.y<n&&(n=a.y),a.y>o&&(o=a.y)}return this.fromMinMaxVector(new t.Vector2(i,n),new t.Vector2(r,o))},e.fromMinMaxVector=function(e,i){return new t.Rectangle(e.x,e.y,i.x-e.x,i.y-e.y)},e.getSweptBroadphaseBounds=function(e,i,n){var r=t.Rectangle.empty;return r.x=i>0?e.x:e.x+i,r.y=n>0?e.y:e.y+n,r.width=i>0?i+e.width:e.width-i,r.height=n>0?n+e.height:e.height-n,r},e.prototype.collisionCheck=function(t,e,i,n){i.value=n.value=0;var r=e.x-(t.x+t.width),o=e.x+e.width-t.x,s=e.y-(t.y+t.height),a=e.y+e.height-t.y;return!(r>0||o<0||s>0||a<0)&&(i.value=Math.abs(r)<o?r:o,n.value=Math.abs(s)<a?s:a,Math.abs(i.value)<Math.abs(n.value)?n.value=0:i.value=0,!0)},e.getIntersectionDepth=function(e,i){var n=e.width/2,r=e.height/2,o=i.width/2,s=i.height/2,a=new t.Vector2(e.left+n,e.top+r),h=new t.Vector2(i.left+o,i.top+s),c=a.x-h.x,l=a.y-h.y,u=n+o,p=r+s;if(Math.abs(c)>=u||Math.abs(l)>=p)return t.Vector2.zero;var f=c>0?u-c:-u-c,d=l>0?p-l:-p-l;return new t.Vector2(f,d)},e.getClosestPointOnBoundsToOrigin=function(e){var i=this.getMax(e),n=Math.abs(e.location.x),r=new t.Vector2(e.location.x,0);return Math.abs(i.x)<n&&(n=Math.abs(i.x),r.x=i.x,r.y=0),Math.abs(i.y)<n&&(n=Math.abs(i.y),r.x=0,r.y=i.y),Math.abs(e.location.y)<n&&(n=Math.abs(e.location.y),r.x=0,r.y=e.location.y),r},e.getClosestPointOnRectangleToPoint=function(e,i){var n=t.Vector2.zero;return n.x=t.MathHelper.clamp(i.x,e.left,e.right),n.y=t.MathHelper.clamp(i.y,e.top,e.bottom),n},e.getClosestPointOnRectangleBorderToPoint=function(e,i){var n=t.Vector2.zero;if(n.x=t.MathHelper.clamp(Math.trunc(i.x),e.left,e.right),n.y=t.MathHelper.clamp(Math.trunc(i.y),e.top,e.bottom),e.contains(n.x,n.y)){var r=e.x-e.left,o=e.right-n.x,s=n.y-e.top,a=e.bottom-n.y,h=Math.min(r,o,s,a);h==s?n.y=e.top:h==a?n.y=e.bottom:h==r?(n.x,e.left):n.x=e.right}return n},e.getMax=function(e){return new t.Vector2(e.right,e.bottom)},e.getCenter=function(e){return new t.Vector2(e.x+e.width/2,e.y+e.height/2)},e.boundsFromPolygonPoints=function(e){for(var i=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,s=0;s<e.length;s++){var a=e[s];a.x<i&&(i=a.x),a.x>r&&(r=a.x),a.y<n&&(n=a.y),a.y>o&&(o=a.y)}return this.fromMinMaxVector(new t.Vector2(Math.trunc(i),Math.trunc(n)),new t.Vector2(Math.trunc(r),Math.trunc(o)))},e.calculateBounds=function(e,i,n,r,o,s,a,h){if(0==s)e.x=Math.trunc(i.x+n.x-r.x*o.x),e.y=Math.trunc(i.y+n.y-r.y*o.y),e.width=Math.trunc(a*o.x),e.height=Math.trunc(h*o.y);else{var c=i.x+n.x,l=i.y+n.y,u=new t.Matrix2D;t.Matrix2D.createTranslation(-c-r.x,-l-r.y,u),t.Matrix2D.createScale(o.x,o.y,void 0),u=u.multiply(void 0),t.Matrix2D.createRotation(s,void 0),u=u.multiply(void 0),t.Matrix2D.createTranslation(c,l,void 0),u=u.multiply(void 0);var p=new t.Vector2(c,l),f=new t.Vector2(c+a,l),d=new t.Vector2(c,l+h),m=new t.Vector2(c+a,l+h);t.Vector2Ext.transformR(p,u,p),t.Vector2Ext.transformR(f,u,f),t.Vector2Ext.transformR(d,u,d),t.Vector2Ext.transformR(m,u,m);var y=Math.trunc(Math.min(p.x,m.x,f.x,d.x)),g=Math.trunc(Math.max(p.x,m.x,f.x,d.x)),_=Math.trunc(Math.min(p.y,m.y,f.y,d.y)),v=Math.trunc(Math.max(p.y,m.y,f.y,d.y));e.location=new t.Vector2(y,_),e.width=Math.trunc(g-y),e.height=Math.trunc(v-_)}},e.scale=function(t,e){t.x=Math.trunc(t.x*e.x),t.y=Math.trunc(t.y*e.y),t.width=Math.trunc(t.width*e.x),t.height=Math.trunc(t.height*e.y)},e.translate=function(t,e){t.location.addEqual(e)},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){function t(){}return t.premultiplyAlpha=function(t){for(var e=t[0],i=0;i<t.length;i+=4)if(255!=e[i+3]){var n=e[i+3]/255;e[i+0]=e[i+0]*n,e[i+1]=e[i+1]*n,e[i+2]=e[i+2]*n}},t}();t.TextureUtils=e}(es||(es={})),function(t){var e=function(){function t(){}return t.getType=function(t){return t.constructor},t}();t.TypeUtils=e}(es||(es={})),function(t){var e=function(){function e(){}return e.isTriangleCCW=function(t,e,i){return this.cross(e.sub(t),i.sub(e))<0},e.halfVector=function(){return new t.Vector2(.5,.5)},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.perpendicularFlip=function(e){return new t.Vector2(-e.y,e.x)},e.angle=function(e,i){return this.normalize(e),this.normalize(i),Math.acos(t.MathHelper.clamp(e.dot(i),-1,1))*t.MathHelper.Rad2Deg},e.angleBetween=function(t,e,i){var n=e.sub(t),r=i.sub(t);return this.angle(n,r)},e.getRayIntersection=function(e,i,n,r,o){void 0===o&&(o=t.Vector2.zero);var s=i.y-e.y,a=i.x-e.x,h=r.y-n.y,c=r.x-n.x;if(s*c==h*a)return o.x=Number.NaN,o.y=Number.NaN,!1;var l=((n.y-e.y)*a*c+s*c*e.x-h*a*n.x)/(s*c-h*a),u=e.y+s/a*(l-e.x);return o.x=l,o.y=u,!0},e.normalize=function(e){var i=Math.sqrt(e.x*e.x+e.y*e.y);i>t.MathHelper.Epsilon?e.divideScaler(i):e.x=e.y=0},e.transformA=function(t,e,i,n,r,o){for(var s=0;s<o;s++){var a=t[e+s],h=n[r+s];h.x=a.x*i.m11+a.y*i.m21+i.m31,h.y=a.x*i.m12+a.y*i.m22+i.m32,n[r+s]=h}},e.transformR=function(e,i,n){void 0===n&&(n=t.Vector2.zero);var r=e.x*i.m11+e.y*i.m21+i.m31,o=e.x*i.m12+e.y*i.m22+i.m32;n.x=r,n.y=o},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={})),function(t){var e=function(){function e(){}return e.range=function(e,i){for(var n=new t.List;i--;)n.add(e++);return n},e.repeat=function(e,i){for(var n=new t.List;i--;)n.add(e);return n},e}();t.Enumerable=e}(es||(es={})),function(t){t.isObj=function(t){return!!t&&"object"==typeof t},t.negate=function(t){return function(){for(var e=[],i=0;i<arguments.length;i++)e[i]=arguments[i];return!t.apply(void 0,__spread(e))}},t.composeComparers=function(t,e){return function(i,n){return t(i,n)||e(i,n)}},t.keyComparer=function(t,e){return function(i,n){var r=t(i),o=t(n);return r>o?e?-1:1:r<o?e?1:-1:0}}}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=[]),this._elements=t}return e.prototype.add=function(t){this._elements.push(t)},e.prototype.append=function(t){this.add(t)},e.prototype.prepend=function(t){this._elements.unshift(t)},e.prototype.addRange=function(t){var e;(e=this._elements).push.apply(e,__spread(t))},e.prototype.aggregate=function(t,e){return this._elements.reduce(t,e)},e.prototype.all=function(t){return this._elements.every(t)},e.prototype.any=function(t){return t?this._elements.some(t):this._elements.length>0},e.prototype.average=function(t){return this.sum(t)/this.count(t)},e.prototype.cast=function(){return new e(this._elements)},e.prototype.clear=function(){this._elements.length=0},e.prototype.concat=function(t){return new e(this._elements.concat(t.toArray()))},e.prototype.contains=function(t){return this.any(function(e){return e===t})},e.prototype.count=function(t){return t?this.where(t).count():this._elements.length},e.prototype.defaultIfEmpty=function(t){return this.count()?this:new e([t])},e.prototype.distinctBy=function(t){var i=this.groupBy(t);return Object.keys(i).reduce(function(t,e){return t.add(i[e][0]),t},new e)},e.prototype.elementAt=function(t){if(t<this.count()&&t>=0)return this._elements[t];throw new Error("ArgumentOutOfRangeException: index is less than 0 or greater than or equal to the number of elements in source.")},e.prototype.elementAtOrDefault=function(t){return t<this.count()&&t>=0?this._elements[t]:void 0},e.prototype.except=function(t){return this.where(function(e){return!t.contains(e)})},e.prototype.first=function(t){if(this.count())return t?this.where(t).first():this._elements[0];throw new Error("InvalidOperationException: The source sequence is empty.")},e.prototype.firstOrDefault=function(t){return this.count(t)?this.first(t):void 0},e.prototype.forEach=function(t){return this._elements.forEach(t)},e.prototype.groupBy=function(t,e){void 0===e&&(e=function(t){return t});return this.aggregate(function(i,n){var r=t(n),o=i[r],s=e(n);return o?o.push(s):i[r]=[s],i},{})},e.prototype.groupJoin=function(t,e,i,n){return this.select(function(r){return n(r,t.where(function(t){return e(r)===i(t)}))})},e.prototype.indexOf=function(t){return this._elements.indexOf(t)},e.prototype.insert=function(t,e){if(t<0||t>this._elements.length)throw new Error("Index is out of range.");this._elements.splice(t,0,e)},e.prototype.intersect=function(t){return this.where(function(e){return t.contains(e)})},e.prototype.join=function(t,e,i,n){return this.selectMany(function(r){return t.where(function(t){return i(t)===e(r)}).select(function(t){return n(r,t)})})},e.prototype.last=function(t){if(this.count())return t?this.where(t).last():this._elements[this.count()-1];throw Error("InvalidOperationException: The source sequence is empty.")},e.prototype.lastOrDefault=function(t){return this.count(t)?this.last(t):void 0},e.prototype.max=function(t){return Math.max.apply(Math,__spread(this._elements.map(t||function(t){return t})))},e.prototype.min=function(t){return Math.min.apply(Math,__spread(this._elements.map(t||function(t){return t})))},e.prototype.ofType=function(t){var e;switch(t){case Number:e="number";break;case String:e="string";break;case Boolean:e=typeof!0;break;case Function:e="function";break;default:e=null}return null===e?this.where(function(e){return e instanceof t}).cast():this.where(function(t){return typeof t===e}).cast()},e.prototype.orderBy=function(e,n){return void 0===n&&(n=t.keyComparer(e,!1)),new i(this._elements,n)},e.prototype.orderByDescending=function(e,n){return void 0===n&&(n=t.keyComparer(e,!0)),new i(this._elements,n)},e.prototype.thenBy=function(t){return this.orderBy(t)},e.prototype.thenByDescending=function(t){return this.orderByDescending(t)},e.prototype.remove=function(t){return-1!==this.indexOf(t)&&(this.removeAt(this.indexOf(t)),!0)},e.prototype.removeAll=function(e){return this.where(t.negate(e))},e.prototype.removeAt=function(t){this._elements.splice(t,1)},e.prototype.reverse=function(){return new e(this._elements.reverse())},e.prototype.select=function(t){return new e(this._elements.map(t))},e.prototype.selectMany=function(t){var i=this;return this.aggregate(function(e,n,r){return e.addRange(i.select(t).elementAt(r).toArray()),e},new e)},e.prototype.sequenceEqual=function(t){return this.all(function(e){return t.contains(e)})},e.prototype.single=function(t){if(1!==this.count(t))throw new Error("The collection does not contain exactly one element.");return this.first(t)},e.prototype.singleOrDefault=function(t){return this.count(t)?this.single(t):void 0},e.prototype.skip=function(t){return new e(this._elements.slice(Math.max(0,t)))},e.prototype.skipLast=function(t){return new e(this._elements.slice(0,-Math.max(0,t)))},e.prototype.skipWhile=function(t){var e=this;return this.skip(this.aggregate(function(i){return t(e.elementAt(i))?++i:i},0))},e.prototype.sum=function(t){return t?this.select(t).sum():this.aggregate(function(t,e){return t+ +e},0)},e.prototype.take=function(t){return new e(this._elements.slice(0,Math.max(0,t)))},e.prototype.takeLast=function(t){return new e(this._elements.slice(-Math.max(0,t)))},e.prototype.takeWhile=function(t){var e=this;return this.take(this.aggregate(function(i){return t(e.elementAt(i))?++i:i},0))},e.prototype.toArray=function(){return this._elements},e.prototype.toDictionary=function(t,i){var n=this;return this.aggregate(function(e,r,o){return e[n.select(t).elementAt(o).toString()]=i?n.select(i).elementAt(o):r,e.add({Key:n.select(t).elementAt(o),Value:i?n.select(i).elementAt(o):r}),e},new e)},e.prototype.toSet=function(){var t,e,i=new Set;try{for(var n=__values(this._elements),r=n.next();!r.done;r=n.next()){var o=r.value;i.add(o)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}return i},e.prototype.toList=function(){return this},e.prototype.toLookup=function(t,e){return this.groupBy(t,e)},e.prototype.where=function(t){return new e(this._elements.filter(t))},e.prototype.zip=function(t,e){var i=this;return t.count()<this.count()?t.select(function(t,n){return e(i.elementAt(n),t)}):this.select(function(i,n){return e(i,t.elementAt(n))})},e}();t.List=e;var i=function(e){function i(t,i){var n=e.call(this,t)||this;return n._comparer=i,n._elements.sort(n._comparer),n}return __extends(i,e),i.prototype.thenBy=function(e){return new i(this._elements,t.composeComparers(this._comparer,t.keyComparer(e,!1)))},i.prototype.thenByDescending=function(e){return new i(this._elements,t.composeComparers(this._comparer,t.keyComparer(e,!0)))},i}(e);t.OrderedList=i}(es||(es={})),function(t){var e=function(){return function(){this.position=t.Vector2.zero,this.begin=!1,this.segment=null,this.angle=0}}();t.EndPoint=e;var i=function(){function t(){}return t.prototype.compare=function(t,e){return t.angle>e.angle?1:t.angle<e.angle?-1:!t.begin&&e.begin?1:t.begin&&!e.begin?-1:0},t}();t.EndPointComparer=i}(es||(es={})),function(t){var e=function(){return function(){this.p1=null,this.p2=null}}();t.Segment=e}(es||(es={})),function(t){var e=function(){function e(e,i){this.lineCountForCircleApproximation=10,this._radius=0,this._origin=t.Vector2.zero,this._isSpotLight=!1,this._spotStartAngle=0,this._spotEndAngle=0,this._endPoints=[],this._segments=[],this._origin=e,this._radius=i,this._radialComparer=new t.EndPointComparer}return e.prototype.addColliderOccluder=function(e){if(e instanceof t.BoxCollider&&0==e.rotation)this.addSquareOccluder(e.bounds);else if(e instanceof t.PolygonCollider)for(var i=e.shape,n=0;n<i.points.length;n++){var r=n-1;0==n&&(r+=i.points.length),this.addLineOccluder(t.Vector2.add(i.points[r],i.position),t.Vector2.add(i.points[n],i.position))}else e instanceof t.CircleCollider&&this.addCircleOccluder(e.absolutePosition,e.radius)},e.prototype.addCircleOccluder=function(e,i){for(var n=e.sub(this._origin),r=Math.atan2(n.y,n.x),o=Math.PI/this.lineCountForCircleApproximation,s=r+t.MathHelper.PiOver2,a=t.MathHelper.angleToVector(s,i).addEqual(e),h=1;h<this.lineCountForCircleApproximation;h++){var c=t.MathHelper.angleToVector(s+h*o,i).addEqual(e);this.addLineOccluder(a,c),a=c}},e.prototype.addLineOccluder=function(t,e){this.addSegment(t,e)},e.prototype.addSquareOccluder=function(e){var i=new t.Vector2(e.right,e.top),n=new t.Vector2(e.left,e.bottom),r=new t.Vector2(e.right,e.bottom);this.addSegment(e.location,i),this.addSegment(i,r),this.addSegment(r,n),this.addSegment(n,e.location)},e.prototype.addSegment=function(e,i){var n=new t.Segment,r=new t.EndPoint,o=new t.EndPoint;r.position=e,r.segment=n,o.position=i,o.segment=n,n.p1=r,n.p2=o,this._segments.push(n),this._endPoints.push(r),this._endPoints.push(o)},e.prototype.clearOccluders=function(){this._segments.length=0,this._endPoints.length=0},e.prototype.begin=function(t,e){this._origin=t,this._radius=e,this._isSpotLight=!1},e.prototype.end=function(){var i,n,r=t.ListPool.obtain();this.updateSegments(),this._endPoints.sort(this._radialComparer.compare);for(var o=0,s=0;s<2;s++)try{for(var a=__values(this._endPoints),h=a.next();!h.done;h=a.next()){var c=h.value,l=0==e._openSegments.size()?null:e._openSegments.getHead().element;if(c.begin){for(var u=e._openSegments.getHead();null!=u&&this.isSegmentInFrontOf(c.segment,u.element,this._origin);)u=u.next;null==u?e._openSegments.push(c.segment):e._openSegments.insert(c.segment,e._openSegments.indexOf(u.element))}else e._openSegments.remove(c.segment);var p=null;0!=e._openSegments.size()&&(p=e._openSegments.getHead().element),l!=p&&(1==s&&(!this._isSpotLight||e.between(o,this._spotStartAngle,this._spotEndAngle)&&e.between(c.angle,this._spotStartAngle,this._spotEndAngle))&&this.addTriangle(r,o,c.angle,l),o=c.angle)}}catch(t){i={error:t}}finally{try{h&&!h.done&&(n=a.return)&&n.call(a)}finally{if(i)throw i.error}}return e._openSegments.clear(),this.clearOccluders(),r},e.prototype.addTriangle=function(i,n,r,o){var s=this._origin.clone(),a=new t.Vector2(this._origin.x+Math.cos(n),this._origin.y+Math.sin(n)),h=t.Vector2.zero,c=t.Vector2.zero;null!=o?(h.x=o.p1.position.x,h.y=o.p1.position.y,c.x=o.p2.position.x,c.y=o.p2.position.y):(h.x=this._origin.x+Math.cos(n)*this._radius*2,h.y=this._origin.y+Math.sin(n)*this._radius*2,c.x=this._origin.x+Math.cos(r)*this._radius*2,c.y=this._origin.y+Math.sin(r)*this._radius*2);var l=e.lineLineIntersection(h,c,s,a);a.x=this._origin.x+Math.cos(r),a.y=this._origin.y+Math.sin(r);var u=e.lineLineIntersection(h,c,s,a);i.push(l),i.push(u)},e.lineLineIntersection=function(e,i,n,r){var o=((r.x-n.x)*(e.y-n.y)-(r.y-n.y)*(e.x-n.x))/((r.y-n.y)*(i.x-e.x)-(r.x-n.x)*(i.y-e.y));return new t.Vector2(e.x+o*(i.x-e.x),e.y+o*(i.y-e.y))},e.between=function(t,e,i){return t=(360+t%360)%360,(e=(36e5+e)%360)<(i=(36e5+i)%360)?e<=t&&t<=i:e<=t||t<=i},e.prototype.loadRectangleBoundaries=function(){this.addSegment(new t.Vector2(this._origin.x-this._radius,this._origin.y-this._radius),new t.Vector2(this._origin.x+this._radius,this._origin.y-this._radius)),this.addSegment(new t.Vector2(this._origin.x-this._radius,this._origin.y+this._radius),new t.Vector2(this._origin.x+this._radius,this._origin.y+this._radius)),this.addSegment(new t.Vector2(this._origin.x-this._radius,this._origin.y-this._radius),new t.Vector2(this._origin.x-this._radius,this._origin.y+this._radius)),this.addSegment(new t.Vector2(this._origin.x+this._radius,this._origin.y-this._radius),new t.Vector2(this._origin.x+this._radius,this._origin.y+this._radius))},e.prototype.isSegmentInFrontOf=function(t,i,n){var r=e.isLeftOf(t.p2.position,t.p1.position,e.interpolate(i.p1.position,i.p2.position,.01)),o=e.isLeftOf(t.p2.position,t.p1.position,e.interpolate(i.p2.position,i.p1.position,.01)),s=e.isLeftOf(t.p2.position,t.p1.position,n),a=e.isLeftOf(i.p2.position,i.p1.position,e.interpolate(t.p1.position,t.p2.position,.01)),h=e.isLeftOf(i.p2.position,i.p1.position,e.interpolate(t.p2.position,t.p1.position,.01)),c=e.isLeftOf(i.p2.position,i.p1.position,n);return a==h&&h!=c||r==o&&o==s},e.interpolate=function(e,i,n){return new t.Vector2(e.x*(1-n)+i.x*n,e.y*(1-n)+i.y*n)},e.isLeftOf=function(t,e,i){return(e.x-t.x)*(i.y-t.y)-(e.y-t.y)*(i.x-t.x)<0},e.prototype.updateSegments=function(){var t,e;try{for(var i=__values(this._segments),n=i.next();!n.done;n=i.next()){var r=n.value;r.p1.angle=Math.atan2(r.p1.position.y-this._origin.y,r.p1.position.x-this._origin.x),r.p2.angle=Math.atan2(r.p2.position.y-this._origin.y,r.p2.position.x-this._origin.x);var o=r.p2.angle-r.p1.angle;o<=-Math.PI&&(o+=2*Math.PI),o>Math.PI&&(o-=2*Math.PI),r.p1.begin=o>0,r.p2.begin=!r.p1.begin}}catch(e){t={error:e}}finally{try{n&&!n.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}this._isSpotLight&&(this._spotStartAngle=this._segments[0].p2.angle,this._spotEndAngle=this._segments[1].p2.angle)},e._cornerCache=[],e._openSegments=new t.LinkedList,e}();t.VisibilityComputer=e}(es||(es={})),function(t){var e=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}return e.prototype.getContext=function(){return this.context},e.prototype.reset=function(){this._elapsedTime=0},e.prototype.stop=function(){this._isDone=!0},e.prototype.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,i,n){this._timeInSeconds=t,this._repeats=e,this.context=i,this._onTime=n},e.prototype.unload=function(){this.context=null,this._onTime=null},e}();t.Timer=e}(es||(es={})),function(t){var e=function(e){function i(){var t=null!==e&&e.apply(this,arguments)||this;return t._timers=[],t}return __extends(i,e),i.prototype.update=function(){for(var e=this._timers.length-1;e>=0;e--)this._timers[e].tick()&&(this._timers[e].unload(),new t.List(this._timers).removeAt(e))},i.prototype.schedule=function(e,i,n,r){var o=new t.Timer;return o.initialize(e,i,n,r),this._timers.push(o),o},i}(t.GlobalManager);t.TimerManager=e}(es||(es={}));