1 line
32 KiB
JavaScript
1 line
32 KiB
JavaScript
|
|
window.es={},window.__extends=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}}();var __awaiter=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))(function(n,a){function o(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){e.done?n(e.value):new i(function(t){t(e.value)}).then(o,s)}l((r=r.apply(e,t||[])).next())})},__generator=this&&this.__generator||function(e,t){var i,r,n,a,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,r&&(n=2&a[0]?r.return:a[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,a[1])).done)return n;switch(r=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(n=(n=o.trys).length>0&&n[n.length-1])&&(6===a[0]||2===a[0])){o=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){o.label=a[1];break}if(6===a[0]&&o.label<n[1]){o.label=n[1],n=a;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(a);break}n[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{i=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}};!function(e){var t=function(t){function i(i,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var a=t.call(this)||this;return a.physicsLayer=new e.Ref(1),a.toContainer=!1,a.tiledMap=i,a._shouldCreateColliders=n,a.displayObject=new egret.DisplayObjectContainer,r&&(a.collisionLayer=i.tileLayers.find(function(e){return e.name==r})),a}return __extends(i,t),Object.defineProperty(i.prototype,"width",{get:function(){return this.tiledMap.width*this.tiledMap.tileWidth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.tiledMap.height*this.tiledMap.tileHeight},enumerable:!0,configurable:!0}),i.prototype.setLayerToRender=function(e){this.layerIndicesToRender=[],this.layerIndicesToRender[0]=this.getLayerIndex(e)},i.prototype.setLayersToRender=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.layerIndicesToRender=[];for(var i=0;i<e.length;i++)this.layerIndicesToRender[i]=this.getLayerIndex(e[i])},i.prototype.getLayerIndex=function(e){var t=this.tiledMap.getLayer(e);for(var i in this.tiledMap.layers)if(this.tiledMap.layers.hasOwnProperty(i)&&this.tiledMap.layers[i]==t)return 0;return-1},i.prototype.getRowAtWorldPosition=function(e){return e-=this.entity.transform.position.y+this._localOffset.y,this.tiledMap.worldToTilePositionY(e)},i.prototype.getColumnAtWorldPosition=function(e){return e-=this.entity.transform.position.x+this._localOffset.x,this.tiledMap.worldToTilePositionX(e)},i.prototype.onEntityTransformChanged=function(e){this._shouldCreateColliders&&e==transform.Component.position&&(this.removeColliders(),this.addColliders())},i.prototype.onAddedToEntity=function(){this.addColliders()},i.prototype.onRemovedFromEntity=function(){this.removeColliders()},i.prototype.update=function(){this.tiledMap.update()},i.prototype.render=function(t){if(this.sync(t),this.layerIndicesToRender)for(var i=0;i<this.tiledMap.layers.length;i++)this.tiledMap.layers[i].visible&&this.layerIndicesToRender.contains(i)&&e.TiledRendering.renderLayerRenderCamera(this.tiledMap.layers[i],this.toContainer?null:this.displayObject,e.Vector2.add(this.entity.transform.position,this._localOffset),this.transform.scale,this.renderLayer,t.bounds);else e.TiledRendering.renderMap(this.tiledMap,this.toContainer?null:this.displayObject,e.Vector2.add(this.entity.transform.position,this._localO
|