First working version of new system.
This commit is contained in:
17
ClassRoom.js
17
ClassRoom.js
@@ -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
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user