19 lines
682 B
JavaScript
19 lines
682 B
JavaScript
const path=require('path')
|
|
module.exports = {
|
|
run(creep) {
|
|
//分配source
|
|
if (creep.carry.energy < creep.carryCapacity) {
|
|
let sources = creep.room.find(FIND_SOURCES);
|
|
//TODO:只去一个地方
|
|
if (creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
|
|
creep.moveTo(sources[0]);
|
|
path.visualPath(creep.pos,sources[0].pos);
|
|
}
|
|
} else {
|
|
if (creep.transfer(Game.spawns['Spawn1'], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
|
creep.moveTo(Game.spawns['Spawn1']);
|
|
path.visualPath(creep.pos,Game.spawns['Spawn1'].pos);
|
|
}
|
|
}
|
|
}
|
|
} |