Skip to content
This repository was archived by the owner on Jul 6, 2022. It is now read-only.

Commit b04a00a

Browse files
committed
Success! #50 is done.
1 parent f4fa8c9 commit b04a00a

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

app/js/maps/system_map.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,19 @@ var SystemMap = {
368368
jump = {type: gate.type};
369369
if (gate.type == 'wormhole') {
370370
// exclude nodes that are outside this region from being anchored
371-
if (from.system.regionID == Data.state.vicinity.regionId && to.system.regionID != Data.state.vicinity.regionId) {
371+
if (from.system.regionID == system.regionID && to.system.regionID != system.regionID) {
372372
exclude.push(to.system.id);
373+
delete to.x;
374+
delete to.y;
375+
delete to.system.x;
376+
delete to.system.y;
373377
}
374-
else if (to.system.regionID == Data.state.vicinity.regionId && from.system.regionID != Data.state.vicinity.regionId) {
378+
else if (to.system.regionID == system.regionID && from.system.regionID != system.regionID) {
375379
exclude.push(from.system.id);
376-
console.log(to)
377-
380+
delete from.x;
381+
delete from.y;
382+
delete from.system.x;
383+
delete from.system.y;
378384
}
379385

380386
// pin the wormhole close to the connecting node
@@ -423,14 +429,14 @@ var SystemMap = {
423429
.chargeDistance(200 * SCALING_FACTOR)
424430
.linkDistance(function(l) {
425431
if (l.type == 'jumpbridge') return 0;
426-
if (l.type == 'wormhole') return 0;
432+
if (l.type == 'wormhole') return 20;
427433
if (l.source.fixed || l.target.fixed) return 0;
428434
var dx = l.source.x - l.target.x, dy = l.source.y - l.target.y;
429435
return Math.min(50 * SCALING_FACTOR, Math.sqrt(dx * dx + dy * dy));
430436
})
431437
.linkStrength(function(l) {
432438
if (l.type == 'jumpbridge') return 0;
433-
if (l.type == 'wormhole') return 0;
439+
if (l.type == 'wormhole') return 0.2;
434440
if (l.source.fixed || l.target.fixed) return 0.1;
435441
return 0.25;
436442
});

app/js/maps/wormhole_map.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ var WormholeMap = {
218218
WormholeMap.links = [];
219219

220220
var nodes = {};
221+
var exclude = [];
221222

222223
WormholeMap.systems = $.map(Data.systems, function(s) {
223224
// var node = { system: s, x: s.x, y: s.y };
@@ -231,6 +232,16 @@ var WormholeMap = {
231232
var from = Data.systems[gate.fromSystem];
232233
var to = Data.systems[gate.toSystem];
233234
jump = {source: nodes[from.id], target: nodes[to.id], type: gate.type};
235+
if (from.regionID == system.regionID && to.regionID != system.regionID) {
236+
exclude.push(to.id);
237+
delete to.x;
238+
delete to.y;
239+
}
240+
else if (to.regionID == system.regionID && from.regionID != system.regionID) {
241+
exclude.push(from.id);
242+
delete from.x;
243+
delete from.y;
244+
}
234245

235246
if (gate.type == 'wormhole') {
236247
if (to.y === undefined && to.x === undefined) {
@@ -254,7 +265,7 @@ var WormholeMap = {
254265
system.x *= SCALING_FACTOR;
255266
system.y *= SCALING_FACTOR;
256267
WormholeMap.nodes.push(system);
257-
if (!Util.is_wormhole(system.system)) {
268+
if (!Util.is_wormhole(system.system) || $.grep(exclude, function(id) { return id == system.id; })) {
258269
WormholeMap.nodes.push(anchor = { x: system.x, y: system.y, fixed: true });
259270
WormholeMap.links.push({ source: system, target: anchor });
260271
}

0 commit comments

Comments
 (0)