First working version of new system.

This commit is contained in:
DouweRavers
2022-04-30 14:23:44 +02:00
parent 3e962ed04a
commit 744b4a2478
9 changed files with 241 additions and 10 deletions

View File

@@ -13,6 +13,8 @@ class _Room extends Room {
if (this.controller.my && this.memory.state == ROOMSTATE_NEUTRAL) this.memory.state = ROOMSTATE_CAPITAL;
}
//#region Checks
// Is the level changed?
isNewLevel() {
if (this.memory.level == undefined) this.memory.level = -1;
@@ -21,7 +23,11 @@ class _Room extends Room {
return value;
}
// Is the max amount of construction sites achieved?
isConstructionQueueFull() { return this.find(FIND_CONSTRUCTION_SITES).length > 90; }
//#endregion
//#region Construcion
// Place construction sites for the road system.
planRoads() {
@@ -45,12 +51,18 @@ class _Room extends Room {
target_array[index++] = structure.pos;
});
// Also add all sources
// Add all sources to targets.
this.find(FIND_SOURCES).forEach(source => {
target_array[index++] = source.pos;
});
// Add minerals to targers
this.find(FIND_MINERALS).forEach(mineral => {
target_array[index++] = mineral.pos;
});
// Build a road for every permutation of the targets.
// TODO: When performance to high make this loop recoverable.
for (let i = 0; i < target_array.length; i++) {
const begin = target_array[i];
for (let j = 0; j < target_array.length; j++) {
@@ -72,4 +84,7 @@ class _Room extends Room {
planStructures() {
}
//#endregion
}