migrate from perforce

This commit is contained in:
2026-04-19 01:16:27 +02:00
commit d161a20915
1810 changed files with 1156171 additions and 0 deletions

42
dist/Util/PathFinding.js vendored Normal file
View File

@@ -0,0 +1,42 @@
import { ECellType } from "../Simulation/index.js";
import { Hex } from "./index.js";
export class PathFinding {
static bfs(level, startIndex, endIndex) {
const listToExplore = [startIndex];
let cameFrom = new Array(level.simCells.length);
cameFrom.fill(-1);
while (listToExplore.length > 0) {
const nodeIndex = listToExplore.shift();
const cell = level.simCells[nodeIndex];
for (let i = 0; i < 6; ++i) {
const neighbourHex = Hex.neighbour(cell.hex, i);
const neighbourIndex = level.getCellIndex(neighbourHex);
if (neighbourIndex === -1) {
continue;
}
const neighbourCell = level.simCells[neighbourIndex];
if (neighbourCell.type === ECellType.Blocked || neighbourCell.type === ECellType.Reserved || neighbourCell.simTower !== null) {
continue;
}
if (cameFrom[neighbourIndex] === -1) {
cameFrom[neighbourIndex] = nodeIndex;
if (neighbourIndex !== endIndex) {
listToExplore.push(neighbourIndex);
}
else {
let idx = neighbourIndex;
const path = [idx];
while (idx !== startIndex) {
const prev = cameFrom[idx];
idx = prev;
path.unshift(idx);
}
return path;
}
}
}
}
return null;
}
}
//# sourceMappingURL=PathFinding.js.map