microboard-temp 0.5.75 → 0.5.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser.js +24 -58
- package/dist/cjs/index.js +24 -58
- package/dist/cjs/node.js +24 -58
- package/dist/esm/browser.js +24 -58
- package/dist/esm/index.js +24 -58
- package/dist/esm/node.js +24 -58
- package/dist/types/Settings.d.ts +1 -0
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -7073,7 +7073,8 @@ var conf = {
|
|
|
7073
7073
|
DECK_VERTICAL_OFFSET: 2,
|
|
7074
7074
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
7075
7075
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
7076
|
-
MAX_CARD_SIZE: 500
|
|
7076
|
+
MAX_CARD_SIZE: 500,
|
|
7077
|
+
CONNECTOR_ITEM_OFFSET: 20
|
|
7077
7078
|
};
|
|
7078
7079
|
initDefaultI18N();
|
|
7079
7080
|
|
|
@@ -36669,7 +36670,6 @@ function radiansBetweenPoints(point1, point22) {
|
|
|
36669
36670
|
}
|
|
36670
36671
|
|
|
36671
36672
|
// src/Items/Connector/getLine/findOrthogonalPath.ts
|
|
36672
|
-
var ITEM_OFFSET = 1;
|
|
36673
36673
|
function getDirection(from, to) {
|
|
36674
36674
|
if (!to) {
|
|
36675
36675
|
return null;
|
|
@@ -36712,7 +36712,7 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
36712
36712
|
for (const pos of potentialNeighbors) {
|
|
36713
36713
|
if (pos.x >= 0 && pos.x < grid.length && pos.y >= 0) {
|
|
36714
36714
|
const newPoint = grid[pos.x][pos.y];
|
|
36715
|
-
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint,
|
|
36715
|
+
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint, conf.CONNECTOR_ITEM_OFFSET - 1))) {
|
|
36716
36716
|
neighbors.push({
|
|
36717
36717
|
point: newPoint,
|
|
36718
36718
|
costSoFar: 0,
|
|
@@ -36760,69 +36760,24 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
36760
36760
|
const endDir = getPointerDirection(end);
|
|
36761
36761
|
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
36762
36762
|
const offsetMap = {
|
|
36763
|
-
top: { x: 0, y: -
|
|
36764
|
-
bottom: { x: 0, y:
|
|
36765
|
-
right: { x:
|
|
36766
|
-
left: { x: -
|
|
36763
|
+
top: { x: 0, y: -conf.CONNECTOR_ITEM_OFFSET },
|
|
36764
|
+
bottom: { x: 0, y: conf.CONNECTOR_ITEM_OFFSET },
|
|
36765
|
+
right: { x: conf.CONNECTOR_ITEM_OFFSET, y: 0 },
|
|
36766
|
+
left: { x: -conf.CONNECTOR_ITEM_OFFSET, y: 0 }
|
|
36767
36767
|
};
|
|
36768
36768
|
const horizontalLines = [];
|
|
36769
36769
|
const verticalLines = [];
|
|
36770
|
-
if (start.pointType !== "Board") {
|
|
36771
|
-
const itemMbr = start.item.getMbr();
|
|
36772
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
36773
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
36774
|
-
}
|
|
36775
|
-
if (end.pointType !== "Board") {
|
|
36776
|
-
const itemMbr = end.item.getMbr();
|
|
36777
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
36778
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
36779
|
-
}
|
|
36780
|
-
const tempStart = start;
|
|
36781
|
-
const tempEnd = end;
|
|
36782
|
-
const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
|
|
36783
|
-
horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
|
|
36784
|
-
verticalLines.push(middle.x, tempStart.x, tempEnd.x);
|
|
36785
|
-
toVisitPoints.forEach((p3) => {
|
|
36786
|
-
horizontalLines.push(p3.y);
|
|
36787
|
-
verticalLines.push(p3.x);
|
|
36788
|
-
});
|
|
36789
|
-
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
36790
|
-
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
36791
36770
|
let newStart;
|
|
36792
36771
|
let newEnd;
|
|
36793
36772
|
const processPoint = (point5, dir2) => {
|
|
36794
36773
|
const itemMbr = point5.item.getMbr();
|
|
36795
|
-
const
|
|
36774
|
+
const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
|
|
36775
|
+
const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
36796
36776
|
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
36797
|
-
|
|
36798
|
-
|
|
36799
|
-
|
|
36800
|
-
|
|
36801
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
36802
|
-
newPoint.x = pointOnMbr.x;
|
|
36803
|
-
}
|
|
36804
|
-
} else if (dir2 === "bottom") {
|
|
36805
|
-
const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
|
|
36806
|
-
const nextYIndex = currentYIndex + 1;
|
|
36807
|
-
if (nextYIndex < uniqueHorizontalLines.length) {
|
|
36808
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
36809
|
-
newPoint.x = pointOnMbr.x;
|
|
36810
|
-
}
|
|
36811
|
-
} else if (dir2 === "left") {
|
|
36812
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
36813
|
-
const nextXIndex = currentXIndex - 1;
|
|
36814
|
-
if (nextXIndex >= 0) {
|
|
36815
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
36816
|
-
newPoint.y = pointOnMbr.y;
|
|
36817
|
-
}
|
|
36818
|
-
} else if (dir2 === "right") {
|
|
36819
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
36820
|
-
const nextXIndex = currentXIndex + 1;
|
|
36821
|
-
if (nextXIndex < uniqueVerticalLines.length) {
|
|
36822
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
36823
|
-
newPoint.y = pointOnMbr.y;
|
|
36824
|
-
}
|
|
36825
|
-
}
|
|
36777
|
+
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
36778
|
+
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
36779
|
+
verticalLines.push(mbrFloored.left - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + conf.CONNECTOR_ITEM_OFFSET);
|
|
36780
|
+
horizontalLines.push(mbrFloored.top - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + conf.CONNECTOR_ITEM_OFFSET);
|
|
36826
36781
|
return newPoint;
|
|
36827
36782
|
};
|
|
36828
36783
|
if (start.pointType !== "Board" && startDir) {
|
|
@@ -36831,6 +36786,17 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
36831
36786
|
if (end.pointType !== "Board" && endDir) {
|
|
36832
36787
|
newEnd = processPoint(end, endDir);
|
|
36833
36788
|
}
|
|
36789
|
+
const finalStart = newStart || start;
|
|
36790
|
+
const finalEnd = newEnd || end;
|
|
36791
|
+
const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
|
|
36792
|
+
horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
|
|
36793
|
+
verticalLines.push(middle.x, finalStart.x, finalEnd.x);
|
|
36794
|
+
toVisitPoints.forEach((p3) => {
|
|
36795
|
+
horizontalLines.push(p3.y);
|
|
36796
|
+
verticalLines.push(p3.x);
|
|
36797
|
+
});
|
|
36798
|
+
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
36799
|
+
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
36834
36800
|
const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
|
|
36835
36801
|
return {
|
|
36836
36802
|
grid,
|
package/dist/cjs/index.js
CHANGED
|
@@ -7073,7 +7073,8 @@ var conf = {
|
|
|
7073
7073
|
DECK_VERTICAL_OFFSET: 2,
|
|
7074
7074
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
7075
7075
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
7076
|
-
MAX_CARD_SIZE: 500
|
|
7076
|
+
MAX_CARD_SIZE: 500,
|
|
7077
|
+
CONNECTOR_ITEM_OFFSET: 20
|
|
7077
7078
|
};
|
|
7078
7079
|
initDefaultI18N();
|
|
7079
7080
|
|
|
@@ -36669,7 +36670,6 @@ function radiansBetweenPoints(point1, point22) {
|
|
|
36669
36670
|
}
|
|
36670
36671
|
|
|
36671
36672
|
// src/Items/Connector/getLine/findOrthogonalPath.ts
|
|
36672
|
-
var ITEM_OFFSET = 1;
|
|
36673
36673
|
function getDirection(from, to) {
|
|
36674
36674
|
if (!to) {
|
|
36675
36675
|
return null;
|
|
@@ -36712,7 +36712,7 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
36712
36712
|
for (const pos of potentialNeighbors) {
|
|
36713
36713
|
if (pos.x >= 0 && pos.x < grid.length && pos.y >= 0) {
|
|
36714
36714
|
const newPoint = grid[pos.x][pos.y];
|
|
36715
|
-
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint,
|
|
36715
|
+
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint, conf.CONNECTOR_ITEM_OFFSET - 1))) {
|
|
36716
36716
|
neighbors.push({
|
|
36717
36717
|
point: newPoint,
|
|
36718
36718
|
costSoFar: 0,
|
|
@@ -36760,69 +36760,24 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
36760
36760
|
const endDir = getPointerDirection(end);
|
|
36761
36761
|
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
36762
36762
|
const offsetMap = {
|
|
36763
|
-
top: { x: 0, y: -
|
|
36764
|
-
bottom: { x: 0, y:
|
|
36765
|
-
right: { x:
|
|
36766
|
-
left: { x: -
|
|
36763
|
+
top: { x: 0, y: -conf.CONNECTOR_ITEM_OFFSET },
|
|
36764
|
+
bottom: { x: 0, y: conf.CONNECTOR_ITEM_OFFSET },
|
|
36765
|
+
right: { x: conf.CONNECTOR_ITEM_OFFSET, y: 0 },
|
|
36766
|
+
left: { x: -conf.CONNECTOR_ITEM_OFFSET, y: 0 }
|
|
36767
36767
|
};
|
|
36768
36768
|
const horizontalLines = [];
|
|
36769
36769
|
const verticalLines = [];
|
|
36770
|
-
if (start.pointType !== "Board") {
|
|
36771
|
-
const itemMbr = start.item.getMbr();
|
|
36772
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
36773
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
36774
|
-
}
|
|
36775
|
-
if (end.pointType !== "Board") {
|
|
36776
|
-
const itemMbr = end.item.getMbr();
|
|
36777
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
36778
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
36779
|
-
}
|
|
36780
|
-
const tempStart = start;
|
|
36781
|
-
const tempEnd = end;
|
|
36782
|
-
const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
|
|
36783
|
-
horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
|
|
36784
|
-
verticalLines.push(middle.x, tempStart.x, tempEnd.x);
|
|
36785
|
-
toVisitPoints.forEach((p3) => {
|
|
36786
|
-
horizontalLines.push(p3.y);
|
|
36787
|
-
verticalLines.push(p3.x);
|
|
36788
|
-
});
|
|
36789
|
-
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
36790
|
-
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
36791
36770
|
let newStart;
|
|
36792
36771
|
let newEnd;
|
|
36793
36772
|
const processPoint = (point5, dir2) => {
|
|
36794
36773
|
const itemMbr = point5.item.getMbr();
|
|
36795
|
-
const
|
|
36774
|
+
const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
|
|
36775
|
+
const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
36796
36776
|
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
36797
|
-
|
|
36798
|
-
|
|
36799
|
-
|
|
36800
|
-
|
|
36801
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
36802
|
-
newPoint.x = pointOnMbr.x;
|
|
36803
|
-
}
|
|
36804
|
-
} else if (dir2 === "bottom") {
|
|
36805
|
-
const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
|
|
36806
|
-
const nextYIndex = currentYIndex + 1;
|
|
36807
|
-
if (nextYIndex < uniqueHorizontalLines.length) {
|
|
36808
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
36809
|
-
newPoint.x = pointOnMbr.x;
|
|
36810
|
-
}
|
|
36811
|
-
} else if (dir2 === "left") {
|
|
36812
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
36813
|
-
const nextXIndex = currentXIndex - 1;
|
|
36814
|
-
if (nextXIndex >= 0) {
|
|
36815
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
36816
|
-
newPoint.y = pointOnMbr.y;
|
|
36817
|
-
}
|
|
36818
|
-
} else if (dir2 === "right") {
|
|
36819
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
36820
|
-
const nextXIndex = currentXIndex + 1;
|
|
36821
|
-
if (nextXIndex < uniqueVerticalLines.length) {
|
|
36822
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
36823
|
-
newPoint.y = pointOnMbr.y;
|
|
36824
|
-
}
|
|
36825
|
-
}
|
|
36777
|
+
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
36778
|
+
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
36779
|
+
verticalLines.push(mbrFloored.left - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + conf.CONNECTOR_ITEM_OFFSET);
|
|
36780
|
+
horizontalLines.push(mbrFloored.top - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + conf.CONNECTOR_ITEM_OFFSET);
|
|
36826
36781
|
return newPoint;
|
|
36827
36782
|
};
|
|
36828
36783
|
if (start.pointType !== "Board" && startDir) {
|
|
@@ -36831,6 +36786,17 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
36831
36786
|
if (end.pointType !== "Board" && endDir) {
|
|
36832
36787
|
newEnd = processPoint(end, endDir);
|
|
36833
36788
|
}
|
|
36789
|
+
const finalStart = newStart || start;
|
|
36790
|
+
const finalEnd = newEnd || end;
|
|
36791
|
+
const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
|
|
36792
|
+
horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
|
|
36793
|
+
verticalLines.push(middle.x, finalStart.x, finalEnd.x);
|
|
36794
|
+
toVisitPoints.forEach((p3) => {
|
|
36795
|
+
horizontalLines.push(p3.y);
|
|
36796
|
+
verticalLines.push(p3.x);
|
|
36797
|
+
});
|
|
36798
|
+
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
36799
|
+
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
36834
36800
|
const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
|
|
36835
36801
|
return {
|
|
36836
36802
|
grid,
|
package/dist/cjs/node.js
CHANGED
|
@@ -8110,7 +8110,8 @@ var conf = {
|
|
|
8110
8110
|
DECK_VERTICAL_OFFSET: 2,
|
|
8111
8111
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
8112
8112
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
8113
|
-
MAX_CARD_SIZE: 500
|
|
8113
|
+
MAX_CARD_SIZE: 500,
|
|
8114
|
+
CONNECTOR_ITEM_OFFSET: 20
|
|
8114
8115
|
};
|
|
8115
8116
|
initDefaultI18N();
|
|
8116
8117
|
|
|
@@ -39142,7 +39143,6 @@ function radiansBetweenPoints(point1, point22) {
|
|
|
39142
39143
|
}
|
|
39143
39144
|
|
|
39144
39145
|
// src/Items/Connector/getLine/findOrthogonalPath.ts
|
|
39145
|
-
var ITEM_OFFSET = 1;
|
|
39146
39146
|
function getDirection(from, to) {
|
|
39147
39147
|
if (!to) {
|
|
39148
39148
|
return null;
|
|
@@ -39185,7 +39185,7 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
39185
39185
|
for (const pos of potentialNeighbors) {
|
|
39186
39186
|
if (pos.x >= 0 && pos.x < grid.length && pos.y >= 0) {
|
|
39187
39187
|
const newPoint = grid[pos.x][pos.y];
|
|
39188
|
-
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint,
|
|
39188
|
+
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint, conf.CONNECTOR_ITEM_OFFSET - 1))) {
|
|
39189
39189
|
neighbors.push({
|
|
39190
39190
|
point: newPoint,
|
|
39191
39191
|
costSoFar: 0,
|
|
@@ -39233,69 +39233,24 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
39233
39233
|
const endDir = getPointerDirection(end);
|
|
39234
39234
|
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
39235
39235
|
const offsetMap = {
|
|
39236
|
-
top: { x: 0, y: -
|
|
39237
|
-
bottom: { x: 0, y:
|
|
39238
|
-
right: { x:
|
|
39239
|
-
left: { x: -
|
|
39236
|
+
top: { x: 0, y: -conf.CONNECTOR_ITEM_OFFSET },
|
|
39237
|
+
bottom: { x: 0, y: conf.CONNECTOR_ITEM_OFFSET },
|
|
39238
|
+
right: { x: conf.CONNECTOR_ITEM_OFFSET, y: 0 },
|
|
39239
|
+
left: { x: -conf.CONNECTOR_ITEM_OFFSET, y: 0 }
|
|
39240
39240
|
};
|
|
39241
39241
|
const horizontalLines = [];
|
|
39242
39242
|
const verticalLines = [];
|
|
39243
|
-
if (start.pointType !== "Board") {
|
|
39244
|
-
const itemMbr = start.item.getMbr();
|
|
39245
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
39246
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
39247
|
-
}
|
|
39248
|
-
if (end.pointType !== "Board") {
|
|
39249
|
-
const itemMbr = end.item.getMbr();
|
|
39250
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
39251
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
39252
|
-
}
|
|
39253
|
-
const tempStart = start;
|
|
39254
|
-
const tempEnd = end;
|
|
39255
|
-
const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
|
|
39256
|
-
horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
|
|
39257
|
-
verticalLines.push(middle.x, tempStart.x, tempEnd.x);
|
|
39258
|
-
toVisitPoints.forEach((p3) => {
|
|
39259
|
-
horizontalLines.push(p3.y);
|
|
39260
|
-
verticalLines.push(p3.x);
|
|
39261
|
-
});
|
|
39262
|
-
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
39263
|
-
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
39264
39243
|
let newStart;
|
|
39265
39244
|
let newEnd;
|
|
39266
39245
|
const processPoint = (point5, dir2) => {
|
|
39267
39246
|
const itemMbr = point5.item.getMbr();
|
|
39268
|
-
const
|
|
39247
|
+
const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
|
|
39248
|
+
const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
39269
39249
|
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
39270
|
-
|
|
39271
|
-
|
|
39272
|
-
|
|
39273
|
-
|
|
39274
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
39275
|
-
newPoint.x = pointOnMbr.x;
|
|
39276
|
-
}
|
|
39277
|
-
} else if (dir2 === "bottom") {
|
|
39278
|
-
const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
|
|
39279
|
-
const nextYIndex = currentYIndex + 1;
|
|
39280
|
-
if (nextYIndex < uniqueHorizontalLines.length) {
|
|
39281
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
39282
|
-
newPoint.x = pointOnMbr.x;
|
|
39283
|
-
}
|
|
39284
|
-
} else if (dir2 === "left") {
|
|
39285
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
39286
|
-
const nextXIndex = currentXIndex - 1;
|
|
39287
|
-
if (nextXIndex >= 0) {
|
|
39288
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
39289
|
-
newPoint.y = pointOnMbr.y;
|
|
39290
|
-
}
|
|
39291
|
-
} else if (dir2 === "right") {
|
|
39292
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
39293
|
-
const nextXIndex = currentXIndex + 1;
|
|
39294
|
-
if (nextXIndex < uniqueVerticalLines.length) {
|
|
39295
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
39296
|
-
newPoint.y = pointOnMbr.y;
|
|
39297
|
-
}
|
|
39298
|
-
}
|
|
39250
|
+
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
39251
|
+
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
39252
|
+
verticalLines.push(mbrFloored.left - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + conf.CONNECTOR_ITEM_OFFSET);
|
|
39253
|
+
horizontalLines.push(mbrFloored.top - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + conf.CONNECTOR_ITEM_OFFSET);
|
|
39299
39254
|
return newPoint;
|
|
39300
39255
|
};
|
|
39301
39256
|
if (start.pointType !== "Board" && startDir) {
|
|
@@ -39304,6 +39259,17 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
39304
39259
|
if (end.pointType !== "Board" && endDir) {
|
|
39305
39260
|
newEnd = processPoint(end, endDir);
|
|
39306
39261
|
}
|
|
39262
|
+
const finalStart = newStart || start;
|
|
39263
|
+
const finalEnd = newEnd || end;
|
|
39264
|
+
const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
|
|
39265
|
+
horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
|
|
39266
|
+
verticalLines.push(middle.x, finalStart.x, finalEnd.x);
|
|
39267
|
+
toVisitPoints.forEach((p3) => {
|
|
39268
|
+
horizontalLines.push(p3.y);
|
|
39269
|
+
verticalLines.push(p3.x);
|
|
39270
|
+
});
|
|
39271
|
+
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
39272
|
+
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
39307
39273
|
const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
|
|
39308
39274
|
return {
|
|
39309
39275
|
grid,
|
package/dist/esm/browser.js
CHANGED
|
@@ -6909,7 +6909,8 @@ var conf = {
|
|
|
6909
6909
|
DECK_VERTICAL_OFFSET: 2,
|
|
6910
6910
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
6911
6911
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
6912
|
-
MAX_CARD_SIZE: 500
|
|
6912
|
+
MAX_CARD_SIZE: 500,
|
|
6913
|
+
CONNECTOR_ITEM_OFFSET: 20
|
|
6913
6914
|
};
|
|
6914
6915
|
initDefaultI18N();
|
|
6915
6916
|
|
|
@@ -36514,7 +36515,6 @@ function radiansBetweenPoints(point1, point22) {
|
|
|
36514
36515
|
}
|
|
36515
36516
|
|
|
36516
36517
|
// src/Items/Connector/getLine/findOrthogonalPath.ts
|
|
36517
|
-
var ITEM_OFFSET = 1;
|
|
36518
36518
|
function getDirection(from, to) {
|
|
36519
36519
|
if (!to) {
|
|
36520
36520
|
return null;
|
|
@@ -36557,7 +36557,7 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
36557
36557
|
for (const pos of potentialNeighbors) {
|
|
36558
36558
|
if (pos.x >= 0 && pos.x < grid.length && pos.y >= 0) {
|
|
36559
36559
|
const newPoint = grid[pos.x][pos.y];
|
|
36560
|
-
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint,
|
|
36560
|
+
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint, conf.CONNECTOR_ITEM_OFFSET - 1))) {
|
|
36561
36561
|
neighbors.push({
|
|
36562
36562
|
point: newPoint,
|
|
36563
36563
|
costSoFar: 0,
|
|
@@ -36605,69 +36605,24 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
36605
36605
|
const endDir = getPointerDirection(end);
|
|
36606
36606
|
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
36607
36607
|
const offsetMap = {
|
|
36608
|
-
top: { x: 0, y: -
|
|
36609
|
-
bottom: { x: 0, y:
|
|
36610
|
-
right: { x:
|
|
36611
|
-
left: { x: -
|
|
36608
|
+
top: { x: 0, y: -conf.CONNECTOR_ITEM_OFFSET },
|
|
36609
|
+
bottom: { x: 0, y: conf.CONNECTOR_ITEM_OFFSET },
|
|
36610
|
+
right: { x: conf.CONNECTOR_ITEM_OFFSET, y: 0 },
|
|
36611
|
+
left: { x: -conf.CONNECTOR_ITEM_OFFSET, y: 0 }
|
|
36612
36612
|
};
|
|
36613
36613
|
const horizontalLines = [];
|
|
36614
36614
|
const verticalLines = [];
|
|
36615
|
-
if (start.pointType !== "Board") {
|
|
36616
|
-
const itemMbr = start.item.getMbr();
|
|
36617
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
36618
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
36619
|
-
}
|
|
36620
|
-
if (end.pointType !== "Board") {
|
|
36621
|
-
const itemMbr = end.item.getMbr();
|
|
36622
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
36623
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
36624
|
-
}
|
|
36625
|
-
const tempStart = start;
|
|
36626
|
-
const tempEnd = end;
|
|
36627
|
-
const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
|
|
36628
|
-
horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
|
|
36629
|
-
verticalLines.push(middle.x, tempStart.x, tempEnd.x);
|
|
36630
|
-
toVisitPoints.forEach((p3) => {
|
|
36631
|
-
horizontalLines.push(p3.y);
|
|
36632
|
-
verticalLines.push(p3.x);
|
|
36633
|
-
});
|
|
36634
|
-
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
36635
|
-
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
36636
36615
|
let newStart;
|
|
36637
36616
|
let newEnd;
|
|
36638
36617
|
const processPoint = (point5, dir2) => {
|
|
36639
36618
|
const itemMbr = point5.item.getMbr();
|
|
36640
|
-
const
|
|
36619
|
+
const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
|
|
36620
|
+
const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
36641
36621
|
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
36642
|
-
|
|
36643
|
-
|
|
36644
|
-
|
|
36645
|
-
|
|
36646
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
36647
|
-
newPoint.x = pointOnMbr.x;
|
|
36648
|
-
}
|
|
36649
|
-
} else if (dir2 === "bottom") {
|
|
36650
|
-
const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
|
|
36651
|
-
const nextYIndex = currentYIndex + 1;
|
|
36652
|
-
if (nextYIndex < uniqueHorizontalLines.length) {
|
|
36653
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
36654
|
-
newPoint.x = pointOnMbr.x;
|
|
36655
|
-
}
|
|
36656
|
-
} else if (dir2 === "left") {
|
|
36657
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
36658
|
-
const nextXIndex = currentXIndex - 1;
|
|
36659
|
-
if (nextXIndex >= 0) {
|
|
36660
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
36661
|
-
newPoint.y = pointOnMbr.y;
|
|
36662
|
-
}
|
|
36663
|
-
} else if (dir2 === "right") {
|
|
36664
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
36665
|
-
const nextXIndex = currentXIndex + 1;
|
|
36666
|
-
if (nextXIndex < uniqueVerticalLines.length) {
|
|
36667
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
36668
|
-
newPoint.y = pointOnMbr.y;
|
|
36669
|
-
}
|
|
36670
|
-
}
|
|
36622
|
+
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
36623
|
+
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
36624
|
+
verticalLines.push(mbrFloored.left - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + conf.CONNECTOR_ITEM_OFFSET);
|
|
36625
|
+
horizontalLines.push(mbrFloored.top - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + conf.CONNECTOR_ITEM_OFFSET);
|
|
36671
36626
|
return newPoint;
|
|
36672
36627
|
};
|
|
36673
36628
|
if (start.pointType !== "Board" && startDir) {
|
|
@@ -36676,6 +36631,17 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
36676
36631
|
if (end.pointType !== "Board" && endDir) {
|
|
36677
36632
|
newEnd = processPoint(end, endDir);
|
|
36678
36633
|
}
|
|
36634
|
+
const finalStart = newStart || start;
|
|
36635
|
+
const finalEnd = newEnd || end;
|
|
36636
|
+
const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
|
|
36637
|
+
horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
|
|
36638
|
+
verticalLines.push(middle.x, finalStart.x, finalEnd.x);
|
|
36639
|
+
toVisitPoints.forEach((p3) => {
|
|
36640
|
+
horizontalLines.push(p3.y);
|
|
36641
|
+
verticalLines.push(p3.x);
|
|
36642
|
+
});
|
|
36643
|
+
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
36644
|
+
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
36679
36645
|
const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
|
|
36680
36646
|
return {
|
|
36681
36647
|
grid,
|
package/dist/esm/index.js
CHANGED
|
@@ -6902,7 +6902,8 @@ var conf = {
|
|
|
6902
6902
|
DECK_VERTICAL_OFFSET: 2,
|
|
6903
6903
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
6904
6904
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
6905
|
-
MAX_CARD_SIZE: 500
|
|
6905
|
+
MAX_CARD_SIZE: 500,
|
|
6906
|
+
CONNECTOR_ITEM_OFFSET: 20
|
|
6906
6907
|
};
|
|
6907
6908
|
initDefaultI18N();
|
|
6908
6909
|
|
|
@@ -36507,7 +36508,6 @@ function radiansBetweenPoints(point1, point22) {
|
|
|
36507
36508
|
}
|
|
36508
36509
|
|
|
36509
36510
|
// src/Items/Connector/getLine/findOrthogonalPath.ts
|
|
36510
|
-
var ITEM_OFFSET = 1;
|
|
36511
36511
|
function getDirection(from, to) {
|
|
36512
36512
|
if (!to) {
|
|
36513
36513
|
return null;
|
|
@@ -36550,7 +36550,7 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
36550
36550
|
for (const pos of potentialNeighbors) {
|
|
36551
36551
|
if (pos.x >= 0 && pos.x < grid.length && pos.y >= 0) {
|
|
36552
36552
|
const newPoint = grid[pos.x][pos.y];
|
|
36553
|
-
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint,
|
|
36553
|
+
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint, conf.CONNECTOR_ITEM_OFFSET - 1))) {
|
|
36554
36554
|
neighbors.push({
|
|
36555
36555
|
point: newPoint,
|
|
36556
36556
|
costSoFar: 0,
|
|
@@ -36598,69 +36598,24 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
36598
36598
|
const endDir = getPointerDirection(end);
|
|
36599
36599
|
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
36600
36600
|
const offsetMap = {
|
|
36601
|
-
top: { x: 0, y: -
|
|
36602
|
-
bottom: { x: 0, y:
|
|
36603
|
-
right: { x:
|
|
36604
|
-
left: { x: -
|
|
36601
|
+
top: { x: 0, y: -conf.CONNECTOR_ITEM_OFFSET },
|
|
36602
|
+
bottom: { x: 0, y: conf.CONNECTOR_ITEM_OFFSET },
|
|
36603
|
+
right: { x: conf.CONNECTOR_ITEM_OFFSET, y: 0 },
|
|
36604
|
+
left: { x: -conf.CONNECTOR_ITEM_OFFSET, y: 0 }
|
|
36605
36605
|
};
|
|
36606
36606
|
const horizontalLines = [];
|
|
36607
36607
|
const verticalLines = [];
|
|
36608
|
-
if (start.pointType !== "Board") {
|
|
36609
|
-
const itemMbr = start.item.getMbr();
|
|
36610
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
36611
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
36612
|
-
}
|
|
36613
|
-
if (end.pointType !== "Board") {
|
|
36614
|
-
const itemMbr = end.item.getMbr();
|
|
36615
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
36616
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
36617
|
-
}
|
|
36618
|
-
const tempStart = start;
|
|
36619
|
-
const tempEnd = end;
|
|
36620
|
-
const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
|
|
36621
|
-
horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
|
|
36622
|
-
verticalLines.push(middle.x, tempStart.x, tempEnd.x);
|
|
36623
|
-
toVisitPoints.forEach((p3) => {
|
|
36624
|
-
horizontalLines.push(p3.y);
|
|
36625
|
-
verticalLines.push(p3.x);
|
|
36626
|
-
});
|
|
36627
|
-
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
36628
|
-
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
36629
36608
|
let newStart;
|
|
36630
36609
|
let newEnd;
|
|
36631
36610
|
const processPoint = (point5, dir2) => {
|
|
36632
36611
|
const itemMbr = point5.item.getMbr();
|
|
36633
|
-
const
|
|
36612
|
+
const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
|
|
36613
|
+
const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
36634
36614
|
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
36635
|
-
|
|
36636
|
-
|
|
36637
|
-
|
|
36638
|
-
|
|
36639
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
36640
|
-
newPoint.x = pointOnMbr.x;
|
|
36641
|
-
}
|
|
36642
|
-
} else if (dir2 === "bottom") {
|
|
36643
|
-
const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
|
|
36644
|
-
const nextYIndex = currentYIndex + 1;
|
|
36645
|
-
if (nextYIndex < uniqueHorizontalLines.length) {
|
|
36646
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
36647
|
-
newPoint.x = pointOnMbr.x;
|
|
36648
|
-
}
|
|
36649
|
-
} else if (dir2 === "left") {
|
|
36650
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
36651
|
-
const nextXIndex = currentXIndex - 1;
|
|
36652
|
-
if (nextXIndex >= 0) {
|
|
36653
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
36654
|
-
newPoint.y = pointOnMbr.y;
|
|
36655
|
-
}
|
|
36656
|
-
} else if (dir2 === "right") {
|
|
36657
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
36658
|
-
const nextXIndex = currentXIndex + 1;
|
|
36659
|
-
if (nextXIndex < uniqueVerticalLines.length) {
|
|
36660
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
36661
|
-
newPoint.y = pointOnMbr.y;
|
|
36662
|
-
}
|
|
36663
|
-
}
|
|
36615
|
+
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
36616
|
+
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
36617
|
+
verticalLines.push(mbrFloored.left - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + conf.CONNECTOR_ITEM_OFFSET);
|
|
36618
|
+
horizontalLines.push(mbrFloored.top - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + conf.CONNECTOR_ITEM_OFFSET);
|
|
36664
36619
|
return newPoint;
|
|
36665
36620
|
};
|
|
36666
36621
|
if (start.pointType !== "Board" && startDir) {
|
|
@@ -36669,6 +36624,17 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
36669
36624
|
if (end.pointType !== "Board" && endDir) {
|
|
36670
36625
|
newEnd = processPoint(end, endDir);
|
|
36671
36626
|
}
|
|
36627
|
+
const finalStart = newStart || start;
|
|
36628
|
+
const finalEnd = newEnd || end;
|
|
36629
|
+
const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
|
|
36630
|
+
horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
|
|
36631
|
+
verticalLines.push(middle.x, finalStart.x, finalEnd.x);
|
|
36632
|
+
toVisitPoints.forEach((p3) => {
|
|
36633
|
+
horizontalLines.push(p3.y);
|
|
36634
|
+
verticalLines.push(p3.x);
|
|
36635
|
+
});
|
|
36636
|
+
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
36637
|
+
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
36672
36638
|
const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
|
|
36673
36639
|
return {
|
|
36674
36640
|
grid,
|
package/dist/esm/node.js
CHANGED
|
@@ -7686,7 +7686,8 @@ var conf = {
|
|
|
7686
7686
|
DECK_VERTICAL_OFFSET: 2,
|
|
7687
7687
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
7688
7688
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
7689
|
-
MAX_CARD_SIZE: 500
|
|
7689
|
+
MAX_CARD_SIZE: 500,
|
|
7690
|
+
CONNECTOR_ITEM_OFFSET: 20
|
|
7690
7691
|
};
|
|
7691
7692
|
initDefaultI18N();
|
|
7692
7693
|
|
|
@@ -38975,7 +38976,6 @@ function radiansBetweenPoints(point1, point22) {
|
|
|
38975
38976
|
}
|
|
38976
38977
|
|
|
38977
38978
|
// src/Items/Connector/getLine/findOrthogonalPath.ts
|
|
38978
|
-
var ITEM_OFFSET = 1;
|
|
38979
38979
|
function getDirection(from, to) {
|
|
38980
38980
|
if (!to) {
|
|
38981
38981
|
return null;
|
|
@@ -39018,7 +39018,7 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
39018
39018
|
for (const pos of potentialNeighbors) {
|
|
39019
39019
|
if (pos.x >= 0 && pos.x < grid.length && pos.y >= 0) {
|
|
39020
39020
|
const newPoint = grid[pos.x][pos.y];
|
|
39021
|
-
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint,
|
|
39021
|
+
if (newPoint && !obstacles.some((obstacle) => obstacle.isAlmostInside(newPoint, conf.CONNECTOR_ITEM_OFFSET - 1))) {
|
|
39022
39022
|
neighbors.push({
|
|
39023
39023
|
point: newPoint,
|
|
39024
39024
|
costSoFar: 0,
|
|
@@ -39066,69 +39066,24 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
39066
39066
|
const endDir = getPointerDirection(end);
|
|
39067
39067
|
const revertMapDir = { top: 0, bottom: 1, right: 2, left: 3 };
|
|
39068
39068
|
const offsetMap = {
|
|
39069
|
-
top: { x: 0, y: -
|
|
39070
|
-
bottom: { x: 0, y:
|
|
39071
|
-
right: { x:
|
|
39072
|
-
left: { x: -
|
|
39069
|
+
top: { x: 0, y: -conf.CONNECTOR_ITEM_OFFSET },
|
|
39070
|
+
bottom: { x: 0, y: conf.CONNECTOR_ITEM_OFFSET },
|
|
39071
|
+
right: { x: conf.CONNECTOR_ITEM_OFFSET, y: 0 },
|
|
39072
|
+
left: { x: -conf.CONNECTOR_ITEM_OFFSET, y: 0 }
|
|
39073
39073
|
};
|
|
39074
39074
|
const horizontalLines = [];
|
|
39075
39075
|
const verticalLines = [];
|
|
39076
|
-
if (start.pointType !== "Board") {
|
|
39077
|
-
const itemMbr = start.item.getMbr();
|
|
39078
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
39079
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
39080
|
-
}
|
|
39081
|
-
if (end.pointType !== "Board") {
|
|
39082
|
-
const itemMbr = end.item.getMbr();
|
|
39083
|
-
verticalLines.push(itemMbr.left - ITEM_OFFSET, itemMbr.left, itemMbr.right, itemMbr.right + ITEM_OFFSET);
|
|
39084
|
-
horizontalLines.push(itemMbr.top - ITEM_OFFSET, itemMbr.top, itemMbr.bottom, itemMbr.bottom + ITEM_OFFSET);
|
|
39085
|
-
}
|
|
39086
|
-
const tempStart = start;
|
|
39087
|
-
const tempEnd = end;
|
|
39088
|
-
const middle = new Point((tempStart.x + tempEnd.x) / 2, (tempStart.y + tempEnd.y) / 2);
|
|
39089
|
-
horizontalLines.push(middle.y, tempStart.y, tempEnd.y);
|
|
39090
|
-
verticalLines.push(middle.x, tempStart.x, tempEnd.x);
|
|
39091
|
-
toVisitPoints.forEach((p3) => {
|
|
39092
|
-
horizontalLines.push(p3.y);
|
|
39093
|
-
verticalLines.push(p3.x);
|
|
39094
|
-
});
|
|
39095
|
-
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
39096
|
-
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
39097
39076
|
let newStart;
|
|
39098
39077
|
let newEnd;
|
|
39099
39078
|
const processPoint = (point5, dir2) => {
|
|
39100
39079
|
const itemMbr = point5.item.getMbr();
|
|
39101
|
-
const
|
|
39080
|
+
const mbrFloored = new Mbr(Math.floor(itemMbr.left), Math.floor(itemMbr.top), Math.floor(itemMbr.right), Math.floor(itemMbr.bottom));
|
|
39081
|
+
const pointOnMbr = mbrFloored.getLines()[revertMapDir[dir2]].getNearestPointOnLineSegment(point5);
|
|
39102
39082
|
const newPoint = Object.create(Object.getPrototypeOf(point5), Object.getOwnPropertyDescriptors(point5));
|
|
39103
|
-
|
|
39104
|
-
|
|
39105
|
-
|
|
39106
|
-
|
|
39107
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
39108
|
-
newPoint.x = pointOnMbr.x;
|
|
39109
|
-
}
|
|
39110
|
-
} else if (dir2 === "bottom") {
|
|
39111
|
-
const currentYIndex = uniqueHorizontalLines.findIndex((y) => Math.abs(y - pointOnMbr.y) < 0.01);
|
|
39112
|
-
const nextYIndex = currentYIndex + 1;
|
|
39113
|
-
if (nextYIndex < uniqueHorizontalLines.length) {
|
|
39114
|
-
newPoint.y = uniqueHorizontalLines[nextYIndex];
|
|
39115
|
-
newPoint.x = pointOnMbr.x;
|
|
39116
|
-
}
|
|
39117
|
-
} else if (dir2 === "left") {
|
|
39118
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
39119
|
-
const nextXIndex = currentXIndex - 1;
|
|
39120
|
-
if (nextXIndex >= 0) {
|
|
39121
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
39122
|
-
newPoint.y = pointOnMbr.y;
|
|
39123
|
-
}
|
|
39124
|
-
} else if (dir2 === "right") {
|
|
39125
|
-
const currentXIndex = uniqueVerticalLines.findIndex((x) => Math.abs(x - pointOnMbr.x) < 0.01);
|
|
39126
|
-
const nextXIndex = currentXIndex + 1;
|
|
39127
|
-
if (nextXIndex < uniqueVerticalLines.length) {
|
|
39128
|
-
newPoint.x = uniqueVerticalLines[nextXIndex];
|
|
39129
|
-
newPoint.y = pointOnMbr.y;
|
|
39130
|
-
}
|
|
39131
|
-
}
|
|
39083
|
+
newPoint.x = pointOnMbr.x + offsetMap[dir2].x;
|
|
39084
|
+
newPoint.y = pointOnMbr.y + offsetMap[dir2].y;
|
|
39085
|
+
verticalLines.push(mbrFloored.left - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.left, pointOnMbr.x, mbrFloored.right, mbrFloored.right + conf.CONNECTOR_ITEM_OFFSET);
|
|
39086
|
+
horizontalLines.push(mbrFloored.top - conf.CONNECTOR_ITEM_OFFSET, mbrFloored.top, pointOnMbr.y, mbrFloored.bottom, mbrFloored.bottom + conf.CONNECTOR_ITEM_OFFSET);
|
|
39132
39087
|
return newPoint;
|
|
39133
39088
|
};
|
|
39134
39089
|
if (start.pointType !== "Board" && startDir) {
|
|
@@ -39137,6 +39092,17 @@ function createGrid(start, end, toVisitPoints = []) {
|
|
|
39137
39092
|
if (end.pointType !== "Board" && endDir) {
|
|
39138
39093
|
newEnd = processPoint(end, endDir);
|
|
39139
39094
|
}
|
|
39095
|
+
const finalStart = newStart || start;
|
|
39096
|
+
const finalEnd = newEnd || end;
|
|
39097
|
+
const middle = new Point((finalStart.x + finalEnd.x) / 2, (finalStart.y + finalEnd.y) / 2);
|
|
39098
|
+
horizontalLines.push(middle.y, finalStart.y, finalEnd.y);
|
|
39099
|
+
verticalLines.push(middle.x, finalStart.x, finalEnd.x);
|
|
39100
|
+
toVisitPoints.forEach((p3) => {
|
|
39101
|
+
horizontalLines.push(p3.y);
|
|
39102
|
+
verticalLines.push(p3.x);
|
|
39103
|
+
});
|
|
39104
|
+
const uniqueHorizontalLines = Array.from(new Set(horizontalLines)).sort((a2, b) => a2 - b);
|
|
39105
|
+
const uniqueVerticalLines = Array.from(new Set(verticalLines)).sort((a2, b) => a2 - b);
|
|
39140
39106
|
const grid = uniqueVerticalLines.map((x) => uniqueHorizontalLines.map((y) => new Point(x, y)));
|
|
39141
39107
|
return {
|
|
39142
39108
|
grid,
|
package/dist/types/Settings.d.ts
CHANGED