Files
esengine/source/bin/framework.min.js
2020-06-08 11:49:45 +08:00

1 line
7.4 KiB
JavaScript

window.framework={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var e in n)n.hasOwnProperty(e)&&(t[e]=n[e])};return function(n,e){function r(){this.constructor=n}t(n,e),n.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}}(),Array.prototype.findIndex=function(t){return function(t,n){for(var e=0,r=t.length;e<r;e++)if(n.call(arguments[2],t[e],e,t))return e;return-1}(this,t)},Array.prototype.any=function(t){return function(t,n){return t.findIndex(n)>-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,n){var e=t.findIndex(n);return-1==e?null:t[e]}(this,t)},Array.prototype.find=function(t){return function(t,n){return t.firstOrDefault(n)}(this,t)},Array.prototype.where=function(t){return function(t,n){if("function"==typeof t.reduce)return t.reduce(function(e,r,i){return n.call(arguments[2],r,i,t)&&e.push(r),e},[]);for(var e=[],r=0,i=t.length;r<i;r++){var o=t[r];n.call(arguments[2],o,r,t)&&e.push(o)}return e}(this,t)},Array.prototype.count=function(t){return function(t,n){return t.where(n).length}(this,t)},Array.prototype.findAll=function(t){return function(t,n){return t.where(n)}(this,t)},Array.prototype.contains=function(t){return function(t,n){for(var e=0,r=t.length;e<r;e++)if(JSON.stringify(t[e])==JSON.stringify(n))return!0;return!1}(this,t)},Array.prototype.removeAll=function(t){!function(t,n){var e;do{(e=t.findIndex(n))>=0&&t.splice(e,1)}while(e>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,n){var e=t.findIndex(function(t){return t===n});return e>=0&&(t.splice(e,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,n){t.splice(n,1)}(this,t)},Array.prototype.removeRange=function(t,n){return function(t,n,e){t.splice(n,e)}(this,t,n)},Array.prototype.select=function(t){return function(t,n){if("function"==typeof t.reduce)return t.reduce(function(e,r,i){return e.push(n.call(arguments[2],r,i,t)),e},[]);for(var e=[],r=0,i=t.length;r<i;r++)e.push(n.call(arguments[2],t[r],r,t));return e}(this,t)},Array.prototype.orderBy=function(t,n){return function(t,n,e){return t.sort(function(t,r){var i=n(t),o=n(r);return e?e(i,o):i>o?1:-1}),t}(this,t,n)},Array.prototype.orderByDescending=function(t,n){return function(t,n,e){return t.sort(function(t,r){var i=n(t),o=n(r);return e?-e(i,o):i<o?1:-1}),t}(this,t,n)},Array.prototype.groupBy=function(t){return function(t,n){if("function"==typeof t.reduce){var e=[];return t.reduce(function(r,i,o){var u=JSON.stringify(n.call(arguments[1],i,o,t)),c=e.findIndex(function(t){return t===u});return c<0&&(c=e.push(u)-1),r[c]||(r[c]=[]),r[c].push(i),r},[])}for(var r=[],i=[],o=function(e,o){var c=JSON.stringify(n.call(u[1],t[e],e,t)),s=i.findIndex(function(t){return t===c});s<0&&(s=i.push(c)-1),r[s]||(r[s]=[]),r[s].push(t[e])},u=arguments,c=0,s=t.length;c<s;c++)o(c);return r}(this,t)},Array.prototype.sum=function(t){return function(t,n){for(var e,r=0,i=t.length;r<i;r++)0==r?e=n?n.call(arguments[2],t[r],r,t):t[r]:e+=n?n.call(arguments[2],t[r],r,t):t[r];return e}(this,t)};var Entity=function(){function t(t){this.name=t,this.transform=new Transform(this)}return t.prototype.attachToScene=function(t){this.scene=t,t.entities.push(this);for(var n=0;n<this.transform.childCount;n++)this.transform.getChild(n).entity.attachToScene(t)},t.prototype.destory=function(){this.scene.entities.remove(this),this.transform.parent=null;for(var t=this.transform.childCount-1;t>=0;t--){this.transform.getChild(t).entity.destory()}},t}(),Scene=function(t){function n(n){var e=t.call(this)||this;return e.entities=[],e.camera=new Camera(n),e.addEventListener(egret.Event.ACTIVATE,e.onActive,e),e.addEventListener(egret.Event.DEACTIVATE,e.onDeactive,e),e}return __extends(n,t),n.prototype.createEntity=function(t){var n=new Entity(t);return this.addEntity(n)},n.prototype.addEntity=function(t){return this.entities.push(t),t.scene=this,t},n.prototype.setActive=function(){return SceneManager.setActiveScene(this),this},n.prototype.initialize=function(){},n.prototype.onActive=function(){},n.prototype.onDeactive=function(){},n.prototype.destory=function(){this.removeEventListener(egret.Event.DEACTIVATE,this.onDeactive,this),this.removeEventListener(egret.Event.ACTIVATE,this.onActive,this),this.camera.destory(),this.camera=null,this.entities.forEach(function(t){return t.destory()}),this.entities.length=0},n}(egret.DisplayObjectContainer),SceneManager=function(){function t(){}return t.createScene=function(t,n){return n.name=t,this._loadedScenes.set(t,n),n},t.setActiveScene=function(t){if(this._activeScene){if(this._activeScene==t)return;this._lastScene=this._activeScene,this._activeScene.destory()}return this._activeScene=t,this._activeScene.initialize(),t},t._loadedScenes=new Map,t}(),Transform=function(){function t(t){this.entity=t,this._children=[]}return Object.defineProperty(t.prototype,"childCount",{get:function(){return this._children.length},enumerable:!0,configurable:!0}),t.prototype.getChild=function(t){return this._children[t]},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},set:function(t){this.setParent(t)},enumerable:!0,configurable:!0}),t.prototype.setParent=function(t){return this._parent==t?this:(this._parent&&this._parent._children.remove(this),t&&t._children.push(this),this._parent=t,this)},t}(),Camera=function(){function t(t){this._displayContent=t}return t.prototype.destory=function(){this._displayContent=null},t}(),MathHelper=function(){function t(){}return t.ToDegrees=function(t){return 57.29577951308232*t},t.ToRadians=function(t){return.017453292519943295*t},t}(),Matrix2D=function(){function t(t,n,e,r,i,o){this.m11=t,this.m12=n,this.m21=e,this.m22=r,this.m31=i,this.m32=o}return Object.defineProperty(t,"identity",{get:function(){return t._identity},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"translation",{get:function(){return new Vector2(this.m31,this.m32)},set:function(t){this.m31=t.x,this.m32=t.y},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return Math.atan2(this.m21,this.m11)},set:function(t){var n=Math.cos(t),e=Math.sin(t);this.m11=n,this.m12=e,this.m21=-e,this.m22=n},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotationDegrees",{get:function(){return MathHelper.ToDegrees(this.rotation)},set:function(t){this.rotation=MathHelper.ToRadians(t)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scale",{get:function(){return new Vector2(this.m11,this.m22)},set:function(t){this.m11=t.x,this.m12=t.y},enumerable:!0,configurable:!0}),t.add=function(t,n){return t.m11+=n.m11,t.m12+=n.m12,t.m21+=n.m21,t.m22+=n.m22,t.m31+=n.m31,t.m32+=n.m32,t},t.divide=function(t,n){return t.m11/=n.m11,t.m12/=n.m12,t.m21/=n.m21,t.m22/=n.m22,t.m31/=n.m31,t.m32/=n.m32,t},t.multiply=function(t,n){var e=t.m11*n.m11+t.m12*n.m21,r=t.m11*n.m12+t.m12*n.m22,i=t.m21*n.m11+t.m22*n.m21,o=t.m21*n.m12+t.m22*n.m22,u=t.m31*n.m11+t.m32*n.m21+n.m31,c=t.m31*n.m12+t.m32*n.m22+n.m32;return t.m11=e,t.m12=r,t.m21=i,t.m22=o,t.m31=u,t.m32=c,t},t._identity=new t(1,0,0,1,0,0),t}(),Vector2=function(){function t(t,n){this.x=t,this.y=n}return t.add=function(t,n){return t.x+=n.x,t.y+=n.y,t},t.divide=function(t,n){return t.x/=n.x,t.y/=n.y,t},t.multiply=function(t,n){return t.x*=n.x,t.y*=n.y,t},t.subtract=function(t,n){return t.x-=n.x,t.y-=n.y,t},t.prototype.normalize=function(){var t=1/Math.sqrt(this.x*this.x+this.y*this.y);this.x*=t,this.y*=t},t}();