Improved harvester behaviour, reworked the job register system and added auto roadbuilding.
This commit is contained in:
@@ -2,18 +2,30 @@ module.exports = {
|
||||
setup: function () { StructureSpawn.prototype = _Spawn.prototype; }
|
||||
}
|
||||
|
||||
|
||||
class _Spawn extends StructureSpawn {
|
||||
|
||||
begin(){
|
||||
if (!this.memory.creepCounter) this.memory.creepCounter = 0;
|
||||
this.memory.init = true;
|
||||
}
|
||||
|
||||
tick(){
|
||||
if(!this.memory.init) this.begin();
|
||||
if(this.room.memory.jobs.length){
|
||||
const job = this.room.memory.jobs[0];
|
||||
const body = [WORK, CARRY, MOVE];
|
||||
const response = this.createCreep(body, "harvester", job);
|
||||
if(response == OK) this.room.memory.jobs.splice(0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
createHarvester() {
|
||||
var body = [WORK, CARRY, MOVE];
|
||||
this.createCreep(body, "harvester", Role.HARVESTER);
|
||||
}
|
||||
|
||||
createCreep(body, name, role) {
|
||||
if (this.memory.creepCounter == undefined) this.memory.creepCounter = 0;
|
||||
createCreep(body, name, job) {
|
||||
const response = this.spawnCreep(body, name + ": " + this.memory.creepCounter, {
|
||||
memory: { job: { role: role } }
|
||||
memory: { job: job }
|
||||
});
|
||||
if (response == OK) this.memory.creepCounter++;
|
||||
return response;
|
||||
|
||||
Reference in New Issue
Block a user