Files
esengine/source/bin/framework.min.js

1 line
130 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
window.es={};var __awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))(function(r,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){t.done?r(t.value):new n(function(e){e(t.value)}).then(s,a)}c((i=i.apply(t,e||[])).next())})},__generator=this&&this.__generator||function(t,e){var n,i,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(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=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++,i=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],i=0}finally{n=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}};window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function i(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}}();var transform,__values=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},__read=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),s=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)s.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.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};!function(t){var e=function(){function t(){this.updateInterval=1,this._enabled=!0,this._updateOrder=0}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.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}();t.Component=e}(es||(es={})),function(t){var e=function(){function e(n,i,r){void 0===r&&(r=!0),this._globalManagers=new t.FastList,this._timerManager=new t.TimerManager,this._frameCounterElapsedTime=0,this._frameCounter=0,this._totalMemory=0,this.width=n,this.height=i,e._instance=this,e.emitter=new t.Emitter,e.emitter.addObserver(t.CoreEvents.FrameUpdated,this.update,this),e.registerGlobalManager(this._timerManager),e.entitySystemsEnabled=r,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(t){t?null==this._instance._scene?(this._instance._scene=t,this._instance._scene.begin(),e.Instance.onSceneChanged()):this._instance._nextScene=t:console.error("场景不能为空")},enumerable:!0,configurable:!0}),e.registerGlobalManager=function(t){this._instance._globalManagers.add(t),t.enabled=!0},e.unregisterGlobalManager=function(t){this._instance._globalManagers.remove(t),t.enabled=!1},e.getGlobalManager=function(t){for(var e=0;e<this._instance._globalManagers.length;e++)if(this._instance._globalManagers.buffer[e]instanceof t)return this._instance._globalManagers.buffer[e];return null},e.schedule=function(t,e,n,i){return void 0===e&&(e=!1),void 0===n&&(n=null),this._instance._timerManager.schedule(t,e,n,i)},e.prototype.onOrientationChanged=function(){e.emitter.emit(t.CoreEvents.OrientationChanged)},e.prototype.startDebugDraw=function(){if(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(){e.emitter.emit(t.CoreEvents.SceneChanged),t.Time.sceneChanged()},e.prototype.onGraphicsDeviceReset=function(){null!=this._graphicsDeviceChangeTimer?this._graphicsDeviceChangeTimer.reset():this._graphicsDeviceChangeTimer=e.schedule(.05,!1,this,function(n){n.context._graphicsDeviceChangeTimer=null,e.emitter.emit(t.CoreEvents.GraphicsDeviceReset)})},e.prototype.initialize=function(){},e.prototype.update=function(e){return __awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(i){if(null!=e&&t.Time.update(e),null!=this._scene){for(n=this._globalManagers.length-1;n>=0;n--)this._globalManagers.buffer[n].enabled&&this._globalManagers.buffer[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.pauseOnFocusLost=!0,e.debugRenderEndabled=!1,e}();t.Core=e}(es||(es={})),function(t){!function(t){t[t.GraphicsDeviceReset=0]="GraphicsDeviceReset",t[t.SceneChanged=1]="SceneChanged",t[t.OrientationChanged=2]="OrientationChanged",t[t.FrameUpdated=3]="FrameUpdated"}(t.CoreEvents||(t.CoreEvents={}))}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){var n=t.updateOrder-e.updateOrder;return 0==n&&(n=t.id-e.id),n},t}();t.EntityComparer=e;var n=function(){function n(e){this.updateInterval=1,this._tag=0,this._enabled=!0,this._updateOrder=0,this.components=new t.ComponentList(this),this.transform=new t.Transform(this),this.name=e,this.id=n._idGenerator++,t.Core.entitySystemsEnabled&&(this.componentBits=new t.BitSet)}return Object.defineProperty(n.prototype,"isDestroyed",{get:function(){return this._isDestroyed},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"tag",{get:function(){return this._tag},set:function(t){this.setTag(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"updateOrder",{get:function(){return this._updateOrder},set:function(t){this.setUpdateOrder(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this.transform.parent},set:function(t){this.transform.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"childCount",{get:function(){return this.transform.childCount},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"position",{get:function(){return this.transform.position},set:function(t){this.transform.setPosition(t.x,t.y)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localPosition",{get:function(){return this.transform.localPosition},set:function(t){this.transform.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"rotation",{get:function(){return this.transform.rotation},set:function(t){this.transform.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"rotationDegrees",{get:function(){return this.transform.rotationDegrees},set:function(t){this.transform.setRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localRotation",{get:function(){return this.transform.localRotation},set:function(t){this.transform.setLocalRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localRotationDegrees",{get:function(){return this.transform.localRotationDegrees},set:function(t){this.transform.setLocalRotationDegrees(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"scale",{get:function(){return this.transform.scale},set:function(t){this.transform.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localScale",{get:function(){return this.transform.localScale},set:function(t){this.transform.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"worldInverseTransform",{get:function(){return this.transform.worldInverseTransform},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localToWorldTransform",{get:function(){return this.transform.localToWorldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"worldToLocalTransform",{get:function(){return this.transform.worldToLocalTransform},enumerable:!0,configurable:!0}),n.prototype.onTransformChanged=function(t){this.components.onEntityTransformChanged(t)},n.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},n.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.components.onEntityEnabled():this.components.onEntityDisabled()),this},n.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},n.prototype.destroy=function(){this._isDestroyed=!0,this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destroy()}},n.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()},n.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)},n.prototype.onAddedToScene=function(){},n.prototype.onRemovedFromScene=function(){this._isDestroyed&&this.components.removeAllComponents()},n.prototype.update=function(){this.components.update()},n.prototype.addComponent=function(t){return t.entity=this,this.components.add(t),t.initialize(),t},n.prototype.getComponent=function(t){return this.components.getComponent(t,!1)},n.prototype.hasComponent=function(t){return null!=this.components.getComponent(t,!1)},n.prototype.getOrCreateComponent=function(t){var e=this.components.getComponent(t,!0);return e||(e=this.addComponent(new t)),e},n.prototype.getComponents=function(t,e){return this.components.getComponents(t,e)},n.prototype.removeComponent=function(t){this.components.remove(t)},n.prototype.removeComponentForType=function(t){var e=this.getComponent(t);return!!e&&(this.removeComponent(e),!0)},n.prototype.removeAllComponents=function(){for(var t=0;t<this.components.count;t++)this.removeComponent(this.components.buffer[t])},n.prototype.compareTo=function(t){var e=this._updateOrder-t._updateOrder;return 0==e&&(e=this.id-t.id),e},n.prototype.equals=function(t){return 0==this.compareTo(t)},n.prototype.getHashCode=function(){return this.id},n.prototype.toString=function(){return"[Entity: name: "+this.name+", tag: "+this.tag+", enabled: "+this.enabled+", depth: "+this.updateOrder+"]"},n._idGenerator=0,n.entityComparer=new e,n}();t.Entity=n}(es||(es={})),function(t){var e=function(){function e(){this._sceneComponents=new t.FastList,this.entities=new t.EntityList(this),t.Core.entitySystemsEnabled&&(this.entityProcessors=new t.EntityProcessorList),this.initialize()}return e.prototype.initialize=function(){},e.prototype.onStart=function(){},e.prototype.unload=function(){},e.prototype.begin=function(){t.Physics.reset(),this.updateResolutionScaler(),null!=this.entityProcessors&&this.entityProcessors.begin(),t.Core.emitter.addObserver(t.CoreEvents.GraphicsDeviceReset,this.updateResolutionScaler,this),t.Core.emitter.addObserver(t.CoreEvents.OrientationChanged,this.updateResolutionScaler,this),this._didSceneBegin=!0,this.onStart()},e.prototype.end=function(){this._didSceneBegin=!1,t.Core.emitter.removeObserver(t.CoreEvents.GraphicsDeviceReset,this.updateResolutionScaler),t.Core.emitter.removeObserver(t.CoreEvents.OrientationChanged,this.updateResolutionScaler),this.entities.removeAllEntities();for(var e=0;e<this._sceneComponents.length;e++)this._sceneComponents.buffer[e].onRemovedFromScene();this._sceneComponents.clear(),t.Physics.clear(),this.entityProcessors&&this.entityProcessors.end(),this.unload()},e.prototype.updateResolutionScaler=function(){},e.prototype.update=function(){this.entities.updateLists();for(var t=this._sceneComponents.length-1;t>=0;t--)this._sceneComponents.buffer[t].enabled&&this._sceneComponents.buffer[t].update();null!=this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),null!=this.entityProcessors&&this.entityProcessors.lateUpdate()},e.prototype.addSceneComponent=function(t){return t.scene=this,t.onEnabled(),this._sceneComponents.add(t),this._sceneComponents.sort(t),t},e.prototype.getSceneComponent=function(t){for(var e=0;e<this._sceneComponents.length;e++){var n=this._sceneComponents.buffer[e];if(n instanceof t)return n}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(t){this._sceneComponents.contains(t)?(this._sceneComponents.remove(t),t.onRemovedFromScene()):console.warn("SceneComponent"+t+"不在SceneComponents列表中!")},e.prototype.createEntity=function(e){var n=new t.Entity(e);return this.addEntity(n)},e.prototype.addEntity=function(t){this.entities.buffer.contains(t)&&console.warn("您试图将同一实体添加到场景两次: "+t),this.entities.add(t),t.scene=this;for(var e=0;e<t.transform.childCount;e++)this.addEntity(t.transform.getChild(e).entity);return t},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.findEntitiesWithTag=function(t){return this.entities.entitiesWithTag(t)},e.prototype.entitiesOfType=function(t){return this.entities.entitiesOfType(t)},e.prototype.findComponentOfType=function(t){return this.entities.findComponentOfType(t)},e.prototype.findComponentsOfType=function(t){return this.entities.findComponentsOfType(t)},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(){return this.entityProcessors.getProcessor()},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=3]="rotationDirty"}(e=t.DirtyType||(t.DirtyType={}));var n=function(){function n(e){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(n.prototype,"childCount",{get:function(){return this._children.length},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"rotationDegrees",{get:function(){return t.MathHelper.toDegrees(this._rotation)},set:function(e){this.setRotation(t.MathHelper.toRadians(e))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localRotationDegrees",{get:function(){return t.MathHelper.toDegrees(this._localRotation)},set:function(e){this.localRotation=t.MathHelper.toRadians(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localToWorldTransform",{get:function(){return this.updateTransform(),this._worldTransform},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},set:function(t){this.setParent(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"worldToLocalTransform",{get:function(){return this._worldToLocalDirty&&(this.parent?(this.parent.updateTransform(),this._worldToLocalTransform=t.Matrix2D.invert(this.parent._worldTransform)):this._worldToLocalTransform=t.Matrix2D.identity,this._worldToLocalDirty=!1),this._worldToLocalTransform},enumerable:!0,configurable:!0}),Object.defineProperty(n.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(n.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(n.prototype,"scale",{get:function(){return this.updateTransform(),this._scale},set:function(t){this.setScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"rotation",{get:function(){return this.updateTransform(),this._rotation},set:function(t){this.setRotation(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localPosition",{get:function(){return this.updateTransform(),this._localPosition},set:function(t){this.setLocalPosition(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localScale",{get:function(){return this.updateTransform(),this._localScale},set:function(t){this.setLocalScale(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"localRotation",{get:function(){return this.updateTransform(),this._localRotation},set:function(t){this.setLocalRotation(t)},enumerable:!0,configurable:!0}),n.prototype.getChild=function(t){return this._children[t]},n.prototype.setParent=function(t){if(this._parent==t)return this;if(!this._parent){var n=new linq.List(this._parent._children);n.remove(this),n.add(this)}return this._parent=t,this.setDirty(e.positionDirty),this},n.prototype.setPosition=function(e,n){var i=new t.Vector2(e,n);return i.equals(this._position)?this:(this._position=i,null!=this.parent?this.localPosition=t.Vector2.transform(this._position,this._worldToLocalTransform):this.localPosition=i,this._positionDirty=!1,this)},n.prototype.setLocalPosition=function(t){return t.equals(this._localPosition)?this:(this._localPosition=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.positionDirty),this)},n.prototype.setRotation=function(t){return this._rotation=t,this.parent?this.localRotation=this.parent.rotation+t:this.localRotation=t,this},n.prototype.setRotationDegrees=function(e){return this.setRotation(t.MathHelper.toRadians(e))},n.prototype.lookAt=function(e){var n=this.position.x>e.x?-1:1,i=t.Vector2.normalize(t.Vector2.subtract(this.position,e));this.rotation=n*Math.acos(t.Vector2.dot(i,t.Vector2.unitY))},n.prototype.setLocalRotation=function(t){return this._localRotation=t,this._localDirty=this._positionDirty=this._localPositionDirty=this._localRotationDirty=this._localScaleDirty=!0,this.setDirty(e.rotationDirty),this},n.prototype.setLocalRotationDegrees=function(e){return this.setLocalRotation(t.MathHelper.toRadians(e))},n.prototype.setScale=function(e){return this._scale=e,this.parent?this.localScale=t.Vector2.divide(e,this.parent._scale):this.localScale=e,this},n.prototype.setLocalScale=function(t){return this._localScale=t,this._localDirty=this._positionDirty=this._localScaleDirty=!0,this.setDirty(e.scaleDirty),this},n.prototype.roundPosition=function(){this.position=this._position.round()},n.prototype.updateTransform=function(){this.hierarchyDirty!=e.clean&&(null!=this.parent&&this.parent.updateTransform(),this._localDirty&&(this._localPositionDirty&&(this._translationMatrix=t.Matrix2D.createTranslation(this._localPosition.x,this._localPosition.y),this._localPositionDirty=!1),this._localRotationDirty&&(this._rotationMatrix=t.Matrix2D.createRotation(this._localRotation),this._localRotationDirty=!1),this._localScaleDirty&&(this._scaleMatrix=t.Matrix2D.createScale(this._localScale.x,this._localScale.y),this._localScaleDirty=!1),this._localTransform=this._scaleMatrix.multiply(this._rotationMatrix),this._localTransform=this._localTransform.multiply(this._translationMatrix),null==this.parent&&(this._worldTransform=this._localTransform,this._rotation=this._localRotation,this._scale=this._localScale,this._worldInverseDirty=!0),this._localDirty=!1),null!=this.parent&&(this._worldTransform=this._localTransform.multiply(this.parent._worldTransform),this._rotation=this._localRotation+this.parent._rotation,this._scale=t.Vector2.multiply(this.parent._scale,this._localScale),this._worldInverseDirty=!0),this._worldToLocalDirty=!0,this._positionDirty=!0,this.hierarchyDirty=e.clean)},n.prototype.setDirty=function(e){if(0==(this.hierarchyDirty&e)){switch(this.hierarchyDirty|=e,e){case t.DirtyType.positionDirty:this.entity.onTransformChanged(transform.Component.position);break;case t.DirtyType.rotationDirty:this.entity.onTransformChanged(transform.Component.rotation);break;case t.DirtyType.scaleDirty:this.entity.onTransformChanged(transform.Component.scale)}for(var n=0;n<this._children.length;n++)this._children[n].setDirty(e)}},n.prototype.copyFrom=function(t){this._position=t.position,this._localPosition=t._localPosition,this._rotation=t._rotation,this._localRotation=t._localRotation,this._scale=t._scale,this._localScale=t._localScale,this.setDirty(e.positionDirty),this.setDirty(e.rotationDirty),this.setDirty(e.scaleDirty)},n.prototype.toString=function(){return"[Transform: parent: "+this.parent+", position: "+this.position+", rotation: "+this.rotation+",\n scale: "+this.scale+", localPosition: "+this._localPosition+", localRotation: "+this._localRotation+",\n localScale: "+this._localScale+"]"},n}();t.Transform=n}(es||(es={})),function(t){var e=function(){function t(t){this._type=t,this._cache=[]}return t.prototype.obtain=function(){try{return this._cache.length>0?this._cache.shift():new this._type}catch(t){throw new Error(this._type+t)}},t.prototype.free=function(t){t.reset(),this._cache.push(t)},t}();t.ComponentPool=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e,t.isIUpdatable=function(t){return void 0!==t.update}}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e}(t.Component);t.PooledComponent=e}(es||(es={})),function(t){var e=function(){function e(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),e.prototype.onEnabled=function(){},e.prototype.onDisabled=function(){},e.prototype.onRemovedFromScene=function(){},e.prototype.update=function(){},e.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},e.prototype.setUpdateOrder=function(e){return this.updateOrder!=e&&(this.updateOrder=e,t.Core.scene._sceneComponents.sort(this)),this},e.prototype.compare=function(t){return this.updateOrder-t.updateOrder},e}();t.SceneComponent=e}(es||(es={})),function(t){var e=function(){function e(){}return e.getITriggerListener=function(e,n){for(var i=0;i<e.components._components.length;i++){var r=e.components._components.buffer[i];t.isITriggerListener(r)&&n.push(r)}for(i=0;i<e.components._componentsToAdd.length;i++){r=e.components._componentsToAdd[i];t.isITriggerListener(r)&&n.push(r)}return n},e}();t.TriggerListenerHelper=e,t.isITriggerListener=function(t){return void 0!==t.onTriggerEnter}}(es||(es={})),function(t){var e=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return __extends(n,e),n.prototype.onAddedToEntity=function(){this._triggerHelper=new t.ColliderTriggerHelper(this.entity)},n.prototype.calculateMovement=function(e,n){if(null==this.entity.getComponent(t.Collider)||null==this._triggerHelper)return!1;for(var i=this.entity.getComponents(t.Collider),r=function(r){var o=i[r];if(o.isTrigger)return"continue";var s=o.bounds.clone();s.x+=e.x,s.y+=e.y,t.Physics.boxcastBroadphaseExcludingSelf(o,s,o.collidesWithLayers.value).forEach(function(i){var r=i;if(!r.isTrigger){var s=new t.CollisionResult;o.collidesWith(r,e,s)&&(e.subtract(s.minimumTranslationVector),null!=s.collider&&(n=s))}})},o=0;o<i.length;o++)r(o);return t.ListPool.free(i),null!=n.collider},n.prototype.applyMovement=function(e){this.entity.position=t.Vector2.add(this.entity.position,e),this._triggerHelper&&this._triggerHelper.update()},n.prototype.move=function(t,e){return this.calculateMovement(t,e),this.applyMovement(t),null!=e.collider},n}(t.Component);t.Mover=e}(es||(es={})),function(t){var e=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t._tempTriggerList=[],t}return __extends(n,e),n.prototype.onAddedToEntity=function(){this._collider=this.entity.getComponent(t.Collider),this._collider||console.warn("ProjectileMover has no Collider. ProjectilMover requires a Collider!")},n.prototype.move=function(e){if(!this._collider)return!1;var n=!1;this.entity.position=t.Vector2.add(this.entity.position,e);for(var i=t.Physics.boxcastBroadphase(this._collider.bounds,this._collider.collidesWithLayers.value),r=0;r<i.size;r++){var o=i[r];this._collider.overlaps(o)&&o.enabled&&(n=!0,this.notifyTriggerListeners(this._collider,o))}return n},n.prototype.notifyTriggerListeners=function(e,n){t.TriggerListenerHelper.getITriggerListener(n.entity,this._tempTriggerList);for(var i=0;i<this._tempTriggerList.length;i++)this._tempTriggerList[i].onTriggerEnter(e,n);this._tempTriggerList.length=0,t.TriggerListenerHelper.getITriggerListener(this.entity,this._tempTriggerList);for(i=0;i<this._tempTriggerList.length;i++)this._tempTriggerList[i].onTriggerEnter(n,e);this._tempTriggerList.length=0},n}(t.Component);t.ProjectileMover=e}(es||(es={})),function(t){var e=function(e){function n(){var n=null!==e&&e.apply(this,arguments)||this;return n.isTrigger=!1,n.physicsLayer=new t.Ref(1),n.collidesWithLayers=new t.Ref(t.Physics.allLayers),n.shouldColliderScaleAndRotateWithTransform=!0,n.registeredPhysicsBounds=new t.Rectangle,n._isPositionDirty=!0,n._isRotationDirty=!0,n._localOffset=t.Vector2.zero,n}return __extends(n,e),Object.defineProperty(n.prototype,"absolutePosition",{get:function(){return t.Vector2.add(this.entity.transform.position,this._localOffset)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"rotation",{get:function(){return this.shouldColliderScaleAndRotateWithTransform&&this.entity?this.entity.transform.rotation:0},enumerable:!0,configurable:!0}),Object.defineProperty(n.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(n.prototype,"localOffset",{get:function(){return this._localOffset},set:function(t){this.setLocalOffset(t)},enumerable:!0,configurable:!0}),n.prototype.setLocalOffset=function(t){return this._localOffset!=t&&(this.unregisterColliderWithPhysicsSystem(),this._localOffset=t,this._localOffsetLength=this._localOffset.length(),this._isPositionDirty=!0,this.registerColliderWithPhysicsSystem()),this},n.prototype.setShouldColliderScaleAndRotateWithTransform=function(t){return this.shouldColliderScaleAndRotateWithTransform=t,this._isPositionDirty=this._isRotationDirty=!0,this},n.prototype.onAddedToEntity=function(){this._isParentEntityAddedToScene=!0,this.registerColliderWithPhysicsSystem()},n.prototype.onRemovedFromEntity=function(){this.unregisterColliderWithPhysicsSystem(),this._isParentEntityAddedToScene=!1},n.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)},n.prototype.onEnabled=function(){this.registerColliderWithPhysicsSystem(),this._isPositionDirty=this._isRotationDirty=!0},n.prototype.onDisabled=function(){this.unregisterColliderWithPhysicsSystem()},n.prototype.registerColliderWithPhysicsSystem=function(){this._isParentEntityAddedToScene&&!this._isColliderRegistered&&(t.Physics.addCollider(this),this._isColliderRegistered=!0)},n.prototype.unregisterColliderWithPhysicsSystem=function(){this._isParentEntityAddedToScene&&this._isColliderRegistered&&t.Physics.removeCollider(this),this._isColliderRegistered=!1},n.prototype.overlaps=function(t){return this.shape.overlaps(t.shape)},n.prototype.collidesWith=function(e,n,i){var r=this.entity.position.clone();this.entity.position=t.Vector2.add(this.entity.position,n);var o=this.shape.collidesWithShape(e.shape,i);return o&&(i.collider=e),this.entity.position=r,o},n}(t.Component);t.Collider=e}(es||(es={})),function(t){var e=function(e){function n(n,i,r,o){var s=e.call(this)||this;return s._localOffset=new t.Vector2(n+r/2,i+o/2),s.shape=new t.Box(r,o),s}return __extends(n,e),Object.defineProperty(n.prototype,"width",{get:function(){return this.shape.width},set:function(t){this.setWidth(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"height",{get:function(){return this.shape.height},set:function(t){this.setHeight(t)},enumerable:!0,configurable:!0}),n.prototype.setSize=function(e,n){var i=this.shape;return e==i.width&&n==i.height||(i.updateBox(e,n),this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},n.prototype.setWidth=function(e){var n=this.shape;return e!=n.width&&(n.updateBox(e,n.height),this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},n.prototype.setHeight=function(e){var n=this.shape;e!=n.height&&(n.updateBox(n.width,e),this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this))},n.prototype.toString=function(){return"[BoxCollider: bounds: "+this.bounds+"]"},n}(t.Collider);t.BoxCollider=e}(es||(es={})),function(t){var e=function(e){function n(n){var i=e.call(this)||this;return i.shape=new t.Circle(n),i}return __extends(n,e),Object.defineProperty(n.prototype,"radius",{get:function(){return this.shape.radius},set:function(t){this.setRadius(t)},enumerable:!0,configurable:!0}),n.prototype.setRadius=function(e){var n=this.shape;return e!=n.radius&&(n.radius=e,n._originalRadius=e,this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},n.prototype.toString=function(){return"[CircleCollider: bounds: "+this.bounds+", radius: "+this.shape.radius+"]"},n}(t.Collider);t.CircleCollider=e}(es||(es={})),function(t){var e=function(e){function n(n){var i=e.call(this)||this,r=n[0]==n[n.length-1],o=new linq.List(n);r&&o.remove(o.last());var s=t.Polygon.findPolygonCenter(n);return i.setLocalOffset(s),t.Polygon.recenterPolygonVerts(n),i.shape=new t.Polygon(n),i}return __extends(n,e),n}(t.Collider);t.PolygonCollider=e}(es||(es={})),function(t){var e=function(){function e(e){this._entities=[],this._matcher=e||t.Matcher.empty()}return Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(t){this._scene=t,this._entities=[]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"matcher",{get:function(){return this._matcher},enumerable:!0,configurable:!0}),e.prototype.initialize=function(){},e.prototype.onChanged=function(t){var e=new linq.List(this._entities).contains(t),n=this._matcher.isInterestedEntity(t);n&&!e?this.add(t):!n&&e&&this.remove(t)},e.prototype.add=function(t){this._entities.push(t),this.onAdded(t)},e.prototype.onAdded=function(t){},e.prototype.remove=function(t){new linq.List(this._entities).remove(t),this.onRemoved(t)},e.prototype.onRemoved=function(t){},e.prototype.update=function(){this.begin(),this.process(this._entities)},e.prototype.lateUpdate=function(){this.lateProcess(this._entities),this.end()},e.prototype.begin=function(){},e.prototype.process=function(t){},e.prototype.lateProcess=function(t){},e.prototype.end=function(){},e}();t.EntitySystem=e}(es||(es={})),function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.lateProcessEntity=function(t){},e.prototype.process=function(t){var e=this;t.forEach(function(t){return e.processEntity(t)})},e.prototype.lateProcess=function(t){var e=this;t.forEach(function(t){return e.lateProcessEntity(t)})},e}(t.EntitySystem);t.EntityProcessingSystem=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.onChanged=function(t){},e.prototype.process=function(t){this.begin(),this.end()},e}(t.EntitySystem);t.PassiveSystem=e}(es||(es={})),function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.onChanged=function(t){},e.prototype.process=function(t){this.begin(),this.processSystem(),this.end()},e}(t.EntitySystem);t.ProcessingSystem=e}(es||(es={})),function(t){var e=function(){function t(e){void 0===e&&(e=64);var n=e>>6;0!=(e&t.LONG_MASK)&&n++,this._bits=new Array(n),this._bits.fill(0)}return t.prototype.and=function(t){for(var e,n=Math.min(this._bits.length,t._bits.length),i=0;i<n;++i)this._bits[i]&=t._bits[i];for(;e<this._bits.length;)this._bits[e++]=0},t.prototype.andNot=function(t){for(var e=Math.min(this._bits.length,t._bits.length);--e>=0;)this._bits[e]&=~t._bits[e]},t.prototype.cardinality=function(){for(var t=0,e=this._bits.length-1;e>=0;e--){var n=this._bits[e];if(0!=n)if(-1!=n){var i=((n=((n=(n>>1&0x5555555555555400)+(0x5555555555555400&n))>>2&0x3333333333333400)+(0x3333333333333400&n))>>32)+n>>>0;t+=((i=((i=(i>>4&252645135)+(252645135&i))>>8&16711935)+(16711935&i))>>16&65535)+(65535&i)}else t+=64}return t},t.prototype.clear=function(t){if(null!=t){var e=t>>6;this.ensure(e),this._bits[e]&=~(1<<t)}else for(var n=0;n<this._bits.length;n++)this._bits[n]=0},t.prototype.get=function(t){var e=t>>6;return!(e>=this._bits.length)&&0!=(this._bits[e]&1<<t)},t.prototype.intersects=function(t){for(var e=Math.min(this._bits.length,t._bits.length);--e>=0;)if(0!=(this._bits[e]&t._bits[e]))return!0;return!1},t.prototype.isEmpty=function(){for(var t=this._bits.length-1;t>=0;t--)if(this._bits[t])return!1;return!0},t.prototype.nextSetBit=function(t){for(var e=t>>6,n=1<<t;e<this._bits.length;){var i=this._bits[e];do{if(0!=(i&n))return t;n<<=1,t++}while(0!=n);n=1,e++}return-1},t.prototype.set=function(t,e){if(void 0===e&&(e=!0),e){var n=t>>6;this.ensure(n),this._bits[n]|=1<<t}else this.clear(t)},t.prototype.ensure=function(t){if(t>=this._bits.length){var e=this._bits.length;this._bits.length=t+1,this._bits.fill(0,e,t+1)}},t.LONG_MASK=63,t}();t.BitSet=e}(es||(es={})),function(t){var e=function(){function e(e){this._components=new t.FastList,this._updatableComponents=new t.FastList,this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=e}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.buffer},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(t){var e=new linq.List(this._componentsToRemove),n=new linq.List(this._componentsToAdd);e.contains(t)&&console.warn("您正在尝试删除一个您已经删除的组件("+t+")"),n.contains(t)?n.remove(t):e.add(t)},e.prototype.removeAllComponents=function(){for(var t=0;t<this._components.length;t++)this.handleRemove(this._components[t]);this._components.clear(),this._updatableComponents.clear(),this._componentsToAdd.length=0,this._componentsToRemove.length=0},e.prototype.deregisterAllComponents=function(){for(var e=0;e<this._components.length;e++){var n=this._components.buffer[e];n&&(t.isIUpdatable(n)&&this._updatableComponents.remove(n),t.Core.entitySystemsEnabled&&(this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(n)),!1),this._entity.scene.entityProcessors.onComponentRemoved(this._entity)))}},e.prototype.registerAllComponents=function(){for(var e=0;e<this._components.length;e++){var n=this._components.buffer[e];t.isIUpdatable(n)&&this._updatableComponents.add(n),t.Core.entitySystemsEnabled&&(this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(n))),this._entity.scene.entityProcessors.onComponentAdded(this._entity))}},e.prototype.updateLists=function(){if(this._componentsToRemove.length>0){for(var n=0;n<this._componentsToRemove.length;n++)this.handleRemove(this._componentsToRemove[n]),this._components.remove(this._componentsToRemove[n]);this._componentsToRemove.length=0}if(this._componentsToAdd.length>0){n=0;for(var i=this._componentsToAdd.length;n<i;n++){var r=this._componentsToAdd[n];t.isIUpdatable(r)&&this._updatableComponents.add(r),t.Core.entitySystemsEnabled&&(this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(r))),this._entity.scene.entityProcessors.onComponentAdded(this._entity)),this._components.add(r),this._tempBufferList.push(r)}this._componentsToAdd.length=0,this._isComponentListUnsorted=!0;for(n=0;n<this._tempBufferList.length;n++){(r=this._tempBufferList[n]).onAddedToEntity(),r.enabled&&r.onEnabled()}this._tempBufferList.length=0}this._isComponentListUnsorted&&(this._updatableComponents.sort(e.compareUpdatableOrder),this._isComponentListUnsorted=!1)},e.prototype.handleRemove=function(e){e&&(t.isIUpdatable(e)&&this._updatableComponents.remove(e),t.Core.entitySystemsEnabled&&(this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(e)),!1),this._entity.scene.entityProcessors.onComponentRemoved(this._entity)),e.onRemovedFromEntity(),e.entity=null)},e.prototype.getComponent=function(t,e){for(var n=0;n<this._components.length;n++){if((i=this._components.buffer[n])instanceof t)return i}if(!e)for(n=0;n<this._componentsToAdd.length;n++){var i;if((i=this._componentsToAdd[n])instanceof t)return i}return null},e.prototype.getComponents=function(t,e){e||(e=[]);for(var n=0;n<this._components.length;n++){(i=this._components.buffer[n])instanceof t&&e.push(i)}for(n=0;n<this._componentsToAdd.length;n++){var i;(i=this._componentsToAdd[n])instanceof t&&e.push(i)}return e},e.prototype.update=function(){this.updateLists();for(var t=0;t<this._updatableComponents.length;t++)this._updatableComponents.buffer[t].enabled&&this._updatableComponents.buffer[t].update()},e.prototype.onEntityTransformChanged=function(t){for(var e=0;e<this._components.length;e++)this._components.buffer[e].enabled&&this._components.buffer[e].onEntityTransformChanged(t);for(e=0;e<this._componentsToAdd.length;e++)this._componentsToAdd[e].enabled&&this._componentsToAdd[e].onEntityTransformChanged(t)},e.prototype.onEntityEnabled=function(){for(var t=0;t<this._components.length;t++)this._components.buffer[t].onEnabled()},e.prototype.onEntityDisabled=function(){for(var t=0;t<this._components.length;t++)this._components.buffer[t].onDisabled()},e.compareUpdatableOrder=new t.IUpdatableComparer,e}();t.ComponentList=e}(es||(es={})),function(t){var e=function(){function t(){}return t.add=function(t){this._componentTypesMask.has(t)||this._componentTypesMask.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(e){this._entities=new t.FastList,this._entitiesToAdded=new t.HashSet,this._entitiesToRemove=new t.HashSet,this._entityDict=new Map,this._unsortedTags=new Set,this.scene=e}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.add(t)},e.prototype.remove=function(t){this._entitiesToRemove.contains(t)?this._entitiesToAdded.contains(t)?this._entitiesToAdded.remove(t):this._entitiesToRemove.contains(t)||this._entitiesToRemove.add(t):console.warn("您正在尝试删除已经删除的实体("+t.name+")")},e.prototype.removeAllEntities=function(){this._unsortedTags.clear(),this._entitiesToAdded.clear(),this._isEntityListUnsorted=!1,this.updateLists();for(var t=0;t<this._entities.length;t++)this._entities.buffer[t]._isDestroyed=!0,this._entities.buffer[t].onRemovedFromScene(),this._entities.buffer[t].scene=null;this._entities.clear(),this._entityDict.clear()},e.prototype.contains=function(t){return this._entities.contains(t)||this._entitiesToAdded.contains(t)},e.prototype.getTagList=function(t){var e=this._entityDict.get(t);return e||(e=[],this._entityDict.set(t,e)),e},e.prototype.addToTagList=function(t){var e=this.getTagList(t.tag);-1==e.findIndex(function(e){return e.id==t.id})&&(e.push(t),this._unsortedTags.add(t.tag))},e.prototype.removeFromTagList=function(t){var e=this._entityDict.get(t.tag);e&&new linq.List(e).remove(t)},e.prototype.update=function(){for(var e=0;e<this._entities.length;e++){var n=this._entities.buffer[e];!n.enabled||1!=n.updateInterval&&t.Time.frameCount%n.updateInterval!=0||n.update()}},e.prototype.updateLists=function(){var e=this;this._entitiesToRemove.getCount()>0&&(this._entitiesToRemove.toArray().forEach(function(n){e.removeFromTagList(n),e._entities.remove(n),n.onRemovedFromScene(),n.scene=null,t.Core.entitySystemsEnabled&&e.scene.entityProcessors.onEntityRemoved(n)}),this._entitiesToRemove.clear()),this._entitiesToAdded.getCount()>0&&(this._entitiesToAdded.toArray().forEach(function(n){e._entities.add(n),n.scene=e.scene,e.addToTagList(n),t.Core.entitySystemsEnabled&&e.scene.entityProcessors.onEntityAdded(n)}),this._entitiesToAdded.toArray().forEach(function(t){t.onAddedToScene()}),this._entitiesToAdded.clear(),this._isEntityListUnsorted=!0),this._isEntityListUnsorted&&(this._entities.sort(t.Entity.entityComparer),this._isEntityListUnsorted=!1),this._unsortedTags.size>0&&(this._unsortedTags.forEach(function(t){return e._entityDict.get(t).sort(function(t,e){return t.compareTo(e)})}),this._unsortedTags.clear())},e.prototype.findEntity=function(t){for(var e=0;e<this._entities.length;e++)if(this._entities.buffer[e].name==t)return this._entities.buffer[e];for(e=0;e<this._entitiesToAdded.getCount();e++){var n=this._entitiesToAdded.toArray()[e];if(n.name==t)return n}return null},e.prototype.entitiesWithTag=function(e){var n=this.getTagList(e),i=t.ListPool.obtain();i.length=this._entities.length;for(var r=0;r<n.length;r++)i.push(n[r]);return i},e.prototype.entitiesOfType=function(e){for(var n=t.ListPool.obtain(),i=0;i<this._entities.length;i++)this._entities.buffer[i]instanceof e&&n.push(this._entities.buffer[i]);for(i=0;i<this._entitiesToAdded.getCount();i++){var r=this._entitiesToAdded.toArray()[i];t.TypeUtils.getType(r)instanceof e&&n.push(r)}return n},e.prototype.findComponentOfType=function(t){for(var e=0;e<this._entities.length;e++){if(this._entities.buffer[e].enabled)if(n=this._entities.buffer[e].getComponent(t))return n}for(e=0;e<this._entitiesToAdded.getCount();e++){var n,i=this._entitiesToAdded.toArray()[e];if(i.enabled)if(n=i.getComponent(t))return n}return null},e.prototype.findComponentsOfType=function(e){for(var n=t.ListPool.obtain(),i=0;i<this._entities.length;i++)this._entities.buffer[i].enabled&&this._entities.buffer[i].getComponents(e,n);for(i=0;i<this._entitiesToAdded.getCount();i++){var r=this._entitiesToAdded.toArray()[i];r.enabled&&r.getComponents(e,n)}return n},e}();t.EntityList=e}(es||(es={})),function(t){var e=function(){function e(){this._processors=[]}return e.prototype.add=function(t){this._processors.push(t)},e.prototype.remove=function(t){new linq.List(this._processors).remove(t)},e.prototype.onComponentAdded=function(t){this.notifyEntityChanged(t)},e.prototype.onComponentRemoved=function(t){this.notifyEntityChanged(t)},e.prototype.onEntityAdded=function(t){this.notifyEntityChanged(t)},e.prototype.onEntityRemoved=function(t){this.removeFromProcessors(t)},e.prototype.begin=function(){},e.prototype.update=function(){for(var t=0;t<this._processors.length;t++)this._processors[t].update()},e.prototype.lateUpdate=function(){for(var t=0;t<this._processors.length;t++)this._processors[t].lateUpdate()},e.prototype.end=function(){},e.prototype.getProcessor=function(){for(var e=0;e<this._processors.length;e++){var n=this._processors[e];if(n instanceof t.EntitySystem)return n}return null},e.prototype.notifyEntityChanged=function(t){for(var e=0;e<this._processors.length;e++)this._processors[e].onChanged(t)},e.prototype.removeFromProcessors=function(t){for(var e=0;e<this._processors.length;e++)this._processors[e].remove(t)},e}();t.EntityProcessorList=e}(es||(es={})),function(t){var e=function(){function e(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(i,r,o){var s=t.HashHelpers.getHashCode(i),a=e.reduce(s,this._buckets.length);if(this._freeValueCellIndex==this._values.length){var c=t.HashHelpers.expandPrime(this._freeValueCellIndex);this._values.length=c,this._valuesInfo.length=c}var u=t.NumberExtension.toNumber(this._buckets[a])-1;if(-1==u)this._valuesInfo[this._freeValueCellIndex]=new n(i,s);else{var h=u;do{if(this._valuesInfo[h].hashcode==s&&this._valuesInfo[h].key==i)return this._values[h]=r,o.value=h,!1;h=this._valuesInfo[h].previous}while(-1!=h);this._collisions++,this._valuesInfo[this._freeValueCellIndex]=new n(i,s,u),this._valuesInfo[u].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 l=0;l<this._freeValueCellIndex;l++){a=e.reduce(this._valuesInfo[l].hashcode,this._buckets.length);var p=t.NumberExtension.toNumber(this._buckets[a])-1;this._buckets[a]=l+1,-1!=p?(this._collisions++,this._valuesInfo[l].previous=p,this._valuesInfo[l].next=-1,this._valuesInfo[p].next=l):(this._valuesInfo[l].next=-1,this._valuesInfo[l].previous=-1)}}return!0},e.prototype.remove=function(n){for(var i=e.hash(n),r=e.reduce(i,this._buckets.length),o=t.NumberExtension.toNumber(this._buckets[r])-1;-1!=o;){if(this._valuesInfo[o].hashcode==i&&this._valuesInfo[o].key==n){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 c=this._valuesInfo[this._freeValueCellIndex].next,u=this._valuesInfo[this._freeValueCellIndex].previous;-1!=c&&(this._valuesInfo[c].previous=o),-1!=u&&(this._valuesInfo[u].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(n,i){for(var r=e.hash(n),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==n)return i.value=s,!0;s=this._valuesInfo[s].previous}return i.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 n=e[t].next,i=e[t].previous;-1!=n&&(e[n].previous=i),-1!=i&&(e[i].next=n)},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 n=function(){return function(t,e,n){void 0===n&&(n=-1),this.key=t,this.hashcode=e,this.previous=n,this.next=-1}}();t.FastNode=n}(es||(es={})),function(t){var e=function(){function e(t){void 0===t&&(t=5),this.length=0,this.buffer=new Array(t)}return e.prototype.clear=function(){this.buffer.length=0,this.length=0},e.prototype.reset=function(){this.length=0},e.prototype.add=function(t){this.length==this.buffer.length&&(this.buffer.length=Math.max(this.buffer.length<<1,10)),this.buffer[this.length++]=t},e.prototype.remove=function(e){for(var n=t.EqualityComparer.default(),i=0;i<this.length;++i)if(n.equals(this.buffer[i],e))return void this.removeAt(i)},e.prototype.removeAt=function(t){if(t>=this.length)throw new Error("index超出范围");this.length--,new linq.List(this.buffer).removeAt(t)},e.prototype.contains=function(e){for(var n=t.EqualityComparer.default(),i=0;i<this.length;++i)if(n.equals(this.buffer[i],e))return!0;return!1},e.prototype.ensureCapacity=function(t){void 0===t&&(t=1),this.length+t>=this.buffer.length&&(this.buffer.length=Math.max(this.buffer.length<<1,this.length+t))},e.prototype.addRange=function(t){var e,n;try{for(var i=__values(t),r=i.next();!r.done;r=i.next()){var o=r.value;this.add(o)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e.prototype.sort=function(t){this.buffer.sort(t.compare)},e}();t.FastList=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),n=3;n<=e;n+=2)if(0==(t&n))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 n=this.primes[e];if(n>=t)return n}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,n=0;if(0==(e="object"==typeof t?JSON.stringify(t):t.toString()).length)return n;for(var i=0;i<e.length;i++){n=(n<<5)-n+e.charCodeAt(i),n&=n}return n},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.allSet=new t.BitSet,this.exclusionSet=new t.BitSet,this.oneSet=new t.BitSet}return e.empty=function(){return new e},e.prototype.getAllSet=function(){return this.allSet},e.prototype.getExclusionSet=function(){return this.exclusionSet},e.prototype.getOneSet=function(){return this.oneSet},e.prototype.isInterestedEntity=function(t){return this.isInterested(t.componentBits)},e.prototype.isInterested=function(t){if(!this.allSet.isEmpty())for(var e=this.allSet.nextSetBit(0);e>=0;e=this.allSet.nextSetBit(e+1))if(!t.get(e))return!1;return!(!this.exclusionSet.isEmpty()&&this.exclusionSet.intersects(t))&&!(!this.oneSet.isEmpty()&&!this.oneSet.intersects(t))},e.prototype.all=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return n.forEach(function(n){e.allSet.set(t.ComponentTypeManager.getIndexFor(n))}),this},e.prototype.exclude=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return n.forEach(function(n){e.exclusionSet.set(t.ComponentTypeManager.getIndexFor(n))}),this},e.prototype.one=function(){for(var e=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];return n.forEach(function(n){e.oneSet.set(t.ComponentTypeManager.getIndexFor(n))}),this},e}();t.Matcher=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,n,i){void 0===i&&(i=!1);for(var r=t.length,o="",s=!1,a=1==i?e.toLowerCase():e,c=0;c<r;c++)s=!1,t.charAt(c)==a.charAt(0)&&t.substr(c,a.length)==a&&(s=!0),s?(o+=n,c=c+a.length-1):o+=t.charAt(c);return o},t.htmlSpecialChars=function(t,e){void 0===e&&(e=!1);for(var n=this.specialSigns.length,i=0;i<n;i+=2){var r=void 0,o=void 0;if(r=this.specialSigns[i],o=this.specialSigns[i+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 n=t.length;if(n>=e)return t;var i=!1;"-"==t.substr(0,1)&&(i=!0,t=t.substr(1));for(var r=e-n,o=0;o<r;o++)t="0"+t;return i&&(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,n,i){void 0===i&&(i=!0),e=Math.floor(e),n=Math.floor(n);var r=t.length;e>r&&(e=r);var o,s=e,a=e+n;return i?o=t.substring(0,s)+t.substr(a,r):(a=(s=r-1-e-n)+n,o=t.substring(0,s+1)+t.substr(a+1,r)),o},t.strReplace=function(t,e){for(var n=0,i=e.length;n<i;n++)null!=e[n]&&""!=e[n]||(e[n]="无"),t=t.replace("{"+n+"}",e[n]);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){var e=(t-this._lastTime)/1e3;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.deltaTime=0,t.timeScale=1,t.frameCount=0,t._lastTime=0,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),n=t.getMonth()+1;return parseInt(e+(n<10?"0":"")+n)},t.dateId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getMonth()+1,n=e<10?"0":"",i=t.getDate(),r=i<10?"0":"";return parseInt(t.getFullYear()+n+e+r+i)},t.weekId=function(t,e){void 0===t&&(t=null),void 0===e&&(e=!0),t=t||new Date;var n=new Date;n.setTime(t.getTime()),n.setDate(1),n.setMonth(0);var i=n.getFullYear(),r=n.getDay();0==r&&(r=7);var o=!1;r<=4?(o=r>1,n.setDate(n.getDate()-(r-1))):n.setDate(n.getDate()+7-r+1);var s=this.diffDay(t,n,!1);if(s<0)return n.setDate(1),n.setMonth(0),n.setDate(n.getDate()-1),this.weekId(n,!1);var a=s/7,c=Math.floor(a)+1;if(53==c){n.setTime(t.getTime()),n.setDate(n.getDate()-1);var u=n.getDay();if(0==u&&(u=7),e&&(!o||u<4))return n.setFullYear(n.getFullYear()+1),n.setDate(1),n.setMonth(0),this.weekId(n,!1)}return parseInt(i+"00"+(c>9?"":"0")+c)},t.diffDay=function(t,e,n){void 0===n&&(n=!1);var i=(t.getTime()-e.getTime())/864e5;return n?Math.ceil(i):Math.floor(i)},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(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();return e+"-"+n+"-"+(i=i<10?"0"+i:i)},t.formatDateTime=function(t){var e=t.getFullYear(),n=t.getMonth()+1;n=n<10?"0"+n:n;var i=t.getDate();i=i<10?"0"+i:i;var r=t.getHours(),o=t.getMinutes();o=o<10?"0"+o:o;var s=t.getSeconds();return e+"-"+n+"-"+i+" "+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,n){void 0===t&&(t=0),void 0===e&&(e=":"),void 0===n&&(n=!0);var i=Math.floor(t/3600),r=Math.floor(t%3600/60),o=Math.floor(t%3600%60),s=i.toString(),a=r.toString(),c=o.toString();return i<10&&(s="0"+s),r<10&&(a="0"+a),o<10&&(c="0"+c),n?s+e+a+e+c:a+e+c},t.timeToMillisecond=function(t,e){void 0===e&&(e=":");for(var n=t.split(e),i=0,r=n.length,o=0;o<r;o++){i+=n[o]*Math.pow(60,r-1-o)}return(i*=1e3).toString()},t}();!function(t){var e=function(){function e(){}return e.getPoint=function(e,n,i,r){var o=1-(r=t.MathHelper.clamp01(r));return t.Vector2.add(t.Vector2.add(t.Vector2.multiply(new t.Vector2(o*o),e),t.Vector2.multiply(new t.Vector2(2*o*r),n)),t.Vector2.multiply(new t.Vector2(r*r),i))},e.getFirstDerivative=function(e,n,i,r){return t.Vector2.add(t.Vector2.multiply(new t.Vector2(2*(1-r)),t.Vector2.subtract(n,e)),t.Vector2.multiply(new t.Vector2(2*r),t.Vector2.subtract(i,n)))},e.getFirstDerivativeThree=function(e,n,i,r,o){var s=1-(o=t.MathHelper.clamp01(o));return t.Vector2.add(t.Vector2.add(t.Vector2.multiply(new t.Vector2(3*s*s),t.Vector2.subtract(n,e)),t.Vector2.multiply(new t.Vector2(6*s*o),t.Vector2.subtract(i,n))),t.Vector2.multiply(new t.Vector2(3*o*o),t.Vector2.subtract(r,i)))},e.getPointThree=function(e,n,i,r,o){var s=1-(o=t.MathHelper.clamp01(o));return t.Vector2.add(t.Vector2.add(t.Vector2.add(t.Vector2.multiply(new t.Vector2(s*s*s),e),t.Vector2.multiply(new t.Vector2(3*s*s*o),n)),t.Vector2.multiply(new t.Vector2(3*s*o*o),i)),t.Vector2.multiply(new t.Vector2(o*o*o),r))},e.getOptimizedDrawingPoints=function(e,n,i,r,o){void 0===o&&(o=1);var s=t.ListPool.obtain();return s.push(e),this.recursiveGetOptimizedDrawingPoints(e,n,i,r,s,o),s.push(r),s},e.recursiveGetOptimizedDrawingPoints=function(e,n,i,r,o,s){var a=t.Vector2.divide(t.Vector2.add(e,n),new t.Vector2(2)),c=t.Vector2.divide(t.Vector2.add(n,i),new t.Vector2(2)),u=t.Vector2.divide(t.Vector2.add(i,r),new t.Vector2(2)),h=t.Vector2.divide(t.Vector2.add(a,c),new t.Vector2(2)),l=t.Vector2.divide(t.Vector2.add(c,u),new t.Vector2(2)),p=t.Vector2.divide(t.Vector2.add(h,l),new t.Vector2(2)),f=t.Vector2.subtract(r,e),d=Math.abs((n.x,r.x*f.y-(n.y-r.y)*f.x)),y=Math.abs((i.x-r.x)*f.y-(i.y-r.y)*f.x);(d+y)*(d+y)<s*(f.x*f.x+f.y*f.y)?o.push(p):(this.recursiveGetOptimizedDrawingPoints(e,a,h,p,o,s),this.recursiveGetOptimizedDrawingPoints(p,l,u,r,o,s))},e}();t.Bezier=e}(es||(es={})),function(t){var e=function(){function t(){}return t.isFlagSet=function(t,e){return 0!=(t&e)},t.isUnshiftedFlagSet=function(t,e){return 0!=(t&(e=1<<e))},t.setFlagExclusive=function(t,e){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.map=function(t,e,n,i,r){return i+(t-e)*(r-i)/(n-e)},e.lerp=function(t,e,n){return t+(e-t)*n},e.clamp=function(t,e,n){return t<e?e:t>n?n:t},e.pointOnCirlce=function(n,i,r){var o=e.toRadians(r);return new t.Vector2(Math.cos(o)*o+n.x,Math.sin(o)*o+n.y)},e.isEven=function(t){return t%2==0},e.clamp01=function(t){return t<0?0:t>1?1:t},e.angleBetweenVectors=function(t,e){return Math.atan2(e.y-t.y,e.x-t.x)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.approach=function(t,e,n){return t<e?Math.min(t+n,e):Math.max(t-n,e)},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 e(t,e,n,i,r,o){this.m11=0,this.m12=0,this.m21=0,this.m22=0,this.m31=0,this.m32=0,this.m11=t,this.m12=e,this.m21=n,this.m22=i,this.m31=r,this.m32=o}return Object.defineProperty(e,"identity",{get:function(){return new e(1,0,0,1,0,0)},enumerable:!0,configurable:!0}),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),n=Math.sin(t);this.m11=e,this.m12=n,this.m21=-n,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){var e=this.identity,n=Math.cos(t),i=Math.sin(t);return e.m11=n,e.m12=i,e.m21=-i,e.m22=n,e},e.createScale=function(t,e){var n=this.identity;return n.m11=t,n.m12=0,n.m21=0,n.m22=e,n.m31=0,n.m32=0,n},e.createTranslation=function(t,e){var n=this.identity;return n.m11=1,n.m12=0,n.m21=0,n.m22=1,n.m31=t,n.m32=e,n},e.invert=function(t){var e=1/t.determinant(),n=this.identity;return n.m11=t.m22*e,n.m12=-t.m12*e,n.m21=-t.m21*e,n.m22=t.m11*e,n.m31=(t.m32*t.m21-t.m31*t.m22)*e,n.m32=-(t.m32*t.m11-t.m31*t.m12)*e,n},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,n=this.m11*t.m12+this.m12*t.m22,i=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=n,this.m21=i,this.m22=r,this.m31=o,this.m32=s,this},e.prototype.determinant=function(){return this.m11*this.m22-this.m12*this.m21},e.lerp=function(t,e,n){return t.m11=t.m11+(e.m11-t.m11)*n,t.m12=t.m12+(e.m12-t.m12)*n,t.m21=t.m21+(e.m21-t.m21)*n,t.m22=t.m22+(e.m22-t.m22)*n,t.m31=t.m31+(e.m31-t.m31)*n,t.m32=t.m32+(e.m32-t.m32)*n,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(n,i){var r=e.createTranslation(n,i);return t.MatrixHelper.mutiply(this,r)},e.prototype.equals=function(t){return this==t},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,n){var i=t.Matrix2D.identity;return i.m11=e.m11+n.m11,i.m12=e.m12+n.m12,i.m21=e.m21+n.m21,i.m22=e.m22+n.m22,i.m31=e.m31+n.m31,i.m32=e.m32+n.m32,i},e.divide=function(e,n){var i=t.Matrix2D.identity;return i.m11=e.m11/n.m11,i.m12=e.m12/n.m12,i.m21=e.m21/n.m21,i.m22=e.m22/n.m22,i.m31=e.m31/n.m31,i.m32=e.m32/n.m32,i},e.mutiply=function(e,n){var i=t.Matrix2D.identity;if(n instanceof t.Matrix2D){var r=e.m11*n.m11+e.m12*n.m21,o=n.m11*n.m12+e.m12*n.m22,s=e.m21*n.m11+e.m22*n.m21,a=e.m21*n.m12+e.m22*n.m22,c=e.m31*n.m11+e.m32*n.m21+n.m31,u=e.m31*n.m12+e.m32*n.m22+n.m32;i.m11=r,i.m12=o,i.m21=s,i.m22=a,i.m31=c,i.m32=u}else"number"==typeof n&&(i.m11=e.m11*n,i.m12=e.m12*n,i.m21=e.m21*n,i.m22=e.m22*n,i.m31=e.m31*n,i.m32=e.m32*n);return i},e.subtract=function(e,n){var i=t.Matrix2D.identity;return i.m11=e.m11-n.m11,i.m12=e.m12-n.m12,i.m21=e.m21-n.m21,i.m22=e.m22-n.m22,i.m31=e.m31-n.m31,i.m32=e.m32-n.m32,i},e}();t.MatrixHelper=e}(es||(es={})),function(t){var e=function(){function e(t,e,n,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=0),this.x=0,this.y=0,this.width=0,this.height=0,this.x=t,this.y=e,this.width=n,this.height=i}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,n,i,r){return new e(t,n,i-t,r-n)},e.rectEncompassingPoints=function(t){for(var e=Number.POSITIVE_INFINITY,n=Number.POSITIVE_INFINITY,i=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>i&&(i=s.x),s.y<n&&(n=s.y),s.y>r&&(r=s.y)}return this.fromMinMax(e,n,i,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,e){e.value=0;var n=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!1}else{var i=1/t.direction.x,r=(this.x-t.start.x)*i,o=(this.x+this.width-t.start.x)*i;if(r>o){var s=r;r=o,o=s}if(e.value=Math.max(r,e.value),n=Math.min(o,n),e.value>n)return!1}if(Math.abs(t.direction.y)<1e-6){if(t.start.y<this.y||t.start.y>this.y+this.height)return!1}else{var a=1/t.direction.y,c=(this.y-t.start.y)*a,u=(this.y+this.height-t.start.y)*a;if(c>u){var h=c;c=u,u=h}if(e.value=Math.max(c,e.value),n=Math.max(u,n),e.value>n)return!1}return!0},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,n=Math.abs(this.location.x),i=new t.Vector2(this.location.x,0);return Math.abs(e.x)<n&&(n=Math.abs(e.x),i.x=e.x,i.y=0),Math.abs(e.y)<n&&(n=Math.abs(e.y),i.x=0,i.y=e.y),Math.abs(this.location.y)<n&&(n=Math.abs(this.location.y),i.x=0,i.y=this.location.y),i},e.prototype.getClosestPointOnRectangleToPoint=function(e){var n=new t.Vector2;return n.x=t.MathHelper.clamp(e.x,this.left,this.right),n.y=t.MathHelper.clamp(e.y,this.top,this.bottom),n},e.prototype.getClosestPointOnRectangleBorderToPoint=function(e,n){var i=new t.Vector2;if(i.x=t.MathHelper.clamp(e.x,this.left,this.right),i.y=t.MathHelper.clamp(e.y,this.top,this.bottom),this.contains(i.x,i.y)){var r=i.x-this.left,o=this.right-i.x,s=i.y-this.top,a=this.bottom-i.y,c=Math.min(r,o,s,a);c==s?(i.y=this.top,n.y=-1):c==a?(i.y=this.bottom,n.y=1):c==r?(i.x=this.left,n.x=-1):(i.x=this.right,n.x=1)}else i.x==this.left&&(n.x=-1),i.x==this.right&&(n.x=1),i.y==this.top&&(n.y=-1),i.y==this.bottom&&(n.y=1);return i},e.intersect=function(t,n){if(t.intersects(n)){var i=Math.min(t.x+t.width,n.x+n.width),r=Math.max(t.x,n.x),o=Math.max(t.y,n.y);return new e(r,o,i-r,Math.min(t.y+t.height,n.y+n.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,n){var i=Math.min(t.x,n.x),r=Math.min(t.y,n.y);return new e(i,r,Math.max(t.right,n.right)-i,Math.max(t.bottom,n.bottom)-r)},e.overlap=function(t,n){var i=Math.max(t.x,n.x,0),r=Math.max(t.y,n.y,0);return new e(i,r,Math.max(Math.min(t.right,n.right)-i,0),Math.max(Math.min(t.bottom,n.bottom)-r,0))},e.prototype.calculateBounds=function(e,n,i,r,o,s,a){if(0==o)this.x=e.x+n.x-i.x*r.x,this.y=e.y+n.y-i.y*r.y,this.width=s*r.x,this.height=a*r.y;else{var c=e.x+n.x,u=e.y+n.y;this._transformMat=t.Matrix2D.createTranslation(-c-i.x,-u-i.y),this._tempMat=t.Matrix2D.createScale(r.x,r.y),this._transformMat=this._transformMat.multiply(this._tempMat),this._tempMat=t.Matrix2D.createRotation(o),this._transformMat=this._transformMat.multiply(this._tempMat),this._tempMat=t.Matrix2D.createTranslation(c,u),this._transformMat=this._transformMat.multiply(this._tempMat);var h=new t.Vector2(c,u),l=new t.Vector2(c+s,u),p=new t.Vector2(c,u+a),f=new t.Vector2(c+s,u+a);t.Vector2Ext.transformR(h,this._transformMat,h),t.Vector2Ext.transformR(l,this._transformMat,l),t.Vector2Ext.transformR(p,this._transformMat,p),t.Vector2Ext.transformR(f,this._transformMat,f);var d=Math.min(h.x,f.x,l.x,p.x),y=Math.max(h.x,f.x,l.x,p.x),m=Math.min(h.y,f.y,l.y,p.y),g=Math.max(h.y,f.y,l.y,p.y);this.location=new t.Vector2(d,m),this.width=y-d,this.height=g-m}},e.prototype.getSweptBroadphaseBounds=function(t,n){var i=e.empty;return i.x=t>0?this.x:this.x+t,i.y=n>0?this.y:this.y+n,i.width=t>0?t+this.width:this.width-t,i.height=n>0?n+this.height:this.height-n,i},e.prototype.collisionCheck=function(t,e,n){e.value=n.value=0;var i=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!(i>0||r<0||o>0||s<0)&&(e.value=Math.abs(i)<r?i:r,n.value=Math.abs(o)<s?o:s,Math.abs(e.value)<Math.abs(n.value)?n.value=0:e.value=0,!0)},e.getIntersectionDepth=function(e,n){var i=e.width/2,r=e.height/2,o=n.width/2,s=n.height/2,a=new t.Vector2(e.left+i,e.top+r),c=new t.Vector2(n.left+o,n.top+s),u=a.x-c.x,h=a.y-c.y,l=i+o,p=r+s;if(Math.abs(u)>=l||Math.abs(h)>=p)return t.Vector2.zero;var f=u>0?l-u:-l-u,d=h>0?p-h:-p-h;return new t.Vector2(f,d)},e.prototype.equals=function(t){return this===t},e.prototype.getHashCode=function(){return this.x^this.y^this.width^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.floor(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(t,e){this.x=0,this.y=0,this.x=t||0,this.y=null!=e?e:this.x}return Object.defineProperty(e,"zero",{get:function(){return 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}),e.add=function(t,n){var i=e.zero;return i.x=t.x+n.x,i.y=t.y+n.y,i},e.divide=function(t,n){var i=e.zero;return i.x=t.x/n.x,i.y=t.y/n.y,i},e.multiply=function(t,n){var i=new e(0,0);return i.x=t.x*n.x,i.y=t.y*n.y,i},e.subtract=function(t,n){var i=new e(0,0);return i.x=t.x-n.x,i.y=t.y-n.y,i},e.normalize=function(t){var n=new e(t.x,t.y),i=1/Math.sqrt(n.x*n.x+n.y*n.y);return n.x*=i,n.y*=i,n},e.dot=function(t,e){return t.x*e.x+t.y*e.y},e.distanceSquared=function(t,e){var n=t.x-e.x,i=t.y-e.y;return n*n+i*i},e.clamp=function(n,i,r){return new e(t.MathHelper.clamp(n.x,i.x,r.x),t.MathHelper.clamp(n.y,i.y,r.y))},e.lerp=function(n,i,r){return new e(t.MathHelper.lerp(n.x,i.x,r),t.MathHelper.lerp(n.y,i.y,r))},e.transform=function(t,n){return new e(t.x*n.m11+t.y*n.m21+n.m31,t.x*n.m12+t.y*n.m22+n.m32)},e.distance=function(t,e){var n=t.x-e.x,i=t.y-e.y;return Math.sqrt(n*n+i*i)},e.angle=function(n,i){return n=e.normalize(n),i=e.normalize(i),Math.acos(t.MathHelper.clamp(e.dot(n,i),-1,1))*t.MathHelper.Rad2Deg},e.negate=function(t){return t.x=-t.x,t.y=-t.y,t},e.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this},e.prototype.divide=function(t){return this.x/=t.x,this.y/=t.y,this},e.prototype.multiply=function(t){return this.x*=t.x,this.y*=t.y,this},e.prototype.subtract=function(t){return this.x-=t.x,this.y-=t.y,this},e.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);this.x*=t,this.y*=t},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.round=function(){return new e(Math.round(this.x),Math.round(this.y))},e.prototype.equals=function(t){return t instanceof e&&(t.x==this.x&&t.y==this.y)},e.prototype.clone=function(){return new e(this.x,this.y)},e}();t.Vector2=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=this._entity.getComponents(t.Collider),n=0;n<e.length;n++)for(var i=e[n],r=t.Physics.boxcastBroadphase(i.bounds,i.collidesWithLayers),o=0;o<r.size;o++){var s=r[o];if((i.isTrigger||s.isTrigger)&&i.overlaps(s)){var a=new t.Pair(i,s);!this._activeTriggerIntersections.contains(a)&&!this._previousTriggerIntersections.contains(a)&&this.notifyTriggerListeners(a,!0),this._activeTriggerIntersections.add(a)}}t.ListPool.free(e),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,n){t.TriggerListenerHelper.getITriggerListener(e.first.entity,this._tempTriggerList);for(var i=0;i<this._tempTriggerList.length;i++)if(n?this._tempTriggerList[i].onTriggerEnter(e.second,e.first):this._tempTriggerList[i].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++)n?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 n=function(){function n(){}return n.isLineToLine=function(e,n,i,r){var o=t.Vector2.subtract(n,e),s=t.Vector2.subtract(r,i),a=o.x*s.y-o.y*s.x;if(0==a)return!1;var c=t.Vector2.subtract(i,e),u=(c.x*s.y-c.y*s.x)/a;if(u<0||u>1)return!1;var h=(c.x*o.y-c.y*o.x)/a;return!(h<0||h>1)},n.lineToLineIntersection=function(e,n,i,r){var o=t.Vector2.zero,s=t.Vector2.subtract(n,e),a=t.Vector2.subtract(r,i),c=s.x*a.y-s.y*a.x;if(0==c)return o;var u=t.Vector2.subtract(i,e),h=(u.x*a.y-u.y*a.x)/c;if(h<0||h>1)return o;var l=(u.x*s.y-u.y*s.x)/c;return l<0||l>1?o:o=t.Vector2.add(e,new t.Vector2(h*s.x,h*s.y))},n.closestPointOnLine=function(e,n,i){var r=t.Vector2.subtract(n,e),o=t.Vector2.subtract(i,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,new t.Vector2(r.x*s,r.y*s))},n.circleToCircle=function(e,n,i,r){return t.Vector2.distanceSquared(e,i)<(n+r)*(n+r)},n.circleToLine=function(e,n,i,r){return t.Vector2.distanceSquared(e,this.closestPointOnLine(i,r,e))<n*n},n.circleToPoint=function(e,n,i){return t.Vector2.distanceSquared(e,i)<n*n},n.rectToCircle=function(n,i,r){if(this.rectToPoint(n.x,n.y,n.width,n.height,i))return!0;var o,s,a=this.getSector(n.x,n.y,n.width,n.height,i);return!(0==(a&e.top)||(o=new t.Vector2(n.x,n.y),s=new t.Vector2(n.x+n.width,n.y),!this.circleToLine(i,r,o,s)))||(!(0==(a&e.bottom)||(o=new t.Vector2(n.x,n.y+n.width),s=new t.Vector2(n.x+n.width,n.y+n.height),!this.circleToLine(i,r,o,s)))||(!(0==(a&e.left)||(o=new t.Vector2(n.x,n.y),s=new t.Vector2(n.x,n.y+n.height),!this.circleToLine(i,r,o,s)))||!(0==(a&e.right)||(o=new t.Vector2(n.x+n.width,n.y),s=new t.Vector2(n.x+n.width,n.y+n.height),!this.circleToLine(i,r,o,s)))))},n.rectToLine=function(n,i,r){var o=this.getSector(n.x,n.y,n.width,n.height,i),s=this.getSector(n.x,n.y,n.width,n.height,r);if(o==e.center||s==e.center)return!0;if(0!=(o&s))return!1;var a=o|s,c=void 0,u=void 0;return!(0==(a&e.top)||(c=new t.Vector2(n.x,n.y),u=new t.Vector2(n.x+n.width,n.y),!this.isLineToLine(c,u,i,r)))||(!(0==(a&e.bottom)||(c=new t.Vector2(n.x,n.y+n.height),u=new t.Vector2(n.x+n.width,n.y+n.height),!this.isLineToLine(c,u,i,r)))||(!(0==(a&e.left)||(c=new t.Vector2(n.x,n.y),u=new t.Vector2(n.x,n.y+n.height),!this.isLineToLine(c,u,i,r)))||!(0==(a&e.right)||(c=new t.Vector2(n.x+n.width,n.y),u=new t.Vector2(n.x+n.width,n.y+n.height),!this.isLineToLine(c,u,i,r)))))},n.rectToPoint=function(t,e,n,i,r){return r.x>=t&&r.y>=e&&r.x<t+n&&r.y<e+i},n.getSector=function(t,n,i,r,o){var s=e.center;return o.x<t?s|=e.left:o.x>=t+i&&(s|=e.right),o.y<n?s|=e.top:o.y>=n+r&&(s|=e.bottom),s},n}();t.Collisions=n}(es||(es={})),function(t){var e=function(){function e(e,n,i,r,o){this.fraction=0,this.distance=0,this.point=t.Vector2.zero,this.normal=t.Vector2.zero,this.collider=e,this.fraction=n,this.distance=i,this.point=r,this.centroid=t.Vector2.zero}return e.prototype.setValues=function(t,e,n,i){this.collider=t,this.fraction=e,this.distance=n,this.point=i},e.prototype.setValuesNonCollider=function(t,e,n,i){this.fraction=t,this.distance=e,this.point=n,this.normal=i},e.prototype.reset=function(){this.collider=null,this.fraction=this.distance=0},e.prototype.toString=function(){return"[RaycastHit] fraction: "+this.fraction+", distance: "+this.distance+", normal: "+this.normal+", centroid: "+this.centroid+", point: "+this.point},e}();t.RaycastHit=e}(es||(es={})),function(t){var e=function(){function e(){}return e.reset=function(){this._spatialHash=new t.SpatialHash(this.spatialHashCellSize),this._hitArray[0].reset()},e.clear=function(){this._spatialHash.clear()},e.overlapCircleAll=function(t,e,n,i){if(void 0===i&&(i=-1),0!=n.length)return this._spatialHash.overlapCircle(t,e,n,i);console.error("传入了一个空的结果数组。不会返回任何结果")},e.boxcastBroadphase=function(t,e){return void 0===e&&(e=this.allLayers),this._spatialHash.aabbBroadphase(t,null,e)},e.boxcastBroadphaseExcludingSelf=function(t,e,n){return void 0===n&&(n=this.allLayers),this._spatialHash.aabbBroadphase(e,t,n)},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,n,i){return void 0===i&&(i=e.allLayers),this._hitArray[0].reset(),this.linecastAll(t,n,this._hitArray,i),this._hitArray[0]},e.linecastAll=function(t,n,i,r){return void 0===r&&(r=e.allLayers),0==i.length?(console.warn("传入了一个空的hits数组。没有点击会被返回"),0):this._spatialHash.linecast(t,n,i,r)},e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e}();t.Physics=e}(es||(es={})),function(t){var e=function(){return function(e,n){this.start=e,this.end=n,this.direction=t.Vector2.subtract(this.end,this.start)}}();t.Ray2D=e}(es||(es={})),function(t){var e=function(){function e(e){void 0===e&&(e=100),this.gridBounds=new t.Rectangle,this._overlapTestCircle=new t.Circle(0),this._cellDict=new n,this._tempHashSet=new Set,this._cellSize=e,this._inverseCellSize=1/this._cellSize,this._raycastParser=new i}return e.prototype.register=function(e){var n=e.bounds.clone();e.registeredPhysicsBounds=n;var i=this.cellCoords(n.x,n.y),r=this.cellCoords(n.right,n.bottom);this.gridBounds.contains(i.x,i.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,i)),this.gridBounds.contains(r.x,r.y)||(this.gridBounds=t.RectangleExt.union(this.gridBounds,r));for(var o=i.x;o<=r.x;o++)for(var s=i.y;s<=r.y;s++){this.cellAtPosition(o,s,!0).push(e)}},e.prototype.remove=function(t){for(var e=t.registeredPhysicsBounds.clone(),n=this.cellCoords(e.x,e.y),i=this.cellCoords(e.right,e.bottom),r=n.x;r<=i.x;r++)for(var o=n.y;o<=i.y;o++){var s=this.cellAtPosition(r,o);s?new linq.List(s).remove(t):console.log("从不存在碰撞器的单元格中移除碰撞器: ["+t+"]")}},e.prototype.removeWithBruteForce=function(t){this._cellDict.remove(t)},e.prototype.clear=function(){this._cellDict.clear()},e.prototype.aabbBroadphase=function(e,n,i){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 c=this.cellAtPosition(s,a);if(null!=c)for(var u=0;u<c.length;u++){var h=c[u];h!=n&&t.Flags.isFlagSet(i,h.physicsLayer.value)&&(e.intersects(h.bounds)&&this._tempHashSet.add(h))}}return this._tempHashSet},e.prototype.linecast=function(e,n,i,r){var o=new t.Ray2D(e,n);this._raycastParser.start(o,i,r);var s=this.cellCoords(e.x,e.y),a=this.cellCoords(n.x,n.y),c=Math.sign(o.direction.x),u=Math.sign(o.direction.y);s.x==a.x&&(c=0),s.y==a.y&&(u=0);var h=c<0?0:c,l=u<0?0:u,p=(s.x+h)*this._cellSize,f=(s.y+l)*this._cellSize,d=0!=o.direction.x?(p-o.start.x)/o.direction.x:Number.MAX_VALUE,y=0!=o.direction.y?(f-o.start.y)/o.direction.y:Number.MAX_VALUE,m=0!=o.direction.x?this._cellSize/(o.direction.x*c):Number.MAX_VALUE,g=0!=o.direction.y?this._cellSize/(o.direction.y*u):Number.MAX_VALUE,_=this.cellAtPosition(s.x,s.y);if(_&&this._raycastParser.checkRayIntersection(s.x,s.y,_))return this._raycastParser.reset(),this._raycastParser.hitCounter;for(;s.x!=a.x||s.y!=a.y;)if(d<y?(s.x=Math.floor(t.MathHelper.approach(s.x,a.x,Math.abs(c))),d+=m):(s.y=Math.floor(t.MathHelper.approach(s.y,a.y,Math.abs(u))),y+=g),(_=this.cellAtPosition(s.x,s.y))&&this._raycastParser.checkRayIntersection(s.x,s.y,_))return this._raycastParser.reset(),this._raycastParser.hitCounter;return this._raycastParser.reset(),this._raycastParser.hitCounter},e.prototype.overlapCircle=function(e,n,i,r){var o,s,a=new t.Rectangle(e.x-n,e.y-n,2*n,2*n);this._overlapTestCircle.radius=n,this._overlapTestCircle.position=e;var c=0,u=this.aabbBroadphase(a,null,r);try{for(var h=__values(u),l=h.next();!l.done;l=h.next()){var p=l.value;if(p instanceof t.BoxCollider)i[c]=p,c++;else if(p instanceof t.CircleCollider)p.shape.overlaps(this._overlapTestCircle)&&(i[c]=p,c++);else{if(!(p instanceof t.PolygonCollider))throw new Error("对这个对撞机类型的overlapCircle没有实现!");p.shape.overlaps(this._overlapTestCircle)&&(i[c]=p,c++)}if(c==i.length)return c}}catch(t){o={error:t}}finally{try{l&&!l.done&&(s=h.return)&&s.call(h)}finally{if(o)throw o.error}}return c},e.prototype.cellCoords=function(e,n){return new t.Vector2(Math.floor(e*this._inverseCellSize),Math.floor(n*this._inverseCellSize))},e.prototype.cellAtPosition=function(t,e,n){void 0===n&&(n=!1);var i=this._cellDict.tryGetValue(t,e);return i||n&&(i=[],this._cellDict.add(t,e,i)),i},e}();t.SpatialHash=e;var n=function(){function t(){this._store=new Map}return t.prototype.add=function(t,e,n){this._store.set(this.getKey(t,e),n)},t.prototype.remove=function(t){this._store.forEach(function(e){var n=new linq.List(e);n.contains(t)&&n.remove(t)})},t.prototype.tryGetValue=function(t,e){return this._store.get(this.getKey(t,e))},t.prototype.getKey=function(t,e){return t+"_"+e},t.prototype.clear=function(){this._store.clear()},t}();t.NumberDictionary=n;var i=function(){function e(){this._tempHit=new t.RaycastHit,this._checkedColliders=[],this._cellHits=[]}return e.prototype.start=function(t,e,n){this._ray=t,this._hits=e,this._layerMask=n,this.hitCounter=0},e.prototype.checkRayIntersection=function(n,i,r){for(var o=new t.Ref(0),s=0;s<r.length;s++){var a=r[s];if(!new linq.List(this._checkedColliders).contains(a))if(this._checkedColliders.push(a),!a.isTrigger||t.Physics.raycastsHitTriggers)if(t.Flags.isFlagSet(this._layerMask,a.physicsLayer.value))if(a.bounds.clone().rayIntersects(this._ray,o)&&o.value<=1&&a.shape.collidesWithLine(this._ray.start,this._ray.end,this._tempHit)){if(!t.Physics.raycastsStartInColliders&&a.shape.containsPoint(this._ray.start))continue;this._tempHit.collider=a,this._cellHits.push(this._tempHit)}}if(0==this._cellHits.length)return!1;this._cellHits.sort(e.compareRaycastHits);for(s=0;s<this._cellHits.length;s++)if(this._hits[this.hitCounter]=this._cellHits[s],this.hitCounter++,this.hitCounter==this._hits.length)return!0;return!1},e.prototype.reset=function(){this._hits=null,this._checkedColliders.length=0,this._cellHits.length=0},e.compareRaycastHits=function(t,e){return t.distance-e.distance},e}();t.RaycastResultParser=i}(es||(es={})),function(t){var e=function(){return function(){}}();t.Shape=e}(es||(es={})),function(t){var e=function(e){function n(t,n){var i=e.call(this)||this;return i._areEdgeNormalsDirty=!0,i.isUnrotated=!0,i.setPoints(t),i.isBox=n,i}return __extends(n,e),Object.defineProperty(n.prototype,"edgeNormals",{get:function(){return this._areEdgeNormalsDirty&&this.buildEdgeNormals(),this._edgeNormals},enumerable:!0,configurable:!0}),n.prototype.setPoints=function(t){this.points=t,this.recalculateCenterAndEdgeNormals(),this._originalPoints=this.points.slice()},n.prototype.recalculateCenterAndEdgeNormals=function(){this._polygonCenter=n.findPolygonCenter(this.points),this._areEdgeNormalsDirty=!0},n.prototype.buildEdgeNormals=function(){var e,n=this.isBox?2:this.points.length;null!=this._edgeNormals&&this._edgeNormals.length==n||(this._edgeNormals=new Array(n));for(var i=0;i<n;i++){var r=this.points[i];e=i+1>=this.points.length?this.points[0]:this.points[i+1];var o=t.Vector2Ext.perpendicular(r,e);t.Vector2Ext.normalize(o),this._edgeNormals[i]=o}},n.buildSymmetricalPolygon=function(e,n){for(var i=new Array(e),r=0;r<e;r++){var o=2*Math.PI*(r/e);i[r]=new t.Vector2(Math.cos(o)*n,Math.sin(o)*n)}return i},n.recenterPolygonVerts=function(e){for(var n=this.findPolygonCenter(e),i=0;i<e.length;i++)e[i]=t.Vector2.subtract(e[i],n)},n.findPolygonCenter=function(e){for(var n=0,i=0,r=0;r<e.length;r++)n+=e[r].x,i+=e[r].y;return new t.Vector2(n/e.length,i/e.length)},n.getFarthestPointInDirection=function(e,n){for(var i=0,r=t.Vector2.dot(e[i],n),o=1;o<e.length;o++){var s=t.Vector2.dot(e[o],n);s>r&&(r=s,i=o)}return e[i]},n.getClosestPointOnPolygonToPoint=function(e,n,i,r){i.value=Number.MAX_VALUE,r.x=0,r.y=0;for(var o=t.Vector2.zero,s=0,a=0;a<e.length;a++){var c=a+1;c==e.length&&(c=0);var u=t.ShapeCollisions.closestPointOnLine(e[a],e[c],n);if((s=t.Vector2.distanceSquared(n,u))<i.value){i.value=s,o=u;var h=t.Vector2.subtract(e[c],e[a]);r.x=-h.y,r.y=h.x}}return t.Vector2Ext.normalize(r),o},n.rotatePolygonVerts=function(e,n,i){for(var r=Math.cos(e),o=Math.sin(e),s=0;s<n.length;s++){var a=n[s];i[s]=new t.Vector2(a.x*r+a.y*-o,a.x*o+a.y*r)}},n.prototype.recalculateBounds=function(e){if(this.center=e.localOffset.clone(),e.shouldColliderScaleAndRotateWithTransform){var n=!0,i=void 0,r=t.Matrix2D.createTranslation(-this._polygonCenter.x,-this._polygonCenter.y);if(e.entity.transform.scale.equals(t.Vector2.one)||(i=t.Matrix2D.createScale(e.entity.transform.scale.x,e.entity.transform.scale.y),r=r.multiply(i),n=!1,this.center=t.Vector2.multiply(e.localOffset,e.entity.transform.scale)),0!=e.entity.transform.rotation){i=t.Matrix2D.createRotation(e.entity.transform.rotation),r=r.multiply(i);var o=Math.atan2(e.localOffset.y*e.entity.transform.scale.y,e.localOffset.x*e.entity.transform.scale.x)*t.MathHelper.Rad2Deg,s=n?e._localOffsetLength:t.Vector2.multiply(e.localOffset,e.entity.transform.scale).length();this.center=t.MathHelper.pointOnCirlce(t.Vector2.zero,s,e.entity.transform.rotationDegrees+o)}i=t.Matrix2D.createTranslation(this._polygonCenter.x,this._polygonCenter.y),r=r.multiply(i),t.Vector2Ext.transform(this._originalPoints,r,this.points),this.isUnrotated=0==e.entity.transform.rotation,e._isRotationDirty&&(this._areEdgeNormalsDirty=!0)}this.position=t.Vector2.add(e.entity.transform.position,this.center),this.bounds=t.Rectangle.rectEncompassingPoints(this.points),this.bounds.location=t.Vector2.add(this.bounds.location,this.position)},n.prototype.overlaps=function(e){var i=new t.CollisionResult;if(e instanceof n)return t.ShapeCollisions.polygonToPolygon(this,e,i);if(e instanceof t.Circle)return!!t.ShapeCollisions.circleToPolygon(e,this,i)&&(i.invertResult(),!0);throw new Error("overlaps of Pologon to "+e+" are not supported")},n.prototype.collidesWithShape=function(e,i){if(e instanceof n)return t.ShapeCollisions.polygonToPolygon(this,e,i);if(e instanceof t.Circle)return!!t.ShapeCollisions.circleToPolygon(e,this,i)&&(i.invertResult(),!0);throw new Error("overlaps of Polygon to "+e+" are not supported")},n.prototype.collidesWithLine=function(e,n,i){return t.ShapeCollisions.lineToPoly(e,n,this,i)},n.prototype.containsPoint=function(t){t.subtract(this.position);for(var e=!1,n=0,i=this.points.length-1;n<this.points.length;i=n++)this.points[n].y>t.y!=this.points[i].y>t.y&&t.x<(this.points[i].x-this.points[n].x)*(t.y-this.points[n].y)/(this.points[i].y-this.points[n].y)+this.points[n].x&&(e=!e);return e},n.prototype.pointCollidesWithShape=function(e,n){return t.ShapeCollisions.pointToPoly(e,this,n)},n}(t.Shape);t.Polygon=e}(es||(es={})),function(t){var e=function(e){function n(t,i){var r=e.call(this,n.buildBox(t,i),!0)||this;return r.width=t,r.height=i,r}return __extends(n,e),n.buildBox=function(e,n){var i=e/2,r=n/2,o=new Array(4);return o[0]=new t.Vector2(-i,-r),o[1]=new t.Vector2(i,-r),o[2]=new t.Vector2(i,r),o[3]=new t.Vector2(-i,r),o},n.prototype.updateBox=function(e,n){this.width=e,this.height=n;var i=e/2,r=n/2;this.points[0]=new t.Vector2(-i,-r),this.points[1]=new t.Vector2(i,-r),this.points[2]=new t.Vector2(i,r),this.points[3]=new t.Vector2(-i,r);for(var o=0;o<this.points.length;o++)this._originalPoints[o]=this.points[o]},n.prototype.overlaps=function(i){if(this.isUnrotated){if(i instanceof n&&i.isUnrotated)return this.bounds.intersects(i.bounds);if(i instanceof t.Circle)return t.Collisions.rectToCircle(this.bounds,i.position,i.radius)}return e.prototype.overlaps.call(this,i)},n.prototype.collidesWithShape=function(i,r){return i instanceof n&&i.isUnrotated?t.ShapeCollisions.boxToBox(this,i,r):e.prototype.collidesWithShape.call(this,i,r)},n.prototype.containsPoint=function(t){return this.isUnrotated?this.bounds.contains(t.x,t.y):e.prototype.containsPoint.call(this,t)},n.prototype.pointCollidesWithShape=function(n,i){return this.isUnrotated?t.ShapeCollisions.pointToBox(n,this,i):e.prototype.pointCollidesWithShape.call(this,n,i)},n}(t.Polygon);t.Box=e}(es||(es={})),function(t){var e=function(e){function n(t){var n=e.call(this)||this;return n.radius=t,n._originalRadius=t,n}return __extends(n,e),n.prototype.recalculateBounds=function(e){if(this.center=e.localOffset,e.shouldColliderScaleAndRotateWithTransform){var n=e.entity.transform.scale,i=1==n.x&&1==n.y,r=Math.max(n.x,n.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=i?e._localOffsetLength:t.Vector2.multiply(e.localOffset,e.entity.transform.scale).length();this.center=t.MathHelper.pointOnCirlce(t.Vector2.zero,s,e.entity.transform.rotationDegrees+o)}}this.position=t.Vector2.add(e.entity.transform.position,this.center),this.bounds=new t.Rectangle(this.position.x-this.radius,this.position.y-this.radius,2*this.radius,2*this.radius)},n.prototype.overlaps=function(e){var i=new t.CollisionResult;if(e instanceof t.Box&&e.isUnrotated)return t.Collisions.rectToCircle(e.bounds,this.position,this.radius);if(e instanceof n)return t.Collisions.circleToCircle(this.position,this.radius,e.position,e.radius);if(e instanceof t.Polygon)return t.ShapeCollisions.circleToPolygon(this,e,i);throw new Error("overlaps of circle to "+e+" are not supported")},n.prototype.collidesWithShape=function(e,i){if(e instanceof t.Box&&e.isUnrotated)return t.ShapeCollisions.circleToBox(this,e,i);if(e instanceof n)return t.ShapeCollisions.circleToCircle(this,e,i);if(e instanceof t.Polygon)return t.ShapeCollisions.circleToPolygon(this,e,i);throw new Error("Collisions of Circle to "+e+" are not supported")},n.prototype.collidesWithLine=function(e,n,i){return t.ShapeCollisions.lineToCircle(e,n,this,i)},n.prototype.containsPoint=function(e){return t.Vector2.subtract(e,this.position).lengthSquared()<=this.radius*this.radius},n.prototype.pointCollidesWithShape=function(e,n){return t.ShapeCollisions.pointToCircle(e,this,n)},n}(t.Shape);t.Circle=e}(es||(es={})),function(t){var e=function(){function e(){this.normal=t.Vector2.zero,this.minimumTranslationVector=t.Vector2.zero,this.point=t.Vector2.zero}return e.prototype.removeHorizontal=function(e){if(Math.sign(this.normal.x)!=Math.sign(e.x)||0==e.x&&0!=this.normal.x){var n=this.minimumTranslationVector.length()/this.normal.y;1!=Math.abs(this.normal.x)&&Math.abs(n)<Math.abs(3*e.y)&&(this.minimumTranslationVector=new t.Vector2(0,-n))}},e.prototype.invertResult=function(){return this.minimumTranslationVector=t.Vector2.negate(this.minimumTranslationVector),this.normal=t.Vector2.negate(this.normal),this},e.prototype.toString=function(){return"[CollisionResult] normal: "+this.normal+", minimumTranslationVector: "+this.minimumTranslationVector},e}();t.CollisionResult=e}(es||(es={})),function(t){var e=function(){function e(){}return e.intersectMovingCircleBox=function(e,n,i,r){var o=n.bounds;o.inflate(e.radius,e.radius);var s=new t.Ray2D(t.Vector2.subtract(e.position,i),e.position);if(!o.rayIntersects(s,r)&&r.value>1)return!1;var a,c=t.Vector2.add(s.start,t.Vector2.add(s.direction,new t.Vector2(r.value))),u=0;c.x<n.bounds.left&&(a|=1),c.x>n.bounds.right&&(u|=1),c.y<n.bounds.top&&(a|=2),c.y>n.bounds.bottom&&(u|=2);var h=a+u;return 3==h&&console.log("m == 3. corner "+t.Time.frameCount),!0},e}();t.RealtimeCollisions=e}(es||(es={})),function(t){var e=function(){function e(){}return e.polygonToPolygon=function(e,n,i){for(var r,o=!0,s=e.edgeNormals.slice(),a=n.edgeNormals.slice(),c=Number.POSITIVE_INFINITY,u=new t.Vector2,h=t.Vector2.subtract(e.position,n.position),l=0;l<s.length+a.length;l++){r=l<s.length?s[l]:a[l-s.length];var p=new t.Ref(0),f=new t.Ref(0),d=new t.Ref(0),y=new t.Ref(0),m=0;this.getInterval(r,e,p,d),this.getInterval(r,n,f,y);var g=t.Vector2.dot(h,r);if(p.value+=g,d.value+=g,(m=this.intervalDistance(p.value,d.value,f.value,y.value))>0&&(o=!1),!o)return!1;(m=Math.abs(m))<c&&(c=m,u=r,t.Vector2.dot(u,h)<0&&(u=new t.Vector2(-u.x,-u.y)))}return i.normal=u,i.minimumTranslationVector=new t.Vector2(-u.x*c,-u.y*c),!0},e.intervalDistance=function(t,e,n,i){return t<n?n-e:t-i},e.getInterval=function(e,n,i,r){var o=t.Vector2.dot(n.points[0],e);i.value=r.value=o;for(var s=1;s<n.points.length;s++)(o=t.Vector2.dot(n.points[s],e))<i.value?i.value=o:o>r.value&&(r.value=o)},e.circleToPolygon=function(e,n,i){var r,o=t.Vector2.subtract(e.position,n.position),s=new t.Ref(0),a=t.Polygon.getClosestPointOnPolygonToPoint(n.points,o,s,i.normal),c=n.containsPoint(e.position);if(s.value>e.radius*e.radius&&!c)return!1;if(c)r=t.Vector2.multiply(i.normal,new t.Vector2(Math.sqrt(s.value)-e.radius));else if(0==s.value)r=new t.Vector2(i.normal.x*e.radius,i.normal.y*e.radius);else{var u=Math.sqrt(s.value);r=new t.Vector2(-o.x+a.x,-o.y+a.y).multiply(new t.Vector2((e.radius-u)/u))}return i.minimumTranslationVector=r,i.point=t.Vector2.add(a,n.position),!0},e.circleToBox=function(e,n,i){var r=n.bounds.getClosestPointOnRectangleBorderToPoint(e.position,i.normal);if(n.containsPoint(e.position)){i.point=r;var o=t.Vector2.add(r,t.Vector2.multiply(i.normal,new t.Vector2(e.radius)));return i.minimumTranslationVector=t.Vector2.subtract(e.position,o),!0}var s=t.Vector2.distanceSquared(r,e.position);if(0==s)i.minimumTranslationVector=t.Vector2.multiply(i.normal,new t.Vector2(e.radius));else if(s<=e.radius*e.radius){i.normal=t.Vector2.subtract(e.position,r);var a=i.normal.length()-e.radius;return i.point=r,t.Vector2Ext.normalize(i.normal),i.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(a),i.normal),!0}return!1},e.pointToCircle=function(e,n,i){var r=t.Vector2.distanceSquared(e,n.position),o=1+n.radius;if(r<o*o){i.normal=t.Vector2.normalize(t.Vector2.subtract(e,n.position));var s=o-Math.sqrt(r);return i.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(-s,-s),i.normal),i.point=t.Vector2.add(n.position,t.Vector2.multiply(i.normal,new t.Vector2(n.radius,n.radius))),!0}return!1},e.pointToBox=function(e,n,i){return!!n.containsPoint(e)&&(i.point=n.bounds.getClosestPointOnRectangleBorderToPoint(e,i.normal),i.minimumTranslationVector=t.Vector2.subtract(e,i.point),!0)},e.closestPointOnLine=function(e,n,i){var r=t.Vector2.subtract(n,e),o=t.Vector2.subtract(i,e),s=t.Vector2.dot(o,r)/t.Vector2.dot(r,r);return s=t.MathHelper.clamp(s,0,1),t.Vector2.add(e,t.Vector2.multiply(r,new t.Vector2(s,s)))},e.pointToPoly=function(e,n,i){if(n.containsPoint(e)){var r=new t.Ref(0),o=t.Polygon.getClosestPointOnPolygonToPoint(n.points,t.Vector2.subtract(e,n.position),r,i.normal);return i.minimumTranslationVector=new t.Vector2(i.normal.x*Math.sqrt(r.value),i.normal.y*Math.sqrt(r.value)),i.point=t.Vector2.add(o,n.position),!0}return!1},e.circleToCircle=function(e,n,i){var r=t.Vector2.distanceSquared(e.position,n.position),o=e.radius+n.radius;if(r<o*o){i.normal=t.Vector2.normalize(t.Vector2.subtract(e.position,n.position));var s=o-Math.sqrt(r);return i.minimumTranslationVector=t.Vector2.multiply(new t.Vector2(-s),i.normal),i.point=t.Vector2.add(n.position,t.Vector2.multiply(i.normal,new t.Vector2(n.radius))),!0}return!1},e.boxToBox=function(e,n,i){var r=this.minkowskiDifference(e,n);return!!r.contains(0,0)&&(i.minimumTranslationVector=r.getClosestPointOnBoundsToOrigin(),!i.minimumTranslationVector.equals(t.Vector2.zero)&&(i.normal=new t.Vector2(-i.minimumTranslationVector.x,-i.minimumTranslationVector.y),i.normal.normalize(),!0))},e.minkowskiDifference=function(e,n){var i=t.Vector2.subtract(e.position,t.Vector2.add(e.bounds.location,new t.Vector2(e.bounds.size.x/2,e.bounds.size.y/2))),r=t.Vector2.subtract(t.Vector2.add(e.bounds.location,i),n.bounds.max),o=t.Vector2.add(e.bounds.size,n.bounds.size);return new t.Rectangle(r.x,r.y,o.x,o.y)},e.lineToPoly=function(e,n,i,r){for(var o=t.Vector2.zero,s=t.Vector2.zero,a=Number.MAX_VALUE,c=!1,u=i.points.length-1,h=0;h<i.points.length;u=h,h++){var l=t.Vector2.add(i.position,i.points[u]),p=t.Vector2.add(i.position,i.points[h]),f=t.Vector2.zero;if(this.lineToLine(l,p,e,n,f)){c=!0;var d=(f.x-e.x)/(n.x-e.x);if((Number.isNaN(d)||Number.isFinite(d))&&(d=(f.y-e.y)/(n.y-e.y)),d<a){var y=t.Vector2.subtract(p,l);o=new t.Vector2(y.y,-y.x),a=d,s=f}}}if(c){o.normalize();var m=t.Vector2.distance(e,s);return r.setValuesNonCollider(a,m,s,o),!0}return!1},e.lineToLine=function(e,n,i,r,o){var s=t.Vector2.subtract(n,e),a=t.Vector2.subtract(r,i),c=s.x*a.y-s.y*a.x;if(0==c)return!1;var u=t.Vector2.subtract(i,e),h=(u.x*a.y-u.y*a.x)/c;if(h<0||h>1)return!1;var l=(u.x*s.y-u.y*s.x)/c;return!(l<0||l>1)&&(t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(h),s)),!0)},e.lineToCircle=function(e,n,i,r){var o=t.Vector2.distance(e,n),s=t.Vector2.divide(t.Vector2.subtract(n,e),new t.Vector2(o)),a=t.Vector2.subtract(e,i.position),c=t.Vector2.dot(a,s),u=t.Vector2.dot(a,a)-i.radius*i.radius;if(u>0&&c>0)return!1;var h=c*c-u;return!(h<0)&&(r.fraction=-c-Math.sqrt(h),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,i.position)),r.fraction=r.distance/o,!0)},e.boxToBoxCast=function(e,n,i,r){var o=this.minkowskiDifference(e,n);if(o.contains(0,0)){var s=o.getClosestPointOnBoundsToOrigin();return!s.equals(t.Vector2.zero)&&(r.normal=new t.Vector2(-s.x),r.normal.normalize(),r.distance=0,r.fraction=0,!0)}var a=new t.Ray2D(t.Vector2.zero,new t.Vector2(-i.x)),c=new t.Ref(0);return!!(o.rayIntersects(a,c)&&c.value<=1)&&(r.fraction=c.value,r.distance=i.length()*c.value,r.normal=new t.Vector2(-i.x,-i.y),r.normal.normalize(),r.centroid=t.Vector2.add(e.bounds.center,t.Vector2.multiply(i,new t.Vector2(c.value))),!0)},e}();t.ShapeCollisions=e}(es||(es={}));var ArrayUtils=function(){function t(){}return t.bubbleSort=function(t){for(var e=!1,n=0;n<t.length;n++){e=!1;for(var i=t.length-1;i>n;i--)if(t[i]<t[i-1]){var r=t[i];t[i]=t[i-1],t[i-1]=r,e=!0}if(!e)break}},t.insertionSort=function(t){for(var e=t.length,n=1;n<e;n++){for(var i=t[n],r=n;r>0&&t[r-1]>i;r--)t[r]=t[r-1];t[r]=i}},t.binarySearch=function(t,e){for(var n=0,i=t.length,r=n+i>>1;n<i;)e<=t[r]?i=r:e>=t[r]&&(n=r+1),r=n+i>>1;return t[n]==e?n:-1},t.findElementIndex=function(t,e){for(var n=t.length,i=0;i<n;++i)if(t[i]==e)return i;return null},t.getMaxElementIndex=function(t){for(var e=0,n=t.length,i=1;i<n;i++)t[i]>t[e]&&(e=i);return e},t.getMinElementIndex=function(t){for(var e=0,n=t.length,i=1;i<n;i++)t[i]<t[e]&&(e=i);return e},t.getUniqueAry=function(t){for(var e=[],n=[],i=t.length,r=0;r<i;++r){var o=t[r];-1==e.indexOf(o)&&e.push(o)}for(r=(i=e.length)-1;r>=0;--r)n.unshift(e[r]);return n},t.getDifferAry=function(t,e){t=this.getUniqueAry(t),e=this.getUniqueAry(e);for(var n=t.concat(e),i={},r=[],o=n.length,s=0;s<o;++s)i[n[s]]?i[n[s]]instanceof Object&&i[n[s]].count++:(i[n[s]]={},i[n[s]].count=0,i[n[s]].key=n[s],i[n[s]].count++);for(var a in i)2!=i[a].count&&r.unshift(i[a].key);return r},t.swap=function(t,e,n){var i=t[e];t[e]=t[n],t[n]=i},t.clearList=function(t){if(t)for(var e=t.length-1;e>=0;e-=1)t.splice(e,1)},t.cloneList=function(t){return t?t.slice(0,t.length):null},t.equals=function(t,e){if(t==e)return!0;var n=t.length;if(n!=e.length)return!1;for(;n--;)if(t[n]!=e[n])return!1;return!0},t.insert=function(t,e,n){if(!t)return null;var i=t.length;if(e>i&&(e=i),e<0&&(e=0),e==i)t.push(n);else if(0==e)t.unshift(n);else{for(var r=i-1;r>=e;r-=1)t[r+1]=t[r];t[e]=n}return n},t.shuffle=function(t){for(var e=t.length;e>1;){e--;var n=RandomUtils.randint(0,e+1),i=t[n];t[n]=t[e],t[e]=i}},t.addIfNotPresent=function(t,e){return!new linq.List(t).contains(e)&&(t.push(e),!0)},t.lastItem=function(t){return t[t.length-1]},t.randomItem=function(t){return t[RandomUtils.randint(0,t.length-1)]},t.randomItems=function(t,e){for(var n=new Set;n.size!=e;){var i=this.randomItem(t);n.has(i)||n.add(i)}var r=es.ListPool.obtain();return n.forEach(function(t){return r.push(t)}),r},t}();!function(t){var e=function(){function t(){}return Object.defineProperty(t,"nativeBase64",{get:function(){return"function"==typeof window.atob},enumerable:!0,configurable:!0}),t.decode=function(t){if(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,""),this.nativeBase64)return window.atob(t);for(var e,n,i,r,o,s,a=[],c=0;c<t.length;)e=this._keyStr.indexOf(t.charAt(c++))<<2|(r=this._keyStr.indexOf(t.charAt(c++)))>>4,n=(15&r)<<4|(o=this._keyStr.indexOf(t.charAt(c++)))>>2,i=(3&o)<<6|(s=this._keyStr.indexOf(t.charAt(c++))),a.push(String.fromCharCode(e)),64!==o&&a.push(String.fromCharCode(n)),64!==s&&a.push(String.fromCharCode(i));return a=a.join("")},t.encode=function(t){if(t=t.replace(/\r\n/g,"\n"),!this.nativeBase64){for(var e,n,i,r,o,s,a,c=[],u=0;u<t.length;)r=(e=t.charCodeAt(u++))>>2,o=(3&e)<<4|(n=t.charCodeAt(u++))>>4,s=(15&n)<<2|(i=t.charCodeAt(u++))>>6,a=63&i,isNaN(n)?s=a=64:isNaN(i)&&(a=64),c.push(this._keyStr.charAt(r)),c.push(this._keyStr.charAt(o)),c.push(this._keyStr.charAt(s)),c.push(this._keyStr.charAt(a));return c=c.join("")}window.btoa(t)},t.decodeBase64AsArray=function(e,n){n=n||1;var i,r,o,s=t.decode(e),a=new Uint32Array(s.length/n);for(i=0,o=s.length/n;i<o;i++)for(a[i]=0,r=n-1;r>=0;--r)a[i]+=s.charCodeAt(i*n+r)<<(r<<3);return a},t.decompress=function(t,e,n){throw new Error("GZIP/ZLIB compressed TMX Tile Map not supported!")},t.decodeCSV=function(t){for(var e=t.replace("\n","").trim().split(","),n=[],i=0;i<e.length;i++)n.push(+e[i]);return n},t._keyStr="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",t}();t.Base64Utils=e}(es||(es={})),function(t){var e=function(){function e(e,n,i,r){if(0!=(4294967040&(e|n|i|r))){var o=t.MathHelper.clamp(e,0,255),s=t.MathHelper.clamp(n,0,255),a=t.MathHelper.clamp(i,0,255),c=t.MathHelper.clamp(r,0,255);this._packedValue=c<<24|a<<16|s<<8|o}else this._packedValue=r<<24|i<<16|n<<8|e}return Object.defineProperty(e.prototype,"b",{get:function(){return this._packedValue>>16},set:function(t){this._packedValue=4278255615&this._packedValue|t<<16},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"g",{get:function(){return this._packedValue>>8},set:function(t){this._packedValue=4294902015&this._packedValue|t<<8},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"r",{get:function(){return this._packedValue},set:function(t){this._packedValue=4294967040&this._packedValue|t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"a",{get:function(){return this._packedValue>>24},set:function(t){this._packedValue=16777215&this._packedValue|t<<24},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"packedValue",{get:function(){return this._packedValue},set:function(t){this._packedValue=t},enumerable:!0,configurable:!0}),e.prototype.equals=function(t){return this._packedValue==t._packedValue},e}();t.Color=e}(es||(es={})),function(t){var e=function(){function e(){}return e.oppositeEdge=function(e){switch(e){case t.Edge.bottom:return t.Edge.top;case t.Edge.top:return t.Edge.bottom;case t.Edge.left:return t.Edge.right;case t.Edge.right:return t.Edge.left}},e.isHorizontal=function(e){return e==t.Edge.right||e==t.Edge.left},e.isVertical=function(e){return e==t.Edge.top||e==t.Edge.bottom},e}();t.EdgeExt=e}(es||(es={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var n=function(){function t(){this._messageTable=new Map}return t.prototype.addObserver=function(t,n,i){var r=this._messageTable.get(t);r||(r=[],this._messageTable.set(t,r)),-1!=r.findIndex(function(t){return t.func==n})&&console.warn("您试图添加相同的观察者两次"),r.push(new e(n,i))},t.prototype.removeObserver=function(t,e){var n=this._messageTable.get(t),i=n.findIndex(function(t){return t.func==e});-1!=i&&new linq.List(n).removeAt(i)},t.prototype.emit=function(t,e){var n=this._messageTable.get(t);if(n)for(var i=n.length-1;i>=0;i--)n[i].func.call(n[i].context,e)},t}();t.Emitter=n}(es||(es={})),function(t){!function(t){t[t.top=0]="top",t[t.bottom=1]="bottom",t[t.left=2]="left",t[t.right=3]="right"}(t.Edge||(t.Edge={}))}(es||(es={})),function(t){var e=function(){function t(){}return t.repeat=function(t,e){for(var n=[];e--;)n.push(t);return n},t}();t.Enumerable=e}(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 n=385229220;return this.forOwn(t,function(t){"number"==typeof t?n+=e._getHashCodeForNumber(t):"string"==typeof t?n+=e._getHashCodeForString(t):"object"==typeof t&&e.forOwn(t,function(){n+=e.getHashCode(t)})}),n},t.prototype._getHashCodeForNumber=function(t){return t},t.prototype._getHashCodeForString=function(t){for(var e=385229220,n=0;n<t.length;n++)e=-1521134295*e^t.charCodeAt(n);return e},t.prototype.forOwn=function(t,e){t=Object(t),Object.keys(t).forEach(function(n){return e(t[n],n,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.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 t(){}return t.toNumber=function(t){return null==t?0:Number(t)},t}();t.NumberExtension=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 n=0;n<e;n++)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={}));var RandomUtils=function(){function t(){}return t.randrange=function(t,e,n){if(void 0===n&&(n=1),0==n)throw new Error("step 不能为 0");var i=e-t;if(0==i)throw new Error("没有可用的范围("+t+","+e+")");i<0&&(i=t-e);var r=Math.floor((i+n-1)/n);return Math.floor(this.random()*r)*n+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 n=t.length;if(e<=0||n<e)throw new Error("采样数量不够");for(var i=[],r=[],o=0;o<e;o++){for(var s=Math.floor(this.random()*n);r.indexOf(s)>=0;)s=Math.floor(this.random()*n);i.push(t[s]),r.push(s)}return i},t.random=function(){return Math.random()},t.boolean=function(t){return void 0===t&&(t=.5),this.random()<t},t._randomCompare=function(t,e){return this.random()>.5?1:-1},t}();!function(t){var e=function(){function e(){}return e.getSide=function(e,n){switch(n){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,n){var i=new t.Rectangle(n.x,n.y,0,0),r=new t.Rectangle;return r.x=Math.min(e.x,i.x),r.y=Math.min(e.y,i.y),r.width=Math.max(e.right,i.right)-r.x,r.height=Math.max(e.bottom,i.bottom)-r.y,r},e.getHalfRect=function(e,n){switch(n){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,n,i){switch(void 0===i&&(i=1),n){case t.Edge.top:return new t.Rectangle(e.x,e.y,e.width,i);case t.Edge.bottom:return new t.Rectangle(e.x,e.y+e.height-i,e.width,i);case t.Edge.left:return new t.Rectangle(e.x,e.y,i,e.height);case t.Edge.right:return new t.Rectangle(e.x+e.width-i,e.y,i,e.height)}},e.expandSide=function(e,n,i){switch(i=Math.abs(i),n){case t.Edge.top:e.y-=i,e.height+=i;break;case t.Edge.bottom:e.height+=i;break;case t.Edge.left:e.x-=i,e.width+=i;break;case t.Edge.right:e.width+=i}},e.contract=function(t,e,n){t.x+=e,t.y+=n,t.width-=2*e,t.height-=2*n},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=e}(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,n=this.getHashCode(t),i=this.buckets[n];if(void 0===i){var r=new Array;return r.push(t),this.buckets[n]=r,this.count=this.count+1,!0}return!i.some(function(n){return e.areEqual(n,t)})&&(i.push(t),this.count=this.count+1,!0)},t.prototype.remove=function(t){var e=this,n=this.getHashCode(t),i=this.buckets[n];if(void 0===i)return!1;var r=!1,o=new Array;return i.forEach(function(n){e.areEqual(n,t)?r=!0:o.push(t)}),this.buckets[n]=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 n=this.buildInternalBuckets(t);this.toArray().forEach(function(t){e.bucketsContains(n.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,n=this.buildInternalBuckets(t);return this.toArray().every(function(t){return e.bucketsContains(n.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,n=new Array,i=0;return t.forEach(function(t){var r=e.getHashCode(t),o=n[r];if(void 0===o){var s=new Array;s.push(t),n[r]=s,i+=1}else o.some(function(n){return e.areEqual(n,t)})||(o.push(t),i+=1)}),{Buckets:n,Count:i}},t.prototype.bucketsContains=function(t,e){var n=this,i=t[this.getHashCode(e)];return void 0!==i&&i.some(function(t){return n.areEqual(t,e)})},t}());t.HashSet=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,n,i,r){return!(t.Vector2Ext.cross(t.Vector2.subtract(e,n),t.Vector2.subtract(i,n))<0)&&(!(t.Vector2Ext.cross(t.Vector2.subtract(e,i),t.Vector2.subtract(r,i))<0)&&!(t.Vector2Ext.cross(t.Vector2.subtract(e,r),t.Vector2.subtract(n,r))<0))},e.prototype.triangulate=function(n,i){void 0===i&&(i=!0);var r=n.length;this.initialize(r);for(var o=0,s=0;r>3&&o<500;){o++;var a=!0,c=n[this._triPrev[s]],u=n[s],h=n[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(c,u,h)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(n[l],c,u,h)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),i||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.length<t&&(this._triNext.reverse(),this._triNext=new Array(Math.max(2*this._triNext.length,t))),this._triPrev.length<t&&(this._triPrev.reverse(),this._triPrev=new Array(Math.max(2*this._triPrev.length,t)));for(var e=0;e<t;e++)this._triPrev[e]=e-1,this._triNext[e]=e+1;this._triPrev[0]=t-1,this._triNext[t-1]=0},e}();t.Triangulator=e}(es||(es={})),function(t){var e=function(){function t(){}return t.getType=function(t){return t.__proto__.constructor},t}();t.TypeUtils=e}(es||(es={})),function(t){var e=function(){function e(){}return e.isTriangleCCW=function(e,n,i){return this.cross(t.Vector2.subtract(n,e),t.Vector2.subtract(i,n))<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,n){return new t.Vector2(-1*(n.y-e.y),n.x-e.x)},e.normalize=function(e){var n=Math.sqrt(e.x*e.x+e.y*e.y);n>t.MathHelper.Epsilon?e.divide(new t.Vector2(n)):e.x=e.y=0},e.transformA=function(t,e,n,i,r,o){for(var s=0;s<o;s++){var a=t[e+s],c=i[r+s];c.x=a.x*n.m11+a.y*n.m21+n.m31,c.y=a.x*n.m12+a.y*n.m22+n.m32,i[r+s]=c}},e.transformR=function(t,e,n){var i=t.x*e.m11+t.y*e.m21+e.m31,r=t.x*e.m12+t.y*e.m22+e.m32;n.x=i,n.y=r},e.transform=function(t,e,n){this.transformA(t,0,e,n,0,t.length)},e.round=function(e){return new t.Vector2(Math.round(e.x),Math.round(e.y))},e}();t.Vector2Ext=e}(es||(es={}));var stopwatch,linq,WebGLUtils=function(){function t(){}return t.getContext=function(){return document.getElementsByTagName("canvas")[0].getContext("2d")},t}();!function(t){var e,n=function(){function t(t){void 0===t&&(t=i),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=(n=this.getSystemTime())-this._stopSystemTime;this._stopDuration+=e,this._stopSystemTime=void 0}else if(void 0===this._startSystemTime){var n=this.getSystemTime();this._startSystemTime=n,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=n,function(t){t.IDLE="IDLE",t.RUNNING="RUNNING",t.STOPPED="STOPPED"}(e||(e={})),t.setDefaultSystemTimeGetter=function(t){void 0===t&&(t=Date.now),i=t};var i=Date.now}(stopwatch||(stopwatch={})),function(t){var e=function(){function e(){}return e.range=function(e,n){for(var i=new t.List;n--;)i.add(e++);return i},e.repeat=function(e,n){for(var i=new t.List;n--;)i.add(e);return i},e}();t.Enumerable=e}(linq||(linq={})),function(t){t.isObj=function(t){return!!t&&"object"==typeof t},t.negate=function(t){return function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return!t.apply(void 0,__spread(e))}},t.composeComparers=function(t,e){return function(n,i){return t(n,i)||e(n,i)}},t.keyComparer=function(t,e){return function(n,i){var r=t(n),o=t(i);return r>o?e?-1:1:r<o?e?1:-1:0}}}(linq||(linq={})),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 n=this.groupBy(t);return Object.keys(n).reduce(function(t,e){return t.add(n[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(n,i){var r=t(i),o=n[r],s=e(i);return o?o.push(s):n[r]=[s],n},{})},e.prototype.groupJoin=function(t,e,n,i){return this.select(function(r){return i(r,t.where(function(t){return e(r)===n(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,n,i){return this.selectMany(function(r){return t.where(function(t){return n(t)===e(r)}).select(function(t){return i(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,i){return void 0===i&&(i=t.keyComparer(e,!1)),new n(this._elements,i)},e.prototype.orderByDescending=function(e,i){return void 0===i&&(i=t.keyComparer(e,!0)),new n(this._elements,i)},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 n=this;return this.aggregate(function(e,i,r){return e.addRange(n.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(n){return t(e.elementAt(n))?++n:n},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(n){return t(e.elementAt(n))?++n:n},0))},e.prototype.toArray=function(){return this._elements},e.prototype.toDictionary=function(t,n){var i=this;return this.aggregate(function(e,r,o){return e[i.select(t).elementAt(o).toString()]=n?i.select(n).elementAt(o):r,e.add({Key:i.select(t).elementAt(o),Value:n?i.select(n).elementAt(o):r}),e},new e)},e.prototype.toSet=function(){var t,e,n=new Set;try{for(var i=__values(this._elements),r=i.next();!r.done;r=i.next()){var o=r.value;n.add(o)}}catch(e){t={error:e}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(t)throw t.error}}return n},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 n=this;return t.count()<this.count()?t.select(function(t,i){return e(n.elementAt(i),t)}):this.select(function(n,i){return e(n,t.elementAt(i))})},e}();t.List=e;var n=function(e){function n(t,n){var i=e.call(this,t)||this;return i._comparer=n,i._elements.sort(i._comparer),i}return __extends(n,e),n.prototype.thenBy=function(e){return new n(this._elements,t.composeComparers(this._comparer,t.keyComparer(e,!1)))},n.prototype.thenByDescending=function(e){return new n(this._elements,t.composeComparers(this._comparer,t.keyComparer(e,!0)))},n}(e);t.OrderedList=n}(linq||(linq={})),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,n,i){this._timeInSeconds=t,this._repeats=e,this.context=n,this._onTime=i},e.prototype.unload=function(){this.context=null,this._onTime=null},e}();t.Timer=e}(es||(es={})),function(t){var e=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t._timers=[],t}return __extends(n,e),n.prototype.update=function(){for(var t=this._timers.length-1;t>=0;t--)this._timers[t].tick()&&(this._timers[t].unload(),new linq.List(this._timers).removeAt(t))},n.prototype.schedule=function(e,n,i,r){var o=new t.Timer;return o.initialize(e,n,i,r),this._timers.push(o),o},n}(t.GlobalManager);t.TimerManager=e}(es||(es={}));