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

1 line
61 KiB
JavaScript
Raw Normal View History

2020-06-11 20:36:36 +08:00
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,o){return e.call(arguments[2],n,o,t)&&i.push(n),i},[]);for(var i=[],n=0,o=t.length;n<o;n++){var r=t[n];e.call(arguments[2],r,n,t)&&i.push(r)}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,o){return i.push(e.call(arguments[2],n,o,t)),i},[]);for(var i=[],n=0,o=t.length;n<o;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 o=e(t),r=e(n);return i?i(o,r):o>r?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,i){return t.sort(function(t,n){var o=e(t),r=e(n);return i?-i(o,r):o<r?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,o,r){var s=JSON.stringify(e.call(arguments[1],o,r,t)),a=i.findIndex(function(t){return t===s});return a<0&&(a=i.push(s)-1),n[a]||(n[a]=[]),n[a].push(o),n},[])}for(var n=[],o=[],r=function(i,r){var a=JSON.stringify(e.call(s[1],t[i],i,t)),h=o.findIndex(function(t){return t===a});h<0&&(h=o.push(a)-1),n[h]||(n[h]=[]),n[h].push(t[i])},s=arguments,a=0,h=t.length;a<h;a++)r(a);return n}(this,t)},Array.prototype.sum=function(t){return function(t,e){for(var i,n=0,o=t.length;n<o;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,o=!1,r=new Map;r.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 o=!0,"break";t.getNeighbors(e.data).forEach(function(o){var h=s.get(e.data)+t.cost(e.data,o);if(!n.hasKey(s,o)||h<s.get(o)){s.set(o,h);var c=h+t.heuristic(o,i);a.enqueue(new AStarNode(o),c),r.set(o,e.data)}})};a.count>0;){if("break"===h())break}return o?this.recontructPath(r,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,o=t.keys(),r=t.values();i=o.next(),n=r.next(),!i.done;)if(JSON.stringify(i.value)==JSON.stringify(e))return n.value;return null},t