Add clerks

This commit is contained in:
uwap 2022-12-27 10:19:14 +01:00
parent 365fd17b01
commit 3bd6b0ac2c
9 changed files with 76 additions and 15 deletions

View file

@ -1,5 +1,9 @@
export const buildContainers = (room: Room) => {
if ((room.controller?.level ?? 0) < 2) {
const controller = room.controller;
if (controller == null) {
return;
}
if (controller.level < 2) {
return;
}
const sources = room.find(FIND_SOURCES);
@ -9,4 +13,17 @@ export const buildContainers = (room: Room) => {
room.createConstructionSite(source.pos.x, source.pos.y - 2, STRUCTURE_CONTAINER);
room.createConstructionSite(source.pos.x, source.pos.y + 2, STRUCTURE_CONTAINER);
}
if (controller.level < 4) {
return;
}
const terrain = room.getTerrain();
if (terrain.get(controller.pos.x, controller.pos.y - 3) !== TERRAIN_MASK_WALL) {
room.createConstructionSite(controller.pos.x, controller.pos.y - 3, STRUCTURE_STORAGE);
} else if (terrain.get(controller.pos.x, controller.pos.y + 3) !== TERRAIN_MASK_WALL) {
room.createConstructionSite(controller.pos.x, controller.pos.y + 3, STRUCTURE_STORAGE);
} else if (terrain.get(controller.pos.x - 3, controller.pos.y) !== TERRAIN_MASK_WALL) {
room.createConstructionSite(controller.pos.x - 3, controller.pos.y, STRUCTURE_STORAGE);
} else if (terrain.get(controller.pos.x + 3, controller.pos.y) !== TERRAIN_MASK_WALL) {
room.createConstructionSite(controller.pos.x + 3, controller.pos.y, STRUCTURE_STORAGE);
}
}