From 1c9276b4a11d376423b46564c990e5016e4e6931 Mon Sep 17 00:00:00 2001 From: yhh <359807859@qq.com> Date: Wed, 27 Jan 2021 14:58:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EDelayedIteratingSystem/Interv?= =?UTF-8?q?alSystem/IntervalIteratingSystem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- engine_support/egret/lib/framework.d.ts | 149 +++++++++- extensions/ecs-tween | 2 +- source/bin/framework.d.ts | 149 +++++++++- source/bin/framework.js | 268 ++++++++++++++---- source/bin/framework.min.js | 2 +- source/src/ECS/Components/ComponentPool.ts | 24 -- source/src/ECS/Components/PooledComponent.ts | 6 - source/src/ECS/Entity.ts | 10 + .../src/ECS/Systems/DelayedIteratingSystem.ts | 131 +++++++++ source/src/ECS/Systems/EntitySystem.ts | 64 +++-- .../ECS/Systems/IntervalIteratingSystem.ts | 25 ++ source/src/ECS/Systems/IntervalSystem.ts | 40 +++ 12 files changed, 733 insertions(+), 137 deletions(-) delete mode 100644 source/src/ECS/Components/ComponentPool.ts delete mode 100644 source/src/ECS/Components/PooledComponent.ts create mode 100644 source/src/ECS/Systems/DelayedIteratingSystem.ts create mode 100644 source/src/ECS/Systems/IntervalIteratingSystem.ts create mode 100644 source/src/ECS/Systems/IntervalSystem.ts diff --git a/engine_support/egret/lib/framework.d.ts b/engine_support/egret/lib/framework.d.ts index bd70e6f5..409c7e37 100644 --- a/engine_support/egret/lib/framework.d.ts +++ b/engine_support/egret/lib/framework.d.ts @@ -351,6 +351,11 @@ declare module es { * 每帧进行调用进行更新组件 */ update(): void; + /** + * 创建组件的新实例。返回实例组件 + * @param componentType + */ + createComponent<T extends Component>(componentType: new () => T): T; /** * 将组件添加到组件列表中。返回组件。 * @param component @@ -857,15 +862,6 @@ declare module es { toString(): string; } } -declare module es { - class ComponentPool<T extends PooledComponent> { - private _cache; - private _type; - constructor(typeClass: any); - obtain(): T; - free(component: T): void; - } -} declare module es { /** * 接口,当添加到一个Component时,只要Component和实体被启用,它就会在每个框架中调用更新方法。 @@ -883,12 +879,6 @@ declare module es { } var isIUpdatable: (props: any) => props is IUpdatable; } -declare module es { - /** 回收实例的组件类型。 */ - abstract class PooledComponent extends Component { - abstract reset(): any; - } -} declare module es { class SceneComponent implements IComparer<SceneComponent> { /** @@ -1272,6 +1262,9 @@ declare module es { private _entities; constructor(matcher?: Matcher); private _scene; + /** + * 这个系统所属的场景 + */ scene: Scene; private _matcher; readonly matcher: Matcher; @@ -1283,10 +1276,96 @@ declare module es { onRemoved(entity: Entity): void; update(): void; lateUpdate(): void; + /** + * 在系统处理开始前调用 + * 在下一个系统开始处理或新的处理回合开始之前(以先到者为准),使用此方法创建的任何实体都不会激活 + */ protected begin(): void; protected process(entities: Entity[]): void; protected lateProcess(entities: Entity[]): void; + /** + * 系统处理完毕后调用 + */ protected end(): void; + /** + * 系统是否需要处理 + * + * 在启用系统时有用,但仅偶尔需要处理 + * 这只影响处理,不影响事件或订阅列表 + * @returns 如果系统应该处理,则为true,如果不处理则为false。 + */ + protected checkProcessing(): boolean; + } +} +declare module es { + /** + * 追踪每个实体的冷却时间,当实体的计时器耗尽时进行处理 + * + * 一个示例系统将是ExpirationSystem,该系统将在特定生存期后删除实体。 + * 你不必运行会为每个实体递减timeLeft值的系统 + * 而只需使用此系统在寿命最短的实体时在将来执行 + * 然后重置系统在未来的某一个最短命实体的时间运行 + * + * 另一个例子是一个动画系统 + * 你知道什么时候你必须对某个实体进行动画制作,比如300毫秒内。 + * 所以你可以设置系统以300毫秒为单位运行来执行动画 + * + * 这将在某些情况下节省CPU周期 + */ + abstract class DelayedIteratingSystem extends EntitySystem { + /** + * 一个实体应被处理的时间 + */ + private delay; + /** + * 如果系统正在运行,并倒计时延迟 + */ + private running; + /** + * 倒计时 + */ + private acc; + constructor(matcher: Matcher); + protected process(entities: Entity[]): void; + protected checkProcessing(): boolean; + /** + * 只有当提供的延迟比系统当前计划执行的时间短时,才会重新启动系统。 + * 如果系统已经停止(不运行),那么提供的延迟将被用来重新启动系统,无论其值如何 + * 如果系统已经在倒计时,并且提供的延迟大于剩余时间,系统将忽略它。 + * 如果提供的延迟时间短于剩余时间,系统将重新启动,以提供的延迟时间运行。 + * @param offeredDelay + */ + offerDelay(offeredDelay: number): void; + /** + * 处理本系统感兴趣的实体 + * 从实体定义的延迟中抽象出accumulativeDelta + * @param entity + * @param accumulatedDelta 本系统最后一次执行后的delta时间 + */ + protected abstract processDelta(entity: Entity, accumulatedDelta: number): any; + protected abstract processExpired(entity: Entity): any; + /** + * 返回该实体处理前的延迟时间 + * @param entity + */ + protected abstract getRemainingDelay(entity: Entity): number; + /** + * 获取系统被命令处理实体后的初始延迟 + */ + getInitialTimeDelay(): number; + /** + * 获取系统计划运行前的时间 + * 如果系统没有运行,则返回零 + */ + getRemainingTimeUntilProcessing(): number; + /** + * 检查系统是否正在倒计时处理 + */ + isRunning(): boolean; + /** + * 停止系统运行,中止当前倒计时 + */ + stop(): void; } } declare module es { @@ -1312,6 +1391,46 @@ declare module es { protected lateProcess(entities: Entity[]): void; } } +declare module es { + /** + * 实体系统以一定的时间间隔进行处理 + */ + abstract class IntervalSystem extends EntitySystem { + /** + * 累积增量以跟踪间隔 + */ + protected acc: number; + /** + * 更新之间需要等待多长时间 + */ + private readonly interval; + private intervalDelta; + constructor(matcher: Matcher, interval: number); + protected checkProcessing(): boolean; + /** + * 获取本系统上次处理后的实际delta值 + */ + protected getIntervalDelta(): number; + } +} +declare module es { + /** + * 每x个ticks处理一个实体的子集 + * + * 典型的用法是每隔一定的时间间隔重新生成弹药或生命值 + * 而无需在每个游戏循环中都进行 + * 而是每100毫秒一次或每秒 + */ + abstract class IntervalIteratingSystem extends IntervalSystem { + constructor(matcher: Matcher, interval: number); + /** + * 处理本系统感兴趣的实体 + * @param entity + */ + abstract processEntity(entity: Entity): any; + protected process(entities: Entity[]): void; + } +} declare module es { abstract class PassiveSystem extends EntitySystem { onChanged(entity: Entity): void; diff --git a/extensions/ecs-tween b/extensions/ecs-tween index 1613c1d2..2154498b 160000 --- a/extensions/ecs-tween +++ b/extensions/ecs-tween @@ -1 +1 @@ -Subproject commit 1613c1d2a8573b487e59248040045700a75f65fd +Subproject commit 2154498b2f8100be178d66d7a6334b7032e41c96 diff --git a/source/bin/framework.d.ts b/source/bin/framework.d.ts index bd70e6f5..409c7e37 100644 --- a/source/bin/framework.d.ts +++ b/source/bin/framework.d.ts @@ -351,6 +351,11 @@ declare module es { * 每帧进行调用进行更新组件 */ update(): void; + /** + * 创建组件的新实例。返回实例组件 + * @param componentType + */ + createComponent<T extends Component>(componentType: new () => T): T; /** * 将组件添加到组件列表中。返回组件。 * @param component @@ -857,15 +862,6 @@ declare module es { toString(): string; } } -declare module es { - class ComponentPool<T extends PooledComponent> { - private _cache; - private _type; - constructor(typeClass: any); - obtain(): T; - free(component: T): void; - } -} declare module es { /** * 接口,当添加到一个Component时,只要Component和实体被启用,它就会在每个框架中调用更新方法。 @@ -883,12 +879,6 @@ declare module es { } var isIUpdatable: (props: any) => props is IUpdatable; } -declare module es { - /** 回收实例的组件类型。 */ - abstract class PooledComponent extends Component { - abstract reset(): any; - } -} declare module es { class SceneComponent implements IComparer<SceneComponent> { /** @@ -1272,6 +1262,9 @@ declare module es { private _entities; constructor(matcher?: Matcher); private _scene; + /** + * 这个系统所属的场景 + */ scene: Scene; private _matcher; readonly matcher: Matcher; @@ -1283,10 +1276,96 @@ declare module es { onRemoved(entity: Entity): void; update(): void; lateUpdate(): void; + /** + * 在系统处理开始前调用 + * 在下一个系统开始处理或新的处理回合开始之前(以先到者为准),使用此方法创建的任何实体都不会激活 + */ protected begin(): void; protected process(entities: Entity[]): void; protected lateProcess(entities: Entity[]): void; + /** + * 系统处理完毕后调用 + */ protected end(): void; + /** + * 系统是否需要处理 + * + * 在启用系统时有用,但仅偶尔需要处理 + * 这只影响处理,不影响事件或订阅列表 + * @returns 如果系统应该处理,则为true,如果不处理则为false。 + */ + protected checkProcessing(): boolean; + } +} +declare module es { + /** + * 追踪每个实体的冷却时间,当实体的计时器耗尽时进行处理 + * + * 一个示例系统将是ExpirationSystem,该系统将在特定生存期后删除实体。 + * 你不必运行会为每个实体递减timeLeft值的系统 + * 而只需使用此系统在寿命最短的实体时在将来执行 + * 然后重置系统在未来的某一个最短命实体的时间运行 + * + * 另一个例子是一个动画系统 + * 你知道什么时候你必须对某个实体进行动画制作,比如300毫秒内。 + * 所以你可以设置系统以300毫秒为单位运行来执行动画 + * + * 这将在某些情况下节省CPU周期 + */ + abstract class DelayedIteratingSystem extends EntitySystem { + /** + * 一个实体应被处理的时间 + */ + private delay; + /** + * 如果系统正在运行,并倒计时延迟 + */ + private running; + /** + * 倒计时 + */ + private acc; + constructor(matcher: Matcher); + protected process(entities: Entity[]): void; + protected checkProcessing(): boolean; + /** + * 只有当提供的延迟比系统当前计划执行的时间短时,才会重新启动系统。 + * 如果系统已经停止(不运行),那么提供的延迟将被用来重新启动系统,无论其值如何 + * 如果系统已经在倒计时,并且提供的延迟大于剩余时间,系统将忽略它。 + * 如果提供的延迟时间短于剩余时间,系统将重新启动,以提供的延迟时间运行。 + * @param offeredDelay + */ + offerDelay(offeredDelay: number): void; + /** + * 处理本系统感兴趣的实体 + * 从实体定义的延迟中抽象出accumulativeDelta + * @param entity + * @param accumulatedDelta 本系统最后一次执行后的delta时间 + */ + protected abstract processDelta(entity: Entity, accumulatedDelta: number): any; + protected abstract processExpired(entity: Entity): any; + /** + * 返回该实体处理前的延迟时间 + * @param entity + */ + protected abstract getRemainingDelay(entity: Entity): number; + /** + * 获取系统被命令处理实体后的初始延迟 + */ + getInitialTimeDelay(): number; + /** + * 获取系统计划运行前的时间 + * 如果系统没有运行,则返回零 + */ + getRemainingTimeUntilProcessing(): number; + /** + * 检查系统是否正在倒计时处理 + */ + isRunning(): boolean; + /** + * 停止系统运行,中止当前倒计时 + */ + stop(): void; } } declare module es { @@ -1312,6 +1391,46 @@ declare module es { protected lateProcess(entities: Entity[]): void; } } +declare module es { + /** + * 实体系统以一定的时间间隔进行处理 + */ + abstract class IntervalSystem extends EntitySystem { + /** + * 累积增量以跟踪间隔 + */ + protected acc: number; + /** + * 更新之间需要等待多长时间 + */ + private readonly interval; + private intervalDelta; + constructor(matcher: Matcher, interval: number); + protected checkProcessing(): boolean; + /** + * 获取本系统上次处理后的实际delta值 + */ + protected getIntervalDelta(): number; + } +} +declare module es { + /** + * 每x个ticks处理一个实体的子集 + * + * 典型的用法是每隔一定的时间间隔重新生成弹药或生命值 + * 而无需在每个游戏循环中都进行 + * 而是每100毫秒一次或每秒 + */ + abstract class IntervalIteratingSystem extends IntervalSystem { + constructor(matcher: Matcher, interval: number); + /** + * 处理本系统感兴趣的实体 + * @param entity + */ + abstract processEntity(entity: Entity): any; + protected process(entities: Entity[]): void; + } +} declare module es { abstract class PassiveSystem extends EntitySystem { onChanged(entity: Entity): void; diff --git a/source/bin/framework.js b/source/bin/framework.js index f4bd6517..0739cc5f 100644 --- a/source/bin/framework.js +++ b/source/bin/framework.js @@ -928,6 +928,15 @@ var es; Entity.prototype.update = function () { this.components.update(); }; + /** + * 创建组件的新实例。返回实例组件 + * @param componentType + */ + Entity.prototype.createComponent = function (componentType) { + var component = new componentType(); + this.addComponent(component); + return component; + }; /** * 将组件添加到组件列表中。返回组件。 * @param component @@ -1953,29 +1962,6 @@ var es; es.Transform = Transform; })(es || (es = {})); var es; -(function (es) { - var ComponentPool = /** @class */ (function () { - function ComponentPool(typeClass) { - this._type = typeClass; - this._cache = []; - } - ComponentPool.prototype.obtain = function () { - try { - return this._cache.length > 0 ? this._cache.shift() : new this._type(); - } - catch (err) { - throw new Error(this._type + err); - } - }; - ComponentPool.prototype.free = function (component) { - component.reset(); - this._cache.push(component); - }; - return ComponentPool; - }()); - es.ComponentPool = ComponentPool; -})(es || (es = {})); -var es; (function (es) { /** * 用于比较组件更新排序 @@ -1992,18 +1978,6 @@ var es; es.isIUpdatable = function (props) { return typeof props['update'] !== 'undefined'; }; })(es || (es = {})); var es; -(function (es) { - /** 回收实例的组件类型。 */ - var PooledComponent = /** @class */ (function (_super) { - __extends(PooledComponent, _super); - function PooledComponent() { - return _super !== null && _super.apply(this, arguments) || this; - } - return PooledComponent; - }(es.Component)); - es.PooledComponent = PooledComponent; -})(es || (es = {})); -var es; (function (es) { var SceneComponent = /** @class */ (function () { function SceneComponent() { @@ -2913,6 +2887,9 @@ var es; this._matcher = matcher ? matcher : es.Matcher.empty(); } Object.defineProperty(EntitySystem.prototype, "scene", { + /** + * 这个系统所属的场景 + */ get: function () { return this._scene; }, @@ -2944,34 +2921,161 @@ var es; this._entities.push(entity); this.onAdded(entity); }; - EntitySystem.prototype.onAdded = function (entity) { - }; + EntitySystem.prototype.onAdded = function (entity) { }; EntitySystem.prototype.remove = function (entity) { new linq.List(this._entities).remove(entity); this.onRemoved(entity); }; - EntitySystem.prototype.onRemoved = function (entity) { - }; + EntitySystem.prototype.onRemoved = function (entity) { }; EntitySystem.prototype.update = function () { - this.begin(); - this.process(this._entities); + if (this.checkProcessing()) { + this.begin(); + this.process(this._entities); + } }; EntitySystem.prototype.lateUpdate = function () { - this.lateProcess(this._entities); - this.end(); - }; - EntitySystem.prototype.begin = function () { - }; - EntitySystem.prototype.process = function (entities) { - }; - EntitySystem.prototype.lateProcess = function (entities) { + if (this.checkProcessing()) { + this.lateProcess(this._entities); + this.end(); + } }; - EntitySystem.prototype.end = function () { + /** + * 在系统处理开始前调用 + * 在下一个系统开始处理或新的处理回合开始之前(以先到者为准),使用此方法创建的任何实体都不会激活 + */ + EntitySystem.prototype.begin = function () { }; + EntitySystem.prototype.process = function (entities) { }; + EntitySystem.prototype.lateProcess = function (entities) { }; + /** + * 系统处理完毕后调用 + */ + EntitySystem.prototype.end = function () { }; + /** + * 系统是否需要处理 + * + * 在启用系统时有用,但仅偶尔需要处理 + * 这只影响处理,不影响事件或订阅列表 + * @returns 如果系统应该处理,则为true,如果不处理则为false。 + */ + EntitySystem.prototype.checkProcessing = function () { + return true; }; return EntitySystem; }()); es.EntitySystem = EntitySystem; })(es || (es = {})); +///<reference path="./EntitySystem.ts"/> +var es; +///<reference path="./EntitySystem.ts"/> +(function (es) { + /** + * 追踪每个实体的冷却时间,当实体的计时器耗尽时进行处理 + * + * 一个示例系统将是ExpirationSystem,该系统将在特定生存期后删除实体。 + * 你不必运行会为每个实体递减timeLeft值的系统 + * 而只需使用此系统在寿命最短的实体时在将来执行 + * 然后重置系统在未来的某一个最短命实体的时间运行 + * + * 另一个例子是一个动画系统 + * 你知道什么时候你必须对某个实体进行动画制作,比如300毫秒内。 + * 所以你可以设置系统以300毫秒为单位运行来执行动画 + * + * 这将在某些情况下节省CPU周期 + */ + var DelayedIteratingSystem = /** @class */ (function (_super) { + __extends(DelayedIteratingSystem, _super); + function DelayedIteratingSystem(matcher) { + var _this = _super.call(this, matcher) || this; + /** + * 一个实体应被处理的时间 + */ + _this.delay = 0; + /** + * 如果系统正在运行,并倒计时延迟 + */ + _this.running = false; + /** + * 倒计时 + */ + _this.acc = 0; + return _this; + } + DelayedIteratingSystem.prototype.process = function (entities) { + var processed = entities.length; + if (processed == 0) { + this.stop(); + return; + } + this.delay = Number.MAX_VALUE; + for (var i = 0; processed > i; i++) { + var e = entities[i]; + this.processDelta(e, this.acc); + var remaining = this.getRemainingDelay(e); + if (remaining <= 0) { + this.processExpired(e); + } + else { + this.offerDelay(remaining); + } + } + this.acc = 0; + }; + DelayedIteratingSystem.prototype.checkProcessing = function () { + if (this.running) { + this.acc += es.Time.deltaTime; + return this.acc >= this.delay; + } + return false; + }; + /** + * 只有当提供的延迟比系统当前计划执行的时间短时,才会重新启动系统。 + * 如果系统已经停止(不运行),那么提供的延迟将被用来重新启动系统,无论其值如何 + * 如果系统已经在倒计时,并且提供的延迟大于剩余时间,系统将忽略它。 + * 如果提供的延迟时间短于剩余时间,系统将重新启动,以提供的延迟时间运行。 + * @param offeredDelay + */ + DelayedIteratingSystem.prototype.offerDelay = function (offeredDelay) { + if (!this.running) { + this.running = true; + this.delay = offeredDelay; + } + else { + this.delay = Math.min(this.delay, offeredDelay); + } + }; + /** + * 获取系统被命令处理实体后的初始延迟 + */ + DelayedIteratingSystem.prototype.getInitialTimeDelay = function () { + return this.delay; + }; + /** + * 获取系统计划运行前的时间 + * 如果系统没有运行,则返回零 + */ + DelayedIteratingSystem.prototype.getRemainingTimeUntilProcessing = function () { + if (this.running) { + return this.delay - this.acc; + } + return 0; + }; + /** + * 检查系统是否正在倒计时处理 + */ + DelayedIteratingSystem.prototype.isRunning = function () { + return this.running; + }; + /** + * 停止系统运行,中止当前倒计时 + */ + DelayedIteratingSystem.prototype.stop = function () { + this.running = false; + this.acc = 0; + }; + return DelayedIteratingSystem; + }(es.EntitySystem)); + es.DelayedIteratingSystem = DelayedIteratingSystem; +})(es || (es = {})); ///<reference path="./EntitySystem.ts" /> var es; ///<reference path="./EntitySystem.ts" /> @@ -3006,6 +3110,70 @@ var es; es.EntityProcessingSystem = EntityProcessingSystem; })(es || (es = {})); var es; +(function (es) { + /** + * 实体系统以一定的时间间隔进行处理 + */ + var IntervalSystem = /** @class */ (function (_super) { + __extends(IntervalSystem, _super); + function IntervalSystem(matcher, interval) { + var _this = _super.call(this, matcher) || this; + /** + * 累积增量以跟踪间隔 + */ + _this.acc = 0; + /** + * 更新之间需要等待多长时间 + */ + _this.interval = 0; + _this.intervalDelta = 0; + _this.interval = interval; + return _this; + } + IntervalSystem.prototype.checkProcessing = function () { + this.acc += es.Time.deltaTime; + if (this.acc >= this.interval) { + this.acc -= this.interval; + this.intervalDelta = (this.acc - this.intervalDelta); + return true; + } + return false; + }; + /** + * 获取本系统上次处理后的实际delta值 + */ + IntervalSystem.prototype.getIntervalDelta = function () { + return this.interval + this.intervalDelta; + }; + return IntervalSystem; + }(es.EntitySystem)); + es.IntervalSystem = IntervalSystem; +})(es || (es = {})); +///<reference path="./IntervalSystem.ts"/> +var es; +///<reference path="./IntervalSystem.ts"/> +(function (es) { + /** + * 每x个ticks处理一个实体的子集 + * + * 典型的用法是每隔一定的时间间隔重新生成弹药或生命值 + * 而无需在每个游戏循环中都进行 + * 而是每100毫秒一次或每秒 + */ + var IntervalIteratingSystem = /** @class */ (function (_super) { + __extends(IntervalIteratingSystem, _super); + function IntervalIteratingSystem(matcher, interval) { + return _super.call(this, matcher, interval) || this; + } + IntervalIteratingSystem.prototype.process = function (entities) { + var _this = this; + entities.forEach(function (entity) { return _this.processEntity(entity); }); + }; + return IntervalIteratingSystem; + }(es.IntervalSystem)); + es.IntervalIteratingSystem = IntervalIteratingSystem; +})(es || (es = {})); +var es; (function (es) { var PassiveSystem = /** @class */ (function (_super) { __extends(PassiveSystem, _super); diff --git a/source/bin/framework.min.js b/source/bin/framework.min.js index 0199165f..8f2c3793 100644 --- a/source/bin/framework.min.js +++ b/source/bin/framework.min.js @@ -1 +1 @@ -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 e(n,i){void 0===n&&(n=!0),void 0===i&&(i=!0),this._globalManagers=[],this._coroutineManager=new t.CoroutineManager,this._timerManager=new t.TimerManager,this._frameCounterElapsedTime=0,this._frameCounter=0,this._totalMemory=0,e._instance=this,e.emitter=new t.Emitter,e.emitter.addObserver(t.CoreEvents.frameUpdated,this.update,this),e.registerGlobalManager(this._coroutineManager),e.registerGlobalManager(this._timerManager),e.entitySystemsEnabled=i,this.debug=n,this.initialize()}return Object.defineProperty(e,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(e,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(e){t.Insist.isNotNull(e,"场景不能为空"),null==this._instance._scene?(this._instance._scene=e,this._instance.onSceneChanged(),this._instance._scene.begin()):this._instance._nextScene=e},enumerable:!0,configurable:!0}),e.create=function(e){return void 0===e&&(e=!0),null==this._instance&&(this._instance=new t.Core(e)),this._instance},e.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},e.unregisterGlobalManager=function(t){new linq.List(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[e]instanceof t)return this._instance._globalManagers[e];return null},e.startCoroutine=function(t){return this._instance._coroutineManager.startCoroutine(t)},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.startDebugUpdate=function(){this.debug&&(t.TimeRuler.Instance.startFrame(),t.TimeRuler.Instance.beginMark("update",65280))},e.prototype.endDebugUpdate=function(){this.debug&&t.TimeRuler.Instance.endMark("update")},e.prototype.startDebugDraw=function(){if(this.debug&&(this._frameCounter++,this._frameCounterElapsedTime+=t.Time.deltaTime,this._frameCounterElapsedTime>=1)){var e=window.performance.memory;null!=e&&(this._totalMemory=Number((e.totalJSHeapSize/1048576).toFixed(2))),this._titleMemory&&this._titleMemory(this._totalMemory,this._frameCounter),this._frameCounter=0,this._frameCounterElapsedTime-=1}},e.prototype.onSceneChanged=function(){t.Time.sceneChanged()},e.prototype.initialize=function(){},e.prototype.update=function(e){return void 0===e&&(e=-1),__awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(i){if(this.startDebugUpdate(),t.Time.update(e),null!=this._scene){for(n=this._globalManagers.length-1;n>=0;n--)this._globalManagers[n].enabled&&this._globalManagers[n].update();this._scene.update(),null!=this._nextScene&&(this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),this._scene.begin())}return this.endDebugUpdate(),this.startDebugDraw(),[2]})})},e.pauseOnFocusLost=!0,e.debugRenderEndabled=!1,e}();t.Core=e}(es||(es={})),function(t){var e;!function(t){t[t.error=0]="error",t[t.warn=1]="warn",t[t.log=2]="log",t[t.info=3]="info",t[t.trace=4]="trace"}(e=t.LogType||(t.LogType={}));var n=function(){function t(){}return t.warnIf=function(t,n){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];t&&this.log(e.warn,n,i)},t.warn=function(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.log(e.warn,t,n)},t.error=function(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.log(e.error,t,n)},t.log=function(t,n){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];switch(t){case e.error:console.error(t+": "+StringUtils.format(n,i));break;case e.warn:console.warn(t+": "+StringUtils.format(n,i));break;case e.log:console.log(t+": "+StringUtils.format(n,i));break;case e.info:console.info(t+": "+StringUtils.format(n,i));break;case e.trace:console.trace(t+": "+StringUtils.format(n,i));break;default:throw new Error("argument out of range")}},t}();t.Debug=n}(es||(es={})),function(t){var e=function(){function t(){}return t.debugText=16777215,t.colliderBounds=5033164.5,t.colliderEdge=9109504,t.colliderPosition=16776960,t.colliderCenter=16711680,t.renderableBounds=16776960,t.renderableCenter=10040012,t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefault=e}(es||(es={})),function(t){var e=function(){function t(){}return t.fail=function(t){void 0===t&&(t=null);for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];null==t?console.assert(!1):console.assert(!1,StringUtils.format(t,e))},t.isTrue=function(t,e){void 0===e&&(e=null);for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];t||(null==e?this.fail():this.fail(e,n))},t.isFalse=function(t,e){void 0===e&&(e=null);for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];null==e?this.isTrue(!t):this.isTrue(!t,e,n)},t.isNull=function(t,e){void 0===e&&(e=null);for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];null==e?this.isTrue(null==t):this.isTrue(null==t,e,n)},t.isNotNull=function(t,e){void 0===e&&(e=null);for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];null==e?this.isTrue(null!=t):this.isTrue(null!=t,e,n)},t.areEqual=function(t,e,n){for(var i=[],r=3;r<arguments.length;r++)i[r-3]=arguments[r];t!=e&&this.fail(n,i)},t.areNotEqual=function(t,e,n){for(var i=[],r=3;r<arguments.length;r++)i[r-3]=arguments[r];t==e&&this.fail(n,i)},t}();t.Insist=e}(es||(es={})),function(t){var e=function(){function t(){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){!function(t){t[t.sceneChanged=0]="sceneChanged",t[t.frameUpdated=1]="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++,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.setParent=function(e){return e instanceof t.Transform?this.transform.setParent(e):e instanceof n&&this.transform.setParent(e.transform),this},n.prototype.setPosition=function(t,e){return this.transform.setPosition(t,e),this},n.prototype.setLocalPosition=function(t){return this.transform.setLocalPosition(t),this},n.prototype.setRotation=function(t){return this.transform.setRotation(t),this},n.prototype.setRotationDegrees=function(t){return this.transform.setRotationDegrees(t),this},n.prototype.setLocalRotation=function(t){return this.transform.setLocalRotation(t),this},n.prototype.setLocalRotationDegrees=function(t){return this.transform.setLocalRotationDegrees(t),this},n.prototype.setScale=function(e){return e instanceof t.Vector2?this.transform.setScale(e):this.transform.setScale(new t.Vector2(e)),this},n.prototype.setLocalScale=function(e){return e instanceof t.Vector2?this.transform.setLocalScale(e):this.transform.setLocalScale(new t.Vector2(e)),this},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(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.angleBetween=function(n,i){var r=e.subtract(n,this),o=e.subtract(i,this);return t.Vector2Ext.angle(r,o)},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){!function(t){t[t.none=0]="none",t[t.bestFit=1]="bestFit"}(t.SceneResolutionPolicy||(t.SceneResolutionPolicy={}));var e=function(){function e(){this._sceneComponents=[],this.entities=new t.EntityList(this),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(),null!=this.entityProcessors&&this.entityProcessors.begin(),this._didSceneBegin=!0,this.onStart()},e.prototype.end=function(){this._didSceneBegin=!1,this.entities.removeAllEntities();for(var e=0;e<this._sceneComponents.length;e++)this._sceneComponents[e].onRemovedFromScene();this._sceneComponents.length=0,t.Physics.clear(),this.entityProcessors&&this.entityProcessors.end(),this.unload()},e.prototype.update=function(){this.entities.updateLists();for(var t=this._sceneComponents.length-1;t>=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();null!=this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),null!=this.entityProcessors&&this.entityProcessors.lateUpdate()},e.prototype.addSceneComponent=function(t){return t.scene=this,t.onEnabled(),this._sceneComponents.push(t),this._sceneComponents.sort(t.compare),t},e.prototype.getSceneComponent=function(t){for(var e=0;e<this._sceneComponents.length;e++){var n=this._sceneComponents[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(e){var n=new linq.List(this._sceneComponents);t.Insist.isTrue(n.contains(e),"SceneComponent"+e+"不在SceneComponents列表中!"),n.remove(e),e.onRemovedFromScene()},e.prototype.createEntity=function(e){var n=new t.Entity(e);return this.addEntity(n)},e.prototype.addEntity=function(e){t.Insist.isFalse(new linq.List(this.entities.buffer).contains(e),"您试图将同一实体添加到场景两次: "+e),this.entities.add(e),e.scene=this;for(var n=0;n<e.transform.childCount;n++)this.addEntity(e.transform.getChild(n).entity);return e},e.prototype.destroyAllEntities=function(){for(var t=0;t<this.entities.count;t++)this.entities.buffer[t].destroy()},e.prototype.findEntity=function(t){return this.entities.findEntity(t)},e.prototype.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=4]="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=t.Vector2Ext.round(this._position)},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 t(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.onRemovedFromScene=function(){},t.prototype.update=function(){},t.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},t.prototype.setUpdateOrder=function(t){return this.updateOrder!=t&&(this.updateOrder=t),this},t.prototype.compare=function(t){return this.updateOrder-t.updateOrder},t}();t.SceneComponent=e}(es||(es={})),function(t){var e=function(e){function n(){var n=e.call(this)||this;return n.shouldUseGravity=!0,n.velocity=new t.Vector2,n._mass=10,n._elasticity=.5,n._friction=.5,n._glue=.01,n._inverseMass=0,n._inverseMass=1/n._mass,n}return __extends(n,e),Object.defineProperty(n.prototype,"mass",{get:function(){return this._mass},set:function(t){this.setMass(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"elasticity",{get:function(){return this._elasticity},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"elasticiy",{set:function(t){this.setElasticity(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"friction",{get:function(){return this._friction},set:function(t){this.setFriction(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"glue",{get:function(){return this._glue},set:function(t){this.setGlue(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isImmovable",{get:function(){return this._mass<1e-4},enumerable:!0,configurable:!0}),n.prototype.setMass=function(e){return this._mass=t.MathHelper.clamp(e,0,Number.MAX_VALUE),this._mass>1e-4?this._inverseMass=1/this._mass:this._inverseMass=0,this},n.prototype.setElasticity=function(e){return this._elasticity=t.MathHelper.clamp01(e),this},n.prototype.setFriction=function(e){return this._friction=t.MathHelper.clamp01(e),this},n.prototype.setGlue=function(e){return this._glue=t.MathHelper.clamp(e,0,10),this},n.prototype.addImpulse=function(e){this.isImmovable||(this.velocity=t.Vector2.add(this.velocity,t.Vector2.multiply(e,new t.Vector2(1e5)).multiply(new t.Vector2(this._inverseMass*t.Time.deltaTime))))},n.prototype.onAddedToEntity=function(){this._collider=this.entity.getComponent(t.Collider),t.Debug.warnIf(null==this._collider,"ArcadeRigidbody 没有 Collider。ArcadeRigidbody需要一个Collider!")},n.prototype.update=function(){var e,i;if(this.isImmovable||null==this._collider)this.velocity=t.Vector2.zero;else{this.shouldUseGravity&&(this.velocity=t.Vector2.add(this.velocity,t.Vector2.multiply(t.Physics.gravity,new t.Vector2(t.Time.deltaTime)))),this.entity.transform.position=t.Vector2.add(this.entity.transform.position,t.Vector2.multiply(this.velocity,new t.Vector2(t.Time.deltaTime)));var r=new t.CollisionResult,o=t.Physics.boxcastBroadphaseExcludingSelfNonRect(this._collider,this._collider.collidesWithLayers.value);try{for(var s=__values(o),a=s.next();!a.done;a=s.next()){var c=a.value;if(!c.entity.equals(this.entity)&&this._collider.collidesWithNonMotion(c,r)){var h=c.entity.getComponent(n);if(null!=h)this.processOverlap(h,r.minimumTranslationVector),this.processCollision(h,r.minimumTranslationVector);else{this.entity.transform.position=t.Vector2.subtract(this.entity.transform.position,r.minimumTranslationVector);var u=this.velocity.clone();this.calculateResponseVelocity(u,r.minimumTranslationVector,u),this.velocity=t.Vector2.add(this.velocity,u)}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}}},n.prototype.processOverlap=function(e,n){this.isImmovable?e.entity.transform.position=t.Vector2.add(e.entity.transform.position,n):e.isImmovable?this.entity.transform.position=t.Vector2.subtract(this.entity.transform.position,n):(this.entity.transform.position=t.Vector2.subtract(this.entity.transform.position,t.Vector2.multiply(n,t.Vector2Ext.halfVector())),e.entity.transform.position=t.Vector2.add(e.entity.transform.position,t.Vector2.multiply(n,t.Vector2Ext.halfVector())))},n.prototype.processCollision=function(e,n){var i=t.Vector2.subtract(this.velocity,e.velocity);this.calculateResponseVelocity(i,n,i);var r=this._inverseMass+e._inverseMass,o=this._inverseMass/r,s=e._inverseMass/r;this.velocity=t.Vector2.add(this.velocity,new t.Vector2(i.x*o,i.y*o)),e.velocity=t.Vector2.subtract(e.velocity,new t.Vector2(i.x*s,i.y*s))},n.prototype.calculateResponseVelocity=function(e,n,i){void 0===i&&(i=new t.Vector2);var r=t.Vector2.multiply(n,new t.Vector2(-1)),o=t.Vector2.normalize(r),s=t.Vector2.dot(e,o),a=new t.Vector2(o.x*s,o.y*s),c=t.Vector2.subtract(e,a);s>0&&(a=t.Vector2.zero);var h=this._friction;c.lengthSquared()<this._glue&&(h=1.01);var u=t.Vector2.multiply(new t.Vector2(1+this._elasticity),a).multiply(new t.Vector2(-1)).subtract(t.Vector2.multiply(new t.Vector2(h),c));i.x=u.x,e.y=u.y},n}(t.Component);t.ArcadeRigidbody=e}(es||(es={})),function(t){var e=function(){function e(){}return e.getITriggerListener=function(e,n){var i,r,o,s;try{for(var a=__values(e.components._components),c=a.next();!c.done;c=a.next()){var h=c.value;t.isITriggerListener(h)&&n.push(h)}}catch(t){i={error:t}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}try{for(var u=__values(e.components._componentsToAdd),l=u.next();!l.done;l=u.next()){h=l.value;t.isITriggerListener(h)&&n.push(h)}}catch(t){o={error:t}}finally{try{l&&!l.done&&(s=u.return)&&s.call(u)}finally{if(o)throw o.error}}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),t.Debug.warnIf(null==this._collider,"ProjectileMover没有Collider。ProjectilMover需要一个Collider!")},n.prototype.move=function(e){var n,i;if(null==this._collider)return!1;var r=!1;this.entity.position=t.Vector2.add(this.entity.position,e);var o=t.Physics.boxcastBroadphase(this._collider.bounds,this._collider.collidesWithLayers.value);try{for(var s=__values(o),a=s.next();!a.done;a=s.next()){var c=a.value;this._collider.overlaps(c)&&c.enabled&&(r=!0,this.notifyTriggerListeners(this._collider,c))}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return r},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&&null!=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.equals(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){void 0===i&&(i=new t.CollisionResult);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.prototype.collidesWithNonMotion=function(e,n){return void 0===n&&(n=new t.CollisionResult),!!this.shape.collidesWithShape(e.shape,n)&&(n.collider=e,!0)},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){this._colliderRequiresAutoSizing=!1;var i=this.shape;return e==i.width&&n==i.height||(i.updateBox(e,n),this._isPositionDirty=!0,this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},n.prototype.setWidth=function(e){this._colliderRequiresAutoSizing=!1;var n=this.shape;return e!=n.width&&(n.updateBox(e,n.height),this._isPositionDirty=!0,this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},n.prototype.setHeight=function(e){this._colliderRequiresAutoSizing=!1;var n=this.shape;e!=n.height&&(n.updateBox(n.width,e),this._isPositionDirty=!0,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){this._colliderRequiresAutoSizing=!1;var n=this.shape;return e!=n.radius&&(n.radius=e,n._originalRadius=e,this._isPositionDirty=!0,null!=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(t){this._components=[],this._updatableComponents=[],this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=t}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(e){var n=new linq.List(this._componentsToRemove),i=new linq.List(this._componentsToAdd);t.Debug.warnIf(n.contains(e),"您正在尝试删除一个您已经删除的组件("+e+")"),i.contains(e)?i.remove(e):n.add(e)},e.prototype.removeAllComponents=function(){for(var t=0;t<this._components.length;t++)this.handleRemove(this._components[t]);this._components.length=0,this._updatableComponents.length=0,this._componentsToAdd.length=0,this._componentsToRemove.length=0},e.prototype.deregisterAllComponents=function(){var e,n;try{for(var i=__values(this._components),r=i.next();!r.done;r=i.next()){var o=r.value;o&&(t.isIUpdatable(o)&&new linq.List(this._updatableComponents).remove(o),this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(o)),!1),this._entity.scene.entityProcessors.onComponentRemoved(this._entity))}}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e.prototype.registerAllComponents=function(){var e,n;try{for(var i=__values(this._components),r=i.next();!r.done;r=i.next()){var o=r.value;t.isIUpdatable(o)&&this._updatableComponents.push(o),this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(o))),this._entity.scene.entityProcessors.onComponentAdded(this._entity)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e.prototype.updateLists=function(){if(this._componentsToRemove.length>0){for(var n=0;n<this._componentsToRemove.length;n++)this.handleRemove(this._componentsToRemove[n]),new linq.List(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.push(r),this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(r))),this._entity.scene.entityProcessors.onComponentAdded(this._entity),this._components.push(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.compare),this._isComponentListUnsorted=!1)},e.prototype.handleRemove=function(e){t.isIUpdatable(e)&&new linq.List(this._updatableComponents).remove(e),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){var n,i,r,o;try{for(var s=__values(this._components),a=s.next();!a.done;a=s.next()){if((u=a.value)instanceof t)return u}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}if(!e)try{for(var c=__values(this._componentsToAdd),h=c.next();!h.done;h=c.next()){var u;if((u=h.value)instanceof t)return u}}catch(t){r={error:t}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}return null},e.prototype.getComponents=function(t,e){var n,i,r,o;e||(e=[]);try{for(var s=__values(this._components),a=s.next();!a.done;a=s.next()){(u=a.value)instanceof t&&e.push(u)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}try{for(var c=__values(this._componentsToAdd),h=c.next();!h.done;h=c.next()){var u;(u=h.value)instanceof t&&e.push(u)}}catch(t){r={error:t}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}return e},e.prototype.update=function(){this.updateLists();for(var t=0;t<this._updatableComponents.length;t++)this._updatableComponents[t].enabled&&this._updatableComponents[t].update()},e.prototype.onEntityTransformChanged=function(t){for(var e=0;e<this._components.length;e++)this._components[e].enabled&&this._components[e].onEntityTransformChanged(t);for(e=0;e<this._componentsToAdd.length;e++)this._componentsToAdd[e].enabled&&this._componentsToAdd[e].onEntityTransformChanged(t)},e.prototype.onEntityEnabled=function(){for(var t=0;t<this._components.length;t++)this._components[t].onEnabled()},e.prototype.onEntityDisabled=function(){for(var t=0;t<this._components.length;t++)this._components[t].onDisabled()},e.compareUpdatableOrder=new t.IUpdatableComparer,e}();t.ComponentList=e}(es||(es={})),function(t){var e=function(){function t(){}return t.add=function(t){this._componentTypesMask.has(t)||this._componentTypesMask.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=[],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(e){t.Debug.warnIf(this._entitiesToRemove.contains(e),"您正在尝试删除已经删除的实体("+e.name+")"),this._entitiesToAdded.contains(e)?this._entitiesToAdded.remove(e):this._entitiesToRemove.contains(e)||this._entitiesToRemove.add(e)},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[t]._isDestroyed=!0,this._entities[t].onRemovedFromScene(),this._entities[t].scene=null;this._entities.length=0,this._entityDict.clear()},e.prototype.contains=function(t){return new linq.List(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(){var e,n;try{for(var i=__values(this._entities),r=i.next();!r.done;r=i.next()){var o=r.value;!o.enabled||1!=o.updateInterval&&t.Time.frameCount%o.updateInterval!=0||o.update()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e.prototype.updateLists=function(){var e=this;this._entitiesToRemove.getCount()>0&&(this._entitiesToRemove.toArray().forEach(function(t){e.removeFromTagList(t),new linq.List(e._entities).remove(t),t.onRemovedFromScene(),t.scene=null,e.scene.entityProcessors.onEntityRemoved(t)}),this._entitiesToRemove.clear()),this._entitiesToAdded.getCount()>0&&(this._entitiesToAdded.toArray().forEach(function(t){e._entities.push(t),t.scene=e.scene,e.addToTagList(t),e.scene.entityProcessors.onEntityAdded(t)}),this._entitiesToAdded.toArray().forEach(function(t){t.onAddedToScene()}),this._entitiesToAdded.clear(),this._isEntityListUnsorted=!0),this._isEntityListUnsorted&&(this._entities.sort(t.Entity.entityComparer.compare),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[e].name==t)return this._entities[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[i]instanceof e&&n.push(this._entities[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[e].enabled)if(n=this._entities[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[i].enabled&&this._entities[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 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.format=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var i=0;i<e.length-1;i++){var r=new RegExp("\\{"+i+"\\}","gm");t=t.replace(r,e[i+1])}return t},t.specialSigns=["&","&","<","<",">",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function t(){}return t.update=function(t){-1==t&&(t=Date.now()),-1==this._lastTime&&(this._lastTime=t);var e=t-this._lastTime;this.totalTime+=e,this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this.timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this.timeSinceSceneLoad=0},t.checkEvery=function(t){return this.timeSinceSceneLoad/t>(this.timeSinceSceneLoad-this.deltaTime)/t},t.totalTime=0,t.unscaledDeltaTime=0,t.deltaTime=0,t.timeScale=1,t.frameCount=0,t.timeSinceSceneLoad=0,t._lastTime=-1,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),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 h=n.getDay();if(0==h&&(h=7),e&&(!o||h<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 new t.Vector2(o*o).multiply(e).add(new t.Vector2(2*o*r).multiply(n)).add(new t.Vector2(r*r).multiply(i))},e.getPointThree=function(e,n,i,r,o){var s=1-(o=t.MathHelper.clamp01(o));return new t.Vector2(s*s*s).multiply(e).add(new t.Vector2(3*s*s*o).multiply(n)).add(new t.Vector2(3*s*o*o).multiply(i)).add(new t.Vector2(o*o*o).multiply(r))},e.getFirstDerivative=function(e,n,i,r){return new t.Vector2(2*(1-r)).multiply(t.Vector2.subtract(n,e)).add(new t.Vector2(2*r).multiply(t.Vector2.subtract(i,n)))},e.getFirstDerivativeThree=function(e,n,i,r,o){var s=1-(o=t.MathHelper.clamp01(o));return new t.Vector2(3*s*s).multiply(t.Vector2.subtract(n,e)).add(new t.Vector2(6*s*o).multiply(t.Vector2.subtract(i,n))).add(new t.Vector2(3*o*o).multiply(t.Vector2.subtract(r,i)))},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)),h=t.Vector2.divide(t.Vector2.add(i,r),new t.Vector2(2)),u=t.Vector2.divide(t.Vector2.add(a,c),new t.Vector2(2)),l=t.Vector2.divide(t.Vector2.add(c,h),new t.Vector2(2)),p=t.Vector2.divide(t.Vector2.add(u,l),new t.Vector2(2)),f=t.Vector2.subtract(r,e),d=Math.abs((n.x,r.x*f.y-(n.y-r.y)*f.x)),m=Math.abs((i.x-r.x)*f.y-(i.y-r.y)*f.x);(d+m)*(d+m)<s*(f.x*f.x+f.y*f.y)?o.push(p):(this.recursiveGetOptimizedDrawingPoints(e,a,u,p,o,s),this.recursiveGetOptimizedDrawingPoints(p,l,h,r,o,s))},e}();t.Bezier=e}(es||(es={})),function(t){var e=function(){function e(){this._points=[],this._curveCount=0}return e.prototype.pointIndexAtTime=function(e){var n=0;return e.value>=1?(e.value=1,n=this._points.length-4):(e.value=t.MathHelper.clamp01(e.value)*this._curveCount,n=~~e,e.value-=n,n*=3),n},e.prototype.setControlPoint=function(e,n){if(e%3==0){var i=t.Vector2.subtract(n,this._points[e]);e>0&&this._points[e-1].add(i),e+1<this._points.length&&this._points[e+1].add(i)}this._points[e]=n},e.prototype.getPointAtTime=function(e){var n=this.pointIndexAtTime(new t.Ref(e));return t.Bezier.getPointThree(this._points[n],this._points[n+1],this._points[n+2],this._points[n+3],e)},e.prototype.getVelocityAtTime=function(e){var n=this.pointIndexAtTime(new t.Ref(e));return t.Bezier.getFirstDerivativeThree(this._points[n],this._points[n+1],this._points[n+2],this._points[n+3],e)},e.prototype.getDirectionAtTime=function(e){return t.Vector2.normalize(this.getVelocityAtTime(e))},e.prototype.addCurve=function(t,e,n,i){0==this._points.length&&this._points.push(t),this._points.push(e),this._points.push(n),this._points.push(i),this._curveCount=(this._points.length-1)/3},e.prototype.reset=function(){this._points.length=0},e.prototype.getDrawingPoints=function(t){for(var e=[],n=0;n<t;n++){var i=n/t;e[n]=this.getPointAtTime(i)}return e},e}();t.BezierSpline=e}(es||(es={})),function(t){var e=function(){function t(){}return t.isFlagSet=function(t,e){return 0!=(t&e)},t.isUnshiftedFlagSet=function(t,e){return 0!=(t&(e=1<<e))},t.setFlagExclusive=function(t,e){t.value=1<<e},t.setFlag=function(t,e){t.value=t.value|1<<e},t.unsetFlag=function(t,e){e=1<<e,t.value=t.value&~e},t.invertFlags=function(t){t.value=~t.value},t}();t.Flags=e}(es||(es={})),function(t){var e=function(){function e(){}return e.toDegrees=function(t){return 57.29577951308232*t},e.toRadians=function(t){return.017453292519943295*t},e.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.angleToVector=function(e,n){return new t.Vector2(Math.cos(e)*n,Math.sin(e)*n)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.roundToNearest=function(t,e){return Math.round(t/e)*e},e.withinEpsilon=function(t,e){return void 0===e&&(e=this.Epsilon),Math.abs(t)<e},e.approach=function(t,e,n){return t<e?Math.min(t+n,e):Math.max(t-n,e)},e.deltaAngle=function(t,e){var n=this.repeat(e-t,360);return n>180&&(n-=360),n},e.repeat=function(t,e){return t-Math.floor(t/e)*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 t(){}return t.createOrthographicOffCenter=function(e,n,i,r,o,s,a){void 0===a&&(a=new t),a.m11=2/(n-e),a.m12=0,a.m13=0,a.m14=0,a.m21=0,a.m22=2/(r-i),a.m23=0,a.m24=0,a.m31=0,a.m32=0,a.m33=1/(o-s),a.m34=0,a.m41=(e+n)/(e-n),a.m42=(r+i)/(i-r),a.m43=o/(o-s),a.m44=1},t.multiply=function(e,n,i){void 0===i&&(i=new t);var r=e.m11*n.m11+e.m12*n.m21+e.m13*n.m31+e.m14*n.m41,o=e.m11*n.m12+e.m12*n.m22+e.m13*n.m32+e.m14*n.m42,s=e.m11*n.m13+e.m12*n.m23+e.m13*n.m33+e.m14*n.m43,a=e.m11*n.m14+e.m12*n.m24+e.m13*n.m34+e.m14*n.m44,c=e.m21*n.m11+e.m22*n.m21+e.m23*n.m31+e.m24*n.m41,h=e.m21*n.m12+e.m22*n.m22+e.m23*n.m32+e.m24*n.m42,u=e.m21*n.m13+e.m22*n.m23+e.m23*n.m33+e.m24*n.m43,l=e.m21*n.m14+e.m22*n.m24+e.m23*n.m34+e.m24*n.m44,p=e.m31*n.m11+e.m32*n.m21+e.m33*n.m31+e.m34*n.m41,f=e.m31*n.m12+e.m32*n.m22+e.m33*n.m32+e.m34*n.m42,d=e.m31*n.m13+e.m32*n.m23+e.m33*n.m33+e.m34*n.m43,m=e.m31*n.m14+e.m32*n.m24+e.m33*n.m34+e.m34*n.m44,y=e.m41*n.m11+e.m42*n.m21+e.m43*n.m31+e.m44*n.m41,g=e.m41*n.m12+e.m42*n.m22+e.m43*n.m32+e.m44*n.m42,v=e.m41*n.m13+e.m42*n.m23+e.m43*n.m33+e.m44*n.m43,_=e.m41*n.m14+e.m42*n.m24+e.m43*n.m34+e.m44*n.m44;i.m11=r,i.m12=o,i.m13=s,i.m14=a,i.m21=c,i.m22=h,i.m23=u,i.m24=l,i.m31=p,i.m32=f,i.m33=d,i.m34=m,i.m41=y,i.m42=g,i.m43=v,i.m44=_},t}();t.Matrix=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.toMatrix=function(e){var n=new t.Matrix;return n.m11=e.m11,n.m12=e.m12,n.m13=0,n.m14=0,n.m21=e.m21,n.m22=e.m22,n.m23=0,n.m24=0,n.m31=0,n.m32=0,n.m33=1,n.m34=0,n.m41=e.m31,n.m42=e.m32,n.m43=0,n.m44=1,n},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,h=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=h}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,h=(this.y+this.height-t.start.y)*a;if(c>h){var u=c;c=h,h=u}if(e.value=Math.max(c,e.value),n=Math.max(h,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,h=e.y+n.y;this._transformMat=t.Matrix2D.createTranslation(-c-i.x,-h-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,h),this._transformMat=this._transformMat.multiply(this._tempMat);var u=new t.Vector2(c,h),l=new t.Vector2(c+s,h),p=new t.Vector2(c,h+a),f=new t.Vector2(c+s,h+a);t.Vector2Ext.transformR(u,this._transformMat,u),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(u.x,f.x,l.x,p.x),m=Math.max(u.x,f.x,l.x,p.x),y=Math.min(u.y,f.y,l.y,p.y),g=Math.max(u.y,f.y,l.y,p.y);this.location=new t.Vector2(d,y),this.width=m-d,this.height=g-y}},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),h=a.x-c.x,u=a.y-c.y,l=i+o,p=r+s;if(Math.abs(h)>=l||Math.abs(u)>=p)return t.Vector2.zero;var f=h>0?l-h:-l-h,d=u>0?p-u:-p-u;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(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.lineToLine=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),h=(c.x*s.y-c.y*s.x)/a;if(h<0||h>1)return!1;var u=(c.x*o.y-c.y*o.x)/a;return!(u<0||u>1)},n.lineToLineIntersection=function(e,n,i,r,o){void 0===o&&(o=new t.Vector2),o.x=0,o.y=0;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 h=t.Vector2.subtract(i,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return!1;var l=(h.x*s.y-h.y*s.x)/c;if(l<0||l>1)return!1;var p=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y));return o.x=p.x,o.y=p.y,!0},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,h=void 0;return!(0==(a&e.top)||(c=new t.Vector2(n.x,n.y),h=new t.Vector2(n.x+n.width,n.y),!this.lineToLine(c,h,i,r)))||(!(0==(a&e.bottom)||(c=new t.Vector2(n.x,n.y+n.height),h=new t.Vector2(n.x+n.width,n.y+n.height),!this.lineToLine(c,h,i,r)))||(!(0==(a&e.left)||(c=new t.Vector2(n.x,n.y),h=new t.Vector2(n.x,n.y+n.height),!this.lineToLine(c,h,i,r)))||!(0==(a&e.right)||(c=new t.Vector2(n.x+n.width,n.y),h=new t.Vector2(n.x+n.width,n.y+n.height),!this.lineToLine(c,h,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(),this._colliderArray[0]=null},e.clear=function(){this._spatialHash.clear()},e.overlapCircle=function(t,n,i){return void 0===i&&(i=e.allLayers),this._colliderArray[0]=null,this._spatialHash.overlapCircle(t,n,this._colliderArray,i),this._colliderArray[0]},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.warn("传入了一个空的结果数组。不会返回任何结果")},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.boxcastBroadphaseExcludingSelfNonRect=function(t,e){void 0===e&&(e=this.allLayers);var n=t.bounds.clone();return this._spatialHash.aabbBroadphase(n,t,e)},e.boxcastBroadphaseExcludingSelfDelta=function(t,n,i,r){void 0===r&&(r=e.allLayers);var o=t.bounds.clone().getSweptBroadphaseBounds(n,i);return this._spatialHash.aabbBroadphase(o,t,r)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.linecast=function(t,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.overlapRectangle=function(t,n){return void 0===n&&(n=e.allLayers),this._colliderArray[0]=null,this._spatialHash.overlapRectangle(t,this._colliderArray,n),this._colliderArray[0]},e.overlapRectangleAll=function(t,n,i){return void 0===i&&(i=e.allLayers),0==n.length?(console.warn("传入了一个空的结果数组。不会返回任何结果"),0):this._spatialHash.overlapRectangle(t,n,i)},e.gravity=new t.Vector2(0,300),e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e._colliderArray=[null],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._overlapTestBox=new t.Box(0,0),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(e){for(var n=e.registeredPhysicsBounds.clone(),i=this.cellCoords(n.x,n.y),r=this.cellCoords(n.right,n.bottom),o=i.x;o<=r.x;o++)for(var s=i.y;s<=r.y;s++){var a=this.cellAtPosition(o,s);t.Insist.isNotNull(a,"从不存在碰撞器的单元格中移除碰撞器: ["+e+"]"),null!=a&&new linq.List(a).remove(e)}},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 h=0;h<c.length;h++){var u=c[h];u!=n&&t.Flags.isFlagSet(i,u.physicsLayer.value)&&(e.intersects(u.bounds)&&this._tempHashSet.add(u))}}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),h=Math.sign(o.direction.y);s.x==a.x&&(c=0),s.y==a.y&&(h=0);var u=c<0?0:c,l=h<0?0:h,p=(s.x+u)*this._cellSize,f=(s.y+l)*this._cellSize,d=0!=o.direction.x?(p-o.start.x)/o.direction.x:Number.MAX_VALUE,m=0!=o.direction.y?(f-o.start.y)/o.direction.y:Number.MAX_VALUE,y=0!=o.direction.x?this._cellSize/(o.direction.x*c):Number.MAX_VALUE,g=0!=o.direction.y?this._cellSize/(o.direction.y*h):Number.MAX_VALUE,v=this.cellAtPosition(s.x,s.y);if(v&&this._raycastParser.checkRayIntersection(s.x,s.y,v))return this._raycastParser.reset(),this._raycastParser.hitCounter;for(;s.x!=a.x||s.y!=a.y;)if(d<m?(s.x=Math.floor(t.MathHelper.approach(s.x,a.x,Math.abs(c))),d+=y):(s.y=Math.floor(t.MathHelper.approach(s.y,a.y,Math.abs(h))),m+=g),(v=this.cellAtPosition(s.x,s.y))&&this._raycastParser.checkRayIntersection(s.x,s.y,v))return this._raycastParser.reset(),this._raycastParser.hitCounter;return this._raycastParser.reset(),this._raycastParser.hitCounter},e.prototype.overlapRectangle=function(e,n,i){var r,o;this._overlapTestBox.updateBox(e.width,e.height),this._overlapTestBox.position=e.location;var s=0,a=this.aabbBroadphase(e,null,i);try{for(var c=__values(a),h=c.next();!h.done;h=c.next()){var u=h.value;if(u instanceof t.BoxCollider)n[s]=u,s++;else if(u instanceof t.CircleCollider)t.Collisions.rectToCircle(e,u.bounds.center,.5*u.bounds.width)&&(n[s]=u,s++);else{if(!(u instanceof t.PolygonCollider))throw new Error("overlapRectangle对这个类型没有实现!");u.shape.overlaps(this._overlapTestBox)&&(n[s]=u,s++)}if(s==n.length)return s}}catch(t){r={error:t}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}return s},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,h=this.aabbBroadphase(a,null,r);try{for(var u=__values(h),l=u.next();!l.done;l=u.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=u.return)&&s.call(u)}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<<16|e>>>0},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 h=t.ShapeCollisions.closestPointOnLine(e[a],e[c],n);if((s=t.Vector2.distanceSquared(n,h))<i.value){i.value=s,o=h;var u=t.Vector2.subtract(e[c],e[a]);r.x=-u.y,r.y=u.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.clone();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.multiply(s.direction,new t.Vector2(r.value))),h=0;c.x<n.bounds.left&&(a|=1),c.x>n.bounds.right&&(h|=1),c.y<n.bounds.top&&(a|=2),c.y>n.bounds.bottom&&(h|=2);var u=a+h;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),!0},e.corner=function(e,n){var i=new t.Vector2;return i.x=0==(1&n)?e.right:e.left,i.y=0==(1&n)?e.bottom:e.top,i},e.testCircleBox=function(e,n,i){i=n.bounds.getClosestPointOnRectangleToPoint(e.position);var r=t.Vector2.subtract(i,e.position);return t.Vector2.dot(r,r)<=e.radius*e.radius},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,h=new t.Vector2,u=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),m=new t.Ref(0),y=0;this.getInterval(r,e,p,d),this.getInterval(r,n,f,m);var g=t.Vector2.dot(u,r);if(p.value+=g,d.value+=g,(y=this.intervalDistance(p.value,d.value,f.value,m.value))>0&&(o=!1),!o)return!1;(y=Math.abs(y))<c&&(c=y,h=r,t.Vector2.dot(h,u)<0&&(h=new t.Vector2(-h.x,-h.y)))}return i.normal=h,i.minimumTranslationVector=new t.Vector2(-h.x*c,-h.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){void 0===i&&(i=new t.CollisionResult);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 h=Math.sqrt(s.value);r=t.Vector2.subtract(new t.Vector2(-1),t.Vector2.subtract(o,a)).multiply(new t.Vector2((e.radius-h)/h))}return i.minimumTranslationVector=r,i.point=t.Vector2.add(a,n.position),!0},e.circleToBox=function(e,n,i){void 0===i&&(i=new t.CollisionResult);var r=n.bounds.getClosestPointOnRectangleBorderToPoint(e.position,i.normal);if(n.containsPoint(e.position)){i.point=r.clone();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)))},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){void 0===i&&(i=new t.CollisionResult);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){void 0===r&&(r=new t.RaycastHit);for(var o=t.Vector2.zero,s=t.Vector2.zero,a=Number.MAX_VALUE,c=!1,h=i.points.length-1,u=0;u<i.points.length;h=u,u++){var l=t.Vector2.add(i.position,i.points[h]),p=t.Vector2.add(i.position,i.points[u]),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 m=t.Vector2.subtract(p,l);o=new t.Vector2(m.y,-m.x),a=d,s=f}}}if(c){o.normalize();var y=t.Vector2.distance(e,s);return r.setValuesNonCollider(a,y,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 h=t.Vector2.subtract(i,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return!1;var l=(h.x*s.y-h.y*s.x)/c;return!(l<0||l>1)&&(t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(u),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),h=t.Vector2.dot(a,a)-i.radius*i.radius;if(h>0&&c>0)return!1;var u=c*c-h;return!(u<0)&&(r.fraction=-c-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,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={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var n=function(){function n(){this._messageTable=new Map}return n.prototype.addObserver=function(n,i,r){var o=this._messageTable.get(n);o||(o=[],this._messageTable.set(n,o)),t.Insist.isFalse(-1!=o.findIndex(function(t){return t.func==i}),"您试图添加相同的观察者两次"),o.push(new e(i,r))},n.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)},n.prototype.emit=function(t){for(var e,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var r=this._messageTable.get(t);if(r)for(var o=r.length-1;o>=0;o--)(e=r[o].func).call.apply(e,__spread([r[o].context],n))},n}();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.computeHash=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=2166136261,i=0;i<t.length;i++)n=16777619*(n^t[i]);return n+=n<<13,n^=n>>7,n+=n<<3,n^=n>>17,n+=n<<5},t}();t.Hash=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=e}(es||(es={})),function(t){var e=function(){function e(){}return Object.defineProperty(e,"size",{get:function(){return new t.Vector2(this.width,this.height)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"center",{get:function(){return new t.Vector2(this.width/2,this.height/2)},enumerable:!0,configurable:!0}),e}();t.Screen=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.update=function(t){this.remainder+=t;var e=Math.trunc(this.remainder);return this.remainder-=e,e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelNumber=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,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]],h=n[s],u=n[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(c,h,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(n[l],c,h,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),i||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.length<t&&(this._triNext.reverse(),this._triNext.length=Math.max(2*this._triNext.length,t)),this._triPrev.length<t&&(this._triPrev.reverse(),this._triPrev.length=Math.max(2*this._triPrev.length,t));for(var e=0;e<t;e++)this._triPrev[e]=e-1,this._triNext[e]=e+1;this._triPrev[0]=t-1,this._triNext[t-1]=0},e}();t.Triangulator=e}(es||(es={})),function(t){var e,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}(es||(es={})),function(t){var e=function(){function e(){this.frameCount=0,this.stopwatch=new t.Stopwatch,this.markers=[],this.markerNameToIdMap=new Map,this.enabled=!0,this.updateCount=0,this.logs=new Array(2);for(var e=0;e<this.logs.length;++e)this.logs[e]=new r}return Object.defineProperty(e,"Instance",{get:function(){return this._instance||(this._instance=new e),this._instance},enumerable:!0,configurable:!0}),e.prototype.startFrame=function(){if(t.Core.Instance.debug){var n=this.updateCount++;if(!(this.enabled&&1<n&&n<e.maxSampleFrames)){this.prevLog=this.logs[1&this.frameCount++],this.curLog=this.logs[1&this.frameCount];for(var i=this.stopwatch.getTime(),r=0;r<this.prevLog.bars.length;++r){for(var o=this.prevLog.bars[r],s=this.curLog.bars[r],a=0;a<o.nestCount;++a){var c=o.markerNests[a];o.markers[c].endTime=i,s.markerNests[a]=a,s.markers[a].markerId=o.markers[c].markerId,s.markers[a].beginTime=0,s.markers[a].endTime=-1,s.markers[a].color=o.markers[c].color}for(c=0;c<o.markCount;++c){var h=o.markers[c].endTime-o.markers[c].beginTime,u=o.markers[c].markerId,l=this.markers[u];l.logs[r].color=o.markers[c].color,l.logs[r].initialized?(l.logs[r].min=Math.min(l.logs[r].min,h),l.logs[r].max=Math.min(l.logs[r].max,h),l.logs[r].avg+=h,l.logs[r].avg*=.5,l.logs[r].samples++>=e.logSnapDuration&&(l.logs[r].snapMin=l.logs[r].min,l.logs[r].snapMax=l.logs[r].max,l.logs[r].snapAvg=l.logs[r].avg,l.logs[r].samples=0)):(l.logs[r].min=h,l.logs[r].max=h,l.logs[r].avg=h,l.logs[r].initialized=!0)}s.markCount=o.nestCount,s.nestCount=o.nestCount}this.stopwatch.reset(),this.stopwatch.start()}}},e.prototype.beginMark=function(i,r,o){if(void 0===o&&(o=0),t.Core.Instance.debug){if(o<0||o>=e.maxBars)throw new Error("barIndex 越位");var s=this.curLog.bars[o];if(s.markCount>=e.maxSamples)throw new Error("超出样本数.\n 要么设置更大的数字为TimeRuler.MaxSmpale,要么降低样本数");if(s.nestCount>=e.maxNestCall)throw new Error("nestCount超出.\n 要么将大的设置为TimeRuler.MaxNestCall,要么将小的设置为NestCall");var a=this.markerNameToIdMap.get(i);null==a&&(a=this.markers.length,this.markerNameToIdMap.set(i,a),this.markers.push(new n(i))),s.markerNests[s.nestCount++]=s.markCount,s.markers[s.markCount].markerId=a,s.markers[s.markCount].color=r,s.markers[s.markCount].beginTime=this.stopwatch.getTime(),s.markers[s.markCount].endTime=-1,s.markCount++}},e.prototype.endMark=function(n,i){if(void 0===i&&(i=0),t.Core.Instance.debug){if(i<0||i>=e.maxBars)throw new Error("barIndex 越位");var r=this.curLog.bars[i];if(r.nestCount<=0)throw new Error("在调用结束标记方法之前调用beginMark方法");var o=this.markerNameToIdMap.get(n);if(null==o)throw new Error("标记"+n+"没有注册。请确认您指定的名称与BeginMark方法使用的名称相同");var s=r.markerNests[--r.nestCount];if(r.markers[s].markerId!=o)throw new Error("beginMark/endMark方法的调用顺序不正确. beginMark(A), beginMark(B), endMark(B), endMark(A).但你不能像这样叫它 beginMark(A), beginMark(B), endMark(A), endMark(B)");r.markers[s].endTime=this.stopwatch.getTime()}},e.prototype.getAverageTime=function(t,n){if(t<0||t>=e.maxBars)throw new Error("barIndex 越位");var i=0,r=this.markerNameToIdMap.get(n);return null!=r&&(i=this.markers[r].logs[t].avg),i},e.prototype.resetLog=function(){var e,n;if(t.Core.Instance.debug)try{for(var i=__values(this.markers),r=i.next();!r.done;r=i.next())for(var o=r.value,s=0;s<o.logs.length;++s)o.logs[s].initialized=!1,o.logs[s].snapMin=0,o.logs[s].snapMax=0,o.logs[s].snapAvg=0,o.logs[s].min=0,o.logs[s].max=0,o.logs[s].avg=0,o.logs[s].samples=0}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e.maxBars=8,e.maxSamples=256,e.maxNestCall=32,e.maxSampleFrames=4,e.logSnapDuration=120,e}();t.TimeRuler=e;var n=function(){return function(t){this.logs=new Array(e.maxBars),this.name=t;for(var n=0;n<e.maxBars;++n)this.logs[n]=new i}}(),i=function(){return function(){this.snapMin=0,this.snapMax=0,this.snapAvg=0,this.min=0,this.max=0,this.avg=0,this.samples=0,this.color=0,this.initialized=!1}}(),r=function(){return function(){this.bars=new Array(e.maxBars);for(var t=0;t<e.maxBars;++t)this.bars[t]=new o}}(),o=function(){return function(){this.markers=new Array(e.maxSamples),this.markCount=0,this.markerNests=new Array(e.maxNestCall),this.nestCount=0,this.markerNests.fill(0);for(var t=0;t<e.maxSamples;++t)this.markers[t]=new s}}(),s=function(){return function(){this.markerId=0,this.beginTime=0,this.endTime=0,this.color=0}}()}(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 h=t.NumberExtension.toNumber(this._buckets[a])-1;if(-1==h)this._valuesInfo[this._freeValueCellIndex]=new n(i,s);else{var u=h;do{if(this._valuesInfo[u].hashcode==s&&this._valuesInfo[u].key==i)return this._values[u]=r,o.value=u,!1;u=this._valuesInfo[u].previous}while(-1!=u);this._collisions++,this._valuesInfo[this._freeValueCellIndex]=new n(i,s,h),this._valuesInfo[h].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,h=this._valuesInfo[this._freeValueCellIndex].previous;-1!=c&&(this._valuesInfo[c].previous=o),-1!=h&&(this._valuesInfo[h].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(){return function(t,e){this.element=t,this.next=e}}();function n(t,e){return t===e}t.Node=e,t.defaultEquals=n;var i=function(){function t(t){void 0===t&&(t=n),this.count=0,this.next=void 0,this.equalsFn=t,this.head=null}return t.prototype.push=function(t){var n,i=new e(t);if(null==this.head)this.head=i;else{for(n=this.head;null!=n.next;)n=n.next;n.next=i}this.count++},t.prototype.removeAt=function(t){if(t>=0&&t<this.count){var e=this.head;if(0===t)this.head=e.next;else{var n=this.getElementAt(t-1);e=n.next,n.next=e.next}return this.count--,e.element}},t.prototype.getElementAt=function(t){if(t>=0&&t<=this.count){for(var e=this.head,n=0;n<t&&null!=e;n++)e=e.next;return e}},t.prototype.insert=function(t,n){if(n>=0&&n<=this.count){var i=new e(t);if(0===n)i.next=this.head,this.head=i;else{var r=this.getElementAt(n-1);i.next=r.next,r.next=i}return this.count++,!0}return!1},t.prototype.indexOf=function(t){for(var e=this.head,n=0;n<this.count&&null!=e;n++){if(this.equalsFn(t,e.element))return n;e=e.next}return-1},t.prototype.remove=function(t){this.removeAt(this.indexOf(t))},t.prototype.clear=function(){this.head=void 0,this.count=0},t.prototype.size=function(){return this.count},t.prototype.isEmpty=function(){return 0===this.size()},t.prototype.getHead=function(){return this.head},t.prototype.toString=function(){if(null==this.head)return"";for(var t=""+this.head.element,e=this.head.next,n=1;n<this.size()&&null!=e;n++)t=t+", "+e.element,e=e.next;return t},t}();t.LinkedList=i}(es||(es={})),function(t){var e=function(){function t(){}return t.warmCache=function(t){if((t-=this._objectQueue.length)>0)for(var e=0;e<t;e++)this._objectQueue.unshift([])},t.trimCache=function(t){for(;t>this._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.first=t,this.second=e}return e.prototype.clear=function(){this.first=this.second=null},e.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},e.prototype.getHashCode=function(){return 37*t.EqualityComparer.default().getHashCode(this.first)+t.EqualityComparer.default().getHashCode(this.second)},e}();t.Pair=e}(es||(es={})),function(t){var e=function(){function e(){}return e.warmCache=function(t,e){if((e-=this._objectQueue.length)>0)for(var 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={})),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.waitForSeconds=function(t){return n.waiter.wait(t)},t}();t.Coroutine=e;var n=function(){function t(){this.waitTime=0}return t.prototype.wait=function(e){return t.waiter.waitTime=e,t.waiter},t.waiter=new t,t}();t.WaitForSeconds=n}(es||(es={})),function(t){var e=function(){function t(){this.waitTimer=0,this.useUnscaledDeltaTime=!1}return t.prototype.stop=function(){this.isDone=!0},t.prototype.setUseUnscaledDeltaTime=function(t){return this.useUnscaledDeltaTime=t,this},t.prototype.prepareForUse=function(){this.isDone=!1},t.prototype.reset=function(){this.isDone=!0,this.waitTimer=0,this.waitForCoroutine=null,this.enumerator=null,this.useUnscaledDeltaTime=!1},t}();t.CoroutineImpl=e;var n=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t._unblockedCoroutines=[],t._shouldRunNextFrame=[],t}return __extends(i,n),i.prototype.startCoroutine=function(n){var i=t.Pool.obtain(e);return i.prepareForUse(),i.enumerator=n,this.tickCoroutine(i)?(this._isInUpdate?this._shouldRunNextFrame.push(i):this._unblockedCoroutines.push(i),i):null},i.prototype.update=function(){this._isInUpdate=!0;for(var e=0;e<this._unblockedCoroutines.length;e++){var n=this._unblockedCoroutines[e];if(n.isDone)t.Pool.free(n);else{if(null!=n.waitForCoroutine){if(!n.waitForCoroutine.isDone){this._shouldRunNextFrame.push(n);continue}n.waitForCoroutine=null}n.waitTimer>0?(n.waitTimer-=n.useUnscaledDeltaTime?t.Time.unscaledDeltaTime:t.Time.deltaTime,this._shouldRunNextFrame.push(n)):this.tickCoroutine(n)&&this._shouldRunNextFrame.push(n)}}var i=new linq.List(this._unblockedCoroutines);i.clear(),i.addRange(this._shouldRunNextFrame),this._shouldRunNextFrame.length=0,this._isInUpdate=!1},i.prototype.tickCoroutine=function(n){var i=n.enumerator.next();return i.done||n.isDone?(t.Pool.free(n),!1):null==i.value||(i.value instanceof t.WaitForSeconds?(n.waitTimer=i.value.waitTime,!0):"number"==typeof i.value?(n.waitTimer=i.value,!0):"string"==typeof i.value?"break"!=i.value||(t.Pool.free(n),!1):!(i.value instanceof e)||(n.waitForCoroutine=i.value,!0))},i}(t.GlobalManager);t.CoroutineManager=n}(es||(es={})),function(t){var e=function(){function e(t,e,n){void 0===n&&(n=!0),this.binWidth=0,this.binHeight=0,this.usedRectangles=[],this.freeRectangles=[],this.init(t,e,n)}return e.prototype.init=function(e,n,i){void 0===i&&(i=!0),this.binWidth=e,this.binHeight=n,this.allowRotations=i;var r=new t.Rectangle;r.x=0,r.y=0,r.width=e,r.height=n,this.usedRectangles.length=0,this.freeRectangles.length=0,this.freeRectangles.push(r)},e.prototype.insert=function(e,n){var i=new t.Rectangle,r=new t.Ref(0),o=new t.Ref(0);if(0==(i=this.findPositionForNewNodeBestAreaFit(e,n,r,o)).height)return i;for(var s=this.freeRectangles.length,a=0;a<s;++a)this.splitFreeNode(this.freeRectangles[a],i)&&(new linq.List(this.freeRectangles).removeAt(a),--a,--s);return this.pruneFreeList(),this.usedRectangles.push(i),i},e.prototype.findPositionForNewNodeBestAreaFit=function(e,n,i,r){var o=new t.Rectangle;i.value=Number.MAX_VALUE;for(var s=0;s<this.freeRectangles.length;++s){var a=this.freeRectangles[s].width*this.freeRectangles[s].height-e*n;if(this.freeRectangles[s].width>=e&&this.freeRectangles[s].height>=n){var c=Math.abs(this.freeRectangles[s].width-e),h=Math.abs(this.freeRectangles[s].height-n),u=Math.min(c,h);(a<i.value||a==i.value&&u<r.value)&&(o.x=this.freeRectangles[s].x,o.y=this.freeRectangles[s].y,o.width=e,o.height=n,r.value=u,i.value=a)}if(this.allowRotations&&this.freeRectangles[s].width>=n&&this.freeRectangles[s].height>=e){c=Math.abs(this.freeRectangles[s].width-n),h=Math.abs(this.freeRectangles[s].height-e),u=Math.min(c,h);(a<i.value||a==i.value&&u<r.value)&&(o.x=this.freeRectangles[s].x,o.y=this.freeRectangles[s].y,o.width=n,o.height=e,r.value=u,i.value=a)}return o}},e.prototype.splitFreeNode=function(t,e){if(e.x>=t.x+t.width||e.x+e.width<=t.x||e.y>=t.y+t.height||e.y+e.height<=t.y)return!1;if(e.x<t.x+t.width&&e.x+e.width>t.x){if(e.y>t.y&&e.y<t.y+t.height)(n=t).height=e.y-n.y,this.freeRectangles.push(n);if(e.y+e.height<t.y+t.height)(n=t).y=e.y+e.height,n.height=t.y+t.height-(e.y+e.height),this.freeRectangles.push(n)}if(e.y<t.y+t.height&&e.y+e.height>t.y){var n;if(e.x>t.x&&e.x<t.x+t.width)(n=t).width=e.x-n.x,this.freeRectangles.push(n);if(e.x+e.width<t.x+t.width)(n=t).x=e.x+e.width,n.width=t.x+t.width-(e.x+e.width),this.freeRectangles.push(n)}return!0},e.prototype.pruneFreeList=function(){for(var t=0;t<this.freeRectangles.length;++t)for(var e=t+1;e<this.freeRectangles.length;++e){if(this.isContainedIn(this.freeRectangles[t],this.freeRectangles[e])){new linq.List(this.freeRectangles).removeAt(t),--t;break}this.isContainedIn(this.freeRectangles[e],this.freeRectangles[t])&&(new linq.List(this.freeRectangles).removeAt(e),--e)}},e.prototype.isContainedIn=function(t,e){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height},e}();t.MaxRectsBinPack=e}(es||(es={}));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=[],h=0;h<t.length;)r=(e=t.charCodeAt(h++))>>2,o=(3&e)<<4|(n=t.charCodeAt(h++))>>4,s=(15&n)<<2|(i=t.charCodeAt(h++))>>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(){}return e.oppositeEdge=function(e){switch(e){case t.Edge.bottom:return t.Edge.top;case t.Edge.top:return t.Edge.bottom;case t.Edge.left:return t.Edge.right;case t.Edge.right:return t.Edge.left}},e.isHorizontal=function(e){return e==t.Edge.right||e==t.Edge.left},e.isVertical=function(e){return e==t.Edge.top||e==t.Edge.bottom},e}();t.EdgeExt=e}(es||(es={})),function(t){var e=function(){function t(){}return t.toNumber=function(t){return null==t?0:Number(t)},t}();t.NumberExtension=e}(es||(es={}));var linq,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.boundsFromPolygonVector=function(e){for(var n=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,s=0;s<e.length;s++){var a=e[s];a.x<n&&(n=a.x),a.x>r&&(r=a.x),a.y<i&&(i=a.y),a.y>o&&(o=a.y)}return this.fromMinMaxVector(new t.Vector2(n,i),new t.Vector2(r,o))},e.fromMinMaxVector=function(e,n){return new t.Rectangle(e.x,e.y,n.x-e.x,n.y-e.y)},e.getSweptBroadphaseBounds=function(e,n,i){var r=t.Rectangle.empty;return r.x=n>0?e.x:e.x+n,r.y=i>0?e.y:e.y+i,r.width=n>0?n+e.width:e.width-n,r.height=i>0?i+e.height:e.height-i,r},e.prototype.collisionCheck=function(t,e,n,i){n.value=i.value=0;var r=e.x-(t.x+t.width),o=e.x+e.width-t.x,s=e.y-(t.y+t.height),a=e.y+e.height-t.y;return!(r>0||o<0||s>0||a<0)&&(n.value=Math.abs(r)<o?r:o,i.value=Math.abs(s)<a?s:a,Math.abs(n.value)<Math.abs(i.value)?i.value=0:n.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),h=a.x-c.x,u=a.y-c.y,l=i+o,p=r+s;if(Math.abs(h)>=l||Math.abs(u)>=p)return t.Vector2.zero;var f=h>0?l-h:-l-h,d=u>0?p-u:-p-u;return new t.Vector2(f,d)},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){function t(){}return t.premultiplyAlpha=function(t){for(var e=t[0],n=0;n<t.length;n+=4)if(255!=e[n+3]){var i=e[n+3]/255;e[n+0]=e[n+0]*i,e[n+1]=e[n+1]*i,e[n+2]=e[n+2]*i}},t}();t.TextureUtils=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.perpendicularFlip=function(e){return new t.Vector2(-e.y,e.x)},e.angle=function(e,n){return this.normalize(e),this.normalize(n),Math.acos(t.MathHelper.clamp(t.Vector2.dot(e,n),-1,1))*t.MathHelper.Rad2Deg},e.getRayIntersection=function(e,n,i,r,o){void 0===o&&(o=new t.Vector2);var s=n.y-e.y,a=n.x-e.x,c=r.y-i.y,h=r.x-i.x;if(s*h==c*a)return o.x=Number.NaN,o.y=Number.NaN,!1;var u=((i.y-e.y)*a*h+s*h*e.x-c*a*i.x)/(s*h-c*a),l=e.y+s/a*(u-e.x);return o.x=u,o.y=l,!0},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(e,n,i){void 0===i&&(i=new t.Vector2);var r=e.x*n.m11+e.y*n.m21+n.m31,o=e.x*n.m12+e.y*n.m22+n.m32;i.x=r,i.y=o},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={})),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(){return function(){this.position=t.Vector2.zero,this.begin=!1,this.segment=null,this.angle=0}}();t.EndPoint=e;var n=function(){function t(){}return t.prototype.compare=function(t,e){return t.angle>e.angle?1:t.angle<e.angle?-1:!t.begin&&e.begin?1:t.begin&&!e.begin?-1:0},t}();t.EndPointComparer=n}(es||(es={})),function(t){var e=function(){return function(){this.p1=null,this.p2=null}}();t.Segment=e}(es||(es={})),function(t){var e=function(){function e(e,n){this.lineCountForCircleApproximation=10,this._radius=0,this._origin=t.Vector2.zero,this._isSpotLight=!1,this._spotStartAngle=0,this._spotEndAngle=0,this._endPoints=[],this._segments=[],this._origin=e,this._radius=n,this._radialComparer=new t.EndPointComparer}return e.prototype.addColliderOccluder=function(e){if(e instanceof t.BoxCollider&&0==e.rotation)this.addSquareOccluder(e.bounds);else if(e instanceof t.PolygonCollider)for(var n=e.shape,i=0;i<n.points.length;i++){var r=i-1;0==i&&(r+=n.points.length),this.addLineOccluder(t.Vector2.add(n.points[r],n.position),t.Vector2.add(n.points[i],n.position))}else e instanceof t.CircleCollider&&this.addCircleOccluder(e.absolutePosition,e.radius)},e.prototype.addCircleOccluder=function(e,n){for(var i=t.Vector2.subtract(e,this._origin),r=Math.atan2(i.y,i.x),o=Math.PI/this.lineCountForCircleApproximation,s=r+t.MathHelper.PiOver2,a=t.MathHelper.angleToVector(s,n).add(e),c=1;c<this.lineCountForCircleApproximation;c++){var h=t.MathHelper.angleToVector(s+c*o,n).add(e);this.addLineOccluder(a,h),a=h}},e.prototype.addLineOccluder=function(t,e){this.addSegment(t,e)},e.prototype.addSquareOccluder=function(e){var n=new t.Vector2(e.right,e.top),i=new t.Vector2(e.left,e.bottom),r=new t.Vector2(e.right,e.bottom);this.addSegment(e.location,n),this.addSegment(n,r),this.addSegment(r,i),this.addSegment(i,e.location)},e.prototype.addSegment=function(e,n){var i=new t.Segment,r=new t.EndPoint,o=new t.EndPoint;r.position=e,r.segment=i,o.position=n,o.segment=i,i.p1=r,i.p2=o,this._segments.push(i),this._endPoints.push(r),this._endPoints.push(o)},e.prototype.clearOccluders=function(){this._segments.length=0,this._endPoints.length=0},e.prototype.begin=function(t,e){this._origin=t,this._radius=e,this._isSpotLight=!1},e.prototype.end=function(){var n,i,r=t.ListPool.obtain();this.updateSegments(),this._endPoints.sort(this._radialComparer.compare);for(var o=0,s=0;s<2;s++)try{for(var a=__values(this._endPoints),c=a.next();!c.done;c=a.next()){var h=c.value,u=0==e._openSegments.size()?null:e._openSegments.getHead().element;if(h.begin){for(var l=e._openSegments.getHead();null!=l&&this.isSegmentInFrontOf(h.segment,l.element,this._origin);)l=l.next;null==l?e._openSegments.push(h.segment):e._openSegments.insert(h.segment,e._openSegments.indexOf(l.element))}else e._openSegments.remove(h.segment);var p=null;0!=e._openSegments.size()&&(p=e._openSegments.getHead().element),u!=p&&(1==s&&(!this._isSpotLight||e.between(o,this._spotStartAngle,this._spotEndAngle)&&e.between(h.angle,this._spotStartAngle,this._spotEndAngle))&&this.addTriangle(r,o,h.angle,u),o=h.angle)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return e._openSegments.clear(),this.clearOccluders(),r},e.prototype.addTriangle=function(n,i,r,o){var s=this._origin.clone(),a=new t.Vector2(this._origin.x+Math.cos(i),this._origin.y+Math.sin(i)),c=t.Vector2.zero,h=t.Vector2.zero;null!=o?(c.x=o.p1.position.x,c.y=o.p1.position.y,h.x=o.p2.position.x,h.y=o.p2.position.y):(c.x=this._origin.x+Math.cos(i)*this._radius*2,c.y=this._origin.y+Math.sin(i)*this._radius*2,h.x=this._origin.x+Math.cos(r)*this._radius*2,h.y=this._origin.y+Math.sin(r)*this._radius*2);var u=e.lineLineIntersection(c,h,s,a);a.x=this._origin.x+Math.cos(r),a.y=this._origin.y+Math.sin(r);var l=e.lineLineIntersection(c,h,s,a);n.push(u),n.push(l)},e.lineLineIntersection=function(e,n,i,r){var o=((r.x-i.x)*(e.y-i.y)-(r.y-i.y)*(e.x-i.x))/((r.y-i.y)*(n.x-e.x)-(r.x-i.x)*(n.y-e.y));return new t.Vector2(e.x+o*(n.x-e.x),e.y+o*(n.y-e.y))},e.between=function(t,e,n){return t=(360+t%360)%360,(e=(36e5+e)%360)<(n=(36e5+n)%360)?e<=t&&t<=n:e<=t||t<=n},e.prototype.loadRectangleBoundaries=function(){this.addSegment(new t.Vector2(this._origin.x-this._radius,this._origin.y-this._radius),new t.Vector2(this._origin.x+this._radius,this._origin.y-this._radius)),this.addSegment(new t.Vector2(this._origin.x-this._radius,this._origin.y+this._radius),new t.Vector2(this._origin.x+this._radius,this._origin.y+this._radius)),this.addSegment(new t.Vector2(this._origin.x-this._radius,this._origin.y-this._radius),new t.Vector2(this._origin.x-this._radius,this._origin.y+this._radius)),this.addSegment(new t.Vector2(this._origin.x+this._radius,this._origin.y-this._radius),new t.Vector2(this._origin.x+this._radius,this._origin.y+this._radius))},e.prototype.isSegmentInFrontOf=function(t,n,i){var r=e.isLeftOf(t.p2.position,t.p1.position,e.interpolate(n.p1.position,n.p2.position,.01)),o=e.isLeftOf(t.p2.position,t.p1.position,e.interpolate(n.p2.position,n.p1.position,.01)),s=e.isLeftOf(t.p2.position,t.p1.position,i),a=e.isLeftOf(n.p2.position,n.p1.position,e.interpolate(t.p1.position,t.p2.position,.01)),c=e.isLeftOf(n.p2.position,n.p1.position,e.interpolate(t.p2.position,t.p1.position,.01)),h=e.isLeftOf(n.p2.position,n.p1.position,i);return a==c&&c!=h||r==o&&o==s},e.interpolate=function(e,n,i){return new t.Vector2(e.x*(1-i)+n.x*i,e.y*(1-i)+n.y*i)},e.isLeftOf=function(t,e,n){return(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x)<0},e.prototype.updateSegments=function(){var t,e;try{for(var n=__values(this._segments),i=n.next();!i.done;i=n.next()){var r=i.value;r.p1.angle=Math.atan2(r.p1.position.y-this._origin.y,r.p1.position.x-this._origin.x),r.p2.angle=Math.atan2(r.p2.position.y-this._origin.y,r.p2.position.x-this._origin.x);var o=r.p2.angle-r.p1.angle;o<=-Math.PI&&(o+=2*Math.PI),o>Math.PI&&(o-=2*Math.PI),r.p1.begin=o>0,r.p2.begin=!r.p1.begin}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}this._isSpotLight&&(this._spotStartAngle=this._segments[0].p2.angle,this._spotEndAngle=this._segments[1].p2.angle)},e._cornerCache=[],e._openSegments=new t.LinkedList,e}();t.VisibilityComputer=e}(es||(es={})),function(t){var e=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}return e.prototype.getContext=function(){return this.context},e.prototype.reset=function(){this._elapsedTime=0},e.prototype.stop=function(){this._isDone=!0},e.prototype.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,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={})); \ No newline at end of file +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 e(n,i){void 0===n&&(n=!0),void 0===i&&(i=!0),this._globalManagers=[],this._coroutineManager=new t.CoroutineManager,this._timerManager=new t.TimerManager,this._frameCounterElapsedTime=0,this._frameCounter=0,this._totalMemory=0,e._instance=this,e.emitter=new t.Emitter,e.emitter.addObserver(t.CoreEvents.frameUpdated,this.update,this),e.registerGlobalManager(this._coroutineManager),e.registerGlobalManager(this._timerManager),e.entitySystemsEnabled=i,this.debug=n,this.initialize()}return Object.defineProperty(e,"Instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),Object.defineProperty(e,"scene",{get:function(){return this._instance?this._instance._scene:null},set:function(e){t.Insist.isNotNull(e,"场景不能为空"),null==this._instance._scene?(this._instance._scene=e,this._instance.onSceneChanged(),this._instance._scene.begin()):this._instance._nextScene=e},enumerable:!0,configurable:!0}),e.create=function(e){return void 0===e&&(e=!0),null==this._instance&&(this._instance=new t.Core(e)),this._instance},e.registerGlobalManager=function(t){this._instance._globalManagers.push(t),t.enabled=!0},e.unregisterGlobalManager=function(t){new linq.List(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[e]instanceof t)return this._instance._globalManagers[e];return null},e.startCoroutine=function(t){return this._instance._coroutineManager.startCoroutine(t)},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.startDebugUpdate=function(){this.debug&&(t.TimeRuler.Instance.startFrame(),t.TimeRuler.Instance.beginMark("update",65280))},e.prototype.endDebugUpdate=function(){this.debug&&t.TimeRuler.Instance.endMark("update")},e.prototype.startDebugDraw=function(){if(this.debug&&(this._frameCounter++,this._frameCounterElapsedTime+=t.Time.deltaTime,this._frameCounterElapsedTime>=1)){var e=window.performance.memory;null!=e&&(this._totalMemory=Number((e.totalJSHeapSize/1048576).toFixed(2))),this._titleMemory&&this._titleMemory(this._totalMemory,this._frameCounter),this._frameCounter=0,this._frameCounterElapsedTime-=1}},e.prototype.onSceneChanged=function(){t.Time.sceneChanged()},e.prototype.initialize=function(){},e.prototype.update=function(e){return void 0===e&&(e=-1),__awaiter(this,void 0,void 0,function(){var n;return __generator(this,function(i){if(this.startDebugUpdate(),t.Time.update(e),null!=this._scene){for(n=this._globalManagers.length-1;n>=0;n--)this._globalManagers[n].enabled&&this._globalManagers[n].update();this._scene.update(),null!=this._nextScene&&(this._scene.end(),this._scene=this._nextScene,this._nextScene=null,this.onSceneChanged(),this._scene.begin())}return this.endDebugUpdate(),this.startDebugDraw(),[2]})})},e.pauseOnFocusLost=!0,e.debugRenderEndabled=!1,e}();t.Core=e}(es||(es={})),function(t){var e;!function(t){t[t.error=0]="error",t[t.warn=1]="warn",t[t.log=2]="log",t[t.info=3]="info",t[t.trace=4]="trace"}(e=t.LogType||(t.LogType={}));var n=function(){function t(){}return t.warnIf=function(t,n){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];t&&this.log(e.warn,n,i)},t.warn=function(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.log(e.warn,t,n)},t.error=function(t){for(var n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];this.log(e.error,t,n)},t.log=function(t,n){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];switch(t){case e.error:console.error(t+": "+StringUtils.format(n,i));break;case e.warn:console.warn(t+": "+StringUtils.format(n,i));break;case e.log:console.log(t+": "+StringUtils.format(n,i));break;case e.info:console.info(t+": "+StringUtils.format(n,i));break;case e.trace:console.trace(t+": "+StringUtils.format(n,i));break;default:throw new Error("argument out of range")}},t}();t.Debug=n}(es||(es={})),function(t){var e=function(){function t(){}return t.debugText=16777215,t.colliderBounds=5033164.5,t.colliderEdge=9109504,t.colliderPosition=16776960,t.colliderCenter=16711680,t.renderableBounds=16776960,t.renderableCenter=10040012,t.verletParticle=14431326,t.verletConstraintEdge=4406838,t}();t.DebugDefault=e}(es||(es={})),function(t){var e=function(){function t(){}return t.fail=function(t){void 0===t&&(t=null);for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];null==t?console.assert(!1):console.assert(!1,StringUtils.format(t,e))},t.isTrue=function(t,e){void 0===e&&(e=null);for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];t||(null==e?this.fail():this.fail(e,n))},t.isFalse=function(t,e){void 0===e&&(e=null);for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];null==e?this.isTrue(!t):this.isTrue(!t,e,n)},t.isNull=function(t,e){void 0===e&&(e=null);for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];null==e?this.isTrue(null==t):this.isTrue(null==t,e,n)},t.isNotNull=function(t,e){void 0===e&&(e=null);for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];null==e?this.isTrue(null!=t):this.isTrue(null!=t,e,n)},t.areEqual=function(t,e,n){for(var i=[],r=3;r<arguments.length;r++)i[r-3]=arguments[r];t!=e&&this.fail(n,i)},t.areNotEqual=function(t,e,n){for(var i=[],r=3;r<arguments.length;r++)i[r-3]=arguments[r];t==e&&this.fail(n,i)},t}();t.Insist=e}(es||(es={})),function(t){var e=function(){function t(){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){!function(t){t[t.sceneChanged=0]="sceneChanged",t[t.frameUpdated=1]="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++,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.setParent=function(e){return e instanceof t.Transform?this.transform.setParent(e):e instanceof n&&this.transform.setParent(e.transform),this},n.prototype.setPosition=function(t,e){return this.transform.setPosition(t,e),this},n.prototype.setLocalPosition=function(t){return this.transform.setLocalPosition(t),this},n.prototype.setRotation=function(t){return this.transform.setRotation(t),this},n.prototype.setRotationDegrees=function(t){return this.transform.setRotationDegrees(t),this},n.prototype.setLocalRotation=function(t){return this.transform.setLocalRotation(t),this},n.prototype.setLocalRotationDegrees=function(t){return this.transform.setLocalRotationDegrees(t),this},n.prototype.setScale=function(e){return e instanceof t.Vector2?this.transform.setScale(e):this.transform.setScale(new t.Vector2(e)),this},n.prototype.setLocalScale=function(e){return e instanceof t.Vector2?this.transform.setLocalScale(e):this.transform.setLocalScale(new t.Vector2(e)),this},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.createComponent=function(t){var e=new t;return this.addComponent(e),e},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(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.angleBetween=function(n,i){var r=e.subtract(n,this),o=e.subtract(i,this);return t.Vector2Ext.angle(r,o)},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){!function(t){t[t.none=0]="none",t[t.bestFit=1]="bestFit"}(t.SceneResolutionPolicy||(t.SceneResolutionPolicy={}));var e=function(){function e(){this._sceneComponents=[],this.entities=new t.EntityList(this),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(),null!=this.entityProcessors&&this.entityProcessors.begin(),this._didSceneBegin=!0,this.onStart()},e.prototype.end=function(){this._didSceneBegin=!1,this.entities.removeAllEntities();for(var e=0;e<this._sceneComponents.length;e++)this._sceneComponents[e].onRemovedFromScene();this._sceneComponents.length=0,t.Physics.clear(),this.entityProcessors&&this.entityProcessors.end(),this.unload()},e.prototype.update=function(){this.entities.updateLists();for(var t=this._sceneComponents.length-1;t>=0;t--)this._sceneComponents[t].enabled&&this._sceneComponents[t].update();null!=this.entityProcessors&&this.entityProcessors.update(),this.entities.update(),null!=this.entityProcessors&&this.entityProcessors.lateUpdate()},e.prototype.addSceneComponent=function(t){return t.scene=this,t.onEnabled(),this._sceneComponents.push(t),this._sceneComponents.sort(t.compare),t},e.prototype.getSceneComponent=function(t){for(var e=0;e<this._sceneComponents.length;e++){var n=this._sceneComponents[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(e){var n=new linq.List(this._sceneComponents);t.Insist.isTrue(n.contains(e),"SceneComponent"+e+"不在SceneComponents列表中!"),n.remove(e),e.onRemovedFromScene()},e.prototype.createEntity=function(e){var n=new t.Entity(e);return this.addEntity(n)},e.prototype.addEntity=function(e){t.Insist.isFalse(new linq.List(this.entities.buffer).contains(e),"您试图将同一实体添加到场景两次: "+e),this.entities.add(e),e.scene=this;for(var n=0;n<e.transform.childCount;n++)this.addEntity(e.transform.getChild(n).entity);return e},e.prototype.destroyAllEntities=function(){for(var t=0;t<this.entities.count;t++)this.entities.buffer[t].destroy()},e.prototype.findEntity=function(t){return this.entities.findEntity(t)},e.prototype.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=4]="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=t.Vector2Ext.round(this._position)},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(){}return t.prototype.compare=function(t,e){return t.updateOrder-e.updateOrder},t}();t.IUpdatableComparer=e,t.isIUpdatable=function(t){return void 0!==t.update}}(es||(es={})),function(t){var e=function(){function t(){this.updateOrder=0,this._enabled=!0}return Object.defineProperty(t.prototype,"enabled",{get:function(){return this._enabled},set:function(t){this.setEnabled(t)},enumerable:!0,configurable:!0}),t.prototype.onEnabled=function(){},t.prototype.onDisabled=function(){},t.prototype.onRemovedFromScene=function(){},t.prototype.update=function(){},t.prototype.setEnabled=function(t){return this._enabled!=t&&(this._enabled=t,this._enabled?this.onEnabled():this.onDisabled()),this},t.prototype.setUpdateOrder=function(t){return this.updateOrder!=t&&(this.updateOrder=t),this},t.prototype.compare=function(t){return this.updateOrder-t.updateOrder},t}();t.SceneComponent=e}(es||(es={})),function(t){var e=function(e){function n(){var n=e.call(this)||this;return n.shouldUseGravity=!0,n.velocity=new t.Vector2,n._mass=10,n._elasticity=.5,n._friction=.5,n._glue=.01,n._inverseMass=0,n._inverseMass=1/n._mass,n}return __extends(n,e),Object.defineProperty(n.prototype,"mass",{get:function(){return this._mass},set:function(t){this.setMass(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"elasticity",{get:function(){return this._elasticity},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"elasticiy",{set:function(t){this.setElasticity(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"friction",{get:function(){return this._friction},set:function(t){this.setFriction(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"glue",{get:function(){return this._glue},set:function(t){this.setGlue(t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isImmovable",{get:function(){return this._mass<1e-4},enumerable:!0,configurable:!0}),n.prototype.setMass=function(e){return this._mass=t.MathHelper.clamp(e,0,Number.MAX_VALUE),this._mass>1e-4?this._inverseMass=1/this._mass:this._inverseMass=0,this},n.prototype.setElasticity=function(e){return this._elasticity=t.MathHelper.clamp01(e),this},n.prototype.setFriction=function(e){return this._friction=t.MathHelper.clamp01(e),this},n.prototype.setGlue=function(e){return this._glue=t.MathHelper.clamp(e,0,10),this},n.prototype.addImpulse=function(e){this.isImmovable||(this.velocity=t.Vector2.add(this.velocity,t.Vector2.multiply(e,new t.Vector2(1e5)).multiply(new t.Vector2(this._inverseMass*t.Time.deltaTime))))},n.prototype.onAddedToEntity=function(){this._collider=this.entity.getComponent(t.Collider),t.Debug.warnIf(null==this._collider,"ArcadeRigidbody 没有 Collider。ArcadeRigidbody需要一个Collider!")},n.prototype.update=function(){var e,i;if(this.isImmovable||null==this._collider)this.velocity=t.Vector2.zero;else{this.shouldUseGravity&&(this.velocity=t.Vector2.add(this.velocity,t.Vector2.multiply(t.Physics.gravity,new t.Vector2(t.Time.deltaTime)))),this.entity.transform.position=t.Vector2.add(this.entity.transform.position,t.Vector2.multiply(this.velocity,new t.Vector2(t.Time.deltaTime)));var r=new t.CollisionResult,o=t.Physics.boxcastBroadphaseExcludingSelfNonRect(this._collider,this._collider.collidesWithLayers.value);try{for(var s=__values(o),a=s.next();!a.done;a=s.next()){var c=a.value;if(!c.entity.equals(this.entity)&&this._collider.collidesWithNonMotion(c,r)){var h=c.entity.getComponent(n);if(null!=h)this.processOverlap(h,r.minimumTranslationVector),this.processCollision(h,r.minimumTranslationVector);else{this.entity.transform.position=t.Vector2.subtract(this.entity.transform.position,r.minimumTranslationVector);var u=this.velocity.clone();this.calculateResponseVelocity(u,r.minimumTranslationVector,u),this.velocity=t.Vector2.add(this.velocity,u)}}}}catch(t){e={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(e)throw e.error}}}},n.prototype.processOverlap=function(e,n){this.isImmovable?e.entity.transform.position=t.Vector2.add(e.entity.transform.position,n):e.isImmovable?this.entity.transform.position=t.Vector2.subtract(this.entity.transform.position,n):(this.entity.transform.position=t.Vector2.subtract(this.entity.transform.position,t.Vector2.multiply(n,t.Vector2Ext.halfVector())),e.entity.transform.position=t.Vector2.add(e.entity.transform.position,t.Vector2.multiply(n,t.Vector2Ext.halfVector())))},n.prototype.processCollision=function(e,n){var i=t.Vector2.subtract(this.velocity,e.velocity);this.calculateResponseVelocity(i,n,i);var r=this._inverseMass+e._inverseMass,o=this._inverseMass/r,s=e._inverseMass/r;this.velocity=t.Vector2.add(this.velocity,new t.Vector2(i.x*o,i.y*o)),e.velocity=t.Vector2.subtract(e.velocity,new t.Vector2(i.x*s,i.y*s))},n.prototype.calculateResponseVelocity=function(e,n,i){void 0===i&&(i=new t.Vector2);var r=t.Vector2.multiply(n,new t.Vector2(-1)),o=t.Vector2.normalize(r),s=t.Vector2.dot(e,o),a=new t.Vector2(o.x*s,o.y*s),c=t.Vector2.subtract(e,a);s>0&&(a=t.Vector2.zero);var h=this._friction;c.lengthSquared()<this._glue&&(h=1.01);var u=t.Vector2.multiply(new t.Vector2(1+this._elasticity),a).multiply(new t.Vector2(-1)).subtract(t.Vector2.multiply(new t.Vector2(h),c));i.x=u.x,e.y=u.y},n}(t.Component);t.ArcadeRigidbody=e}(es||(es={})),function(t){var e=function(){function e(){}return e.getITriggerListener=function(e,n){var i,r,o,s;try{for(var a=__values(e.components._components),c=a.next();!c.done;c=a.next()){var h=c.value;t.isITriggerListener(h)&&n.push(h)}}catch(t){i={error:t}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}try{for(var u=__values(e.components._componentsToAdd),l=u.next();!l.done;l=u.next()){h=l.value;t.isITriggerListener(h)&&n.push(h)}}catch(t){o={error:t}}finally{try{l&&!l.done&&(s=u.return)&&s.call(u)}finally{if(o)throw o.error}}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),t.Debug.warnIf(null==this._collider,"ProjectileMover没有Collider。ProjectilMover需要一个Collider!")},n.prototype.move=function(e){var n,i;if(null==this._collider)return!1;var r=!1;this.entity.position=t.Vector2.add(this.entity.position,e);var o=t.Physics.boxcastBroadphase(this._collider.bounds,this._collider.collidesWithLayers.value);try{for(var s=__values(o),a=s.next();!a.done;a=s.next()){var c=a.value;this._collider.overlaps(c)&&c.enabled&&(r=!0,this.notifyTriggerListeners(this._collider,c))}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}return r},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&&null!=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.equals(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){void 0===i&&(i=new t.CollisionResult);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.prototype.collidesWithNonMotion=function(e,n){return void 0===n&&(n=new t.CollisionResult),!!this.shape.collidesWithShape(e.shape,n)&&(n.collider=e,!0)},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){this._colliderRequiresAutoSizing=!1;var i=this.shape;return e==i.width&&n==i.height||(i.updateBox(e,n),this._isPositionDirty=!0,this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},n.prototype.setWidth=function(e){this._colliderRequiresAutoSizing=!1;var n=this.shape;return e!=n.width&&(n.updateBox(e,n.height),this._isPositionDirty=!0,this.entity&&this._isParentEntityAddedToScene&&t.Physics.updateCollider(this)),this},n.prototype.setHeight=function(e){this._colliderRequiresAutoSizing=!1;var n=this.shape;e!=n.height&&(n.updateBox(n.width,e),this._isPositionDirty=!0,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){this._colliderRequiresAutoSizing=!1;var n=this.shape;return e!=n.radius&&(n.radius=e,n._originalRadius=e,this._isPositionDirty=!0,null!=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.checkProcessing()&&(this.begin(),this.process(this._entities))},e.prototype.lateUpdate=function(){this.checkProcessing()&&(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.prototype.checkProcessing=function(){return!0},e}();t.EntitySystem=e}(es||(es={})),function(t){var e=function(e){function n(t){var n=e.call(this,t)||this;return n.delay=0,n.running=!1,n.acc=0,n}return __extends(n,e),n.prototype.process=function(t){var e=t.length;if(0!=e){this.delay=Number.MAX_VALUE;for(var n=0;e>n;n++){var i=t[n];this.processDelta(i,this.acc);var r=this.getRemainingDelay(i);r<=0?this.processExpired(i):this.offerDelay(r)}this.acc=0}else this.stop()},n.prototype.checkProcessing=function(){return!!this.running&&(this.acc+=t.Time.deltaTime,this.acc>=this.delay)},n.prototype.offerDelay=function(t){this.running?this.delay=Math.min(this.delay,t):(this.running=!0,this.delay=t)},n.prototype.getInitialTimeDelay=function(){return this.delay},n.prototype.getRemainingTimeUntilProcessing=function(){return this.running?this.delay-this.acc:0},n.prototype.isRunning=function(){return this.running},n.prototype.stop=function(){this.running=!1,this.acc=0},n}(t.EntitySystem);t.DelayedIteratingSystem=e}(es||(es={})),function(t){var e=function(t){function e(e){return t.call(this,e)||this}return __extends(e,t),e.prototype.lateProcessEntity=function(t){},e.prototype.process=function(t){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(e){function n(t,n){var i=e.call(this,t)||this;return i.acc=0,i.interval=0,i.intervalDelta=0,i.interval=n,i}return __extends(n,e),n.prototype.checkProcessing=function(){return this.acc+=t.Time.deltaTime,this.acc>=this.interval&&(this.acc-=this.interval,this.intervalDelta=this.acc-this.intervalDelta,!0)},n.prototype.getIntervalDelta=function(){return this.interval+this.intervalDelta},n}(t.EntitySystem);t.IntervalSystem=e}(es||(es={})),function(t){var e=function(t){function e(e,n){return t.call(this,e,n)||this}return __extends(e,t),e.prototype.process=function(t){var e=this;t.forEach(function(t){return e.processEntity(t)})},e}(t.IntervalSystem);t.IntervalIteratingSystem=e}(es||(es={})),function(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(t){this._components=[],this._updatableComponents=[],this._componentsToAdd=[],this._componentsToRemove=[],this._tempBufferList=[],this._entity=t}return Object.defineProperty(e.prototype,"count",{get:function(){return this._components.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buffer",{get:function(){return this._components},enumerable:!0,configurable:!0}),e.prototype.markEntityListUnsorted=function(){this._isComponentListUnsorted=!0},e.prototype.add=function(t){this._componentsToAdd.push(t)},e.prototype.remove=function(e){var n=new linq.List(this._componentsToRemove),i=new linq.List(this._componentsToAdd);t.Debug.warnIf(n.contains(e),"您正在尝试删除一个您已经删除的组件("+e+")"),i.contains(e)?i.remove(e):n.add(e)},e.prototype.removeAllComponents=function(){for(var t=0;t<this._components.length;t++)this.handleRemove(this._components[t]);this._components.length=0,this._updatableComponents.length=0,this._componentsToAdd.length=0,this._componentsToRemove.length=0},e.prototype.deregisterAllComponents=function(){var e,n;try{for(var i=__values(this._components),r=i.next();!r.done;r=i.next()){var o=r.value;o&&(t.isIUpdatable(o)&&new linq.List(this._updatableComponents).remove(o),this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(o)),!1),this._entity.scene.entityProcessors.onComponentRemoved(this._entity))}}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e.prototype.registerAllComponents=function(){var e,n;try{for(var i=__values(this._components),r=i.next();!r.done;r=i.next()){var o=r.value;t.isIUpdatable(o)&&this._updatableComponents.push(o),this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(o))),this._entity.scene.entityProcessors.onComponentAdded(this._entity)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e.prototype.updateLists=function(){if(this._componentsToRemove.length>0){for(var n=0;n<this._componentsToRemove.length;n++)this.handleRemove(this._componentsToRemove[n]),new linq.List(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.push(r),this._entity.componentBits.set(t.ComponentTypeManager.getIndexFor(t.TypeUtils.getType(r))),this._entity.scene.entityProcessors.onComponentAdded(this._entity),this._components.push(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.compare),this._isComponentListUnsorted=!1)},e.prototype.handleRemove=function(e){t.isIUpdatable(e)&&new linq.List(this._updatableComponents).remove(e),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){var n,i,r,o;try{for(var s=__values(this._components),a=s.next();!a.done;a=s.next()){if((u=a.value)instanceof t)return u}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}if(!e)try{for(var c=__values(this._componentsToAdd),h=c.next();!h.done;h=c.next()){var u;if((u=h.value)instanceof t)return u}}catch(t){r={error:t}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}return null},e.prototype.getComponents=function(t,e){var n,i,r,o;e||(e=[]);try{for(var s=__values(this._components),a=s.next();!a.done;a=s.next()){(u=a.value)instanceof t&&e.push(u)}}catch(t){n={error:t}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}try{for(var c=__values(this._componentsToAdd),h=c.next();!h.done;h=c.next()){var u;(u=h.value)instanceof t&&e.push(u)}}catch(t){r={error:t}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}return e},e.prototype.update=function(){this.updateLists();for(var t=0;t<this._updatableComponents.length;t++)this._updatableComponents[t].enabled&&this._updatableComponents[t].update()},e.prototype.onEntityTransformChanged=function(t){for(var e=0;e<this._components.length;e++)this._components[e].enabled&&this._components[e].onEntityTransformChanged(t);for(e=0;e<this._componentsToAdd.length;e++)this._componentsToAdd[e].enabled&&this._componentsToAdd[e].onEntityTransformChanged(t)},e.prototype.onEntityEnabled=function(){for(var t=0;t<this._components.length;t++)this._components[t].onEnabled()},e.prototype.onEntityDisabled=function(){for(var t=0;t<this._components.length;t++)this._components[t].onDisabled()},e.compareUpdatableOrder=new t.IUpdatableComparer,e}();t.ComponentList=e}(es||(es={})),function(t){var e=function(){function t(){}return t.add=function(t){this._componentTypesMask.has(t)||this._componentTypesMask.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=[],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(e){t.Debug.warnIf(this._entitiesToRemove.contains(e),"您正在尝试删除已经删除的实体("+e.name+")"),this._entitiesToAdded.contains(e)?this._entitiesToAdded.remove(e):this._entitiesToRemove.contains(e)||this._entitiesToRemove.add(e)},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[t]._isDestroyed=!0,this._entities[t].onRemovedFromScene(),this._entities[t].scene=null;this._entities.length=0,this._entityDict.clear()},e.prototype.contains=function(t){return new linq.List(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(){var e,n;try{for(var i=__values(this._entities),r=i.next();!r.done;r=i.next()){var o=r.value;!o.enabled||1!=o.updateInterval&&t.Time.frameCount%o.updateInterval!=0||o.update()}}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e.prototype.updateLists=function(){var e=this;this._entitiesToRemove.getCount()>0&&(this._entitiesToRemove.toArray().forEach(function(t){e.removeFromTagList(t),new linq.List(e._entities).remove(t),t.onRemovedFromScene(),t.scene=null,e.scene.entityProcessors.onEntityRemoved(t)}),this._entitiesToRemove.clear()),this._entitiesToAdded.getCount()>0&&(this._entitiesToAdded.toArray().forEach(function(t){e._entities.push(t),t.scene=e.scene,e.addToTagList(t),e.scene.entityProcessors.onEntityAdded(t)}),this._entitiesToAdded.toArray().forEach(function(t){t.onAddedToScene()}),this._entitiesToAdded.clear(),this._isEntityListUnsorted=!0),this._isEntityListUnsorted&&(this._entities.sort(t.Entity.entityComparer.compare),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[e].name==t)return this._entities[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[i]instanceof e&&n.push(this._entities[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[e].enabled)if(n=this._entities[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[i].enabled&&this._entities[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 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.format=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];for(var i=0;i<e.length-1;i++){var r=new RegExp("\\{"+i+"\\}","gm");t=t.replace(r,e[i+1])}return t},t.specialSigns=["&","&","<","<",">",">",'"',""","'","'","®","®","©","©","™","™"],t}();!function(t){var e=function(){function t(){}return t.update=function(t){-1==t&&(t=Date.now()),-1==this._lastTime&&(this._lastTime=t);var e=t-this._lastTime;this.totalTime+=e,this.deltaTime=e*this.timeScale,this.unscaledDeltaTime=e,this.timeSinceSceneLoad+=e,this.frameCount++,this._lastTime=t},t.sceneChanged=function(){this.timeSinceSceneLoad=0},t.checkEvery=function(t){return this.timeSinceSceneLoad/t>(this.timeSinceSceneLoad-this.deltaTime)/t},t.totalTime=0,t.unscaledDeltaTime=0,t.deltaTime=0,t.timeScale=1,t.frameCount=0,t.timeSinceSceneLoad=0,t._lastTime=-1,t}();t.Time=e}(es||(es={}));var TimeUtils=function(){function t(){}return t.monthId=function(t){void 0===t&&(t=null);var e=(t=t||new Date).getFullYear(),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 h=n.getDay();if(0==h&&(h=7),e&&(!o||h<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 new t.Vector2(o*o).multiply(e).add(new t.Vector2(2*o*r).multiply(n)).add(new t.Vector2(r*r).multiply(i))},e.getPointThree=function(e,n,i,r,o){var s=1-(o=t.MathHelper.clamp01(o));return new t.Vector2(s*s*s).multiply(e).add(new t.Vector2(3*s*s*o).multiply(n)).add(new t.Vector2(3*s*o*o).multiply(i)).add(new t.Vector2(o*o*o).multiply(r))},e.getFirstDerivative=function(e,n,i,r){return new t.Vector2(2*(1-r)).multiply(t.Vector2.subtract(n,e)).add(new t.Vector2(2*r).multiply(t.Vector2.subtract(i,n)))},e.getFirstDerivativeThree=function(e,n,i,r,o){var s=1-(o=t.MathHelper.clamp01(o));return new t.Vector2(3*s*s).multiply(t.Vector2.subtract(n,e)).add(new t.Vector2(6*s*o).multiply(t.Vector2.subtract(i,n))).add(new t.Vector2(3*o*o).multiply(t.Vector2.subtract(r,i)))},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)),h=t.Vector2.divide(t.Vector2.add(i,r),new t.Vector2(2)),u=t.Vector2.divide(t.Vector2.add(a,c),new t.Vector2(2)),l=t.Vector2.divide(t.Vector2.add(c,h),new t.Vector2(2)),p=t.Vector2.divide(t.Vector2.add(u,l),new t.Vector2(2)),f=t.Vector2.subtract(r,e),d=Math.abs((n.x,r.x*f.y-(n.y-r.y)*f.x)),m=Math.abs((i.x-r.x)*f.y-(i.y-r.y)*f.x);(d+m)*(d+m)<s*(f.x*f.x+f.y*f.y)?o.push(p):(this.recursiveGetOptimizedDrawingPoints(e,a,u,p,o,s),this.recursiveGetOptimizedDrawingPoints(p,l,h,r,o,s))},e}();t.Bezier=e}(es||(es={})),function(t){var e=function(){function e(){this._points=[],this._curveCount=0}return e.prototype.pointIndexAtTime=function(e){var n=0;return e.value>=1?(e.value=1,n=this._points.length-4):(e.value=t.MathHelper.clamp01(e.value)*this._curveCount,n=~~e,e.value-=n,n*=3),n},e.prototype.setControlPoint=function(e,n){if(e%3==0){var i=t.Vector2.subtract(n,this._points[e]);e>0&&this._points[e-1].add(i),e+1<this._points.length&&this._points[e+1].add(i)}this._points[e]=n},e.prototype.getPointAtTime=function(e){var n=this.pointIndexAtTime(new t.Ref(e));return t.Bezier.getPointThree(this._points[n],this._points[n+1],this._points[n+2],this._points[n+3],e)},e.prototype.getVelocityAtTime=function(e){var n=this.pointIndexAtTime(new t.Ref(e));return t.Bezier.getFirstDerivativeThree(this._points[n],this._points[n+1],this._points[n+2],this._points[n+3],e)},e.prototype.getDirectionAtTime=function(e){return t.Vector2.normalize(this.getVelocityAtTime(e))},e.prototype.addCurve=function(t,e,n,i){0==this._points.length&&this._points.push(t),this._points.push(e),this._points.push(n),this._points.push(i),this._curveCount=(this._points.length-1)/3},e.prototype.reset=function(){this._points.length=0},e.prototype.getDrawingPoints=function(t){for(var e=[],n=0;n<t;n++){var i=n/t;e[n]=this.getPointAtTime(i)}return e},e}();t.BezierSpline=e}(es||(es={})),function(t){var e=function(){function t(){}return t.isFlagSet=function(t,e){return 0!=(t&e)},t.isUnshiftedFlagSet=function(t,e){return 0!=(t&(e=1<<e))},t.setFlagExclusive=function(t,e){t.value=1<<e},t.setFlag=function(t,e){t.value=t.value|1<<e},t.unsetFlag=function(t,e){e=1<<e,t.value=t.value&~e},t.invertFlags=function(t){t.value=~t.value},t}();t.Flags=e}(es||(es={})),function(t){var e=function(){function e(){}return e.toDegrees=function(t){return 57.29577951308232*t},e.toRadians=function(t){return.017453292519943295*t},e.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.angleToVector=function(e,n){return new t.Vector2(Math.cos(e)*n,Math.sin(e)*n)},e.incrementWithWrap=function(t,e){return++t==e?0:t},e.roundToNearest=function(t,e){return Math.round(t/e)*e},e.withinEpsilon=function(t,e){return void 0===e&&(e=this.Epsilon),Math.abs(t)<e},e.approach=function(t,e,n){return t<e?Math.min(t+n,e):Math.max(t-n,e)},e.deltaAngle=function(t,e){var n=this.repeat(e-t,360);return n>180&&(n-=360),n},e.repeat=function(t,e){return t-Math.floor(t/e)*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 t(){}return t.createOrthographicOffCenter=function(e,n,i,r,o,s,a){void 0===a&&(a=new t),a.m11=2/(n-e),a.m12=0,a.m13=0,a.m14=0,a.m21=0,a.m22=2/(r-i),a.m23=0,a.m24=0,a.m31=0,a.m32=0,a.m33=1/(o-s),a.m34=0,a.m41=(e+n)/(e-n),a.m42=(r+i)/(i-r),a.m43=o/(o-s),a.m44=1},t.multiply=function(e,n,i){void 0===i&&(i=new t);var r=e.m11*n.m11+e.m12*n.m21+e.m13*n.m31+e.m14*n.m41,o=e.m11*n.m12+e.m12*n.m22+e.m13*n.m32+e.m14*n.m42,s=e.m11*n.m13+e.m12*n.m23+e.m13*n.m33+e.m14*n.m43,a=e.m11*n.m14+e.m12*n.m24+e.m13*n.m34+e.m14*n.m44,c=e.m21*n.m11+e.m22*n.m21+e.m23*n.m31+e.m24*n.m41,h=e.m21*n.m12+e.m22*n.m22+e.m23*n.m32+e.m24*n.m42,u=e.m21*n.m13+e.m22*n.m23+e.m23*n.m33+e.m24*n.m43,l=e.m21*n.m14+e.m22*n.m24+e.m23*n.m34+e.m24*n.m44,p=e.m31*n.m11+e.m32*n.m21+e.m33*n.m31+e.m34*n.m41,f=e.m31*n.m12+e.m32*n.m22+e.m33*n.m32+e.m34*n.m42,d=e.m31*n.m13+e.m32*n.m23+e.m33*n.m33+e.m34*n.m43,m=e.m31*n.m14+e.m32*n.m24+e.m33*n.m34+e.m34*n.m44,y=e.m41*n.m11+e.m42*n.m21+e.m43*n.m31+e.m44*n.m41,g=e.m41*n.m12+e.m42*n.m22+e.m43*n.m32+e.m44*n.m42,v=e.m41*n.m13+e.m42*n.m23+e.m43*n.m33+e.m44*n.m43,_=e.m41*n.m14+e.m42*n.m24+e.m43*n.m34+e.m44*n.m44;i.m11=r,i.m12=o,i.m13=s,i.m14=a,i.m21=c,i.m22=h,i.m23=u,i.m24=l,i.m31=p,i.m32=f,i.m33=d,i.m34=m,i.m41=y,i.m42=g,i.m43=v,i.m44=_},t}();t.Matrix=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.toMatrix=function(e){var n=new t.Matrix;return n.m11=e.m11,n.m12=e.m12,n.m13=0,n.m14=0,n.m21=e.m21,n.m22=e.m22,n.m23=0,n.m24=0,n.m31=0,n.m32=0,n.m33=1,n.m34=0,n.m41=e.m31,n.m42=e.m32,n.m43=0,n.m44=1,n},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,h=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=h}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,h=(this.y+this.height-t.start.y)*a;if(c>h){var u=c;c=h,h=u}if(e.value=Math.max(c,e.value),n=Math.max(h,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,h=e.y+n.y;this._transformMat=t.Matrix2D.createTranslation(-c-i.x,-h-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,h),this._transformMat=this._transformMat.multiply(this._tempMat);var u=new t.Vector2(c,h),l=new t.Vector2(c+s,h),p=new t.Vector2(c,h+a),f=new t.Vector2(c+s,h+a);t.Vector2Ext.transformR(u,this._transformMat,u),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(u.x,f.x,l.x,p.x),m=Math.max(u.x,f.x,l.x,p.x),y=Math.min(u.y,f.y,l.y,p.y),g=Math.max(u.y,f.y,l.y,p.y);this.location=new t.Vector2(d,y),this.width=m-d,this.height=g-y}},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),h=a.x-c.x,u=a.y-c.y,l=i+o,p=r+s;if(Math.abs(h)>=l||Math.abs(u)>=p)return t.Vector2.zero;var f=h>0?l-h:-l-h,d=u>0?p-u:-p-u;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(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.lineToLine=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),h=(c.x*s.y-c.y*s.x)/a;if(h<0||h>1)return!1;var u=(c.x*o.y-c.y*o.x)/a;return!(u<0||u>1)},n.lineToLineIntersection=function(e,n,i,r,o){void 0===o&&(o=new t.Vector2),o.x=0,o.y=0;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 h=t.Vector2.subtract(i,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return!1;var l=(h.x*s.y-h.y*s.x)/c;if(l<0||l>1)return!1;var p=t.Vector2.add(e,new t.Vector2(u*s.x,u*s.y));return o.x=p.x,o.y=p.y,!0},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,h=void 0;return!(0==(a&e.top)||(c=new t.Vector2(n.x,n.y),h=new t.Vector2(n.x+n.width,n.y),!this.lineToLine(c,h,i,r)))||(!(0==(a&e.bottom)||(c=new t.Vector2(n.x,n.y+n.height),h=new t.Vector2(n.x+n.width,n.y+n.height),!this.lineToLine(c,h,i,r)))||(!(0==(a&e.left)||(c=new t.Vector2(n.x,n.y),h=new t.Vector2(n.x,n.y+n.height),!this.lineToLine(c,h,i,r)))||!(0==(a&e.right)||(c=new t.Vector2(n.x+n.width,n.y),h=new t.Vector2(n.x+n.width,n.y+n.height),!this.lineToLine(c,h,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(),this._colliderArray[0]=null},e.clear=function(){this._spatialHash.clear()},e.overlapCircle=function(t,n,i){return void 0===i&&(i=e.allLayers),this._colliderArray[0]=null,this._spatialHash.overlapCircle(t,n,this._colliderArray,i),this._colliderArray[0]},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.warn("传入了一个空的结果数组。不会返回任何结果")},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.boxcastBroadphaseExcludingSelfNonRect=function(t,e){void 0===e&&(e=this.allLayers);var n=t.bounds.clone();return this._spatialHash.aabbBroadphase(n,t,e)},e.boxcastBroadphaseExcludingSelfDelta=function(t,n,i,r){void 0===r&&(r=e.allLayers);var o=t.bounds.clone().getSweptBroadphaseBounds(n,i);return this._spatialHash.aabbBroadphase(o,t,r)},e.addCollider=function(t){e._spatialHash.register(t)},e.removeCollider=function(t){e._spatialHash.remove(t)},e.updateCollider=function(t){this._spatialHash.remove(t),this._spatialHash.register(t)},e.linecast=function(t,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.overlapRectangle=function(t,n){return void 0===n&&(n=e.allLayers),this._colliderArray[0]=null,this._spatialHash.overlapRectangle(t,this._colliderArray,n),this._colliderArray[0]},e.overlapRectangleAll=function(t,n,i){return void 0===i&&(i=e.allLayers),0==n.length?(console.warn("传入了一个空的结果数组。不会返回任何结果"),0):this._spatialHash.overlapRectangle(t,n,i)},e.gravity=new t.Vector2(0,300),e.spatialHashCellSize=100,e.allLayers=-1,e.raycastsHitTriggers=!1,e.raycastsStartInColliders=!1,e._hitArray=[new t.RaycastHit],e._colliderArray=[null],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._overlapTestBox=new t.Box(0,0),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(e){for(var n=e.registeredPhysicsBounds.clone(),i=this.cellCoords(n.x,n.y),r=this.cellCoords(n.right,n.bottom),o=i.x;o<=r.x;o++)for(var s=i.y;s<=r.y;s++){var a=this.cellAtPosition(o,s);t.Insist.isNotNull(a,"从不存在碰撞器的单元格中移除碰撞器: ["+e+"]"),null!=a&&new linq.List(a).remove(e)}},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 h=0;h<c.length;h++){var u=c[h];u!=n&&t.Flags.isFlagSet(i,u.physicsLayer.value)&&(e.intersects(u.bounds)&&this._tempHashSet.add(u))}}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),h=Math.sign(o.direction.y);s.x==a.x&&(c=0),s.y==a.y&&(h=0);var u=c<0?0:c,l=h<0?0:h,p=(s.x+u)*this._cellSize,f=(s.y+l)*this._cellSize,d=0!=o.direction.x?(p-o.start.x)/o.direction.x:Number.MAX_VALUE,m=0!=o.direction.y?(f-o.start.y)/o.direction.y:Number.MAX_VALUE,y=0!=o.direction.x?this._cellSize/(o.direction.x*c):Number.MAX_VALUE,g=0!=o.direction.y?this._cellSize/(o.direction.y*h):Number.MAX_VALUE,v=this.cellAtPosition(s.x,s.y);if(v&&this._raycastParser.checkRayIntersection(s.x,s.y,v))return this._raycastParser.reset(),this._raycastParser.hitCounter;for(;s.x!=a.x||s.y!=a.y;)if(d<m?(s.x=Math.floor(t.MathHelper.approach(s.x,a.x,Math.abs(c))),d+=y):(s.y=Math.floor(t.MathHelper.approach(s.y,a.y,Math.abs(h))),m+=g),(v=this.cellAtPosition(s.x,s.y))&&this._raycastParser.checkRayIntersection(s.x,s.y,v))return this._raycastParser.reset(),this._raycastParser.hitCounter;return this._raycastParser.reset(),this._raycastParser.hitCounter},e.prototype.overlapRectangle=function(e,n,i){var r,o;this._overlapTestBox.updateBox(e.width,e.height),this._overlapTestBox.position=e.location;var s=0,a=this.aabbBroadphase(e,null,i);try{for(var c=__values(a),h=c.next();!h.done;h=c.next()){var u=h.value;if(u instanceof t.BoxCollider)n[s]=u,s++;else if(u instanceof t.CircleCollider)t.Collisions.rectToCircle(e,u.bounds.center,.5*u.bounds.width)&&(n[s]=u,s++);else{if(!(u instanceof t.PolygonCollider))throw new Error("overlapRectangle对这个类型没有实现!");u.shape.overlaps(this._overlapTestBox)&&(n[s]=u,s++)}if(s==n.length)return s}}catch(t){r={error:t}}finally{try{h&&!h.done&&(o=c.return)&&o.call(c)}finally{if(r)throw r.error}}return s},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,h=this.aabbBroadphase(a,null,r);try{for(var u=__values(h),l=u.next();!l.done;l=u.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=u.return)&&s.call(u)}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<<16|e>>>0},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 h=t.ShapeCollisions.closestPointOnLine(e[a],e[c],n);if((s=t.Vector2.distanceSquared(n,h))<i.value){i.value=s,o=h;var u=t.Vector2.subtract(e[c],e[a]);r.x=-u.y,r.y=u.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.clone();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.multiply(s.direction,new t.Vector2(r.value))),h=0;c.x<n.bounds.left&&(a|=1),c.x>n.bounds.right&&(h|=1),c.y<n.bounds.top&&(a|=2),c.y>n.bounds.bottom&&(h|=2);var u=a+h;return 3==u&&console.log("m == 3. corner "+t.Time.frameCount),!0},e.corner=function(e,n){var i=new t.Vector2;return i.x=0==(1&n)?e.right:e.left,i.y=0==(1&n)?e.bottom:e.top,i},e.testCircleBox=function(e,n,i){i=n.bounds.getClosestPointOnRectangleToPoint(e.position);var r=t.Vector2.subtract(i,e.position);return t.Vector2.dot(r,r)<=e.radius*e.radius},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,h=new t.Vector2,u=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),m=new t.Ref(0),y=0;this.getInterval(r,e,p,d),this.getInterval(r,n,f,m);var g=t.Vector2.dot(u,r);if(p.value+=g,d.value+=g,(y=this.intervalDistance(p.value,d.value,f.value,m.value))>0&&(o=!1),!o)return!1;(y=Math.abs(y))<c&&(c=y,h=r,t.Vector2.dot(h,u)<0&&(h=new t.Vector2(-h.x,-h.y)))}return i.normal=h,i.minimumTranslationVector=new t.Vector2(-h.x*c,-h.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){void 0===i&&(i=new t.CollisionResult);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 h=Math.sqrt(s.value);r=t.Vector2.subtract(new t.Vector2(-1),t.Vector2.subtract(o,a)).multiply(new t.Vector2((e.radius-h)/h))}return i.minimumTranslationVector=r,i.point=t.Vector2.add(a,n.position),!0},e.circleToBox=function(e,n,i){void 0===i&&(i=new t.CollisionResult);var r=n.bounds.getClosestPointOnRectangleBorderToPoint(e.position,i.normal);if(n.containsPoint(e.position)){i.point=r.clone();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)))},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){void 0===i&&(i=new t.CollisionResult);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){void 0===r&&(r=new t.RaycastHit);for(var o=t.Vector2.zero,s=t.Vector2.zero,a=Number.MAX_VALUE,c=!1,h=i.points.length-1,u=0;u<i.points.length;h=u,u++){var l=t.Vector2.add(i.position,i.points[h]),p=t.Vector2.add(i.position,i.points[u]),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 m=t.Vector2.subtract(p,l);o=new t.Vector2(m.y,-m.x),a=d,s=f}}}if(c){o.normalize();var y=t.Vector2.distance(e,s);return r.setValuesNonCollider(a,y,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 h=t.Vector2.subtract(i,e),u=(h.x*a.y-h.y*a.x)/c;if(u<0||u>1)return!1;var l=(h.x*s.y-h.y*s.x)/c;return!(l<0||l>1)&&(t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(u),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),h=t.Vector2.dot(a,a)-i.radius*i.radius;if(h>0&&c>0)return!1;var u=c*c-h;return!(u<0)&&(r.fraction=-c-Math.sqrt(u),r.fraction<0&&(r.fraction=0),r.point=t.Vector2.add(e,t.Vector2.multiply(new t.Vector2(r.fraction),s)),r.distance=t.Vector2.distance(e,r.point),r.normal=t.Vector2.normalize(t.Vector2.subtract(r.point,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={})),function(t){var e=function(){return function(t,e){this.func=t,this.context=e}}();t.FuncPack=e;var n=function(){function n(){this._messageTable=new Map}return n.prototype.addObserver=function(n,i,r){var o=this._messageTable.get(n);o||(o=[],this._messageTable.set(n,o)),t.Insist.isFalse(-1!=o.findIndex(function(t){return t.func==i}),"您试图添加相同的观察者两次"),o.push(new e(i,r))},n.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)},n.prototype.emit=function(t){for(var e,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var r=this._messageTable.get(t);if(r)for(var o=r.length-1;o>=0;o--)(e=r[o].func).call.apply(e,__spread([r[o].context],n))},n}();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.computeHash=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=2166136261,i=0;i<t.length;i++)n=16777619*(n^t[i]);return n+=n<<13,n^=n>>7,n+=n<<3,n^=n>>17,n+=n<<5},t}();t.Hash=e}(es||(es={})),function(t){var e=function(){return function(t){this.value=t}}();t.Ref=e}(es||(es={})),function(t){var e=function(){function e(){}return Object.defineProperty(e,"size",{get:function(){return new t.Vector2(this.width,this.height)},enumerable:!0,configurable:!0}),Object.defineProperty(e,"center",{get:function(){return new t.Vector2(this.width/2,this.height/2)},enumerable:!0,configurable:!0}),e}();t.Screen=e}(es||(es={})),function(t){var e=function(){function t(){}return t.prototype.update=function(t){this.remainder+=t;var e=Math.trunc(this.remainder);return this.remainder-=e,e},t.prototype.reset=function(){this.remainder=0},t}();t.SubpixelNumber=e}(es||(es={})),function(t){var e=function(){function e(){this.triangleIndices=[],this._triPrev=new Array(12),this._triNext=new Array(12)}return e.testPointTriangle=function(e,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]],h=n[s],u=n[this._triNext[s]];if(t.Vector2Ext.isTriangleCCW(c,h,u)){var l=this._triNext[this._triNext[s]];do{if(e.testPointTriangle(n[l],c,h,u)){a=!1;break}l=this._triNext[l]}while(l!=this._triPrev[s])}else a=!1;a?(this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),this._triNext[this._triPrev[s]]=this._triNext[s],this._triPrev[this._triNext[s]]=this._triPrev[s],r--,s=this._triPrev[s]):s=this._triNext[s]}this.triangleIndices.push(this._triPrev[s]),this.triangleIndices.push(s),this.triangleIndices.push(this._triNext[s]),i||this.triangleIndices.reverse()},e.prototype.initialize=function(t){this.triangleIndices.length=0,this._triNext.length<t&&(this._triNext.reverse(),this._triNext.length=Math.max(2*this._triNext.length,t)),this._triPrev.length<t&&(this._triPrev.reverse(),this._triPrev.length=Math.max(2*this._triPrev.length,t));for(var e=0;e<t;e++)this._triPrev[e]=e-1,this._triNext[e]=e+1;this._triPrev[0]=t-1,this._triNext[t-1]=0},e}();t.Triangulator=e}(es||(es={})),function(t){var e,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}(es||(es={})),function(t){var e=function(){function e(){this.frameCount=0,this.stopwatch=new t.Stopwatch,this.markers=[],this.markerNameToIdMap=new Map,this.enabled=!0,this.updateCount=0,this.logs=new Array(2);for(var e=0;e<this.logs.length;++e)this.logs[e]=new r}return Object.defineProperty(e,"Instance",{get:function(){return this._instance||(this._instance=new e),this._instance},enumerable:!0,configurable:!0}),e.prototype.startFrame=function(){if(t.Core.Instance.debug){var n=this.updateCount++;if(!(this.enabled&&1<n&&n<e.maxSampleFrames)){this.prevLog=this.logs[1&this.frameCount++],this.curLog=this.logs[1&this.frameCount];for(var i=this.stopwatch.getTime(),r=0;r<this.prevLog.bars.length;++r){for(var o=this.prevLog.bars[r],s=this.curLog.bars[r],a=0;a<o.nestCount;++a){var c=o.markerNests[a];o.markers[c].endTime=i,s.markerNests[a]=a,s.markers[a].markerId=o.markers[c].markerId,s.markers[a].beginTime=0,s.markers[a].endTime=-1,s.markers[a].color=o.markers[c].color}for(c=0;c<o.markCount;++c){var h=o.markers[c].endTime-o.markers[c].beginTime,u=o.markers[c].markerId,l=this.markers[u];l.logs[r].color=o.markers[c].color,l.logs[r].initialized?(l.logs[r].min=Math.min(l.logs[r].min,h),l.logs[r].max=Math.min(l.logs[r].max,h),l.logs[r].avg+=h,l.logs[r].avg*=.5,l.logs[r].samples++>=e.logSnapDuration&&(l.logs[r].snapMin=l.logs[r].min,l.logs[r].snapMax=l.logs[r].max,l.logs[r].snapAvg=l.logs[r].avg,l.logs[r].samples=0)):(l.logs[r].min=h,l.logs[r].max=h,l.logs[r].avg=h,l.logs[r].initialized=!0)}s.markCount=o.nestCount,s.nestCount=o.nestCount}this.stopwatch.reset(),this.stopwatch.start()}}},e.prototype.beginMark=function(i,r,o){if(void 0===o&&(o=0),t.Core.Instance.debug){if(o<0||o>=e.maxBars)throw new Error("barIndex 越位");var s=this.curLog.bars[o];if(s.markCount>=e.maxSamples)throw new Error("超出样本数.\n 要么设置更大的数字为TimeRuler.MaxSmpale,要么降低样本数");if(s.nestCount>=e.maxNestCall)throw new Error("nestCount超出.\n 要么将大的设置为TimeRuler.MaxNestCall,要么将小的设置为NestCall");var a=this.markerNameToIdMap.get(i);null==a&&(a=this.markers.length,this.markerNameToIdMap.set(i,a),this.markers.push(new n(i))),s.markerNests[s.nestCount++]=s.markCount,s.markers[s.markCount].markerId=a,s.markers[s.markCount].color=r,s.markers[s.markCount].beginTime=this.stopwatch.getTime(),s.markers[s.markCount].endTime=-1,s.markCount++}},e.prototype.endMark=function(n,i){if(void 0===i&&(i=0),t.Core.Instance.debug){if(i<0||i>=e.maxBars)throw new Error("barIndex 越位");var r=this.curLog.bars[i];if(r.nestCount<=0)throw new Error("在调用结束标记方法之前调用beginMark方法");var o=this.markerNameToIdMap.get(n);if(null==o)throw new Error("标记"+n+"没有注册。请确认您指定的名称与BeginMark方法使用的名称相同");var s=r.markerNests[--r.nestCount];if(r.markers[s].markerId!=o)throw new Error("beginMark/endMark方法的调用顺序不正确. beginMark(A), beginMark(B), endMark(B), endMark(A).但你不能像这样叫它 beginMark(A), beginMark(B), endMark(A), endMark(B)");r.markers[s].endTime=this.stopwatch.getTime()}},e.prototype.getAverageTime=function(t,n){if(t<0||t>=e.maxBars)throw new Error("barIndex 越位");var i=0,r=this.markerNameToIdMap.get(n);return null!=r&&(i=this.markers[r].logs[t].avg),i},e.prototype.resetLog=function(){var e,n;if(t.Core.Instance.debug)try{for(var i=__values(this.markers),r=i.next();!r.done;r=i.next())for(var o=r.value,s=0;s<o.logs.length;++s)o.logs[s].initialized=!1,o.logs[s].snapMin=0,o.logs[s].snapMax=0,o.logs[s].snapAvg=0,o.logs[s].min=0,o.logs[s].max=0,o.logs[s].avg=0,o.logs[s].samples=0}catch(t){e={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}},e.maxBars=8,e.maxSamples=256,e.maxNestCall=32,e.maxSampleFrames=4,e.logSnapDuration=120,e}();t.TimeRuler=e;var n=function(){return function(t){this.logs=new Array(e.maxBars),this.name=t;for(var n=0;n<e.maxBars;++n)this.logs[n]=new i}}(),i=function(){return function(){this.snapMin=0,this.snapMax=0,this.snapAvg=0,this.min=0,this.max=0,this.avg=0,this.samples=0,this.color=0,this.initialized=!1}}(),r=function(){return function(){this.bars=new Array(e.maxBars);for(var t=0;t<e.maxBars;++t)this.bars[t]=new o}}(),o=function(){return function(){this.markers=new Array(e.maxSamples),this.markCount=0,this.markerNests=new Array(e.maxNestCall),this.nestCount=0,this.markerNests.fill(0);for(var t=0;t<e.maxSamples;++t)this.markers[t]=new s}}(),s=function(){return function(){this.markerId=0,this.beginTime=0,this.endTime=0,this.color=0}}()}(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 h=t.NumberExtension.toNumber(this._buckets[a])-1;if(-1==h)this._valuesInfo[this._freeValueCellIndex]=new n(i,s);else{var u=h;do{if(this._valuesInfo[u].hashcode==s&&this._valuesInfo[u].key==i)return this._values[u]=r,o.value=u,!1;u=this._valuesInfo[u].previous}while(-1!=u);this._collisions++,this._valuesInfo[this._freeValueCellIndex]=new n(i,s,h),this._valuesInfo[h].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,h=this._valuesInfo[this._freeValueCellIndex].previous;-1!=c&&(this._valuesInfo[c].previous=o),-1!=h&&(this._valuesInfo[h].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(){return function(t,e){this.element=t,this.next=e}}();function n(t,e){return t===e}t.Node=e,t.defaultEquals=n;var i=function(){function t(t){void 0===t&&(t=n),this.count=0,this.next=void 0,this.equalsFn=t,this.head=null}return t.prototype.push=function(t){var n,i=new e(t);if(null==this.head)this.head=i;else{for(n=this.head;null!=n.next;)n=n.next;n.next=i}this.count++},t.prototype.removeAt=function(t){if(t>=0&&t<this.count){var e=this.head;if(0===t)this.head=e.next;else{var n=this.getElementAt(t-1);e=n.next,n.next=e.next}return this.count--,e.element}},t.prototype.getElementAt=function(t){if(t>=0&&t<=this.count){for(var e=this.head,n=0;n<t&&null!=e;n++)e=e.next;return e}},t.prototype.insert=function(t,n){if(n>=0&&n<=this.count){var i=new e(t);if(0===n)i.next=this.head,this.head=i;else{var r=this.getElementAt(n-1);i.next=r.next,r.next=i}return this.count++,!0}return!1},t.prototype.indexOf=function(t){for(var e=this.head,n=0;n<this.count&&null!=e;n++){if(this.equalsFn(t,e.element))return n;e=e.next}return-1},t.prototype.remove=function(t){this.removeAt(this.indexOf(t))},t.prototype.clear=function(){this.head=void 0,this.count=0},t.prototype.size=function(){return this.count},t.prototype.isEmpty=function(){return 0===this.size()},t.prototype.getHead=function(){return this.head},t.prototype.toString=function(){if(null==this.head)return"";for(var t=""+this.head.element,e=this.head.next,n=1;n<this.size()&&null!=e;n++)t=t+", "+e.element,e=e.next;return t},t}();t.LinkedList=i}(es||(es={})),function(t){var e=function(){function t(){}return t.warmCache=function(t){if((t-=this._objectQueue.length)>0)for(var e=0;e<t;e++)this._objectQueue.unshift([])},t.trimCache=function(t){for(;t>this._objectQueue.length;)this._objectQueue.shift()},t.clearCache=function(){this._objectQueue.length=0},t.obtain=function(){return this._objectQueue.length>0?this._objectQueue.shift():[]},t.free=function(t){this._objectQueue.unshift(t),t.length=0},t._objectQueue=[],t}();t.ListPool=e}(es||(es={})),function(t){var e=function(){function e(t,e){this.first=t,this.second=e}return e.prototype.clear=function(){this.first=this.second=null},e.prototype.equals=function(t){return this.first==t.first&&this.second==t.second},e.prototype.getHashCode=function(){return 37*t.EqualityComparer.default().getHashCode(this.first)+t.EqualityComparer.default().getHashCode(this.second)},e}();t.Pair=e}(es||(es={})),function(t){var e=function(){function e(){}return e.warmCache=function(t,e){if((e-=this._objectQueue.length)>0)for(var 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={})),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.waitForSeconds=function(t){return n.waiter.wait(t)},t}();t.Coroutine=e;var n=function(){function t(){this.waitTime=0}return t.prototype.wait=function(e){return t.waiter.waitTime=e,t.waiter},t.waiter=new t,t}();t.WaitForSeconds=n}(es||(es={})),function(t){var e=function(){function t(){this.waitTimer=0,this.useUnscaledDeltaTime=!1}return t.prototype.stop=function(){this.isDone=!0},t.prototype.setUseUnscaledDeltaTime=function(t){return this.useUnscaledDeltaTime=t,this},t.prototype.prepareForUse=function(){this.isDone=!1},t.prototype.reset=function(){this.isDone=!0,this.waitTimer=0,this.waitForCoroutine=null,this.enumerator=null,this.useUnscaledDeltaTime=!1},t}();t.CoroutineImpl=e;var n=function(n){function i(){var t=null!==n&&n.apply(this,arguments)||this;return t._unblockedCoroutines=[],t._shouldRunNextFrame=[],t}return __extends(i,n),i.prototype.startCoroutine=function(n){var i=t.Pool.obtain(e);return i.prepareForUse(),i.enumerator=n,this.tickCoroutine(i)?(this._isInUpdate?this._shouldRunNextFrame.push(i):this._unblockedCoroutines.push(i),i):null},i.prototype.update=function(){this._isInUpdate=!0;for(var e=0;e<this._unblockedCoroutines.length;e++){var n=this._unblockedCoroutines[e];if(n.isDone)t.Pool.free(n);else{if(null!=n.waitForCoroutine){if(!n.waitForCoroutine.isDone){this._shouldRunNextFrame.push(n);continue}n.waitForCoroutine=null}n.waitTimer>0?(n.waitTimer-=n.useUnscaledDeltaTime?t.Time.unscaledDeltaTime:t.Time.deltaTime,this._shouldRunNextFrame.push(n)):this.tickCoroutine(n)&&this._shouldRunNextFrame.push(n)}}var i=new linq.List(this._unblockedCoroutines);i.clear(),i.addRange(this._shouldRunNextFrame),this._shouldRunNextFrame.length=0,this._isInUpdate=!1},i.prototype.tickCoroutine=function(n){var i=n.enumerator.next();return i.done||n.isDone?(t.Pool.free(n),!1):null==i.value||(i.value instanceof t.WaitForSeconds?(n.waitTimer=i.value.waitTime,!0):"number"==typeof i.value?(n.waitTimer=i.value,!0):"string"==typeof i.value?"break"!=i.value||(t.Pool.free(n),!1):!(i.value instanceof e)||(n.waitForCoroutine=i.value,!0))},i}(t.GlobalManager);t.CoroutineManager=n}(es||(es={})),function(t){var e=function(){function e(t,e,n){void 0===n&&(n=!0),this.binWidth=0,this.binHeight=0,this.usedRectangles=[],this.freeRectangles=[],this.init(t,e,n)}return e.prototype.init=function(e,n,i){void 0===i&&(i=!0),this.binWidth=e,this.binHeight=n,this.allowRotations=i;var r=new t.Rectangle;r.x=0,r.y=0,r.width=e,r.height=n,this.usedRectangles.length=0,this.freeRectangles.length=0,this.freeRectangles.push(r)},e.prototype.insert=function(e,n){var i=new t.Rectangle,r=new t.Ref(0),o=new t.Ref(0);if(0==(i=this.findPositionForNewNodeBestAreaFit(e,n,r,o)).height)return i;for(var s=this.freeRectangles.length,a=0;a<s;++a)this.splitFreeNode(this.freeRectangles[a],i)&&(new linq.List(this.freeRectangles).removeAt(a),--a,--s);return this.pruneFreeList(),this.usedRectangles.push(i),i},e.prototype.findPositionForNewNodeBestAreaFit=function(e,n,i,r){var o=new t.Rectangle;i.value=Number.MAX_VALUE;for(var s=0;s<this.freeRectangles.length;++s){var a=this.freeRectangles[s].width*this.freeRectangles[s].height-e*n;if(this.freeRectangles[s].width>=e&&this.freeRectangles[s].height>=n){var c=Math.abs(this.freeRectangles[s].width-e),h=Math.abs(this.freeRectangles[s].height-n),u=Math.min(c,h);(a<i.value||a==i.value&&u<r.value)&&(o.x=this.freeRectangles[s].x,o.y=this.freeRectangles[s].y,o.width=e,o.height=n,r.value=u,i.value=a)}if(this.allowRotations&&this.freeRectangles[s].width>=n&&this.freeRectangles[s].height>=e){c=Math.abs(this.freeRectangles[s].width-n),h=Math.abs(this.freeRectangles[s].height-e),u=Math.min(c,h);(a<i.value||a==i.value&&u<r.value)&&(o.x=this.freeRectangles[s].x,o.y=this.freeRectangles[s].y,o.width=n,o.height=e,r.value=u,i.value=a)}return o}},e.prototype.splitFreeNode=function(t,e){if(e.x>=t.x+t.width||e.x+e.width<=t.x||e.y>=t.y+t.height||e.y+e.height<=t.y)return!1;if(e.x<t.x+t.width&&e.x+e.width>t.x){if(e.y>t.y&&e.y<t.y+t.height)(n=t).height=e.y-n.y,this.freeRectangles.push(n);if(e.y+e.height<t.y+t.height)(n=t).y=e.y+e.height,n.height=t.y+t.height-(e.y+e.height),this.freeRectangles.push(n)}if(e.y<t.y+t.height&&e.y+e.height>t.y){var n;if(e.x>t.x&&e.x<t.x+t.width)(n=t).width=e.x-n.x,this.freeRectangles.push(n);if(e.x+e.width<t.x+t.width)(n=t).x=e.x+e.width,n.width=t.x+t.width-(e.x+e.width),this.freeRectangles.push(n)}return!0},e.prototype.pruneFreeList=function(){for(var t=0;t<this.freeRectangles.length;++t)for(var e=t+1;e<this.freeRectangles.length;++e){if(this.isContainedIn(this.freeRectangles[t],this.freeRectangles[e])){new linq.List(this.freeRectangles).removeAt(t),--t;break}this.isContainedIn(this.freeRectangles[e],this.freeRectangles[t])&&(new linq.List(this.freeRectangles).removeAt(e),--e)}},e.prototype.isContainedIn=function(t,e){return t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height},e}();t.MaxRectsBinPack=e}(es||(es={}));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=[],h=0;h<t.length;)r=(e=t.charCodeAt(h++))>>2,o=(3&e)<<4|(n=t.charCodeAt(h++))>>4,s=(15&n)<<2|(i=t.charCodeAt(h++))>>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(){}return e.oppositeEdge=function(e){switch(e){case t.Edge.bottom:return t.Edge.top;case t.Edge.top:return t.Edge.bottom;case t.Edge.left:return t.Edge.right;case t.Edge.right:return t.Edge.left}},e.isHorizontal=function(e){return e==t.Edge.right||e==t.Edge.left},e.isVertical=function(e){return e==t.Edge.top||e==t.Edge.bottom},e}();t.EdgeExt=e}(es||(es={})),function(t){var e=function(){function t(){}return t.toNumber=function(t){return null==t?0:Number(t)},t}();t.NumberExtension=e}(es||(es={}));var linq,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.boundsFromPolygonVector=function(e){for(var n=Number.POSITIVE_INFINITY,i=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=Number.NEGATIVE_INFINITY,s=0;s<e.length;s++){var a=e[s];a.x<n&&(n=a.x),a.x>r&&(r=a.x),a.y<i&&(i=a.y),a.y>o&&(o=a.y)}return this.fromMinMaxVector(new t.Vector2(n,i),new t.Vector2(r,o))},e.fromMinMaxVector=function(e,n){return new t.Rectangle(e.x,e.y,n.x-e.x,n.y-e.y)},e.getSweptBroadphaseBounds=function(e,n,i){var r=t.Rectangle.empty;return r.x=n>0?e.x:e.x+n,r.y=i>0?e.y:e.y+i,r.width=n>0?n+e.width:e.width-n,r.height=i>0?i+e.height:e.height-i,r},e.prototype.collisionCheck=function(t,e,n,i){n.value=i.value=0;var r=e.x-(t.x+t.width),o=e.x+e.width-t.x,s=e.y-(t.y+t.height),a=e.y+e.height-t.y;return!(r>0||o<0||s>0||a<0)&&(n.value=Math.abs(r)<o?r:o,i.value=Math.abs(s)<a?s:a,Math.abs(n.value)<Math.abs(i.value)?i.value=0:n.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),h=a.x-c.x,u=a.y-c.y,l=i+o,p=r+s;if(Math.abs(h)>=l||Math.abs(u)>=p)return t.Vector2.zero;var f=h>0?l-h:-l-h,d=u>0?p-u:-p-u;return new t.Vector2(f,d)},e}();t.RectangleExt=e}(es||(es={})),function(t){var e=function(){function t(){}return t.premultiplyAlpha=function(t){for(var e=t[0],n=0;n<t.length;n+=4)if(255!=e[n+3]){var i=e[n+3]/255;e[n+0]=e[n+0]*i,e[n+1]=e[n+1]*i,e[n+2]=e[n+2]*i}},t}();t.TextureUtils=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.perpendicularFlip=function(e){return new t.Vector2(-e.y,e.x)},e.angle=function(e,n){return this.normalize(e),this.normalize(n),Math.acos(t.MathHelper.clamp(t.Vector2.dot(e,n),-1,1))*t.MathHelper.Rad2Deg},e.getRayIntersection=function(e,n,i,r,o){void 0===o&&(o=new t.Vector2);var s=n.y-e.y,a=n.x-e.x,c=r.y-i.y,h=r.x-i.x;if(s*h==c*a)return o.x=Number.NaN,o.y=Number.NaN,!1;var u=((i.y-e.y)*a*h+s*h*e.x-c*a*i.x)/(s*h-c*a),l=e.y+s/a*(u-e.x);return o.x=u,o.y=l,!0},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(e,n,i){void 0===i&&(i=new t.Vector2);var r=e.x*n.m11+e.y*n.m21+n.m31,o=e.x*n.m12+e.y*n.m22+n.m32;i.x=r,i.y=o},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={})),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(){return function(){this.position=t.Vector2.zero,this.begin=!1,this.segment=null,this.angle=0}}();t.EndPoint=e;var n=function(){function t(){}return t.prototype.compare=function(t,e){return t.angle>e.angle?1:t.angle<e.angle?-1:!t.begin&&e.begin?1:t.begin&&!e.begin?-1:0},t}();t.EndPointComparer=n}(es||(es={})),function(t){var e=function(){return function(){this.p1=null,this.p2=null}}();t.Segment=e}(es||(es={})),function(t){var e=function(){function e(e,n){this.lineCountForCircleApproximation=10,this._radius=0,this._origin=t.Vector2.zero,this._isSpotLight=!1,this._spotStartAngle=0,this._spotEndAngle=0,this._endPoints=[],this._segments=[],this._origin=e,this._radius=n,this._radialComparer=new t.EndPointComparer}return e.prototype.addColliderOccluder=function(e){if(e instanceof t.BoxCollider&&0==e.rotation)this.addSquareOccluder(e.bounds);else if(e instanceof t.PolygonCollider)for(var n=e.shape,i=0;i<n.points.length;i++){var r=i-1;0==i&&(r+=n.points.length),this.addLineOccluder(t.Vector2.add(n.points[r],n.position),t.Vector2.add(n.points[i],n.position))}else e instanceof t.CircleCollider&&this.addCircleOccluder(e.absolutePosition,e.radius)},e.prototype.addCircleOccluder=function(e,n){for(var i=t.Vector2.subtract(e,this._origin),r=Math.atan2(i.y,i.x),o=Math.PI/this.lineCountForCircleApproximation,s=r+t.MathHelper.PiOver2,a=t.MathHelper.angleToVector(s,n).add(e),c=1;c<this.lineCountForCircleApproximation;c++){var h=t.MathHelper.angleToVector(s+c*o,n).add(e);this.addLineOccluder(a,h),a=h}},e.prototype.addLineOccluder=function(t,e){this.addSegment(t,e)},e.prototype.addSquareOccluder=function(e){var n=new t.Vector2(e.right,e.top),i=new t.Vector2(e.left,e.bottom),r=new t.Vector2(e.right,e.bottom);this.addSegment(e.location,n),this.addSegment(n,r),this.addSegment(r,i),this.addSegment(i,e.location)},e.prototype.addSegment=function(e,n){var i=new t.Segment,r=new t.EndPoint,o=new t.EndPoint;r.position=e,r.segment=i,o.position=n,o.segment=i,i.p1=r,i.p2=o,this._segments.push(i),this._endPoints.push(r),this._endPoints.push(o)},e.prototype.clearOccluders=function(){this._segments.length=0,this._endPoints.length=0},e.prototype.begin=function(t,e){this._origin=t,this._radius=e,this._isSpotLight=!1},e.prototype.end=function(){var n,i,r=t.ListPool.obtain();this.updateSegments(),this._endPoints.sort(this._radialComparer.compare);for(var o=0,s=0;s<2;s++)try{for(var a=__values(this._endPoints),c=a.next();!c.done;c=a.next()){var h=c.value,u=0==e._openSegments.size()?null:e._openSegments.getHead().element;if(h.begin){for(var l=e._openSegments.getHead();null!=l&&this.isSegmentInFrontOf(h.segment,l.element,this._origin);)l=l.next;null==l?e._openSegments.push(h.segment):e._openSegments.insert(h.segment,e._openSegments.indexOf(l.element))}else e._openSegments.remove(h.segment);var p=null;0!=e._openSegments.size()&&(p=e._openSegments.getHead().element),u!=p&&(1==s&&(!this._isSpotLight||e.between(o,this._spotStartAngle,this._spotEndAngle)&&e.between(h.angle,this._spotStartAngle,this._spotEndAngle))&&this.addTriangle(r,o,h.angle,u),o=h.angle)}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}return e._openSegments.clear(),this.clearOccluders(),r},e.prototype.addTriangle=function(n,i,r,o){var s=this._origin.clone(),a=new t.Vector2(this._origin.x+Math.cos(i),this._origin.y+Math.sin(i)),c=t.Vector2.zero,h=t.Vector2.zero;null!=o?(c.x=o.p1.position.x,c.y=o.p1.position.y,h.x=o.p2.position.x,h.y=o.p2.position.y):(c.x=this._origin.x+Math.cos(i)*this._radius*2,c.y=this._origin.y+Math.sin(i)*this._radius*2,h.x=this._origin.x+Math.cos(r)*this._radius*2,h.y=this._origin.y+Math.sin(r)*this._radius*2);var u=e.lineLineIntersection(c,h,s,a);a.x=this._origin.x+Math.cos(r),a.y=this._origin.y+Math.sin(r);var l=e.lineLineIntersection(c,h,s,a);n.push(u),n.push(l)},e.lineLineIntersection=function(e,n,i,r){var o=((r.x-i.x)*(e.y-i.y)-(r.y-i.y)*(e.x-i.x))/((r.y-i.y)*(n.x-e.x)-(r.x-i.x)*(n.y-e.y));return new t.Vector2(e.x+o*(n.x-e.x),e.y+o*(n.y-e.y))},e.between=function(t,e,n){return t=(360+t%360)%360,(e=(36e5+e)%360)<(n=(36e5+n)%360)?e<=t&&t<=n:e<=t||t<=n},e.prototype.loadRectangleBoundaries=function(){this.addSegment(new t.Vector2(this._origin.x-this._radius,this._origin.y-this._radius),new t.Vector2(this._origin.x+this._radius,this._origin.y-this._radius)),this.addSegment(new t.Vector2(this._origin.x-this._radius,this._origin.y+this._radius),new t.Vector2(this._origin.x+this._radius,this._origin.y+this._radius)),this.addSegment(new t.Vector2(this._origin.x-this._radius,this._origin.y-this._radius),new t.Vector2(this._origin.x-this._radius,this._origin.y+this._radius)),this.addSegment(new t.Vector2(this._origin.x+this._radius,this._origin.y-this._radius),new t.Vector2(this._origin.x+this._radius,this._origin.y+this._radius))},e.prototype.isSegmentInFrontOf=function(t,n,i){var r=e.isLeftOf(t.p2.position,t.p1.position,e.interpolate(n.p1.position,n.p2.position,.01)),o=e.isLeftOf(t.p2.position,t.p1.position,e.interpolate(n.p2.position,n.p1.position,.01)),s=e.isLeftOf(t.p2.position,t.p1.position,i),a=e.isLeftOf(n.p2.position,n.p1.position,e.interpolate(t.p1.position,t.p2.position,.01)),c=e.isLeftOf(n.p2.position,n.p1.position,e.interpolate(t.p2.position,t.p1.position,.01)),h=e.isLeftOf(n.p2.position,n.p1.position,i);return a==c&&c!=h||r==o&&o==s},e.interpolate=function(e,n,i){return new t.Vector2(e.x*(1-i)+n.x*i,e.y*(1-i)+n.y*i)},e.isLeftOf=function(t,e,n){return(e.x-t.x)*(n.y-t.y)-(e.y-t.y)*(n.x-t.x)<0},e.prototype.updateSegments=function(){var t,e;try{for(var n=__values(this._segments),i=n.next();!i.done;i=n.next()){var r=i.value;r.p1.angle=Math.atan2(r.p1.position.y-this._origin.y,r.p1.position.x-this._origin.x),r.p2.angle=Math.atan2(r.p2.position.y-this._origin.y,r.p2.position.x-this._origin.x);var o=r.p2.angle-r.p1.angle;o<=-Math.PI&&(o+=2*Math.PI),o>Math.PI&&(o-=2*Math.PI),r.p1.begin=o>0,r.p2.begin=!r.p1.begin}}catch(e){t={error:e}}finally{try{i&&!i.done&&(e=n.return)&&e.call(n)}finally{if(t)throw t.error}}this._isSpotLight&&(this._spotStartAngle=this._segments[0].p2.angle,this._spotEndAngle=this._segments[1].p2.angle)},e._cornerCache=[],e._openSegments=new t.LinkedList,e}();t.VisibilityComputer=e}(es||(es={})),function(t){var e=function(){function e(){this._timeInSeconds=0,this._repeats=!1,this._isDone=!1,this._elapsedTime=0}return e.prototype.getContext=function(){return this.context},e.prototype.reset=function(){this._elapsedTime=0},e.prototype.stop=function(){this._isDone=!0},e.prototype.tick=function(){return!this._isDone&&this._elapsedTime>this._timeInSeconds&&(this._elapsedTime-=this._timeInSeconds,this._onTime(this),this._isDone||this._repeats||(this._isDone=!0)),this._elapsedTime+=t.Time.deltaTime,this._isDone},e.prototype.initialize=function(t,e,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={})); \ No newline at end of file diff --git a/source/src/ECS/Components/ComponentPool.ts b/source/src/ECS/Components/ComponentPool.ts deleted file mode 100644 index 8b52e501..00000000 --- a/source/src/ECS/Components/ComponentPool.ts +++ /dev/null @@ -1,24 +0,0 @@ -module es { - export class ComponentPool<T extends PooledComponent> { - private _cache: T[]; - private _type: any; - - constructor(typeClass: any) { - this._type = typeClass; - this._cache = []; - } - - public obtain(): T { - try { - return this._cache.length > 0 ? this._cache.shift() : new this._type(); - } catch (err) { - throw new Error(this._type + err); - } - } - - public free(component: T) { - component.reset(); - this._cache.push(component); - } - } -} diff --git a/source/src/ECS/Components/PooledComponent.ts b/source/src/ECS/Components/PooledComponent.ts deleted file mode 100644 index 1d289140..00000000 --- a/source/src/ECS/Components/PooledComponent.ts +++ /dev/null @@ -1,6 +0,0 @@ -module es { - /** 回收实例的组件类型。 */ - export abstract class PooledComponent extends Component { - public abstract reset(); - } -} diff --git a/source/src/ECS/Entity.ts b/source/src/ECS/Entity.ts index 06d6c116..0e2c0c47 100644 --- a/source/src/ECS/Entity.ts +++ b/source/src/ECS/Entity.ts @@ -380,6 +380,16 @@ module es { this.components.update(); } + /** + * 创建组件的新实例。返回实例组件 + * @param componentType + */ + public createComponent<T extends Component>(componentType: new () => T): T { + let component = new componentType(); + this.addComponent(component); + return component; + } + /** * 将组件添加到组件列表中。返回组件。 * @param component diff --git a/source/src/ECS/Systems/DelayedIteratingSystem.ts b/source/src/ECS/Systems/DelayedIteratingSystem.ts new file mode 100644 index 00000000..1450672e --- /dev/null +++ b/source/src/ECS/Systems/DelayedIteratingSystem.ts @@ -0,0 +1,131 @@ +///<reference path="./EntitySystem.ts"/> +module es { + /** + * 追踪每个实体的冷却时间,当实体的计时器耗尽时进行处理 + * + * 一个示例系统将是ExpirationSystem,该系统将在特定生存期后删除实体。 + * 你不必运行会为每个实体递减timeLeft值的系统 + * 而只需使用此系统在寿命最短的实体时在将来执行 + * 然后重置系统在未来的某一个最短命实体的时间运行 + * + * 另一个例子是一个动画系统 + * 你知道什么时候你必须对某个实体进行动画制作,比如300毫秒内。 + * 所以你可以设置系统以300毫秒为单位运行来执行动画 + * + * 这将在某些情况下节省CPU周期 + */ + export abstract class DelayedIteratingSystem extends EntitySystem { + /** + * 一个实体应被处理的时间 + */ + private delay: number = 0; + /** + * 如果系统正在运行,并倒计时延迟 + */ + private running: boolean = false; + /** + * 倒计时 + */ + private acc: number = 0; + + constructor(matcher: Matcher) { + super(matcher); + } + + protected process(entities: Entity[]) { + let processed = entities.length; + if (processed == 0) { + this.stop(); + return; + } + + this.delay = Number.MAX_VALUE; + for (let i = 0; processed > i; i++) { + let e = entities[i]; + this.processDelta(e, this.acc); + let remaining = this.getRemainingDelay(e); + if (remaining <= 0) { + this.processExpired(e); + } else { + this.offerDelay(remaining); + } + } + + this.acc = 0; + } + + protected checkProcessing() { + if (this.running) { + this.acc += Time.deltaTime; + return this.acc >= this.delay; + } + return false; + } + + /** + * 只有当提供的延迟比系统当前计划执行的时间短时,才会重新启动系统。 + * 如果系统已经停止(不运行),那么提供的延迟将被用来重新启动系统,无论其值如何 + * 如果系统已经在倒计时,并且提供的延迟大于剩余时间,系统将忽略它。 + * 如果提供的延迟时间短于剩余时间,系统将重新启动,以提供的延迟时间运行。 + * @param offeredDelay + */ + public offerDelay(offeredDelay: number) { + if (!this.running) { + this.running = true; + this.delay = offeredDelay; + } else { + this.delay = Math.min(this.delay, offeredDelay); + } + } + + /** + * 处理本系统感兴趣的实体 + * 从实体定义的延迟中抽象出accumulativeDelta + * @param entity + * @param accumulatedDelta 本系统最后一次执行后的delta时间 + */ + protected abstract processDelta(entity: Entity, accumulatedDelta: number); + + protected abstract processExpired(entity: Entity); + + /** + * 返回该实体处理前的延迟时间 + * @param entity + */ + protected abstract getRemainingDelay(entity: Entity): number; + + /** + * 获取系统被命令处理实体后的初始延迟 + */ + public getInitialTimeDelay() { + return this.delay; + } + + /** + * 获取系统计划运行前的时间 + * 如果系统没有运行,则返回零 + */ + public getRemainingTimeUntilProcessing(): number { + if (this.running) { + return this.delay - this.acc; + } + + return 0; + } + + /** + * 检查系统是否正在倒计时处理 + */ + public isRunning(): boolean { + return this.running; + } + + /** + * 停止系统运行,中止当前倒计时 + */ + public stop() { + this.running = false; + this.acc = 0; + } + } +} \ No newline at end of file diff --git a/source/src/ECS/Systems/EntitySystem.ts b/source/src/ECS/Systems/EntitySystem.ts index ec4d5672..5045e7c4 100644 --- a/source/src/ECS/Systems/EntitySystem.ts +++ b/source/src/ECS/Systems/EntitySystem.ts @@ -11,6 +11,9 @@ module es { private _scene: Scene; + /** + * 这个系统所属的场景 + */ public get scene() { return this._scene; } @@ -45,42 +48,53 @@ module es { this.onAdded(entity); } - public onAdded(entity: Entity) { - } + public onAdded(entity: Entity) { } public remove(entity: Entity) { new linq.List(this._entities).remove(entity); this.onRemoved(entity); } - public onRemoved(entity: Entity) { - - } + public onRemoved(entity: Entity) { } public update() { - this.begin(); - this.process(this._entities); + if (this.checkProcessing()) { + this.begin(); + this.process(this._entities); + } } public lateUpdate() { - this.lateProcess(this._entities); - this.end(); - } - - protected begin() { - - } - - protected process(entities: Entity[]) { - - } - - protected lateProcess(entities: Entity[]) { - - } - - protected end() { - + if (this.checkProcessing()) { + this.lateProcess(this._entities); + this.end(); + } + } + + /** + * 在系统处理开始前调用 + * 在下一个系统开始处理或新的处理回合开始之前(以先到者为准),使用此方法创建的任何实体都不会激活 + */ + protected begin() { } + + protected process(entities: Entity[]) { } + + protected lateProcess(entities: Entity[]) { } + + /** + * 系统处理完毕后调用 + */ + protected end() { } + + /** + * 系统是否需要处理 + * + * 在启用系统时有用,但仅偶尔需要处理 + * 这只影响处理,不影响事件或订阅列表 + * @returns 如果系统应该处理,则为true,如果不处理则为false。 + */ + protected checkProcessing() { + return true; } } } diff --git a/source/src/ECS/Systems/IntervalIteratingSystem.ts b/source/src/ECS/Systems/IntervalIteratingSystem.ts new file mode 100644 index 00000000..ffde462b --- /dev/null +++ b/source/src/ECS/Systems/IntervalIteratingSystem.ts @@ -0,0 +1,25 @@ +///<reference path="./IntervalSystem.ts"/> +module es { + /** + * 每x个ticks处理一个实体的子集 + * + * 典型的用法是每隔一定的时间间隔重新生成弹药或生命值 + * 而无需在每个游戏循环中都进行 + * 而是每100毫秒一次或每秒 + */ + export abstract class IntervalIteratingSystem extends IntervalSystem { + constructor(matcher: Matcher, interval: number) { + super(matcher, interval); + } + + /** + * 处理本系统感兴趣的实体 + * @param entity + */ + public abstract processEntity(entity: Entity); + + protected process(entities: Entity[]) { + entities.forEach(entity => this.processEntity(entity)); + } + } +} \ No newline at end of file diff --git a/source/src/ECS/Systems/IntervalSystem.ts b/source/src/ECS/Systems/IntervalSystem.ts new file mode 100644 index 00000000..31178852 --- /dev/null +++ b/source/src/ECS/Systems/IntervalSystem.ts @@ -0,0 +1,40 @@ +module es { + /** + * 实体系统以一定的时间间隔进行处理 + */ + export abstract class IntervalSystem extends EntitySystem { + /** + * 累积增量以跟踪间隔 + */ + protected acc: number = 0; + /** + * 更新之间需要等待多长时间 + */ + private readonly interval: number = 0; + private intervalDelta: number = 0; + + constructor(matcher: Matcher, interval: number) { + super(matcher); + this.interval = interval; + } + + protected checkProcessing() { + this.acc += Time.deltaTime; + if (this.acc >= this.interval) { + this.acc -= this.interval; + this.intervalDelta = (this.acc - this.intervalDelta); + + return true; + } + + return false; + } + + /** + * 获取本系统上次处理后的实际delta值 + */ + protected getIntervalDelta() { + return this.interval + this.intervalDelta; + } + } +} \ No newline at end of file