Merge pull request #2 from DouweRavers/develop
fixed wrong vacancy generation bug.
This commit is contained in:
@@ -49,7 +49,7 @@ function buildRoads(){
|
|||||||
sId => {
|
sId => {
|
||||||
const source = Game.getObjectById(sId);
|
const source = Game.getObjectById(sId);
|
||||||
var roads = [];
|
var roads = [];
|
||||||
roads = roads.concat(source.pos.findPathTo(this.controller));
|
roads = roads.concat(source.pos.findPathTo(room.controller));
|
||||||
roads.pop();
|
roads.pop();
|
||||||
roads = roads.concat(source.pos.findPathTo(room.find(FIND_MY_STRUCTURES, { filter:{ structureType:STRUCTURE_SPAWN }})[0]));
|
roads = roads.concat(source.pos.findPathTo(room.find(FIND_MY_STRUCTURES, { filter:{ structureType:STRUCTURE_SPAWN }})[0]));
|
||||||
roads.pop();
|
roads.pop();
|
||||||
|
|||||||
13
RoomClass.js
13
RoomClass.js
@@ -29,11 +29,16 @@ function jobScan(room){
|
|||||||
|
|
||||||
function vacancyScan(room){
|
function vacancyScan(room){
|
||||||
const activeJobs = room.find(FIND_MY_CREEPS).map(creep=>creep.memory.job);
|
const activeJobs = room.find(FIND_MY_CREEPS).map(creep=>creep.memory.job);
|
||||||
const jobs = [].concat(room.memory.jobs);
|
console.log(activeJobs.toString());
|
||||||
activeJobs.forEach(job => {
|
console.log(room.memory.jobs.toString());
|
||||||
const index = jobs.indexOf(job);
|
const jobs = room.memory.jobs.filter((j)=>{
|
||||||
if(0 <= index) jobs.splice(index,1);
|
const index = activeJobs.findIndex(aj=> _.isEqual(aj,j));
|
||||||
|
if(index < 0) return true;
|
||||||
|
activeJobs.splice(index,1);
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
console.log(jobs.toString());
|
||||||
|
|
||||||
room.memory.vacancies = jobs;
|
room.memory.vacancies = jobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ class _StructureSpawn extends StructureSpawn {
|
|||||||
|
|
||||||
tick(){
|
tick(){
|
||||||
if(!this.memory.init) this.begin();
|
if(!this.memory.init) this.begin();
|
||||||
|
if(this.store.getUsedCapacity(RESOURCE_ENERGY) < 300) return;
|
||||||
const job = this.room.memory.vacancies.pop();
|
const job = this.room.memory.vacancies.pop();
|
||||||
if(job){
|
if(job){
|
||||||
const name = getJobName(job.role);
|
const name = getJobName(job.role);
|
||||||
|
|||||||
Reference in New Issue
Block a user