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

1 line
38 KiB
JavaScript
Raw Normal View History

2020-06-09 19:45:09 +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 n in e)e.hasOwnProperty(n)&&(t[n]=e[n])};return function(e,n){function o(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(o.prototype=n.prototype,new o)}}(),Array.prototype.findIndex=function(t){return function(t,e){for(var n=0,o=t.length;n<o;n++)if(e.call(arguments[2],t[n],n,t))return n;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 n=t.findIndex(e);return-1==n?null:t[n]}(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(n,o,i){return e.call(arguments[2],o,i,t)&&n.push(o),n},[]);for(var n=[],o=0,i=t.length;o<i;o++){var r=t[o];e.call(arguments[2],r,o,t)&&n.push(r)}return n}(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 n=0,o=t.length;n<o;n++)if(t[n]==e)return!0;return!1}(this,t)},Array.prototype.removeAll=function(t){!function(t,e){var n;do{(n=t.findIndex(e))>=0&&t.splice(n,1)}while(n>=0)}(this,t)},Array.prototype.remove=function(t){return function(t,e){var n=t.findIndex(function(t){return t===e});return n>=0&&(t.splice(n,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,n){t.splice(e,n)}(this,t,e)},Array.prototype.select=function(t){return function(t,e){if("function"==typeof t.reduce)return t.reduce(function(n,o,i){return n.push(e.call(arguments[2],o,i,t)),n},[]);for(var n=[],o=0,i=t.length;o<i;o++)n.push(e.call(arguments[2],t[o],o,t));return n}(this,t)},Array.prototype.orderBy=function(t,e){return function(t,e,n){return t.sort(function(t,o){var i=e(t),r=e(o);return n?n(i,r):i>r?1:-1}),t}(this,t,e)},Array.prototype.orderByDescending=function(t,e){return function(t,e,n){return t.sort(function(t,o){var i=e(t),r=e(o);return n?-n(i,r):i<r?1:-1}),t}(this,t,e)},Array.prototype.groupBy=function(t){return function(t,e){if("function"==typeof t.reduce){var n=[];return t.reduce(function(o,i,r){var s=JSON.stringify(e.call(arguments[1],i,r,t)),a=n.findIndex(function(t){return t===s});return a<0&&(a=n.push(s)-1),o[a]||(o[a]=[]),o[a].push(i),o},[])}for(var o=[],i=[],r=function(n,r){var a=JSON.stringify(e.call(s[1],t[n],n,t)),h=i.findIndex(function(t){return t===a});h<0&&(h=i.push(a)-1),o[h]||(o[h]=[]),o[h].push(t[n])},s=arguments,a=0,h=t.length;a<h;a++)r(a);return o}(this,t)},Array.prototype.sum=function(t){return function(t,e){for(var n,o=0,i=t.length;o<i;o++)0==o?n=e?e.call(arguments[2],t[o],o,t):t[o]:n+=e?e.call(arguments[2],t[o],o,t):t[o];return n}(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,n){var o=this,i=!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(n))return i=!0,"break";t.getNeighbors(e.data).forEach(function(i){var h=s.get(e.data)+t.cost(e.data,i);if(!o.hasKey(s,i)||h<s.get(i)){s.set(i,h);var c=h+t.heuristic(i,n);a.enqueue(new AStarNode(i),c),r.set(i,e.data)}})};a.count>0;){if("break"===h())break}return i?this.recontructPath(r,e,n):null},t.hasKey=function(t,e){for(var n,o=t.keys();!(n=o.next()).done;)if(JSON.stringify(n.value)==JSON.stringify(e))return!0;return!1},t.getKey=function(t,e){for(var n,o,i=t.keys(),r=t.values();n=i.next(),o=r.next(),!n.done;)if(JSON.stringify(n.value)==JSON.stringify(e))return o.value;return null},t