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

@@ -6,4 +6,32 @@ module.exports = {
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 < 5;
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++;
}
}