Files
esengine/demo/libs/framework/framework.min.js

1 line
82 KiB
JavaScript
Raw Normal View History

window.framework={},window.__extends=this&&this.__extends||function(){var t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])};return function(e,i){function n(){this.constructor=e}t(e,i),e.prototype=null===i?Object.create(i):(n.prototype=i.prototype,new n)}}(),Array.prototype.findIndex=function(t){return function(t,e){for(var i=0,n=t.length;i<n;i++)if(e.call(arguments[2],t[i],i,t))return i;return-1}(this,t)},Array.prototype.any=function(t){return function(t,e){return t.findIndex(e)>-1}(this,t)},Array.prototype.firstOrDefault=function(t){return function(t,e){var i=t.findIndex(e);return-1==i?null:t[i]}(this,t)},Array.prototype.find=function(t){return function(t,e){return t.firstOrDefault(e)}(this,t)},Array.prototype.where=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return e.call(arguments[2],n,r,t)&&i.push(n),i},[]);for(var i=[],n=0,r=t.length;n<r;n++){var o=t[n];e.call(arguments[2],o,n,t)&&i.push(o)}return i}(this,t)},Array.prototype.count=function(t){return function(t,e){return t.where(e).length}(this,t)},Array.prototype.findAll=function(t){return function(t,e){return t.where(e)}(this,t)},Array.prototype.contains=function(t){return function(t,e){for(var i=0,n=t.length;i<n;i++)if(t[i]==e)return!0;return!1}(this,t)},Array.prototype.removeAll=function(t){!function(t,e){var i;do{(i=t.findIndex(e))>=0&&t.splice(i,1)}while(i>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var i=t.findIndex(function(t){return t===e});return i>=0&&(t.splice(i,1),!0)}(this,t)},Array.prototype.removeAt=function(t){return function(t,e){t.splice(e,1)}(this,t)},Array.prototype.removeRange=function(t,e){return function(t,e,i){t.splice(e,i)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(i,n,r){return i.push(e.call(arguments[2],n,r,t)),i},[]);for(var i=[],n=0,r=t.length;n<r;n++)i.push(e.call(arguments[2],t[n],n,t));return i}(this,t)},Array.prototype.orderBy=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?i(r,o):r>o?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,i){return t.sort(function(t,n){var r=e(t),o=e(n);return i?-i(r,o):r<o?1:-1}),t}(this,t,e)},Array.prototype.groupBy=function(t){return function(t,e){if("function"==typeof t.reduce){var i=[];return t.reduce(function(n,r,o){var s=JSON.stringify(e.call(arguments[1],r,o,t)),a=i.findIndex(function(t){return t===s});return a<0&&(a=i.push(s)-1),n[a]||(n[a]=[]),n[a].push(r),n},[])}for(var n=[],r=[],o=function(i,o){var a=JSON.stringify(e.call(s[1],t[i],i,t)),h=r.findIndex(function(t){return t===a});h<0&&(h=r.push(a)-1),n[h]||(n[h]=[]),n[h].push(t[i])},s=arguments,a=0,h=t.length;a<h;a++)o(a);return n}(this,t)},Array.prototype.sum=function(t){return function(t,e){for(var i,n=0,r=t.length;n<r;n++)0==n?i=e?e.call(arguments[2],t[n],n,t):t[n]:i+=e?e.call(arguments[2],t[n],n,t):t[n];return i}(this,t)};var DirtyType,ComponentTransform,PriorityQueueNode=function(){return function(){this.priority=0,this.insertionIndex=0,this.queueIndex=0}}(),AStarPathfinder=function(){function t(){}return t.search=function(t,e,i){var n=this,r=!1,o=new Map;o.set(e,e);var s=new Map,a=new PriorityQueue(1e3);a.enqueue(new AStarNode(e),0),s.set(e,0);for(var h=function(){var e=a.dequeue();if(JSON.stringify(e.data)==JSON.stringify(i))return r=!0,"break";t.getNeighbors(e.data).forEach(function(r){var h=s.get(e.data)+t.cost(e.data,r);if(!n.hasKey(s,r)||h<s.get(r)){s.set(r,h);var c=h+t.heuristic(r,i);a.enqueue(new AStarNode(r),c),o.set(r,e.data)}})};a.count>0;){if("break"===h())break}return r?this.recontructPath(o,e,i):null},t.hasKey=function(t,e){for(var i,n=t.keys();!(i=n.next()).done;)if(JSON.stringify(i.value)==JSON.stringify(e))return!0;return!1},t.getKey=function(t,e){for(var i,n,r=t.keys(),o=t.values();i=r.next(),n=o.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},t