Builder Creeps and Extension Blueprints
This commit is contained in:
parent
48350d6f33
commit
5e6618edca
5 changed files with 62 additions and 10 deletions
16
src/RoomPlanner/Blueprints/Extensions.ts
Normal file
16
src/RoomPlanner/Blueprints/Extensions.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
const extentionsAvailable = (roomlevel: number) => {
|
||||
return roomlevel > 2 ? roomlevel * 10 - 20 : (roomlevel - 1) * 5;
|
||||
}
|
||||
|
||||
export const buildExtentions = (room: Room) => {
|
||||
const spawns = room.find(FIND_MY_SPAWNS);
|
||||
if (spawns.length < 1) return;
|
||||
const spawn = spawns[0];
|
||||
const exts = extentionsAvailable(room.controller?.level ?? 0)
|
||||
for (let x = -Math.floor(Math.sqrt(exts) / 2); x < Math.sqrt(exts) / 2; x++) {
|
||||
for (let y = -Math.floor(Math.sqrt(exts) / 2); y < Math.sqrt(exts) / 2; y++) {
|
||||
room.visual.circle(spawn.pos.x + x * 2, spawn.pos.y + y * 2);
|
||||
room.createConstructionSite(spawn.pos.x + x * 2, spawn.pos.y + y * 2, STRUCTURE_EXTENSION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2,9 +2,10 @@ export const buildRoads = (room: Room) => {
|
|||
if ((room.controller?.level ?? 0) < 2) {
|
||||
return;
|
||||
}
|
||||
const sources = room.find(FIND_SOURCES);
|
||||
const sources: _HasRoomPosition[] = room.find(FIND_SOURCES);
|
||||
const sourcesAndSpawns = sources.concat(room.find(FIND_MY_SPAWNS));
|
||||
room.visual.clear();
|
||||
for (const source of sources) {
|
||||
for (const source of sourcesAndSpawns) {
|
||||
for (const source2 of sources) {
|
||||
const path = source.pos.findPathTo(source2, {
|
||||
ignoreCreeps: true,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue