2 lines
7.1 KiB
JavaScript
2 lines
7.1 KiB
JavaScript
|
!function(t){function o(o){for(var i,r,a=o[0],l=o[1],c=o[2],h=0,p=[];h<a.length;h++)r=a[h],e[r]&&p.push(e[r][0]),e[r]=0;for(i in l)Object.prototype.hasOwnProperty.call(l,i)&&(t[i]=l[i]);for(d&&d(o);p.length;)p.shift()();return s.push.apply(s,c||[]),n()}function n(){for(var t,o=0;o<s.length;o++){for(var n=s[o],i=!0,a=1;a<n.length;a++){var l=n[a];0!==e[l]&&(i=!1)}i&&(s.splice(o--,1),t=r(r.s=n[0]))}return t}var i={},e={1:0},s=[];function r(o){if(i[o])return i[o].exports;var n=i[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=t,r.c=i,r.d=function(t,o,n){r.o(t,o)||Object.defineProperty(t,o,{configurable:!1,enumerable:!0,get:n})},r.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},r.n=function(t){var o=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(o,"a",o),o},r.o=function(t,o){return Object.prototype.hasOwnProperty.call(t,o)},r.p="";var a=window.webpackJsonp=window.webpackJsonp||[],l=a.push.bind(a);a.push=o,a=a.slice();for(var c=0;c<a.length;c++)o(a[c]);var d=l;s.push([110,0]),n()}({107:function(t,o,n){t.exports=n.p+"726c2296b05703758a8f65fd9097f683.png"},110:function(t,o,n){"use strict";n.r(o);var i=n(109),e=n(8),s=n(108),r=n(12);class a{constructor(t,o){this.station=t,this.line=o}}const l=(t,o)=>Math.floor(Math.random()*(o-(t+1)))+t,c=(t,o)=>{const n=o.reduce((t,o)=>t+o,0),i=l(0,n);let e=0;for(let n=0;n<o.length;n+=1)if(i<(e+=o[n]))return t[n]},d=()=>new e.Point(l(0,window.innerWidth),l(0,window.innerHeight)),h=(t,o)=>Math.abs(t.x-o.x)<1&&Math.abs(t.y-o.y)<1,p=(t,o)=>{const n=t.x-o.x,i=t.y-o.y;return Math.sqrt(n*n+i*i)},u=(t,o,n,i,e)=>(t-o)*(e-i)/(n-o)+i;var f,w;(w=f||(f={}))[w.North=0]="North",w[w.Northeast=1]="Northeast",w[w.East=2]="East",w[w.Southeast=3]="Southeast",w[w.South=4]="South",w[w.Southwest=5]="Southwest",w[w.West=6]="West",w[w.Northwest=7]="Northwest";const g=(t,o)=>{const n=((t,o)=>180+((t,o)=>Math.atan2(-(o.x-t.x),o.y-t.y))(t,o)*(180/Math.PI))(t,o);let i=null;if(n>=337.5||n<22.5)i=f.North;else if(n>=22.5&&n<67.5)i=f.Northeast;else if(n>=67.5&&n<112.5)i=f.East;else if(n>=112.5&&n<157.5)i=f.Southeast;else if(n>=157.5&&n<202.5)i=f.South;else if(n>=202.5&&n<247.5)i=f.Southwest;else if(n>=247.5&&n<292.5)i=f.West;else{if(!(n>=292.5&&n<337.5))throw Error("Angle between points is not a valid degree");i=f.Northwest}return i};let x=0;class y{static largestStation(t){let o=null;for(const n of t)(null===o||n.population>o.population)&&(o=n);return o}static stationsWithinRadius(t,o,n){return t.filter(t=>p(o,t.location)<=n)}static stationsInDirection(t,o,n){return t.filter(t=>g(o,t.location)===n)}static closestStation(t,o){return t.reduce((t,n)=>p(o,t.location)<p(o,n.location)?t:n)}static randomCloseLargeStation(t,o,n){const i=y.stationsWithinRadius(t,o,n),e=i.map(t=>t.population);return c(i,e)}static isPointDistant(t,o,n){for(const i of o)if(p(t,i.location)<n)return!1;return!0}static randomDistantPoint(t,o){let n=100;for(;n>0;){const i=d();if(y.isPointDistant(i,t,o))return i;n-=1}return null}constructor(t,o,n,i){this.location=t,this.population=o,this.color=n,this.connections=i||[],x+=1,this.id=x,this.label=new PIXI.Text(`${this.id}`,{fill:"#FFA500",fontFamily:"monospace",fontSize:"12px"})}}const m=Math.floor(Math.sqrt(Math.pow(window.innerWidth,2)+Math.pow(window.innerHeight,2))/8);class b{constructor(t,o){this.name=t,this.color=o}connectStations(t,o,n,i){n.push(t);const e=o.filter(o=>o!==t),s=y.stationsWithinRadius(e,t.location,m);for(let o=0;o<i&&!(s.length<1);o+=1){const o=y.largestStation(s);t.connections.push(new a(o,this)),s.splice(s.indexOf(o),1)}for(const e of t.connections)-1===n.indexOf(e.station)&&this.connectStations(e.station,o,n,i)}}let S=0;class v{constructor(t,o,n,i,e,s){this.location=t,this.speed=o,this.origin=i,this.destination=e,this.passengers=n,this.color=s,this.sprite=new PIXI.Sprite(PIXI.loader.resources.nodeImg.texture),S+=1,this.id=S,this.label=new PIXI.Text(`${this.id}`,{fill:"#AEAEAE",fontFamily:"monospace",fontSize:"12px"})}boardPassengers(){this.location,this.origin.location}}var M=n(107);n(239),e.loader.add(
|
||
|
//# sourceMappingURL=main.min.js.map
|