Skip to content

Commit

Permalink
Correctly disable bays when they have an overfull extension, even if …
Browse files Browse the repository at this point in the history
…it's inactive.
  • Loading branch information
Mirroar committed Apr 26, 2024
1 parent f4a1e0a commit 5341d0a
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/manager.bay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,23 @@ export default class Bay {
}

// Bay is also considered blocked if one of it's extensions is overfull.
for (const structure of this.extensions) {
if (structure.store.getUsedCapacity(RESOURCE_ENERGY) > structure.store.getCapacity(RESOURCE_ENERGY)) {
return true;
}
}

const hasOverfullExtension = cache.inHeap(
'has-overfull-extensions:' + this.name,
250,
() => {
const room = Game.rooms[this.pos.roomName];
for (const structure of (room.structuresByType[STRUCTURE_EXTENSION]) || []) {
if (structure.pos.getRangeTo(this.pos) > 1) continue;
if (structure.store.getUsedCapacity(RESOURCE_ENERGY) > structure.store.getCapacity(RESOURCE_ENERGY)) {
return true;
}
}

return false;
},
);
if (hasOverfullExtension) return true;

// Do not add extensions to bay if another important structure is in the bay.
const importantStructures = this.pos.findInRange(FIND_STRUCTURES, 1, {
filter: structure => (problematicStructures as string[]).includes(structure.structureType) && structure.isOperational(),
Expand Down

0 comments on commit 5341d0a

Please sign in to comment.