Files
screeps/ClassSpawn.js
DouweRavers 4e3ad07fff Improved performance of walking.
Switches to manual walking when close to target.
2022-05-01 00:52:48 +02:00

38 lines
792 B
JavaScript

module.exports = {
setup: function () { StructureSpawn.prototype = _Spawn.prototype; }
}
class _Spawn extends StructureSpawn {
init() {
}
requireNewCreep(role) {
const roleCount = this.room.find(FIND_MY_CREEPS, {
filter: (c) => { return c.memory.role == role; }
}).length;
switch (role) {
case ROLE_HARVESTER:
return roleCount < 10;
break;
default:
break;
}
}
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;
const response = this.spawnCreep(body, name + ": " + this.memory.creepCounter, {
memory: { role: role }
});
if (response == OK) this.memory.creepCounter++;
}
}