Add a Road planner

This commit is contained in:
uwap 2022-12-21 13:40:06 +01:00
parent a73f1f7004
commit ed73f8330b
2 changed files with 26 additions and 1 deletions

View file

@ -0,0 +1,19 @@
export const buildRoads = (room: Room) => {
if (room.controller?.level ?? 0 < 2) {
return;
}
const sources = room.find(FIND_SOURCES);
room.visual.clear();
for (const source of sources) {
for (const source2 of sources) {
const path = source.pos.findPathTo(source2, {
ignoreCreeps: true,
ignoreRoads: true
});
for (const point of path) {
room.visual.line(point.x, point.y, point.x - point.dx, point.y - point.dy);
room.createConstructionSite(point.x, point.y, STRUCTURE_ROAD);
}
}
}
}